@mysten/docs 0.1.44 → 0.1.46
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/dist/codegen/index.md +307 -25
- package/dist/dapp-kit/getting-started/react.md +2 -2
- package/dist/dapp-kit/getting-started/vue.md +2 -2
- package/dist/dapp-kit/llms-index.md +4 -4
- package/dist/dapp-kit/react/hooks/use-current-client.md +6 -5
- package/dist/dapp-kit/state.md +2 -2
- package/dist/kiosk/advanced-examples.md +3 -3
- package/dist/kiosk/from-v1.md +9 -9
- package/dist/kiosk/index.md +6 -3
- package/dist/kiosk/kiosk-client/introduction.md +10 -7
- package/dist/kiosk/llms-index.md +4 -4
- package/dist/llms-index.md +26 -25
- package/dist/seal/index.md +3 -0
- package/dist/sui/bcs.md +2 -2
- package/dist/sui/clients/core.md +151 -690
- package/dist/sui/clients/executing.md +113 -0
- package/dist/sui/clients/graphql.md +91 -46
- package/dist/sui/clients/grpc.md +239 -142
- package/dist/sui/clients/index.md +87 -51
- package/dist/sui/clients/querying.md +539 -0
- package/dist/sui/executors.md +28 -13
- package/dist/sui/index.md +1 -1
- package/dist/sui/llms-index.md +18 -17
- package/dist/sui/migrations/sui-2.0/dapp-kit.md +3 -3
- package/dist/sui/migrations/sui-2.0/deepbook-v3.md +2 -2
- package/dist/sui/migrations/sui-2.0/index.md +46 -25
- package/dist/sui/migrations/sui-2.0/json-rpc-migration.md +462 -284
- package/dist/sui/migrations/sui-2.0/kiosk.md +10 -9
- package/dist/sui/migrations/sui-2.0/sdk-maintainers.md +17 -11
- package/dist/sui/migrations/sui-2.0/sui.md +47 -29
- package/dist/sui/migrations/sui-2.0/suins.md +2 -2
- package/dist/sui/migrations/sui-2.0/walrus.md +3 -3
- package/dist/sui/migrations/sui-2.0/zksend.md +9 -8
- package/dist/sui/sdk-building.md +7 -5
- package/dist/sui/transactions/signing-and-execution.md +8 -28
- package/package.json +21 -21
- package/dist/sui/clients/json-rpc.md +0 -239
package/dist/codegen/index.md
CHANGED
|
@@ -67,15 +67,16 @@ This generates TypeScript code in your configured output directory (for example,
|
|
|
67
67
|
|
|
68
68
|
The `SuiCodegenConfig` type supports the following options:
|
|
69
69
|
|
|
70
|
-
| Option | Type | Default
|
|
71
|
-
| ------------------------------ | ---------------------- |
|
|
72
|
-
| `output` | `string` | -
|
|
73
|
-
| `packages` | `PackageConfig[]` | -
|
|
74
|
-
| `prune` | `boolean` | `true`
|
|
75
|
-
| `generateSummaries` | `boolean` | `true`
|
|
76
|
-
| `generate` | `GenerateOptions` | -
|
|
77
|
-
| `importExtension` | `'.js' \| '.ts' \| ''` | `'.js'`
|
|
78
|
-
| `includePhantomTypeParameters` | `boolean` | `false`
|
|
70
|
+
| Option | Type | Default | Description |
|
|
71
|
+
| ------------------------------ | ---------------------- | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
72
|
+
| `output` | `string` | - | The directory where codegen writes generated code |
|
|
73
|
+
| `packages` | `PackageConfig[]` | - | Array of Move packages to generate code for |
|
|
74
|
+
| `prune` | `boolean` | `true` | When enabled, only generates code for the main package and omits dependency modules (dependency types referenced by included types are still generated under `deps/`) |
|
|
75
|
+
| `generateSummaries` | `boolean` | `true` | Automatically run `sui move summary` before generating code. Creates a `package_summaries` directory in your Move package which can be added to `.gitignore` |
|
|
76
|
+
| `generate` | `GenerateOptions` | - | Default [generate options](#the-generate-option) (types, functions) for all packages |
|
|
77
|
+
| `importExtension` | `'.js' \| '.ts' \| ''` | `'.js'` | File extension used in generated import statements |
|
|
78
|
+
| `includePhantomTypeParameters` | `boolean` | `false` | Include [phantom type parameters](#phantom-types) as function arguments in generated BCS types |
|
|
79
|
+
| `fullnodeUrls` | network URL map | Sui public fullnodes | Override the Mainnet or Testnet fullnode used to fetch onchain package summaries |
|
|
79
80
|
|
|
80
81
|
### Package configuration
|
|
81
82
|
|
|
@@ -84,12 +85,14 @@ local (from source) or onchain (fetched from a network).
|
|
|
84
85
|
|
|
85
86
|
#### Local packages
|
|
86
87
|
|
|
87
|
-
| Option
|
|
88
|
-
|
|
|
89
|
-
| `package`
|
|
90
|
-
| `path`
|
|
91
|
-
| `packageName`
|
|
92
|
-
| `generate`
|
|
88
|
+
| Option | Type | Required | Description |
|
|
89
|
+
| ----------------- | ------------------------ | -------- | ------------------------------------------------------------------------------------------------ |
|
|
90
|
+
| `package` | `string` | yes | Package identifier (for example, `@local-pkg/my-package`) |
|
|
91
|
+
| `path` | `string` | yes | Path to the Move package directory |
|
|
92
|
+
| `packageName` | `string` | no | Custom name for generated code directory |
|
|
93
|
+
| `generate` | `PackageGenerateOptions` | no | Control what gets generated from this package |
|
|
94
|
+
| `configArguments` | `ConfigArguments` | no | Map this package's function parameters to a [runtime config object](#the-configarguments-option) |
|
|
95
|
+
| `bcsOverrides` | `BcsOverrides` | no | Replace generated BCS types with [custom types](#the-bcsoverrides-option) |
|
|
93
96
|
|
|
94
97
|
```typescript
|
|
95
98
|
{
|
|
@@ -103,12 +106,15 @@ local (from source) or onchain (fetched from a network).
|
|
|
103
106
|
For packages already deployed onchain, generate code directly from a package ID or MVR name without
|
|
104
107
|
needing local source code:
|
|
105
108
|
|
|
106
|
-
| Option
|
|
107
|
-
|
|
|
108
|
-
| `package`
|
|
109
|
-
| `
|
|
110
|
-
| `
|
|
111
|
-
| `
|
|
109
|
+
| Option | Type | Required | Description |
|
|
110
|
+
| ----------------- | ------------------------ | -------- | ------------------------------------------------------------------------------------------------ |
|
|
111
|
+
| `package` | `string` | yes | Package ID or name emitted into generated code |
|
|
112
|
+
| `sourcePackageId` | `string` | no | Package ID to fetch when generating an unpublished package name |
|
|
113
|
+
| `packageName` | `string` | yes | Name for the generated code directory |
|
|
114
|
+
| `network` | `'mainnet' \| 'testnet'` | yes | Network to resolve and fetch the package from |
|
|
115
|
+
| `generate` | `PackageGenerateOptions` | no | Control what gets generated from this package |
|
|
116
|
+
| `configArguments` | `ConfigArguments` | no | Map this package's function parameters to a [runtime config object](#the-configarguments-option) |
|
|
117
|
+
| `bcsOverrides` | `BcsOverrides` | no | Replace generated BCS types with [custom types](#the-bcsoverrides-option) |
|
|
112
118
|
|
|
113
119
|
```typescript
|
|
114
120
|
{
|
|
@@ -267,6 +273,271 @@ src/contracts/
|
|
|
267
273
|
|
|
268
274
|
Set `prune: false` to generate all dependency modules with their full types and functions.
|
|
269
275
|
|
|
276
|
+
## The `configArguments` option
|
|
277
|
+
|
|
278
|
+
SDKs built on generated bindings often spend a lot of wrapper code passing values from a per-network
|
|
279
|
+
config object (package IDs, registry or treasury object IDs, pool addresses) into generated function
|
|
280
|
+
calls. The `configArguments` option moves that mapping into codegen: declare which Move types (or
|
|
281
|
+
package addresses) come from a config object, and the generated functions accept that config object
|
|
282
|
+
directly.
|
|
283
|
+
|
|
284
|
+
`configArguments` is set on a package entry and maps config keys to matchers. Matchers reference
|
|
285
|
+
types as `module::Type`, optionally qualified with a package identifier from the `packages` config
|
|
286
|
+
or an address:
|
|
287
|
+
|
|
288
|
+
```typescript
|
|
289
|
+
const config: SuiCodegenConfig = {
|
|
290
|
+
output: './src/contracts',
|
|
291
|
+
packages: [
|
|
292
|
+
{
|
|
293
|
+
package: '@myapp/core',
|
|
294
|
+
path: './move/core',
|
|
295
|
+
configArguments: {
|
|
296
|
+
// Every parameter of this type resolves from `config.registry`
|
|
297
|
+
registry: { type: 'registry::Registry' },
|
|
298
|
+
// Generic type: matches every instantiation, config value must be a resolver function
|
|
299
|
+
pool: { type: 'pool::Pool' },
|
|
300
|
+
// Instantiated generic: only matches this exact instantiation
|
|
301
|
+
suiPool: { type: 'pool::Pool<0x2::sui::SUI>' },
|
|
302
|
+
// Function matcher: configures a single function's parameter
|
|
303
|
+
adminCap: { function: 'admin::set_fees', parameterName: 'cap' },
|
|
304
|
+
// Package entry: adds a config key that overrides the package address used for calls
|
|
305
|
+
corePackageId: { package: '@myapp/core' },
|
|
306
|
+
},
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
package: '@myapp/vaults',
|
|
310
|
+
path: './move/vaults',
|
|
311
|
+
configArguments: {
|
|
312
|
+
// Types from other packages are referenced by their package identifier
|
|
313
|
+
vaultPool: { type: '@myapp/core::pool::Pool' },
|
|
314
|
+
},
|
|
315
|
+
},
|
|
316
|
+
],
|
|
317
|
+
};
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
Matcher rules:
|
|
321
|
+
|
|
322
|
+
- A bare `module::Type` refers to a type from the package the config is declared on.
|
|
323
|
+
- Types from other packages in the run use their package identifier (for example,
|
|
324
|
+
`@myapp/core::pool::Pool`) and must be dependencies of the declaring package.
|
|
325
|
+
- Types can also be referenced by an explicit address (for example, `0x2::sui::SUI`). Addresses
|
|
326
|
+
aren't validated, so only use addresses that are valid on every network your generated code
|
|
327
|
+
targets.
|
|
328
|
+
- Partially instantiated generics like `Pool<T>` are not supported. Use an uninstantiated matcher
|
|
329
|
+
with a resolver function instead.
|
|
330
|
+
- Function matchers can target a parameter by `parameterName` or `parameterIndex`. Both can be
|
|
331
|
+
omitted when the function has a single argument.
|
|
332
|
+
- A key can declare an array of matchers. If they span multiple types, the config value must be a
|
|
333
|
+
resolver function.
|
|
334
|
+
- Invalid matchers fail at generation time, and keys that never match any generated parameter
|
|
335
|
+
produce a warning.
|
|
336
|
+
|
|
337
|
+
### Generated output
|
|
338
|
+
|
|
339
|
+
For each function with matched parameters, the generated options gain an optional `config` property
|
|
340
|
+
typed with the keys that function uses. Matched parameters become optional in `arguments`, and an
|
|
341
|
+
explicitly passed argument always takes precedence over the config value:
|
|
342
|
+
|
|
343
|
+
```typescript
|
|
344
|
+
|
|
345
|
+
package?: string;
|
|
346
|
+
arguments: BorrowArguments; // `pool` is optional here
|
|
347
|
+
config?: {
|
|
348
|
+
pool: (ctx: ConfigResolverContext) => string | TransactionObjectArgument;
|
|
349
|
+
corePackageId?: string;
|
|
350
|
+
};
|
|
351
|
+
typeArguments: [string];
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const packageAddress = options.package ?? options.config?.corePackageId ?? '@myapp/core';
|
|
355
|
+
// ...
|
|
356
|
+
pool: options.arguments?.pool ?? options.config?.pool?.({ ... }),
|
|
357
|
+
}
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
Keys bound to a single concrete type accept a plain value (an object ID or a transaction argument).
|
|
361
|
+
Keys that match a generic type, or multiple types, must be resolver functions, because a single ID
|
|
362
|
+
can't be correct for every instantiation. A resolver can also return a transaction callback
|
|
363
|
+
(`(ctx) => (tx) => ...`) to build the argument dynamically. Resolvers receive the matched
|
|
364
|
+
parameter's own type arguments plus call-site metadata:
|
|
365
|
+
|
|
366
|
+
```typescript
|
|
367
|
+
|
|
368
|
+
typeArguments: string[]; // canonical for concrete instantiations; as-provided for generic positions
|
|
369
|
+
packageAddress: string;
|
|
370
|
+
moduleName: string;
|
|
371
|
+
functionName: string;
|
|
372
|
+
parameterName?: string; // Move parameter name, when the summary includes names
|
|
373
|
+
parameterIndex: number; // position in the generated function's arguments
|
|
374
|
+
}
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
This makes resolvers reusable across functions that use the type in different positions:
|
|
378
|
+
|
|
379
|
+
```typescript
|
|
380
|
+
const myConfig = {
|
|
381
|
+
registry: '0x123...',
|
|
382
|
+
pool: (ctx: ConfigResolverContext) => poolsByCoinType[ctx.typeArguments[0]],
|
|
383
|
+
suiPool: '0x456...',
|
|
384
|
+
adminCap: '0x789...',
|
|
385
|
+
corePackageId: '0xabc...',
|
|
386
|
+
} satisfies CoreConfig;
|
|
387
|
+
|
|
388
|
+
tx.add(
|
|
389
|
+
borrow({
|
|
390
|
+
arguments: { amount: 100n },
|
|
391
|
+
config: myConfig,
|
|
392
|
+
typeArguments: ['0x2::sui::SUI'],
|
|
393
|
+
}),
|
|
394
|
+
);
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
Each package's output also includes a `config-arguments.ts` file with an interface covering the
|
|
398
|
+
package's config keys, named after the package's `packageName` (for example, `packageName: 'core'`
|
|
399
|
+
produces `CoreConfig`). Use it with `satisfies` when defining your config object, as shown above. An
|
|
400
|
+
SDK spanning multiple packages can check one shared config object against the intersection of the
|
|
401
|
+
per-package interfaces:
|
|
402
|
+
|
|
403
|
+
```typescript
|
|
404
|
+
const myConfig = { ... } satisfies CoreConfig & MarginConfig;
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
### Name refinement
|
|
408
|
+
|
|
409
|
+
When a signature has two parameters of the same matched type (for example, `base_pool` and
|
|
410
|
+
`quote_pool`, both `Pool<T>`), a bare type matcher matches both: the key's config value must then be
|
|
411
|
+
a resolver function, which receives each parameter's own context. To give each parameter its own
|
|
412
|
+
config key instead, refine the matchers with the Move parameter names:
|
|
413
|
+
|
|
414
|
+
```typescript
|
|
415
|
+
configArguments: {
|
|
416
|
+
basePool: { type: 'pool::Pool', parameterName: 'base_pool' },
|
|
417
|
+
quotePool: { type: 'pool::Pool', parameterName: 'quote_pool' },
|
|
418
|
+
},
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
Parameter names are only available in summaries generated from local packages. For onchain packages
|
|
422
|
+
without parameter names, use function matchers with `parameterIndex` to target individual
|
|
423
|
+
parameters.
|
|
424
|
+
|
|
425
|
+
### Package address precedence
|
|
426
|
+
|
|
427
|
+
For package entries, the address used for a generated call is resolved in this order:
|
|
428
|
+
|
|
429
|
+
1. An explicit `options.package` argument
|
|
430
|
+
2. The config key declared by the package entry (for example, `config.corePackageId`)
|
|
431
|
+
3. The generated default (the package's MVR name or address)
|
|
432
|
+
|
|
433
|
+
On networks where the package's MVR name doesn't resolve, supply the deployed package ID through the
|
|
434
|
+
config object. Package entries only apply to the main package's generated modules, and for packages
|
|
435
|
+
generated without an MVR name or address `package` remains required.
|
|
436
|
+
|
|
437
|
+
## The `bcsOverrides` option
|
|
438
|
+
|
|
439
|
+
Generated BCS types mirror the raw Move layout, but the raw layout is often not the shape an SDK
|
|
440
|
+
wants to expose: a `u64` field might be a 1e9 fixed-point price, or a struct like
|
|
441
|
+
`i64::I64 { magnitude: u64, is_negative: bool }` is really a signed integer. The `bcsOverrides`
|
|
442
|
+
option replaces generated BCS types with custom ones — typically built with
|
|
443
|
+
[`transform`](/bcs#transforms) — so parsed values come out in the shape you want and inputs accept
|
|
444
|
+
it.
|
|
445
|
+
|
|
446
|
+
`bcsOverrides` is set on a package entry as an array. Every entry names the Move `type` it replaces
|
|
447
|
+
and the `source` module the replacement is imported from, and can optionally narrow the entry to
|
|
448
|
+
specific `fields`:
|
|
449
|
+
|
|
450
|
+
```typescript
|
|
451
|
+
const config: SuiCodegenConfig = {
|
|
452
|
+
output: './src/contracts',
|
|
453
|
+
packages: [
|
|
454
|
+
{
|
|
455
|
+
package: '@local-pkg/deepbook_predict',
|
|
456
|
+
path: './move/deepbook_predict',
|
|
457
|
+
bcsOverrides: [
|
|
458
|
+
// Replace a datatype's generated declaration: every generated layout that
|
|
459
|
+
// references it uses the custom type. Imports `I64` from the source module.
|
|
460
|
+
{ type: 'fixed_math::i64::I64', source: './src/bcs/i64.ts' },
|
|
461
|
+
|
|
462
|
+
// `fields` narrows an entry to the field sites matching a glob. Entries are tried
|
|
463
|
+
// in declaration order and the first match wins, so narrow entries go first.
|
|
464
|
+
{ type: 'u64', fields: 'order::*.*_price', source: './src/bcs/units.ts#Price9' },
|
|
465
|
+
|
|
466
|
+
// A type with no generated declaration is replaced wherever it is rendered —
|
|
467
|
+
// here, every remaining `u64` parses to a bigint instead of a decimal string.
|
|
468
|
+
{ type: 'u64', source: './src/bcs/integers.ts#U64' },
|
|
469
|
+
|
|
470
|
+
// A whole-type match wins over its elements, so this replaces the vector itself
|
|
471
|
+
// rather than letting the `u64` rule apply to its items.
|
|
472
|
+
{ type: 'vector<u64>', source: './src/bcs/units.ts#Payouts' },
|
|
473
|
+
],
|
|
474
|
+
},
|
|
475
|
+
],
|
|
476
|
+
};
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
The replacement module exports plain BCS types:
|
|
480
|
+
|
|
481
|
+
```typescript
|
|
482
|
+
// ./src/bcs/units.ts
|
|
483
|
+
|
|
484
|
+
/** 1e9 fixed-point u64 exposed as a decimal number. */
|
|
485
|
+
const Price9 = bcs.u64().transform({
|
|
486
|
+
input: (value: number) => BigInt(Math.round(value * 1e9)).toString(),
|
|
487
|
+
output: (raw) => Number(raw) / 1e9,
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
The custom type's inferred input and output types flow through the generated code, so
|
|
493
|
+
`Node.parse(bytes).levels` is a `number[]` and `Node.serialize` accepts one.
|
|
494
|
+
|
|
495
|
+
Entry rules:
|
|
496
|
+
|
|
497
|
+
- `type` uses the same package scoping as `configArguments` matchers (bare `module::Type` for the
|
|
498
|
+
declaring package, package identifiers, explicit addresses), and additionally accepts
|
|
499
|
+
named-address labels from the package's summaries (for example, `fixed_math::i64::I64`) so entries
|
|
500
|
+
can target dependency packages that are not codegen-run entries.
|
|
501
|
+
- A datatype entry written without type arguments or `fields` replaces the type's generated
|
|
502
|
+
**declaration**: the module exports the custom type under the Move type's name, and every use
|
|
503
|
+
picks it up because uses already reference the declaration. For a generic type the source must
|
|
504
|
+
export a function `(...typeParameters: BcsType<any>[]) => BcsType<any>` mirroring the generated
|
|
505
|
+
call convention.
|
|
506
|
+
- Every other entry replaces the type **wherever it is rendered**. That covers types with no
|
|
507
|
+
declaration to replace (primitives, `vector`, and the stdlib types generated layouts serialize
|
|
508
|
+
inline — `String`, `Option`, `ID`/`UID`), a single instantiation of a generic
|
|
509
|
+
(`pool::Pool<0x2::sui::SUI>`), and any entry narrowed with `fields`.
|
|
510
|
+
- Replacement applies at **any depth**, because the type renderer consults overrides as it recurses.
|
|
511
|
+
An override on `u64` also replaces the `u64` inside `vector<u64>` and `Option<u64>`. A whole-type
|
|
512
|
+
match wins over its elements, so an entry for `vector<u64>` replaces the vector rather than its
|
|
513
|
+
items.
|
|
514
|
+
- `fields` restricts an entry to the field sites matching one glob, where `*` matches any run of
|
|
515
|
+
characters. Sites are written `module::Type.field`, or `module::Type.variant.field` for enum
|
|
516
|
+
variant fields (positional fields are named `pos0`, `pos1`, …). A glob that names no module —
|
|
517
|
+
`Order.*_price` — is matched against the `Type.field` suffix, so it applies in every module. An
|
|
518
|
+
entry with `fields` never replaces a declaration, since a declaration exists once for every use.
|
|
519
|
+
- At each use site, matching entries are tried in **declaration order and the first match wins**. An
|
|
520
|
+
unrestricted datatype declaration remains the fallback for sites not matched by an earlier
|
|
521
|
+
field-restricted entry. There is no specificity scoring, so put narrow entries before broad ones.
|
|
522
|
+
- `source` is an import specifier, optionally suffixed with `#ExportName`. Relative specifiers
|
|
523
|
+
resolve against the config file's directory and are rewritten into relative imports from each
|
|
524
|
+
generated file, with their extension replaced by the configured `importExtension` (so a
|
|
525
|
+
`./src/bcs/units.ts` source is imported as `units.js` by default); bare package specifiers are
|
|
526
|
+
emitted as-is. Without a fragment, datatype entries import the Move type's name; entries whose
|
|
527
|
+
`type` is a primitive or `vector` must include one.
|
|
528
|
+
- Replacement modules must be self-contained: a module whose export replaces a declaration can't
|
|
529
|
+
import generated modules that reference the replaced type, because that would create a circular
|
|
530
|
+
import. Declare the raw layout inline when building a transform.
|
|
531
|
+
- A replacement built with `.transform()` is a plain `BcsType`, so a type replaced that way loses
|
|
532
|
+
the `MoveStruct` helpers (`typeTag()`, `resolveTypeTag()`, `get()`, `getMany()`). Extend
|
|
533
|
+
`MoveStruct` instead if the replaced type needs them.
|
|
534
|
+
- An entry that matches nothing is not an error. A shared set of overrides can be applied to several
|
|
535
|
+
packages even when only some of them have fields of a given type.
|
|
536
|
+
|
|
537
|
+
Overrides only affect generated BCS layouts (parsing and serializing structs, enums, and events,
|
|
538
|
+
including `MoveStruct.get()`). Generated transaction-building functions serialize their arguments
|
|
539
|
+
from Move type tags at runtime, so pure function arguments are unaffected.
|
|
540
|
+
|
|
270
541
|
## Phantom types
|
|
271
542
|
|
|
272
543
|
In Move, phantom type parameters are type parameters that only appear at the type level and don't
|
|
@@ -370,8 +641,8 @@ async function readCounter(client: ClientWithCoreApi, id: string) {
|
|
|
370
641
|
```
|
|
371
642
|
|
|
372
643
|
> **Warning:** Always use `content`, not `objectBcs`, when parsing with generated types. The `objectBcs` field
|
|
373
|
-
> contains a full object envelope with additional metadata that
|
|
374
|
-
> [
|
|
644
|
+
> contains a full object envelope with additional metadata that causes parsing to fail. See
|
|
645
|
+
> [Querying data](/sui/clients/querying#objectbcs) for details.
|
|
375
646
|
|
|
376
647
|
### Getting type tags
|
|
377
648
|
|
|
@@ -440,11 +711,15 @@ const balanceType = await Balance.resolveTypeTag({
|
|
|
440
711
|
|
|
441
712
|
### Using with MVR (Move Version Registry)
|
|
442
713
|
|
|
443
|
-
If your package is registered on MVR, the generated code works without additional configuration.
|
|
714
|
+
If your package is registered on MVR, the generated code works without additional configuration. The
|
|
715
|
+
configured name is preserved in generated function targets and type tags. At runtime MVR resolves
|
|
716
|
+
function packages and type origins independently for the client's network.
|
|
444
717
|
|
|
445
718
|
### Local packages
|
|
446
719
|
|
|
447
|
-
For local packages using `@local-pkg/*` identifiers, configure
|
|
720
|
+
For local packages using `@local-pkg/*` identifiers, configure package overrides for Move calls and
|
|
721
|
+
first-level type overrides for each local type used as a transaction type argument or resolved for a
|
|
722
|
+
query:
|
|
448
723
|
|
|
449
724
|
```typescript
|
|
450
725
|
|
|
@@ -456,6 +731,9 @@ const client = new SuiGrpcClient({
|
|
|
456
731
|
packages: {
|
|
457
732
|
'@local-pkg/counter': '0xYOUR_PACKAGE_ID',
|
|
458
733
|
},
|
|
734
|
+
types: {
|
|
735
|
+
'@local-pkg/counter::counter::Counter': '0xTYPE_ORIGIN::counter::Counter',
|
|
736
|
+
},
|
|
459
737
|
},
|
|
460
738
|
},
|
|
461
739
|
});
|
|
@@ -474,6 +752,7 @@ const GRPC_URLS = {
|
|
|
474
752
|
const PACKAGE_IDS = {
|
|
475
753
|
testnet: {
|
|
476
754
|
counter: '0xYOUR_PACKAGE_ID',
|
|
755
|
+
counterType: '0xTYPE_ORIGIN::counter::Counter',
|
|
477
756
|
},
|
|
478
757
|
};
|
|
479
758
|
|
|
@@ -488,6 +767,9 @@ const dAppKit = createDAppKit({
|
|
|
488
767
|
packages: {
|
|
489
768
|
'@local-pkg/counter': PACKAGE_IDS[network].counter,
|
|
490
769
|
},
|
|
770
|
+
types: {
|
|
771
|
+
'@local-pkg/counter::counter::Counter': PACKAGE_IDS[network].counterType,
|
|
772
|
+
},
|
|
491
773
|
},
|
|
492
774
|
},
|
|
493
775
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# React
|
|
2
2
|
|
|
3
|
-
> Set up dApp Kit in a React application
|
|
3
|
+
> Set up dApp Kit in a React application
|
|
4
4
|
|
|
5
5
|
This guide walks you through integrating dApp Kit into a React application.
|
|
6
6
|
|
|
@@ -147,7 +147,7 @@ function TransferButton() {
|
|
|
147
147
|
| [`useCurrentAccount`](/dapp-kit/react/hooks/use-current-account) | Currently selected account |
|
|
148
148
|
| [`useCurrentWallet`](/dapp-kit/react/hooks/use-current-wallet) | Currently connected wallet |
|
|
149
149
|
| [`useCurrentNetwork`](/dapp-kit/react/hooks/use-current-network) | Current network |
|
|
150
|
-
| [`useCurrentClient`](/dapp-kit/react/hooks/use-current-client) |
|
|
150
|
+
| [`useCurrentClient`](/dapp-kit/react/hooks/use-current-client) | Current Sui client instance |
|
|
151
151
|
| [`useWallets`](/dapp-kit/react/hooks/use-wallets) | List of available wallets |
|
|
152
152
|
|
|
153
153
|
## Components
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Vue
|
|
2
2
|
|
|
3
|
-
> Set up dApp Kit in a Vue application
|
|
3
|
+
> Set up dApp Kit in a Vue application
|
|
4
4
|
|
|
5
5
|
This guide walks you through integrating dApp Kit into a Vue application using Web Components and
|
|
6
6
|
direct store access.
|
|
@@ -174,7 +174,7 @@ Access these stores through `dAppKit.stores`:
|
|
|
174
174
|
| ----------------- | ------------------------------------------------- |
|
|
175
175
|
| `$connection` | Connection state with wallet, account, and status |
|
|
176
176
|
| `$currentNetwork` | Current network string |
|
|
177
|
-
| `$currentClient` |
|
|
177
|
+
| `$currentClient` | Current Sui client instance |
|
|
178
178
|
| `$wallets` | List of available wallets |
|
|
179
179
|
|
|
180
180
|
See [State Management](/dapp-kit/state) for full documentation.
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
- [Sui dApp Kit](..md): Build Sui apps with framework-agnostic core and React bindings.
|
|
5
5
|
- [@mysten/create-dapp](./getting-started/create-dapp.md): Create a Sui app with one command using the create-dapp CLI scaffolding tool.
|
|
6
|
-
- [React](./getting-started/react.md): Set up dApp Kit in a React application
|
|
6
|
+
- [React](./getting-started/react.md): Set up dApp Kit in a React application
|
|
7
7
|
- [Next.js](./getting-started/next-js.md): Set up dApp Kit in a Next.js application.
|
|
8
|
-
- [Vue](./getting-started/vue.md): Set up dApp Kit in a Vue application
|
|
8
|
+
- [Vue](./getting-started/vue.md): Set up dApp Kit in a Vue application
|
|
9
9
|
- [DApp Kit Instance](./dapp-kit-instance.md): Create and configure a DAppKit instance for wallet and client management
|
|
10
|
-
- [State](./state.md): Access and subscribe to wallet connection state in dApp Kit
|
|
10
|
+
- [State](./state.md): Access and subscribe to wallet connection state in dApp Kit
|
|
11
11
|
- [Connect Wallet](./actions/connect-wallet.md): Programmatically connect to a Sui wallet using the dApp Kit connectWallet action.
|
|
12
12
|
- [Disconnect Wallet](./actions/disconnect-wallet.md): Programmatically disconnect from a Sui wallet using the dApp Kit disconnectWallet action.
|
|
13
13
|
- [Sign and Execute Transaction](./actions/sign-and-execute-transaction.md): Sign and execute a transaction on the Sui network using the connected wallet.
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
- [React Hooks](./react/hooks.md): React hooks for accessing dApp Kit state and actions in Sui applications.
|
|
20
20
|
- [useDAppKit](./react/hooks/use-dapp-kit.md): React hook to access the full dApp Kit instance for calling actions directly.
|
|
21
21
|
- [useCurrentAccount](./react/hooks/use-current-account.md): React hook to get the currently selected wallet account in a Sui dApp.
|
|
22
|
-
- [useCurrentClient](./react/hooks/use-current-client.md): React hook to get the current Sui client instance for the active network
|
|
22
|
+
- [useCurrentClient](./react/hooks/use-current-client.md): React hook to get the current Sui client instance for the active network
|
|
23
23
|
- [useCurrentNetwork](./react/hooks/use-current-network.md): React hook to get the currently selected Sui network in dApp Kit.
|
|
24
24
|
- [useCurrentWallet](./react/hooks/use-current-wallet.md): React hook to get the currently connected wallet in a Sui dApp.
|
|
25
25
|
- [useWalletConnection](./react/hooks/use-wallet-connection.md): React hook to manage wallet connection status and information in a Sui dApp.
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
# useCurrentClient
|
|
2
2
|
|
|
3
|
-
> React hook to get the current Sui client instance for the active network
|
|
3
|
+
> React hook to get the current Sui client instance for the active network
|
|
4
4
|
|
|
5
5
|
The `useCurrentClient` hook provides access to the blockchain client instance for the current
|
|
6
6
|
network.
|
|
7
7
|
|
|
8
|
-
> **Note:**
|
|
9
|
-
>
|
|
10
|
-
>
|
|
8
|
+
> **Note:** With the standard setup, this returns the `SuiGrpcClient` instance created by `createClient`. More
|
|
9
|
+
> generally, it returns whatever client type your dApp Kit instance creates, as long as that client
|
|
10
|
+
> implements the Sui Core API. Application code should call the concrete client's top-level methods
|
|
11
|
+
> directly.
|
|
11
12
|
|
|
12
13
|
> **Warning:** All dApp Kit hooks must be used within components that are descendants of
|
|
13
14
|
> [`DAppKitProvider`](../dapp-kit-provider). Using them outside will result in an error.
|
|
@@ -32,5 +33,5 @@ network.
|
|
|
32
33
|
## Return value
|
|
33
34
|
|
|
34
35
|
```tsx
|
|
35
|
-
|
|
36
|
+
ReturnType<typeof dAppKit.getClient>;
|
|
36
37
|
```
|
package/dist/dapp-kit/state.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# State
|
|
2
2
|
|
|
3
|
-
> Access and subscribe to wallet connection state in dApp Kit
|
|
3
|
+
> Access and subscribe to wallet connection state in dApp Kit
|
|
4
4
|
|
|
5
5
|
The Sui dApp Kit SDK uses [nanostores](https://github.com/nanostores/nanostores) for state
|
|
6
6
|
management, providing a lightweight, framework-agnostic solution that works across React, Vue,
|
|
@@ -100,7 +100,7 @@ This store is read-only. Use `dAppKit.switchNetwork()` to change networks.
|
|
|
100
100
|
|
|
101
101
|
### Current client store (`$currentClient`)
|
|
102
102
|
|
|
103
|
-
Contains the
|
|
103
|
+
Contains the Sui client instance for the current network:
|
|
104
104
|
|
|
105
105
|
```typescript
|
|
106
106
|
const client = dAppKit.stores.$currentClient.get();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Advanced Examples
|
|
2
2
|
|
|
3
|
-
> Advanced Kiosk SDK usage patterns and code examples for complex scenarios
|
|
3
|
+
> Advanced Kiosk SDK usage patterns and code examples for complex scenarios
|
|
4
4
|
|
|
5
5
|
# Some extended examples
|
|
6
6
|
|
|
@@ -14,8 +14,8 @@ const bullsharkType = `${packageId}::suifrens::SuiFren<${packageId}::bullshark::
|
|
|
14
14
|
const capyType = `${packageId}::suifrens::SuiFren<${packageId}::capy::Capy>`;
|
|
15
15
|
|
|
16
16
|
// initialize the client with the kiosk extension.
|
|
17
|
-
const client = new
|
|
18
|
-
|
|
17
|
+
const client = new SuiGrpcClient({
|
|
18
|
+
baseUrl: 'https://fullnode.mainnet.sui.io:443',
|
|
19
19
|
network: 'mainnet',
|
|
20
20
|
}).$extend(kiosk());
|
|
21
21
|
```
|
package/dist/kiosk/from-v1.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Migrating from Kiosk SDK V1
|
|
2
2
|
|
|
3
|
-
> Migrate from Kiosk SDK v1 to the current version with the builder-pattern API
|
|
3
|
+
> Migrate from Kiosk SDK v1 to the current version with the builder-pattern API
|
|
4
4
|
|
|
5
5
|
The original version of Kiosk SDK provided basic experimentation with the Kiosk API. The new version
|
|
6
6
|
of the SDK (0.7+) provides a more robust experience for building kiosk/transfer policy transactions.
|
|
@@ -46,8 +46,8 @@ Using the new SDK, you can build the same transaction as follows:
|
|
|
46
46
|
```typescript
|
|
47
47
|
|
|
48
48
|
// You need to do this only once and re-use it in the application.
|
|
49
|
-
const client = new
|
|
50
|
-
|
|
49
|
+
const client = new SuiGrpcClient({
|
|
50
|
+
baseUrl: 'https://fullnode.mainnet.sui.io:443',
|
|
51
51
|
network: 'mainnet',
|
|
52
52
|
}).$extend(kiosk());
|
|
53
53
|
|
|
@@ -98,8 +98,8 @@ Using the new SDK, you can build the same transaction as follows:
|
|
|
98
98
|
```typescript
|
|
99
99
|
|
|
100
100
|
// You need to do this only once and re-use it in the application.
|
|
101
|
-
const client = new
|
|
102
|
-
|
|
101
|
+
const client = new SuiGrpcClient({
|
|
102
|
+
baseUrl: 'https://fullnode.mainnet.sui.io:443',
|
|
103
103
|
network: 'mainnet',
|
|
104
104
|
}).$extend(kiosk());
|
|
105
105
|
|
|
@@ -198,8 +198,8 @@ Using the new SDK, you can build the same transaction as follows:
|
|
|
198
198
|
```typescript
|
|
199
199
|
|
|
200
200
|
// You need to do this only once and re-use it in the application.
|
|
201
|
-
const client = new
|
|
202
|
-
|
|
201
|
+
const client = new SuiGrpcClient({
|
|
202
|
+
baseUrl: 'https://fullnode.mainnet.sui.io:443',
|
|
203
203
|
network: 'mainnet',
|
|
204
204
|
}).$extend(kiosk());
|
|
205
205
|
|
|
@@ -296,8 +296,8 @@ On the new SDK, the same transaction can be built as follows:
|
|
|
296
296
|
```typescript
|
|
297
297
|
|
|
298
298
|
// You need to do this only once and re-use it in the application.
|
|
299
|
-
const client = new
|
|
300
|
-
|
|
299
|
+
const client = new SuiGrpcClient({
|
|
300
|
+
baseUrl: 'https://fullnode.mainnet.sui.io:443',
|
|
301
301
|
network: 'mainnet',
|
|
302
302
|
}).$extend(kiosk());
|
|
303
303
|
|
package/dist/kiosk/index.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Kiosk SDK
|
|
2
2
|
|
|
3
|
-
> TypeScript SDK for interacting with Sui Kiosk onchain commerce
|
|
3
|
+
> TypeScript SDK for interacting with Sui Kiosk onchain commerce
|
|
4
4
|
|
|
5
5
|
Kiosk SDK is a tool to interact with Sui and Mysten Kiosk. You can use it to query kiosk related
|
|
6
6
|
data, build transactions to interact, and extend Kiosk to support custom rules.
|
|
@@ -16,7 +16,10 @@ npm i @mysten/kiosk
|
|
|
16
16
|
The Kiosk SDK exports a client extension that integrates with Sui clients. Add it to your client
|
|
17
17
|
using `$extend(kiosk())` to access kiosk functionality through `client.kiosk`.
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
The Kiosk extension accepts any Sui client that implements `ClientWithCoreApi`. Use `SuiGrpcClient`
|
|
20
|
+
for new Kiosk code; `SuiGraphQLClient` and the deprecated `SuiJsonRpcClient` are also compatible.
|
|
21
|
+
|
|
22
|
+
> **Note:** The gRPC object API returns Display v2 metadata. Use GraphQL or JSON-RPC when reading objects
|
|
23
|
+
> whose types still rely on legacy Display metadata.
|
|
21
24
|
|
|
22
25
|
- [Read more about setting up the Kiosk client extension](/kiosk/kiosk-client/introduction)
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
# Kiosk Client
|
|
2
2
|
|
|
3
|
-
> Introduction to the KioskClient extension for querying and managing kiosks on Sui
|
|
3
|
+
> Introduction to the KioskClient extension for querying and managing kiosks on Sui
|
|
4
4
|
|
|
5
5
|
The Kiosk SDK exports a client extension that provides all Kiosk functionality.
|
|
6
6
|
|
|
7
7
|
> We recommend you keep only one client instance throughout your app or script. For example, in
|
|
8
8
|
> React, you'd use a context to provide the client.
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
The Kiosk extension accepts any Sui client that implements `ClientWithCoreApi`. Use `SuiGrpcClient`
|
|
11
|
+
for new Kiosk code; `SuiGraphQLClient` and the deprecated `SuiJsonRpcClient` are also compatible.
|
|
12
|
+
|
|
13
|
+
> **Note:** The gRPC object API returns Display v2 metadata. Use GraphQL or JSON-RPC when reading objects
|
|
14
|
+
> whose types still rely on legacy Display metadata.
|
|
12
15
|
|
|
13
16
|
## Setting up the kiosk extension
|
|
14
17
|
|
|
@@ -20,8 +23,8 @@ require constantly changing the package IDs).
|
|
|
20
23
|
|
|
21
24
|
```typescript
|
|
22
25
|
|
|
23
|
-
const client = new
|
|
24
|
-
|
|
26
|
+
const client = new SuiGrpcClient({
|
|
27
|
+
baseUrl: 'https://fullnode.testnet.sui.io:443',
|
|
25
28
|
network: 'testnet',
|
|
26
29
|
}).$extend(kiosk());
|
|
27
30
|
|
|
@@ -36,8 +39,8 @@ for the rules and extensions you want to use.
|
|
|
36
39
|
|
|
37
40
|
```typescript
|
|
38
41
|
|
|
39
|
-
const client = new
|
|
40
|
-
|
|
42
|
+
const client = new SuiGrpcClient({
|
|
43
|
+
baseUrl: 'https://fullnode.devnet.sui.io:443',
|
|
41
44
|
network: 'devnet',
|
|
42
45
|
}).$extend(
|
|
43
46
|
kiosk({
|