@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
|
@@ -73,15 +73,15 @@ export const JsonU64 = pipe(
|
|
|
73
73
|
);
|
|
74
74
|
// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/crates/sui-types/src/base_types.rs#L138
|
|
75
75
|
// Implemented as a tuple in rust
|
|
76
|
-
export const
|
|
76
|
+
export const ObjectRefSchema = object({
|
|
77
77
|
objectId: SuiAddress,
|
|
78
78
|
version: JsonU64,
|
|
79
79
|
digest: string(),
|
|
80
80
|
});
|
|
81
|
-
export type ObjectRef = InferOutput<typeof
|
|
81
|
+
export type ObjectRef = InferOutput<typeof ObjectRefSchema>;
|
|
82
82
|
|
|
83
83
|
// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/crates/sui-types/src/transaction.rs#L690-L702
|
|
84
|
-
export const
|
|
84
|
+
export const ArgumentSchema = pipe(
|
|
85
85
|
union([
|
|
86
86
|
object({ GasCoin: literal(true) }),
|
|
87
87
|
object({ Input: pipe(number(), integer()), type: optional(literal('pure')) }),
|
|
@@ -108,26 +108,26 @@ export const Argument = pipe(
|
|
|
108
108
|
| { $kind: 'NestedResult'; NestedResult: [number, number] }
|
|
109
109
|
>;
|
|
110
110
|
|
|
111
|
-
export type Argument = InferOutput<typeof
|
|
111
|
+
export type Argument = InferOutput<typeof ArgumentSchema>;
|
|
112
112
|
|
|
113
113
|
// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/crates/sui-types/src/transaction.rs#L1387-L1392
|
|
114
|
-
export const
|
|
114
|
+
export const GasDataSchema = object({
|
|
115
115
|
budget: nullable(JsonU64),
|
|
116
116
|
price: nullable(JsonU64),
|
|
117
117
|
owner: nullable(SuiAddress),
|
|
118
|
-
payment: nullable(array(
|
|
118
|
+
payment: nullable(array(ObjectRefSchema)),
|
|
119
119
|
});
|
|
120
|
-
export type GasData = InferOutput<typeof
|
|
120
|
+
export type GasData = InferOutput<typeof GasDataSchema>;
|
|
121
121
|
|
|
122
122
|
// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/external-crates/move/crates/move-core-types/src/language_storage.rs#L140-L147
|
|
123
|
-
export const
|
|
123
|
+
export const StructTagSchema = object({
|
|
124
124
|
address: string(),
|
|
125
125
|
module: string(),
|
|
126
126
|
name: string(),
|
|
127
127
|
// type_params in rust, should be updated to use camelCase
|
|
128
128
|
typeParams: array(string()),
|
|
129
129
|
});
|
|
130
|
-
export type StructTag = InferOutput<typeof
|
|
130
|
+
export type StructTag = InferOutput<typeof StructTagSchema>;
|
|
131
131
|
|
|
132
132
|
// https://github.com/MystenLabs/sui/blob/cea8742e810142a8145fd83c4c142d61e561004a/crates/sui-graphql-rpc/schema/current_progress_schema.graphql#L1614-L1627
|
|
133
133
|
export type OpenMoveTypeSignatureBody =
|
|
@@ -150,7 +150,7 @@ export type OpenMoveTypeSignatureBody =
|
|
|
150
150
|
}
|
|
151
151
|
| { typeParameter: number };
|
|
152
152
|
|
|
153
|
-
export const
|
|
153
|
+
export const OpenMoveTypeSignatureBodySchema: GenericSchema<OpenMoveTypeSignatureBody> = union([
|
|
154
154
|
literal('address'),
|
|
155
155
|
literal('bool'),
|
|
156
156
|
literal('u8'),
|
|
@@ -159,57 +159,57 @@ export const OpenMoveTypeSignatureBody: GenericSchema<OpenMoveTypeSignatureBody>
|
|
|
159
159
|
literal('u64'),
|
|
160
160
|
literal('u128'),
|
|
161
161
|
literal('u256'),
|
|
162
|
-
object({ vector: lazy(() =>
|
|
162
|
+
object({ vector: lazy(() => OpenMoveTypeSignatureBodySchema) }),
|
|
163
163
|
object({
|
|
164
164
|
datatype: object({
|
|
165
165
|
package: string(),
|
|
166
166
|
module: string(),
|
|
167
167
|
type: string(),
|
|
168
|
-
typeParameters: array(lazy(() =>
|
|
168
|
+
typeParameters: array(lazy(() => OpenMoveTypeSignatureBodySchema)),
|
|
169
169
|
}),
|
|
170
170
|
}),
|
|
171
171
|
object({ typeParameter: pipe(number(), integer()) }),
|
|
172
172
|
]);
|
|
173
173
|
|
|
174
174
|
// https://github.com/MystenLabs/sui/blob/cea8742e810142a8145fd83c4c142d61e561004a/crates/sui-graphql-rpc/schema/current_progress_schema.graphql#L1609-L1612
|
|
175
|
-
export const
|
|
175
|
+
export const OpenMoveTypeSignatureSchema = object({
|
|
176
176
|
ref: nullable(union([literal('&'), literal('&mut')])),
|
|
177
|
-
body:
|
|
177
|
+
body: OpenMoveTypeSignatureBodySchema,
|
|
178
178
|
});
|
|
179
|
-
export type OpenMoveTypeSignature = InferOutput<typeof
|
|
179
|
+
export type OpenMoveTypeSignature = InferOutput<typeof OpenMoveTypeSignatureSchema>;
|
|
180
180
|
|
|
181
181
|
// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/crates/sui-types/src/transaction.rs#L707-L718
|
|
182
|
-
const
|
|
182
|
+
const ProgrammableMoveCallSchema = object({
|
|
183
183
|
package: ObjectID,
|
|
184
184
|
module: string(),
|
|
185
185
|
function: string(),
|
|
186
186
|
// snake case in rust
|
|
187
187
|
typeArguments: array(string()),
|
|
188
|
-
arguments: array(
|
|
189
|
-
_argumentTypes: optional(nullable(array(
|
|
188
|
+
arguments: array(ArgumentSchema),
|
|
189
|
+
_argumentTypes: optional(nullable(array(OpenMoveTypeSignatureSchema))),
|
|
190
190
|
});
|
|
191
|
-
export type ProgrammableMoveCall = InferOutput<typeof
|
|
191
|
+
export type ProgrammableMoveCall = InferOutput<typeof ProgrammableMoveCallSchema>;
|
|
192
192
|
|
|
193
193
|
export const $Intent = object({
|
|
194
194
|
name: string(),
|
|
195
|
-
inputs: record(string(), union([
|
|
195
|
+
inputs: record(string(), union([ArgumentSchema, array(ArgumentSchema)])),
|
|
196
196
|
data: record(string(), unknown()),
|
|
197
197
|
});
|
|
198
198
|
|
|
199
199
|
// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/crates/sui-types/src/transaction.rs#L657-L685
|
|
200
|
-
export const
|
|
201
|
-
MoveCall:
|
|
200
|
+
export const CommandSchema = safeEnum({
|
|
201
|
+
MoveCall: ProgrammableMoveCallSchema,
|
|
202
202
|
TransferObjects: object({
|
|
203
|
-
objects: array(
|
|
204
|
-
address:
|
|
203
|
+
objects: array(ArgumentSchema),
|
|
204
|
+
address: ArgumentSchema,
|
|
205
205
|
}),
|
|
206
206
|
SplitCoins: object({
|
|
207
|
-
coin:
|
|
208
|
-
amounts: array(
|
|
207
|
+
coin: ArgumentSchema,
|
|
208
|
+
amounts: array(ArgumentSchema),
|
|
209
209
|
}),
|
|
210
210
|
MergeCoins: object({
|
|
211
|
-
destination:
|
|
212
|
-
sources: array(
|
|
211
|
+
destination: ArgumentSchema,
|
|
212
|
+
sources: array(ArgumentSchema),
|
|
213
213
|
}),
|
|
214
214
|
Publish: object({
|
|
215
215
|
modules: array(BCSBytes),
|
|
@@ -217,13 +217,13 @@ export const Command = safeEnum({
|
|
|
217
217
|
}),
|
|
218
218
|
MakeMoveVec: object({
|
|
219
219
|
type: nullable(string()),
|
|
220
|
-
elements: array(
|
|
220
|
+
elements: array(ArgumentSchema),
|
|
221
221
|
}),
|
|
222
222
|
Upgrade: object({
|
|
223
223
|
modules: array(BCSBytes),
|
|
224
224
|
dependencies: array(ObjectID),
|
|
225
225
|
package: ObjectID,
|
|
226
|
-
ticket:
|
|
226
|
+
ticket: ArgumentSchema,
|
|
227
227
|
}),
|
|
228
228
|
$Intent,
|
|
229
229
|
});
|
|
@@ -271,20 +271,20 @@ export type Command<Arg = Argument> = EnumOutputShape<{
|
|
|
271
271
|
}>;
|
|
272
272
|
|
|
273
273
|
// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/crates/sui-types/src/transaction.rs#L102-L114
|
|
274
|
-
export const
|
|
275
|
-
ImmOrOwnedObject:
|
|
274
|
+
export const ObjectArgSchema = safeEnum({
|
|
275
|
+
ImmOrOwnedObject: ObjectRefSchema,
|
|
276
276
|
SharedObject: object({
|
|
277
277
|
objectId: ObjectID,
|
|
278
278
|
// snake case in rust
|
|
279
279
|
initialSharedVersion: JsonU64,
|
|
280
280
|
mutable: boolean(),
|
|
281
281
|
}),
|
|
282
|
-
Receiving:
|
|
282
|
+
Receiving: ObjectRefSchema,
|
|
283
283
|
});
|
|
284
284
|
|
|
285
285
|
// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/crates/sui-types/src/transaction.rs#L75-L80
|
|
286
|
-
const
|
|
287
|
-
Object:
|
|
286
|
+
const CallArgSchema = safeEnum({
|
|
287
|
+
Object: ObjectArgSchema,
|
|
288
288
|
Pure: object({
|
|
289
289
|
bytes: BCSBytes,
|
|
290
290
|
}),
|
|
@@ -296,12 +296,13 @@ const CallArg = safeEnum({
|
|
|
296
296
|
version: optional(nullable(JsonU64)),
|
|
297
297
|
digest: optional(nullable(string())),
|
|
298
298
|
initialSharedVersion: optional(nullable(JsonU64)),
|
|
299
|
+
mutable: optional(nullable(boolean())),
|
|
299
300
|
}),
|
|
300
301
|
});
|
|
301
|
-
export type CallArg = InferOutput<typeof
|
|
302
|
+
export type CallArg = InferOutput<typeof CallArgSchema>;
|
|
302
303
|
|
|
303
304
|
export const NormalizedCallArg = safeEnum({
|
|
304
|
-
Object:
|
|
305
|
+
Object: ObjectArgSchema,
|
|
305
306
|
Pure: object({
|
|
306
307
|
bytes: BCSBytes,
|
|
307
308
|
}),
|
|
@@ -314,12 +315,13 @@ export const TransactionExpiration = safeEnum({
|
|
|
314
315
|
|
|
315
316
|
export type TransactionExpiration = InferOutput<typeof TransactionExpiration>;
|
|
316
317
|
|
|
317
|
-
export const
|
|
318
|
+
export const TransactionDataSchema = object({
|
|
318
319
|
version: literal(2),
|
|
319
320
|
sender: nullish(SuiAddress),
|
|
320
321
|
expiration: nullish(TransactionExpiration),
|
|
321
|
-
gasData:
|
|
322
|
-
inputs: array(
|
|
323
|
-
commands: array(
|
|
322
|
+
gasData: GasDataSchema,
|
|
323
|
+
inputs: array(CallArgSchema),
|
|
324
|
+
commands: array(CommandSchema),
|
|
324
325
|
});
|
|
325
|
-
|
|
326
|
+
|
|
327
|
+
export type TransactionData = InferOutput<typeof TransactionDataSchema>;
|
|
@@ -26,8 +26,8 @@ import {
|
|
|
26
26
|
|
|
27
27
|
import { TypeTagSerializer } from '../../bcs/index.js';
|
|
28
28
|
import type { StructTag as StructTagType, TypeTag as TypeTagType } from '../../bcs/types.js';
|
|
29
|
-
import { JsonU64, ObjectID, safeEnum,
|
|
30
|
-
import type { Argument } from './internal.js';
|
|
29
|
+
import { JsonU64, ObjectID, safeEnum, TransactionDataSchema } from './internal.js';
|
|
30
|
+
import type { Argument, ArgumentSchema, TransactionData } from './internal.js';
|
|
31
31
|
|
|
32
32
|
export const ObjectRef = object({
|
|
33
33
|
digest: string(),
|
|
@@ -370,7 +370,7 @@ function convertTransactionArgument(
|
|
|
370
370
|
}
|
|
371
371
|
|
|
372
372
|
export function transactionDataFromV1(data: SerializedTransactionDataV1): TransactionData {
|
|
373
|
-
return parse(
|
|
373
|
+
return parse(TransactionDataSchema, {
|
|
374
374
|
version: 2,
|
|
375
375
|
sender: data.sender ?? null,
|
|
376
376
|
expiration: data.expiration
|
|
@@ -526,12 +526,12 @@ export function transactionDataFromV1(data: SerializedTransactionDataV1): Transa
|
|
|
526
526
|
|
|
527
527
|
throw new Error(`Unknown transaction ${Object.keys(transaction)}`);
|
|
528
528
|
}),
|
|
529
|
-
} satisfies InferInput<typeof
|
|
529
|
+
} satisfies InferInput<typeof TransactionDataSchema>);
|
|
530
530
|
}
|
|
531
531
|
|
|
532
532
|
function parseV1TransactionArgument(
|
|
533
533
|
arg: InferOutput<typeof TransactionArgument>,
|
|
534
|
-
): InferInput<typeof
|
|
534
|
+
): InferInput<typeof ArgumentSchema> {
|
|
535
535
|
switch (arg.kind) {
|
|
536
536
|
case 'GasCoin': {
|
|
537
537
|
return { GasCoin: true };
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
unknown,
|
|
22
22
|
} from 'valibot';
|
|
23
23
|
|
|
24
|
-
import { BCSBytes, JsonU64, ObjectID,
|
|
24
|
+
import { BCSBytes, JsonU64, ObjectID, ObjectRefSchema, SuiAddress } from './internal.js';
|
|
25
25
|
import type { Simplify } from '@mysten/utils';
|
|
26
26
|
|
|
27
27
|
function enumUnion<T extends Record<string, GenericSchema<any>>>(options: T) {
|
|
@@ -49,7 +49,7 @@ const GasData = object({
|
|
|
49
49
|
budget: nullable(JsonU64),
|
|
50
50
|
price: nullable(JsonU64),
|
|
51
51
|
owner: nullable(SuiAddress),
|
|
52
|
-
payment: nullable(array(
|
|
52
|
+
payment: nullable(array(ObjectRefSchema)),
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/crates/sui-types/src/transaction.rs#L707-L718
|
|
@@ -102,14 +102,14 @@ const Command = enumUnion({
|
|
|
102
102
|
|
|
103
103
|
// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/crates/sui-types/src/transaction.rs#L102-L114
|
|
104
104
|
const ObjectArg = enumUnion({
|
|
105
|
-
ImmOrOwnedObject:
|
|
105
|
+
ImmOrOwnedObject: ObjectRefSchema,
|
|
106
106
|
SharedObject: object({
|
|
107
107
|
objectId: ObjectID,
|
|
108
108
|
// snake case in rust
|
|
109
109
|
initialSharedVersion: JsonU64,
|
|
110
110
|
mutable: boolean(),
|
|
111
111
|
}),
|
|
112
|
-
Receiving:
|
|
112
|
+
Receiving: ObjectRefSchema,
|
|
113
113
|
});
|
|
114
114
|
|
|
115
115
|
// https://github.com/MystenLabs/sui/blob/df41d5fa8127634ff4285671a01ead00e519f806/crates/sui-types/src/transaction.rs#L75-L80
|
|
@@ -126,6 +126,7 @@ const CallArg = enumUnion({
|
|
|
126
126
|
version: optional(nullable(JsonU64)),
|
|
127
127
|
digest: optional(nullable(string())),
|
|
128
128
|
initialSharedVersion: optional(nullable(JsonU64)),
|
|
129
|
+
mutable: optional(nullable(boolean())),
|
|
129
130
|
}),
|
|
130
131
|
});
|
|
131
132
|
|
|
@@ -134,7 +135,7 @@ const TransactionExpiration = enumUnion({
|
|
|
134
135
|
Epoch: JsonU64,
|
|
135
136
|
});
|
|
136
137
|
|
|
137
|
-
export const
|
|
138
|
+
export const SerializedTransactionDataV2Schema = object({
|
|
138
139
|
version: literal(2),
|
|
139
140
|
sender: nullish(SuiAddress),
|
|
140
141
|
expiration: nullish(TransactionExpiration),
|
|
@@ -144,4 +145,4 @@ export const SerializedTransactionDataV2 = object({
|
|
|
144
145
|
digest: optional(nullable(string())),
|
|
145
146
|
});
|
|
146
147
|
|
|
147
|
-
export type SerializedTransactionDataV2 = InferOutput<typeof
|
|
148
|
+
export type SerializedTransactionDataV2 = InferOutput<typeof SerializedTransactionDataV2Schema>;
|
|
@@ -39,31 +39,19 @@ export function createObjectMethods<T>(makeObject: (value: TransactionObjectInpu
|
|
|
39
39
|
}),
|
|
40
40
|
);
|
|
41
41
|
object.random = () =>
|
|
42
|
-
object(
|
|
43
|
-
|
|
42
|
+
object({
|
|
43
|
+
$kind: 'UnresolvedObject',
|
|
44
|
+
UnresolvedObject: {
|
|
44
45
|
objectId: '0x8',
|
|
45
|
-
initialSharedVersion: 1,
|
|
46
46
|
mutable: false,
|
|
47
|
-
}
|
|
48
|
-
);
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
49
|
object.denyList = (options?: { mutable?: boolean }) => {
|
|
50
|
-
const mutable = options?.mutable;
|
|
51
|
-
|
|
52
|
-
if (mutable !== undefined) {
|
|
53
|
-
return object(
|
|
54
|
-
Inputs.SharedObjectRef({
|
|
55
|
-
objectId: '0x403',
|
|
56
|
-
initialSharedVersion: 1,
|
|
57
|
-
mutable,
|
|
58
|
-
}),
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
50
|
return object({
|
|
63
51
|
$kind: 'UnresolvedObject',
|
|
64
52
|
UnresolvedObject: {
|
|
65
53
|
objectId: '0x403',
|
|
66
|
-
|
|
54
|
+
mutable: options?.mutable,
|
|
67
55
|
},
|
|
68
56
|
});
|
|
69
57
|
};
|
|
@@ -5,8 +5,8 @@ import { is } from 'valibot';
|
|
|
5
5
|
|
|
6
6
|
import type { SuiMoveNormalizedType } from '../client/index.js';
|
|
7
7
|
import { normalizeSuiAddress } from '../utils/sui-types.js';
|
|
8
|
-
import {
|
|
9
|
-
import type { CallArg } from './data/internal.js';
|
|
8
|
+
import { ArgumentSchema } from './data/internal.js';
|
|
9
|
+
import type { Argument, CallArg } from './data/internal.js';
|
|
10
10
|
|
|
11
11
|
export function extractMutableReference(
|
|
12
12
|
normalizedType: SuiMoveNormalizedType,
|
|
@@ -69,5 +69,5 @@ export function getIdFromCallArg(arg: string | CallArg) {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
export function isArgument(value: unknown): value is Argument {
|
|
72
|
-
return is(
|
|
72
|
+
return is(ArgumentSchema, value);
|
|
73
73
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { TypeTag } from '../bcs/bcs.js';
|
|
5
|
+
import { TypeTagSerializer } from '../bcs/type-tag-serializer.js';
|
|
6
|
+
import { deriveDynamicFieldID } from './dynamic-fields.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Derive the ID of an object that has been created through `derived_object`.
|
|
10
|
+
*/
|
|
11
|
+
export function deriveObjectID(
|
|
12
|
+
parentId: string,
|
|
13
|
+
typeTag: typeof TypeTag.$inferInput,
|
|
14
|
+
key: Uint8Array,
|
|
15
|
+
) {
|
|
16
|
+
const typeTagStr = typeof typeTag === 'string' ? typeTag : TypeTagSerializer.tagToString(typeTag);
|
|
17
|
+
return deriveDynamicFieldID(
|
|
18
|
+
parentId,
|
|
19
|
+
`0x2::derived_object::DerivedObjectKey<${typeTagStr}>`,
|
|
20
|
+
key,
|
|
21
|
+
);
|
|
22
|
+
}
|
package/src/utils/index.ts
CHANGED
package/src/version.ts
CHANGED
package/src/zklogin/publickey.ts
CHANGED
|
@@ -27,7 +27,7 @@ export interface ZkLoginCompatibleClient
|
|
|
27
27
|
* A zkLogin public identifier
|
|
28
28
|
*/
|
|
29
29
|
export class ZkLoginPublicIdentifier extends PublicKey {
|
|
30
|
-
#data: Uint8Array
|
|
30
|
+
#data: Uint8Array<ArrayBuffer>;
|
|
31
31
|
#client?: ZkLoginCompatibleClient;
|
|
32
32
|
#legacyAddress: boolean;
|
|
33
33
|
|
|
@@ -43,7 +43,7 @@ export class ZkLoginPublicIdentifier extends PublicKey {
|
|
|
43
43
|
if (typeof value === 'string') {
|
|
44
44
|
this.#data = fromBase64(value);
|
|
45
45
|
} else if (value instanceof Uint8Array) {
|
|
46
|
-
this.#data = value
|
|
46
|
+
this.#data = value as Uint8Array<ArrayBuffer>;
|
|
47
47
|
} else {
|
|
48
48
|
this.#data = Uint8Array.from(value);
|
|
49
49
|
}
|
|
@@ -146,7 +146,7 @@ export class ZkLoginPublicIdentifier extends PublicKey {
|
|
|
146
146
|
/**
|
|
147
147
|
* Return the byte array representation of the zkLogin public identifier
|
|
148
148
|
*/
|
|
149
|
-
toRawBytes(): Uint8Array {
|
|
149
|
+
toRawBytes(): Uint8Array<ArrayBuffer> {
|
|
150
150
|
return this.#data;
|
|
151
151
|
}
|
|
152
152
|
|