@mysten/sui 2.16.0 → 2.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
- package/dist/jsonRpc/http-transport.mjs +1 -2
- package/dist/jsonRpc/http-transport.mjs.map +1 -1
- package/dist/transactions/Transaction.d.mts +7 -7
- package/dist/transactions/data/internal.d.mts +109 -109
- package/dist/transactions/data/internal.d.mts.map +1 -1
- package/dist/transactions/data/v1.d.mts +220 -220
- package/dist/transactions/data/v1.d.mts.map +1 -1
- package/dist/transactions/data/v2.d.mts +16 -16
- package/dist/version.mjs +2 -3
- package/dist/version.mjs.map +1 -1
- package/docs/bcs.md +17 -14
- package/docs/clients/core.md +68 -62
- package/docs/clients/graphql.md +6 -4
- package/docs/clients/grpc.md +18 -13
- package/docs/clients/index.md +17 -15
- package/docs/clients/json-rpc.md +21 -17
- package/docs/cryptography/keypairs.md +16 -7
- package/docs/cryptography/multisig.md +7 -5
- package/docs/cryptography/passkey.md +16 -15
- package/docs/cryptography/webcrypto-signer.md +9 -9
- package/docs/executors.md +25 -22
- package/docs/faucet.md +4 -4
- package/docs/hello-sui.md +8 -7
- package/docs/index.md +20 -21
- package/docs/install.md +4 -4
- package/docs/llm-docs.md +10 -10
- package/docs/llms-index.md +41 -57
- package/docs/migrations/0.38.md +10 -9
- package/docs/migrations/sui-1.0.md +35 -33
- package/docs/migrations/sui-2.0/agent-prompt.md +4 -4
- package/docs/migrations/sui-2.0/dapp-kit.md +47 -47
- package/docs/migrations/sui-2.0/deepbook-v3.md +2 -2
- package/docs/migrations/sui-2.0/index.md +38 -37
- package/docs/migrations/sui-2.0/json-rpc-migration.md +59 -50
- package/docs/migrations/sui-2.0/kiosk.md +9 -9
- package/docs/migrations/sui-2.0/sdk-maintainers.md +8 -8
- package/docs/migrations/sui-2.0/seal.md +2 -2
- package/docs/migrations/sui-2.0/sui.md +17 -17
- package/docs/migrations/sui-2.0/suins.md +6 -4
- package/docs/migrations/sui-2.0/wallet-builders.md +6 -6
- package/docs/migrations/sui-2.0/walrus.md +4 -4
- package/docs/migrations/sui-2.0/zksend.md +7 -6
- package/docs/plugins.md +19 -16
- package/docs/sdk-building.md +37 -33
- package/docs/transaction-building/basics.md +16 -14
- package/docs/transaction-building/gas.md +3 -4
- package/docs/transaction-building/intents.md +6 -5
- package/docs/transaction-building/offline.md +11 -9
- package/docs/transaction-building/sponsored-transactions.md +2 -2
- package/docs/utils/derived_objects.md +13 -13
- package/docs/utils/index.md +2 -2
- package/docs/zklogin.md +7 -2
- package/package.json +4 -5
- package/src/jsonRpc/http-transport.ts +1 -2
- package/src/version.ts +1 -2
- package/src/transactions/__tests__/Transaction.test.ts +0 -184
- package/src/transactions/__tests__/bcs.test.ts +0 -205
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @mysten/kiosk
|
|
2
2
|
|
|
3
|
-
> Migrate @mysten/kiosk to 2.0
|
|
3
|
+
> Migrate @mysten/kiosk to 2.0 with client extension pattern and KioskTransaction.
|
|
4
4
|
|
|
5
5
|
This package now exports a client extension that integrates with Sui clients.
|
|
6
6
|
|
|
@@ -27,7 +27,7 @@ This package now exports a client extension that integrates with Sui clients.
|
|
|
27
27
|
+ const ownedKiosks = await client.kiosk.getOwnedKiosks({ address: myAddress });
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
## Removed: transactionBlock
|
|
30
|
+
## Removed: `transactionBlock` parameter
|
|
31
31
|
|
|
32
32
|
The deprecated `transactionBlock` parameter has been removed from `KioskTransaction`,
|
|
33
33
|
`TransferPolicyTransaction`, and rule resolving functions. Use `transaction` instead:
|
|
@@ -48,12 +48,12 @@ const tpTx = new TransferPolicyTransaction({
|
|
|
48
48
|
});
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
## Removed:
|
|
51
|
+
## Removed: low-level helper functions
|
|
52
52
|
|
|
53
53
|
The low-level helper functions have been removed in favor of the `KioskTransaction` and
|
|
54
54
|
`TransferPolicyTransaction` builder classes.
|
|
55
55
|
|
|
56
|
-
### Kiosk
|
|
56
|
+
### Kiosk functions
|
|
57
57
|
|
|
58
58
|
| Removed Function | Use Instead |
|
|
59
59
|
| ------------------- | ------------------------ |
|
|
@@ -70,7 +70,7 @@ The low-level helper functions have been removed in favor of the `KioskTransacti
|
|
|
70
70
|
| `borrowValue` | `kioskTx.borrow()` |
|
|
71
71
|
| `returnValue` | `kioskTx.return()` |
|
|
72
72
|
|
|
73
|
-
### Transfer
|
|
73
|
+
### Transfer policy functions
|
|
74
74
|
|
|
75
75
|
| Removed Function | Use Instead |
|
|
76
76
|
| ------------------------------------ | ------------------------------------------------------- |
|
|
@@ -79,14 +79,14 @@ The low-level helper functions have been removed in favor of the `KioskTransacti
|
|
|
79
79
|
| `confirmRequest` | Handled automatically by `kioskTx.purchaseAndResolve()` |
|
|
80
80
|
| `removeTransferPolicyRule` | `tpTx.removeRule()` |
|
|
81
81
|
|
|
82
|
-
### Personal Kiosk
|
|
82
|
+
### Personal Kiosk functions
|
|
83
83
|
|
|
84
84
|
| Removed Function | Use Instead |
|
|
85
85
|
| ----------------------- | --------------------------------------------- |
|
|
86
86
|
| `convertToPersonalTx` | `kioskTx.convertToPersonal()` |
|
|
87
87
|
| `transferPersonalCapTx` | Handled automatically by `kioskTx.finalize()` |
|
|
88
88
|
|
|
89
|
-
### Rule
|
|
89
|
+
### Rule attachment functions
|
|
90
90
|
|
|
91
91
|
| Removed Function | Use Instead |
|
|
92
92
|
| --------------------------- | ----------------------------- |
|
|
@@ -95,7 +95,7 @@ The low-level helper functions have been removed in favor of the `KioskTransacti
|
|
|
95
95
|
| `attachPersonalKioskRuleTx` | `tpTx.addPersonalKioskRule()` |
|
|
96
96
|
| `attachFloorPriceRuleTx` | `tpTx.addFloorPriceRule()` |
|
|
97
97
|
|
|
98
|
-
## Migration
|
|
98
|
+
## Migration example
|
|
99
99
|
|
|
100
100
|
```diff
|
|
101
101
|
- import { createKiosk, shareKiosk, placeAndList } from '@mysten/kiosk';
|
|
@@ -117,4 +117,4 @@ The low-level helper functions have been removed in favor of the `KioskTransacti
|
|
|
117
117
|
+ .placeAndList({ itemType, item, price })
|
|
118
118
|
+ .shareAndTransferCap(address)
|
|
119
119
|
+ .finalize();
|
|
120
|
-
```
|
|
120
|
+
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# SDK Maintainers
|
|
2
2
|
|
|
3
|
-
> Migration guide for SDK maintainers and library authors
|
|
3
|
+
> Migration guide for SDK maintainers and library authors upgrading to 2.0.
|
|
4
4
|
|
|
5
5
|
# Upgrading SDKs to @mysten/sui@2.0.0
|
|
6
6
|
|
|
@@ -22,7 +22,7 @@ gRPC):
|
|
|
22
22
|
}
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
## Access
|
|
25
|
+
## Access data through `client.core` methods
|
|
26
26
|
|
|
27
27
|
All data access methods are namespaced under `client.core`:
|
|
28
28
|
|
|
@@ -44,7 +44,7 @@ All data access methods are namespaced under `client.core`:
|
|
|
44
44
|
|
|
45
45
|
See the [Core API documentation](/sui/clients/core) for all available methods.
|
|
46
46
|
|
|
47
|
-
## Use
|
|
47
|
+
## Use peer dependencies
|
|
48
48
|
|
|
49
49
|
Declare `@mysten/*` packages as peer dependencies:
|
|
50
50
|
|
|
@@ -59,7 +59,7 @@ Declare `@mysten/*` packages as peer dependencies:
|
|
|
59
59
|
}
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
## Client
|
|
62
|
+
## Client extensions
|
|
63
63
|
|
|
64
64
|
v2.0 introduces client extensions that let users add your SDK to any Sui client:
|
|
65
65
|
|
|
@@ -81,10 +81,10 @@ await client.mySDK.doSomething();
|
|
|
81
81
|
See the [Building SDKs guide](/sui/sdk-building#client-extensions) for the complete extension
|
|
82
82
|
pattern.
|
|
83
83
|
|
|
84
|
-
## Code
|
|
84
|
+
## Code generation
|
|
85
85
|
|
|
86
|
-
Use
|
|
87
|
-
|
|
86
|
+
Use [`@mysten/codegen`](/codegen) to generate type-safe TypeScript bindings from your Move packages.
|
|
87
|
+
See the [codegen documentation](/codegen) for setup instructions.
|
|
88
88
|
|
|
89
89
|
For complete SDK development patterns including client extensions, transaction thunks, and best
|
|
90
|
-
practices, see the [Building SDKs guide](/sui/sdk-building).
|
|
90
|
+
practices, see the [Building SDKs guide](/sui/sdk-building).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @mysten/seal
|
|
2
2
|
|
|
3
|
-
> Migrate @mysten/seal to 2.0
|
|
3
|
+
> Migrate @mysten/seal to 2.0 with the new registration function pattern.
|
|
4
4
|
|
|
5
5
|
The deprecated `SealClient.asClientExtension()` static method has been removed. Use the `seal()`
|
|
6
6
|
registration function instead:
|
|
@@ -11,4 +11,4 @@ registration function instead:
|
|
|
11
11
|
|
|
12
12
|
- const client = suiClient.$extend(SealClient.asClientExtension());
|
|
13
13
|
+ const client = suiClient.$extend(seal());
|
|
14
|
-
```
|
|
14
|
+
```
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @mysten/sui
|
|
2
2
|
|
|
3
|
-
> Migrate @mysten/sui from 1.x to 2.0
|
|
3
|
+
> Migrate @mysten/sui from 1.x to 2.0 with new client APIs and BCS changes.
|
|
4
4
|
|
|
5
|
-
## Removal of SuiClient
|
|
5
|
+
## Removal of `SuiClient` exports
|
|
6
6
|
|
|
7
7
|
The `@mysten/sui/client` export path has been removed. All JSON-RPC client functionality is now
|
|
8
8
|
exported from `@mysten/sui/jsonRpc`.
|
|
@@ -34,7 +34,7 @@ exported from `@mysten/sui/jsonRpc`.
|
|
|
34
34
|
});
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
## Network
|
|
37
|
+
## Network parameter required
|
|
38
38
|
|
|
39
39
|
When creating a new `SuiGraphQLClient` or `SuiJsonRpcClient`, you must now provide a `network`
|
|
40
40
|
parameter:
|
|
@@ -51,13 +51,13 @@ const client = new SuiJsonRpcClient({
|
|
|
51
51
|
});
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
## BCS
|
|
54
|
+
## BCS schema changes
|
|
55
55
|
|
|
56
56
|
Several BCS schemas in `@mysten/sui/bcs` have been updated to align exactly with the Rust
|
|
57
57
|
implementation. These changes affect serialization and deserialization of transaction effects and
|
|
58
58
|
objects.
|
|
59
59
|
|
|
60
|
-
### ExecutionStatus
|
|
60
|
+
### `ExecutionStatus` changes
|
|
61
61
|
|
|
62
62
|
**BCS Schema** (when parsing raw effects): The variant was renamed from `Failed` to `Failure`:
|
|
63
63
|
|
|
@@ -66,7 +66,7 @@ objects.
|
|
|
66
66
|
+ effects.status.Failure.error
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
**Core API** (gRPC
|
|
69
|
+
**Core API** (gRPC and GraphQL responses): Uses a simplified structure with a `success` boolean:
|
|
70
70
|
|
|
71
71
|
```typescript
|
|
72
72
|
// Core API returns this structure
|
|
@@ -80,7 +80,7 @@ if (tx.effects.status.success) {
|
|
|
80
80
|
}
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
-
### Object BCS
|
|
83
|
+
### Object BCS schema changes
|
|
84
84
|
|
|
85
85
|
Several changes to object BCS schemas:
|
|
86
86
|
|
|
@@ -107,7 +107,7 @@ const data = {
|
|
|
107
107
|
**This affects serialization.** Any existing serialized data with `ConsensusV2` will need to be
|
|
108
108
|
re-serialized with the new `ConsensusAddressOwner` variant.
|
|
109
109
|
|
|
110
|
-
### UnchangedSharedKind to UnchangedConsensusKind
|
|
110
|
+
### `UnchangedSharedKind` to `UnchangedConsensusKind`
|
|
111
111
|
|
|
112
112
|
Transaction effects field renamed:
|
|
113
113
|
|
|
@@ -122,7 +122,7 @@ Transaction effects field renamed:
|
|
|
122
122
|
**New variants:** `MutateConsensusStreamEnded`, `ReadConsensusStreamEnded`, `Cancelled`,
|
|
123
123
|
`PerEpochConfig`
|
|
124
124
|
|
|
125
|
-
## Experimental
|
|
125
|
+
## Experimental client API stabilization
|
|
126
126
|
|
|
127
127
|
The experimental client API has been stabilized and moved from `@mysten/sui/experimental` to
|
|
128
128
|
`@mysten/sui/client`. All `Experimental_` prefixes have been removed.
|
|
@@ -171,7 +171,7 @@ The experimental client API has been stabilized and moved from `@mysten/sui/expe
|
|
|
171
171
|
| `Experimental_SuiClientTypes` | `SuiClientTypes` |
|
|
172
172
|
| `Experimental_CoreClientOptions` | `CoreClientOptions` |
|
|
173
173
|
|
|
174
|
-
## Commands
|
|
174
|
+
## Commands renamed to `TransactionCommands`
|
|
175
175
|
|
|
176
176
|
The `Commands` type exported from `@mysten/sui/transactions` has been renamed to
|
|
177
177
|
`TransactionCommands` because `Commands` is a reserved keyword in React Native.
|
|
@@ -187,7 +187,7 @@ The `Commands` type exported from `@mysten/sui/transactions` has been renamed to
|
|
|
187
187
|
+ tx.add(TransactionCommands.TransferObjects([coin], recipient));
|
|
188
188
|
```
|
|
189
189
|
|
|
190
|
-
## GraphQL
|
|
190
|
+
## GraphQL schema consolidation
|
|
191
191
|
|
|
192
192
|
The SDK now exports a single unified GraphQL schema instead of multiple versioned schemas.
|
|
193
193
|
|
|
@@ -206,7 +206,7 @@ The SDK now exports a single unified GraphQL schema instead of multiple versione
|
|
|
206
206
|
+ import { graphql } from '@mysten/sui/graphql/schema';
|
|
207
207
|
```
|
|
208
208
|
|
|
209
|
-
## Named
|
|
209
|
+
## Named packages plugin removed
|
|
210
210
|
|
|
211
211
|
The `namedPackagesPlugin` and global plugin registry APIs have been removed. MVR (Move Registry)
|
|
212
212
|
resolution is now built directly into the core client.
|
|
@@ -250,7 +250,7 @@ MVR name resolution happens automatically during transaction building. The SDK d
|
|
|
250
250
|
+ });
|
|
251
251
|
```
|
|
252
252
|
|
|
253
|
-
## Transaction
|
|
253
|
+
## Transaction executors now accept any client
|
|
254
254
|
|
|
255
255
|
The transaction executor classes now accept any client implementing `ClientWithCoreApi` instead of
|
|
256
256
|
requiring `SuiJsonRpcClient` specifically.
|
|
@@ -301,9 +301,9 @@ Include options have also changed:
|
|
|
301
301
|
+ });
|
|
302
302
|
```
|
|
303
303
|
|
|
304
|
-
##
|
|
304
|
+
## zkLogin changes
|
|
305
305
|
|
|
306
|
-
### legacyAddress
|
|
306
|
+
### `legacyAddress` parameter required
|
|
307
307
|
|
|
308
308
|
The `legacyAddress` parameter is now **required** for all zkLogin address computation functions.
|
|
309
309
|
|
|
@@ -327,7 +327,7 @@ The `legacyAddress` parameter is now **required** for all zkLogin address comput
|
|
|
327
327
|
+ toZkLoginPublicIdentifier(addressSeed, iss, { legacyAddress: false })
|
|
328
328
|
```
|
|
329
329
|
|
|
330
|
-
## Default
|
|
330
|
+
## Default transaction expiration
|
|
331
331
|
|
|
332
332
|
Transactions now default the expiration to the current epoch + 1 using `ValidDuring` when built with
|
|
333
333
|
a client. This provides replay protection for all transactions without requiring explicit
|
|
@@ -338,4 +338,4 @@ configuration.
|
|
|
338
338
|
```typescript
|
|
339
339
|
const tx = new Transaction();
|
|
340
340
|
tx.setExpiration({ None: true });
|
|
341
|
-
```
|
|
341
|
+
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @mysten/suins
|
|
2
2
|
|
|
3
|
-
> Migrate @mysten/suins to 2.0
|
|
3
|
+
> Migrate @mysten/suins to 2.0 with client extension pattern.
|
|
4
4
|
|
|
5
5
|
This package now exports a client extension that integrates with Sui clients.
|
|
6
6
|
|
|
@@ -24,11 +24,13 @@ This package now exports a client extension that integrates with Sui clients.
|
|
|
24
24
|
+ const nameRecord = await client.suins.getNameRecord('example.sui');
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
## Custom
|
|
27
|
+
## Custom package IDs
|
|
28
28
|
|
|
29
|
-
For custom deployments or networks other than
|
|
29
|
+
For custom deployments or networks other than Mainnet or Testnet, you can provide custom package
|
|
30
|
+
info:
|
|
30
31
|
|
|
31
32
|
```ts
|
|
33
|
+
|
|
32
34
|
const customPackageInfo: PackageInfo = {
|
|
33
35
|
packageId: '0x...',
|
|
34
36
|
packageIdV1: '0x...',
|
|
@@ -39,4 +41,4 @@ const client = new SuiGrpcClient({
|
|
|
39
41
|
baseUrl: 'http://localhost:9000',
|
|
40
42
|
network: 'localnet',
|
|
41
43
|
}).$extend(suins({ packageInfo: customPackageInfo }));
|
|
42
|
-
```
|
|
44
|
+
```
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
# Wallet Builders
|
|
2
2
|
|
|
3
|
-
> Migration guide for wallet extension developers
|
|
3
|
+
> Migration guide for wallet extension developers upgrading to 2.0.
|
|
4
4
|
|
|
5
5
|
This guide covers the breaking changes for wallet builders implementing the
|
|
6
6
|
`@mysten/wallet-standard` interface.
|
|
7
7
|
|
|
8
|
-
## Key
|
|
8
|
+
## Key changes
|
|
9
9
|
|
|
10
10
|
### Removal of `sui:reportTransactionEffects`
|
|
11
11
|
|
|
12
12
|
The `sui:reportTransactionEffects` feature has been removed entirely. If your wallet implements this
|
|
13
13
|
feature, remove it.
|
|
14
14
|
|
|
15
|
-
### New
|
|
15
|
+
### New core API response format
|
|
16
16
|
|
|
17
17
|
The most significant change is how you obtain BCS-encoded effects for the
|
|
18
18
|
`signAndExecuteTransaction` response. The new core API returns effects in a different structure.
|
|
19
19
|
|
|
20
20
|
## Migrating `signAndExecuteTransaction`
|
|
21
21
|
|
|
22
|
-
The wallet standard output format hasn't changed
|
|
23
|
-
|
|
22
|
+
The wallet standard output format hasn't changed. What's different is how you obtain the BCS effects
|
|
23
|
+
when using the new Sui client APIs.
|
|
24
24
|
|
|
25
25
|
```diff
|
|
26
26
|
#signAndExecuteTransaction: SuiSignAndExecuteTransactionMethod = async ({
|
|
@@ -63,4 +63,4 @@ Key changes:
|
|
|
63
63
|
|
|
64
64
|
- Use `signer.signAndExecuteTransaction()` instead of `suiClient.executeTransactionBlock()`
|
|
65
65
|
- Response is a union type - unwrap with `result.Transaction ?? result.FailedTransaction`
|
|
66
|
-
- BCS effects are in `tx.effects.bcs` (Uint8Array) instead of `rawEffects` (number array)
|
|
66
|
+
- BCS effects are in `tx.effects.bcs` (Uint8Array) instead of `rawEffects` (number array)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @mysten/walrus
|
|
2
2
|
|
|
3
|
-
> Migrate @mysten/walrus to 2.0
|
|
3
|
+
> Migrate @mysten/walrus to 2.0 with required client parameter and updated API.
|
|
4
4
|
|
|
5
|
-
## Breaking
|
|
5
|
+
## Breaking changes
|
|
6
6
|
|
|
7
7
|
- **Client required**: `WalrusClient` can no longer be created with just an RPC URL. You must pass a
|
|
8
8
|
Sui client.
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
- **Removed deprecated method**: `WalrusClient.experimental_asClientExtension()` has been removed.
|
|
12
12
|
Use the `walrus()` function instead.
|
|
13
13
|
|
|
14
|
-
## Updated
|
|
14
|
+
## Updated usage
|
|
15
15
|
|
|
16
16
|
If you were creating `WalrusClient` directly:
|
|
17
17
|
|
|
@@ -38,4 +38,4 @@ If you were passing `network` to `walrus()`, remove it:
|
|
|
38
38
|
```diff
|
|
39
39
|
- client.$extend(walrus({ network: 'testnet' }));
|
|
40
40
|
+ client.$extend(walrus());
|
|
41
|
-
```
|
|
41
|
+
```
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# @mysten/zksend
|
|
2
2
|
|
|
3
|
-
> Migrate @mysten/zksend to 2.0
|
|
3
|
+
> Migrate @mysten/zksend to 2.0 with client extension pattern and simplified API.
|
|
4
4
|
|
|
5
5
|
This package now exports a client extension that integrates with Sui clients, enabling compatibility
|
|
6
6
|
with gRPC, GraphQL, and JSON RPC transports.
|
|
7
7
|
|
|
8
|
-
## Breaking
|
|
8
|
+
## Breaking changes
|
|
9
9
|
|
|
10
10
|
- **Client extension**: The zkSend SDK is now a client extension (`client.$extend(zksend())`)
|
|
11
11
|
- **Non-contract links removed**: Only contract-based links are now supported. The `contract` option
|
|
@@ -31,7 +31,7 @@ Update your code to use the client extension:
|
|
|
31
31
|
+ }).$extend(zksend());
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
### Creating a
|
|
34
|
+
### Creating a link builder
|
|
35
35
|
|
|
36
36
|
```diff
|
|
37
37
|
- const builder = new ZkSendLinkBuilder({
|
|
@@ -44,7 +44,7 @@ Update your code to use the client extension:
|
|
|
44
44
|
+ });
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
### Loading a
|
|
47
|
+
### Loading a link
|
|
48
48
|
|
|
49
49
|
```diff
|
|
50
50
|
- const link = new ZkSendLink({
|
|
@@ -68,9 +68,10 @@ Update your code to use the client extension:
|
|
|
68
68
|
+ const link = await client.zksend.loadLinkFromUrl(url);
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
## Complete
|
|
71
|
+
## Complete example
|
|
72
72
|
|
|
73
73
|
```ts
|
|
74
|
+
|
|
74
75
|
// Create client with zkSend extension
|
|
75
76
|
const client = new SuiGrpcClient({
|
|
76
77
|
baseUrl: 'https://fullnode.testnet.sui.io:443',
|
|
@@ -91,4 +92,4 @@ const { tx, link } = await linkBuilder.build();
|
|
|
91
92
|
// Later, load an existing link
|
|
92
93
|
const existingLink = await client.zksend.loadLinkFromUrl(linkUrl);
|
|
93
94
|
const assets = await existingLink.getAssets();
|
|
94
|
-
```
|
|
95
|
+
```
|
package/docs/plugins.md
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
# Transaction Plugins
|
|
2
2
|
|
|
3
|
-
> Extend transaction building with reusable plugins
|
|
3
|
+
> Extend transaction building with reusable plugins.
|
|
4
4
|
|
|
5
|
-
> **Warning:** The `Transaction` plugin API is experimental and
|
|
6
|
-
> developed.
|
|
5
|
+
> **Warning:** The `Transaction` plugin API is experimental and might change rapidly as it is being developed.
|
|
7
6
|
|
|
8
7
|
This document describes the plugin API for the `Transaction` builder. It covers internal details
|
|
9
8
|
intended for developers interested in extending the `Transaction` builder. Developers using the
|
|
@@ -20,10 +19,10 @@ modify the data and commands added to a transaction before it is serialized to J
|
|
|
20
19
|
BCS bytes. Transaction Intents are custom representations of user intents for a transaction,
|
|
21
20
|
eventually resolved to one or more commands in the transaction.
|
|
22
21
|
|
|
23
|
-
## Contents of a
|
|
22
|
+
## Contents of a transaction
|
|
24
23
|
|
|
25
|
-
When a `Transaction` is created (
|
|
26
|
-
[TransactionDataBuilder](/typedoc/classes/_mysten_sui.transactions.TransactionDataBuilder.html)
|
|
24
|
+
When a `Transaction` is created (for example, `new Transaction()`), it is initialized with an empty
|
|
25
|
+
[`TransactionDataBuilder`](/typedoc/classes/_mysten_sui.transactions.TransactionDataBuilder.html)
|
|
27
26
|
instance which stores the state of the partially built transaction. The full API of the
|
|
28
27
|
`TransactionDataBuilder` won't be covered here, but you can find the available methods and
|
|
29
28
|
properties in the
|
|
@@ -36,13 +35,13 @@ takes depend on the command, but they will be one of a few different types:
|
|
|
36
35
|
- `GasCoin`: A reference to the coin used to pay for gas.
|
|
37
36
|
- `Input`: An input to the transaction (described below).
|
|
38
37
|
- `Result`: The result of a previous command.
|
|
39
|
-
- `NestedResult`: If a previous command returns a tuple (
|
|
40
|
-
used to refer to a specific value in that tuple.
|
|
38
|
+
- `NestedResult`: If a previous command returns a tuple (for example, `SplitCoin`), a `NestedResult`
|
|
39
|
+
is used to refer to a specific value in that tuple.
|
|
41
40
|
|
|
42
41
|
Transactions also store a list of Inputs, which refer to user-provided values. Inputs can either be
|
|
43
42
|
objects or Pure values and can be represented in several different ways:
|
|
44
43
|
|
|
45
|
-
- `Pure`: An input value serialized to BCS. Pure values are generally scalar values or
|
|
44
|
+
- `Pure`: An input value serialized to BCS. Pure values are generally scalar values or basic
|
|
46
45
|
wrappers like options or vectors and cannot represent object types.
|
|
47
46
|
- `Object`: A fully resolved object reference, which will be one of the following types:
|
|
48
47
|
- `ImmOrOwnedObject`: A reference to an object, including the object's `id`, `version`, and
|
|
@@ -53,13 +52,13 @@ objects or Pure values and can be represented in several different ways:
|
|
|
53
52
|
`digest`.
|
|
54
53
|
- `UnresolvedPure`: A placeholder for a pure value that has not been serialized to BCS.
|
|
55
54
|
- `UnresolvedObject`: A partial reference to an object, often containing just the object's `id`, but
|
|
56
|
-
|
|
55
|
+
might also include a version, digest, or initialSharedVersion.
|
|
57
56
|
|
|
58
|
-
## Lifecycle of a
|
|
57
|
+
## Lifecycle of a transaction
|
|
59
58
|
|
|
60
59
|
Because transactions can contain `UnresolvedPure` and `UnresolvedObject` inputs, these values need
|
|
61
60
|
to be resolved before the transaction can be serialized to BCS. However, these unresolved inputs can
|
|
62
|
-
be represented in JSON. What
|
|
61
|
+
be represented in JSON. What might not be able to be represented in JSON are Transaction Intents.
|
|
63
62
|
Transaction Intents represent custom concepts added by plugins or third-party SDKs. To account for
|
|
64
63
|
this, the build process of a transaction is split into two phases: serialization and building.
|
|
65
64
|
Serialization prepares the transaction to be serialized to JSON by running serialization plugins,
|
|
@@ -67,7 +66,7 @@ and resolving any unsupported intents. The Build phase then runs, which runs bui
|
|
|
67
66
|
resolves any UnresolvedPure and UnresolvedObject inputs, before the transaction is serialized to
|
|
68
67
|
BCS.
|
|
69
68
|
|
|
70
|
-
## Serialization
|
|
69
|
+
## Serialization plugins
|
|
71
70
|
|
|
72
71
|
Serialization plugins can be added to a `Transaction` by calling the `addSerializationPlugin` method
|
|
73
72
|
on a `Transaction` instance. Serialization plugins are called in the order they are added and are
|
|
@@ -83,7 +82,7 @@ transaction.addSerializationPlugin(async (transactionData, buildOptions, next) =
|
|
|
83
82
|
});
|
|
84
83
|
```
|
|
85
84
|
|
|
86
|
-
## Build
|
|
85
|
+
## Build plugins
|
|
87
86
|
|
|
88
87
|
The build phase is responsible for taking unresolved objects and unresolved pure values and
|
|
89
88
|
converting them to their resolved versions by querying the RPC API to fetch the missing data. Build
|
|
@@ -137,7 +136,7 @@ const transaction = new Transaction();
|
|
|
137
136
|
transaction.addBuildPlugin(simpleObjectCachePlugin);
|
|
138
137
|
```
|
|
139
138
|
|
|
140
|
-
## Transaction
|
|
139
|
+
## Transaction intents
|
|
141
140
|
|
|
142
141
|
Transaction Intents consist of two parts: adding the intent to the transaction and resolving the
|
|
143
142
|
intent to standard commands.
|
|
@@ -145,6 +144,7 @@ intent to standard commands.
|
|
|
145
144
|
Adding an intent is similar to adding any other command to a transaction:
|
|
146
145
|
|
|
147
146
|
```typescript
|
|
147
|
+
|
|
148
148
|
const transaction = new Transaction();
|
|
149
149
|
|
|
150
150
|
transaction.add(
|
|
@@ -162,6 +162,7 @@ wraps things up a bit. The `add` method on transactions accepts a function that
|
|
|
162
162
|
current transaction instance. This allows us to create a helper that automatically adds the intent:
|
|
163
163
|
|
|
164
164
|
```typescript
|
|
165
|
+
|
|
165
166
|
function transferToSender(objects: TransactionObjectInput[]) {
|
|
166
167
|
return (tx: Transaction) => {
|
|
167
168
|
tx.add(
|
|
@@ -186,6 +187,7 @@ commands. To do this, we'll use the `addIntentResolver` method on the `Transacti
|
|
|
186
187
|
intent is present in the transaction.
|
|
187
188
|
|
|
188
189
|
```typescript
|
|
190
|
+
|
|
189
191
|
const transaction = new Transaction();
|
|
190
192
|
|
|
191
193
|
transaction.addIntentResolver('TransferToSender', resolveTransferToSender);
|
|
@@ -235,6 +237,7 @@ Manually adding intent resolvers to a transaction can be cumbersome, so we can a
|
|
|
235
237
|
automatically when our `transferToSender` helper is called:
|
|
236
238
|
|
|
237
239
|
```typescript
|
|
240
|
+
|
|
238
241
|
function transferToSender(objects: TransactionObjectInput[]) {
|
|
239
242
|
return (tx: Transaction) => {
|
|
240
243
|
// As long as we are adding the same function reference, it will only be added once
|
|
@@ -252,4 +255,4 @@ function transferToSender(objects: TransactionObjectInput[]) {
|
|
|
252
255
|
|
|
253
256
|
const transaction = new Transaction();
|
|
254
257
|
transaction.add(transferToSender(['0x1234']));
|
|
255
|
-
```
|
|
258
|
+
```
|