-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #251 from MeshJS/v1.6.2
v1.6.2
- Loading branch information
Showing
140 changed files
with
3,321 additions
and
995 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
apps/playground/src/components/cardano/mint-mesh-token.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { MeshWallet, ForgeScript, Mint, Transaction } from "@meshsdk/core"; | ||
import { useWallet } from "@meshsdk/react"; | ||
|
||
import { demoAssetMetadata, demoMnemonic } from "~/data/cardano"; | ||
import LiveCodeDemo from "../sections/live-code-demo"; | ||
import { getProvider } from "./mesh-wallet"; | ||
|
||
export default function MintMeshToken() { | ||
const { wallet, connected } = useWallet(); | ||
|
||
async function runDemo() { | ||
const blockchainProvider = getProvider(); | ||
const mintingWallet = new MeshWallet({ | ||
networkId: 0, | ||
fetcher: blockchainProvider, | ||
submitter: blockchainProvider, | ||
key: { | ||
type: "mnemonic", | ||
words: demoMnemonic, | ||
}, | ||
}); | ||
const forgingScript = ForgeScript.withOneSignature( | ||
mintingWallet.getChangeAddress(), | ||
); | ||
|
||
const usedAddress = await wallet.getUsedAddresses(); | ||
const address = usedAddress[0]; | ||
|
||
const asset: Mint = { | ||
assetName: "MeshToken", | ||
assetQuantity: "1", | ||
metadata: demoAssetMetadata, | ||
label: "721", | ||
recipient: address, | ||
}; | ||
|
||
const tx = new Transaction({ initiator: wallet }); | ||
tx.mintAsset(forgingScript, asset); | ||
|
||
const unsignedTx = await tx.build(); | ||
const signedTx = await wallet.signTx(unsignedTx, true); | ||
const signedTx2 = await mintingWallet.signTx(signedTx, true); | ||
const txHash = await wallet.submitTx(signedTx2); | ||
return txHash; | ||
} | ||
|
||
return ( | ||
<LiveCodeDemo | ||
title="Mint Mesh Token" | ||
subtitle="Mint a Mesh Token to try demos" | ||
runCodeFunction={runDemo} | ||
disabled={!connected} | ||
runDemoButtonTooltip={ | ||
!connected ? "Connect wallet to run this demo" : undefined | ||
} | ||
runDemoShowBrowseWalletConnect={true} | ||
hideDemoButtonIfnotConnected={true} | ||
hideConnectButtonIfConnected={true} | ||
></LiveCodeDemo> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.