@mysten/sui 1.37.5 → 1.38.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 +20 -0
- package/dist/cjs/bcs/index.d.ts +1 -1
- package/dist/cjs/cryptography/intent.d.ts +1 -1
- package/dist/cjs/cryptography/keypair.d.ts +1 -1
- package/dist/cjs/cryptography/keypair.js.map +1 -1
- package/dist/cjs/cryptography/publickey.d.ts +3 -3
- package/dist/cjs/cryptography/publickey.js.map +2 -2
- package/dist/cjs/cryptography/signature.d.ts +3 -3
- package/dist/cjs/experimental/transports/json-rpc-resolver.js +5 -3
- package/dist/cjs/experimental/transports/json-rpc-resolver.js.map +2 -2
- package/dist/cjs/experimental/transports/jsonRPC.d.ts +2 -2
- package/dist/cjs/keypairs/ed25519/keypair.d.ts +1 -1
- package/dist/cjs/keypairs/ed25519/keypair.js.map +1 -1
- package/dist/cjs/keypairs/ed25519/publickey.d.ts +1 -1
- package/dist/cjs/keypairs/ed25519/publickey.js.map +2 -2
- package/dist/cjs/keypairs/passkey/keypair.d.ts +1 -1
- package/dist/cjs/keypairs/passkey/keypair.js.map +1 -1
- package/dist/cjs/keypairs/passkey/publickey.d.ts +1 -1
- package/dist/cjs/keypairs/passkey/publickey.js.map +2 -2
- package/dist/cjs/keypairs/secp256k1/keypair.d.ts +1 -1
- package/dist/cjs/keypairs/secp256k1/keypair.js.map +1 -1
- package/dist/cjs/keypairs/secp256k1/publickey.d.ts +1 -1
- package/dist/cjs/keypairs/secp256k1/publickey.js.map +2 -2
- package/dist/cjs/keypairs/secp256r1/keypair.d.ts +1 -1
- package/dist/cjs/keypairs/secp256r1/keypair.js.map +1 -1
- package/dist/cjs/keypairs/secp256r1/publickey.d.ts +1 -1
- package/dist/cjs/keypairs/secp256r1/publickey.js.map +2 -2
- package/dist/cjs/multisig/publickey.d.ts +1 -1
- package/dist/cjs/multisig/publickey.js.map +2 -2
- package/dist/cjs/transactions/Commands.d.ts +9 -9
- package/dist/cjs/transactions/Commands.js +9 -9
- package/dist/cjs/transactions/Commands.js.map +2 -2
- package/dist/cjs/transactions/Transaction.d.ts +6 -5
- package/dist/cjs/transactions/Transaction.js +5 -5
- package/dist/cjs/transactions/Transaction.js.map +2 -2
- package/dist/cjs/transactions/TransactionData.d.ts +4 -5
- package/dist/cjs/transactions/TransactionData.js +3 -3
- package/dist/cjs/transactions/TransactionData.js.map +2 -2
- package/dist/cjs/transactions/data/internal.d.ts +21 -19
- package/dist/cjs/transactions/data/internal.js +45 -44
- package/dist/cjs/transactions/data/internal.js.map +2 -2
- package/dist/cjs/transactions/data/v1.d.ts +1 -1
- package/dist/cjs/transactions/data/v1.js +1 -1
- package/dist/cjs/transactions/data/v1.js.map +2 -2
- package/dist/cjs/transactions/data/v2.d.ts +4 -2
- package/dist/cjs/transactions/data/v2.js +7 -6
- package/dist/cjs/transactions/data/v2.js.map +2 -2
- package/dist/cjs/transactions/executor/caching.d.ts +1 -1
- package/dist/cjs/transactions/executor/serial.d.ts +1 -1
- package/dist/cjs/transactions/object.js +6 -16
- package/dist/cjs/transactions/object.js.map +2 -2
- package/dist/cjs/transactions/utils.d.ts +1 -2
- package/dist/cjs/transactions/utils.js +1 -1
- package/dist/cjs/transactions/utils.js.map +2 -2
- package/dist/cjs/utils/derived-objects.d.ts +5 -0
- package/dist/cjs/utils/derived-objects.js +34 -0
- package/dist/cjs/utils/derived-objects.js.map +7 -0
- package/dist/cjs/utils/index.d.ts +1 -0
- package/dist/cjs/utils/index.js +2 -0
- package/dist/cjs/utils/index.js.map +2 -2
- package/dist/cjs/version.d.ts +2 -2
- package/dist/cjs/version.js +2 -2
- package/dist/cjs/version.js.map +1 -1
- package/dist/cjs/zklogin/publickey.d.ts +2 -2
- package/dist/cjs/zklogin/publickey.js.map +2 -2
- package/dist/esm/bcs/index.d.ts +1 -1
- package/dist/esm/cryptography/intent.d.ts +1 -1
- package/dist/esm/cryptography/keypair.d.ts +1 -1
- package/dist/esm/cryptography/keypair.js.map +1 -1
- package/dist/esm/cryptography/publickey.d.ts +3 -3
- package/dist/esm/cryptography/publickey.js.map +2 -2
- package/dist/esm/cryptography/signature.d.ts +3 -3
- package/dist/esm/experimental/transports/json-rpc-resolver.js +6 -4
- package/dist/esm/experimental/transports/json-rpc-resolver.js.map +2 -2
- package/dist/esm/experimental/transports/jsonRPC.d.ts +2 -2
- package/dist/esm/keypairs/ed25519/keypair.d.ts +1 -1
- package/dist/esm/keypairs/ed25519/keypair.js.map +1 -1
- package/dist/esm/keypairs/ed25519/publickey.d.ts +1 -1
- package/dist/esm/keypairs/ed25519/publickey.js.map +2 -2
- package/dist/esm/keypairs/passkey/keypair.d.ts +1 -1
- package/dist/esm/keypairs/passkey/keypair.js.map +1 -1
- package/dist/esm/keypairs/passkey/publickey.d.ts +1 -1
- package/dist/esm/keypairs/passkey/publickey.js.map +2 -2
- package/dist/esm/keypairs/secp256k1/keypair.d.ts +1 -1
- package/dist/esm/keypairs/secp256k1/keypair.js.map +1 -1
- package/dist/esm/keypairs/secp256k1/publickey.d.ts +1 -1
- package/dist/esm/keypairs/secp256k1/publickey.js.map +2 -2
- package/dist/esm/keypairs/secp256r1/keypair.d.ts +1 -1
- package/dist/esm/keypairs/secp256r1/keypair.js.map +1 -1
- package/dist/esm/keypairs/secp256r1/publickey.d.ts +1 -1
- package/dist/esm/keypairs/secp256r1/publickey.js.map +2 -2
- package/dist/esm/multisig/publickey.d.ts +1 -1
- package/dist/esm/multisig/publickey.js.map +2 -2
- package/dist/esm/transactions/Commands.d.ts +9 -9
- package/dist/esm/transactions/Commands.js +10 -10
- package/dist/esm/transactions/Commands.js.map +2 -2
- package/dist/esm/transactions/Transaction.d.ts +6 -5
- package/dist/esm/transactions/Transaction.js +12 -7
- package/dist/esm/transactions/Transaction.js.map +2 -2
- package/dist/esm/transactions/TransactionData.d.ts +4 -5
- package/dist/esm/transactions/TransactionData.js +4 -4
- package/dist/esm/transactions/TransactionData.js.map +2 -2
- package/dist/esm/transactions/data/internal.d.ts +21 -19
- package/dist/esm/transactions/data/internal.js +45 -44
- package/dist/esm/transactions/data/internal.js.map +2 -2
- package/dist/esm/transactions/data/v1.d.ts +1 -1
- package/dist/esm/transactions/data/v1.js +2 -2
- package/dist/esm/transactions/data/v1.js.map +2 -2
- package/dist/esm/transactions/data/v2.d.ts +4 -2
- package/dist/esm/transactions/data/v2.js +8 -7
- package/dist/esm/transactions/data/v2.js.map +2 -2
- package/dist/esm/transactions/executor/caching.d.ts +1 -1
- package/dist/esm/transactions/executor/serial.d.ts +1 -1
- package/dist/esm/transactions/object.js +6 -16
- package/dist/esm/transactions/object.js.map +2 -2
- package/dist/esm/transactions/utils.d.ts +1 -2
- package/dist/esm/transactions/utils.js +2 -2
- package/dist/esm/transactions/utils.js.map +2 -2
- package/dist/esm/utils/derived-objects.d.ts +5 -0
- package/dist/esm/utils/derived-objects.js +14 -0
- package/dist/esm/utils/derived-objects.js.map +7 -0
- package/dist/esm/utils/index.d.ts +1 -0
- package/dist/esm/utils/index.js +2 -0
- package/dist/esm/utils/index.js.map +2 -2
- package/dist/esm/version.d.ts +2 -2
- package/dist/esm/version.js +2 -2
- package/dist/esm/version.js.map +1 -1
- package/dist/esm/zklogin/publickey.d.ts +2 -2
- package/dist/esm/zklogin/publickey.js.map +2 -2
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/src/cryptography/keypair.ts +1 -1
- package/src/cryptography/publickey.ts +2 -2
- package/src/experimental/transports/json-rpc-resolver.ts +8 -4
- package/src/keypairs/ed25519/keypair.ts +1 -1
- package/src/keypairs/ed25519/publickey.ts +3 -3
- package/src/keypairs/passkey/keypair.ts +2 -2
- package/src/keypairs/passkey/publickey.ts +3 -3
- package/src/keypairs/secp256k1/keypair.ts +1 -1
- package/src/keypairs/secp256k1/publickey.ts +3 -3
- package/src/keypairs/secp256r1/keypair.ts +1 -1
- package/src/keypairs/secp256r1/publickey.ts +3 -3
- package/src/multisig/publickey.ts +3 -3
- package/src/transactions/Commands.ts +27 -22
- package/src/transactions/Transaction.ts +18 -11
- package/src/transactions/TransactionData.ts +7 -6
- package/src/transactions/data/internal.ts +44 -42
- package/src/transactions/data/v1.ts +5 -5
- package/src/transactions/data/v2.ts +7 -6
- package/src/transactions/object.ts +6 -18
- package/src/transactions/utils.ts +3 -3
- package/src/utils/derived-objects.ts +22 -0
- package/src/utils/index.ts +2 -0
- package/src/version.ts +2 -2
- package/src/zklogin/publickey.ts +3 -3
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"author": "Mysten Labs <build@mystenlabs.com>",
|
|
4
4
|
"description": "Sui TypeScript API",
|
|
5
5
|
"homepage": "https://sdk.mystenlabs.com",
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.38.0",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"files": [
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"access": "public"
|
|
112
112
|
},
|
|
113
113
|
"devDependencies": {
|
|
114
|
-
"@0no-co/graphqlsp": "^1.
|
|
114
|
+
"@0no-co/graphqlsp": "^1.15.0",
|
|
115
115
|
"@graphql-codegen/add": "^5.0.3",
|
|
116
116
|
"@graphql-codegen/cli": "^5.0.7",
|
|
117
117
|
"@graphql-codegen/typed-document-node": "^5.1.2",
|
|
@@ -125,11 +125,11 @@
|
|
|
125
125
|
"@types/ws": "^8.18.1",
|
|
126
126
|
"cross-env": "^7.0.3",
|
|
127
127
|
"graphql-config": "^5.1.5",
|
|
128
|
-
"msw": "^2.
|
|
129
|
-
"tmp": "^0.2.
|
|
128
|
+
"msw": "^2.11.1",
|
|
129
|
+
"tmp": "^0.2.5",
|
|
130
130
|
"ts-retry-promise": "^0.8.1",
|
|
131
|
-
"typescript": "^5.
|
|
132
|
-
"vite": "^7.
|
|
131
|
+
"typescript": "^5.9.2",
|
|
132
|
+
"vite": "^7.1.5",
|
|
133
133
|
"vite-tsconfig-paths": "^5.1.4",
|
|
134
134
|
"vitest": "^3.2.4",
|
|
135
135
|
"wait-on": "^8.0.4",
|
|
@@ -143,12 +143,12 @@
|
|
|
143
143
|
"@scure/base": "^1.2.6",
|
|
144
144
|
"@scure/bip32": "^1.7.0",
|
|
145
145
|
"@scure/bip39": "^1.6.0",
|
|
146
|
-
"gql.tada": "^1.8.
|
|
146
|
+
"gql.tada": "^1.8.13",
|
|
147
147
|
"graphql": "^16.11.0",
|
|
148
|
-
"poseidon-lite": "
|
|
148
|
+
"poseidon-lite": "0.2.1",
|
|
149
149
|
"valibot": "^0.36.0",
|
|
150
|
-
"@mysten/bcs": "1.
|
|
151
|
-
"@mysten/utils": "0.
|
|
150
|
+
"@mysten/bcs": "1.8.0",
|
|
151
|
+
"@mysten/utils": "0.2.0"
|
|
152
152
|
},
|
|
153
153
|
"scripts": {
|
|
154
154
|
"clean": "rm -rf tsconfig.tsbuildinfo ./dist",
|
|
@@ -39,7 +39,7 @@ export interface SignAndExecuteOptions {
|
|
|
39
39
|
* TODO: Document
|
|
40
40
|
*/
|
|
41
41
|
export abstract class Signer {
|
|
42
|
-
abstract sign(bytes: Uint8Array): Promise<Uint8Array
|
|
42
|
+
abstract sign(bytes: Uint8Array): Promise<Uint8Array<ArrayBuffer>>;
|
|
43
43
|
/**
|
|
44
44
|
* Sign messages with a specific intent. By combining the message bytes with the intent before hashing and signing,
|
|
45
45
|
* it ensures that a signed message is tied to a specific purpose and domain separator is provided
|
|
@@ -105,7 +105,7 @@ export abstract class PublicKey {
|
|
|
105
105
|
* Returns the bytes representation of the public key
|
|
106
106
|
* prefixed with the signature scheme flag
|
|
107
107
|
*/
|
|
108
|
-
toSuiBytes(): Uint8Array {
|
|
108
|
+
toSuiBytes(): Uint8Array<ArrayBuffer> {
|
|
109
109
|
const rawBytes = this.toRawBytes();
|
|
110
110
|
const suiBytes = new Uint8Array(rawBytes.length + 1);
|
|
111
111
|
suiBytes.set([this.flag()]);
|
|
@@ -127,7 +127,7 @@ export abstract class PublicKey {
|
|
|
127
127
|
/**
|
|
128
128
|
* Return the byte array representation of the public key
|
|
129
129
|
*/
|
|
130
|
-
abstract toRawBytes(): Uint8Array
|
|
130
|
+
abstract toRawBytes(): Uint8Array<ArrayBuffer>;
|
|
131
131
|
|
|
132
132
|
/**
|
|
133
133
|
* Return signature scheme flag of the public key
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { parse } from 'valibot';
|
|
5
5
|
|
|
6
6
|
import { normalizeSuiAddress, normalizeSuiObjectId, SUI_TYPE_ARG } from '../../utils/index.js';
|
|
7
|
-
import {
|
|
7
|
+
import { ObjectRefSchema } from '../../transactions/data/internal.js';
|
|
8
8
|
import type { CallArg, Command, OpenMoveTypeSignature } from '../../transactions/data/internal.js';
|
|
9
9
|
import { Inputs } from '../../transactions/Inputs.js';
|
|
10
10
|
import {
|
|
@@ -118,7 +118,9 @@ async function setGasPayment(transactionData: TransactionDataBuilder, client: Su
|
|
|
118
118
|
throw new Error('No valid gas coins found for the transaction.');
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
transactionData.gasConfig.payment = paymentCoins.map((payment) =>
|
|
121
|
+
transactionData.gasConfig.payment = paymentCoins.map((payment) =>
|
|
122
|
+
parse(ObjectRefSchema, payment),
|
|
123
|
+
);
|
|
122
124
|
}
|
|
123
125
|
}
|
|
124
126
|
|
|
@@ -206,7 +208,7 @@ async function resolveObjectReferences(transactionData: TransactionDataBuilder,
|
|
|
206
208
|
objectId: id,
|
|
207
209
|
initialSharedVersion:
|
|
208
210
|
input.UnresolvedObject.initialSharedVersion || object?.initialSharedVersion!,
|
|
209
|
-
mutable: isUsedAsMutable(transactionData, index),
|
|
211
|
+
mutable: input.UnresolvedObject.mutable || isUsedAsMutable(transactionData, index),
|
|
210
212
|
});
|
|
211
213
|
} else if (isUsedAsReceiving(transactionData, index)) {
|
|
212
214
|
updated = Inputs.ReceivingRef(
|
|
@@ -252,7 +254,9 @@ async function normalizeInputs(transactionData: TransactionDataBuilder, client:
|
|
|
252
254
|
return null;
|
|
253
255
|
});
|
|
254
256
|
const needsResolution = inputs.some(
|
|
255
|
-
(input) =>
|
|
257
|
+
(input) =>
|
|
258
|
+
input?.UnresolvedPure ||
|
|
259
|
+
(input?.UnresolvedObject && typeof input?.UnresolvedObject.mutable !== 'boolean'),
|
|
256
260
|
);
|
|
257
261
|
|
|
258
262
|
if (needsResolution) {
|
|
@@ -139,7 +139,7 @@ export class Ed25519Keypair extends Keypair {
|
|
|
139
139
|
* Return the signature for the provided data using Ed25519.
|
|
140
140
|
*/
|
|
141
141
|
async sign(data: Uint8Array) {
|
|
142
|
-
return ed25519.sign(data, this.keypair.secretKey)
|
|
142
|
+
return ed25519.sign(data, this.keypair.secretKey) as Uint8Array<ArrayBuffer>;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
/**
|
|
@@ -19,7 +19,7 @@ const PUBLIC_KEY_SIZE = 32;
|
|
|
19
19
|
*/
|
|
20
20
|
export class Ed25519PublicKey extends PublicKey {
|
|
21
21
|
static SIZE = PUBLIC_KEY_SIZE;
|
|
22
|
-
private data: Uint8Array
|
|
22
|
+
private data: Uint8Array<ArrayBuffer>;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Create a new Ed25519PublicKey object
|
|
@@ -31,7 +31,7 @@ export class Ed25519PublicKey extends PublicKey {
|
|
|
31
31
|
if (typeof value === 'string') {
|
|
32
32
|
this.data = fromBase64(value);
|
|
33
33
|
} else if (value instanceof Uint8Array) {
|
|
34
|
-
this.data = value
|
|
34
|
+
this.data = value as Uint8Array<ArrayBuffer>;
|
|
35
35
|
} else {
|
|
36
36
|
this.data = Uint8Array.from(value);
|
|
37
37
|
}
|
|
@@ -53,7 +53,7 @@ export class Ed25519PublicKey extends PublicKey {
|
|
|
53
53
|
/**
|
|
54
54
|
* Return the byte array representation of the Ed25519 public key
|
|
55
55
|
*/
|
|
56
|
-
toRawBytes(): Uint8Array {
|
|
56
|
+
toRawBytes(): Uint8Array<ArrayBuffer> {
|
|
57
57
|
return this.data;
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -65,7 +65,7 @@ export class BrowserPasskeyProvider implements PasskeyProvider {
|
|
|
65
65
|
name: this.#name,
|
|
66
66
|
displayName: this.#name,
|
|
67
67
|
...this.#options.user,
|
|
68
|
-
id: randomBytes(10),
|
|
68
|
+
id: randomBytes(10) as BufferSource,
|
|
69
69
|
},
|
|
70
70
|
challenge: new TextEncoder().encode('Create passkey wallet on Sui'),
|
|
71
71
|
pubKeyCredParams: [{ alg: -7, type: 'public-key' }],
|
|
@@ -83,7 +83,7 @@ export class BrowserPasskeyProvider implements PasskeyProvider {
|
|
|
83
83
|
async get(challenge: Uint8Array): Promise<AuthenticationCredential> {
|
|
84
84
|
return (await navigator.credentials.get({
|
|
85
85
|
publicKey: {
|
|
86
|
-
challenge,
|
|
86
|
+
challenge: challenge as BufferSource,
|
|
87
87
|
userVerification: this.#options.authenticatorSelection?.userVerification || 'required',
|
|
88
88
|
timeout: this.#options.timeout ?? 60000,
|
|
89
89
|
},
|
|
@@ -65,7 +65,7 @@ export const SECP256R1_SPKI_HEADER = new Uint8Array([
|
|
|
65
65
|
*/
|
|
66
66
|
export class PasskeyPublicKey extends PublicKey {
|
|
67
67
|
static SIZE = PASSKEY_PUBLIC_KEY_SIZE;
|
|
68
|
-
private data: Uint8Array
|
|
68
|
+
private data: Uint8Array<ArrayBuffer>;
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
71
|
* Create a new PasskeyPublicKey object
|
|
@@ -77,7 +77,7 @@ export class PasskeyPublicKey extends PublicKey {
|
|
|
77
77
|
if (typeof value === 'string') {
|
|
78
78
|
this.data = fromBase64(value);
|
|
79
79
|
} else if (value instanceof Uint8Array) {
|
|
80
|
-
this.data = value
|
|
80
|
+
this.data = value as Uint8Array<ArrayBuffer>;
|
|
81
81
|
} else {
|
|
82
82
|
this.data = Uint8Array.from(value);
|
|
83
83
|
}
|
|
@@ -99,7 +99,7 @@ export class PasskeyPublicKey extends PublicKey {
|
|
|
99
99
|
/**
|
|
100
100
|
* Return the byte array representation of the Secp256r1 public key
|
|
101
101
|
*/
|
|
102
|
-
toRawBytes(): Uint8Array {
|
|
102
|
+
toRawBytes(): Uint8Array<ArrayBuffer> {
|
|
103
103
|
return this.data;
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -132,7 +132,7 @@ export class Secp256k1Keypair extends Keypair {
|
|
|
132
132
|
const sig = secp256k1.sign(msgHash, this.keypair.secretKey, {
|
|
133
133
|
lowS: true,
|
|
134
134
|
});
|
|
135
|
-
return sig.toCompactRawBytes()
|
|
135
|
+
return sig.toCompactRawBytes() as Uint8Array<ArrayBuffer>;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
/**
|
|
@@ -20,7 +20,7 @@ const SECP256K1_PUBLIC_KEY_SIZE = 33;
|
|
|
20
20
|
*/
|
|
21
21
|
export class Secp256k1PublicKey extends PublicKey {
|
|
22
22
|
static SIZE = SECP256K1_PUBLIC_KEY_SIZE;
|
|
23
|
-
private data: Uint8Array
|
|
23
|
+
private data: Uint8Array<ArrayBuffer>;
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Create a new Secp256k1PublicKey object
|
|
@@ -32,7 +32,7 @@ export class Secp256k1PublicKey extends PublicKey {
|
|
|
32
32
|
if (typeof value === 'string') {
|
|
33
33
|
this.data = fromBase64(value);
|
|
34
34
|
} else if (value instanceof Uint8Array) {
|
|
35
|
-
this.data = value
|
|
35
|
+
this.data = value as Uint8Array<ArrayBuffer>;
|
|
36
36
|
} else {
|
|
37
37
|
this.data = Uint8Array.from(value);
|
|
38
38
|
}
|
|
@@ -54,7 +54,7 @@ export class Secp256k1PublicKey extends PublicKey {
|
|
|
54
54
|
/**
|
|
55
55
|
* Return the byte array representation of the Secp256k1 public key
|
|
56
56
|
*/
|
|
57
|
-
toRawBytes(): Uint8Array {
|
|
57
|
+
toRawBytes(): Uint8Array<ArrayBuffer> {
|
|
58
58
|
return this.data;
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -133,7 +133,7 @@ export class Secp256r1Keypair extends Keypair {
|
|
|
133
133
|
const sig = secp256r1.sign(msgHash, this.keypair.secretKey, {
|
|
134
134
|
lowS: true,
|
|
135
135
|
});
|
|
136
|
-
return sig.toCompactRawBytes()
|
|
136
|
+
return sig.toCompactRawBytes() as Uint8Array<ArrayBuffer>;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
/**
|
|
@@ -17,7 +17,7 @@ const SECP256R1_PUBLIC_KEY_SIZE = 33;
|
|
|
17
17
|
*/
|
|
18
18
|
export class Secp256r1PublicKey extends PublicKey {
|
|
19
19
|
static SIZE = SECP256R1_PUBLIC_KEY_SIZE;
|
|
20
|
-
private data: Uint8Array
|
|
20
|
+
private data: Uint8Array<ArrayBuffer>;
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Create a new Secp256r1PublicKey object
|
|
@@ -29,7 +29,7 @@ export class Secp256r1PublicKey extends PublicKey {
|
|
|
29
29
|
if (typeof value === 'string') {
|
|
30
30
|
this.data = fromBase64(value);
|
|
31
31
|
} else if (value instanceof Uint8Array) {
|
|
32
|
-
this.data = value
|
|
32
|
+
this.data = value as Uint8Array<ArrayBuffer>;
|
|
33
33
|
} else {
|
|
34
34
|
this.data = Uint8Array.from(value);
|
|
35
35
|
}
|
|
@@ -51,7 +51,7 @@ export class Secp256r1PublicKey extends PublicKey {
|
|
|
51
51
|
/**
|
|
52
52
|
* Return the byte array representation of the Secp256r1 public key
|
|
53
53
|
*/
|
|
54
|
-
toRawBytes(): Uint8Array {
|
|
54
|
+
toRawBytes(): Uint8Array<ArrayBuffer> {
|
|
55
55
|
return this.data;
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -64,7 +64,7 @@ export const MIN_SIGNER_IN_MULTISIG = 1;
|
|
|
64
64
|
* A MultiSig public key
|
|
65
65
|
*/
|
|
66
66
|
export class MultiSigPublicKey extends PublicKey {
|
|
67
|
-
private rawBytes: Uint8Array
|
|
67
|
+
private rawBytes: Uint8Array<ArrayBuffer>;
|
|
68
68
|
private multisigPublicKey: MultiSigPublicKeyStruct;
|
|
69
69
|
private publicKeys: {
|
|
70
70
|
weight: number;
|
|
@@ -87,7 +87,7 @@ export class MultiSigPublicKey extends PublicKey {
|
|
|
87
87
|
|
|
88
88
|
this.multisigPublicKey = bcs.MultiSigPublicKey.parse(this.rawBytes);
|
|
89
89
|
} else if (value instanceof Uint8Array) {
|
|
90
|
-
this.rawBytes = value
|
|
90
|
+
this.rawBytes = value as Uint8Array<ArrayBuffer>;
|
|
91
91
|
this.multisigPublicKey = bcs.MultiSigPublicKey.parse(this.rawBytes);
|
|
92
92
|
} else {
|
|
93
93
|
this.multisigPublicKey = value;
|
|
@@ -169,7 +169,7 @@ export class MultiSigPublicKey extends PublicKey {
|
|
|
169
169
|
/**
|
|
170
170
|
* Return the byte array representation of the MultiSig public key
|
|
171
171
|
*/
|
|
172
|
-
toRawBytes(): Uint8Array {
|
|
172
|
+
toRawBytes(): Uint8Array<ArrayBuffer> {
|
|
173
173
|
return this.rawBytes;
|
|
174
174
|
}
|
|
175
175
|
|
|
@@ -6,13 +6,13 @@ import type { InferInput } from 'valibot';
|
|
|
6
6
|
import { parse } from 'valibot';
|
|
7
7
|
|
|
8
8
|
import { normalizeSuiObjectId } from '../utils/sui-types.js';
|
|
9
|
-
import { Argument } from './data/internal.js';
|
|
10
|
-
import
|
|
9
|
+
import type { Argument, CallArg, Command } from './data/internal.js';
|
|
10
|
+
import { ArgumentSchema } from './data/internal.js';
|
|
11
11
|
import type { AsyncTransactionThunk, Transaction } from './Transaction.js';
|
|
12
12
|
|
|
13
13
|
export type TransactionArgument =
|
|
14
|
-
| InferInput<typeof
|
|
15
|
-
| ((tx: Transaction) => InferInput<typeof
|
|
14
|
+
| InferInput<typeof ArgumentSchema>
|
|
15
|
+
| ((tx: Transaction) => InferInput<typeof ArgumentSchema>)
|
|
16
16
|
| AsyncTransactionThunk;
|
|
17
17
|
export type TransactionInput = CallArg;
|
|
18
18
|
|
|
@@ -63,38 +63,38 @@ export const Commands = {
|
|
|
63
63
|
},
|
|
64
64
|
|
|
65
65
|
TransferObjects(
|
|
66
|
-
objects: InferInput<typeof
|
|
67
|
-
address: InferInput<typeof
|
|
66
|
+
objects: InferInput<typeof ArgumentSchema>[],
|
|
67
|
+
address: InferInput<typeof ArgumentSchema>,
|
|
68
68
|
): TransactionShape<'TransferObjects'> {
|
|
69
69
|
return {
|
|
70
70
|
$kind: 'TransferObjects',
|
|
71
71
|
TransferObjects: {
|
|
72
|
-
objects: objects.map((o) => parse(
|
|
73
|
-
address: parse(
|
|
72
|
+
objects: objects.map((o) => parse(ArgumentSchema, o)),
|
|
73
|
+
address: parse(ArgumentSchema, address),
|
|
74
74
|
},
|
|
75
75
|
};
|
|
76
76
|
},
|
|
77
77
|
SplitCoins(
|
|
78
|
-
coin: InferInput<typeof
|
|
79
|
-
amounts: InferInput<typeof
|
|
78
|
+
coin: InferInput<typeof ArgumentSchema>,
|
|
79
|
+
amounts: InferInput<typeof ArgumentSchema>[],
|
|
80
80
|
): TransactionShape<'SplitCoins'> {
|
|
81
81
|
return {
|
|
82
82
|
$kind: 'SplitCoins',
|
|
83
83
|
SplitCoins: {
|
|
84
|
-
coin: parse(
|
|
85
|
-
amounts: amounts.map((o) => parse(
|
|
84
|
+
coin: parse(ArgumentSchema, coin),
|
|
85
|
+
amounts: amounts.map((o) => parse(ArgumentSchema, o)),
|
|
86
86
|
},
|
|
87
87
|
};
|
|
88
88
|
},
|
|
89
89
|
MergeCoins(
|
|
90
|
-
destination: InferInput<typeof
|
|
91
|
-
sources: InferInput<typeof
|
|
90
|
+
destination: InferInput<typeof ArgumentSchema>,
|
|
91
|
+
sources: InferInput<typeof ArgumentSchema>[],
|
|
92
92
|
): TransactionShape<'MergeCoins'> {
|
|
93
93
|
return {
|
|
94
94
|
$kind: 'MergeCoins',
|
|
95
95
|
MergeCoins: {
|
|
96
|
-
destination: parse(
|
|
97
|
-
sources: sources.map((o) => parse(
|
|
96
|
+
destination: parse(ArgumentSchema, destination),
|
|
97
|
+
sources: sources.map((o) => parse(ArgumentSchema, o)),
|
|
98
98
|
},
|
|
99
99
|
};
|
|
100
100
|
},
|
|
@@ -124,7 +124,7 @@ export const Commands = {
|
|
|
124
124
|
modules: number[][] | string[];
|
|
125
125
|
dependencies: string[];
|
|
126
126
|
package: string;
|
|
127
|
-
ticket: InferInput<typeof
|
|
127
|
+
ticket: InferInput<typeof ArgumentSchema>;
|
|
128
128
|
}): TransactionShape<'Upgrade'> {
|
|
129
129
|
return {
|
|
130
130
|
$kind: 'Upgrade',
|
|
@@ -134,7 +134,7 @@ export const Commands = {
|
|
|
134
134
|
),
|
|
135
135
|
dependencies: dependencies.map((dep) => normalizeSuiObjectId(dep)),
|
|
136
136
|
package: packageId,
|
|
137
|
-
ticket: parse(
|
|
137
|
+
ticket: parse(ArgumentSchema, ticket),
|
|
138
138
|
},
|
|
139
139
|
};
|
|
140
140
|
},
|
|
@@ -143,13 +143,13 @@ export const Commands = {
|
|
|
143
143
|
elements,
|
|
144
144
|
}: {
|
|
145
145
|
type?: string;
|
|
146
|
-
elements: InferInput<typeof
|
|
146
|
+
elements: InferInput<typeof ArgumentSchema>[];
|
|
147
147
|
}): TransactionShape<'MakeMoveVec'> {
|
|
148
148
|
return {
|
|
149
149
|
$kind: 'MakeMoveVec',
|
|
150
150
|
MakeMoveVec: {
|
|
151
151
|
type: type ?? null,
|
|
152
|
-
elements: elements.map((o) => parse(
|
|
152
|
+
elements: elements.map((o) => parse(ArgumentSchema, o)),
|
|
153
153
|
},
|
|
154
154
|
};
|
|
155
155
|
},
|
|
@@ -159,7 +159,10 @@ export const Commands = {
|
|
|
159
159
|
data = {},
|
|
160
160
|
}: {
|
|
161
161
|
name: string;
|
|
162
|
-
inputs?: Record<
|
|
162
|
+
inputs?: Record<
|
|
163
|
+
string,
|
|
164
|
+
InferInput<typeof ArgumentSchema> | InferInput<typeof ArgumentSchema>[]
|
|
165
|
+
>;
|
|
163
166
|
data?: Record<string, unknown>;
|
|
164
167
|
}): TransactionShape<'$Intent'> {
|
|
165
168
|
return {
|
|
@@ -169,7 +172,9 @@ export const Commands = {
|
|
|
169
172
|
inputs: Object.fromEntries(
|
|
170
173
|
Object.entries(inputs).map(([key, value]) => [
|
|
171
174
|
key,
|
|
172
|
-
Array.isArray(value)
|
|
175
|
+
Array.isArray(value)
|
|
176
|
+
? value.map((o) => parse(ArgumentSchema, o))
|
|
177
|
+
: parse(ArgumentSchema, value),
|
|
173
178
|
]),
|
|
174
179
|
),
|
|
175
180
|
data,
|
|
@@ -11,10 +11,15 @@ import type { SignatureWithBytes, Signer } from '../cryptography/index.js';
|
|
|
11
11
|
import { normalizeSuiAddress } from '../utils/sui-types.js';
|
|
12
12
|
import type { TransactionArgument } from './Commands.js';
|
|
13
13
|
import { Commands } from './Commands.js';
|
|
14
|
-
import type { CallArg, Command } from './data/internal.js';
|
|
15
|
-
import {
|
|
14
|
+
import type { CallArg, Command, Argument, ObjectRef } from './data/internal.js';
|
|
15
|
+
import {
|
|
16
|
+
ArgumentSchema,
|
|
17
|
+
NormalizedCallArg,
|
|
18
|
+
ObjectRefSchema,
|
|
19
|
+
TransactionExpiration,
|
|
20
|
+
} from './data/internal.js';
|
|
16
21
|
import { serializeV1TransactionData } from './data/v1.js';
|
|
17
|
-
import {
|
|
22
|
+
import { SerializedTransactionDataV2Schema } from './data/v2.js';
|
|
18
23
|
import { Inputs } from './Inputs.js';
|
|
19
24
|
import { needsTransactionResolution, resolveTransactionPlugin } from './resolve.js';
|
|
20
25
|
import type {
|
|
@@ -29,8 +34,10 @@ import { getIdFromCallArg } from './utils.js';
|
|
|
29
34
|
import { namedPackagesPlugin } from './plugins/NamedPackagesPlugin.js';
|
|
30
35
|
|
|
31
36
|
export type TransactionObjectArgument =
|
|
32
|
-
| Exclude<InferInput<typeof
|
|
33
|
-
| ((
|
|
37
|
+
| Exclude<InferInput<typeof ArgumentSchema>, { Input: unknown; type?: 'pure' }>
|
|
38
|
+
| ((
|
|
39
|
+
tx: Transaction,
|
|
40
|
+
) => Exclude<InferInput<typeof ArgumentSchema>, { Input: unknown; type?: 'pure' }>)
|
|
34
41
|
| AsyncTransactionThunk<TransactionResultArgument>;
|
|
35
42
|
|
|
36
43
|
export type TransactionResult = Extract<Argument, { Result: unknown }> &
|
|
@@ -290,7 +297,7 @@ export class Transaction {
|
|
|
290
297
|
this.#data.gasConfig.owner = owner;
|
|
291
298
|
}
|
|
292
299
|
setGasPayment(payments: ObjectRef[]) {
|
|
293
|
-
this.#data.gasConfig.payment = payments.map((payment) => parse(
|
|
300
|
+
this.#data.gasConfig.payment = payments.map((payment) => parse(ObjectRefSchema, payment));
|
|
294
301
|
}
|
|
295
302
|
|
|
296
303
|
#data: TransactionDataBuilder;
|
|
@@ -363,7 +370,7 @@ export class Transaction {
|
|
|
363
370
|
return this.object(this.add(value as (tx: Transaction) => TransactionObjectArgument));
|
|
364
371
|
}
|
|
365
372
|
|
|
366
|
-
if (typeof value === 'object' && is(
|
|
373
|
+
if (typeof value === 'object' && is(ArgumentSchema, value)) {
|
|
367
374
|
return value as { $kind: 'Input'; Input: number; type?: 'object' };
|
|
368
375
|
}
|
|
369
376
|
|
|
@@ -538,10 +545,10 @@ export class Transaction {
|
|
|
538
545
|
return this.#resolveArgument(resolved);
|
|
539
546
|
}
|
|
540
547
|
|
|
541
|
-
return parse(
|
|
548
|
+
return parse(ArgumentSchema, resolved);
|
|
542
549
|
}
|
|
543
550
|
|
|
544
|
-
return parse(
|
|
551
|
+
return parse(ArgumentSchema, arg);
|
|
545
552
|
}
|
|
546
553
|
|
|
547
554
|
// Method shorthands:
|
|
@@ -668,7 +675,7 @@ export class Transaction {
|
|
|
668
675
|
const fullyResolved = this.isFullyResolved();
|
|
669
676
|
return JSON.stringify(
|
|
670
677
|
parse(
|
|
671
|
-
|
|
678
|
+
SerializedTransactionDataV2Schema,
|
|
672
679
|
fullyResolved
|
|
673
680
|
? {
|
|
674
681
|
...this.#data.snapshot(),
|
|
@@ -720,7 +727,7 @@ export class Transaction {
|
|
|
720
727
|
}
|
|
721
728
|
|
|
722
729
|
/** Build the transaction to BCS bytes. */
|
|
723
|
-
async build(options: BuildTransactionOptions = {}): Promise<Uint8Array
|
|
730
|
+
async build(options: BuildTransactionOptions = {}): Promise<Uint8Array<ArrayBuffer>> {
|
|
724
731
|
await this.prepareForSerialization(options);
|
|
725
732
|
await this.#prepareBuild(options);
|
|
726
733
|
return this.#data.build({
|
|
@@ -13,11 +13,12 @@ import type {
|
|
|
13
13
|
Command,
|
|
14
14
|
GasData,
|
|
15
15
|
TransactionExpiration,
|
|
16
|
+
TransactionData,
|
|
16
17
|
} from './data/internal.js';
|
|
17
|
-
import {
|
|
18
|
+
import { TransactionDataSchema } from './data/internal.js';
|
|
18
19
|
import { transactionDataFromV1 } from './data/v1.js';
|
|
19
20
|
import type { SerializedTransactionDataV1 } from './data/v1.js';
|
|
20
|
-
import type {
|
|
21
|
+
import type { SerializedTransactionDataV2Schema } from './data/v2.js';
|
|
21
22
|
import { hashTypedData } from './hash.js';
|
|
22
23
|
|
|
23
24
|
function prepareSuiAddress(address: string) {
|
|
@@ -69,13 +70,13 @@ export class TransactionDataBuilder implements TransactionData {
|
|
|
69
70
|
|
|
70
71
|
static restore(
|
|
71
72
|
data:
|
|
72
|
-
| InferInput<typeof
|
|
73
|
+
| InferInput<typeof SerializedTransactionDataV2Schema>
|
|
73
74
|
| InferInput<typeof SerializedTransactionDataV1>,
|
|
74
75
|
) {
|
|
75
76
|
if (data.version === 2) {
|
|
76
|
-
return new TransactionDataBuilder(parse(
|
|
77
|
+
return new TransactionDataBuilder(parse(TransactionDataSchema, data));
|
|
77
78
|
} else {
|
|
78
|
-
return new TransactionDataBuilder(parse(
|
|
79
|
+
return new TransactionDataBuilder(parse(TransactionDataSchema, transactionDataFromV1(data)));
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
|
|
@@ -320,7 +321,7 @@ export class TransactionDataBuilder implements TransactionData {
|
|
|
320
321
|
}
|
|
321
322
|
|
|
322
323
|
snapshot(): TransactionData {
|
|
323
|
-
return parse(
|
|
324
|
+
return parse(TransactionDataSchema, this);
|
|
324
325
|
}
|
|
325
326
|
|
|
326
327
|
shallowClone() {
|