starknet 10.7.1 → 10.7.2
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 +11 -0
- package/dist/index.d.ts +30 -2
- package/dist/index.global.js +48 -14
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +48 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -11332,9 +11332,12 @@ var getDefaultPaymasterNodeUrl = (networkName, mute = false) => {
|
|
|
11332
11332
|
var assertGasFeeFromUnsafeCalls = (unsafeCalls, fees) => {
|
|
11333
11333
|
const unsafeCall = toOutsideCallV2(unsafeCalls[unsafeCalls.length - 1]);
|
|
11334
11334
|
const unsafeGasTokenCalldata = CallData.toCalldata(unsafeCall.Calldata);
|
|
11335
|
-
const unsafeGasTokenValue =
|
|
11335
|
+
const unsafeGasTokenValue = uint256ToBN({
|
|
11336
|
+
low: unsafeGasTokenCalldata[1],
|
|
11337
|
+
high: unsafeGasTokenCalldata[2]
|
|
11338
|
+
});
|
|
11336
11339
|
assert(
|
|
11337
|
-
|
|
11340
|
+
unsafeGasTokenValue === BigInt(fees),
|
|
11338
11341
|
"Gas token value is not equal to the provided gas fees"
|
|
11339
11342
|
);
|
|
11340
11343
|
};
|
|
@@ -11344,12 +11347,21 @@ var assertGasTokenFromUnsafeCalls = (unsafeCalls, gasToken) => {
|
|
|
11344
11347
|
BigInt(unsafeCall.To) === BigInt(gasToken),
|
|
11345
11348
|
"Gas token address is not equal to the provided gas token"
|
|
11346
11349
|
);
|
|
11350
|
+
assert(
|
|
11351
|
+
unsafeCall.Selector === getSelectorFromName("transfer"),
|
|
11352
|
+
"Gas token call selector is not a transfer"
|
|
11353
|
+
);
|
|
11354
|
+
assert(
|
|
11355
|
+
CallData.toCalldata(unsafeCall.Calldata).length === 3,
|
|
11356
|
+
"Gas token transfer calldata does not match the expected recipient/amount shape"
|
|
11357
|
+
);
|
|
11347
11358
|
};
|
|
11348
|
-
function assertCallsAreStrictlyEqual(originalCalls, unsafeCalls) {
|
|
11359
|
+
function assertCallsAreStrictlyEqual(originalCalls, unsafeCalls, isSponsored = false) {
|
|
11349
11360
|
const baseError = "Provided calls are not strictly equal to the returned calls";
|
|
11361
|
+
const expectedExtraCalls = isSponsored ? 0 : 1;
|
|
11350
11362
|
assert(
|
|
11351
|
-
unsafeCalls.length -
|
|
11352
|
-
`${baseError}: Expected ${originalCalls.length +
|
|
11363
|
+
unsafeCalls.length - expectedExtraCalls === originalCalls.length,
|
|
11364
|
+
`${baseError}: Expected ${originalCalls.length + expectedExtraCalls} calls, got ${unsafeCalls.length}`
|
|
11353
11365
|
);
|
|
11354
11366
|
for (let callIndex = 0; callIndex < originalCalls.length; callIndex += 1) {
|
|
11355
11367
|
const originalCall = originalCalls[callIndex];
|
|
@@ -11383,21 +11395,42 @@ function assertCallsAreStrictlyEqual(originalCalls, unsafeCalls) {
|
|
|
11383
11395
|
}
|
|
11384
11396
|
}
|
|
11385
11397
|
}
|
|
11386
|
-
var
|
|
11387
|
-
|
|
11388
|
-
|
|
11389
|
-
|
|
11390
|
-
|
|
11398
|
+
var domainFieldToFelt = (value) => {
|
|
11399
|
+
try {
|
|
11400
|
+
return toBigInt(value);
|
|
11401
|
+
} catch {
|
|
11402
|
+
return toBigInt(encodeShortString(String(value)));
|
|
11403
|
+
}
|
|
11404
|
+
};
|
|
11405
|
+
var assertChainIdFromTypedData = (typedData, chainId) => {
|
|
11406
|
+
assert(
|
|
11407
|
+
typedData.domain.chainId !== void 0 && domainFieldToFelt(typedData.domain.chainId) === BigInt(chainId),
|
|
11408
|
+
"Paymaster typed data domain chainId does not match the account's provider chain"
|
|
11409
|
+
);
|
|
11410
|
+
};
|
|
11411
|
+
var assertPaymasterTransactionSafety = (preparedTransaction, calls, paymasterDetails, chainId, maxFeeInGasToken) => {
|
|
11412
|
+
if (preparedTransaction.type === "invoke" || preparedTransaction.type === "deploy_and_invoke") {
|
|
11413
|
+
assertChainIdFromTypedData(preparedTransaction.typed_data, chainId);
|
|
11414
|
+
const { message } = preparedTransaction.typed_data;
|
|
11415
|
+
const hasV1Calls = "calls" in message;
|
|
11416
|
+
const hasV2Calls = "Calls" in message;
|
|
11417
|
+
assert(
|
|
11418
|
+
hasV1Calls !== hasV2Calls,
|
|
11419
|
+
'Paymaster typed data must declare exactly one of "calls" (SNIP-9 V1) or "Calls" (SNIP-9 V2)'
|
|
11420
|
+
);
|
|
11421
|
+
const unsafeCalls = hasV1Calls ? message.calls : message.Calls;
|
|
11422
|
+
assertCallsAreStrictlyEqual(calls, unsafeCalls, paymasterDetails.feeMode.mode === "sponsored");
|
|
11423
|
+
if (paymasterDetails.feeMode.mode !== "sponsored") {
|
|
11391
11424
|
assertGasTokenFromUnsafeCalls(unsafeCalls, paymasterDetails.feeMode.gasToken);
|
|
11425
|
+
assertGasFeeFromUnsafeCalls(
|
|
11426
|
+
unsafeCalls,
|
|
11427
|
+
preparedTransaction.fee.suggested_max_fee_in_gas_token
|
|
11428
|
+
);
|
|
11392
11429
|
if (maxFeeInGasToken) {
|
|
11393
11430
|
assert(
|
|
11394
11431
|
preparedTransaction.fee.suggested_max_fee_in_gas_token <= maxFeeInGasToken,
|
|
11395
11432
|
"Gas token price is too high"
|
|
11396
11433
|
);
|
|
11397
|
-
assertGasFeeFromUnsafeCalls(
|
|
11398
|
-
unsafeCalls,
|
|
11399
|
-
preparedTransaction.fee.suggested_max_fee_in_gas_token
|
|
11400
|
-
);
|
|
11401
11434
|
}
|
|
11402
11435
|
}
|
|
11403
11436
|
}
|
|
@@ -12522,6 +12555,7 @@ var Account = class {
|
|
|
12522
12555
|
preparedTransaction,
|
|
12523
12556
|
calls,
|
|
12524
12557
|
paymasterDetails,
|
|
12558
|
+
await this.provider.getChainId(),
|
|
12525
12559
|
maxFeeInGasToken
|
|
12526
12560
|
);
|
|
12527
12561
|
const transaction = await this.preparePaymasterTransaction(preparedTransaction);
|