@tetherto/wdk-wallet-evm-erc-4337 1.0.0-beta.14 → 1.0.0-beta.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tetherto/wdk-wallet-evm-erc-4337",
3
- "version": "1.0.0-beta.14",
3
+ "version": "1.0.0-beta.15",
4
4
  "description": "A simple package to manage BIP-32 wallets for evm blockchains, which implement the erc-4337 standard and its account abstraction features",
5
5
  "keywords": [
6
6
  "wdk",
@@ -42,7 +42,7 @@
42
42
  "@pimlico/mock-paymaster": "0.0.4",
43
43
  "concurrently": "9.2.0",
44
44
  "cross-env": "7.0.3",
45
- "hardhat": "3.9.1",
45
+ "hardhat": "3.12.0",
46
46
  "jest": "29.7.0",
47
47
  "prool": "0.0.23",
48
48
  "standard": "17.1.2",
@@ -316,6 +316,7 @@ export default class WalletAccountReadOnlyEvmErc4337 extends WalletAccountReadOn
316
316
  * @param {Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>} [config] - If set, overrides the given configuration options.
317
317
  * @returns {Promise<Omit<TransactionResult, 'hash'>>} The transaction's quotes.
318
318
  * @throws {ConfigurationError} If the override `config` is invalid or has missing required fields.
319
+ * @throws {ConfigurationError} If, in token mode, the configured `paymasterAddress` does not match the paymaster address returned by the paymaster RPC. This guards against the auto-generated ERC-20 approval targeting an unexpected paymaster contract.
319
320
  * @throws {Error} If the token paymaster reports AA50 (account does not hold the paymaster token).
320
321
  */
321
322
  async quoteSendTransaction (tx, config) {
@@ -349,6 +350,7 @@ export default class WalletAccountReadOnlyEvmErc4337 extends WalletAccountReadOn
349
350
  * @param {EvmErc4337GasOverrides} [txOverrides] - If set, applies these UserOperationV7 gas/fee overrides to the underlying transaction.
350
351
  * @returns {Promise<Omit<TransferResult, 'hash'>>} The transfer's quotes.
351
352
  * @throws {ConfigurationError} If the override `config` is invalid or has missing required fields.
353
+ * @throws {ConfigurationError} If, in token mode, the configured `paymasterAddress` does not match the paymaster address returned by the paymaster RPC. This guards against the auto-generated ERC-20 approval targeting an unexpected paymaster contract.
352
354
  * @throws {Error} If the token paymaster reports AA50 (account does not hold the paymaster token).
353
355
  */
354
356
  async quoteTransfer (options, config, txOverrides) {
@@ -775,6 +777,16 @@ export default class WalletAccountReadOnlyEvmErc4337 extends WalletAccountReadOn
775
777
  paymasterOverrides
776
778
  )
777
779
 
778
- return { userOp: result.userOperation, tokenQuote: result.tokenQuote }
780
+ const sponsoredOp = result.userOperation
781
+
782
+ if (mode === PaymasterMode.TOKEN && sponsoredOp.paymaster &&
783
+ sponsoredOp.paymaster.toLowerCase() !== config.paymasterAddress.toLowerCase()) {
784
+ throw new ConfigurationError(
785
+ `paymasterAddress mismatch: configured ${config.paymasterAddress} but RPC ${config.paymasterUrl} returned ${sponsoredOp.paymaster}. ` +
786
+ 'The generated ERC-20 approval would target an unexpected paymaster.'
787
+ )
788
+ }
789
+
790
+ return { userOp: sponsoredOp, tokenQuote: result.tokenQuote }
779
791
  }
780
792
  }