Skip to content

Commit

Permalink
Update zkSend docs (#19170)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan-Mysten authored Sep 5, 2024
1 parent 2d01996 commit 22844ae
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/clever-suits-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@mysten/zksend': patch
---

Add network param to zksend links
2 changes: 2 additions & 0 deletions sdk/docs/pages/dapp-kit/stashed.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ To enable support for Stashed wallets, pass the `stashedWallet` object to the `W
component. This object has the following properties:

- **`name`** - The name of your dApp, shown to the user when connecting to the dApp.
- **`network`** _(optional)_ - The network that you would like the Stashed wallet to use. Defaults
to `mainnet`, supports `mainnet` and `testnet`.

```tsx
function App({ children }) {
Expand Down
4 changes: 2 additions & 2 deletions sdk/docs/pages/dapp-kit/wallet-provider.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ All props are optional.
- `enableUnsafeBurner` - Enables the development-only unsafe burner wallet, useful for testing.
- `autoConnect` - Enables automatically reconnecting to the most recently used wallet account upon
mounting.
- `zkSend` - Enables and configures the zkSend wallet. Read more about how to
[use the zkSend integration](./zksend.mdx).
- `stashedWallet` - Enables and configures the Stashed wallet. Read more about how to
[use the Stashed integration](./stashed.mdx).
- `storage` - Configures how the most recently connected-to wallet account is stored. Set to `null`
to disable persisting state entirely. Defaults to using `localStorage` if it is available.
- `storageKey` - The key to use to store the most recently connected wallet account.
Expand Down
2 changes: 2 additions & 0 deletions sdk/docs/pages/zksend/dapp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ your application's lifecycle.
connection in Stashed.
- `options`: An optional object with the following properties:
- `origin`: The origin of the Stashed website. Defaults to `https://getstashed.com`.
- `network`: The network that you would like the Stashed wallet to use. Defaults to `mainnet`,
supports `mainnet` and `testnet`.

```ts
import { registerStashedWallet } from '@mysten/zksend';
Expand Down
4 changes: 3 additions & 1 deletion sdk/docs/pages/zksend/link-builder.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Callout } from 'nextra/components';

## Limitations

- zkSend only supports Mainnet at this time.
- zkSend only supports Mainnet and Testnet at this time.
- Objects within links must be publicly transferrable.

## Create a link
Expand All @@ -27,6 +27,8 @@ constructor takes an object with the following options:
- **`name`** - The name of your dApp. This will be shown to the user when claiming the link.
- **`client`** (optional) - The `@mysten/sui` client used to fetch data to construct the link. If
not provided, a default client will be used.
- **`network`** (optional) - The Sui network that the link will be created for. Defaults to
`mainnet`.

```ts
import { ZkSendLinkBuilder } from '@mysten/zksend';
Expand Down
6 changes: 6 additions & 0 deletions sdk/zksend/src/links/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export class ZkSendLinkBuilder {
}[] = [];
balances = new Map<string, bigint>();
sender: string;
network: 'mainnet' | 'testnet';
#host: string;
#path: string;
keypair: Keypair;
Expand All @@ -78,6 +79,7 @@ export class ZkSendLinkBuilder {
this.keypair = keypair;
this.#client = client;
this.sender = normalizeSuiAddress(sender);
this.network = network;

if (contract) {
this.#contract = new ZkBag(contract.packageId, contract);
Expand Down Expand Up @@ -108,6 +110,10 @@ export class ZkSendLinkBuilder {
decodeSuiPrivateKey(this.keypair.getSecretKey()).secretKey,
)}`;

if (this.network !== 'mainnet') {
link.searchParams.set('network', this.network);
}

if (this.#redirect) {
link.searchParams.set('redirect_url', this.#redirect.url);
if (this.#redirect.name) {
Expand Down
2 changes: 2 additions & 0 deletions sdk/zksend/src/links/claim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export class ZkSendLink {
link = new ZkSendLink({
...options,
keypair,
network: parsed.searchParams.get('network') === 'testnet' ? 'testnet' : 'mainnet',
host: `${parsed.protocol}//${parsed.host}`,
path: parsed.pathname,
isContractLink: true,
Expand All @@ -142,6 +143,7 @@ export class ZkSendLink {
link = new ZkSendLink({
...options,
keypair,
network: parsed.searchParams.get('network') === 'testnet' ? 'testnet' : 'mainnet',
host: `${parsed.protocol}//${parsed.host}`,
path: parsed.pathname,
isContractLink: false,
Expand Down

0 comments on commit 22844ae

Please sign in to comment.