starknet 11.4.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 CHANGED
@@ -1,3 +1,9 @@
1
+ ## [11.4.1](https://github.com/starknet-io/starknet.js/compare/v11.4.0...v11.4.1) (2026-10-20)
2
+
3
+ ### Bug Fixes
4
+
5
+ - **paymaster:** verify the signed hash is the expected outside execution ([a049bc1](https://github.com/starknet-io/starknet.js/commit/a049bc13f63aa209d6378351954fc0219ee122df))
6
+
1
7
  # [11.4.0](https://github.com/starknet-io/starknet.js/compare/v11.3.0...v11.4.0) (2026-10-16)
2
8
 
3
9
  ### Features
package/dist/index.d.ts CHANGED
@@ -9790,7 +9790,17 @@ declare class Account implements AccountInterface {
9790
9790
  accountInvocationsFactory(invocations: Invocations, details: AccountInvocationsFactoryDetails): Promise<AccountInvocations>;
9791
9791
  buildPaymasterTransaction(calls: Call[], paymasterDetails: PaymasterDetails): Promise<PreparedTransaction>;
9792
9792
  estimatePaymasterTransactionFee(calls: Call[], paymasterDetails: PaymasterDetails): Promise<PaymasterFeeEstimate>;
9793
- preparePaymasterTransaction(preparedTransaction: PreparedTransaction): Promise<ExecutableUserTransaction>;
9793
+ /**
9794
+ * Signs a transaction prepared by the paymaster, after checking it is safe to sign. The safety
9795
+ * check needs the calls and the fee details the user actually requested, so a caller that uses
9796
+ * this low-level method directly must pass them, the same way `executePaymasterTransaction`
9797
+ * does.
9798
+ * @param preparedTransaction the transaction returned by the paymaster.
9799
+ * @param calls the calls the user requested.
9800
+ * @param paymasterDetails the fee mode and related paymaster details.
9801
+ * @param maxFeeInGasToken optional user-approved ceiling on the gas-token fee.
9802
+ */
9803
+ preparePaymasterTransaction(preparedTransaction: PreparedTransaction, calls: Call[], paymasterDetails: PaymasterDetails, maxFeeInGasToken?: BigNumberish): Promise<ExecutableUserTransaction>;
9794
9804
  executePaymasterTransaction(calls: Call[], paymasterDetails: PaymasterDetails, maxFeeInGasToken?: BigNumberish): Promise<InvokeFunctionResponse>;
9795
9805
  }
9796
9806
 
@@ -13455,9 +13465,12 @@ declare const getDefaultPaymasterNodeUrl: (networkName?: _NetworkName, mute?: bo
13455
13465
  */
13456
13466
  declare function assertCallsAreStrictlyEqual(originalCalls: Call[], unsafeCalls: (OutsideCallV1 | OutsideCallV2)[], isSponsored?: boolean): void;
13457
13467
  /**
13458
- * Asserts that a paymaster-prepared transaction is safe to sign: the typed-data domain is
13459
- * bound to the account's own chain, and — for non-sponsored transactions — the calls and the
13460
- * appended gas-token transfer match what the user actually requested.
13468
+ * Asserts that a paymaster-prepared transaction is safe to sign. It checks that the typed-data
13469
+ * domain is bound to the account's own chain, and — for non-sponsored transactions — that the
13470
+ * calls and the appended gas-token transfer match what the user asked for. It then rebuilds the
13471
+ * outside execution it expects, from its own SNIP-9 shape and the user's own calls, and checks
13472
+ * that the hash the account would sign is that outside execution and nothing else. When the user
13473
+ * gave time bounds, the signed window must stay inside them.
13461
13474
  * @param {PreparedTransaction} preparedTransaction - The transaction returned by the paymaster.
13462
13475
  * @param {Call[]} calls - The calls originally requested by the user.
13463
13476
  * @param {PaymasterDetails} paymasterDetails - The fee mode and related paymaster details.
@@ -24577,6 +24577,47 @@ ${indent}}` : "}";
24577
24577
  );
24578
24578
  }
24579
24579
  }
24580
+ const msg = message;
24581
+ const version = hasV1Calls ? OutsideExecutionVersion.V1 : OutsideExecutionVersion.V2;
24582
+ const [callerKey, nonceKey, afterKey, beforeKey] = hasV1Calls ? ["caller", "nonce", "execute_after", "execute_before"] : ["Caller", "Nonce", "Execute After", "Execute Before"];
24583
+ assert(
24584
+ [callerKey, nonceKey, afterKey, beforeKey].every((key) => msg[key] !== void 0),
24585
+ "Paymaster typed data does not match the expected outside execution"
24586
+ );
24587
+ const caller = msg[callerKey];
24588
+ const nonce = msg[nonceKey];
24589
+ const executeAfter = msg[afterKey];
24590
+ const executeBefore = msg[beforeKey];
24591
+ if (paymasterDetails.timeBounds) {
24592
+ const requestedAfter = toBigInt(paymasterDetails.timeBounds.executeAfter ?? 1);
24593
+ const requestedBefore = toBigInt(paymasterDetails.timeBounds.executeBefore);
24594
+ assert(
24595
+ toBigInt(executeAfter) >= requestedAfter && toBigInt(executeBefore) <= requestedBefore,
24596
+ "Paymaster typed data execution window is not within the requested time bounds"
24597
+ );
24598
+ }
24599
+ const expectedCalls = [...calls];
24600
+ if (paymasterDetails.feeMode.mode !== "sponsored") {
24601
+ const feeCall = toOutsideCallV2(unsafeCalls[unsafeCalls.length - 1]);
24602
+ const feeRecipient = CallData.toCalldata(feeCall.Calldata)[0];
24603
+ const feeAmount = bnToUint256(preparedTransaction.fee.suggested_max_fee_in_gas_token);
24604
+ expectedCalls.push({
24605
+ contractAddress: paymasterDetails.feeMode.gasToken,
24606
+ entrypoint: "transfer",
24607
+ calldata: [feeRecipient, feeAmount.low, feeAmount.high]
24608
+ });
24609
+ }
24610
+ const expectedTypedData = getTypedData(
24611
+ chainId,
24612
+ { caller, execute_after: executeAfter, execute_before: executeBefore },
24613
+ nonce,
24614
+ expectedCalls,
24615
+ version
24616
+ );
24617
+ assert(
24618
+ getMessageHash(expectedTypedData, 0) === getMessageHash(preparedTransaction.typed_data, 0),
24619
+ "Paymaster typed data does not match the expected outside execution"
24620
+ );
24580
24621
  }
24581
24622
  };
24582
24623
 
@@ -25740,7 +25781,24 @@ ${indent}}` : "}";
25740
25781
  const preparedTransaction = await this.buildPaymasterTransaction(calls, paymasterDetails);
25741
25782
  return preparedTransaction.fee;
25742
25783
  }
25743
- async preparePaymasterTransaction(preparedTransaction) {
25784
+ /**
25785
+ * Signs a transaction prepared by the paymaster, after checking it is safe to sign. The safety
25786
+ * check needs the calls and the fee details the user actually requested, so a caller that uses
25787
+ * this low-level method directly must pass them, the same way `executePaymasterTransaction`
25788
+ * does.
25789
+ * @param preparedTransaction the transaction returned by the paymaster.
25790
+ * @param calls the calls the user requested.
25791
+ * @param paymasterDetails the fee mode and related paymaster details.
25792
+ * @param maxFeeInGasToken optional user-approved ceiling on the gas-token fee.
25793
+ */
25794
+ async preparePaymasterTransaction(preparedTransaction, calls, paymasterDetails, maxFeeInGasToken) {
25795
+ assertPaymasterTransactionSafety(
25796
+ preparedTransaction,
25797
+ calls,
25798
+ paymasterDetails,
25799
+ await this.provider.getChainId(),
25800
+ maxFeeInGasToken
25801
+ );
25744
25802
  let transaction;
25745
25803
  switch (preparedTransaction.type) {
25746
25804
  case "deploy_and_invoke": {
@@ -25782,14 +25840,12 @@ ${indent}}` : "}";
25782
25840
  }
25783
25841
  async executePaymasterTransaction(calls, paymasterDetails, maxFeeInGasToken) {
25784
25842
  const preparedTransaction = await this.buildPaymasterTransaction(calls, paymasterDetails);
25785
- assertPaymasterTransactionSafety(
25843
+ const transaction = await this.preparePaymasterTransaction(
25786
25844
  preparedTransaction,
25787
25845
  calls,
25788
25846
  paymasterDetails,
25789
- await this.provider.getChainId(),
25790
25847
  maxFeeInGasToken
25791
25848
  );
25792
- const transaction = await this.preparePaymasterTransaction(preparedTransaction);
25793
25849
  return this.paymaster.executeTransaction(transaction, preparedTransaction.parameters).then((response) => ({ transaction_hash: response.transaction_hash }));
25794
25850
  }
25795
25851
  };