@mysten/sui 2.27.1 → 2.28.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 +14 -0
- package/dist/bcs/bcs.d.mts +6 -6
- package/dist/bcs/bcs.d.mts.map +1 -1
- package/dist/bcs/bcs.mjs +29 -2
- package/dist/bcs/bcs.mjs.map +1 -1
- package/dist/bcs/effects.mjs +2 -1
- package/dist/bcs/effects.mjs.map +1 -1
- package/dist/bcs/index.d.mts +137 -41
- package/dist/bcs/index.d.mts.map +1 -1
- package/dist/bcs/transactions.mjs +2 -1
- package/dist/bcs/transactions.mjs.map +1 -1
- package/dist/client/transaction-resolver.mjs +45 -9
- package/dist/client/transaction-resolver.mjs.map +1 -1
- package/dist/cryptography/signature.d.mts +14 -14
- package/dist/grpc/proto/sui/forking/v1alpha/forking_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/execution_status.d.mts +9 -1
- package/dist/grpc/proto/sui/rpc/v2/execution_status.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/execution_status.mjs +8 -0
- package/dist/grpc/proto/sui/rpc/v2/execution_status.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
- 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/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 +50 -2
- package/dist/grpc/proto/sui/rpc/v2/transaction.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction.mjs +36 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction.mjs.map +1 -1
- package/dist/grpc/proto/types.d.mts +2 -2
- package/dist/grpc/proto/types.mjs +2 -1
- package/dist/transactions/Transaction.d.mts +21 -9
- package/dist/transactions/Transaction.d.mts.map +1 -1
- package/dist/transactions/data/internal.d.mts +133 -109
- package/dist/transactions/data/internal.d.mts.map +1 -1
- package/dist/transactions/data/internal.mjs +11 -2
- package/dist/transactions/data/internal.mjs.map +1 -1
- package/dist/transactions/data/v1.d.mts +242 -220
- package/dist/transactions/data/v1.d.mts.map +1 -1
- package/dist/transactions/data/v1.mjs +27 -4
- package/dist/transactions/data/v1.mjs.map +1 -1
- package/dist/transactions/data/v2.d.mts +28 -16
- package/dist/transactions/data/v2.d.mts.map +1 -1
- package/dist/transactions/data/v2.mjs +3 -2
- package/dist/transactions/data/v2.mjs.map +1 -1
- package/dist/version.mjs +1 -1
- package/dist/version.mjs.map +1 -1
- package/dist/zklogin/bcs.d.mts +14 -14
- package/package.json +1 -1
- package/src/bcs/bcs.ts +45 -0
- package/src/bcs/effects.ts +3 -0
- package/src/bcs/transactions.ts +1 -0
- package/src/bcs/types.ts +10 -1
- package/src/client/transaction-resolver.ts +79 -9
- package/src/grpc/proto/sui/rpc/v2/execution_status.ts +8 -0
- package/src/grpc/proto/sui/rpc/v2/transaction.ts +68 -0
- package/src/transactions/data/internal.ts +19 -0
- package/src/transactions/data/v1.ts +51 -12
- package/src/transactions/data/v2.ts +2 -0
- package/src/version.ts +1 -1
|
@@ -145,6 +145,13 @@ export interface TransactionExpiration {
|
|
|
145
145
|
* @generated from protobuf field: optional uint32 nonce = 7;
|
|
146
146
|
*/
|
|
147
147
|
nonce?: number;
|
|
148
|
+
/**
|
|
149
|
+
* The validators allowed to propose this transaction in consensus. Only set when `kind`
|
|
150
|
+
* is `VALIDITY`. Leave unset to let any validator propose the transaction.
|
|
151
|
+
*
|
|
152
|
+
* @generated from protobuf field: optional sui.rpc.v2.AllowedProposers allowed_proposers = 8;
|
|
153
|
+
*/
|
|
154
|
+
allowedProposers?: AllowedProposers;
|
|
148
155
|
}
|
|
149
156
|
/**
|
|
150
157
|
* @generated from protobuf enum sui.rpc.v2.TransactionExpiration.TransactionExpirationKind
|
|
@@ -181,6 +188,40 @@ export enum TransactionExpiration_TransactionExpirationKind {
|
|
|
181
188
|
* @generated from protobuf enum value: VALID_DURING = 3;
|
|
182
189
|
*/
|
|
183
190
|
VALID_DURING = 3,
|
|
191
|
+
/**
|
|
192
|
+
* Everything in VALID_DURING, plus a restriction on which validators may
|
|
193
|
+
* propose the transaction in consensus.
|
|
194
|
+
*
|
|
195
|
+
* @generated from protobuf enum value: VALIDITY = 4;
|
|
196
|
+
*/
|
|
197
|
+
VALIDITY = 4,
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* The validators allowed to propose a transaction in consensus.
|
|
201
|
+
*
|
|
202
|
+
* Proposal by any other validator is byzantine behavior and invalidates the whole block.
|
|
203
|
+
*
|
|
204
|
+
* @generated from protobuf message sui.rpc.v2.AllowedProposers
|
|
205
|
+
*/
|
|
206
|
+
export interface AllowedProposers {
|
|
207
|
+
/**
|
|
208
|
+
* The epoch whose committee `proposers` indexes into.
|
|
209
|
+
*
|
|
210
|
+
* Committee indices are only meaningful against one committee, so a set recorded for any
|
|
211
|
+
* other epoch is ignored and the transaction is treated as naming no proposers.
|
|
212
|
+
*
|
|
213
|
+
* @generated from protobuf field: optional uint64 epoch = 1;
|
|
214
|
+
*/
|
|
215
|
+
epoch?: bigint;
|
|
216
|
+
/**
|
|
217
|
+
* Committee indices of the allowed proposers, strictly increasing and non-empty.
|
|
218
|
+
*
|
|
219
|
+
* An empty list names no validator and is rejected; omit `allowed_proposers` entirely to
|
|
220
|
+
* let any validator propose the transaction.
|
|
221
|
+
*
|
|
222
|
+
* @generated from protobuf field: repeated uint32 proposers = 2;
|
|
223
|
+
*/
|
|
224
|
+
proposers: number[];
|
|
184
225
|
}
|
|
185
226
|
/**
|
|
186
227
|
* Transaction type.
|
|
@@ -1314,6 +1355,7 @@ class TransactionExpiration$Type extends MessageType<TransactionExpiration> {
|
|
|
1314
1355
|
{ no: 5, name: 'max_timestamp', kind: 'message', T: () => Timestamp },
|
|
1315
1356
|
{ no: 6, name: 'chain', kind: 'scalar', opt: true, T: 9 /*ScalarType.STRING*/ },
|
|
1316
1357
|
{ no: 7, name: 'nonce', kind: 'scalar', opt: true, T: 13 /*ScalarType.UINT32*/ },
|
|
1358
|
+
{ no: 8, name: 'allowed_proposers', kind: 'message', T: () => AllowedProposers },
|
|
1317
1359
|
]);
|
|
1318
1360
|
}
|
|
1319
1361
|
}
|
|
@@ -1322,6 +1364,32 @@ class TransactionExpiration$Type extends MessageType<TransactionExpiration> {
|
|
|
1322
1364
|
*/
|
|
1323
1365
|
export const TransactionExpiration = new TransactionExpiration$Type();
|
|
1324
1366
|
// @generated message type with reflection information, may provide speed optimized methods
|
|
1367
|
+
class AllowedProposers$Type extends MessageType<AllowedProposers> {
|
|
1368
|
+
constructor() {
|
|
1369
|
+
super('sui.rpc.v2.AllowedProposers', [
|
|
1370
|
+
{
|
|
1371
|
+
no: 1,
|
|
1372
|
+
name: 'epoch',
|
|
1373
|
+
kind: 'scalar',
|
|
1374
|
+
opt: true,
|
|
1375
|
+
T: 4 /*ScalarType.UINT64*/,
|
|
1376
|
+
L: 0 /*LongType.BIGINT*/,
|
|
1377
|
+
},
|
|
1378
|
+
{
|
|
1379
|
+
no: 2,
|
|
1380
|
+
name: 'proposers',
|
|
1381
|
+
kind: 'scalar',
|
|
1382
|
+
repeat: 1 /*RepeatType.PACKED*/,
|
|
1383
|
+
T: 13 /*ScalarType.UINT32*/,
|
|
1384
|
+
},
|
|
1385
|
+
]);
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
/**
|
|
1389
|
+
* @generated MessageType for protobuf message sui.rpc.v2.AllowedProposers
|
|
1390
|
+
*/
|
|
1391
|
+
export const AllowedProposers = new AllowedProposers$Type();
|
|
1392
|
+
// @generated message type with reflection information, may provide speed optimized methods
|
|
1325
1393
|
class TransactionKind$Type extends MessageType<TransactionKind> {
|
|
1326
1394
|
constructor() {
|
|
1327
1395
|
super('sui.rpc.v2.TransactionKind', [
|
|
@@ -343,10 +343,29 @@ export const ValidDuringSchema = object({
|
|
|
343
343
|
});
|
|
344
344
|
export type ValidDuring = InferOutput<typeof ValidDuringSchema>;
|
|
345
345
|
|
|
346
|
+
// Rust: crates/sui-types/src/transaction.rs
|
|
347
|
+
export const AllowedProposersSchema = object({
|
|
348
|
+
epoch: JsonU64,
|
|
349
|
+
// Shared by `setExpiration` and `restore`, so this can only carry the invariant true on both.
|
|
350
|
+
proposers: pipe(
|
|
351
|
+
array(U32),
|
|
352
|
+
check((proposers) => proposers.length > 0, 'Allowed proposers must not be empty'),
|
|
353
|
+
),
|
|
354
|
+
});
|
|
355
|
+
export type AllowedProposers = InferOutput<typeof AllowedProposersSchema>;
|
|
356
|
+
|
|
357
|
+
// Rust: crates/sui-types/src/transaction.rs
|
|
358
|
+
export const ValiditySchema = object({
|
|
359
|
+
...ValidDuringSchema.entries,
|
|
360
|
+
allowedProposers: nullable(AllowedProposersSchema),
|
|
361
|
+
});
|
|
362
|
+
export type Validity = InferOutput<typeof ValiditySchema>;
|
|
363
|
+
|
|
346
364
|
export const TransactionExpiration = safeEnum({
|
|
347
365
|
None: literal(true),
|
|
348
366
|
Epoch: JsonU64,
|
|
349
367
|
ValidDuring: ValidDuringSchema,
|
|
368
|
+
Validity: ValiditySchema,
|
|
350
369
|
});
|
|
351
370
|
|
|
352
371
|
export type TransactionExpiration = InferOutput<typeof TransactionExpiration>;
|
|
@@ -26,7 +26,14 @@ 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 {
|
|
29
|
+
import {
|
|
30
|
+
JsonU64,
|
|
31
|
+
ObjectID,
|
|
32
|
+
safeEnum,
|
|
33
|
+
TransactionDataSchema,
|
|
34
|
+
ValidDuringSchema,
|
|
35
|
+
ValiditySchema,
|
|
36
|
+
} from './internal.js';
|
|
30
37
|
import type { Argument, ArgumentSchema, TransactionData } from './internal.js';
|
|
31
38
|
|
|
32
39
|
export const ObjectRef = object({
|
|
@@ -65,11 +72,52 @@ const TransactionInput = union([
|
|
|
65
72
|
}),
|
|
66
73
|
]);
|
|
67
74
|
|
|
75
|
+
// Carried here rather than collapsed to `{ None: true }`, which silently dropped the expiration
|
|
76
|
+
// (and its allowed proposers) from a `serialize()` -> `from()` round trip before signing.
|
|
68
77
|
const TransactionExpiration = union([
|
|
69
78
|
object({ Epoch: pipe(number(), integer()) }),
|
|
70
79
|
object({ None: nullable(literal(true)) }),
|
|
80
|
+
object({ ValidDuring: ValidDuringSchema }),
|
|
81
|
+
object({ Validity: ValiditySchema }),
|
|
71
82
|
]);
|
|
72
83
|
|
|
84
|
+
function expirationToV1(
|
|
85
|
+
expiration: TransactionData['expiration'],
|
|
86
|
+
): InferOutput<typeof TransactionExpiration> | null {
|
|
87
|
+
if (!expiration) return null;
|
|
88
|
+
|
|
89
|
+
switch (expiration.$kind) {
|
|
90
|
+
case 'Epoch':
|
|
91
|
+
return { Epoch: Number(expiration.Epoch) };
|
|
92
|
+
case 'ValidDuring':
|
|
93
|
+
return { ValidDuring: expiration.ValidDuring };
|
|
94
|
+
case 'Validity':
|
|
95
|
+
return { Validity: expiration.Validity };
|
|
96
|
+
case 'None':
|
|
97
|
+
return { None: true };
|
|
98
|
+
default:
|
|
99
|
+
// Representing a new variant here is not optional: this fails to compile without it.
|
|
100
|
+
expiration satisfies never;
|
|
101
|
+
throw new Error(`Unknown transaction expiration: ${JSON.stringify(expiration)}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function expirationFromV1(
|
|
106
|
+
expiration: SerializedTransactionDataV1['expiration'],
|
|
107
|
+
): InferInput<typeof TransactionDataSchema>['expiration'] {
|
|
108
|
+
if (!expiration) return null;
|
|
109
|
+
if ('Epoch' in expiration) return { Epoch: expiration.Epoch };
|
|
110
|
+
if ('ValidDuring' in expiration) return { ValidDuring: expiration.ValidDuring };
|
|
111
|
+
if ('Validity' in expiration) return { Validity: expiration.Validity };
|
|
112
|
+
if ('None' in expiration) return { None: true };
|
|
113
|
+
|
|
114
|
+
// `restore` does not validate v1 payloads against the schema, so this is the only place an
|
|
115
|
+
// unrecognised expiration can be caught rather than silently becoming `{ None: true }`.
|
|
116
|
+
throw new Error(
|
|
117
|
+
`Unknown transaction expiration in v1 transaction data: ${Object.keys(expiration).join(', ')}`,
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
73
121
|
const StringEncodedBigint = pipe(
|
|
74
122
|
union([number(), string(), bigint()]),
|
|
75
123
|
check((val) => {
|
|
@@ -267,12 +315,7 @@ export function serializeV1TransactionData(
|
|
|
267
315
|
return {
|
|
268
316
|
version: 1,
|
|
269
317
|
sender: transactionData.sender ?? undefined,
|
|
270
|
-
expiration:
|
|
271
|
-
transactionData.expiration?.$kind === 'Epoch'
|
|
272
|
-
? { Epoch: Number(transactionData.expiration.Epoch) }
|
|
273
|
-
: transactionData.expiration
|
|
274
|
-
? { None: true }
|
|
275
|
-
: null,
|
|
318
|
+
expiration: expirationToV1(transactionData.expiration),
|
|
276
319
|
gasConfig: {
|
|
277
320
|
owner: transactionData.gasData.owner ?? undefined,
|
|
278
321
|
budget: transactionData.gasData.budget ?? undefined,
|
|
@@ -373,11 +416,7 @@ export function transactionDataFromV1(data: SerializedTransactionDataV1): Transa
|
|
|
373
416
|
return parse(TransactionDataSchema, {
|
|
374
417
|
version: 2,
|
|
375
418
|
sender: data.sender ?? null,
|
|
376
|
-
expiration: data.expiration
|
|
377
|
-
? 'Epoch' in data.expiration
|
|
378
|
-
? { Epoch: data.expiration.Epoch }
|
|
379
|
-
: { None: true }
|
|
380
|
-
: null,
|
|
419
|
+
expiration: expirationFromV1(data.expiration),
|
|
381
420
|
gasData: {
|
|
382
421
|
owner: data.gasConfig.owner ?? null,
|
|
383
422
|
budget: data.gasConfig.budget?.toString() ?? null,
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
ObjectRefSchema,
|
|
30
30
|
SuiAddress,
|
|
31
31
|
ValidDuringSchema,
|
|
32
|
+
ValiditySchema,
|
|
32
33
|
} from './internal.js';
|
|
33
34
|
import type { Simplify } from '@mysten/utils';
|
|
34
35
|
|
|
@@ -143,6 +144,7 @@ const TransactionExpiration = enumUnion({
|
|
|
143
144
|
None: literal(true),
|
|
144
145
|
Epoch: JsonU64,
|
|
145
146
|
ValidDuring: ValidDuringSchema,
|
|
147
|
+
Validity: ValiditySchema,
|
|
146
148
|
});
|
|
147
149
|
|
|
148
150
|
export const SerializedTransactionDataV2Schema = object({
|
package/src/version.ts
CHANGED