@mysten/docs 0.1.28 → 0.1.29

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.
@@ -296,8 +296,9 @@ they don't affect serialization. The generated type is a constant rather than a
296
296
  This works correctly for parsing onchain data because phantom types don't change the binary layout.
297
297
 
298
298
  > **Note:** With the default behavior, phantom parameters appear as literals in the type name (for example,
299
- > `Balance<phantom T>`). These names are useful for debugging but are not valid onchain type tags. If
300
- > you need valid type names with resolved phantom parameters, enable `includePhantomTypeParameters`.
299
+ > `Balance<phantom T>`). These names are useful for debugging but are not valid onchain type tags. Use
300
+ > the [`typeTag` method](#getting-type-tags) to build valid type tags with the phantom parameters
301
+ > filled in.
301
302
 
302
303
  ### Including phantom type parameters
303
304
 
@@ -372,6 +373,69 @@ async function readCounter(client: ClientWithCoreApi, id: string) {
372
373
  > contains a full object envelope with additional metadata that will cause parsing to fail. See the
373
374
  > [Core API docs](/sui/clients/core#objectbcs) for details.
374
375
 
376
+ ### Getting type tags
377
+
378
+ Generated types build their own type tag strings with the `typeTag` method, so you don't hand-write
379
+ strings like `` `${packageId}::module::Name<${coinType}>` ``. By default the tag uses the package
380
+ the type was generated from — a real address for framework types, or the configured name for a local
381
+ or MVR package:
382
+
383
+ ```typescript
384
+
385
+ Balance.typeTag({ typeArguments: ['0x2::sui::SUI'] });
386
+ // '0x2::balance::Balance<0x2::sui::SUI>'
387
+
388
+ Counter.typeTag();
389
+ // '@local-pkg/counter::counter::Counter'
390
+ ```
391
+
392
+ Types with phantom type parameters require `typeArguments`; types without them take none. This is
393
+ enforced at compile time:
394
+
395
+ ```typescript
396
+ Counter.typeTag(); // ok — no type parameters
397
+ Balance.typeTag({ typeArguments: ['0x2::sui::SUI'] }); // ok
398
+
399
+ // @ts-expect-error — Balance has a phantom parameter, typeArguments is required
400
+ Balance.typeTag();
401
+ ```
402
+
403
+ `typeArguments` is the full positional list, in Move declaration order. Each entry is a type tag
404
+ string, another `typeTag()` result, or a BCS type (its `name` is used):
405
+
406
+ ```typescript
407
+
408
+ Balance.typeTag({ typeArguments: [bcs.u64()] });
409
+ // '0x2::balance::Balance<u64>'
410
+ ```
411
+
412
+ To override the package identifier — for example, to pin a specific published address — pass
413
+ `package`:
414
+
415
+ ```typescript
416
+ Counter.typeTag({ package: '0xPACKAGE_ID' });
417
+ // '0xPACKAGE_ID::counter::Counter'
418
+ ```
419
+
420
+ ### Resolving type tags
421
+
422
+ For a local or MVR package, `typeTag` returns the configured name (`@local-pkg/counter::…`). That is
423
+ valid in transaction `typeArguments` — it resolves automatically when the transaction is built — but
424
+ query filters and comparisons against onchain data need a resolved, address-only tag.
425
+ `resolveTypeTag` takes the same options as `typeTag` plus a `client`, resolves any names through it,
426
+ and normalizes the result:
427
+
428
+ ```typescript
429
+ const counterType = await Counter.resolveTypeTag({ client });
430
+ // '0x0000…0123::counter::Counter'
431
+
432
+ const balanceType = await Balance.resolveTypeTag({
433
+ client,
434
+ typeArguments: ['0x2::sui::SUI'],
435
+ });
436
+ // '0x0000…0002::balance::Balance<0x0000…0002::sui::SUI>'
437
+ ```
438
+
375
439
  ## Client configuration
376
440
 
377
441
  ### Using with MVR (Move Version Registry)
@@ -92,22 +92,26 @@ These JSON-RPC methods have direct replacements in the core API:
92
92
 
93
93
  These JSON-RPC methods can be replaced by calling gRPC service clients directly:
94
94
 
95
- | JSON-RPC Method | gRPC Service Replacement |
96
- | ----------------------------------- | --------------------------------------------------------------- |
97
- | `getCheckpoint` | `ledgerService.getCheckpoint` |
98
- | `getCheckpoints` | `ledgerService.listCheckpoints` |
99
- | `getLatestCheckpointSequenceNumber` | `ledgerService.getCheckpoint` |
100
- | `getEpochs` | `ledgerService.listEpochs` |
101
- | `getCurrentEpoch` | `ledgerService.getEpoch` |
102
- | `getLatestSuiSystemState` | `ledgerService.getSystemState` |
103
- | `getCommitteeInfo` | `ledgerService.getCommittee` |
104
- | `getValidatorsApy` | `ledgerService.getValidators` |
105
- | `getProtocolConfig` | `ledgerService.getProtocolConfig` |
106
- | `getNormalizedMoveModule` | `movePackageService.getPackage` (response includes all modules) |
107
- | `getNormalizedMoveModulesByPackage` | `movePackageService.getPackage` |
108
- | `getNormalizedMoveStruct` | `movePackageService.getDatatype` |
109
- | `resolveNameServiceAddress` | `nameService.lookupName` |
110
- | `resolveNameServiceNames` | `nameService.reverseLookupName` |
95
+ | JSON-RPC Method | gRPC Service Replacement |
96
+ | ----------------------------------- | ---------------------------------------------------------------- |
97
+ | `getCheckpoint` | `ledgerService.getCheckpoint` |
98
+ | `getLatestCheckpointSequenceNumber` | `ledgerService.getServiceInfo` (read `checkpointHeight`) |
99
+ | `getCurrentEpoch` | `ledgerService.getEpoch` (omit `epoch` for the current) |
100
+ | `getLatestSuiSystemState` | `ledgerService.getEpoch` with `system_state` in the read mask |
101
+ | `getCommitteeInfo` | `ledgerService.getEpoch` with `committee` in the read mask |
102
+ | `getProtocolConfig` | `ledgerService.getEpoch` with `protocol_config` in the read mask |
103
+ | `getCoinMetadata` | `stateService.getCoinInfo` (response includes `metadata`) |
104
+ | `getTotalSupply` | `stateService.getCoinInfo` (response includes `treasury`) |
105
+ | `getNormalizedMoveModule` | `movePackageService.getPackage` (response includes all modules) |
106
+ | `getNormalizedMoveModulesByPackage` | `movePackageService.getPackage` |
107
+ | `getNormalizedMoveStruct` | `movePackageService.getDatatype` |
108
+ | `resolveNameServiceAddress` | `nameService.lookupName` |
109
+ | `resolveNameServiceNames` | `nameService.reverseLookupName` |
110
+
111
+ > **Warning:** `getCheckpoints` and `getEpochs` (paginated listings) have no gRPC equivalent — use the
112
+ > `checkpoints` / `epochs` GraphQL queries instead. `getValidatorsApy` also has no replacement:
113
+ > there is no canonical definition of validator APY, so it must be computed client-side from
114
+ > validator exchange rates (see [Validator APY](#validator-apy) below).
111
115
 
112
116
  ### Example: using gRPC service clients
113
117
 
@@ -118,13 +122,32 @@ const client = new SuiGrpcClient({
118
122
  network: 'mainnet',
119
123
  });
120
124
 
121
- // Get checkpoint information
125
+ // Get the latest checkpoint sequence number (replaces getLatestCheckpointSequenceNumber)
126
+ const { response: info } = await client.ledgerService.getServiceInfo({});
127
+ const latestCheckpoint = info.checkpointHeight;
128
+
129
+ // Get a specific checkpoint by sequence number. `checkpointId` is required (a oneof);
130
+ // the read mask defaults to `sequence_number,digest`, so request more fields as needed.
122
131
  const { response } = await client.ledgerService.getCheckpoint({
123
- sequenceNumber: 12345n,
132
+ checkpointId: { oneofKind: 'sequenceNumber', sequenceNumber: latestCheckpoint },
124
133
  });
125
134
 
126
- // Get current epoch
127
- const { response: epoch } = await client.ledgerService.getEpoch({});
135
+ // Get the current epoch (omit `epoch` for the current one). The system state,
136
+ // committee, and protocol config are NOT returned by default — you must request
137
+ // them via the read mask (the default mask is just `epoch`).
138
+ const { response: epoch } = await client.ledgerService.getEpoch({
139
+ readMask: { paths: ['epoch', 'system_state', 'committee', 'protocol_config'] },
140
+ });
141
+ const systemState = epoch.epoch?.systemState;
142
+ const committee = epoch.epoch?.committee;
143
+ const protocolConfig = epoch.epoch?.protocolConfig;
144
+
145
+ // Get coin metadata and total supply in one call
146
+ const { response: coinInfo } = await client.stateService.getCoinInfo({
147
+ coinType: '0x2::sui::SUI',
148
+ });
149
+ const metadata = coinInfo.metadata;
150
+ const totalSupply = coinInfo.treasury?.totalSupply;
128
151
 
129
152
  // Get Move package information (includes all modules)
130
153
  const { response: pkg } = await client.movePackageService.getPackage({
@@ -148,19 +171,21 @@ const { response: address } = await client.nameService.lookupName({
148
171
 
149
172
  Some JSON-RPC methods don't have gRPC equivalents and require using `SuiGraphQLClient` instead:
150
173
 
151
- | JSON-RPC Method | GraphQL Alternative |
152
- | --------------------------- | ---------------------------------- |
153
- | `queryTransactionBlocks` | `transactions` query |
154
- | `multiGetTransactionBlocks` | `multiGetTransactionEffects` query |
155
- | `queryEvents` | `events` query |
156
- | `getCoinMetadata` | `coinMetadata` query |
157
- | `getTotalSupply` | `coinMetadata` query |
158
- | `getStakes` | `address.stakedSuis` query |
159
- | `getStakesByIds` | `multiGetObjects` query |
160
- | `tryGetPastObject` | Historical object queries |
161
- | `getNetworkMetrics` | Use indexer |
162
- | `getAddressMetrics` | Use indexer |
163
- | `getMoveCallMetrics` | Use indexer |
174
+ | JSON-RPC Method | GraphQL Alternative |
175
+ | --------------------------- | --------------------------------------------------------- |
176
+ | `queryTransactionBlocks` | `transactions` query |
177
+ | `multiGetTransactionBlocks` | `multiGetTransactionEffects` query |
178
+ | `queryEvents` | `events` query |
179
+ | `getCheckpoints` | `checkpoints` query |
180
+ | `getEpochs` | `epochs` query |
181
+ | `getCoinMetadata` | `coinMetadata` query (or gRPC `stateService.getCoinInfo`) |
182
+ | `getTotalSupply` | `coinMetadata` query (or gRPC `stateService.getCoinInfo`) |
183
+ | `getStakes` | `address.stakedSuis` query |
184
+ | `getStakesByIds` | `multiGetObjects` query |
185
+ | `tryGetPastObject` | Historical object queries |
186
+ | `getNetworkMetrics` | Use indexer |
187
+ | `getAddressMetrics` | Use indexer |
188
+ | `getMoveCallMetrics` | Use indexer |
164
189
 
165
190
  ### Setting up GraphQL client
166
191
 
@@ -364,6 +389,24 @@ const result = await graphqlClient.query({
364
389
  });
365
390
  ```
366
391
 
392
+ ## Validator APY
393
+
394
+ There is **no replacement** for `getValidatorsApy`, and one will not be added. There is no canonical
395
+ definition of validator APY — no other chain's core/general-purpose RPCs offer this endpoint — so it
396
+ must be computed client-side from validator staking-pool exchange rates.
397
+
398
+ The general approach: read each validator's `exchangeRates` (a table of `pool_token_amount` /
399
+ `sui_amount` per epoch) and estimate the annualized rate from the change in exchange rate over the
400
+ trailing epochs. Two concrete reference implementations:
401
+
402
+ - The `jsonrpc-alt` implementation in
403
+ [`sui-indexer-alt-jsonrpc`](https://github.com/MystenLabs/sui/blob/31537d4d9235b9f61dc07a3a71b05ed61a2bda7b/crates/sui-indexer-alt-jsonrpc/src/api/governance.rs#L422-L440),
404
+ which is compact and readable.
405
+ - [This GraphQL approach](https://github.com/MystenLabs/sui/issues/23832#issuecomment-4437791087),
406
+ which fetches the precursor exchange-rate information in a single query.
407
+
408
+ Treat whichever formula you adopt as _a_ definition of validator APY, not _the_ definition.
409
+
367
410
  ## Response format differences
368
411
 
369
412
  The gRPC client uses the core API response format, which differs from JSON-RPC responses. See the
@@ -255,4 +255,28 @@ function transferToSender(objects: TransactionObjectInput[]) {
255
255
 
256
256
  const transaction = new Transaction();
257
257
  transaction.add(transferToSender(['0x1234']));
258
- ```
258
+ ```
259
+
260
+ ## Copying transactions that use custom intents
261
+
262
+ `Transaction.from` creates a deep copy of a transaction. Copying is synchronous, so any unresolved
263
+ intents are carried over as-is and resolved later when the copy is built or serialized. To do that,
264
+ the copy needs the intent resolvers, but resolvers are functions and cannot be represented in the
265
+ serialized transaction data.
266
+
267
+ Built-in intents (such as the `CoinWithBalance` intent added by `tx.coin()`) are re-attached
268
+ automatically. For custom intents, pass the resolvers through the `intentResolvers` option so the
269
+ copy knows how to resolve them:
270
+
271
+ ```typescript
272
+
273
+ const copy = Transaction.from(transaction, {
274
+ intentResolvers: {
275
+ TransferToSender: resolveTransferToSender,
276
+ },
277
+ });
278
+ ```
279
+
280
+ Without this, `Transaction.from` throws if the transaction still contains unresolved custom intents.
281
+ Alternatively, you can `await transaction.prepareForSerialization()` first to resolve the intents
282
+ before copying, but that requires an async call and (for some intents) a client.
@@ -240,14 +240,16 @@ for (const coin of objects) {
240
240
  Gasless transactions enable peer-to-peer payments of qualified stablecoins to execute without paying
241
241
  gas fees in SUI. The sender does not need to hold SUI in their wallet. Gasless transactions are an
242
242
  extension of
243
- [address balances](https://docs.sui.io/guides/developer/digital-assets/address-balances), using
244
- `send_funds()` with `gas=0` and `gas_budget=0`. See the
245
- [Sui gasless transactions guide](https://docs.sui.io/guides/developer/transactions/gasless-transactions)
246
- for full details.
243
+ [address balances](https://docs.sui.io/onchain-finance/asset-custody/address-balances/using-address-balances),
244
+ built around `0x2::balance::send_funds` with `gasPrice = 0` and `gasBudget = 0` on the transaction.
245
+ See the
246
+ [Sui gasless stablecoin transfers guide](https://docs.sui.io/develop/transaction-payment/gasless-stablecoin-transfers)
247
+ for full details, including the current
248
+ [allowlist of eligible stablecoins](https://docs.sui.io/develop/transaction-payment/gasless-stablecoin-transfers#eligible-stablecoins).
247
249
 
248
250
  Gasless transactions are limited to transactions that send funds as balances for specific
249
- stablecoins. Using `0x2::balance::send_funds` with `tx.balance()` is the recommended way to build
250
- gasless transactions with the Typescript SDK.
251
+ allowlisted stablecoins. Using `0x2::balance::send_funds` with `tx.balance()` is the recommended way
252
+ to build gasless transactions with the TypeScript SDK.
251
253
 
252
254
  ### SDK support (gRPC and GraphQL)
253
255
 
@@ -258,16 +260,17 @@ the gas price is set when the transaction is built.
258
260
 
259
261
  const client = new SuiGrpcClient({ url: 'https://grpc.mainnet.sui.io:443' });
260
262
 
263
+ // Mainnet USDC. For the full set of allowlisted gasless stablecoins, see:
264
+ // https://docs.sui.io/develop/transaction-payment/gasless-stablecoin-transfers#eligible-stablecoins
265
+ const USDC = '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC';
266
+
261
267
  const tx = new Transaction();
262
268
  tx.setSender(keypair.toSuiAddress());
263
269
 
264
270
  tx.moveCall({
265
271
  target: '0x2::balance::send_funds',
266
- typeArguments: ['0x...::usdc::USDC'],
267
- arguments: [
268
- tx.balance({ type: '0x...::usdc::USDC', balance: 1_000_000 }),
269
- tx.pure.address(recipient),
270
- ],
272
+ typeArguments: [USDC],
273
+ arguments: [tx.balance({ type: USDC, balance: 1_000_000 }), tx.pure.address(recipient)],
271
274
  });
272
275
 
273
276
  const result = await client.signAndExecuteTransaction({
@@ -277,11 +280,14 @@ const result = await client.signAndExecuteTransaction({
277
280
  ```
278
281
 
279
282
  The JSON-RPC transport does not automatically detect gasless eligibility. You can opt in by setting
280
- the gas price to zero with `tx.setGasPrice(0)`, but this causes the transaction to fail if it is not
281
- actually gasless-eligible.
283
+ the gas price to zero with `tx.setGasPrice(0)`, but only after confirming the coin type is on the
284
+ [allowlist](https://docs.sui.io/develop/transaction-payment/gasless-stablecoin-transfers#eligible-stablecoins)
285
+ and the PTB shape is eligible. Otherwise the transaction fails at validation.
282
286
 
283
- > **Warning:** When executing through a wallet (using dapp-kit), you might need to build the transaction first if
284
- > the wallet itself is still using JSON-RPC to execute transactions.
287
+ > **Warning:** If your wallet builds transactions with gRPC but executes through a different transport (for
288
+ > example, dapp-kit wallets that still execute over JSON-RPC), pass the gRPC client to `build` so
289
+ > the gas price still gets set correctly:
285
290
  >
286
- > Call `tx.build({ client: grpcClient })` to use your grpc client to set the gas price
287
- > correctly for your transaction.
291
+ > ```tsx
292
+ > const bytes = await tx.build({ client: grpcClient });
293
+ > ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mysten/docs",
3
- "version": "0.1.28",
3
+ "version": "0.1.29",
4
4
  "description": "LLM-friendly documentation for the Sui TypeScript SDK ecosystem",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -18,50 +18,50 @@
18
18
  "node": ">=24"
19
19
  },
20
20
  "dependencies": {
21
- "@tanstack/react-query": "^5.90.16",
21
+ "@tanstack/react-query": "^5.101.0",
22
22
  "fast-glob": "^3.3.3",
23
- "fumadocs-core": "16.4.7",
24
- "fumadocs-docgen": "^3.0.5",
25
- "fumadocs-mdx": "14.2.5",
26
- "fumadocs-typescript": "^5.2.0",
27
- "fumadocs-ui": "16.4.7",
28
- "next": "^16.2.6",
29
- "react": "^19.2.3",
30
- "react-dom": "^19.2.3",
31
- "@mysten/aws-kms-signer": "0.1.2",
32
- "@mysten/bcs": "2.0.5",
33
- "@mysten/dapp-kit": "1.0.6",
34
- "@mysten/dapp-kit-core": "1.3.2",
35
- "@mysten/dapp-kit-react": "2.0.3",
36
- "@mysten/enoki-connect": "1.0.4",
37
- "@mysten/enoki": "1.0.8",
38
- "@mysten/deepbook-v3": "1.4.1",
39
- "@mysten/gcp-kms-signer": "0.1.2",
40
- "@mysten/kiosk": "1.2.6",
41
- "@mysten/payment-kit": "0.1.11",
42
- "@mysten/seal": "1.1.3",
43
- "@mysten/slush-wallet": "1.0.5",
44
- "@mysten/ledger-signer": "0.1.2",
45
- "@mysten/signers": "1.0.5",
46
- "@mysten/sui": "2.17.0",
47
- "@mysten/utils": "0.3.3",
48
- "@mysten/wallet-standard": "0.20.3",
49
- "@mysten/walrus": "1.1.7",
50
- "@mysten/webcrypto-signer": "0.1.2",
51
- "@mysten/zksend": "1.1.2",
52
- "@mysten/suins": "1.1.4"
23
+ "fumadocs-core": "16.10.2",
24
+ "fumadocs-docgen": "^3.0.10",
25
+ "fumadocs-mdx": "15.0.12",
26
+ "fumadocs-typescript": "^5.2.6",
27
+ "fumadocs-ui": "16.10.2",
28
+ "next": "^16.2.9",
29
+ "react": "^19.2.7",
30
+ "react-dom": "^19.2.7",
31
+ "@mysten/aws-kms-signer": "0.2.0",
32
+ "@mysten/bcs": "2.1.0",
33
+ "@mysten/dapp-kit": "1.1.0",
34
+ "@mysten/dapp-kit-core": "1.4.0",
35
+ "@mysten/dapp-kit-react": "2.1.0",
36
+ "@mysten/deepbook-v3": "1.5.0",
37
+ "@mysten/enoki": "1.1.0",
38
+ "@mysten/enoki-connect": "1.1.0",
39
+ "@mysten/kiosk": "1.3.0",
40
+ "@mysten/ledger-signer": "0.2.0",
41
+ "@mysten/payment-kit": "0.2.0",
42
+ "@mysten/seal": "1.2.0",
43
+ "@mysten/gcp-kms-signer": "0.2.0",
44
+ "@mysten/signers": "1.1.0",
45
+ "@mysten/slush-wallet": "1.1.0",
46
+ "@mysten/sui": "2.18.0",
47
+ "@mysten/suins": "1.2.0",
48
+ "@mysten/wallet-standard": "0.21.0",
49
+ "@mysten/walrus": "1.2.0",
50
+ "@mysten/zksend": "1.2.0",
51
+ "@mysten/utils": "0.4.0",
52
+ "@mysten/webcrypto-signer": "0.2.0"
53
53
  },
54
54
  "devDependencies": {
55
- "@tailwindcss/postcss": "^4.1.18",
56
- "@types/mdx": "^2.0.13",
57
- "@types/node": "^25.0.8",
58
- "@types/react": "^19.2.8",
55
+ "@tailwindcss/postcss": "^4.3.1",
56
+ "@types/mdx": "^2.0.14",
57
+ "@types/node": "^25.9.3",
58
+ "@types/react": "^19.2.17",
59
59
  "@types/react-dom": "^19.2.3",
60
- "postcss": "^8.5.14",
61
- "tailwindcss": "^4.1.18",
62
- "typedoc": "^0.28.16",
60
+ "postcss": ">=8.5.10",
61
+ "tailwindcss": "^4.3.1",
62
+ "typedoc": "^0.28.19",
63
63
  "typedoc-plugin-mermaid": "^1.12.0",
64
- "typescript": "^5.9.3"
64
+ "typescript": "^6.0.3"
65
65
  },
66
66
  "scripts": {
67
67
  "build": "typedoc && next build && pnpm run build:docs",