Skip to content

Commit c0f0009

Browse files
committed
fix some todos
1 parent fc0add8 commit c0f0009

File tree

5 files changed

+300
-3
lines changed

5 files changed

+300
-3
lines changed

packages/enoki/README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,76 @@
11
# `@mysten/enoki`
2+
3+
zkLogin authentication and sponsored transactions. Enable users to sign in with Google, Twitch, Facebook, and other OAuth providers, and execute transactions without gas fees.
4+
5+
## Features
6+
7+
- **zkLogin**: Authenticate users with OAuth providers (Google, Twitch, Facebook)
8+
- **Sponsored Transactions**: Execute transactions without requiring users to hold gas
9+
- **Wallet Integration**: Register Enoki wallets with dApp Kit
10+
- **Subname Management**: Create and manage SuiNS subnames
11+
12+
## Installation
13+
14+
```sh
15+
npm install @mysten/enoki
16+
```
17+
18+
## Quick Start
19+
20+
### Register Enoki wallets
21+
22+
```ts
23+
import { registerEnokiWallets } from '@mysten/enoki';
24+
25+
registerEnokiWallets({
26+
apiKey: 'your-enoki-api-key',
27+
providers: ['google', 'twitch', 'facebook'],
28+
});
29+
```
30+
31+
### Use with React and dApp Kit
32+
33+
```tsx
34+
import { registerEnokiWallets } from '@mysten/enoki';
35+
import { useEnokiFlow } from '@mysten/enoki/react';
36+
37+
// In your app setup
38+
registerEnokiWallets({
39+
apiKey: 'your-enoki-api-key',
40+
providers: ['google'],
41+
});
42+
43+
// In your component
44+
function LoginButton() {
45+
const { login } = useEnokiFlow();
46+
47+
return <button onClick={() => login('google')}>Sign in with Google</button>;
48+
}
49+
```
50+
51+
### Low-level client usage
52+
53+
```ts
54+
import { EnokiClient } from '@mysten/enoki';
55+
56+
const client = new EnokiClient({
57+
apiKey: 'your-enoki-api-key',
58+
});
59+
60+
// Create a sponsored transaction
61+
const sponsored = await client.createSponsoredTransaction({
62+
network: 'mainnet',
63+
sender: '0x...',
64+
transactionKindBytes: '...',
65+
});
66+
67+
// Execute it
68+
await client.executeSponsoredTransaction({
69+
digest: sponsored.digest,
70+
signature: '...',
71+
});
72+
```
73+
74+
## Documentation
75+
76+
See the [Enoki documentation](https://docs.enoki.mystenlabs.com) for detailed setup and usage.

packages/enoki/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@mysten/enoki",
33
"version": "0.13.0",
4-
"description": "TODO: Description",
4+
"description": "zkLogin authentication and sponsored transactions",
55
"license": "Apache-2.0",
66
"author": "Mysten Labs <[email protected]>",
77
"type": "module",

packages/walrus/src/utils/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export const MAX_SYMBOL_SIZE_BY_ENCODING_TYPE = {
2222
RedStuff: 2 ** 16 - 1,
2323
};
2424

25-
// TODO: this name is kinda bad
2625
export function encodedBlobLength(
2726
unencodedLength: number,
2827
nShards: number,

packages/zksend/README.md

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,224 @@
11
# `@mysten/zksend`
2+
3+
Create claimable links for transferring coins and NFTs. Recipients can claim assets via URL without needing a wallet set up beforehand.
4+
5+
## Installation
6+
7+
```sh
8+
npm install @mysten/zksend
9+
```
10+
11+
## Limitations
12+
13+
- zkSend only supports Mainnet and Testnet at this time.
14+
- Objects within links must be publicly transferrable.
15+
16+
## Create a link
17+
18+
You can start creating your own zkSend link using the `ZkSendLinkBuilder` class. This class
19+
constructor takes an object with the following options:
20+
21+
- **`sender`** (required) - The address of the sender / creator of the link.
22+
- **`client`** (optional) - The `@mysten/sui` client used to fetch data to construct the link. If not provided, a default client will be used.
23+
- **`network`** (optional) - The network that the link will be created for. Defaults to `mainnet`.
24+
25+
```ts
26+
import { ZkSendLinkBuilder } from '@mysten/zksend';
27+
28+
const link = new ZkSendLinkBuilder({
29+
sender: '0x...',
30+
});
31+
```
32+
33+
### Adding SUI to the link
34+
35+
You can add SUI to the link by calling `link.addClaimableMist()`. This method takes the following params:
36+
37+
- **`amount`** (required) - The amount of MIST (the base unit of SUI) to add to the link.
38+
39+
### Adding non-SUI coins to the link
40+
41+
You can add non-SUI coins to the link by calling `link.addClaimableBalance()`. This method takes the following params:
42+
43+
- **`coinType`** (required) - The coin type of the coin to add to the link (e.g. `0x2::sui::SUI`).
44+
- **`amount`** (required) - The amount of the coin to add to the link. Represented in the base unit of the coin.
45+
46+
The SDK will automatically perform the necessary coin management logic to transfer the defined amount, such as merging and splitting coin objects.
47+
48+
### Adding objects to the link
49+
50+
You can add a publicly-transferrable object to the link by calling `link.addClaimableObject()`. This method takes the following params:
51+
52+
- **`id`** (required) - The ID of the object. This must be owned by the `sender` you configured when creating the link.
53+
54+
### Adding objects created in the same transaction
55+
56+
You can create objects to add to links in the same transaction the link is created in by using `link.addClaimableObjectRef()`:
57+
58+
- **`ref`** (required) - The reference to the object you want to add to the link.
59+
- **`type`** (required) - The move type of the object you are adding
60+
61+
```ts
62+
const tx = new Transaction();
63+
64+
const link = new ZkSendLinkBuilder({
65+
sender: '0x...',
66+
});
67+
68+
const newObject = tx.moveCall({
69+
target: `${PACKAGE_ID}::your_module::mint`,
70+
});
71+
72+
link.addClaimableObjectRef({
73+
ref: newObject,
74+
type: `${PACKAGE_ID}::your_module::YourType`,
75+
});
76+
77+
// Adds the link creation transactions to the transaction
78+
link.createSendTransaction({
79+
transaction: tx,
80+
});
81+
```
82+
83+
### Getting the link URL
84+
85+
At any time, you can get the URL for the link by calling `link.getLink()`.
86+
87+
## Submitting the link transaction
88+
89+
Once you have built your zkSend link, you need to execute a transaction to transfer assets and make the link claimable.
90+
91+
You can call the `link.createSendTransaction()` method, which returns a `Transaction` object that you can sign and submit.
92+
93+
```ts
94+
const tx = await link.createSendTransaction();
95+
96+
const { bytes, signature } = tx.sign({ client, signer: keypair });
97+
98+
const result = await client.executeTransactionBlock({
99+
transactionBlock: bytes,
100+
signature,
101+
});
102+
```
103+
104+
If you have a keypair you would like to send the transaction with, you can use the `create` method as shorthand for creating the send transaction, signing it, and submitting it:
105+
106+
```ts
107+
await link.create({
108+
signer: yourKeypair,
109+
// Wait until the new link is ready to be indexed so it is claimable
110+
waitForTransaction: true,
111+
});
112+
```
113+
114+
## Claiming a link
115+
116+
To claim a link via the SDK you can use the `ZkSendLink` class:
117+
118+
```ts
119+
import { ZkSendLink } from '@mysten/zksend';
120+
121+
// create a link instance from a URL
122+
const link = await ZkSendLink.fromUrl('https://zksend.com/claim#$abc...');
123+
124+
// list what claimable assets the link has
125+
const { nfts, balances } = link.assets;
126+
127+
// claim all the assets from the link
128+
await link.claimAssets(addressOfClaimer);
129+
```
130+
131+
## Listing links you have created
132+
133+
To list the links created by a specific address, you can use the `listCreatedLinks` function:
134+
135+
```ts
136+
import { listCreatedLinks } from '@mysten/zksend';
137+
138+
const { links, hasNextPage, cursor } = await listCreatedLinks({
139+
address: addressOfCreator,
140+
});
141+
142+
// get the claimable assets for this link (will be empty if the link has been claimed)
143+
const { nfts, balances } = await links[0].assets;
144+
```
145+
146+
## Listing transactions and the links they created
147+
148+
`getSentTransactionsWithLinks` will return a list of transactions sent by the provided address. Each result will include the transaction that was sent, along with an array containing any links that were created or regenerated by that transaction.
149+
150+
```ts
151+
import { getSentTransactionsWithLinks } from '@mysten/zksend';
152+
153+
const { data, hasNextPage, nextCursor } = await getSentTransactionsWithLinks({
154+
address: addressOfCreator,
155+
});
156+
157+
for (const { transaction, links } of data) {
158+
// get the claimable assets for this link (will be empty if the link has been claimed)
159+
const firstLink = links[0];
160+
161+
// link is claimed
162+
firstLink.claimed;
163+
const { nfts, balances } = firstLink.assets;
164+
165+
// claim link
166+
await firstLink.link.claimAssets(addressOfClaimer);
167+
}
168+
```
169+
170+
By default `getSentTransactionsWithLinks` will not load the assets for claimed links. This can be changed by passing `loadClaimedAssets: true` to the function.
171+
172+
## Regenerating links
173+
174+
If you lose a link you've created, you can re-generate the link (this can only done from the address that originally created the link):
175+
176+
```ts
177+
import { listCreatedLinks } from '@mysten/zksend';
178+
179+
const { links, hasNextPage, cursor } = await listCreatedLinks({
180+
address: addressOfCreator,
181+
});
182+
183+
// url will be the new link url
184+
const { url, transaction } = await links[0].link.createRegenerateTransaction(addressOfLinkCreator);
185+
186+
// Execute the transaction to regenerate the link
187+
const result = await client.signAndExecuteTransaction({
188+
transaction,
189+
signer: keypair,
190+
});
191+
```
192+
193+
## Bulk link creation
194+
195+
To create multiple links in a single transaction, you can use `ZkSendLinkBuilder.createLinks`:
196+
197+
```ts
198+
const links = [];
199+
200+
for (let i = 0; i < 10; i++) {
201+
const link = new ZkSendLinkBuilder({
202+
client,
203+
sender: keypair.toSuiAddress(),
204+
});
205+
206+
link.addClaimableMist(100n);
207+
links.push(link);
208+
}
209+
210+
const urls = links.map((link) => link.getLink());
211+
212+
const tx = await ZkSendLinkBuilder.createLinks({
213+
links,
214+
});
215+
216+
const result = await client.signAndExecuteTransaction({
217+
transaction: tx,
218+
signer: keypair,
219+
});
220+
```
221+
222+
## Documentation
223+
224+
See the [zkSend SDK documentation](https://sdk.mystenlabs.com/zksend) for more details.

packages/zksend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@mysten/zksend",
33
"version": "0.14.12",
4-
"description": "TODO: Write Description",
4+
"description": "Create claimable links for transferring coins and NFTs",
55
"license": "Apache-2.0",
66
"author": "Mysten Labs <[email protected]>",
77
"type": "module",

0 commit comments

Comments
 (0)