-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into svelte-bump-version
- Loading branch information
Showing
8 changed files
with
107 additions
and
23 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
90 changes: 90 additions & 0 deletions
90
apps/playground/src/pages/svelte/getting-started/state.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,90 @@ | ||
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"; | ||
|
||
export default function SvelteState() { | ||
return ( | ||
<TwoColumnsScroll | ||
sidebarTo="svelteState" | ||
title="Get Wallet State" | ||
leftSection={Left()} | ||
rightSection={Right()} | ||
/> | ||
); | ||
} | ||
|
||
function Left() { | ||
let code = ``; | ||
code += `<script lang="ts">\n`; | ||
code += ` import { BrowserWalletState } from "@meshsdk/svelte";\n`; | ||
code += `\n`; | ||
code += ` const { wallet, connected, name, connecting, connect, disconnect } = BrowserWalletState;\n`; | ||
code += `</script>`; | ||
|
||
return ( | ||
<> | ||
<p> | ||
Provide information on the current wallet's state, and functions for | ||
connecting and disconnecting user wallet. | ||
</p> | ||
<Codeblock data={code} /> | ||
<p> | ||
<code>wallet</code> is a{" "} | ||
<Link href="/apis/wallets/browserwallet">Browser Wallet</Link> instance, | ||
which expose all CIP wallets functions from getting assets to signing | ||
tranasction. | ||
</p> | ||
<p> | ||
<code>connected</code>, a boolean, <code>true</code> if user's wallet is | ||
connected. | ||
</p> | ||
<p> | ||
<code>name</code>, a string, the name of the connect wallet. | ||
</p> | ||
<p> | ||
<code>connecting</code>, a boolean, <code>true</code> if the wallet is | ||
connecting and initializing. | ||
</p> | ||
<p> | ||
<code>connect(walletName: string)</code>, a function, provide the wallet | ||
name to connect wallet. Retrive a list of available wallets with{" "} | ||
<code>useWalletList()</code>. | ||
</p> | ||
<p> | ||
<code>disconnect()</code>, a function, to disconnect the connected | ||
wallet. | ||
</p> | ||
</> | ||
); | ||
} | ||
|
||
function Right() { | ||
let example = ``; | ||
example += `<script lang="ts">\n`; | ||
example += ` import { CardanoWallet, BrowserWalletState } from "@meshsdk/svelte";\n`; | ||
example += `\n`; | ||
example += ` export async function getAddress() {\n`; | ||
example += ` const { wallet } = BrowserWalletState;\n`; | ||
example += `\n`; | ||
example += ` if (wallet) {\n`; | ||
example += ` const address = await wallet.getChangeAddress();\n`; | ||
example += ` console.log(address);\n`; | ||
example += ` }\n`; | ||
example += ` }\n`; | ||
example += `</script>\n`; | ||
example += `\n`; | ||
example += `<main>\n`; | ||
example += ` <CardanoWallet />\n`; | ||
example += ` <button on:click={getAddress}>getAddress</button>\n`; | ||
example += `</div>\n`; | ||
|
||
return ( | ||
<LiveCodeDemo | ||
title="Wallet State" | ||
subtitle="Get the current wallet's state" | ||
code={example} | ||
childrenAfterCodeFunctions={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
4 changes: 2 additions & 2 deletions
4
packages/mesh-svelte/src/lib/cardano-wallet/component/index.ts
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import Root from "./connect-wallet-button.svelte"; | ||
import { type ConnectWalletButtonProps } from "./types"; | ||
import { type CardanoWalletButtonProps } from "./types"; | ||
|
||
export { Root as ConnectWallet, type ConnectWalletButtonProps }; | ||
export { Root as CardanoWallet, type CardanoWalletButtonProps }; |
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