Skip to content

Commit

Permalink
add setNetwork
Browse files Browse the repository at this point in the history
  • Loading branch information
jinglescode committed Aug 26, 2024
1 parent f70d314 commit f2dfd5f
Show file tree
Hide file tree
Showing 34 changed files with 66 additions and 58 deletions.
4 changes: 2 additions & 2 deletions apps/playground/src/components/cardano/mint-mesh-token.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MeshWallet, ForgeScript, Mint, Transaction } from "@meshsdk/core";
import { ForgeScript, MeshWallet, Mint, Transaction } from "@meshsdk/core";
import { useWallet } from "@meshsdk/react";

import { demoAssetMetadata, demoMnemonic } from "~/data/cardano";
Expand Down Expand Up @@ -34,7 +34,7 @@ export default function MintMeshToken() {
recipient: address,
};

const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.mintAsset(forgingScript, asset);

const unsignedTx = await tx.build();
Expand Down
2 changes: 1 addition & 1 deletion apps/playground/src/pages/aiken/transactions/lock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function Right() {
fields: [hash],
};

const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.sendLovelace(
{
address: scriptAddress,
Expand Down
1 change: 1 addition & 0 deletions apps/playground/src/pages/aiken/transactions/redeem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ function Right() {
const redeemer = { data: { alternative: 0, fields: ["Hello, World!"] } };

const tx = new Transaction({ initiator: wallet })
.setNetwork("preprod")
.redeemValue({
value: assetUtxo,
script: script,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function Right() {
const beginId = await provider.resolveAddress(handle);
const address = beginId.address;

const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.sendLovelace(address, amount);

const unsignedTx = await tx.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function Right() {
);

async function runDemo() {
const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.setMetadata(674, {
msg: message.split("\n"),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function Right() {
const blockchainprovider = getProvider("mainnet");
const address = await blockchainprovider.fetchHandleAddress(handle);

const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.sendLovelace(address, amount);

const unsignedTx = await tx.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function Right() {
recipient: address,
};

const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork('preprod');
tx.mintAsset(forgingScript, asset);

const unsignedTx = await tx.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function Right() {
const [amount, setAmount] = useState<string>("1");

async function runDemo() {
const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.sendAssets({ address: address }, [
{
unit: asset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ function Right() {
const tx = new Transaction({
initiator: wallet,
verbose: true,
}).sendLovelace(address, amount);
})
.setNetwork("preprod")
.sendLovelace(address, amount);

const unsignedTx = await tx.build();
const signedTx = await wallet.signTx(unsignedTx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function Right() {
const utxo = utxos[0];

if (utxo) {
const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.sendValue(await wallet.getChangeAddress(), utxo);

const unsignedTx = await tx.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function Right() {
const utxo = (await wallet.getUtxos())[0];

if (utxo) {
const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.setCollateral([utxo]);

const unsignedTx = await tx.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function Right() {
);

async function runDemo() {
const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.setMetadata(0, message);

const unsignedTx = await tx.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function Right() {
const { wallet, connected } = useWallet();

async function runDemo() {
const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.setRequiredSigners(await wallet.getUsedAddresses());

const unsignedTx = await tx.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function Right(userInput: string, setUserInput: (value: string) => void) {
};

// create transaction
const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.burnAsset(forgingScript, asset);

const unsignedTx = await tx.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ function Right() {
};

const tx = new Transaction({ initiator: wallet })
.setNetwork("preprod")
.setTxInputs([utxos[0]!])
.mintAsset(script, cip68Token, redeemer);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function Right() {
recipient: address,
};

const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.mintAsset(forgingScript, asset1);
tx.setTimeToExpire("99999999");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import Link from "~/components/link";

import { AssetMetadata, ForgeScript, Mint, Transaction } from "@meshsdk/core";
import { useWallet } from "@meshsdk/react";

import Link from "~/components/link";
import LiveCodeDemo from "~/components/sections/live-code-demo";
import TwoColumnsScroll from "~/components/sections/two-columns-scroll";
import Codeblock from "~/components/text/codeblock";
Expand Down Expand Up @@ -104,7 +103,7 @@ function Right() {
};

// create transaction
const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.mintAsset(forgingScript, asset);

const unsignedTx = await tx.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ function Right(userInput: string, setUserInput: (value: string) => void) {
};

const tx = new Transaction({ initiator: wallet })
.setNetwork("preprod")
.mintAsset(script, asset, redeemer)
.setRequiredSigners([address]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function Right() {

const forgingScript = ForgeScript.withOneSignature(address);

const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");

const _assetMetadata: RoyaltiesStandard = {
rate: userInput,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useState } from "react";
import Link from "~/components/link";

import {
Asset,
Expand All @@ -10,6 +9,7 @@ import {
import { useWallet } from "@meshsdk/react";

import Input from "~/components/form/input";
import Link from "~/components/link";
import InputTable from "~/components/sections/input-table";
import LiveCodeDemo from "~/components/sections/live-code-demo";
import TwoColumnsScroll from "~/components/sections/two-columns-scroll";
Expand Down Expand Up @@ -135,7 +135,7 @@ function Right() {
];

// transaction
const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.sendAssets(
{
address: scriptAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ function Right() {
const address = await wallet.getChangeAddress();

const tx = new Transaction({ initiator: wallet })
.setNetwork("preprod")
.redeemValue({
value: assetUtxo,
script: script as PlutusScript,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function Right() {
throw "No address found";
}

const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.delegateStake(rewardAddress, userInput);

const unsignedTx = await tx.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function Right() {
throw "No address found";
}

const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.deregisterStake(rewardAddress);

const unsignedTx = await tx.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function Right() {
throw "No address found";
}

const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.registerStake(rewardAddress);
tx.delegateStake(rewardAddress, userInput);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function Right() {
throw "No address found";
}

const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.withdrawRewards(rewardAddress, userInput);

const unsignedTx = await tx.build();
Expand Down
5 changes: 3 additions & 2 deletions apps/playground/src/pages/apis/txbuilder/common.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { MeshTxBuilder } from "@meshsdk/core";
import { CSLSerializer } from "@meshsdk/core-csl";

import { getProvider } from "~/components/cardano/mesh-wallet";

export function getTxBuilder() {
const blockchainProvider = getProvider();
return new MeshTxBuilder({
const txBuilder = new MeshTxBuilder({
fetcher: blockchainProvider,
evaluator: blockchainProvider,
});
txBuilder.setNetwork("preprod");
return txBuilder;
}

export default function Placeholder() {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Transaction } from "@meshsdk/core";
import { resolveTxHash } from "@meshsdk/core";
import { resolveTxHash, Transaction } from "@meshsdk/core";
import { useWallet } from "@meshsdk/react";

import { getMeshWallet } from "~/components/cardano/mesh-wallet";
Expand Down Expand Up @@ -34,7 +33,7 @@ function Right() {
const { wallet, connected } = useWallet();

async function runDemo() {
const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.sendLovelace(demoAddresses.testnet, "1500000");
const unsignedTx = await tx.build();
const hash1 = resolveTxHash(unsignedTx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export function getContract(wallet: BrowserWallet) {
const meshTxBuilder = new MeshTxBuilder({
fetcher: blockchainProvider,
submitter: blockchainProvider,
verbose: true,
});

const contract = new MeshGiftCardContract({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function Right() {
},
});

const tx = new Transaction({ initiator: wallet });
const tx = new Transaction({ initiator: wallet }).setNetwork("preprod");
tx.sendLovelace(userInput, "1000000");

const unsignedTx = await tx.build();
Expand Down
19 changes: 15 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f2dfd5f

Please sign in to comment.