@mysten/sui 2.15.0 → 2.16.1
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 +27 -0
- package/dist/bcs/bcs.d.mts +6 -6
- package/dist/client/mvr.d.mts.map +1 -1
- package/dist/client/mvr.mjs +3 -0
- package/dist/client/mvr.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/name_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/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 +6 -6
- 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/transactions/data/v2.d.mts.map +1 -1
- package/dist/utils/format.d.mts +5 -1
- package/dist/utils/format.d.mts.map +1 -1
- package/dist/utils/format.mjs +19 -1
- package/dist/utils/format.mjs.map +1 -1
- package/dist/utils/index.d.mts +2 -2
- package/dist/utils/index.mjs +2 -2
- package/dist/version.mjs +2 -3
- package/dist/version.mjs.map +1 -1
- package/dist/zklogin/bcs.d.mts +14 -14
- package/dist/zklogin/bcs.d.mts.map +1 -1
- package/package.json +4 -5
- package/src/client/mvr.ts +12 -0
- package/src/jsonRpc/http-transport.ts +1 -2
- package/src/utils/format.ts +36 -0
- package/src/utils/index.ts +1 -1
- package/src/version.ts +1 -2
- package/docs/bcs.md +0 -131
- package/docs/clients/core.md +0 -616
- package/docs/clients/graphql.md +0 -99
- package/docs/clients/grpc.md +0 -205
- package/docs/clients/index.md +0 -93
- package/docs/clients/json-rpc.md +0 -235
- package/docs/cryptography/keypairs.md +0 -258
- package/docs/cryptography/multisig.md +0 -192
- package/docs/cryptography/passkey.md +0 -111
- package/docs/cryptography/webcrypto-signer.md +0 -81
- package/docs/executors.md +0 -147
- package/docs/faucet.md +0 -26
- package/docs/hello-sui.md +0 -114
- package/docs/index.md +0 -54
- package/docs/install.md +0 -61
- package/docs/llm-docs.md +0 -32
- package/docs/llms-index.md +0 -60
- package/docs/migrations/0.38.md +0 -57
- package/docs/migrations/sui-1.0.md +0 -453
- package/docs/migrations/sui-2.0/agent-prompt.md +0 -42
- package/docs/migrations/sui-2.0/dapp-kit.md +0 -350
- package/docs/migrations/sui-2.0/deepbook-v3.md +0 -33
- package/docs/migrations/sui-2.0/index.md +0 -157
- package/docs/migrations/sui-2.0/json-rpc-migration.md +0 -399
- package/docs/migrations/sui-2.0/kiosk.md +0 -120
- package/docs/migrations/sui-2.0/sdk-maintainers.md +0 -90
- package/docs/migrations/sui-2.0/seal.md +0 -14
- package/docs/migrations/sui-2.0/sui.md +0 -341
- package/docs/migrations/sui-2.0/suins.md +0 -42
- package/docs/migrations/sui-2.0/wallet-builders.md +0 -66
- package/docs/migrations/sui-2.0/walrus.md +0 -41
- package/docs/migrations/sui-2.0/zksend.md +0 -94
- package/docs/plugins.md +0 -255
- package/docs/sdk-building.md +0 -340
- package/docs/transaction-building/basics.md +0 -297
- package/docs/transaction-building/gas.md +0 -62
- package/docs/transaction-building/intents.md +0 -61
- package/docs/transaction-building/offline.md +0 -71
- package/docs/transaction-building/sponsored-transactions.md +0 -22
- package/docs/utils/derived_objects.md +0 -80
- package/docs/utils/index.md +0 -52
- package/docs/zklogin.md +0 -78
- package/src/transactions/__tests__/Transaction.test.ts +0 -184
- package/src/transactions/__tests__/bcs.test.ts +0 -205
package/docs/zklogin.md
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
# ZkLogin
|
|
2
|
-
|
|
3
|
-
> Zero-knowledge authentication with OAuth providers on Sui
|
|
4
|
-
|
|
5
|
-
Utilities for working with zkLogin. Currently contains functionality to create and parse zkLogin
|
|
6
|
-
signatures and compute zkLogin addresses.
|
|
7
|
-
|
|
8
|
-
To parse a serialized zkLogin signature
|
|
9
|
-
|
|
10
|
-
```typescript
|
|
11
|
-
const parsedSignature = await parseZkLoginSignature('BQNNMTY4NjAxMzAyO....');
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
Use `getZkLoginSignature` to serialize a zkLogin signature.
|
|
15
|
-
|
|
16
|
-
```typescript
|
|
17
|
-
const serializedSignature = await getZkLoginSignature({ inputs, maxEpoch, userSignature });
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
To compute the address for a given address seed and iss you can use `computeZkLoginAddressFromSeed`
|
|
21
|
-
|
|
22
|
-
```typescript
|
|
23
|
-
const address = computeZkLoginAddressFromSeed(0n, 'https://accounts.google.com');
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
To compute an address from jwt:
|
|
27
|
-
|
|
28
|
-
```typescript
|
|
29
|
-
const address = jwtToAddress(jwtAsString, salt);
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
To compute an address from a parsed jwt:
|
|
33
|
-
|
|
34
|
-
```typescript
|
|
35
|
-
const address = computeZkLoginAddress({
|
|
36
|
-
claimName,
|
|
37
|
-
claimValue,
|
|
38
|
-
iss,
|
|
39
|
-
aud,
|
|
40
|
-
userSalt: BigInt(salt),
|
|
41
|
-
});
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
To use zkLogin inside a multisig, see the [Multisig Guide](../sui/cryptography/multisig) for more
|
|
45
|
-
details.
|
|
46
|
-
|
|
47
|
-
## Legacy addresses
|
|
48
|
-
|
|
49
|
-
When zklogin was first introduced, there was an inconsistency in how the address seed was computed.
|
|
50
|
-
For backwards compatibility reasons there are 2 valid addresses for a given set of inputs. Methods
|
|
51
|
-
that produce zklogin addresses all accept a `legacyAddress` boolean flag, either as their last
|
|
52
|
-
parameter, or in their options argument.
|
|
53
|
-
|
|
54
|
-
```typescript
|
|
55
|
-
|
|
56
|
-
computeZkLoginAddress,
|
|
57
|
-
computeZkLoginAddressFromSeed,
|
|
58
|
-
jwtToAddress,
|
|
59
|
-
toZkLoginPublicIdentifier,
|
|
60
|
-
genAddressSeed,
|
|
61
|
-
} from '@mysten/sui/zklogin';
|
|
62
|
-
|
|
63
|
-
const address = jwtToAddress(jwtAsString, salt, true);
|
|
64
|
-
const address = computeZkLoginAddressFromSeed(0n, 'https://accounts.google.com', true);
|
|
65
|
-
const address = computeZkLoginAddress({
|
|
66
|
-
claimName,
|
|
67
|
-
claimValue,
|
|
68
|
-
iss,
|
|
69
|
-
aud,
|
|
70
|
-
userSalt: BigInt(salt),
|
|
71
|
-
legacyAddress: true,
|
|
72
|
-
});
|
|
73
|
-
const address = toZkLoginPublicIdentifier(
|
|
74
|
-
genAddressSeed(userSalt, claimName, claimValue, aud),
|
|
75
|
-
iss,
|
|
76
|
-
{ legacyAddress: true },
|
|
77
|
-
).toSuiAddress();
|
|
78
|
-
```
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import { toBase58 } from '@mysten/bcs';
|
|
5
|
-
import { describe, expect, it } from 'vitest';
|
|
6
|
-
|
|
7
|
-
import { bcs } from '../../bcs/index.js';
|
|
8
|
-
import { TransactionCommands, Transaction } from '../index.js';
|
|
9
|
-
import { Inputs } from '../Inputs.js';
|
|
10
|
-
|
|
11
|
-
it('can construct and serialize an empty tranaction', () => {
|
|
12
|
-
const tx = new Transaction();
|
|
13
|
-
expect(() => tx.serialize()).not.toThrow();
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('can construct a receiving transaction argument', () => {
|
|
17
|
-
const tx = new Transaction();
|
|
18
|
-
tx.object(Inputs.ReceivingRef(ref()));
|
|
19
|
-
expect(() => tx.serialize()).not.toThrow();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('receiving transaction argument different from object argument', () => {
|
|
23
|
-
const oref = ref();
|
|
24
|
-
const rtx = new Transaction();
|
|
25
|
-
rtx.object(Inputs.ReceivingRef(oref));
|
|
26
|
-
const otx = new Transaction();
|
|
27
|
-
otx.object(Inputs.ObjectRef(oref));
|
|
28
|
-
expect(() => rtx.serialize()).not.toThrow();
|
|
29
|
-
expect(() => otx.serialize()).not.toThrow();
|
|
30
|
-
expect(otx.serialize()).not.toEqual(rtx.serialize());
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('can be serialized and deserialized to the same values', () => {
|
|
34
|
-
const tx = new Transaction();
|
|
35
|
-
tx.add(TransactionCommands.SplitCoins(tx.gas, [tx.pure.u64(100)]));
|
|
36
|
-
const serialized = tx.serialize();
|
|
37
|
-
const tx2 = Transaction.from(serialized);
|
|
38
|
-
expect(serialized).toEqual(tx2.serialize());
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('allows transfer with the result of split Commands', () => {
|
|
42
|
-
const tx = new Transaction();
|
|
43
|
-
const coin = tx.add(TransactionCommands.SplitCoins(tx.gas, [tx.pure.u64(100)]));
|
|
44
|
-
tx.add(TransactionCommands.TransferObjects([coin], tx.object('0x2')));
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('supports nested results through either array index or destructuring', () => {
|
|
48
|
-
const tx = new Transaction();
|
|
49
|
-
const registerResult = tx.add(
|
|
50
|
-
TransactionCommands.MoveCall({
|
|
51
|
-
target: '0x2::game::register',
|
|
52
|
-
}),
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
const [nft, account] = registerResult;
|
|
56
|
-
|
|
57
|
-
// NOTE: This might seem silly but destructuring works differently than property access.
|
|
58
|
-
expect(nft).toBe(registerResult[0]);
|
|
59
|
-
expect(account).toBe(registerResult[1]);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
describe('offline build', () => {
|
|
63
|
-
it('builds an empty transaction offline when provided sufficient data', async () => {
|
|
64
|
-
const tx = setup();
|
|
65
|
-
await tx.build();
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('supports epoch expiration', async () => {
|
|
69
|
-
const tx = setup();
|
|
70
|
-
tx.setExpiration({ Epoch: 1 });
|
|
71
|
-
await tx.build();
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('builds a split transaction', async () => {
|
|
75
|
-
const tx = setup();
|
|
76
|
-
tx.add(TransactionCommands.SplitCoins(tx.gas, [tx.pure.u64(100)]));
|
|
77
|
-
await tx.build();
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('breaks reference equality', () => {
|
|
81
|
-
const tx = setup();
|
|
82
|
-
const tx2 = Transaction.from(tx);
|
|
83
|
-
|
|
84
|
-
tx.setGasBudget(999);
|
|
85
|
-
|
|
86
|
-
// Ensure that setting budget after a clone does not affect the original:
|
|
87
|
-
expect(tx2.getData()).not.toEqual(tx.getData());
|
|
88
|
-
|
|
89
|
-
// Ensure `getData()` always breaks reference equality:
|
|
90
|
-
expect(tx.getData()).not.toBe(tx.getData());
|
|
91
|
-
expect(tx.getData().gasData).not.toBe(tx.getData().gasData);
|
|
92
|
-
expect(tx.getData().commands).not.toBe(tx.getData().commands);
|
|
93
|
-
expect(tx.getData().inputs).not.toBe(tx.getData().inputs);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('can determine the type of inputs for built-in Commands', async () => {
|
|
97
|
-
const tx = setup();
|
|
98
|
-
tx.splitCoins(tx.gas, [100]);
|
|
99
|
-
await tx.build();
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('supports pre-serialized inputs as Uint8Array', async () => {
|
|
103
|
-
const tx = setup();
|
|
104
|
-
const inputBytes = bcs.U64.serialize(100n).toBytes();
|
|
105
|
-
// Use bytes directly in pure value:
|
|
106
|
-
tx.add(TransactionCommands.SplitCoins(tx.gas, [tx.pure(inputBytes)]));
|
|
107
|
-
await tx.build();
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it('builds a more complex interaction', async () => {
|
|
111
|
-
const tx = setup();
|
|
112
|
-
const coin = tx.splitCoins(tx.gas, [100]);
|
|
113
|
-
tx.add(TransactionCommands.MergeCoins(tx.gas, [coin, tx.object(Inputs.ObjectRef(ref()))]));
|
|
114
|
-
tx.add(
|
|
115
|
-
TransactionCommands.MoveCall({
|
|
116
|
-
target: '0x2::devnet_nft::mint',
|
|
117
|
-
typeArguments: [],
|
|
118
|
-
arguments: [tx.pure.string('foo'), tx.pure.string('bar'), tx.pure.string('baz')],
|
|
119
|
-
}),
|
|
120
|
-
);
|
|
121
|
-
await tx.build();
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('uses a receiving argument', async () => {
|
|
125
|
-
const tx = setup();
|
|
126
|
-
tx.object(Inputs.ObjectRef(ref()));
|
|
127
|
-
const coin = tx.splitCoins(tx.gas, [100]);
|
|
128
|
-
tx.add(TransactionCommands.MergeCoins(tx.gas, [coin, tx.object(Inputs.ObjectRef(ref()))]));
|
|
129
|
-
tx.add(
|
|
130
|
-
TransactionCommands.MoveCall({
|
|
131
|
-
target: '0x2::devnet_nft::mint',
|
|
132
|
-
typeArguments: [],
|
|
133
|
-
arguments: [tx.object(Inputs.ObjectRef(ref())), tx.object(Inputs.ReceivingRef(ref()))],
|
|
134
|
-
}),
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
const bytes = await tx.build();
|
|
138
|
-
const tx2 = Transaction.from(bytes);
|
|
139
|
-
const bytes2 = await tx2.build();
|
|
140
|
-
|
|
141
|
-
expect(bytes).toEqual(bytes2);
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it('builds a more complex interaction', async () => {
|
|
145
|
-
const tx = setup();
|
|
146
|
-
const coin = tx.splitCoins(tx.gas, [100]);
|
|
147
|
-
tx.add(TransactionCommands.MergeCoins(tx.gas, [coin, tx.object(Inputs.ObjectRef(ref()))]));
|
|
148
|
-
tx.add(
|
|
149
|
-
TransactionCommands.MoveCall({
|
|
150
|
-
target: '0x2::devnet_nft::mint',
|
|
151
|
-
typeArguments: [],
|
|
152
|
-
arguments: [tx.pure.string('foo'), tx.pure.string('bar'), tx.pure.string('baz')],
|
|
153
|
-
}),
|
|
154
|
-
);
|
|
155
|
-
|
|
156
|
-
const bytes = await tx.build();
|
|
157
|
-
const tx2 = Transaction.from(bytes);
|
|
158
|
-
const bytes2 = await tx2.build();
|
|
159
|
-
|
|
160
|
-
expect(bytes).toEqual(bytes2);
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
function ref(): { objectId: string; version: string; digest: string } {
|
|
165
|
-
return {
|
|
166
|
-
objectId: (Math.random() * 100000).toFixed(0).padEnd(64, '0'),
|
|
167
|
-
version: String((Math.random() * 10000).toFixed(0)),
|
|
168
|
-
digest: toBase58(
|
|
169
|
-
new Uint8Array([
|
|
170
|
-
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1,
|
|
171
|
-
2,
|
|
172
|
-
]),
|
|
173
|
-
),
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function setup() {
|
|
178
|
-
const tx = new Transaction();
|
|
179
|
-
tx.setSender('0x2');
|
|
180
|
-
tx.setGasPrice(5);
|
|
181
|
-
tx.setGasBudget(100);
|
|
182
|
-
tx.setGasPayment([ref()]);
|
|
183
|
-
return tx;
|
|
184
|
-
}
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import { toBase58 } from '@mysten/bcs';
|
|
5
|
-
import { expect, it } from 'vitest';
|
|
6
|
-
|
|
7
|
-
import { bcs } from '../../bcs/index.js';
|
|
8
|
-
import { normalizeStructTag, normalizeSuiAddress } from '../../utils/sui-types.js';
|
|
9
|
-
|
|
10
|
-
// Oooh-weeee we nailed it!
|
|
11
|
-
it('can serialize simplified programmable call struct', () => {
|
|
12
|
-
const moveCall = {
|
|
13
|
-
package: '0x2',
|
|
14
|
-
module: 'display',
|
|
15
|
-
function: 'new',
|
|
16
|
-
typeArguments: [normalizeStructTag('0x6::capy::Capy')],
|
|
17
|
-
arguments: [
|
|
18
|
-
{
|
|
19
|
-
$kind: 'GasCoin',
|
|
20
|
-
GasCoin: true,
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
$kind: 'NestedResult',
|
|
24
|
-
NestedResult: [0, 1],
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
$kind: 'Input',
|
|
28
|
-
Input: 3,
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
$kind: 'Result',
|
|
32
|
-
Result: 1,
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
} satisfies typeof bcs.ProgrammableMoveCall.$inferType;
|
|
36
|
-
|
|
37
|
-
const bytes = bcs.ProgrammableMoveCall.serialize(moveCall).toBytes();
|
|
38
|
-
const result = bcs.ProgrammableMoveCall.parse(bytes);
|
|
39
|
-
|
|
40
|
-
// since we normalize addresses when (de)serializing, the returned value differs
|
|
41
|
-
// only check the module and the function; ignore address comparison (it's not an issue
|
|
42
|
-
// with non-0x2 addresses).
|
|
43
|
-
expect(result.arguments).toEqual(moveCall.arguments);
|
|
44
|
-
expect(result.function).toEqual(moveCall.function);
|
|
45
|
-
expect(result.module).toEqual(moveCall.module);
|
|
46
|
-
expect(normalizeSuiAddress(result.package)).toEqual(normalizeSuiAddress(moveCall.package));
|
|
47
|
-
expect(result.typeArguments[0]).toEqual(moveCall.typeArguments[0]);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
function ref(): { objectId: string; version: string; digest: string } {
|
|
51
|
-
return {
|
|
52
|
-
objectId: normalizeSuiAddress((Math.random() * 100000).toFixed(0).padEnd(64, '0')),
|
|
53
|
-
version: String((Math.random() * 10000).toFixed(0)),
|
|
54
|
-
digest: toBase58(
|
|
55
|
-
new Uint8Array([
|
|
56
|
-
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1,
|
|
57
|
-
2,
|
|
58
|
-
]),
|
|
59
|
-
),
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
it('can serialize transaction data with a programmable transaction', () => {
|
|
64
|
-
const sui = normalizeSuiAddress('0x2');
|
|
65
|
-
const txData = {
|
|
66
|
-
$kind: 'V1',
|
|
67
|
-
V1: {
|
|
68
|
-
sender: normalizeSuiAddress('0xBAD'),
|
|
69
|
-
expiration: { $kind: 'None', None: true },
|
|
70
|
-
gasData: {
|
|
71
|
-
payment: [ref()],
|
|
72
|
-
owner: sui,
|
|
73
|
-
price: '1',
|
|
74
|
-
budget: '1000000',
|
|
75
|
-
},
|
|
76
|
-
kind: {
|
|
77
|
-
$kind: 'ProgrammableTransaction',
|
|
78
|
-
ProgrammableTransaction: {
|
|
79
|
-
inputs: [
|
|
80
|
-
// first argument is the publisher object
|
|
81
|
-
{
|
|
82
|
-
$kind: 'Object',
|
|
83
|
-
Object: {
|
|
84
|
-
$kind: 'ImmOrOwnedObject',
|
|
85
|
-
ImmOrOwnedObject: ref(),
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
// second argument is a vector of names
|
|
89
|
-
{
|
|
90
|
-
$kind: 'Pure',
|
|
91
|
-
Pure: {
|
|
92
|
-
bytes: bcs
|
|
93
|
-
.vector(bcs.String)
|
|
94
|
-
.serialize(['name', 'description', 'img_url'])
|
|
95
|
-
.toBase64(),
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
// third argument is a vector of values
|
|
99
|
-
{
|
|
100
|
-
$kind: 'Pure',
|
|
101
|
-
Pure: {
|
|
102
|
-
bytes: bcs
|
|
103
|
-
.vector(bcs.String)
|
|
104
|
-
.serialize([
|
|
105
|
-
'Capy {name}',
|
|
106
|
-
'A cute little creature',
|
|
107
|
-
'https://api.capy.art/{id}/svg',
|
|
108
|
-
])
|
|
109
|
-
.toBase64(),
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
// 4th and last argument is the account address to send display to
|
|
113
|
-
{
|
|
114
|
-
$kind: 'Pure',
|
|
115
|
-
Pure: {
|
|
116
|
-
bytes: bcs.Address.serialize(ref().objectId).toBase64(),
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
],
|
|
120
|
-
commands: [
|
|
121
|
-
{
|
|
122
|
-
$kind: 'MoveCall',
|
|
123
|
-
MoveCall: {
|
|
124
|
-
package: sui,
|
|
125
|
-
module: 'display',
|
|
126
|
-
function: 'new',
|
|
127
|
-
typeArguments: [`${sui}::capy::Capy`],
|
|
128
|
-
arguments: [
|
|
129
|
-
// publisher object
|
|
130
|
-
{
|
|
131
|
-
$kind: 'Input',
|
|
132
|
-
Input: 0,
|
|
133
|
-
},
|
|
134
|
-
],
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
$kind: 'MoveCall',
|
|
139
|
-
MoveCall: {
|
|
140
|
-
package: sui,
|
|
141
|
-
module: 'display',
|
|
142
|
-
function: 'add_multiple',
|
|
143
|
-
typeArguments: [`${sui}::capy::Capy`],
|
|
144
|
-
arguments: [
|
|
145
|
-
// result of the first transaction
|
|
146
|
-
{
|
|
147
|
-
$kind: 'Result',
|
|
148
|
-
Result: 0,
|
|
149
|
-
},
|
|
150
|
-
// second argument - vector of names
|
|
151
|
-
{
|
|
152
|
-
$kind: 'Input',
|
|
153
|
-
Input: 1,
|
|
154
|
-
},
|
|
155
|
-
// third argument - vector of values
|
|
156
|
-
{
|
|
157
|
-
$kind: 'Input',
|
|
158
|
-
Input: 2,
|
|
159
|
-
},
|
|
160
|
-
],
|
|
161
|
-
},
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
$kind: 'MoveCall',
|
|
165
|
-
MoveCall: {
|
|
166
|
-
package: sui,
|
|
167
|
-
module: 'display',
|
|
168
|
-
function: 'update_version',
|
|
169
|
-
typeArguments: [`${sui}::capy::Capy`],
|
|
170
|
-
arguments: [
|
|
171
|
-
// result of the first transaction again
|
|
172
|
-
{
|
|
173
|
-
$kind: 'Result',
|
|
174
|
-
Result: 0,
|
|
175
|
-
},
|
|
176
|
-
],
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
$kind: 'TransferObjects',
|
|
181
|
-
TransferObjects: {
|
|
182
|
-
objects: [
|
|
183
|
-
// the display object
|
|
184
|
-
{
|
|
185
|
-
$kind: 'Result',
|
|
186
|
-
Result: 0,
|
|
187
|
-
},
|
|
188
|
-
],
|
|
189
|
-
// address is also an input
|
|
190
|
-
address: {
|
|
191
|
-
$kind: 'Input',
|
|
192
|
-
Input: 3,
|
|
193
|
-
},
|
|
194
|
-
},
|
|
195
|
-
},
|
|
196
|
-
],
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
},
|
|
200
|
-
} satisfies typeof bcs.TransactionData.$inferType;
|
|
201
|
-
|
|
202
|
-
const bytes = bcs.TransactionData.serialize(txData).toBytes();
|
|
203
|
-
const result = bcs.TransactionData.parse(bytes);
|
|
204
|
-
expect(result).toMatchObject(txData);
|
|
205
|
-
});
|