starknet 7.3.0 → 7.5.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 +24 -0
- package/dist/index.d.ts +210 -30
- package/dist/index.global.js +171 -59
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +161 -49
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +161 -49
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.global.js
CHANGED
|
@@ -235,7 +235,7 @@ var starknet = (() => {
|
|
|
235
235
|
// src/types/api/jsonrpc/index.ts
|
|
236
236
|
var jsonrpc_exports = {};
|
|
237
237
|
|
|
238
|
-
// node_modules/starknet-types-07/dist/esm/index.js
|
|
238
|
+
// node_modules/@starknet-io/starknet-types-07/dist/esm/index.js
|
|
239
239
|
var esm_exports = {};
|
|
240
240
|
__export(esm_exports, {
|
|
241
241
|
API: () => api_exports,
|
|
@@ -257,7 +257,7 @@ var starknet = (() => {
|
|
|
257
257
|
WALLET_API: () => wallet_api_exports
|
|
258
258
|
});
|
|
259
259
|
|
|
260
|
-
// node_modules/starknet-types-07/dist/esm/api/index.js
|
|
260
|
+
// node_modules/@starknet-io/starknet-types-07/dist/esm/api/index.js
|
|
261
261
|
var api_exports = {};
|
|
262
262
|
__export(api_exports, {
|
|
263
263
|
EBlockTag: () => EBlockTag,
|
|
@@ -275,13 +275,13 @@ var starknet = (() => {
|
|
|
275
275
|
SPEC: () => components_exports
|
|
276
276
|
});
|
|
277
277
|
|
|
278
|
-
// node_modules/starknet-types-07/dist/esm/api/errors.js
|
|
278
|
+
// node_modules/@starknet-io/starknet-types-07/dist/esm/api/errors.js
|
|
279
279
|
var errors_exports = {};
|
|
280
280
|
|
|
281
|
-
// node_modules/starknet-types-07/dist/esm/api/components.js
|
|
281
|
+
// node_modules/@starknet-io/starknet-types-07/dist/esm/api/components.js
|
|
282
282
|
var components_exports = {};
|
|
283
283
|
|
|
284
|
-
// node_modules/starknet-types-07/dist/esm/api/nonspec.js
|
|
284
|
+
// node_modules/@starknet-io/starknet-types-07/dist/esm/api/nonspec.js
|
|
285
285
|
var ETransactionType = {
|
|
286
286
|
DECLARE: "DECLARE",
|
|
287
287
|
DEPLOY: "DEPLOY",
|
|
@@ -342,25 +342,25 @@ var starknet = (() => {
|
|
|
342
342
|
F3: "0x100000000000000000000000000000003"
|
|
343
343
|
};
|
|
344
344
|
|
|
345
|
-
// node_modules/starknet-types-07/dist/esm/wallet-api/index.js
|
|
345
|
+
// node_modules/@starknet-io/starknet-types-07/dist/esm/wallet-api/index.js
|
|
346
346
|
var wallet_api_exports = {};
|
|
347
347
|
__export(wallet_api_exports, {
|
|
348
348
|
Permission: () => Permission,
|
|
349
349
|
TypedDataRevision: () => TypedDataRevision
|
|
350
350
|
});
|
|
351
351
|
|
|
352
|
-
// node_modules/starknet-types-07/dist/esm/wallet-api/constants.js
|
|
352
|
+
// node_modules/@starknet-io/starknet-types-07/dist/esm/wallet-api/constants.js
|
|
353
353
|
var Permission = {
|
|
354
354
|
ACCOUNTS: "accounts"
|
|
355
355
|
};
|
|
356
356
|
|
|
357
|
-
// node_modules/starknet-types-07/dist/esm/wallet-api/typedData.js
|
|
357
|
+
// node_modules/@starknet-io/starknet-types-07/dist/esm/wallet-api/typedData.js
|
|
358
358
|
var TypedDataRevision = {
|
|
359
359
|
ACTIVE: "1",
|
|
360
360
|
LEGACY: "0"
|
|
361
361
|
};
|
|
362
362
|
|
|
363
|
-
// node_modules/starknet-types-08/dist/esm/index.js
|
|
363
|
+
// node_modules/@starknet-io/starknet-types-08/dist/esm/index.js
|
|
364
364
|
var esm_exports2 = {};
|
|
365
365
|
__export(esm_exports2, {
|
|
366
366
|
ABI_TYPE_CONSTRUCTOR: () => ABI_TYPE_CONSTRUCTOR,
|
|
@@ -406,7 +406,7 @@ var starknet = (() => {
|
|
|
406
406
|
WALLET_API: () => wallet_api_exports2
|
|
407
407
|
});
|
|
408
408
|
|
|
409
|
-
// node_modules/starknet-types-08/dist/esm/api/index.js
|
|
409
|
+
// node_modules/@starknet-io/starknet-types-08/dist/esm/api/index.js
|
|
410
410
|
var api_exports2 = {};
|
|
411
411
|
__export(api_exports2, {
|
|
412
412
|
ABI_TYPE_CONSTRUCTOR: () => ABI_TYPE_CONSTRUCTOR,
|
|
@@ -447,10 +447,10 @@ var starknet = (() => {
|
|
|
447
447
|
TXN_TYPE_L1_HANDLER: () => TXN_TYPE_L1_HANDLER
|
|
448
448
|
});
|
|
449
449
|
|
|
450
|
-
// node_modules/starknet-types-08/dist/esm/api/contract.js
|
|
450
|
+
// node_modules/@starknet-io/starknet-types-08/dist/esm/api/contract.js
|
|
451
451
|
var contract_exports = {};
|
|
452
452
|
|
|
453
|
-
// node_modules/starknet-types-08/dist/esm/api/constants.js
|
|
453
|
+
// node_modules/@starknet-io/starknet-types-08/dist/esm/api/constants.js
|
|
454
454
|
var STATUS_ACCEPTED_ON_L2 = "ACCEPTED_ON_L2";
|
|
455
455
|
var STATUS_ACCEPTED_ON_L1 = "ACCEPTED_ON_L1";
|
|
456
456
|
var STATUS_SUCCEEDED = "SUCCEEDED";
|
|
@@ -560,25 +560,25 @@ var starknet = (() => {
|
|
|
560
560
|
F3: ETransactionVersion4.F3
|
|
561
561
|
};
|
|
562
562
|
|
|
563
|
-
// node_modules/starknet-types-08/dist/esm/wallet-api/index.js
|
|
563
|
+
// node_modules/@starknet-io/starknet-types-08/dist/esm/wallet-api/index.js
|
|
564
564
|
var wallet_api_exports2 = {};
|
|
565
565
|
__export(wallet_api_exports2, {
|
|
566
566
|
Permission: () => Permission2,
|
|
567
567
|
TypedDataRevision: () => TypedDataRevision2
|
|
568
568
|
});
|
|
569
569
|
|
|
570
|
-
// node_modules/starknet-types-08/dist/esm/wallet-api/constants.js
|
|
570
|
+
// node_modules/@starknet-io/starknet-types-08/dist/esm/wallet-api/constants.js
|
|
571
571
|
var Permission2 = {
|
|
572
572
|
ACCOUNTS: "accounts"
|
|
573
573
|
};
|
|
574
574
|
|
|
575
|
-
// node_modules/starknet-types-08/dist/esm/wallet-api/typedData.js
|
|
575
|
+
// node_modules/@starknet-io/starknet-types-08/dist/esm/wallet-api/typedData.js
|
|
576
576
|
var TypedDataRevision2 = {
|
|
577
577
|
ACTIVE: "1",
|
|
578
578
|
LEGACY: "0"
|
|
579
579
|
};
|
|
580
580
|
|
|
581
|
-
// node_modules/starknet-types-08/dist/esm/snip-29/index.js
|
|
581
|
+
// node_modules/@starknet-io/starknet-types-08/dist/esm/snip-29/index.js
|
|
582
582
|
var snip_29_exports = {};
|
|
583
583
|
|
|
584
584
|
// src/utils/encode.ts
|
|
@@ -920,14 +920,8 @@ var starknet = (() => {
|
|
|
920
920
|
websocket: void 0
|
|
921
921
|
};
|
|
922
922
|
var RPC_DEFAULT_NODES = {
|
|
923
|
-
SN_MAIN: [
|
|
924
|
-
|
|
925
|
-
`https://free-rpc.nethermind.io/mainnet-juno/`
|
|
926
|
-
],
|
|
927
|
-
SN_SEPOLIA: [
|
|
928
|
-
`https://starknet-sepolia.public.blastapi.io/rpc/`,
|
|
929
|
-
`https://free-rpc.nethermind.io/sepolia-juno/`
|
|
930
|
-
]
|
|
923
|
+
SN_MAIN: [`https://starknet-mainnet.public.blastapi.io/rpc/`],
|
|
924
|
+
SN_SEPOLIA: [`https://starknet-sepolia.public.blastapi.io/rpc/`]
|
|
931
925
|
};
|
|
932
926
|
var PAYMASTER_RPC_NODES = {
|
|
933
927
|
SN_MAIN: [`https://starknet.paymaster.avnu.fi`],
|
|
@@ -938,7 +932,8 @@ var starknet = (() => {
|
|
|
938
932
|
legacyTxRPC08Message: "RPC 0.8 do not support legacy transactions",
|
|
939
933
|
SWOldV3: "RPC 0.7 V3 tx (improper resource bounds) not supported in RPC 0.8",
|
|
940
934
|
channelVersionMismatch: "Channel specification version is not compatible with the connected node Specification Version",
|
|
941
|
-
unsupportedSpecVersion: "The connected node specification version is not supported by this library"
|
|
935
|
+
unsupportedSpecVersion: "The connected node specification version is not supported by this library",
|
|
936
|
+
maxFeeInV3: "maxFee is not supported in V3 transactions, use resourceBounds instead"
|
|
942
937
|
};
|
|
943
938
|
|
|
944
939
|
// src/global/config.ts
|
|
@@ -1928,6 +1923,15 @@ ${indent}}` : "}";
|
|
|
1928
1923
|
throw new Error(message || "Assertion failure");
|
|
1929
1924
|
}
|
|
1930
1925
|
}
|
|
1926
|
+
function assertX(condition, method) {
|
|
1927
|
+
if (!condition) {
|
|
1928
|
+
if (method.length === 0) {
|
|
1929
|
+
method();
|
|
1930
|
+
} else {
|
|
1931
|
+
throw new Error("AssertionX failure: message function should not require arguments");
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1931
1935
|
|
|
1932
1936
|
// src/utils/num.ts
|
|
1933
1937
|
var num_exports = {};
|
|
@@ -2696,6 +2700,7 @@ ${indent}}` : "}";
|
|
|
2696
2700
|
// src/utils/hash/selector.ts
|
|
2697
2701
|
var selector_exports = {};
|
|
2698
2702
|
__export(selector_exports, {
|
|
2703
|
+
getL1MessageHash: () => getL1MessageHash,
|
|
2699
2704
|
getL2MessageHash: () => getL2MessageHash,
|
|
2700
2705
|
getSelector: () => getSelector,
|
|
2701
2706
|
getSelectorFromName: () => getSelectorFromName,
|
|
@@ -4928,6 +4933,9 @@ ${indent}}` : "}";
|
|
|
4928
4933
|
...l2Calldata
|
|
4929
4934
|
]);
|
|
4930
4935
|
}
|
|
4936
|
+
function getL1MessageHash(fromL2Address, toL1Address, payload) {
|
|
4937
|
+
return solidityUint256PackedKeccak256([fromL2Address, toL1Address, payload.length, ...payload]);
|
|
4938
|
+
}
|
|
4931
4939
|
|
|
4932
4940
|
// src/utils/shortString.ts
|
|
4933
4941
|
var shortString_exports = {};
|
|
@@ -7081,6 +7089,7 @@ ${indent}}` : "}";
|
|
|
7081
7089
|
computePoseidonHashOnElements: () => computePoseidonHashOnElements,
|
|
7082
7090
|
computeSierraContractClassHash: () => computeSierraContractClassHash,
|
|
7083
7091
|
formatSpaces: () => formatSpaces,
|
|
7092
|
+
getL1MessageHash: () => getL1MessageHash,
|
|
7084
7093
|
getL2MessageHash: () => getL2MessageHash,
|
|
7085
7094
|
getSelector: () => getSelector,
|
|
7086
7095
|
getSelectorFromName: () => getSelectorFromName,
|
|
@@ -12782,6 +12791,11 @@ ${indent}}` : "}";
|
|
|
12782
12791
|
fee_data_availability_mode: details.feeDataAvailabilityMode
|
|
12783
12792
|
}
|
|
12784
12793
|
});
|
|
12794
|
+
assertX(!details.maxFee, () => {
|
|
12795
|
+
logger.warn(SYSTEM_MESSAGES.maxFeeInV3, {
|
|
12796
|
+
type: esm_exports.ETransactionType.INVOKE
|
|
12797
|
+
});
|
|
12798
|
+
});
|
|
12785
12799
|
}
|
|
12786
12800
|
return this.waitMode ? this.waitForTransaction((await promise).transaction_hash) : promise;
|
|
12787
12801
|
}
|
|
@@ -12852,6 +12866,11 @@ ${indent}}` : "}";
|
|
|
12852
12866
|
fee_data_availability_mode: details.feeDataAvailabilityMode
|
|
12853
12867
|
}
|
|
12854
12868
|
});
|
|
12869
|
+
assertX(!details.maxFee, () => {
|
|
12870
|
+
logger.warn(SYSTEM_MESSAGES.maxFeeInV3, {
|
|
12871
|
+
type: esm_exports.ETransactionType.DECLARE
|
|
12872
|
+
});
|
|
12873
|
+
});
|
|
12855
12874
|
} else {
|
|
12856
12875
|
throw Error("declare unspotted parameters");
|
|
12857
12876
|
}
|
|
@@ -12893,6 +12912,11 @@ ${indent}}` : "}";
|
|
|
12893
12912
|
fee_data_availability_mode: details.feeDataAvailabilityMode
|
|
12894
12913
|
}
|
|
12895
12914
|
});
|
|
12915
|
+
assertX(!details.maxFee, () => {
|
|
12916
|
+
logger.warn(SYSTEM_MESSAGES.maxFeeInV3, {
|
|
12917
|
+
type: esm_exports.ETransactionType.DEPLOY_ACCOUNT
|
|
12918
|
+
});
|
|
12919
|
+
});
|
|
12896
12920
|
}
|
|
12897
12921
|
return this.waitMode ? this.waitForTransaction((await promise).transaction_hash) : promise;
|
|
12898
12922
|
}
|
|
@@ -12963,6 +12987,12 @@ ${indent}}` : "}";
|
|
|
12963
12987
|
fee_data_availability_mode: invocation.feeDataAvailabilityMode,
|
|
12964
12988
|
account_deployment_data: invocation.accountDeploymentData.map((it) => toHex(it))
|
|
12965
12989
|
};
|
|
12990
|
+
assertX(!invocation.maxFee, () => {
|
|
12991
|
+
logger.warn(SYSTEM_MESSAGES.maxFeeInV3, {
|
|
12992
|
+
type: invocation.type,
|
|
12993
|
+
versionType
|
|
12994
|
+
});
|
|
12995
|
+
});
|
|
12966
12996
|
}
|
|
12967
12997
|
if (invocation.type === TransactionType.INVOKE) {
|
|
12968
12998
|
return {
|
|
@@ -17243,19 +17273,20 @@ ${indent}}` : "}";
|
|
|
17243
17273
|
}
|
|
17244
17274
|
function parseEvents(providerReceivedEvents, abiEvents, abiStructs, abiEnums) {
|
|
17245
17275
|
const ret = providerReceivedEvents.flat().reduce((acc, recEvent) => {
|
|
17246
|
-
|
|
17276
|
+
const currentEvent = JSON.parse(JSON.stringify(recEvent));
|
|
17277
|
+
let abiEvent = abiEvents[currentEvent.keys.shift() ?? 0];
|
|
17247
17278
|
if (!abiEvent) {
|
|
17248
17279
|
return acc;
|
|
17249
17280
|
}
|
|
17250
17281
|
while (!abiEvent.name) {
|
|
17251
|
-
const hashName =
|
|
17282
|
+
const hashName = currentEvent.keys.shift();
|
|
17252
17283
|
assert(!!hashName, 'Not enough data in "keys" property of this event.');
|
|
17253
17284
|
abiEvent = abiEvent[hashName];
|
|
17254
17285
|
}
|
|
17255
17286
|
const parsedEvent = {};
|
|
17256
17287
|
parsedEvent[abiEvent.name] = {};
|
|
17257
|
-
const keysIter =
|
|
17258
|
-
const dataIter =
|
|
17288
|
+
const keysIter = currentEvent.keys[Symbol.iterator]();
|
|
17289
|
+
const dataIter = currentEvent.data[Symbol.iterator]();
|
|
17259
17290
|
const abiEventKeys = abiEvent.members?.filter((it) => it.kind === "key") || abiEvent.keys;
|
|
17260
17291
|
const abiEventData = abiEvent.members?.filter((it) => it.kind === "data") || abiEvent.data;
|
|
17261
17292
|
abiEventKeys.forEach((key) => {
|
|
@@ -17276,9 +17307,10 @@ ${indent}}` : "}";
|
|
|
17276
17307
|
parsedEvent[abiEvent.name]
|
|
17277
17308
|
);
|
|
17278
17309
|
});
|
|
17279
|
-
if ("block_hash" in
|
|
17280
|
-
if ("block_number" in
|
|
17281
|
-
if ("transaction_hash" in
|
|
17310
|
+
if ("block_hash" in currentEvent) parsedEvent.block_hash = currentEvent.block_hash;
|
|
17311
|
+
if ("block_number" in currentEvent) parsedEvent.block_number = currentEvent.block_number;
|
|
17312
|
+
if ("transaction_hash" in currentEvent)
|
|
17313
|
+
parsedEvent.transaction_hash = currentEvent.transaction_hash;
|
|
17282
17314
|
acc.push(parsedEvent);
|
|
17283
17315
|
return acc;
|
|
17284
17316
|
}, []);
|
|
@@ -17312,8 +17344,19 @@ ${indent}}` : "}";
|
|
|
17312
17344
|
buildExecuteFromOutsideCall: () => buildExecuteFromOutsideCall,
|
|
17313
17345
|
buildExecuteFromOutsideCallData: () => buildExecuteFromOutsideCallData,
|
|
17314
17346
|
getOutsideCall: () => getOutsideCall,
|
|
17315
|
-
getTypedData: () => getTypedData
|
|
17347
|
+
getTypedData: () => getTypedData,
|
|
17348
|
+
toOutsideCallV2: () => toOutsideCallV2
|
|
17316
17349
|
});
|
|
17350
|
+
function toOutsideCallV2(call) {
|
|
17351
|
+
if ("calldata_len" in call) {
|
|
17352
|
+
return {
|
|
17353
|
+
To: call.to,
|
|
17354
|
+
Selector: call.selector,
|
|
17355
|
+
Calldata: call.calldata
|
|
17356
|
+
};
|
|
17357
|
+
}
|
|
17358
|
+
return call;
|
|
17359
|
+
}
|
|
17317
17360
|
function getOutsideCall(call) {
|
|
17318
17361
|
const callData = call.calldata ?? [];
|
|
17319
17362
|
const callDataCompiled = Array.isArray(callData) ? callData : CallData.compile(callData);
|
|
@@ -17423,6 +17466,8 @@ ${indent}}` : "}";
|
|
|
17423
17466
|
// src/utils/paymaster.ts
|
|
17424
17467
|
var paymaster_exports = {};
|
|
17425
17468
|
__export(paymaster_exports, {
|
|
17469
|
+
assertCallsAreStrictlyEqual: () => assertCallsAreStrictlyEqual,
|
|
17470
|
+
assertPaymasterTransactionSafety: () => assertPaymasterTransactionSafety,
|
|
17426
17471
|
getDefaultPaymasterNodeUrl: () => getDefaultPaymasterNodeUrl
|
|
17427
17472
|
});
|
|
17428
17473
|
var getDefaultPaymasterNodeUrl = (networkName, mute = false) => {
|
|
@@ -17433,6 +17478,79 @@ ${indent}}` : "}";
|
|
|
17433
17478
|
const randIdx = Math.floor(Math.random() * nodes.length);
|
|
17434
17479
|
return nodes[randIdx];
|
|
17435
17480
|
};
|
|
17481
|
+
var assertGasFeeFromUnsafeCalls = (unsafeCalls, fees) => {
|
|
17482
|
+
const unsafeCall = toOutsideCallV2(unsafeCalls[unsafeCalls.length - 1]);
|
|
17483
|
+
const unsafeGasTokenCalldata = CallData.toCalldata(unsafeCall.Calldata);
|
|
17484
|
+
const unsafeGasTokenValue = unsafeGasTokenCalldata[1];
|
|
17485
|
+
assert(
|
|
17486
|
+
BigInt(unsafeGasTokenValue) === BigInt(fees),
|
|
17487
|
+
"Gas token value is not equal to the provided gas fees"
|
|
17488
|
+
);
|
|
17489
|
+
};
|
|
17490
|
+
var assertGasTokenFromUnsafeCalls = (unsafeCalls, gasToken) => {
|
|
17491
|
+
const unsafeCall = toOutsideCallV2(unsafeCalls[unsafeCalls.length - 1]);
|
|
17492
|
+
assert(
|
|
17493
|
+
BigInt(unsafeCall.To) === BigInt(gasToken),
|
|
17494
|
+
"Gas token address is not equal to the provided gas token"
|
|
17495
|
+
);
|
|
17496
|
+
};
|
|
17497
|
+
function assertCallsAreStrictlyEqual(originalCalls, unsafeCalls) {
|
|
17498
|
+
const baseError = "Provided calls are not strictly equal to the returned calls";
|
|
17499
|
+
assert(
|
|
17500
|
+
unsafeCalls.length - 1 === originalCalls.length,
|
|
17501
|
+
`${baseError}: Expected ${originalCalls.length + 1} calls, got ${unsafeCalls.length}`
|
|
17502
|
+
);
|
|
17503
|
+
for (let callIndex = 0; callIndex < originalCalls.length; callIndex += 1) {
|
|
17504
|
+
const originalCall = originalCalls[callIndex];
|
|
17505
|
+
const unsafeCall = toOutsideCallV2(unsafeCalls[callIndex]);
|
|
17506
|
+
const normalizeAddress = (address) => {
|
|
17507
|
+
return toBigInt(address).toString(16).toLowerCase();
|
|
17508
|
+
};
|
|
17509
|
+
const originalAddress = normalizeAddress(originalCall.contractAddress);
|
|
17510
|
+
const unsafeAddress = normalizeAddress(unsafeCall.To);
|
|
17511
|
+
assert(
|
|
17512
|
+
originalAddress === unsafeAddress,
|
|
17513
|
+
`${baseError}: Contract address mismatch at call ${callIndex}. Expected: ${originalCall.contractAddress}, Got: ${unsafeCall.To}`
|
|
17514
|
+
);
|
|
17515
|
+
assert(
|
|
17516
|
+
getSelectorFromName(originalCall.entrypoint) === unsafeCall.Selector,
|
|
17517
|
+
`${baseError}: Entrypoint mismatch at call ${callIndex}. Expected: ${originalCall.entrypoint}, Got: ${unsafeCall.Selector}`
|
|
17518
|
+
);
|
|
17519
|
+
const originalCalldata = CallData.toCalldata(originalCall.calldata);
|
|
17520
|
+
const unsafeCalldata = CallData.toCalldata(unsafeCall.Calldata);
|
|
17521
|
+
assert(
|
|
17522
|
+
originalCalldata.length === unsafeCalldata.length,
|
|
17523
|
+
`${baseError}: Calldata length mismatch at call ${callIndex}. Expected length: ${originalCalldata.length}, Got length: ${unsafeCalldata.length}`
|
|
17524
|
+
);
|
|
17525
|
+
for (let dataIndex = 0; dataIndex < originalCalldata.length; dataIndex += 1) {
|
|
17526
|
+
const originalValue = BigInt(originalCalldata[dataIndex]);
|
|
17527
|
+
const unsafeValue = BigInt(unsafeCalldata[dataIndex]);
|
|
17528
|
+
assert(
|
|
17529
|
+
originalValue === unsafeValue,
|
|
17530
|
+
`${baseError}: Calldata value mismatch at call ${callIndex}, parameter ${dataIndex}. Expected: ${originalCalldata[dataIndex]}, Got: ${unsafeCalldata[dataIndex]}`
|
|
17531
|
+
);
|
|
17532
|
+
}
|
|
17533
|
+
}
|
|
17534
|
+
}
|
|
17535
|
+
var assertPaymasterTransactionSafety = (preparedTransaction, calls, paymasterDetails, maxFeeInGasToken) => {
|
|
17536
|
+
if (paymasterDetails.feeMode.mode !== "sponsored") {
|
|
17537
|
+
if (preparedTransaction.type === "invoke" || preparedTransaction.type === "deploy_and_invoke") {
|
|
17538
|
+
const unsafeCalls = "calls" in preparedTransaction.typed_data.message ? preparedTransaction.typed_data.message.calls : preparedTransaction.typed_data.message.Calls;
|
|
17539
|
+
assertCallsAreStrictlyEqual(calls, unsafeCalls);
|
|
17540
|
+
assertGasTokenFromUnsafeCalls(unsafeCalls, paymasterDetails.feeMode.gasToken);
|
|
17541
|
+
if (maxFeeInGasToken) {
|
|
17542
|
+
assert(
|
|
17543
|
+
preparedTransaction.fee.suggested_max_fee_in_gas_token <= maxFeeInGasToken,
|
|
17544
|
+
"Gas token price is too high"
|
|
17545
|
+
);
|
|
17546
|
+
assertGasFeeFromUnsafeCalls(
|
|
17547
|
+
unsafeCalls,
|
|
17548
|
+
preparedTransaction.fee.suggested_max_fee_in_gas_token
|
|
17549
|
+
);
|
|
17550
|
+
}
|
|
17551
|
+
}
|
|
17552
|
+
}
|
|
17553
|
+
};
|
|
17436
17554
|
|
|
17437
17555
|
// src/paymaster/rpc.ts
|
|
17438
17556
|
var convertCalls = (calls) => calls.map((call) => ({
|
|
@@ -17452,13 +17570,14 @@ ${indent}}` : "}";
|
|
|
17452
17570
|
}
|
|
17453
17571
|
return { mode: "default", gasToken: feeMode.gas_token };
|
|
17454
17572
|
};
|
|
17455
|
-
var convertTimeBounds = (timeBounds) => timeBounds
|
|
17456
|
-
execute_after: timeBounds.executeAfter
|
|
17457
|
-
|
|
17573
|
+
var convertTimeBounds = (timeBounds) => timeBounds ? {
|
|
17574
|
+
execute_after: timeBounds.executeAfter || 1,
|
|
17575
|
+
// If executeAfter is not provided, set it to 1, meaning the transaction can be executed immediately
|
|
17576
|
+
execute_before: timeBounds.executeBefore
|
|
17458
17577
|
} : void 0;
|
|
17459
|
-
var convertTIME_BOUNDS = (timeBounds) => timeBounds
|
|
17460
|
-
executeAfter:
|
|
17461
|
-
executeBefore:
|
|
17578
|
+
var convertTIME_BOUNDS = (timeBounds) => timeBounds ? {
|
|
17579
|
+
executeAfter: timeBounds.execute_after,
|
|
17580
|
+
executeBefore: timeBounds.execute_before
|
|
17462
17581
|
} : void 0;
|
|
17463
17582
|
var convertEXECUTION_PARAMETERS = (parameters) => ({
|
|
17464
17583
|
version: parameters.version,
|
|
@@ -17871,13 +17990,6 @@ ${indent}}` : "}";
|
|
|
17871
17990
|
}
|
|
17872
17991
|
async execute(transactions, transactionsDetail = {}) {
|
|
17873
17992
|
const calls = Array.isArray(transactions) ? transactions : [transactions];
|
|
17874
|
-
if (transactionsDetail.paymaster) {
|
|
17875
|
-
return this.executePaymasterTransaction(
|
|
17876
|
-
calls,
|
|
17877
|
-
transactionsDetail.paymaster,
|
|
17878
|
-
transactionsDetail.maxFee
|
|
17879
|
-
);
|
|
17880
|
-
}
|
|
17881
17993
|
const nonce = toBigInt(transactionsDetail.nonce ?? await this.getNonce());
|
|
17882
17994
|
const version = toTransactionVersion(
|
|
17883
17995
|
this.getPreferredVersion(ETransactionVersion5.V1, ETransactionVersion5.V3),
|
|
@@ -17954,11 +18066,7 @@ ${indent}}` : "}";
|
|
|
17954
18066
|
const preparedTransaction = await this.buildPaymasterTransaction(calls, paymasterDetails);
|
|
17955
18067
|
return preparedTransaction.fee;
|
|
17956
18068
|
}
|
|
17957
|
-
async
|
|
17958
|
-
const preparedTransaction = await this.buildPaymasterTransaction(calls, paymasterDetails);
|
|
17959
|
-
if (maxFee && preparedTransaction.fee.gas_token_price_in_strk > maxFee) {
|
|
17960
|
-
throw Error("Gas token price is too high");
|
|
17961
|
-
}
|
|
18069
|
+
async preparePaymasterTransaction(preparedTransaction) {
|
|
17962
18070
|
let transaction;
|
|
17963
18071
|
switch (preparedTransaction.type) {
|
|
17964
18072
|
case "deploy_and_invoke": {
|
|
@@ -17996,6 +18104,17 @@ ${indent}}` : "}";
|
|
|
17996
18104
|
default:
|
|
17997
18105
|
throw Error("Invalid transaction type");
|
|
17998
18106
|
}
|
|
18107
|
+
return transaction;
|
|
18108
|
+
}
|
|
18109
|
+
async executePaymasterTransaction(calls, paymasterDetails, maxFeeInGasToken) {
|
|
18110
|
+
const preparedTransaction = await this.buildPaymasterTransaction(calls, paymasterDetails);
|
|
18111
|
+
assertPaymasterTransactionSafety(
|
|
18112
|
+
preparedTransaction,
|
|
18113
|
+
calls,
|
|
18114
|
+
paymasterDetails,
|
|
18115
|
+
maxFeeInGasToken
|
|
18116
|
+
);
|
|
18117
|
+
const transaction = await this.preparePaymasterTransaction(preparedTransaction);
|
|
17999
18118
|
return this.paymaster.executeTransaction(transaction, preparedTransaction.parameters).then((response) => ({ transaction_hash: response.transaction_hash }));
|
|
18000
18119
|
}
|
|
18001
18120
|
/**
|
|
@@ -18586,14 +18705,7 @@ ${indent}}` : "}";
|
|
|
18586
18705
|
/**
|
|
18587
18706
|
* ACCOUNT METHODS
|
|
18588
18707
|
*/
|
|
18589
|
-
execute(calls
|
|
18590
|
-
const details = arg2 === void 0 || Array.isArray(arg2) ? transactionsDetail : arg2;
|
|
18591
|
-
if (details.paymaster) {
|
|
18592
|
-
return this.executePaymasterTransaction(
|
|
18593
|
-
Array.isArray(calls) ? calls : [calls],
|
|
18594
|
-
details.paymaster
|
|
18595
|
-
);
|
|
18596
|
-
}
|
|
18708
|
+
execute(calls) {
|
|
18597
18709
|
const txCalls = [].concat(calls).map((it) => {
|
|
18598
18710
|
const { contractAddress, entrypoint, calldata } = it;
|
|
18599
18711
|
return {
|