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.js
CHANGED
|
@@ -11517,9 +11517,12 @@ var getDefaultPaymasterNodeUrl = (networkName, mute = false) => {
|
|
|
11517
11517
|
var assertGasFeeFromUnsafeCalls = (unsafeCalls, fees) => {
|
|
11518
11518
|
const unsafeCall = toOutsideCallV2(unsafeCalls[unsafeCalls.length - 1]);
|
|
11519
11519
|
const unsafeGasTokenCalldata = CallData.toCalldata(unsafeCall.Calldata);
|
|
11520
|
-
const unsafeGasTokenValue =
|
|
11520
|
+
const unsafeGasTokenValue = uint256ToBN({
|
|
11521
|
+
low: unsafeGasTokenCalldata[1],
|
|
11522
|
+
high: unsafeGasTokenCalldata[2]
|
|
11523
|
+
});
|
|
11521
11524
|
assert(
|
|
11522
|
-
|
|
11525
|
+
unsafeGasTokenValue === BigInt(fees),
|
|
11523
11526
|
"Gas token value is not equal to the provided gas fees"
|
|
11524
11527
|
);
|
|
11525
11528
|
};
|
|
@@ -11529,12 +11532,21 @@ var assertGasTokenFromUnsafeCalls = (unsafeCalls, gasToken) => {
|
|
|
11529
11532
|
BigInt(unsafeCall.To) === BigInt(gasToken),
|
|
11530
11533
|
"Gas token address is not equal to the provided gas token"
|
|
11531
11534
|
);
|
|
11535
|
+
assert(
|
|
11536
|
+
unsafeCall.Selector === getSelectorFromName("transfer"),
|
|
11537
|
+
"Gas token call selector is not a transfer"
|
|
11538
|
+
);
|
|
11539
|
+
assert(
|
|
11540
|
+
CallData.toCalldata(unsafeCall.Calldata).length === 3,
|
|
11541
|
+
"Gas token transfer calldata does not match the expected recipient/amount shape"
|
|
11542
|
+
);
|
|
11532
11543
|
};
|
|
11533
|
-
function assertCallsAreStrictlyEqual(originalCalls, unsafeCalls) {
|
|
11544
|
+
function assertCallsAreStrictlyEqual(originalCalls, unsafeCalls, isSponsored = false) {
|
|
11534
11545
|
const baseError = "Provided calls are not strictly equal to the returned calls";
|
|
11546
|
+
const expectedExtraCalls = isSponsored ? 0 : 1;
|
|
11535
11547
|
assert(
|
|
11536
|
-
unsafeCalls.length -
|
|
11537
|
-
`${baseError}: Expected ${originalCalls.length +
|
|
11548
|
+
unsafeCalls.length - expectedExtraCalls === originalCalls.length,
|
|
11549
|
+
`${baseError}: Expected ${originalCalls.length + expectedExtraCalls} calls, got ${unsafeCalls.length}`
|
|
11538
11550
|
);
|
|
11539
11551
|
for (let callIndex = 0; callIndex < originalCalls.length; callIndex += 1) {
|
|
11540
11552
|
const originalCall = originalCalls[callIndex];
|
|
@@ -11568,21 +11580,42 @@ function assertCallsAreStrictlyEqual(originalCalls, unsafeCalls) {
|
|
|
11568
11580
|
}
|
|
11569
11581
|
}
|
|
11570
11582
|
}
|
|
11571
|
-
var
|
|
11572
|
-
|
|
11573
|
-
|
|
11574
|
-
|
|
11575
|
-
|
|
11583
|
+
var domainFieldToFelt = (value) => {
|
|
11584
|
+
try {
|
|
11585
|
+
return toBigInt(value);
|
|
11586
|
+
} catch {
|
|
11587
|
+
return toBigInt(encodeShortString(String(value)));
|
|
11588
|
+
}
|
|
11589
|
+
};
|
|
11590
|
+
var assertChainIdFromTypedData = (typedData, chainId) => {
|
|
11591
|
+
assert(
|
|
11592
|
+
typedData.domain.chainId !== void 0 && domainFieldToFelt(typedData.domain.chainId) === BigInt(chainId),
|
|
11593
|
+
"Paymaster typed data domain chainId does not match the account's provider chain"
|
|
11594
|
+
);
|
|
11595
|
+
};
|
|
11596
|
+
var assertPaymasterTransactionSafety = (preparedTransaction, calls, paymasterDetails, chainId, maxFeeInGasToken) => {
|
|
11597
|
+
if (preparedTransaction.type === "invoke" || preparedTransaction.type === "deploy_and_invoke") {
|
|
11598
|
+
assertChainIdFromTypedData(preparedTransaction.typed_data, chainId);
|
|
11599
|
+
const { message } = preparedTransaction.typed_data;
|
|
11600
|
+
const hasV1Calls = "calls" in message;
|
|
11601
|
+
const hasV2Calls = "Calls" in message;
|
|
11602
|
+
assert(
|
|
11603
|
+
hasV1Calls !== hasV2Calls,
|
|
11604
|
+
'Paymaster typed data must declare exactly one of "calls" (SNIP-9 V1) or "Calls" (SNIP-9 V2)'
|
|
11605
|
+
);
|
|
11606
|
+
const unsafeCalls = hasV1Calls ? message.calls : message.Calls;
|
|
11607
|
+
assertCallsAreStrictlyEqual(calls, unsafeCalls, paymasterDetails.feeMode.mode === "sponsored");
|
|
11608
|
+
if (paymasterDetails.feeMode.mode !== "sponsored") {
|
|
11576
11609
|
assertGasTokenFromUnsafeCalls(unsafeCalls, paymasterDetails.feeMode.gasToken);
|
|
11610
|
+
assertGasFeeFromUnsafeCalls(
|
|
11611
|
+
unsafeCalls,
|
|
11612
|
+
preparedTransaction.fee.suggested_max_fee_in_gas_token
|
|
11613
|
+
);
|
|
11577
11614
|
if (maxFeeInGasToken) {
|
|
11578
11615
|
assert(
|
|
11579
11616
|
preparedTransaction.fee.suggested_max_fee_in_gas_token <= maxFeeInGasToken,
|
|
11580
11617
|
"Gas token price is too high"
|
|
11581
11618
|
);
|
|
11582
|
-
assertGasFeeFromUnsafeCalls(
|
|
11583
|
-
unsafeCalls,
|
|
11584
|
-
preparedTransaction.fee.suggested_max_fee_in_gas_token
|
|
11585
|
-
);
|
|
11586
11619
|
}
|
|
11587
11620
|
}
|
|
11588
11621
|
}
|
|
@@ -12707,6 +12740,7 @@ var Account = class {
|
|
|
12707
12740
|
preparedTransaction,
|
|
12708
12741
|
calls,
|
|
12709
12742
|
paymasterDetails,
|
|
12743
|
+
await this.provider.getChainId(),
|
|
12710
12744
|
maxFeeInGasToken
|
|
12711
12745
|
);
|
|
12712
12746
|
const transaction = await this.preparePaymasterTransaction(preparedTransaction);
|