starknet 11.3.0 → 11.4.1
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 +12 -0
- package/dist/falcon/index.d.ts +352 -0
- package/dist/falcon/index.js +3736 -0
- package/dist/falcon/index.js.map +1 -0
- package/dist/falcon/index.mjs +3723 -0
- package/dist/falcon/index.mjs.map +1 -0
- package/dist/index.d.ts +17 -4
- package/dist/index.global.js +60 -4
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +60 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -1
package/dist/index.js
CHANGED
|
@@ -19028,6 +19028,47 @@ var assertPaymasterTransactionSafety = (preparedTransaction, calls, paymasterDet
|
|
|
19028
19028
|
);
|
|
19029
19029
|
}
|
|
19030
19030
|
}
|
|
19031
|
+
const msg = message;
|
|
19032
|
+
const version = hasV1Calls ? OutsideExecutionVersion.V1 : OutsideExecutionVersion.V2;
|
|
19033
|
+
const [callerKey, nonceKey, afterKey, beforeKey] = hasV1Calls ? ["caller", "nonce", "execute_after", "execute_before"] : ["Caller", "Nonce", "Execute After", "Execute Before"];
|
|
19034
|
+
assert(
|
|
19035
|
+
[callerKey, nonceKey, afterKey, beforeKey].every((key) => msg[key] !== void 0),
|
|
19036
|
+
"Paymaster typed data does not match the expected outside execution"
|
|
19037
|
+
);
|
|
19038
|
+
const caller = msg[callerKey];
|
|
19039
|
+
const nonce = msg[nonceKey];
|
|
19040
|
+
const executeAfter = msg[afterKey];
|
|
19041
|
+
const executeBefore = msg[beforeKey];
|
|
19042
|
+
if (paymasterDetails.timeBounds) {
|
|
19043
|
+
const requestedAfter = toBigInt(paymasterDetails.timeBounds.executeAfter ?? 1);
|
|
19044
|
+
const requestedBefore = toBigInt(paymasterDetails.timeBounds.executeBefore);
|
|
19045
|
+
assert(
|
|
19046
|
+
toBigInt(executeAfter) >= requestedAfter && toBigInt(executeBefore) <= requestedBefore,
|
|
19047
|
+
"Paymaster typed data execution window is not within the requested time bounds"
|
|
19048
|
+
);
|
|
19049
|
+
}
|
|
19050
|
+
const expectedCalls = [...calls];
|
|
19051
|
+
if (paymasterDetails.feeMode.mode !== "sponsored") {
|
|
19052
|
+
const feeCall = toOutsideCallV2(unsafeCalls[unsafeCalls.length - 1]);
|
|
19053
|
+
const feeRecipient = CallData.toCalldata(feeCall.Calldata)[0];
|
|
19054
|
+
const feeAmount = bnToUint256(preparedTransaction.fee.suggested_max_fee_in_gas_token);
|
|
19055
|
+
expectedCalls.push({
|
|
19056
|
+
contractAddress: paymasterDetails.feeMode.gasToken,
|
|
19057
|
+
entrypoint: "transfer",
|
|
19058
|
+
calldata: [feeRecipient, feeAmount.low, feeAmount.high]
|
|
19059
|
+
});
|
|
19060
|
+
}
|
|
19061
|
+
const expectedTypedData = getTypedData(
|
|
19062
|
+
chainId,
|
|
19063
|
+
{ caller, execute_after: executeAfter, execute_before: executeBefore },
|
|
19064
|
+
nonce,
|
|
19065
|
+
expectedCalls,
|
|
19066
|
+
version
|
|
19067
|
+
);
|
|
19068
|
+
assert(
|
|
19069
|
+
getMessageHash(expectedTypedData, 0) === getMessageHash(preparedTransaction.typed_data, 0),
|
|
19070
|
+
"Paymaster typed data does not match the expected outside execution"
|
|
19071
|
+
);
|
|
19031
19072
|
}
|
|
19032
19073
|
};
|
|
19033
19074
|
|
|
@@ -20191,7 +20232,24 @@ var Account = class {
|
|
|
20191
20232
|
const preparedTransaction = await this.buildPaymasterTransaction(calls, paymasterDetails);
|
|
20192
20233
|
return preparedTransaction.fee;
|
|
20193
20234
|
}
|
|
20194
|
-
|
|
20235
|
+
/**
|
|
20236
|
+
* Signs a transaction prepared by the paymaster, after checking it is safe to sign. The safety
|
|
20237
|
+
* check needs the calls and the fee details the user actually requested, so a caller that uses
|
|
20238
|
+
* this low-level method directly must pass them, the same way `executePaymasterTransaction`
|
|
20239
|
+
* does.
|
|
20240
|
+
* @param preparedTransaction the transaction returned by the paymaster.
|
|
20241
|
+
* @param calls the calls the user requested.
|
|
20242
|
+
* @param paymasterDetails the fee mode and related paymaster details.
|
|
20243
|
+
* @param maxFeeInGasToken optional user-approved ceiling on the gas-token fee.
|
|
20244
|
+
*/
|
|
20245
|
+
async preparePaymasterTransaction(preparedTransaction, calls, paymasterDetails, maxFeeInGasToken) {
|
|
20246
|
+
assertPaymasterTransactionSafety(
|
|
20247
|
+
preparedTransaction,
|
|
20248
|
+
calls,
|
|
20249
|
+
paymasterDetails,
|
|
20250
|
+
await this.provider.getChainId(),
|
|
20251
|
+
maxFeeInGasToken
|
|
20252
|
+
);
|
|
20195
20253
|
let transaction;
|
|
20196
20254
|
switch (preparedTransaction.type) {
|
|
20197
20255
|
case "deploy_and_invoke": {
|
|
@@ -20233,14 +20291,12 @@ var Account = class {
|
|
|
20233
20291
|
}
|
|
20234
20292
|
async executePaymasterTransaction(calls, paymasterDetails, maxFeeInGasToken) {
|
|
20235
20293
|
const preparedTransaction = await this.buildPaymasterTransaction(calls, paymasterDetails);
|
|
20236
|
-
|
|
20294
|
+
const transaction = await this.preparePaymasterTransaction(
|
|
20237
20295
|
preparedTransaction,
|
|
20238
20296
|
calls,
|
|
20239
20297
|
paymasterDetails,
|
|
20240
|
-
await this.provider.getChainId(),
|
|
20241
20298
|
maxFeeInGasToken
|
|
20242
20299
|
);
|
|
20243
|
-
const transaction = await this.preparePaymasterTransaction(preparedTransaction);
|
|
20244
20300
|
return this.paymaster.executeTransaction(transaction, preparedTransaction.parameters).then((response) => ({ transaction_hash: response.transaction_hash }));
|
|
20245
20301
|
}
|
|
20246
20302
|
};
|