@mysten/sui 2.16.2 → 2.16.3

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.
@@ -1,31 +1,31 @@
1
- import * as _mysten_bcs1118 from "@mysten/bcs";
1
+ import * as _mysten_bcs810 from "@mysten/bcs";
2
2
  import { InferBcsInput } from "@mysten/bcs";
3
3
 
4
4
  //#region src/zklogin/bcs.d.ts
5
- declare const zkLoginSignature: _mysten_bcs1118.BcsStruct<{
6
- inputs: _mysten_bcs1118.BcsStruct<{
7
- proofPoints: _mysten_bcs1118.BcsStruct<{
8
- a: _mysten_bcs1118.BcsType<string[], Iterable<string> & {
5
+ declare const zkLoginSignature: _mysten_bcs810.BcsStruct<{
6
+ inputs: _mysten_bcs810.BcsStruct<{
7
+ proofPoints: _mysten_bcs810.BcsStruct<{
8
+ a: _mysten_bcs810.BcsType<string[], Iterable<string> & {
9
9
  length: number;
10
10
  }, string>;
11
- b: _mysten_bcs1118.BcsType<string[][], Iterable<Iterable<string> & {
11
+ b: _mysten_bcs810.BcsType<string[][], Iterable<Iterable<string> & {
12
12
  length: number;
13
13
  }> & {
14
14
  length: number;
15
15
  }, string>;
16
- c: _mysten_bcs1118.BcsType<string[], Iterable<string> & {
16
+ c: _mysten_bcs810.BcsType<string[], Iterable<string> & {
17
17
  length: number;
18
18
  }, string>;
19
19
  }, string>;
20
- issBase64Details: _mysten_bcs1118.BcsStruct<{
21
- value: _mysten_bcs1118.BcsType<string, string, "string">;
22
- indexMod4: _mysten_bcs1118.BcsType<number, number, "u8">;
20
+ issBase64Details: _mysten_bcs810.BcsStruct<{
21
+ value: _mysten_bcs810.BcsType<string, string, "string">;
22
+ indexMod4: _mysten_bcs810.BcsType<number, number, "u8">;
23
23
  }, string>;
24
- headerBase64: _mysten_bcs1118.BcsType<string, string, "string">;
25
- addressSeed: _mysten_bcs1118.BcsType<string, string, "string">;
24
+ headerBase64: _mysten_bcs810.BcsType<string, string, "string">;
25
+ addressSeed: _mysten_bcs810.BcsType<string, string, "string">;
26
26
  }, string>;
27
- maxEpoch: _mysten_bcs1118.BcsType<string, string | number | bigint, "u64">;
28
- userSignature: _mysten_bcs1118.BcsType<Uint8Array<ArrayBufferLike>, Iterable<number>, "vector<u8>">;
27
+ maxEpoch: _mysten_bcs810.BcsType<string, string | number | bigint, "u64">;
28
+ userSignature: _mysten_bcs810.BcsType<Uint8Array<ArrayBufferLike>, Iterable<number>, "vector<u8>">;
29
29
  }, string>;
30
30
  type ZkLoginSignature = InferBcsInput<typeof zkLoginSignature>;
31
31
  type ZkLoginSignatureInputs = ZkLoginSignature['inputs'];
@@ -1 +1 @@
1
- {"version":3,"file":"bcs.d.mts","names":[],"sources":["../../src/zklogin/bcs.ts"],"mappings":";;;;cAMa,gBAAA,kBAAgB,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;KAkBjB,gBAAA,GAAmB,aAAA,QAAqB,gBAAA;AAAA,KACxC,sBAAA,GAAyB,gBAAA"}
1
+ {"version":3,"file":"bcs.d.mts","names":[],"sources":["../../src/zklogin/bcs.ts"],"mappings":";;;;cAMa,gBAAA,iBAAgB,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;KAkBjB,gBAAA,GAAmB,aAAA,QAAqB,gBAAA;AAAA,KACxC,sBAAA,GAAyB,gBAAA"}
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": "2.16.2",
6
+ "version": "2.16.3",
7
7
  "license": "Apache-2.0",
8
8
  "sideEffects": false,
9
9
  "files": [
@@ -84,7 +84,18 @@ export async function coreClientResolveTransactionPlugin(
84
84
  }
85
85
  }
86
86
 
87
- const needsSystemState = needsGasPrice || (needsPayment && usesGasCoin);
87
+ // `setGasBudget` simulates with `payment: []` whenever it has to compute a
88
+ // budget (i.e. one wasn't preset). The validator's replay-protection check
89
+ // then requires either a `ValidDuring` expiration or at least one
90
+ // "address-owned" input — an `ImmOrOwnedMoveObject` whose owner is
91
+ // `AddressOwner`, which we can't tell from `Immutable` without owner info we
92
+ // don't track. Provide a simulate-only `ValidDuring` whenever we'll actually
93
+ // simulate and one isn't user-set.
94
+ const needsSimulateExpiration =
95
+ !options.onlyTransactionKind && !transactionData.expiration && !transactionData.gasData.budget;
96
+ const needsSystemState =
97
+ needsGasPrice || (needsPayment && usesGasCoin) || needsSimulateExpiration;
98
+ const needsChainId = (needsPayment && usesGasCoin) || needsSimulateExpiration;
88
99
  const [, systemStateResult, balanceResult, coinsResult, chainIdResult] = await Promise.all([
89
100
  normalizeInputs(transactionData, client),
90
101
  needsSystemState ? client.core.getCurrentSystemState() : null,
@@ -92,19 +103,25 @@ export async function coreClientResolveTransactionPlugin(
92
103
  needsPayment && gasPayer
93
104
  ? client.core.listCoins({ owner: gasPayer, coinType: SUI_TYPE_ARG })
94
105
  : null,
95
- needsPayment && usesGasCoin ? client.core.getChainIdentifier() : null,
106
+ needsChainId ? client.core.getChainIdentifier() : null,
96
107
  ]);
97
108
 
98
109
  await resolveObjectReferences(transactionData, client);
99
110
 
100
111
  if (!options.onlyTransactionKind) {
101
112
  const systemState = systemStateResult?.systemState ?? null;
113
+ const chainIdentifier = chainIdResult?.chainIdentifier ?? null;
102
114
 
103
115
  if (systemState && !transactionData.gasData.price) {
104
116
  transactionData.gasData.price = systemState.referenceGasPrice;
105
117
  }
106
118
 
107
- await setGasBudget(transactionData, client);
119
+ const simulateExpiration =
120
+ needsSimulateExpiration && systemState && chainIdentifier
121
+ ? buildValidDuringExpiration(systemState, chainIdentifier)
122
+ : undefined;
123
+
124
+ await setGasBudget(transactionData, client, simulateExpiration);
108
125
 
109
126
  if (needsPayment) {
110
127
  if (!balanceResult || !coinsResult) {
@@ -119,25 +136,24 @@ export async function coreClientResolveTransactionPlugin(
119
136
  usesGasCoin,
120
137
  withdrawals,
121
138
  gasPayer: gasPayer!,
122
- chainIdentifier: chainIdResult?.chainIdentifier ?? null,
139
+ chainIdentifier,
123
140
  epoch: systemState?.epoch ?? null,
124
141
  });
125
142
  }
126
143
 
127
144
  if (!transactionData.expiration && transactionData.gasData.payment?.length === 0) {
128
- await setExpiration(
129
- transactionData,
130
- client,
131
- systemState,
132
- chainIdResult?.chainIdentifier ?? null,
133
- );
145
+ await setExpiration(transactionData, client, systemState, chainIdentifier);
134
146
  }
135
147
  }
136
148
 
137
149
  return await next();
138
150
  }
139
151
 
140
- async function setGasBudget(transactionData: TransactionDataBuilder, client: ClientWithCoreApi) {
152
+ async function setGasBudget(
153
+ transactionData: TransactionDataBuilder,
154
+ client: ClientWithCoreApi,
155
+ simulateExpiration?: ValidDuringExpiration,
156
+ ) {
141
157
  if (transactionData.gasData.budget) {
142
158
  return;
143
159
  }
@@ -149,6 +165,7 @@ async function setGasBudget(transactionData: TransactionDataBuilder, client: Cli
149
165
  budget: String(MAX_GAS),
150
166
  payment: [],
151
167
  },
168
+ ...(simulateExpiration && { expiration: simulateExpiration }),
152
169
  },
153
170
  }),
154
171
  include: { effects: true },
@@ -243,9 +260,27 @@ async function setExpiration(
243
260
  existingChainIdentifier ?? client.core.getChainIdentifier().then((r) => r.chainIdentifier),
244
261
  systemState ?? client.core.getCurrentSystemState().then((r) => r.systemState),
245
262
  ]);
246
- const currentEpoch = BigInt(resolvedSystemState.epoch);
263
+ transactionData.expiration = buildValidDuringExpiration(resolvedSystemState, chainIdentifier);
264
+ }
247
265
 
248
- transactionData.expiration = {
266
+ type ValidDuringExpiration = {
267
+ $kind: 'ValidDuring';
268
+ ValidDuring: {
269
+ minEpoch: string;
270
+ maxEpoch: string;
271
+ minTimestamp: null;
272
+ maxTimestamp: null;
273
+ chain: string;
274
+ nonce: number;
275
+ };
276
+ };
277
+
278
+ function buildValidDuringExpiration(
279
+ systemState: SystemStateData,
280
+ chainIdentifier: string,
281
+ ): ValidDuringExpiration {
282
+ const currentEpoch = BigInt(systemState.epoch);
283
+ return {
249
284
  $kind: 'ValidDuring',
250
285
  ValidDuring: {
251
286
  minEpoch: String(currentEpoch),
package/src/version.ts CHANGED
@@ -3,4 +3,4 @@
3
3
 
4
4
  // This file is generated by genversion.mjs. Do not edit it directly.
5
5
 
6
- export const PACKAGE_VERSION = '2.16.2';
6
+ export const PACKAGE_VERSION = '2.16.3';