@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
package/docs/bcs.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# BCS
|
|
2
2
|
|
|
3
|
-
> Binary Canonical Serialization for encoding Sui Move types
|
|
3
|
+
> Binary Canonical Serialization for encoding Sui Move types.
|
|
4
4
|
|
|
5
5
|
The `@mysten/sui/bcs` package extends `@mysten/bcs` with Sui specific scheme definitions.
|
|
6
6
|
|
|
@@ -41,15 +41,16 @@ the following pre-defined schemes:
|
|
|
41
41
|
- `TransactionExpiration`
|
|
42
42
|
- `TransactionKind`
|
|
43
43
|
- `TypeTag`
|
|
44
|
-
- `Object
|
|
45
|
-
- `TransactionEffects
|
|
46
|
-
- `TransactionEffectsV1
|
|
47
|
-
- `TransactionEffectsV2
|
|
44
|
+
- `Object`: Complete object with data, owner, previousTransaction, and storageRebate
|
|
45
|
+
- `TransactionEffects`: Transaction execution effects (supports both V1 and V2)
|
|
46
|
+
- `TransactionEffectsV1`: Legacy transaction effects format
|
|
47
|
+
- `TransactionEffectsV2`: Current transaction effects format with detailed object changes
|
|
48
48
|
|
|
49
49
|
All the upper-cased values are `BcsType` instances, and can be used directly to parse and serialize
|
|
50
50
|
data.
|
|
51
51
|
|
|
52
52
|
```typescript
|
|
53
|
+
|
|
53
54
|
bcs.U8.serialize(1);
|
|
54
55
|
bcs.Address.serialize('0x1');
|
|
55
56
|
bcs.TypeTag.serialize({
|
|
@@ -59,13 +60,14 @@ bcs.TypeTag.serialize({
|
|
|
59
60
|
});
|
|
60
61
|
```
|
|
61
62
|
|
|
62
|
-
## Working with
|
|
63
|
+
## Working with objects
|
|
63
64
|
|
|
64
|
-
To parse
|
|
65
|
+
To parse onchain objects, fetch them with `include: { content: true }` and pass `object.content` to
|
|
65
66
|
a generated BCS type or a manual struct definition. The `content` field contains only the inner Move
|
|
66
67
|
struct bytes:
|
|
67
68
|
|
|
68
69
|
```typescript
|
|
70
|
+
|
|
69
71
|
const { object } = await client.core.getObject({
|
|
70
72
|
objectId: '0x123...',
|
|
71
73
|
include: { content: true },
|
|
@@ -74,9 +76,9 @@ const { object } = await client.core.getObject({
|
|
|
74
76
|
const parsed = MyStruct.parse(object.content);
|
|
75
77
|
```
|
|
76
78
|
|
|
77
|
-
### `bcs.Object
|
|
79
|
+
### `bcs.Object`: Full object envelope
|
|
78
80
|
|
|
79
|
-
The `bcs.Object` schema represents the complete
|
|
81
|
+
The `bcs.Object` schema represents the complete onchain object, including metadata (type, owner,
|
|
80
82
|
version, previous transaction, storage rebate) wrapping the inner struct bytes. This is what the
|
|
81
83
|
`objectBcs` include option returns. Most of this metadata is already available as fields on the
|
|
82
84
|
object response, so you typically only need `content`.
|
|
@@ -104,15 +106,16 @@ const serialized = bcs.Object.serialize({
|
|
|
104
106
|
});
|
|
105
107
|
```
|
|
106
108
|
|
|
107
|
-
> **Warning:** Do not pass `objectBcs` bytes to a Move struct parser
|
|
108
|
-
>
|
|
109
|
-
>
|
|
109
|
+
> **Warning:** Do not pass `objectBcs` bytes to a Move struct parser. It contains wrapping metadata that will
|
|
110
|
+
> cause parsing to fail. Use `content` for parsing Move struct fields. See the [Core API
|
|
111
|
+
> docs](/sui/clients/core#objectbcs) for details.
|
|
110
112
|
|
|
111
|
-
## Working with
|
|
113
|
+
## Working with transaction effects
|
|
112
114
|
|
|
113
115
|
The `bcs.TransactionEffects` schema can be used to parse transaction effects:
|
|
114
116
|
|
|
115
117
|
```typescript
|
|
118
|
+
|
|
116
119
|
// Parse transaction effects
|
|
117
120
|
const effects = bcs.TransactionEffects.parse(effectsBytes);
|
|
118
121
|
|
|
@@ -128,4 +131,4 @@ for (const [objectId, change] of effects.V2.changedObjects) {
|
|
|
128
131
|
console.log('Object:', objectId);
|
|
129
132
|
console.log('Output state:', change.outputState.$kind);
|
|
130
133
|
}
|
|
131
|
-
```
|
|
134
|
+
```
|
package/docs/clients/core.md
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
# Core API
|
|
2
2
|
|
|
3
|
-
> Transport-agnostic Core API shared by all Sui clients
|
|
3
|
+
> Transport-agnostic Core API shared by all Sui clients.
|
|
4
4
|
|
|
5
5
|
The Core API is the transport-agnostic interface that all Sui clients implement. It provides a
|
|
6
6
|
consistent set of methods for interacting with the Sui blockchain, regardless of whether you're
|
|
7
7
|
using gRPC, GraphQL, or JSON-RPC.
|
|
8
8
|
|
|
9
|
-
## ClientWithCoreApi
|
|
9
|
+
## `ClientWithCoreApi`
|
|
10
10
|
|
|
11
11
|
The `ClientWithCoreApi` type represents any client that implements the Core API. Use this type when
|
|
12
12
|
building SDKs or libraries that should work with any transport:
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
|
+
|
|
15
16
|
// Your SDK works with any client
|
|
16
17
|
class MySDK {
|
|
17
18
|
constructor(private client: ClientWithCoreApi) {}
|
|
@@ -23,7 +24,7 @@ class MySDK {
|
|
|
23
24
|
}
|
|
24
25
|
```
|
|
25
26
|
|
|
26
|
-
## Object
|
|
27
|
+
## Object methods
|
|
27
28
|
|
|
28
29
|
Object methods accept an optional `include` parameter to control what data is returned. By default,
|
|
29
30
|
every object comes with `objectId`, `version`, `digest`, `owner`, and `type`. The following fields
|
|
@@ -31,13 +32,13 @@ are only populated when requested:
|
|
|
31
32
|
|
|
32
33
|
| Option | Type | Description |
|
|
33
34
|
| --------------------- | --------- | ------------------------------------------------------------------------- |
|
|
34
|
-
| `content` | `boolean` | BCS-encoded Move struct content
|
|
35
|
+
| `content` | `boolean` | BCS-encoded Move struct content (pass this to generated BCS type parsers) |
|
|
35
36
|
| `previousTransaction` | `boolean` | Digest of the transaction that last mutated this object |
|
|
36
37
|
| `json` | `boolean` | JSON representation of the object's Move struct content |
|
|
37
|
-
| `objectBcs` | `boolean` | Full BCS-encoded object envelope (rarely needed
|
|
38
|
+
| `objectBcs` | `boolean` | Full BCS-encoded object envelope (rarely needed; see [below](#objectbcs)) |
|
|
38
39
|
| `display` | `boolean` | [Sui Display Standard](https://docs.sui.io/standards/display) metadata |
|
|
39
40
|
|
|
40
|
-
### getObject
|
|
41
|
+
### `getObject`
|
|
41
42
|
|
|
42
43
|
Fetch a single object by ID.
|
|
43
44
|
|
|
@@ -56,7 +57,7 @@ console.log(object.digest);
|
|
|
56
57
|
console.log(object.type); // e.g., "0x2::coin::Coin<0x2::sui::SUI>"
|
|
57
58
|
```
|
|
58
59
|
|
|
59
|
-
### getObjects
|
|
60
|
+
### `getObjects`
|
|
60
61
|
|
|
61
62
|
Fetch multiple objects in a single request.
|
|
62
63
|
|
|
@@ -75,7 +76,7 @@ for (const obj of objects) {
|
|
|
75
76
|
}
|
|
76
77
|
```
|
|
77
78
|
|
|
78
|
-
### listOwnedObjects
|
|
79
|
+
### `listOwnedObjects`
|
|
79
80
|
|
|
80
81
|
List objects owned by an address.
|
|
81
82
|
|
|
@@ -107,6 +108,7 @@ Use `include: { content: true }` to get the BCS-encoded Move struct bytes, then
|
|
|
107
108
|
generated types (from `@mysten/codegen`) or manual BCS definitions:
|
|
108
109
|
|
|
109
110
|
```typescript
|
|
111
|
+
|
|
110
112
|
const { object } = await client.core.getObject({
|
|
111
113
|
objectId: '0x123...',
|
|
112
114
|
include: { content: true },
|
|
@@ -119,31 +121,32 @@ const parsed = MyStruct.parse(object.content);
|
|
|
119
121
|
|
|
120
122
|
You can also fetch a JSON representation of the object's content with `include: { json: true }`.
|
|
121
123
|
|
|
122
|
-
> **Warning:** The `json` field structure
|
|
123
|
-
>
|
|
124
|
-
>
|
|
125
|
-
>
|
|
124
|
+
> **Warning:** The `json` field structure might vary between API implementations. For example, JSON-RPC returns
|
|
125
|
+
> UID fields as nested objects (`{ "id": { "id": "0x..." } }`), while gRPC and GraphQL flatten
|
|
126
|
+
> them (`{ "id": "0x..." }`). For consistent data across all clients, use `content` and parse BCS
|
|
127
|
+
> directly.
|
|
126
128
|
|
|
127
129
|
### `objectBcs`
|
|
128
130
|
|
|
129
|
-
The `objectBcs` option returns the full BCS-encoded object envelope
|
|
130
|
-
metadata (type, `hasPublicTransfer`, version, owner, previous transaction, storage
|
|
131
|
-
this metadata is already available as fields on the object response, so you
|
|
132
|
-
`content`. If you do need `objectBcs`, parse it with `bcs.Object` from
|
|
131
|
+
The `objectBcs` option returns the full BCS-encoded object envelope, which is the struct content
|
|
132
|
+
wrapped in metadata (type, `hasPublicTransfer`, version, owner, previous transaction, and storage
|
|
133
|
+
rebate). Most of this metadata is already available as fields on the object response, so you
|
|
134
|
+
typically only need `content`. If you do need `objectBcs`, parse it with `bcs.Object` from
|
|
135
|
+
`@mysten/sui/bcs`:
|
|
133
136
|
|
|
134
137
|
```typescript
|
|
138
|
+
|
|
135
139
|
const envelope = bcs.Object.parse(object.objectBcs);
|
|
136
140
|
```
|
|
137
141
|
|
|
138
|
-
> **Error:** Do not pass `objectBcs` to a Move struct parser
|
|
139
|
-
>
|
|
140
|
-
> fields.
|
|
142
|
+
> **Error:** Do not pass `objectBcs` to a Move struct parser. It contains wrapping metadata that will cause
|
|
143
|
+
> parsing to fail or produce incorrect results. Use `content` for parsing Move struct fields.
|
|
141
144
|
|
|
142
145
|
### `display` include option
|
|
143
146
|
|
|
144
147
|
The `display` option fetches [Sui Display Standard](https://docs.sui.io/standards/display) metadata
|
|
145
|
-
for an object. Display templates define how an object should be presented in wallets and explorers
|
|
146
|
-
fields like `name`, `description`, and `image_url`.
|
|
148
|
+
for an object. Display templates define how an object should be presented in wallets and explorers,
|
|
149
|
+
including fields like `name`, `description`, and `image_url`.
|
|
147
150
|
|
|
148
151
|
```typescript
|
|
149
152
|
const { object } = await client.core.getObject({
|
|
@@ -168,9 +171,9 @@ The `display` field is `null` when the object's type has no registered Display t
|
|
|
168
171
|
|
|
169
172
|
`display` works with `getObject`, `getObjects`, and `listOwnedObjects`.
|
|
170
173
|
|
|
171
|
-
## Coin and
|
|
174
|
+
## Coin and balance methods
|
|
172
175
|
|
|
173
|
-
### getBalance
|
|
176
|
+
### `getBalance`
|
|
174
177
|
|
|
175
178
|
Get the balance of a specific coin type for an owner.
|
|
176
179
|
|
|
@@ -184,7 +187,7 @@ console.log(balance.totalBalance); // Total balance as bigint
|
|
|
184
187
|
console.log(balance.coinObjectCount); // Number of coin objects
|
|
185
188
|
```
|
|
186
189
|
|
|
187
|
-
### listBalances
|
|
190
|
+
### `listBalances`
|
|
188
191
|
|
|
189
192
|
List all coin balances for an owner.
|
|
190
193
|
|
|
@@ -198,7 +201,7 @@ for (const balance of balances) {
|
|
|
198
201
|
}
|
|
199
202
|
```
|
|
200
203
|
|
|
201
|
-
### listCoins
|
|
204
|
+
### `listCoins`
|
|
202
205
|
|
|
203
206
|
List coin objects of a specific type owned by an address.
|
|
204
207
|
|
|
@@ -214,7 +217,7 @@ for (const coin of result.coins) {
|
|
|
214
217
|
}
|
|
215
218
|
```
|
|
216
219
|
|
|
217
|
-
### getCoinMetadata
|
|
220
|
+
### `getCoinMetadata`
|
|
218
221
|
|
|
219
222
|
Get metadata for a coin type, including its name, symbol, decimals, and description.
|
|
220
223
|
|
|
@@ -229,9 +232,9 @@ if (coinMetadata) {
|
|
|
229
232
|
}
|
|
230
233
|
```
|
|
231
234
|
|
|
232
|
-
## Dynamic
|
|
235
|
+
## Dynamic field methods
|
|
233
236
|
|
|
234
|
-
### listDynamicFields
|
|
237
|
+
### `listDynamicFields`
|
|
235
238
|
|
|
236
239
|
List dynamic fields on an object.
|
|
237
240
|
|
|
@@ -246,11 +249,12 @@ for (const field of result.dynamicFields) {
|
|
|
246
249
|
}
|
|
247
250
|
```
|
|
248
251
|
|
|
249
|
-
### getDynamicField
|
|
252
|
+
### `getDynamicField`
|
|
250
253
|
|
|
251
254
|
Get a specific dynamic field by name.
|
|
252
255
|
|
|
253
256
|
```typescript
|
|
257
|
+
|
|
254
258
|
const { dynamicField } = await client.core.getDynamicField({
|
|
255
259
|
parentId: '0x123...',
|
|
256
260
|
name: {
|
|
@@ -264,7 +268,7 @@ console.log(dynamicField.value.type);
|
|
|
264
268
|
console.log(dynamicField.value.bcs); // BCS-encoded value
|
|
265
269
|
```
|
|
266
270
|
|
|
267
|
-
### getDynamicObjectField
|
|
271
|
+
### `getDynamicObjectField`
|
|
268
272
|
|
|
269
273
|
Get a dynamic object field, returning the referenced object. Supports the same
|
|
270
274
|
[object include options](#object-methods) as `getObject`.
|
|
@@ -280,20 +284,20 @@ const { object } = await client.core.getDynamicObjectField({
|
|
|
280
284
|
});
|
|
281
285
|
```
|
|
282
286
|
|
|
283
|
-
## Transaction
|
|
287
|
+
## Transaction methods
|
|
284
288
|
|
|
285
289
|
Transaction methods accept an optional `include` parameter to control what data is returned. By
|
|
286
290
|
default, every transaction result includes `digest`, `signatures`, `epoch`, and `status`. The
|
|
287
291
|
following fields are only populated when requested:
|
|
288
292
|
|
|
289
|
-
| Option | Type | Description
|
|
290
|
-
| ---------------- | --------- |
|
|
291
|
-
| `effects` | `boolean` | Parsed transaction effects (gas used, changed objects, status
|
|
292
|
-
| `events` | `boolean` | Events emitted during execution
|
|
293
|
-
| `transaction` | `boolean` | Parsed transaction data (sender, gas config, inputs, commands)
|
|
294
|
-
| `balanceChanges` | `boolean` | Balance changes caused by the transaction
|
|
295
|
-
| `objectTypes` | `boolean` | Map of object IDs to their types for all changed objects
|
|
296
|
-
| `bcs` | `boolean` | Raw BCS-encoded transaction bytes
|
|
293
|
+
| Option | Type | Description |
|
|
294
|
+
| ---------------- | --------- | ------------------------------------------------------------------ |
|
|
295
|
+
| `effects` | `boolean` | Parsed transaction effects (gas used, changed objects, and status) |
|
|
296
|
+
| `events` | `boolean` | Events emitted during execution |
|
|
297
|
+
| `transaction` | `boolean` | Parsed transaction data (sender, gas config, inputs, commands) |
|
|
298
|
+
| `balanceChanges` | `boolean` | Balance changes caused by the transaction |
|
|
299
|
+
| `objectTypes` | `boolean` | Map of object IDs to their types for all changed objects |
|
|
300
|
+
| `bcs` | `boolean` | Raw BCS-encoded transaction bytes |
|
|
297
301
|
|
|
298
302
|
`simulateTransaction` also supports:
|
|
299
303
|
|
|
@@ -301,7 +305,7 @@ following fields are only populated when requested:
|
|
|
301
305
|
| ---------------- | --------- | ------------------------------------------------------ |
|
|
302
306
|
| `commandResults` | `boolean` | Return values and mutated references from each command |
|
|
303
307
|
|
|
304
|
-
### executeTransaction
|
|
308
|
+
### `executeTransaction`
|
|
305
309
|
|
|
306
310
|
Execute a signed transaction.
|
|
307
311
|
|
|
@@ -323,7 +327,7 @@ if (result.Transaction) {
|
|
|
323
327
|
}
|
|
324
328
|
```
|
|
325
329
|
|
|
326
|
-
### simulateTransaction
|
|
330
|
+
### `simulateTransaction`
|
|
327
331
|
|
|
328
332
|
Simulate a transaction without executing it.
|
|
329
333
|
|
|
@@ -342,7 +346,7 @@ console.log(result.effects);
|
|
|
342
346
|
console.log(result.balanceChanges);
|
|
343
347
|
```
|
|
344
348
|
|
|
345
|
-
#### Disabling
|
|
349
|
+
#### Disabling checks
|
|
346
350
|
|
|
347
351
|
By default, `simulateTransaction` runs with full transaction validation. For example when inspecting
|
|
348
352
|
non-public or non-entry Move functions set `checksEnabled: false`:
|
|
@@ -357,11 +361,12 @@ const result = await client.core.simulateTransaction({
|
|
|
357
361
|
});
|
|
358
362
|
```
|
|
359
363
|
|
|
360
|
-
### signAndExecuteTransaction
|
|
364
|
+
### `signAndExecuteTransaction`
|
|
361
365
|
|
|
362
366
|
Sign and execute a transaction in one step.
|
|
363
367
|
|
|
364
368
|
```typescript
|
|
369
|
+
|
|
365
370
|
const tx = new Transaction();
|
|
366
371
|
tx.transferObjects([tx.object('0x123...')], '0xrecipient...');
|
|
367
372
|
|
|
@@ -379,7 +384,7 @@ if (result.FailedTransaction) {
|
|
|
379
384
|
console.log('Digest:', result.Transaction.digest);
|
|
380
385
|
```
|
|
381
386
|
|
|
382
|
-
### getTransaction
|
|
387
|
+
### `getTransaction`
|
|
383
388
|
|
|
384
389
|
Fetch a transaction by digest.
|
|
385
390
|
|
|
@@ -410,7 +415,7 @@ const result = await client.core.getTransaction({
|
|
|
410
415
|
console.log(result.Transaction?.bcs); // Uint8Array
|
|
411
416
|
```
|
|
412
417
|
|
|
413
|
-
### waitForTransaction
|
|
418
|
+
### `waitForTransaction`
|
|
414
419
|
|
|
415
420
|
Wait for a transaction to be available.
|
|
416
421
|
|
|
@@ -433,9 +438,9 @@ const finalResult = await client.core.waitForTransaction({
|
|
|
433
438
|
});
|
|
434
439
|
```
|
|
435
440
|
|
|
436
|
-
## System
|
|
441
|
+
## System methods
|
|
437
442
|
|
|
438
|
-
### getReferenceGasPrice
|
|
443
|
+
### `getReferenceGasPrice`
|
|
439
444
|
|
|
440
445
|
Get the current reference gas price.
|
|
441
446
|
|
|
@@ -444,7 +449,7 @@ const { referenceGasPrice } = await client.core.getReferenceGasPrice();
|
|
|
444
449
|
console.log(referenceGasPrice); // bigint
|
|
445
450
|
```
|
|
446
451
|
|
|
447
|
-
### getCurrentSystemState
|
|
452
|
+
### `getCurrentSystemState`
|
|
448
453
|
|
|
449
454
|
Get the current system state including epoch information.
|
|
450
455
|
|
|
@@ -454,7 +459,7 @@ console.log(systemState.epoch);
|
|
|
454
459
|
console.log(systemState.systemStateVersion);
|
|
455
460
|
```
|
|
456
461
|
|
|
457
|
-
### getChainIdentifier
|
|
462
|
+
### `getChainIdentifier`
|
|
458
463
|
|
|
459
464
|
Get the chain identifier for the network.
|
|
460
465
|
|
|
@@ -463,9 +468,9 @@ const { chainIdentifier } = await client.core.getChainIdentifier();
|
|
|
463
468
|
console.log(chainIdentifier); // e.g., "4c78adac"
|
|
464
469
|
```
|
|
465
470
|
|
|
466
|
-
## Move
|
|
471
|
+
## Move methods
|
|
467
472
|
|
|
468
|
-
### getMoveFunction
|
|
473
|
+
### `getMoveFunction`
|
|
469
474
|
|
|
470
475
|
Get information about a Move function.
|
|
471
476
|
|
|
@@ -481,9 +486,9 @@ console.log(fn.parameters);
|
|
|
481
486
|
console.log(fn.typeParameters);
|
|
482
487
|
```
|
|
483
488
|
|
|
484
|
-
## Name
|
|
489
|
+
## Name service methods
|
|
485
490
|
|
|
486
|
-
### defaultNameServiceName
|
|
491
|
+
### `defaultNameServiceName`
|
|
487
492
|
|
|
488
493
|
Resolve an address to its default SuiNS name.
|
|
489
494
|
|
|
@@ -495,11 +500,11 @@ const { name } = await client.core.defaultNameServiceName({
|
|
|
495
500
|
console.log(name); // e.g., "example.sui"
|
|
496
501
|
```
|
|
497
502
|
|
|
498
|
-
## MVR
|
|
503
|
+
## MVR methods
|
|
499
504
|
|
|
500
505
|
The client also exposes MVR (Move Registry) methods through `client.core.mvr`:
|
|
501
506
|
|
|
502
|
-
### resolveType
|
|
507
|
+
### `resolveType`
|
|
503
508
|
|
|
504
509
|
Resolve a type name (including `.move` names) to a fully qualified type.
|
|
505
510
|
|
|
@@ -511,9 +516,9 @@ const { type } = await client.core.mvr.resolveType({
|
|
|
511
516
|
console.log(type); // "0x2::coin::Coin<0x2::sui::SUI>"
|
|
512
517
|
```
|
|
513
518
|
|
|
514
|
-
## Error
|
|
519
|
+
## Error handling
|
|
515
520
|
|
|
516
|
-
Methods that fetch objects
|
|
521
|
+
Methods that fetch objects might return errors in the result:
|
|
517
522
|
|
|
518
523
|
```typescript
|
|
519
524
|
const { objects } = await client.core.getObjects({
|
|
@@ -545,12 +550,13 @@ if (result.Transaction) {
|
|
|
545
550
|
}
|
|
546
551
|
```
|
|
547
552
|
|
|
548
|
-
## SuiClientTypes Namespace
|
|
553
|
+
## `SuiClientTypes` Namespace
|
|
549
554
|
|
|
550
555
|
The `SuiClientTypes` namespace contains all type definitions for the Core API. Import it when you
|
|
551
556
|
need to type function parameters, return values, or variables:
|
|
552
557
|
|
|
553
558
|
```typescript
|
|
559
|
+
|
|
554
560
|
// Type function parameters
|
|
555
561
|
function processObject(obj: SuiClientTypes.Object<{ content: true }>) {
|
|
556
562
|
console.log(obj.objectId, obj.content);
|
|
@@ -572,7 +578,7 @@ const options: SuiClientTypes.GetObjectOptions<{ content: true }> = {
|
|
|
572
578
|
};
|
|
573
579
|
```
|
|
574
580
|
|
|
575
|
-
### Common
|
|
581
|
+
### Common types
|
|
576
582
|
|
|
577
583
|
| Type | Description |
|
|
578
584
|
| ---------------------- | ------------------------------------------- |
|
|
@@ -590,7 +596,7 @@ const options: SuiClientTypes.GetObjectOptions<{ content: true }> = {
|
|
|
590
596
|
| `FunctionResponse` | Move function metadata |
|
|
591
597
|
| `Network` | Network identifier type |
|
|
592
598
|
|
|
593
|
-
### Include
|
|
599
|
+
### Include options types
|
|
594
600
|
|
|
595
601
|
| Type | Description |
|
|
596
602
|
| ---------------------------- | --------------------------------------- |
|
|
@@ -598,7 +604,7 @@ const options: SuiClientTypes.GetObjectOptions<{ content: true }> = {
|
|
|
598
604
|
| `TransactionInclude` | Options for transaction data inclusion |
|
|
599
605
|
| `SimulateTransactionInclude` | Extended options for simulation results |
|
|
600
606
|
|
|
601
|
-
### Method
|
|
607
|
+
### Method options types
|
|
602
608
|
|
|
603
609
|
| Type | Description |
|
|
604
610
|
| ---------------------------------- | --------------------------------------- |
|
|
@@ -613,4 +619,4 @@ const options: SuiClientTypes.GetObjectOptions<{ content: true }> = {
|
|
|
613
619
|
| `SimulateTransactionOptions` | Options for `simulateTransaction` |
|
|
614
620
|
| `SignAndExecuteTransactionOptions` | Options for `signAndExecuteTransaction` |
|
|
615
621
|
| `GetTransactionOptions` | Options for `getTransaction` |
|
|
616
|
-
| `WaitForTransactionOptions` | Options for `waitForTransaction` |
|
|
622
|
+
| `WaitForTransactionOptions` | Options for `waitForTransaction` |
|
package/docs/clients/graphql.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# SuiGraphQLClient
|
|
2
2
|
|
|
3
|
-
> Connect to Sui
|
|
3
|
+
> Connect to Sui through GraphQL with SuiGraphQLClient.
|
|
4
4
|
|
|
5
5
|
The `SuiGraphQLClient` enables type-safe GraphQL queries against the Sui GraphQL API.
|
|
6
6
|
|
|
@@ -10,6 +10,7 @@ For more details on the Sui GraphQL API, see the
|
|
|
10
10
|
The `SuiGraphQLClient` implements all the the [Core API](/sui/clients/core) methods:
|
|
11
11
|
|
|
12
12
|
```typescript
|
|
13
|
+
|
|
13
14
|
const client = new SuiGraphQLClient({
|
|
14
15
|
url: 'https://sui-mainnet.mystenlabs.com/graphql',
|
|
15
16
|
network: 'mainnet',
|
|
@@ -26,6 +27,7 @@ queries.
|
|
|
26
27
|
We'll start by creating our client, and executing a very basic query:
|
|
27
28
|
|
|
28
29
|
```typescript
|
|
30
|
+
|
|
29
31
|
const gqlClient = new SuiGraphQLClient({
|
|
30
32
|
url: 'https://graphql.testnet.sui.io/graphql',
|
|
31
33
|
network: 'testnet',
|
|
@@ -48,7 +50,7 @@ async function getChainIdentifier() {
|
|
|
48
50
|
|
|
49
51
|
## Type-safety for GraphQL queries
|
|
50
52
|
|
|
51
|
-
You
|
|
53
|
+
You might have noticed the example above does not include any type definitions for the query. The
|
|
52
54
|
`graphql` function used in the example is powered by [`gql.tada`](https://gql-tada.0no.co/) and will
|
|
53
55
|
automatically provide the required type information to ensure that your queries are properly typed
|
|
54
56
|
when executed through `SuiGraphQLClient`.
|
|
@@ -80,7 +82,7 @@ async function getDefaultSuinsName(address: string) {
|
|
|
80
82
|
## Using typed GraphQL queries with other GraphQL clients
|
|
81
83
|
|
|
82
84
|
The `graphql` function returns document nodes that implement the
|
|
83
|
-
[TypedDocumentNode](https://github.com/dotansimha/graphql-typed-document-node) standard, and will
|
|
85
|
+
[`TypedDocumentNode`](https://github.com/dotansimha/graphql-typed-document-node) standard, and will
|
|
84
86
|
work with the majority of popular GraphQL clients to provide queries that are automatically typed.
|
|
85
87
|
|
|
86
88
|
```typescript
|
|
@@ -96,4 +98,4 @@ function ChainIdentifier() {
|
|
|
96
98
|
|
|
97
99
|
return <div>{data?.chainIdentifier}</div>;
|
|
98
100
|
}
|
|
99
|
-
```
|
|
101
|
+
```
|
package/docs/clients/grpc.md
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
# SuiGrpcClient
|
|
2
2
|
|
|
3
|
-
> Connect to Sui
|
|
3
|
+
> Connect to Sui through gRPC with SuiGrpcClient.
|
|
4
4
|
|
|
5
5
|
The `SuiGrpcClient` provides access to the Full Node gRPC API.
|
|
6
6
|
|
|
7
7
|
For more complete details on what is available through this API see the
|
|
8
|
-
[gRPC API docs](https://docs.sui.io/
|
|
8
|
+
[gRPC API docs](https://docs.sui.io/develop/accessing-data/grpc/what-is-grpc).
|
|
9
9
|
|
|
10
10
|
## Creating a gRPC client
|
|
11
11
|
|
|
12
12
|
To get started, create a `SuiGrpcClient` instance by specifying a network and base URL:
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
|
+
|
|
15
16
|
const grpcClient = new SuiGrpcClient({
|
|
16
17
|
network: 'testnet',
|
|
17
18
|
baseUrl: 'https://fullnode.testnet.sui.io:443',
|
|
@@ -30,8 +31,8 @@ const grpcClient = new SuiGrpcClient({
|
|
|
30
31
|
## Transport options
|
|
31
32
|
|
|
32
33
|
By default, `SuiGrpcClient` uses `GrpcWebFetchTransport` from
|
|
33
|
-
[protobuf-ts](https://github.com/timostamm/protobuf-ts), which works in browsers and Node.js
|
|
34
|
-
Fetch API. You can also provide a custom transport for advanced use cases.
|
|
34
|
+
[protobuf-ts](https://github.com/timostamm/protobuf-ts), which works in browsers and Node.js through
|
|
35
|
+
the Fetch API. You can also provide a custom transport for advanced use cases.
|
|
35
36
|
|
|
36
37
|
The `GrpcWebFetchTransport` class, `GrpcWebOptions` type, and `RpcTransport` type are all
|
|
37
38
|
re-exported from `@mysten/sui/grpc` for convenience.
|
|
@@ -42,6 +43,7 @@ The default transport uses the gRPC-web protocol over HTTP/1.1 or HTTP/2. You ca
|
|
|
42
43
|
passing `GrpcWebFetchTransport` options directly:
|
|
43
44
|
|
|
44
45
|
```typescript
|
|
46
|
+
|
|
45
47
|
const transport = new GrpcWebFetchTransport({
|
|
46
48
|
baseUrl: 'https://your-custom-grpc-endpoint.com',
|
|
47
49
|
format: 'binary', // default is 'text' (base64-encoded)
|
|
@@ -56,7 +58,7 @@ const grpcClient = new SuiGrpcClient({
|
|
|
56
58
|
|
|
57
59
|
### Native gRPC transport
|
|
58
60
|
|
|
59
|
-
For server-side applications (Node.js, Bun,
|
|
61
|
+
For server-side applications (Node.js, Bun, and others), you can use the native gRPC transport with
|
|
60
62
|
`@protobuf-ts/grpc-transport` and `@grpc/grpc-js`. This uses HTTP/2 with the native gRPC protocol
|
|
61
63
|
rather than the gRPC-web translation layer.
|
|
62
64
|
|
|
@@ -69,6 +71,7 @@ npm install @protobuf-ts/grpc-transport @grpc/grpc-js
|
|
|
69
71
|
Then create the client with a `GrpcTransport`:
|
|
70
72
|
|
|
71
73
|
```typescript
|
|
74
|
+
|
|
72
75
|
const transport = new GrpcTransport({
|
|
73
76
|
host: 'fullnode.testnet.sui.io:443',
|
|
74
77
|
channelCredentials: ChannelCredentials.createSsl(),
|
|
@@ -83,6 +86,7 @@ const grpcClient = new SuiGrpcClient({
|
|
|
83
86
|
For local development without TLS:
|
|
84
87
|
|
|
85
88
|
```typescript
|
|
89
|
+
|
|
86
90
|
const transport = new GrpcTransport({
|
|
87
91
|
host: '127.0.0.1:9000',
|
|
88
92
|
channelCredentials: ChannelCredentials.createInsecure(),
|
|
@@ -99,13 +103,14 @@ const grpcClient = new SuiGrpcClient({
|
|
|
99
103
|
The `SuiGrpcClient` exposes several service clients for lower-level access to the gRPC API. These
|
|
100
104
|
service clients are generated using [protobuf-ts](https://github.com/timostamm/protobuf-ts), which
|
|
101
105
|
provides type-safe gRPC clients for TypeScript. For more details on how to use gRPC with Sui, see
|
|
102
|
-
the [gRPC overview](https://docs.sui.io/
|
|
106
|
+
the [gRPC overview](https://docs.sui.io/develop/accessing-data/grpc/what-is-grpc).
|
|
103
107
|
|
|
104
108
|
### With the core API
|
|
105
109
|
|
|
106
110
|
The gRPC client implements all the [`core`](./core) API methods:
|
|
107
111
|
|
|
108
112
|
```typescript
|
|
113
|
+
|
|
109
114
|
const grpcClient = new SuiGrpcClient({
|
|
110
115
|
network: 'testnet',
|
|
111
116
|
baseUrl: 'https://fullnode.testnet.sui.io:443',
|
|
@@ -118,7 +123,7 @@ await grpcClient.getCoins({
|
|
|
118
123
|
|
|
119
124
|
To query additional data not available in the core API, you can use the service clients directly:
|
|
120
125
|
|
|
121
|
-
### Transaction
|
|
126
|
+
### Transaction execution service
|
|
122
127
|
|
|
123
128
|
```typescript
|
|
124
129
|
const { response } = await grpcClient.transactionExecutionService.executeTransaction({
|
|
@@ -140,7 +145,7 @@ if (!response.finality?.effects?.status?.success) {
|
|
|
140
145
|
}
|
|
141
146
|
```
|
|
142
147
|
|
|
143
|
-
### Ledger
|
|
148
|
+
### Ledger service
|
|
144
149
|
|
|
145
150
|
```typescript
|
|
146
151
|
// Get transaction by digest
|
|
@@ -152,7 +157,7 @@ const { response } = await grpcClient.ledgerService.getTransaction({
|
|
|
152
157
|
const { response: epochInfo } = await grpcClient.ledgerService.getEpoch({});
|
|
153
158
|
```
|
|
154
159
|
|
|
155
|
-
### State
|
|
160
|
+
### State service
|
|
156
161
|
|
|
157
162
|
```typescript
|
|
158
163
|
// List owned objects
|
|
@@ -167,7 +172,7 @@ const { response: fields } = await grpcClient.stateService.listDynamicFields({
|
|
|
167
172
|
});
|
|
168
173
|
```
|
|
169
174
|
|
|
170
|
-
### Move
|
|
175
|
+
### Move package service
|
|
171
176
|
|
|
172
177
|
```typescript
|
|
173
178
|
// Get function information
|
|
@@ -178,7 +183,7 @@ const { response } = await grpcClient.movePackageService.getFunction({
|
|
|
178
183
|
});
|
|
179
184
|
```
|
|
180
185
|
|
|
181
|
-
### Name
|
|
186
|
+
### Name service
|
|
182
187
|
|
|
183
188
|
```typescript
|
|
184
189
|
// Reverse lookup address to get name
|
|
@@ -187,7 +192,7 @@ const { response } = await grpcClient.nameService.reverseLookupName({
|
|
|
187
192
|
});
|
|
188
193
|
```
|
|
189
194
|
|
|
190
|
-
### Signature
|
|
195
|
+
### Signature verification service
|
|
191
196
|
|
|
192
197
|
```typescript
|
|
193
198
|
// Verify a signature
|
|
@@ -202,4 +207,4 @@ const { response } = await grpcClient.signatureVerificationService.verifySignatu
|
|
|
202
207
|
},
|
|
203
208
|
jwks: [],
|
|
204
209
|
});
|
|
205
|
-
```
|
|
210
|
+
```
|