@mysten/sui 2.7.0 → 2.8.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 +13 -0
- package/dist/bcs/bcs.d.mts +6 -6
- package/dist/cryptography/signature.d.mts +6 -6
- package/dist/grpc/proto/sui/rpc/v2/ledger_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.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
- package/dist/keypairs/passkey/keypair.d.mts +11 -4
- package/dist/keypairs/passkey/keypair.d.mts.map +1 -1
- package/dist/keypairs/passkey/keypair.mjs +19 -6
- package/dist/keypairs/passkey/keypair.mjs.map +1 -1
- package/dist/transactions/Transaction.d.mts +6 -6
- package/dist/transactions/Transaction.d.mts.map +1 -1
- package/dist/version.mjs +2 -2
- package/dist/version.mjs.map +1 -1
- package/dist/zklogin/bcs.d.mts +14 -14
- package/docs/bcs.md +131 -0
- package/docs/clients/core.md +601 -0
- package/docs/clients/graphql.md +99 -0
- package/docs/clients/grpc.md +152 -0
- package/docs/clients/index.md +93 -0
- package/docs/clients/json-rpc.md +235 -0
- package/docs/cryptography/keypairs.md +258 -0
- package/docs/cryptography/multisig.md +192 -0
- package/docs/cryptography/passkey.md +111 -0
- package/docs/cryptography/webcrypto-signer.md +81 -0
- package/docs/executors.md +147 -0
- package/docs/faucet.md +26 -0
- package/docs/hello-sui.md +114 -0
- package/docs/index.md +54 -0
- package/docs/install.md +61 -0
- package/docs/llm-docs.md +32 -0
- package/docs/llms-index.md +60 -0
- package/docs/migrations/0.38.md +57 -0
- package/docs/migrations/sui-1.0.md +453 -0
- package/docs/migrations/sui-2.0/agent-prompt.md +42 -0
- package/docs/migrations/sui-2.0/dapp-kit.md +350 -0
- package/docs/migrations/sui-2.0/deepbook-v3.md +33 -0
- package/docs/migrations/sui-2.0/index.md +157 -0
- package/docs/migrations/sui-2.0/json-rpc-migration.md +383 -0
- package/docs/migrations/sui-2.0/kiosk.md +120 -0
- package/docs/migrations/sui-2.0/sdk-maintainers.md +90 -0
- package/docs/migrations/sui-2.0/seal.md +14 -0
- package/docs/migrations/sui-2.0/sui.md +341 -0
- package/docs/migrations/sui-2.0/suins.md +42 -0
- package/docs/migrations/sui-2.0/wallet-builders.md +66 -0
- package/docs/migrations/sui-2.0/walrus.md +41 -0
- package/docs/migrations/sui-2.0/zksend.md +94 -0
- package/docs/plugins.md +255 -0
- package/docs/sdk-building.md +340 -0
- package/docs/transaction-building/basics.md +297 -0
- package/docs/transaction-building/gas.md +62 -0
- package/docs/transaction-building/intents.md +61 -0
- package/docs/transaction-building/offline.md +71 -0
- package/docs/transaction-building/sponsored-transactions.md +22 -0
- package/docs/utils/derived_objects.md +59 -0
- package/docs/utils/index.md +52 -0
- package/docs/zklogin.md +78 -0
- package/package.json +5 -3
- package/src/keypairs/passkey/keypair.ts +20 -6
- package/src/version.ts +2 -2
package/docs/bcs.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# BCS
|
|
2
|
+
|
|
3
|
+
> Binary Canonical Serialization for encoding Sui Move types
|
|
4
|
+
|
|
5
|
+
The `@mysten/sui/bcs` package extends `@mysten/bcs` with Sui specific scheme definitions.
|
|
6
|
+
|
|
7
|
+
To learn more about using BCS see the [BCS documentation](/bcs).
|
|
8
|
+
|
|
9
|
+
the `bcs` export of `@mysten/sui/bcs` contains all the same exports as `bcs` from `@mysten/bcs` plus
|
|
10
|
+
the following pre-defined schemes:
|
|
11
|
+
|
|
12
|
+
- `U8`
|
|
13
|
+
- `U16`
|
|
14
|
+
- `U32`
|
|
15
|
+
- `U64`
|
|
16
|
+
- `U128`
|
|
17
|
+
- `U256`
|
|
18
|
+
- `ULEB128`
|
|
19
|
+
- `Bool`
|
|
20
|
+
- `String`
|
|
21
|
+
- `Address`
|
|
22
|
+
- `Argument`
|
|
23
|
+
- `CallArg`
|
|
24
|
+
- `CompressedSignature`
|
|
25
|
+
- `GasData`
|
|
26
|
+
- `MultiSig`
|
|
27
|
+
- `MultiSigPkMap`
|
|
28
|
+
- `MultiSigPublicKey`
|
|
29
|
+
- `ObjectArg`
|
|
30
|
+
- `ObjectDigest`
|
|
31
|
+
- `ProgrammableMoveCall`
|
|
32
|
+
- `ProgrammableTransaction`
|
|
33
|
+
- `PublicKey`
|
|
34
|
+
- `SenderSignedData`
|
|
35
|
+
- `SharedObjectRef`
|
|
36
|
+
- `StructTag`
|
|
37
|
+
- `SuiObjectRef`
|
|
38
|
+
- `Transaction`
|
|
39
|
+
- `TransactionData`
|
|
40
|
+
- `TransactionDataV1`
|
|
41
|
+
- `TransactionExpiration`
|
|
42
|
+
- `TransactionKind`
|
|
43
|
+
- `TypeTag`
|
|
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
|
+
|
|
49
|
+
All the upper-cased values are `BcsType` instances, and can be used directly to parse and serialize
|
|
50
|
+
data.
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
bcs.U8.serialize(1);
|
|
54
|
+
bcs.Address.serialize('0x1');
|
|
55
|
+
bcs.TypeTag.serialize({
|
|
56
|
+
vector: {
|
|
57
|
+
u8: true,
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Working with Objects
|
|
63
|
+
|
|
64
|
+
To parse on-chain objects, fetch them with `include: { content: true }` and pass `object.content` to
|
|
65
|
+
a generated BCS type or a manual struct definition. The `content` field contains only the inner Move
|
|
66
|
+
struct bytes:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
const { object } = await client.core.getObject({
|
|
70
|
+
objectId: '0x123...',
|
|
71
|
+
include: { content: true },
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const parsed = MyStruct.parse(object.content);
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### `bcs.Object` — Full object envelope
|
|
78
|
+
|
|
79
|
+
The `bcs.Object` schema represents the complete on-chain object, including metadata (type, owner,
|
|
80
|
+
version, previous transaction, storage rebate) wrapping the inner struct bytes. This is what the
|
|
81
|
+
`objectBcs` include option returns. Most of this metadata is already available as fields on the
|
|
82
|
+
object response, so you typically only need `content`.
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
|
|
86
|
+
// Parse a full object envelope (from objectBcs include option)
|
|
87
|
+
const envelope = bcs.Object.parse(object.objectBcs);
|
|
88
|
+
console.log('Owner:', envelope.owner);
|
|
89
|
+
console.log('Inner struct bytes:', envelope.data.Move.contents);
|
|
90
|
+
|
|
91
|
+
// Serialize a full object envelope
|
|
92
|
+
const serialized = bcs.Object.serialize({
|
|
93
|
+
data: {
|
|
94
|
+
Move: {
|
|
95
|
+
type: { GasCoin: null },
|
|
96
|
+
hasPublicTransfer: true,
|
|
97
|
+
version: '1',
|
|
98
|
+
contents: new Uint8Array([...]),
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
owner: { AddressOwner: '0x...' },
|
|
102
|
+
previousTransaction: '...',
|
|
103
|
+
storageRebate: '1000',
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
> **Warning:** Do not pass `objectBcs` bytes to a Move struct parser — it contains wrapping metadata
|
|
108
|
+
> that will cause parsing to fail. Use `content` for parsing Move struct fields. See the
|
|
109
|
+
> [Core API docs](/sui/clients/core#objectbcs) for details.
|
|
110
|
+
|
|
111
|
+
## Working with Transaction Effects
|
|
112
|
+
|
|
113
|
+
The `bcs.TransactionEffects` schema can be used to parse transaction effects:
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
// Parse transaction effects
|
|
117
|
+
const effects = bcs.TransactionEffects.parse(effectsBytes);
|
|
118
|
+
|
|
119
|
+
// Check execution status
|
|
120
|
+
if (effects.V2.status.$kind === 'Success') {
|
|
121
|
+
console.log('Transaction succeeded');
|
|
122
|
+
} else {
|
|
123
|
+
console.log('Transaction failed:', effects.V2.status.Failure.error);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Access changed objects
|
|
127
|
+
for (const [objectId, change] of effects.V2.changedObjects) {
|
|
128
|
+
console.log('Object:', objectId);
|
|
129
|
+
console.log('Output state:', change.outputState.$kind);
|
|
130
|
+
}
|
|
131
|
+
```
|