@mysten/sui 2.23.1 → 2.24.0
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 +16 -0
- package/README.md +9 -9
- package/dist/bcs/index.d.mts +36 -36
- package/dist/client/core.d.mts +1 -0
- package/dist/client/core.d.mts.map +1 -1
- package/dist/client/core.mjs.map +1 -1
- package/dist/client/types.d.mts +7 -0
- package/dist/client/types.d.mts.map +1 -1
- package/dist/cryptography/signature.d.mts +6 -6
- package/dist/graphql/client.d.mts +1 -0
- package/dist/graphql/client.d.mts.map +1 -1
- package/dist/graphql/client.mjs +3 -0
- package/dist/graphql/client.mjs.map +1 -1
- package/dist/graphql/core.d.mts +1 -0
- package/dist/graphql/core.d.mts.map +1 -1
- package/dist/graphql/core.mjs +10 -1
- package/dist/graphql/core.mjs.map +1 -1
- package/dist/graphql/generated/queries.d.mts.map +1 -1
- package/dist/graphql/generated/queries.mjs +8 -1
- package/dist/graphql/generated/queries.mjs.map +1 -1
- package/dist/grpc/client.d.mts +1 -0
- package/dist/grpc/client.d.mts.map +1 -1
- package/dist/grpc/client.mjs +3 -0
- package/dist/grpc/client.mjs.map +1 -1
- package/dist/grpc/core.d.mts +1 -0
- package/dist/grpc/core.d.mts.map +1 -1
- package/dist/grpc/core.mjs +32 -12
- package/dist/grpc/core.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/name_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/core.d.mts +6 -0
- package/dist/jsonRpc/core.d.mts.map +1 -1
- package/dist/jsonRpc/core.mjs +15 -4
- package/dist/jsonRpc/core.mjs.map +1 -1
- package/dist/transactions/Transaction.d.mts +3 -3
- 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/transactions/data/v2.d.mts.map +1 -1
- package/dist/version.mjs +1 -1
- package/dist/version.mjs.map +1 -1
- package/docs/clients/core.md +31 -10
- package/docs/clients/graphql.md +43 -8
- package/docs/clients/grpc.md +91 -9
- package/docs/clients/index.md +86 -39
- package/docs/clients/json-rpc.md +30 -26
- package/docs/executors.md +28 -13
- package/docs/index.md +1 -1
- package/docs/llms-index.md +17 -17
- package/docs/migrations/sui-2.0/dapp-kit.md +3 -3
- package/docs/migrations/sui-2.0/deepbook-v3.md +2 -2
- package/docs/migrations/sui-2.0/index.md +46 -25
- package/docs/migrations/sui-2.0/json-rpc-migration.md +460 -284
- package/docs/migrations/sui-2.0/kiosk.md +10 -9
- package/docs/migrations/sui-2.0/sdk-maintainers.md +17 -11
- package/docs/migrations/sui-2.0/sui.md +47 -29
- package/docs/migrations/sui-2.0/suins.md +2 -2
- package/docs/migrations/sui-2.0/walrus.md +3 -3
- package/docs/migrations/sui-2.0/zksend.md +9 -8
- package/docs/sdk-building.md +7 -5
- package/package.json +1 -1
- package/src/client/core.ts +4 -0
- package/src/client/types.ts +11 -0
- package/src/graphql/client.ts +6 -0
- package/src/graphql/core.ts +15 -0
- package/src/graphql/generated/queries.ts +14 -0
- package/src/graphql/queries/nameService.graphql +6 -0
- package/src/grpc/client.ts +6 -0
- package/src/grpc/core.ts +51 -12
- package/src/jsonRpc/core.ts +50 -14
- package/src/version.ts +1 -1
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
# @mysten/kiosk
|
|
2
2
|
|
|
3
|
-
> Migrate @mysten/kiosk to 2.0 with client extension pattern and KioskTransaction
|
|
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
|
|
|
7
|
-
> **Note:** The Kiosk SDK
|
|
8
|
-
> `SuiGrpcClient`
|
|
7
|
+
> **Note:** The Kiosk SDK accepts `SuiGrpcClient`, `SuiGraphQLClient`, and other clients that implement
|
|
8
|
+
> `ClientWithCoreApi`. Use `SuiGrpcClient` for new Kiosk code. The gRPC object API returns Display
|
|
9
|
+
> v2 metadata; use GraphQL or JSON-RPC for object types that still rely on legacy Display metadata.
|
|
9
10
|
|
|
10
11
|
```diff
|
|
11
12
|
- import { SuiClient, getFullnodeUrl } from '@mysten/sui/client';
|
|
12
13
|
- import { KioskClient, Network } from '@mysten/kiosk';
|
|
13
|
-
+ import {
|
|
14
|
+
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
14
15
|
+ import { kiosk } from '@mysten/kiosk';
|
|
15
16
|
|
|
16
17
|
- const suiClient = new SuiClient({ url: getFullnodeUrl('mainnet') });
|
|
@@ -18,8 +19,8 @@ This package now exports a client extension that integrates with Sui clients.
|
|
|
18
19
|
- client: suiClient,
|
|
19
20
|
- network: Network.MAINNET,
|
|
20
21
|
- });
|
|
21
|
-
+ const client = new
|
|
22
|
-
+
|
|
22
|
+
+ const client = new SuiGrpcClient({
|
|
23
|
+
+ baseUrl: 'https://fullnode.mainnet.sui.io:443',
|
|
23
24
|
+ network: 'mainnet',
|
|
24
25
|
+ }).$extend(kiosk());
|
|
25
26
|
|
|
@@ -100,14 +101,14 @@ The low-level helper functions have been removed in favor of the `KioskTransacti
|
|
|
100
101
|
```diff
|
|
101
102
|
- import { createKiosk, shareKiosk, placeAndList } from '@mysten/kiosk';
|
|
102
103
|
+ import { kiosk, KioskTransaction } from '@mysten/kiosk';
|
|
103
|
-
+ import {
|
|
104
|
+
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
104
105
|
|
|
105
106
|
- const [kiosk, cap] = createKiosk(tx);
|
|
106
107
|
- shareKiosk(tx, kiosk);
|
|
107
108
|
- placeAndList(tx, itemType, kiosk, cap, item, price);
|
|
108
109
|
|
|
109
|
-
+ const client = new
|
|
110
|
-
+
|
|
110
|
+
+ const client = new SuiGrpcClient({
|
|
111
|
+
+ baseUrl: 'https://fullnode.mainnet.sui.io:443',
|
|
111
112
|
+ network: 'mainnet',
|
|
112
113
|
+ }).$extend(kiosk());
|
|
113
114
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# SDK Maintainers
|
|
2
2
|
|
|
3
|
-
> Migration guide for SDK maintainers and library authors upgrading to 2.0
|
|
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
|
|
|
@@ -10,8 +10,8 @@ For comprehensive SDK development patterns, see the [Building SDKs guide](/sui/s
|
|
|
10
10
|
|
|
11
11
|
## Use `ClientWithCoreApi`
|
|
12
12
|
|
|
13
|
-
Accept `ClientWithCoreApi` instead of `SuiClient`
|
|
14
|
-
|
|
13
|
+
Accept `ClientWithCoreApi` instead of `SuiClient` so applications can pass a `SuiGrpcClient`,
|
|
14
|
+
`SuiGraphQLClient`, or a legacy `SuiJsonRpcClient` during migration:
|
|
15
15
|
|
|
16
16
|
```diff
|
|
17
17
|
- import { SuiClient } from '@mysten/sui/client';
|
|
@@ -24,7 +24,9 @@ gRPC):
|
|
|
24
24
|
|
|
25
25
|
## Access data through `client.core` methods
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
SDKs should access shared client methods through `client.core`. Application code can use the same
|
|
28
|
+
methods at the top level of its concrete client, but `client.core` is the stable contract for
|
|
29
|
+
libraries that should work across transports:
|
|
28
30
|
|
|
29
31
|
```diff
|
|
30
32
|
- const result = await this.client.getObject({ objectId });
|
|
@@ -34,13 +36,17 @@ All data access methods are namespaced under `client.core`:
|
|
|
34
36
|
+ const result = await this.client.core.listOwnedObjects({ owner });
|
|
35
37
|
```
|
|
36
38
|
|
|
37
|
-
| v1.x Method | v2.0 Method
|
|
38
|
-
| -------------------------------- |
|
|
39
|
-
| `client.getObject()` | `client.core.getObject()`
|
|
40
|
-
| `client.getOwnedObjects()` | `client.core.listOwnedObjects()`
|
|
41
|
-
| `client.getDynamicFieldObject()` | `client.core.getDynamicField()`
|
|
42
|
-
| `client.getDynamicFields()` | `client.core.listDynamicFields()`
|
|
43
|
-
| `client.multiGetObjects()` | `client.core.getObjects()`
|
|
39
|
+
| v1.x Method | v2.0 Method |
|
|
40
|
+
| -------------------------------- | ------------------------------------------------------------------------ |
|
|
41
|
+
| `client.getObject()` | `client.core.getObject()` |
|
|
42
|
+
| `client.getOwnedObjects()` | `client.core.listOwnedObjects()` |
|
|
43
|
+
| `client.getDynamicFieldObject()` | `client.core.getDynamicField()` or `client.core.getDynamicObjectField()` |
|
|
44
|
+
| `client.getDynamicFields()` | `client.core.listDynamicFields()` |
|
|
45
|
+
| `client.multiGetObjects()` | `client.core.getObjects()` |
|
|
46
|
+
|
|
47
|
+
Use `getDynamicField()` for regular dynamic fields and when you need the field entry or BCS-encoded
|
|
48
|
+
value. Use `getDynamicObjectField()` only for dynamic object fields when you want the referenced
|
|
49
|
+
child object returned directly.
|
|
44
50
|
|
|
45
51
|
See the [Core API documentation](/sui/clients/core) for all available methods.
|
|
46
52
|
|
|
@@ -1,51 +1,63 @@
|
|
|
1
1
|
# @mysten/sui
|
|
2
2
|
|
|
3
|
-
> Migrate @mysten/sui from 1.x to 2.0 with
|
|
3
|
+
> Migrate @mysten/sui from 1.x to 2.0 with gRPC clients, Core API, and BCS changes
|
|
4
4
|
|
|
5
5
|
## Removal of `SuiClient` exports
|
|
6
6
|
|
|
7
|
-
The
|
|
8
|
-
|
|
7
|
+
The old `SuiClient` export has been removed from `@mysten/sui/client`. For application code, migrate
|
|
8
|
+
to [`SuiGrpcClient`](/sui/clients/grpc) and use top-level methods such as `client.getObject()`,
|
|
9
|
+
`client.listCoins()`, and `client.signAndExecuteTransaction()`.
|
|
10
|
+
|
|
11
|
+
Legacy JSON-RPC functionality moved to `@mysten/sui/jsonRpc`, but JSON-RPC APIs are deprecated in
|
|
12
|
+
the Sui TypeScript SDK. Use the JSON-RPC exports only when maintaining code that still needs the old
|
|
13
|
+
JSON-RPC method names or response shapes during migration.
|
|
9
14
|
|
|
10
15
|
**Removed exports:**
|
|
11
16
|
|
|
12
|
-
- `SuiClient` (use `SuiJsonRpcClient`
|
|
13
|
-
- `SuiClientOptions` (use `
|
|
14
|
-
|
|
15
|
-
- `
|
|
17
|
+
- `SuiClient` (use `SuiGrpcClient`; legacy JSON-RPC code can use `SuiJsonRpcClient`)
|
|
18
|
+
- `SuiClientOptions` (use `SuiGrpcClientOptions`; legacy JSON-RPC code can use
|
|
19
|
+
`SuiJsonRpcClientOptions`)
|
|
20
|
+
- `isSuiClient` (use `isSuiGrpcClient`, `isSuiGraphQLClient`, or legacy `isSuiJsonRpcClient`)
|
|
21
|
+
- `SuiTransport` (legacy JSON-RPC code can use `JsonRpcTransport`)
|
|
16
22
|
- `SuiTransportRequestOptions` (use `JsonRpcTransportRequestOptions` instead)
|
|
17
|
-
- `SuiTransportSubscribeOptions` (use
|
|
23
|
+
- `SuiTransportSubscribeOptions` (removed; use the gRPC subscription service for streaming APIs)
|
|
18
24
|
- `SuiHTTPTransportOptions` (use `JsonRpcHTTPTransportOptions` instead)
|
|
19
25
|
- `SuiHTTPTransport` (use `JsonRpcHTTPTransport` instead)
|
|
20
|
-
- `getFullnodeUrl` (
|
|
26
|
+
- `getFullnodeUrl` (pass the full node URL to `SuiGrpcClient.baseUrl`; legacy JSON-RPC code can use
|
|
27
|
+
`getJsonRpcFullnodeUrl`)
|
|
21
28
|
- All JSON-RPC types (now exported from `@mysten/sui/jsonRpc`)
|
|
22
29
|
|
|
23
30
|
**Migration:**
|
|
24
31
|
|
|
25
32
|
```diff
|
|
26
33
|
- import { SuiClient, getFullnodeUrl } from '@mysten/sui/client';
|
|
27
|
-
+ import {
|
|
34
|
+
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
28
35
|
|
|
29
36
|
- const client = new SuiClient({
|
|
30
37
|
- url: getFullnodeUrl('devnet'),
|
|
31
|
-
+ const client = new
|
|
32
|
-
+
|
|
38
|
+
+ const client = new SuiGrpcClient({
|
|
39
|
+
+ baseUrl: 'https://fullnode.devnet.sui.io:443',
|
|
33
40
|
network: 'devnet',
|
|
34
41
|
});
|
|
35
42
|
```
|
|
36
43
|
|
|
37
44
|
## Network parameter required
|
|
38
45
|
|
|
39
|
-
When creating a new `SuiGraphQLClient
|
|
40
|
-
parameter:
|
|
46
|
+
When creating a new `SuiGrpcClient`, `SuiGraphQLClient`, or legacy `SuiJsonRpcClient`, provide a
|
|
47
|
+
`network` parameter:
|
|
41
48
|
|
|
42
49
|
```ts
|
|
43
|
-
const
|
|
50
|
+
const grpcClient = new SuiGrpcClient({
|
|
51
|
+
baseUrl: 'https://...',
|
|
52
|
+
network: 'mainnet', // Required
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const graphqlClient = new SuiGraphQLClient({
|
|
44
56
|
url: 'https://...',
|
|
45
57
|
network: 'mainnet', // Required
|
|
46
58
|
});
|
|
47
59
|
|
|
48
|
-
const
|
|
60
|
+
const jsonRpcClient = new SuiJsonRpcClient({
|
|
49
61
|
url: 'https://...',
|
|
50
62
|
network: 'mainnet', // Required
|
|
51
63
|
});
|
|
@@ -66,11 +78,12 @@ objects.
|
|
|
66
78
|
+ effects.status.Failure.error
|
|
67
79
|
```
|
|
68
80
|
|
|
69
|
-
**Core API** (gRPC and GraphQL responses):
|
|
81
|
+
**Core API and top-level client methods** (gRPC and GraphQL responses): Use a simplified structure
|
|
82
|
+
with a `success` boolean:
|
|
70
83
|
|
|
71
84
|
```typescript
|
|
72
|
-
//
|
|
73
|
-
const result = await client.
|
|
85
|
+
// Top-level gRPC and GraphQL methods return this structure.
|
|
86
|
+
const result = await client.getTransaction({ digest, include: { effects: true } });
|
|
74
87
|
const tx = result.Transaction ?? result.FailedTransaction;
|
|
75
88
|
|
|
76
89
|
if (tx.effects.status.success) {
|
|
@@ -223,7 +236,7 @@ resolution is now built directly into the core client.
|
|
|
223
236
|
**How it works now:**
|
|
224
237
|
|
|
225
238
|
MVR name resolution happens automatically during transaction building. The SDK detects `.move` names
|
|
226
|
-
|
|
239
|
+
like `@org/package::module::Type` and resolves them using the client's MVR resolver.
|
|
227
240
|
|
|
228
241
|
**Migration:**
|
|
229
242
|
|
|
@@ -238,11 +251,10 @@ MVR name resolution happens automatically during transaction building. The SDK d
|
|
|
238
251
|
- })
|
|
239
252
|
- );
|
|
240
253
|
|
|
241
|
-
+ import {
|
|
242
|
-
+ import type { NamedPackagesOverrides } from '@mysten/sui/client';
|
|
254
|
+
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
243
255
|
+
|
|
244
|
-
+ const client = new
|
|
245
|
-
+
|
|
256
|
+
+ const client = new SuiGrpcClient({
|
|
257
|
+
+ baseUrl: 'https://fullnode.mainnet.sui.io:443',
|
|
246
258
|
+ network: 'mainnet',
|
|
247
259
|
+ mvr: {
|
|
248
260
|
+ overrides: myOverrides,
|
|
@@ -264,7 +276,8 @@ requiring `SuiJsonRpcClient` specifically.
|
|
|
264
276
|
**Breaking changes:**
|
|
265
277
|
|
|
266
278
|
- Constructor `client` parameter type changed from `SuiJsonRpcClient` to `ClientWithCoreApi`
|
|
267
|
-
- Return type of `executeTransaction()
|
|
279
|
+
- Return type of `executeTransaction()` changed from the legacy `{ digest, effects, data }` wrapper
|
|
280
|
+
to a Core API `TransactionResult` discriminated union returned directly
|
|
268
281
|
- The second parameter changed from JSON-RPC options to core API include options
|
|
269
282
|
|
|
270
283
|
**Migration:**
|
|
@@ -272,7 +285,12 @@ requiring `SuiJsonRpcClient` specifically.
|
|
|
272
285
|
```diff
|
|
273
286
|
|
|
274
287
|
- import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
275
|
-
+
|
|
288
|
+
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
289
|
+
|
|
290
|
+
+ const client = new SuiGrpcClient({
|
|
291
|
+
+ baseUrl: 'https://fullnode.devnet.sui.io:443',
|
|
292
|
+
+ network: 'devnet',
|
|
293
|
+
+ });
|
|
276
294
|
|
|
277
295
|
const executor = new SerialTransactionExecutor({
|
|
278
296
|
- client: jsonRpcClient,
|
|
@@ -282,10 +300,10 @@ const executor = new SerialTransactionExecutor({
|
|
|
282
300
|
|
|
283
301
|
const result = await executor.executeTransaction(tx);
|
|
284
302
|
|
|
285
|
-
// Accessing the transaction result
|
|
303
|
+
// Accessing the transaction result now returned directly
|
|
286
304
|
- console.log(result.data.effects?.status.status);
|
|
287
|
-
+ const
|
|
288
|
-
+ console.log(
|
|
305
|
+
+ const transaction = result.Transaction ?? result.FailedTransaction;
|
|
306
|
+
+ console.log(transaction.effects.status.success);
|
|
289
307
|
```
|
|
290
308
|
|
|
291
309
|
Include options have also changed:
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# @mysten/suins
|
|
2
2
|
|
|
3
|
-
> Migrate @mysten/suins to 2.0 with client extension pattern
|
|
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
|
|
|
7
7
|
```diff
|
|
8
8
|
- import { SuiClient, getFullnodeUrl } from '@mysten/sui/client';
|
|
9
9
|
- import { SuinsClient } from '@mysten/suins';
|
|
10
|
-
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
10
|
+
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
11
11
|
+ import { suins } from '@mysten/suins';
|
|
12
12
|
|
|
13
13
|
- const suiClient = new SuiClient({ url: getFullnodeUrl('mainnet') });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @mysten/walrus
|
|
2
2
|
|
|
3
|
-
> Migrate @mysten/walrus to 2.0 with required client parameter and updated API
|
|
3
|
+
> Migrate @mysten/walrus to 2.0 with required client parameter and updated API
|
|
4
4
|
|
|
5
5
|
## Breaking changes
|
|
6
6
|
|
|
@@ -17,7 +17,7 @@ If you were creating `WalrusClient` directly:
|
|
|
17
17
|
|
|
18
18
|
```diff
|
|
19
19
|
- import { WalrusClient } from '@mysten/walrus';
|
|
20
|
-
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
20
|
+
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
21
21
|
+ import { walrus } from '@mysten/walrus';
|
|
22
22
|
|
|
23
23
|
- const walrusClient = new WalrusClient({
|
|
@@ -30,7 +30,7 @@ If you were creating `WalrusClient` directly:
|
|
|
30
30
|
+ }).$extend(walrus());
|
|
31
31
|
|
|
32
32
|
- await walrusClient.getBlob(blobId);
|
|
33
|
-
+ await client.walrus.getBlob(blobId);
|
|
33
|
+
+ await client.walrus.getBlob({ blobId });
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
If you were passing `network` to `walrus()`, remove it:
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# @mysten/zksend
|
|
2
2
|
|
|
3
|
-
> Migrate @mysten/zksend to 2.0 with client extension pattern and simplified API
|
|
3
|
+
> Migrate @mysten/zksend to 2.0 with client extension pattern and simplified API
|
|
4
4
|
|
|
5
|
-
This package now exports a client extension that integrates with Sui clients
|
|
6
|
-
|
|
5
|
+
This package now exports a client extension that integrates with Sui clients through the Core API.
|
|
6
|
+
Use `SuiGrpcClient` for most applications.
|
|
7
7
|
|
|
8
8
|
## Breaking changes
|
|
9
9
|
|
|
@@ -23,7 +23,7 @@ Update your code to use the client extension:
|
|
|
23
23
|
```diff
|
|
24
24
|
- import { ZkSendLinkBuilder, ZkSendLink } from '@mysten/zksend';
|
|
25
25
|
+ import { zksend } from '@mysten/zksend';
|
|
26
|
-
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
26
|
+
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
27
27
|
|
|
28
28
|
+ const client = new SuiGrpcClient({
|
|
29
29
|
+ baseUrl: 'https://fullnode.testnet.sui.io:443',
|
|
@@ -84,12 +84,13 @@ const linkBuilder = client.zksend.linkBuilder({
|
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
// Add assets to the link
|
|
87
|
-
linkBuilder.
|
|
87
|
+
linkBuilder.addClaimableMist(1_000_000_000n); // 1 SUI
|
|
88
88
|
|
|
89
|
-
// Create the transaction
|
|
90
|
-
const
|
|
89
|
+
// Create the transaction and get the claim URL
|
|
90
|
+
const tx = await linkBuilder.createSendTransaction();
|
|
91
|
+
const linkUrl = linkBuilder.getLink();
|
|
91
92
|
|
|
92
93
|
// Later, load an existing link
|
|
93
94
|
const existingLink = await client.zksend.loadLinkFromUrl(linkUrl);
|
|
94
|
-
const assets =
|
|
95
|
+
const assets = existingLink.assets;
|
|
95
96
|
```
|
package/docs/sdk-building.md
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
# Building SDKs
|
|
2
2
|
|
|
3
|
-
> Build custom SDKs on top of the Sui TypeScript SDK
|
|
3
|
+
> Build custom SDKs on top of the Sui TypeScript SDK
|
|
4
4
|
|
|
5
5
|
This guide covers recommended patterns for building TypeScript SDKs that integrate with the Sui SDK.
|
|
6
|
-
Following these patterns ensures your SDK integrates seamlessly with the ecosystem, works
|
|
7
|
-
|
|
6
|
+
Following these patterns ensures your SDK integrates seamlessly with the ecosystem, works with
|
|
7
|
+
`SuiGrpcClient` and `SuiGraphQLClient` through the shared Core API, and composes well with other
|
|
8
|
+
SDKs. Legacy JSON-RPC clients can also be supported during migration because they implement the same
|
|
9
|
+
Core API contract.
|
|
8
10
|
|
|
9
11
|
All SDKs should depend on [`ClientWithCoreApi`](./clients/core), which is the transport-agnostic
|
|
10
|
-
interface implemented by
|
|
11
|
-
|
|
12
|
+
interface implemented by Sui clients. This lets application code choose one concrete client and use
|
|
13
|
+
top-level methods, while SDK internals use `client.core` for portable reads, writes, and queries.
|
|
12
14
|
|
|
13
15
|
## Package setup
|
|
14
16
|
|
package/package.json
CHANGED
package/src/client/core.ts
CHANGED
|
@@ -134,6 +134,10 @@ export abstract class CoreClient extends BaseClient implements SuiClientTypes.Tr
|
|
|
134
134
|
options: SuiClientTypes.DefaultNameServiceNameOptions,
|
|
135
135
|
): Promise<SuiClientTypes.DefaultNameServiceNameResponse>;
|
|
136
136
|
|
|
137
|
+
abstract resolveNameServiceAddress(
|
|
138
|
+
options: SuiClientTypes.ResolveNameServiceAddressOptions,
|
|
139
|
+
): Promise<SuiClientTypes.ResolveNameServiceAddressResponse>;
|
|
140
|
+
|
|
137
141
|
async getDynamicField(
|
|
138
142
|
options: SuiClientTypes.GetDynamicFieldOptions,
|
|
139
143
|
): Promise<SuiClientTypes.GetDynamicFieldResponse> {
|
package/src/client/types.ts
CHANGED
|
@@ -757,6 +757,14 @@ export namespace SuiClientTypes {
|
|
|
757
757
|
}
|
|
758
758
|
|
|
759
759
|
/** Name service methods */
|
|
760
|
+
export interface ResolveNameServiceAddressOptions extends CoreClientMethodOptions {
|
|
761
|
+
name: string;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
export interface ResolveNameServiceAddressResponse {
|
|
765
|
+
address: string | null;
|
|
766
|
+
}
|
|
767
|
+
|
|
760
768
|
export interface DefaultNameServiceNameOptions extends CoreClientMethodOptions {
|
|
761
769
|
address: string;
|
|
762
770
|
}
|
|
@@ -768,6 +776,9 @@ export namespace SuiClientTypes {
|
|
|
768
776
|
}
|
|
769
777
|
|
|
770
778
|
export interface TransportMethods {
|
|
779
|
+
resolveNameServiceAddress: (
|
|
780
|
+
options: ResolveNameServiceAddressOptions,
|
|
781
|
+
) => Promise<ResolveNameServiceAddressResponse>;
|
|
771
782
|
defaultNameServiceName: (
|
|
772
783
|
options: DefaultNameServiceNameOptions,
|
|
773
784
|
) => Promise<DefaultNameServiceNameResponse>;
|
package/src/graphql/client.ts
CHANGED
|
@@ -369,4 +369,10 @@ export class SuiGraphQLClient<Queries extends Record<string, GraphQLDocument> =
|
|
|
369
369
|
): Promise<SuiClientTypes.DefaultNameServiceNameResponse> {
|
|
370
370
|
return this.core.defaultNameServiceName(input);
|
|
371
371
|
}
|
|
372
|
+
|
|
373
|
+
resolveNameServiceAddress(
|
|
374
|
+
input: SuiClientTypes.ResolveNameServiceAddressOptions,
|
|
375
|
+
): Promise<SuiClientTypes.ResolveNameServiceAddressResponse> {
|
|
376
|
+
return this.core.resolveNameServiceAddress(input);
|
|
377
|
+
}
|
|
372
378
|
}
|
package/src/graphql/core.ts
CHANGED
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
ListEventsDocument,
|
|
32
32
|
ListTransactionsDocument,
|
|
33
33
|
MultiGetObjectsDocument,
|
|
34
|
+
ResolveNameServiceAddressDocument,
|
|
34
35
|
ResolveTransactionDocument,
|
|
35
36
|
SimulateTransactionDocument,
|
|
36
37
|
VerifyZkLoginSignatureDocument,
|
|
@@ -776,6 +777,20 @@ export class GraphQLCoreClient extends CoreClient {
|
|
|
776
777
|
};
|
|
777
778
|
}
|
|
778
779
|
|
|
780
|
+
async resolveNameServiceAddress(
|
|
781
|
+
options: SuiClientTypes.ResolveNameServiceAddressOptions,
|
|
782
|
+
): Promise<SuiClientTypes.ResolveNameServiceAddressResponse> {
|
|
783
|
+
const { data, errors } = await this.#graphqlClient.query({
|
|
784
|
+
query: ResolveNameServiceAddressDocument,
|
|
785
|
+
signal: options.signal,
|
|
786
|
+
variables: { name: options.name },
|
|
787
|
+
});
|
|
788
|
+
|
|
789
|
+
handleGraphQLErrors(errors);
|
|
790
|
+
|
|
791
|
+
return { address: data?.address?.address ?? null };
|
|
792
|
+
}
|
|
793
|
+
|
|
779
794
|
async getMoveFunction(
|
|
780
795
|
options: SuiClientTypes.GetMoveFunctionOptions,
|
|
781
796
|
): Promise<SuiClientTypes.GetMoveFunctionResponse> {
|
|
@@ -286,6 +286,13 @@ export type DefaultSuinsNameQueryVariables = Exact<{
|
|
|
286
286
|
|
|
287
287
|
export type DefaultSuinsNameQuery = { address: { defaultNameRecord: { domain: string } | null } | null };
|
|
288
288
|
|
|
289
|
+
export type ResolveNameServiceAddressQueryVariables = Exact<{
|
|
290
|
+
name: string;
|
|
291
|
+
}>;
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
export type ResolveNameServiceAddressQuery = { address: { address: string } | null };
|
|
295
|
+
|
|
289
296
|
export type GetOwnedObjectsQueryVariables = Exact<{
|
|
290
297
|
owner: string;
|
|
291
298
|
limit?: number | null | undefined;
|
|
@@ -904,6 +911,13 @@ export const DefaultSuinsNameDocument = new TypedDocumentString(`
|
|
|
904
911
|
}
|
|
905
912
|
}
|
|
906
913
|
`) as unknown as TypedDocumentString<DefaultSuinsNameQuery, DefaultSuinsNameQueryVariables>;
|
|
914
|
+
export const ResolveNameServiceAddressDocument = new TypedDocumentString(`
|
|
915
|
+
query resolveNameServiceAddress($name: String!) {
|
|
916
|
+
address(name: $name) {
|
|
917
|
+
address
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
`) as unknown as TypedDocumentString<ResolveNameServiceAddressQuery, ResolveNameServiceAddressQueryVariables>;
|
|
907
921
|
export const GetOwnedObjectsDocument = new TypedDocumentString(`
|
|
908
922
|
query getOwnedObjects($owner: SuiAddress!, $limit: Int, $cursor: String, $filter: ObjectFilter, $includeContent: Boolean = false, $includePreviousTransaction: Boolean = false, $includeObjectBcs: Boolean = false, $includeJson: Boolean = false, $includeDisplay: Boolean = false) {
|
|
909
923
|
address(address: $owner) {
|
package/src/grpc/client.ts
CHANGED
|
@@ -336,4 +336,10 @@ export class SuiGrpcClient extends BaseClient implements SuiClientTypes.Transpor
|
|
|
336
336
|
): Promise<SuiClientTypes.DefaultNameServiceNameResponse> {
|
|
337
337
|
return this.core.defaultNameServiceName(input);
|
|
338
338
|
}
|
|
339
|
+
|
|
340
|
+
resolveNameServiceAddress(
|
|
341
|
+
input: SuiClientTypes.ResolveNameServiceAddressOptions,
|
|
342
|
+
): Promise<SuiClientTypes.ResolveNameServiceAddressResponse> {
|
|
343
|
+
return this.core.resolveNameServiceAddress(input);
|
|
344
|
+
}
|
|
339
345
|
}
|
package/src/grpc/core.ts
CHANGED
|
@@ -54,6 +54,7 @@ import {
|
|
|
54
54
|
import type { QueryEnd, QueryOptions } from './proto/sui/rpc/v2/query_options.js';
|
|
55
55
|
import { Ordering, QueryEndReason } from './proto/sui/rpc/v2/query_options.js';
|
|
56
56
|
import type { ResolvedPagination } from '../client/query-filters.js';
|
|
57
|
+
import { RpcError } from '@protobuf-ts/runtime-rpc';
|
|
57
58
|
import {
|
|
58
59
|
resolveEventFilter,
|
|
59
60
|
resolvePagination,
|
|
@@ -66,6 +67,21 @@ export interface GrpcCoreClientOptions extends CoreClientOptions {
|
|
|
66
67
|
client: SuiGrpcClient;
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
function isNameServiceResolutionMiss(error: unknown): boolean {
|
|
71
|
+
if (!(error instanceof RpcError)) return false;
|
|
72
|
+
if (error.code === 'NOT_FOUND') return true;
|
|
73
|
+
if (error.code !== 'RESOURCE_EXHAUSTED') return false;
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
// The gRPC service currently reports expired names as RESOURCE_EXHAUSTED without a
|
|
77
|
+
// structured reason. grpc-web URI-encodes status messages, so decode before matching while
|
|
78
|
+
// preserving unrelated RESOURCE_EXHAUSTED failures such as capacity limits.
|
|
79
|
+
return decodeURIComponent(error.message) === 'name has expired';
|
|
80
|
+
} catch {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
69
85
|
export class GrpcCoreClient extends CoreClient {
|
|
70
86
|
#client: SuiGrpcClient;
|
|
71
87
|
constructor({ client, ...options }: GrpcCoreClientOptions) {
|
|
@@ -797,6 +813,25 @@ export class GrpcCoreClient extends CoreClient {
|
|
|
797
813
|
};
|
|
798
814
|
}
|
|
799
815
|
|
|
816
|
+
async resolveNameServiceAddress(
|
|
817
|
+
options: SuiClientTypes.ResolveNameServiceAddressOptions,
|
|
818
|
+
): Promise<SuiClientTypes.ResolveNameServiceAddressResponse> {
|
|
819
|
+
try {
|
|
820
|
+
const { response } = await this.#client.nameService.lookupName(
|
|
821
|
+
{ name: options.name },
|
|
822
|
+
{ abort: options.signal },
|
|
823
|
+
);
|
|
824
|
+
|
|
825
|
+
return { address: response.record?.targetAddress ?? null };
|
|
826
|
+
} catch (error) {
|
|
827
|
+
if (isNameServiceResolutionMiss(error)) {
|
|
828
|
+
return { address: null };
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
throw error;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
|
|
800
835
|
async getMoveFunction(
|
|
801
836
|
options: SuiClientTypes.GetMoveFunctionOptions,
|
|
802
837
|
): Promise<SuiClientTypes.GetMoveFunctionResponse> {
|
|
@@ -1392,18 +1427,22 @@ export function parseTransactionEffects({
|
|
|
1392
1427
|
nonRefundableStorageFee: effects.gasUsed?.nonRefundableStorageFee?.toString()!,
|
|
1393
1428
|
},
|
|
1394
1429
|
transactionDigest: effects.transactionDigest!,
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1430
|
+
// gas_object is unset when the transaction has no gas object (system
|
|
1431
|
+
// transactions, or gas paid from an address balance)
|
|
1432
|
+
gasObject: effects.gasObject
|
|
1433
|
+
? {
|
|
1434
|
+
objectId: effects.gasObject.objectId!,
|
|
1435
|
+
inputState: mapInputObjectState(effects.gasObject.inputState)!,
|
|
1436
|
+
inputVersion: effects.gasObject.inputVersion?.toString() ?? null,
|
|
1437
|
+
inputDigest: effects.gasObject.inputDigest ?? null,
|
|
1438
|
+
inputOwner: mapOwner(effects.gasObject.inputOwner),
|
|
1439
|
+
outputState: mapOutputObjectState(effects.gasObject.outputState)!,
|
|
1440
|
+
outputVersion: effects.gasObject.outputVersion?.toString() ?? null,
|
|
1441
|
+
outputDigest: effects.gasObject.outputDigest ?? null,
|
|
1442
|
+
outputOwner: mapOwner(effects.gasObject.outputOwner),
|
|
1443
|
+
idOperation: mapIdOperation(effects.gasObject.idOperation)!,
|
|
1444
|
+
}
|
|
1445
|
+
: null,
|
|
1407
1446
|
eventsDigest: effects.eventsDigest ?? null,
|
|
1408
1447
|
dependencies: effects.dependencies,
|
|
1409
1448
|
lamportVersion: effects.lamportVersion?.toString() ?? null,
|