@lifi/sdk-provider-ethereum 0.0.0-preview-c996a5fb → 0.0.0-preview-e8c80bc4

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.
Files changed (153) hide show
  1. package/CHANGELOG.md +24 -3
  2. package/dist/cjs/actions/checkPermitSupport.js +2 -2
  3. package/dist/cjs/actions/checkPermitSupport.js.map +1 -1
  4. package/dist/cjs/actions/getAllowance.d.ts +1 -1
  5. package/dist/cjs/actions/getAllowance.js +4 -4
  6. package/dist/cjs/actions/getAllowance.js.map +1 -1
  7. package/dist/cjs/actions/getMaxPriorityFeePerGas.d.ts +1 -1
  8. package/dist/cjs/actions/getMaxPriorityFeePerGas.js +2 -2
  9. package/dist/cjs/actions/getMaxPriorityFeePerGas.js.map +1 -1
  10. package/dist/cjs/actions/isSafeSignature.d.ts +1 -1
  11. package/dist/cjs/actions/isSafeSignature.js +2 -1
  12. package/dist/cjs/actions/isSafeSignature.js.map +1 -1
  13. package/dist/cjs/actions/resolveTransactionHash.js +6 -2
  14. package/dist/cjs/actions/resolveTransactionHash.js.map +1 -1
  15. package/dist/cjs/actions/setAllowance.d.ts +2 -2
  16. package/dist/cjs/actions/setAllowance.js +9 -5
  17. package/dist/cjs/actions/setAllowance.js.map +1 -1
  18. package/dist/cjs/actions/waitForRelayedTransactionReceipt.js.map +1 -1
  19. package/dist/cjs/core/tasks/EthereumBatchedSignAndExecuteTask.js +4 -1
  20. package/dist/cjs/core/tasks/EthereumBatchedSignAndExecuteTask.js.map +1 -1
  21. package/dist/cjs/core/tasks/EthereumCheckAllowanceTask.js +2 -2
  22. package/dist/cjs/core/tasks/EthereumCheckAllowanceTask.js.map +1 -1
  23. package/dist/cjs/core/tasks/EthereumNativePermitTask.js +1 -1
  24. package/dist/cjs/core/tasks/EthereumNativePermitTask.js.map +1 -1
  25. package/dist/cjs/core/tasks/EthereumPrepareTransactionTask.js +1 -1
  26. package/dist/cjs/core/tasks/EthereumPrepareTransactionTask.js.map +1 -1
  27. package/dist/cjs/core/tasks/EthereumResetAllowanceTask.js +3 -2
  28. package/dist/cjs/core/tasks/EthereumResetAllowanceTask.js.map +1 -1
  29. package/dist/cjs/core/tasks/EthereumSetAllowanceTask.js +3 -2
  30. package/dist/cjs/core/tasks/EthereumSetAllowanceTask.js.map +1 -1
  31. package/dist/cjs/core/tasks/EthereumStandardSignAndExecuteTask.js +3 -2
  32. package/dist/cjs/core/tasks/EthereumStandardSignAndExecuteTask.js.map +1 -1
  33. package/dist/cjs/core/tasks/helpers/estimateTransactionRequest.d.ts +1 -1
  34. package/dist/cjs/core/tasks/helpers/estimateTransactionRequest.js +2 -2
  35. package/dist/cjs/core/tasks/helpers/estimateTransactionRequest.js.map +1 -1
  36. package/dist/cjs/core/tasks/helpers/getEthereumExecutionStrategy.js +3 -2
  37. package/dist/cjs/core/tasks/helpers/getEthereumExecutionStrategy.js.map +1 -1
  38. package/dist/cjs/errors/parseEthereumErrors.js +2 -1
  39. package/dist/cjs/errors/parseEthereumErrors.js.map +1 -1
  40. package/dist/cjs/permits/allowanceTransfer.js.map +1 -1
  41. package/dist/cjs/permits/getNativePermit.js +4 -4
  42. package/dist/cjs/permits/getNativePermit.js.map +1 -1
  43. package/dist/cjs/permits/getPermitTransferFromValues.js +1 -1
  44. package/dist/cjs/permits/getPermitTransferFromValues.js.map +1 -1
  45. package/dist/cjs/permits/isNativePermitValid.js +1 -1
  46. package/dist/cjs/permits/isNativePermitValid.js.map +1 -1
  47. package/dist/cjs/types.d.ts +6 -0
  48. package/dist/cjs/types.js.map +1 -1
  49. package/dist/cjs/utils/getActionWithFallback.d.ts +2 -1
  50. package/dist/cjs/utils/getActionWithFallback.js +2 -2
  51. package/dist/cjs/utils/getActionWithFallback.js.map +1 -1
  52. package/dist/cjs/utils/getSendChain.d.ts +2 -0
  53. package/dist/cjs/utils/getSendChain.js +6 -0
  54. package/dist/cjs/utils/getSendChain.js.map +1 -0
  55. package/dist/cjs/version.d.ts +1 -1
  56. package/dist/cjs/version.js +1 -1
  57. package/dist/cjs/version.js.map +1 -1
  58. package/dist/esm/actions/checkPermitSupport.js +2 -2
  59. package/dist/esm/actions/checkPermitSupport.js.map +1 -1
  60. package/dist/esm/actions/getAllowance.d.ts +1 -1
  61. package/dist/esm/actions/getAllowance.d.ts.map +1 -1
  62. package/dist/esm/actions/getAllowance.js +4 -4
  63. package/dist/esm/actions/getAllowance.js.map +1 -1
  64. package/dist/esm/actions/getMaxPriorityFeePerGas.d.ts +1 -1
  65. package/dist/esm/actions/getMaxPriorityFeePerGas.d.ts.map +1 -1
  66. package/dist/esm/actions/getMaxPriorityFeePerGas.js +2 -2
  67. package/dist/esm/actions/getMaxPriorityFeePerGas.js.map +1 -1
  68. package/dist/esm/actions/isSafeSignature.d.ts +1 -1
  69. package/dist/esm/actions/isSafeSignature.js +2 -1
  70. package/dist/esm/actions/isSafeSignature.js.map +1 -1
  71. package/dist/esm/actions/resolveTransactionHash.js +6 -2
  72. package/dist/esm/actions/resolveTransactionHash.js.map +1 -1
  73. package/dist/esm/actions/setAllowance.d.ts +2 -2
  74. package/dist/esm/actions/setAllowance.d.ts.map +1 -1
  75. package/dist/esm/actions/setAllowance.js +9 -5
  76. package/dist/esm/actions/setAllowance.js.map +1 -1
  77. package/dist/esm/actions/waitForRelayedTransactionReceipt.js.map +1 -1
  78. package/dist/esm/core/tasks/EthereumBatchedSignAndExecuteTask.d.ts.map +1 -1
  79. package/dist/esm/core/tasks/EthereumBatchedSignAndExecuteTask.js +4 -1
  80. package/dist/esm/core/tasks/EthereumBatchedSignAndExecuteTask.js.map +1 -1
  81. package/dist/esm/core/tasks/EthereumCheckAllowanceTask.js +2 -2
  82. package/dist/esm/core/tasks/EthereumCheckAllowanceTask.js.map +1 -1
  83. package/dist/esm/core/tasks/EthereumNativePermitTask.js +1 -1
  84. package/dist/esm/core/tasks/EthereumNativePermitTask.js.map +1 -1
  85. package/dist/esm/core/tasks/EthereumPrepareTransactionTask.js +1 -1
  86. package/dist/esm/core/tasks/EthereumPrepareTransactionTask.js.map +1 -1
  87. package/dist/esm/core/tasks/EthereumResetAllowanceTask.d.ts.map +1 -1
  88. package/dist/esm/core/tasks/EthereumResetAllowanceTask.js +3 -2
  89. package/dist/esm/core/tasks/EthereumResetAllowanceTask.js.map +1 -1
  90. package/dist/esm/core/tasks/EthereumSetAllowanceTask.d.ts.map +1 -1
  91. package/dist/esm/core/tasks/EthereumSetAllowanceTask.js +3 -2
  92. package/dist/esm/core/tasks/EthereumSetAllowanceTask.js.map +1 -1
  93. package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.d.ts.map +1 -1
  94. package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.js +3 -2
  95. package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.js.map +1 -1
  96. package/dist/esm/core/tasks/helpers/estimateTransactionRequest.d.ts +1 -1
  97. package/dist/esm/core/tasks/helpers/estimateTransactionRequest.d.ts.map +1 -1
  98. package/dist/esm/core/tasks/helpers/estimateTransactionRequest.js +2 -2
  99. package/dist/esm/core/tasks/helpers/estimateTransactionRequest.js.map +1 -1
  100. package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.js +3 -2
  101. package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.js.map +1 -1
  102. package/dist/esm/errors/parseEthereumErrors.d.ts.map +1 -1
  103. package/dist/esm/errors/parseEthereumErrors.js +3 -2
  104. package/dist/esm/errors/parseEthereumErrors.js.map +1 -1
  105. package/dist/esm/permits/allowanceTransfer.js.map +1 -1
  106. package/dist/esm/permits/getNativePermit.d.ts.map +1 -1
  107. package/dist/esm/permits/getNativePermit.js +4 -4
  108. package/dist/esm/permits/getNativePermit.js.map +1 -1
  109. package/dist/esm/permits/getPermitTransferFromValues.js +1 -1
  110. package/dist/esm/permits/getPermitTransferFromValues.js.map +1 -1
  111. package/dist/esm/permits/isNativePermitValid.js +1 -1
  112. package/dist/esm/permits/isNativePermitValid.js.map +1 -1
  113. package/dist/esm/types.d.ts +6 -0
  114. package/dist/esm/types.d.ts.map +1 -1
  115. package/dist/esm/types.js.map +1 -1
  116. package/dist/esm/utils/getActionWithFallback.d.ts +2 -1
  117. package/dist/esm/utils/getActionWithFallback.d.ts.map +1 -1
  118. package/dist/esm/utils/getActionWithFallback.js +2 -2
  119. package/dist/esm/utils/getActionWithFallback.js.map +1 -1
  120. package/dist/esm/utils/getSendChain.d.ts +3 -0
  121. package/dist/esm/utils/getSendChain.d.ts.map +1 -0
  122. package/dist/esm/utils/getSendChain.js +5 -0
  123. package/dist/esm/utils/getSendChain.js.map +1 -0
  124. package/dist/esm/version.d.ts +1 -1
  125. package/dist/esm/version.js +1 -1
  126. package/dist/esm/version.js.map +1 -1
  127. package/package.json +3 -3
  128. package/src/actions/checkPermitSupport.ts +4 -2
  129. package/src/actions/getAllowance.ts +8 -4
  130. package/src/actions/getMaxPriorityFeePerGas.ts +4 -2
  131. package/src/actions/isSafeSignature.ts +3 -3
  132. package/src/actions/resolveTransactionHash.ts +10 -3
  133. package/src/actions/setAllowance.ts +31 -6
  134. package/src/actions/waitForRelayedTransactionReceipt.ts +17 -16
  135. package/src/core/tasks/EthereumBatchedSignAndExecuteTask.ts +4 -0
  136. package/src/core/tasks/EthereumCheckAllowanceTask.ts +3 -2
  137. package/src/core/tasks/EthereumNativePermitTask.ts +2 -1
  138. package/src/core/tasks/EthereumPrepareTransactionTask.ts +2 -1
  139. package/src/core/tasks/EthereumResetAllowanceTask.ts +4 -2
  140. package/src/core/tasks/EthereumSetAllowanceTask.ts +4 -2
  141. package/src/core/tasks/EthereumStandardSignAndExecuteTask.ts +4 -2
  142. package/src/core/tasks/helpers/estimateTransactionRequest.ts +4 -2
  143. package/src/core/tasks/helpers/getEthereumExecutionStrategy.ts +4 -2
  144. package/src/errors/parseEthereumErrors.ts +11 -2
  145. package/src/index.ts +0 -1
  146. package/src/permits/allowanceTransfer.ts +1 -1
  147. package/src/permits/getNativePermit.ts +9 -5
  148. package/src/permits/getPermitTransferFromValues.ts +2 -1
  149. package/src/permits/isNativePermitValid.ts +1 -1
  150. package/src/types.ts +7 -2
  151. package/src/utils/getActionWithFallback.ts +3 -2
  152. package/src/utils/getSendChain.ts +6 -0
  153. package/src/version.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @lifi/sdk-provider-ethereum
2
2
 
3
- ## 0.0.0-preview-c996a5fb
3
+ ## 0.0.0-preview-e8c80bc4
4
4
 
5
5
  ### Minor Changes
6
6
 
@@ -21,14 +21,35 @@
21
21
 
22
22
  Deprecated (still exported, so that published consumers keep building):
23
23
 
24
- - `getRelayerQuote` in `@lifi/sdk` and in the client actions. The legacy relayer endpoint is shut down. Use `getRoutes` with `options.gasless: true`.
24
+ - `getRelayerQuote` in `@lifi/sdk` and in the client actions. The legacy relayer endpoint is shut down, so it now rejects at once with a `NotFound` error and sends no request. Use `getRoutes` with `options.gasless: true`.
25
25
  - `isGaslessStep(step, chain)` in `@lifi/sdk-provider-ethereum`. It detects only the legacy typed data. Use `isGaslessStep(step)` from `@lifi/sdk`.
26
26
 
27
27
  ### Patch Changes
28
28
 
29
+ - [#545](https://github.com/lifinance/sdk/pull/545) [`37688cc`](https://github.com/lifinance/sdk/commit/37688cc732187f08f429062e506b67dee2a2a30a) Thanks [@chybisov](https://github.com/chybisov)! - Update `tronweb` to 6.5.2.
30
+ Update `viem` to 2.57.19.
31
+
29
32
  - [#539](https://github.com/lifinance/sdk/pull/539) [`b80e5f4`](https://github.com/lifinance/sdk/commit/b80e5f49941190812935644c55d5c9c075bac354) Thanks [@chybisov](https://github.com/chybisov)! - Bump runtime dependencies: @lifi/types to 18.16.0, bitcoinjs-lib to 7.0.5, viem to 2.57.17, @solana/kit to 8.6.0, @stellar/stellar-sdk to 17.4.0, @mysten/sui to 2.39.1.
33
+
34
+ - [#540](https://github.com/lifinance/sdk/pull/540) [`b44c152`](https://github.com/lifinance/sdk/commit/b44c1525f301a7b2c3dfa6ae6d7d337f3ce3847e) Thanks [@chybisov](https://github.com/chybisov)! - When the wallet cannot switch to the step's chain, the step now fails with `ChainSwitchError`, not `UnknownError`. wagmi connectors throw viem's `SwitchChainError` for this, for example for "Unknown Network: eip155:130" or "wallet_switchEthereumChain::chainId 0xe708 not supported". `parseEthereumErrors` runs its existing checks first. So a rejected switch still gives `SignatureRejected`, and a switch error with the code -32000 or -32603 keeps the result that it had before. A raw EIP-1193 error with code 4001 now also gives `SignatureRejected`.
35
+
36
+ - [#540](https://github.com/lifinance/sdk/pull/540) [`b44c152`](https://github.com/lifinance/sdk/commit/b44c1525f301a7b2c3dfa6ae6d7d337f3ce3847e) Thanks [@chybisov](https://github.com/chybisov)! - When a read through the wallet fails, the SDK reads again through a public client. That client now uses the step's chain, not `walletClient.chain`, which can be old. For `setTokenAllowance` and `revokeTokenApproval`, it uses the token's chain. This covers the allowance, permit, gas estimate and priority fee reads.
37
+
38
+ - [#546](https://github.com/lifinance/sdk/pull/546) [`5d236b1`](https://github.com/lifinance/sdk/commit/5d236b1cee56231db6d220af8335d48957f23b9a) Thanks [@chybisov](https://github.com/chybisov)! - Some wallets answer `eth_sendTransaction` with `null`, a value that is not hex, or a value shorter than a transaction hash. The approval, approval reset, swap and bridge steps now throw a `TransactionError` with `TransactionFailed` for this answer.
39
+
40
+ - [#547](https://github.com/lifinance/sdk/pull/547) [`784c1d5`](https://github.com/lifinance/sdk/commit/784c1d5d4a16be7ab97aca75d2b23fa06bc5a540) Thanks [@chybisov](https://github.com/chybisov)! - Read the wallet capabilities (EIP-5792) one time in each run of a step. Before, prepare read them again, and a late or failed read could move the step between `batched` and `standard` after its approval. Then the step failed with `TransactionUnprepared`, or it sent the swap without the correct approval. Now a step whose first read is late or fails stays in `standard`.
41
+
42
+ - [#546](https://github.com/lifinance/sdk/pull/546) [`5d236b1`](https://github.com/lifinance/sdk/commit/5d236b1cee56231db6d220af8335d48957f23b9a) Thanks [@chybisov](https://github.com/chybisov)! - The approval and approval reset steps now wait for the receipt of the transaction that the Safe executes, not of the Safe signature. Before, the steps did not check the receipt of a queued Safe approval.
43
+
44
+ - [#540](https://github.com/lifinance/sdk/pull/540) [`b44c152`](https://github.com/lifinance/sdk/commit/b44c1525f301a7b2c3dfa6ae6d7d337f3ce3847e) Thanks [@chybisov](https://github.com/chybisov)! - A batched send (`wallet_sendCalls`) and an approval or allowance reset now name the step's chain. Before, viem took the chain from `client.chain`. A connector client (for example, from wagmi `getConnectorClient` with `assertChainId: false`) can keep an old chain while the wallet is already on the step's chain. The wallet then rejected the bundle ("Chain ID must match the dApp selected network"), or viem stopped the approval with `ChainMismatchError`. `setAllowance` takes an optional `chain` as its last parameter.
45
+
46
+ - [#540](https://github.com/lifinance/sdk/pull/540) [`b44c152`](https://github.com/lifinance/sdk/commit/b44c1525f301a7b2c3dfa6ae6d7d337f3ce3847e) Thanks [@chybisov](https://github.com/chybisov)! - All sends now use one rule for the chain. When `client.chain` is the step's chain, the send keeps it. Otherwise the send uses the step's chain from the LI.FI API. This covers the main transaction, batched calls, approvals and allowance resets.
47
+
48
+ Before, the main transaction always used the API chain, which has no fee settings or serializers. So a local account lost the fee rules of its chain, for example the HyperEVM base fee multiplier. A matching `client.chain` now also keeps its custom fields and hooks, as viem does when no chain is given.
49
+
50
+ `setTokenAllowance` and `revokeTokenApproval` now send on the token's chain. An old `walletClient.chain` no longer makes them fail with `ChainMismatchError`. If the wallet is really on another chain than the token, they now fail with `ChainMismatchError`. Before, they sent the approval on the wallet's chain. To find the token's chain, they read the chain list, which can load it from the API the first time.
30
51
  - Updated dependencies [[`b80e5f4`](https://github.com/lifinance/sdk/commit/b80e5f49941190812935644c55d5c9c075bac354), [`de384d3`](https://github.com/lifinance/sdk/commit/de384d3fffbe0f87f73f268529b8f528cf2c4a8b)]:
31
- - @lifi/sdk@0.0.0-preview-c996a5fb
52
+ - @lifi/sdk@0.0.0-preview-e8c80bc4
32
53
 
33
54
  ## 4.2.12
34
55
 
@@ -31,12 +31,12 @@ const checkPermitSupport = async (client, { chain, tokenAddress, ownerAddress, a
31
31
  spenderAddress: chain.permit2Proxy,
32
32
  amount,
33
33
  ownerAddress
34
- });
34
+ }, chain.id);
35
35
  let permit2Allowance;
36
36
  if (chain.permit2 && await require_permits_canAccountUsePermit2.canAccountUsePermit2(client, {
37
37
  chainId: chain.id,
38
38
  address: ownerAddress
39
- })) permit2Allowance = await require_actions_getAllowance.getAllowance(client, viemClient, tokenAddress, ownerAddress, chain.permit2);
39
+ })) permit2Allowance = await require_actions_getAllowance.getAllowance(client, viemClient, tokenAddress, ownerAddress, chain.permit2, chain.id);
40
40
  return {
41
41
  nativePermitSupported: !!nativePermit,
42
42
  permit2AllowanceSufficient: !!permit2Allowance && permit2Allowance >= amount
@@ -1 +1 @@
1
- {"version":3,"file":"checkPermitSupport.js","names":["ChainType","getPublicClient","getActionWithFallback","getNativePermit","canAccountUsePermit2","getAllowance"],"sources":["../../../src/actions/checkPermitSupport.ts"],"sourcesContent":["import { ChainType, type ExtendedChain, type SDKClient } from '@lifi/sdk'\nimport type { Address } from 'viem'\nimport { getPublicClient } from '../client/publicClient.js'\nimport { canAccountUsePermit2 } from '../permits/canAccountUsePermit2.js'\nimport { getNativePermit } from '../permits/getNativePermit.js'\nimport type { EthereumSDKProvider } from '../types.js'\nimport { getActionWithFallback } from '../utils/getActionWithFallback.js'\nimport { getAllowance } from './getAllowance.js'\n\ntype PermitSupport = {\n /** Whether the token supports EIP-2612 native permits */\n nativePermitSupported: boolean\n /** Whether Permit2 is available and has sufficient allowance */\n permit2AllowanceSufficient: boolean\n}\n\n/**\n * Checks what permit types are *usable* for a token on a specific chain.\n * Checks in order:\n * 1. Native permit (EIP-2612) support\n * 2. Permit2 — deployed on the chain, signable by the owner (see\n * `canAccountUsePermit2`), and allowance sufficient\n *\n * @param client - The SDK client\n * @param chain - The chain to check permit support on\n * @param tokenAddress - The token address to check\n * @param ownerAddress - The address that would sign the permit\n * @param amount - The amount to check allowance against for Permit2\n * @returns Object indicating which permit types are supported\n */\nexport const checkPermitSupport = async (\n client: SDKClient,\n {\n chain,\n tokenAddress,\n ownerAddress,\n amount,\n }: {\n chain: ExtendedChain\n tokenAddress: Address\n ownerAddress: Address\n amount: bigint\n }\n): Promise<PermitSupport> => {\n const provider = client.getProvider(ChainType.EVM) as\n | EthereumSDKProvider\n | undefined\n let viemClient = await provider?.getWalletClient?.()\n\n if (!viemClient) {\n viemClient = await getPublicClient(client, chain.id)\n }\n\n const nativePermit = await getActionWithFallback(\n client,\n viemClient,\n getNativePermit,\n 'getNativePermit',\n {\n client,\n viemClient,\n chainId: chain.id,\n tokenAddress,\n spenderAddress: chain.permit2Proxy as Address,\n amount,\n ownerAddress,\n }\n )\n\n let permit2Allowance: bigint | undefined\n // Only read the allowance if the owner can sign for it: Permit2 may reject an\n // account with code via EIP-1271, making any allowance unusable.\n //\n // An EIP-7702 owner is probed twice here, once per gate. The two run\n // sequentially, so `withDedupe` would not collapse them, and caching the\n // verdict would defeat the deliberate freshness of `getAccountCode`. Two\n // `eth_call`s on an already multi-RPC action is the cheaper trade.\n if (\n chain.permit2 &&\n (await canAccountUsePermit2(client, {\n chainId: chain.id,\n address: ownerAddress,\n }))\n ) {\n permit2Allowance = await getAllowance(\n client,\n viemClient,\n tokenAddress,\n ownerAddress,\n chain.permit2 as Address\n )\n }\n\n return {\n nativePermitSupported: !!nativePermit,\n permit2AllowanceSufficient:\n !!permit2Allowance && permit2Allowance >= amount,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,qBAAqB,OAChC,QACA,EACE,OACA,cACA,cACA,aAOyB;CAI3B,IAAI,aAAa,MAHA,OAAO,YAAYA,UAAAA,UAAU,GAGhB,CAAC,EAAE,kBAAkB;CAEnD,IAAI,CAAC,YACH,aAAa,MAAMC,4BAAAA,gBAAgB,QAAQ,MAAM,EAAE;CAGrD,MAAM,eAAe,MAAMC,oCAAAA,sBACzB,QACA,YACAC,gCAAAA,iBACA,mBACA;EACE;EACA;EACA,SAAS,MAAM;EACf;EACA,gBAAgB,MAAM;EACtB;EACA;CACF,CACF;CAEA,IAAI;CAQJ,IACE,MAAM,WACL,MAAMC,qCAAAA,qBAAqB,QAAQ;EAClC,SAAS,MAAM;EACf,SAAS;CACX,CAAC,GAED,mBAAmB,MAAMC,6BAAAA,aACvB,QACA,YACA,cACA,cACA,MAAM,OACR;CAGF,OAAO;EACL,uBAAuB,CAAC,CAAC;EACzB,4BACE,CAAC,CAAC,oBAAoB,oBAAoB;CAC9C;AACF"}
1
+ {"version":3,"file":"checkPermitSupport.js","names":["ChainType","getPublicClient","getActionWithFallback","getNativePermit","canAccountUsePermit2","getAllowance"],"sources":["../../../src/actions/checkPermitSupport.ts"],"sourcesContent":["import { ChainType, type ExtendedChain, type SDKClient } from '@lifi/sdk'\nimport type { Address } from 'viem'\nimport { getPublicClient } from '../client/publicClient.js'\nimport { canAccountUsePermit2 } from '../permits/canAccountUsePermit2.js'\nimport { getNativePermit } from '../permits/getNativePermit.js'\nimport type { EthereumSDKProvider } from '../types.js'\nimport { getActionWithFallback } from '../utils/getActionWithFallback.js'\nimport { getAllowance } from './getAllowance.js'\n\ntype PermitSupport = {\n /** Whether the token supports EIP-2612 native permits */\n nativePermitSupported: boolean\n /** Whether Permit2 is available and has sufficient allowance */\n permit2AllowanceSufficient: boolean\n}\n\n/**\n * Checks what permit types are *usable* for a token on a specific chain.\n * Checks in order:\n * 1. Native permit (EIP-2612) support\n * 2. Permit2 — deployed on the chain, signable by the owner (see\n * `canAccountUsePermit2`), and allowance sufficient\n *\n * @param client - The SDK client\n * @param chain - The chain to check permit support on\n * @param tokenAddress - The token address to check\n * @param ownerAddress - The address that would sign the permit\n * @param amount - The amount to check allowance against for Permit2\n * @returns Object indicating which permit types are supported\n */\nexport const checkPermitSupport = async (\n client: SDKClient,\n {\n chain,\n tokenAddress,\n ownerAddress,\n amount,\n }: {\n chain: ExtendedChain\n tokenAddress: Address\n ownerAddress: Address\n amount: bigint\n }\n): Promise<PermitSupport> => {\n const provider = client.getProvider(ChainType.EVM) as\n | EthereumSDKProvider\n | undefined\n let viemClient = await provider?.getWalletClient?.()\n\n if (!viemClient) {\n viemClient = await getPublicClient(client, chain.id)\n }\n\n const nativePermit = await getActionWithFallback(\n client,\n viemClient,\n getNativePermit,\n 'getNativePermit',\n {\n client,\n viemClient,\n chainId: chain.id,\n tokenAddress,\n spenderAddress: chain.permit2Proxy as Address,\n amount,\n ownerAddress,\n },\n chain.id\n )\n\n let permit2Allowance: bigint | undefined\n // Only read the allowance if the owner can sign for it: Permit2 may reject an\n // account with code via EIP-1271, making any allowance unusable.\n //\n // An EIP-7702 owner is probed twice here, once per gate. The two run\n // sequentially, so `withDedupe` would not collapse them, and caching the\n // verdict would defeat the deliberate freshness of `getAccountCode`. Two\n // `eth_call`s on an already multi-RPC action is the cheaper trade.\n if (\n chain.permit2 &&\n (await canAccountUsePermit2(client, {\n chainId: chain.id,\n address: ownerAddress,\n }))\n ) {\n permit2Allowance = await getAllowance(\n client,\n viemClient,\n tokenAddress,\n ownerAddress,\n chain.permit2 as Address,\n chain.id\n )\n }\n\n return {\n nativePermitSupported: !!nativePermit,\n permit2AllowanceSufficient:\n !!permit2Allowance && permit2Allowance >= amount,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,qBAAqB,OAChC,QACA,EACE,OACA,cACA,cACA,aAOyB;CAI3B,IAAI,aAAa,MAHA,OAAO,YAAYA,UAAAA,UAAU,GAGhB,CAAC,EAAE,kBAAkB;CAEnD,IAAI,CAAC,YACH,aAAa,MAAMC,4BAAAA,gBAAgB,QAAQ,MAAM,EAAE;CAGrD,MAAM,eAAe,MAAMC,oCAAAA,sBACzB,QACA,YACAC,gCAAAA,iBACA,mBACA;EACE;EACA;EACA,SAAS,MAAM;EACf;EACA,gBAAgB,MAAM;EACtB;EACA;CACF,GACA,MAAM,EACR;CAEA,IAAI;CAQJ,IACE,MAAM,WACL,MAAMC,qCAAAA,qBAAqB,QAAQ;EAClC,SAAS,MAAM;EACf,SAAS;CACX,CAAC,GAED,mBAAmB,MAAMC,6BAAAA,aACvB,QACA,YACA,cACA,cACA,MAAM,SACN,MAAM,EACR;CAGF,OAAO;EACL,uBAAuB,CAAC,CAAC;EACzB,4BACE,CAAC,CAAC,oBAAoB,oBAAoB;CAC9C;AACF"}
@@ -1,7 +1,7 @@
1
1
  import { TokenAllowance, TokenSpender, TokenSpenderAllowance } from "../types.js";
2
2
  import { BaseToken, ChainId, SDKClient } from "@lifi/sdk";
3
3
  import { Address, Client } from "viem";
4
- export declare const getAllowance: (client: SDKClient, viemClient: Client, tokenAddress: Address, ownerAddress: Address, spenderAddress: Address) => Promise<bigint>;
4
+ export declare const getAllowance: (client: SDKClient, viemClient: Client, tokenAddress: Address, ownerAddress: Address, spenderAddress: Address, chainId: number | undefined) => Promise<bigint>;
5
5
  export declare const getAllowanceMulticall: (client: SDKClient, viemClient: Client, chainId: ChainId, tokens: TokenSpender[], ownerAddress: Address) => Promise<TokenSpenderAllowance[]>;
6
6
  /**
7
7
  * Get the current allowance for a certain token.
@@ -6,14 +6,14 @@ const require_utils_isZeroAddress = require("../utils/isZeroAddress.js");
6
6
  const require_actions_getMulticallAddress = require("./getMulticallAddress.js");
7
7
  let viem_actions = require("viem/actions");
8
8
  // src/actions/getAllowance.ts
9
- const getAllowance = async (client, viemClient, tokenAddress, ownerAddress, spenderAddress) => {
9
+ const getAllowance = async (client, viemClient, tokenAddress, ownerAddress, spenderAddress, chainId) => {
10
10
  try {
11
11
  return await require_utils_getActionWithFallback.getActionWithFallback(client, viemClient, viem_actions.readContract, "readContract", {
12
12
  address: tokenAddress,
13
13
  abi: require_utils_abi.allowanceAbi,
14
14
  functionName: "allowance",
15
15
  args: [ownerAddress, spenderAddress]
16
- });
16
+ }, chainId);
17
17
  } catch (_e) {
18
18
  return 0n;
19
19
  }
@@ -31,7 +31,7 @@ const getAllowanceMulticall = async (client, viemClient, chainId, tokens, ownerA
31
31
  const results = await require_utils_getActionWithFallback.getActionWithFallback(client, viemClient, viem_actions.multicall, "multicall", {
32
32
  contracts,
33
33
  multicallAddress
34
- });
34
+ }, chainId);
35
35
  if (!results.length) throw new Error(`Couldn't load allowance from chainId ${chainId} using multicall.`);
36
36
  return tokens.map(({ token, spenderAddress }, i) => ({
37
37
  token,
@@ -50,7 +50,7 @@ const getAllowanceMulticall = async (client, viemClient, chainId, tokens, ownerA
50
50
  const getTokenAllowance = async (client, token, ownerAddress, spenderAddress) => {
51
51
  if (require_utils_isZeroAddress.isZeroAddress(token.address)) return;
52
52
  const viemClient = await require_client_publicClient.getPublicClient(client, token.chainId);
53
- return await getAllowance(client, viemClient, token.address, ownerAddress, spenderAddress);
53
+ return await getAllowance(client, viemClient, token.address, ownerAddress, spenderAddress, token.chainId);
54
54
  };
55
55
  /**
56
56
  * Get the current allowance for a list of token/spender address pairs.
@@ -1 +1 @@
1
- {"version":3,"file":"getAllowance.js","names":["getActionWithFallback","readContract","allowanceAbi","getMulticallAddress","multicall","isZeroAddress","getPublicClient"],"sources":["../../../src/actions/getAllowance.ts"],"sourcesContent":["import type { BaseToken, ChainId, SDKClient } from '@lifi/sdk'\nimport type { Address, Client } from 'viem'\nimport { multicall, readContract } from 'viem/actions'\nimport { getPublicClient } from '../client/publicClient.js'\nimport type {\n TokenAllowance,\n TokenSpender,\n TokenSpenderAllowance,\n} from '../types.js'\nimport { allowanceAbi } from '../utils/abi.js'\nimport { getActionWithFallback } from '../utils/getActionWithFallback.js'\nimport { isZeroAddress } from '../utils/isZeroAddress.js'\nimport { getMulticallAddress } from './getMulticallAddress.js'\n\nexport const getAllowance = async (\n client: SDKClient,\n viemClient: Client,\n tokenAddress: Address,\n ownerAddress: Address,\n spenderAddress: Address\n): Promise<bigint> => {\n try {\n const approved = await getActionWithFallback(\n client,\n viemClient,\n readContract,\n 'readContract',\n {\n address: tokenAddress as Address,\n abi: allowanceAbi,\n functionName: 'allowance' as const,\n args: [ownerAddress, spenderAddress] as const,\n }\n )\n return approved as bigint\n } catch (_e) {\n return 0n\n }\n}\n\nexport const getAllowanceMulticall = async (\n client: SDKClient,\n viemClient: Client,\n chainId: ChainId,\n tokens: TokenSpender[],\n ownerAddress: Address\n): Promise<TokenSpenderAllowance[]> => {\n if (!tokens.length) {\n return []\n }\n const multicallAddress = await getMulticallAddress(client, chainId)\n if (!multicallAddress) {\n throw new Error(`No multicall address configured for chainId ${chainId}.`)\n }\n const contracts = tokens.map((token) => ({\n address: token.token.address as Address,\n abi: allowanceAbi,\n functionName: 'allowance',\n args: [ownerAddress, token.spenderAddress],\n }))\n\n const results = await getActionWithFallback(\n client,\n viemClient,\n multicall,\n 'multicall',\n {\n contracts,\n multicallAddress: multicallAddress as Address,\n }\n )\n\n if (!results.length) {\n throw new Error(\n `Couldn't load allowance from chainId ${chainId} using multicall.`\n )\n }\n\n return tokens.map(({ token, spenderAddress }, i: number) => ({\n token,\n spenderAddress,\n allowance: results[i].result as bigint,\n }))\n}\n\n/**\n * Get the current allowance for a certain token.\n * @param client - The SDK client\n * @param token - The token that should be checked\n * @param ownerAddress - The owner of the token\n * @param spenderAddress - The spender address that has to be approved\n * @returns Returns allowance\n */\nexport const getTokenAllowance = async (\n client: SDKClient,\n token: BaseToken,\n ownerAddress: Address,\n spenderAddress: Address\n): Promise<bigint | undefined> => {\n // native token don't need approval\n if (isZeroAddress(token.address)) {\n return\n }\n\n const viemClient = await getPublicClient(client, token.chainId)\n\n const approved = await getAllowance(\n client,\n viemClient,\n token.address as Address,\n ownerAddress,\n spenderAddress\n )\n return approved\n}\n\n/**\n * Get the current allowance for a list of token/spender address pairs.\n * @param client - The SDK client\n * @param ownerAddress - The owner of the tokens\n * @param tokens - A list of token and spender address pairs\n * @returns Returns array of tokens and their allowance\n */\nexport const getTokenAllowanceMulticall = async (\n client: SDKClient,\n ownerAddress: Address,\n tokens: TokenSpender[]\n): Promise<TokenAllowance[]> => {\n // filter out native tokens\n const filteredTokens = tokens.filter(\n ({ token }) => !isZeroAddress(token.address)\n )\n\n // group by chain\n const tokenDataByChain: { [chainId: number]: TokenSpender[] } = {}\n for (const data of filteredTokens) {\n if (!tokenDataByChain[data.token.chainId]) {\n tokenDataByChain[data.token.chainId] = []\n }\n tokenDataByChain[data.token.chainId].push(data)\n }\n\n const chainKeys = Object.keys(tokenDataByChain).map(Number.parseInt)\n\n const allowances = (\n await Promise.all(\n chainKeys.map(async (chainId) => {\n const viemClient = await getPublicClient(client, chainId)\n // get allowances for current chain and token list\n return getAllowanceMulticall(\n client,\n viemClient,\n chainId,\n tokenDataByChain[chainId],\n ownerAddress\n )\n })\n )\n ).flat()\n\n return allowances\n}\n"],"mappings":";;;;;;;;AAcA,MAAa,eAAe,OAC1B,QACA,YACA,cACA,cACA,mBACoB;CACpB,IAAI;EAaF,OAAO,MAZgBA,oCAAAA,sBACrB,QACA,YACAC,aAAAA,cACA,gBACA;GACE,SAAS;GACT,KAAKC,kBAAAA;GACL,cAAc;GACd,MAAM,CAAC,cAAc,cAAc;EACrC,CACF;CAEF,SAAS,IAAI;EACX,OAAO;CACT;AACF;AAEA,MAAa,wBAAwB,OACnC,QACA,YACA,SACA,QACA,iBACqC;CACrC,IAAI,CAAC,OAAO,QACV,OAAO,CAAC;CAEV,MAAM,mBAAmB,MAAMC,oCAAAA,oBAAoB,QAAQ,OAAO;CAClE,IAAI,CAAC,kBACH,MAAM,IAAI,MAAM,+CAA+C,QAAQ,EAAE;CAE3E,MAAM,YAAY,OAAO,KAAK,WAAW;EACvC,SAAS,MAAM,MAAM;EACrB,KAAKD,kBAAAA;EACL,cAAc;EACd,MAAM,CAAC,cAAc,MAAM,cAAc;CAC3C,EAAE;CAEF,MAAM,UAAU,MAAMF,oCAAAA,sBACpB,QACA,YACAI,aAAAA,WACA,aACA;EACE;EACkB;CACpB,CACF;CAEA,IAAI,CAAC,QAAQ,QACX,MAAM,IAAI,MACR,wCAAwC,QAAQ,kBAClD;CAGF,OAAO,OAAO,KAAK,EAAE,OAAO,kBAAkB,OAAe;EAC3D;EACA;EACA,WAAW,QAAQ,EAAE,CAAC;CACxB,EAAE;AACJ;;;;;;;;;AAUA,MAAa,oBAAoB,OAC/B,QACA,OACA,cACA,mBACgC;CAEhC,IAAIC,4BAAAA,cAAc,MAAM,OAAO,GAC7B;CAGF,MAAM,aAAa,MAAMC,4BAAAA,gBAAgB,QAAQ,MAAM,OAAO;CAS9D,OAAO,MAPgB,aACrB,QACA,YACA,MAAM,SACN,cACA,cACF;AAEF;;;;;;;;AASA,MAAa,6BAA6B,OACxC,QACA,cACA,WAC8B;CAE9B,MAAM,iBAAiB,OAAO,QAC3B,EAAE,YAAY,CAACD,4BAAAA,cAAc,MAAM,OAAO,CAC7C;CAGA,MAAM,mBAA0D,CAAC;CACjE,KAAK,MAAM,QAAQ,gBAAgB;EACjC,IAAI,CAAC,iBAAiB,KAAK,MAAM,UAC/B,iBAAiB,KAAK,MAAM,WAAW,CAAC;EAE1C,iBAAiB,KAAK,MAAM,QAAQ,CAAC,KAAK,IAAI;CAChD;CAEA,MAAM,YAAY,OAAO,KAAK,gBAAgB,CAAC,CAAC,IAAI,OAAO,QAAQ;CAkBnE,QAfE,MAAM,QAAQ,IACZ,UAAU,IAAI,OAAO,YAAY;EAC/B,MAAM,aAAa,MAAMC,4BAAAA,gBAAgB,QAAQ,OAAO;EAExD,OAAO,sBACL,QACA,YACA,SACA,iBAAiB,UACjB,YACF;CACF,CAAC,CACH,EAAA,CACA,KAEc;AAClB"}
1
+ {"version":3,"file":"getAllowance.js","names":["getActionWithFallback","readContract","allowanceAbi","getMulticallAddress","multicall","isZeroAddress","getPublicClient"],"sources":["../../../src/actions/getAllowance.ts"],"sourcesContent":["import type { BaseToken, ChainId, SDKClient } from '@lifi/sdk'\nimport type { Address, Client } from 'viem'\nimport { multicall, readContract } from 'viem/actions'\nimport { getPublicClient } from '../client/publicClient.js'\nimport type {\n TokenAllowance,\n TokenSpender,\n TokenSpenderAllowance,\n} from '../types.js'\nimport { allowanceAbi } from '../utils/abi.js'\nimport { getActionWithFallback } from '../utils/getActionWithFallback.js'\nimport { isZeroAddress } from '../utils/isZeroAddress.js'\nimport { getMulticallAddress } from './getMulticallAddress.js'\n\nexport const getAllowance = async (\n client: SDKClient,\n viemClient: Client,\n tokenAddress: Address,\n ownerAddress: Address,\n spenderAddress: Address,\n chainId: number | undefined\n): Promise<bigint> => {\n try {\n const approved = await getActionWithFallback(\n client,\n viemClient,\n readContract,\n 'readContract',\n {\n address: tokenAddress as Address,\n abi: allowanceAbi,\n functionName: 'allowance' as const,\n args: [ownerAddress, spenderAddress] as const,\n },\n chainId\n )\n return approved as bigint\n } catch (_e) {\n return 0n\n }\n}\n\nexport const getAllowanceMulticall = async (\n client: SDKClient,\n viemClient: Client,\n chainId: ChainId,\n tokens: TokenSpender[],\n ownerAddress: Address\n): Promise<TokenSpenderAllowance[]> => {\n if (!tokens.length) {\n return []\n }\n const multicallAddress = await getMulticallAddress(client, chainId)\n if (!multicallAddress) {\n throw new Error(`No multicall address configured for chainId ${chainId}.`)\n }\n const contracts = tokens.map((token) => ({\n address: token.token.address as Address,\n abi: allowanceAbi,\n functionName: 'allowance',\n args: [ownerAddress, token.spenderAddress],\n }))\n\n const results = await getActionWithFallback(\n client,\n viemClient,\n multicall,\n 'multicall',\n {\n contracts,\n multicallAddress: multicallAddress as Address,\n },\n chainId\n )\n\n if (!results.length) {\n throw new Error(\n `Couldn't load allowance from chainId ${chainId} using multicall.`\n )\n }\n\n return tokens.map(({ token, spenderAddress }, i: number) => ({\n token,\n spenderAddress,\n allowance: results[i].result as bigint,\n }))\n}\n\n/**\n * Get the current allowance for a certain token.\n * @param client - The SDK client\n * @param token - The token that should be checked\n * @param ownerAddress - The owner of the token\n * @param spenderAddress - The spender address that has to be approved\n * @returns Returns allowance\n */\nexport const getTokenAllowance = async (\n client: SDKClient,\n token: BaseToken,\n ownerAddress: Address,\n spenderAddress: Address\n): Promise<bigint | undefined> => {\n // native token don't need approval\n if (isZeroAddress(token.address)) {\n return\n }\n\n const viemClient = await getPublicClient(client, token.chainId)\n\n const approved = await getAllowance(\n client,\n viemClient,\n token.address as Address,\n ownerAddress,\n spenderAddress,\n token.chainId\n )\n return approved\n}\n\n/**\n * Get the current allowance for a list of token/spender address pairs.\n * @param client - The SDK client\n * @param ownerAddress - The owner of the tokens\n * @param tokens - A list of token and spender address pairs\n * @returns Returns array of tokens and their allowance\n */\nexport const getTokenAllowanceMulticall = async (\n client: SDKClient,\n ownerAddress: Address,\n tokens: TokenSpender[]\n): Promise<TokenAllowance[]> => {\n // filter out native tokens\n const filteredTokens = tokens.filter(\n ({ token }) => !isZeroAddress(token.address)\n )\n\n // group by chain\n const tokenDataByChain: { [chainId: number]: TokenSpender[] } = {}\n for (const data of filteredTokens) {\n if (!tokenDataByChain[data.token.chainId]) {\n tokenDataByChain[data.token.chainId] = []\n }\n tokenDataByChain[data.token.chainId].push(data)\n }\n\n const chainKeys = Object.keys(tokenDataByChain).map(Number.parseInt)\n\n const allowances = (\n await Promise.all(\n chainKeys.map(async (chainId) => {\n const viemClient = await getPublicClient(client, chainId)\n // get allowances for current chain and token list\n return getAllowanceMulticall(\n client,\n viemClient,\n chainId,\n tokenDataByChain[chainId],\n ownerAddress\n )\n })\n )\n ).flat()\n\n return allowances\n}\n"],"mappings":";;;;;;;;AAcA,MAAa,eAAe,OAC1B,QACA,YACA,cACA,cACA,gBACA,YACoB;CACpB,IAAI;EAcF,OAAO,MAbgBA,oCAAAA,sBACrB,QACA,YACAC,aAAAA,cACA,gBACA;GACE,SAAS;GACT,KAAKC,kBAAAA;GACL,cAAc;GACd,MAAM,CAAC,cAAc,cAAc;EACrC,GACA,OACF;CAEF,SAAS,IAAI;EACX,OAAO;CACT;AACF;AAEA,MAAa,wBAAwB,OACnC,QACA,YACA,SACA,QACA,iBACqC;CACrC,IAAI,CAAC,OAAO,QACV,OAAO,CAAC;CAEV,MAAM,mBAAmB,MAAMC,oCAAAA,oBAAoB,QAAQ,OAAO;CAClE,IAAI,CAAC,kBACH,MAAM,IAAI,MAAM,+CAA+C,QAAQ,EAAE;CAE3E,MAAM,YAAY,OAAO,KAAK,WAAW;EACvC,SAAS,MAAM,MAAM;EACrB,KAAKD,kBAAAA;EACL,cAAc;EACd,MAAM,CAAC,cAAc,MAAM,cAAc;CAC3C,EAAE;CAEF,MAAM,UAAU,MAAMF,oCAAAA,sBACpB,QACA,YACAI,aAAAA,WACA,aACA;EACE;EACkB;CACpB,GACA,OACF;CAEA,IAAI,CAAC,QAAQ,QACX,MAAM,IAAI,MACR,wCAAwC,QAAQ,kBAClD;CAGF,OAAO,OAAO,KAAK,EAAE,OAAO,kBAAkB,OAAe;EAC3D;EACA;EACA,WAAW,QAAQ,EAAE,CAAC;CACxB,EAAE;AACJ;;;;;;;;;AAUA,MAAa,oBAAoB,OAC/B,QACA,OACA,cACA,mBACgC;CAEhC,IAAIC,4BAAAA,cAAc,MAAM,OAAO,GAC7B;CAGF,MAAM,aAAa,MAAMC,4BAAAA,gBAAgB,QAAQ,MAAM,OAAO;CAU9D,OAAO,MARgB,aACrB,QACA,YACA,MAAM,SACN,cACA,gBACA,MAAM,OACR;AAEF;;;;;;;;AASA,MAAa,6BAA6B,OACxC,QACA,cACA,WAC8B;CAE9B,MAAM,iBAAiB,OAAO,QAC3B,EAAE,YAAY,CAACD,4BAAAA,cAAc,MAAM,OAAO,CAC7C;CAGA,MAAM,mBAA0D,CAAC;CACjE,KAAK,MAAM,QAAQ,gBAAgB;EACjC,IAAI,CAAC,iBAAiB,KAAK,MAAM,UAC/B,iBAAiB,KAAK,MAAM,WAAW,CAAC;EAE1C,iBAAiB,KAAK,MAAM,QAAQ,CAAC,KAAK,IAAI;CAChD;CAEA,MAAM,YAAY,OAAO,KAAK,gBAAgB,CAAC,CAAC,IAAI,OAAO,QAAQ;CAkBnE,QAfE,MAAM,QAAQ,IACZ,UAAU,IAAI,OAAO,YAAY;EAC/B,MAAM,aAAa,MAAMC,4BAAAA,gBAAgB,QAAQ,OAAO;EAExD,OAAO,sBACL,QACA,YACA,SACA,iBAAiB,UACjB,YACF;CACF,CAAC,CACH,EAAA,CACA,KAEc;AAClB"}
@@ -1,3 +1,3 @@
1
1
  import { SDKClient } from "@lifi/sdk";
2
2
  import { Client } from "viem";
3
- export declare const getMaxPriorityFeePerGas: (client: SDKClient, viemClient: Client) => Promise<bigint | undefined>;
3
+ export declare const getMaxPriorityFeePerGas: (client: SDKClient, viemClient: Client, chainId: number | undefined) => Promise<bigint | undefined>;
@@ -3,8 +3,8 @@ const require_utils_getActionWithFallback = require("../utils/getActionWithFallb
3
3
  const require_utils_median = require("../utils/median.js");
4
4
  let viem_actions = require("viem/actions");
5
5
  // src/actions/getMaxPriorityFeePerGas.ts
6
- const getMaxPriorityFeePerGas = async (client, viemClient) => {
7
- const maxPriorityFeePerGasList = (await require_utils_getActionWithFallback.getActionWithFallback(client, viemClient, viem_actions.getBlock, "getBlock", { includeTransactions: true })).transactions.filter((tx) => tx.maxPriorityFeePerGas).map((tx) => tx.maxPriorityFeePerGas);
6
+ const getMaxPriorityFeePerGas = async (client, viemClient, chainId) => {
7
+ const maxPriorityFeePerGasList = (await require_utils_getActionWithFallback.getActionWithFallback(client, viemClient, viem_actions.getBlock, "getBlock", { includeTransactions: true }, chainId)).transactions.filter((tx) => tx.maxPriorityFeePerGas).map((tx) => tx.maxPriorityFeePerGas);
8
8
  if (!maxPriorityFeePerGasList.length) return;
9
9
  let maxPriorityFeePerGasSum = 0n;
10
10
  for (const value of maxPriorityFeePerGasList) maxPriorityFeePerGasSum += value;
@@ -1 +1 @@
1
- {"version":3,"file":"getMaxPriorityFeePerGas.js","names":["getActionWithFallback","getBlock","median"],"sources":["../../../src/actions/getMaxPriorityFeePerGas.ts"],"sourcesContent":["import type { SDKClient } from '@lifi/sdk'\nimport type { Client, Transaction } from 'viem'\nimport { getBlock } from 'viem/actions'\nimport { getActionWithFallback } from '../utils/getActionWithFallback.js'\nimport { median } from '../utils/median.js'\n\nexport const getMaxPriorityFeePerGas = async (\n client: SDKClient,\n viemClient: Client\n): Promise<bigint | undefined> => {\n const block = await getActionWithFallback(\n client,\n viemClient,\n getBlock,\n 'getBlock',\n {\n includeTransactions: true,\n }\n )\n\n const maxPriorityFeePerGasList = (block.transactions as Transaction[])\n .filter((tx) => tx.maxPriorityFeePerGas)\n .map((tx) => tx.maxPriorityFeePerGas) as bigint[]\n\n if (!maxPriorityFeePerGasList.length) {\n return\n }\n\n let maxPriorityFeePerGasSum = 0n\n for (const value of maxPriorityFeePerGasList) {\n maxPriorityFeePerGasSum += value\n }\n\n const maxPriorityFeePerGasMedian = median(maxPriorityFeePerGasList) ?? 0n\n\n const maxPriorityFeePerGasAvg =\n maxPriorityFeePerGasSum / BigInt(maxPriorityFeePerGasList.length)\n\n return maxPriorityFeePerGasMedian > maxPriorityFeePerGasAvg\n ? maxPriorityFeePerGasAvg\n : maxPriorityFeePerGasMedian\n}\n"],"mappings":";;;;;AAMA,MAAa,0BAA0B,OACrC,QACA,eACgC;CAWhC,MAAM,4BAA4B,MAVdA,oCAAAA,sBAClB,QACA,YACAC,aAAAA,UACA,YACA,EACE,qBAAqB,KACvB,CACF,EAAA,CAEwC,aACrC,QAAQ,OAAO,GAAG,oBAAoB,CAAC,CACvC,KAAK,OAAO,GAAG,oBAAoB;CAEtC,IAAI,CAAC,yBAAyB,QAC5B;CAGF,IAAI,0BAA0B;CAC9B,KAAK,MAAM,SAAS,0BAClB,2BAA2B;CAG7B,MAAM,6BAA6BC,qBAAAA,OAAO,wBAAwB,KAAK;CAEvE,MAAM,0BACJ,0BAA0B,OAAO,yBAAyB,MAAM;CAElE,OAAO,6BAA6B,0BAChC,0BACA;AACN"}
1
+ {"version":3,"file":"getMaxPriorityFeePerGas.js","names":["getActionWithFallback","getBlock","median"],"sources":["../../../src/actions/getMaxPriorityFeePerGas.ts"],"sourcesContent":["import type { SDKClient } from '@lifi/sdk'\nimport type { Client, Transaction } from 'viem'\nimport { getBlock } from 'viem/actions'\nimport { getActionWithFallback } from '../utils/getActionWithFallback.js'\nimport { median } from '../utils/median.js'\n\nexport const getMaxPriorityFeePerGas = async (\n client: SDKClient,\n viemClient: Client,\n chainId: number | undefined\n): Promise<bigint | undefined> => {\n const block = await getActionWithFallback(\n client,\n viemClient,\n getBlock,\n 'getBlock',\n {\n includeTransactions: true,\n },\n chainId\n )\n\n const maxPriorityFeePerGasList = (block.transactions as Transaction[])\n .filter((tx) => tx.maxPriorityFeePerGas)\n .map((tx) => tx.maxPriorityFeePerGas) as bigint[]\n\n if (!maxPriorityFeePerGasList.length) {\n return\n }\n\n let maxPriorityFeePerGasSum = 0n\n for (const value of maxPriorityFeePerGasList) {\n maxPriorityFeePerGasSum += value\n }\n\n const maxPriorityFeePerGasMedian = median(maxPriorityFeePerGasList) ?? 0n\n\n const maxPriorityFeePerGasAvg =\n maxPriorityFeePerGasSum / BigInt(maxPriorityFeePerGasList.length)\n\n return maxPriorityFeePerGasMedian > maxPriorityFeePerGasAvg\n ? maxPriorityFeePerGasAvg\n : maxPriorityFeePerGasMedian\n}\n"],"mappings":";;;;;AAMA,MAAa,0BAA0B,OACrC,QACA,YACA,YACgC;CAYhC,MAAM,4BAA4B,MAXdA,oCAAAA,sBAClB,QACA,YACAC,aAAAA,UACA,YACA,EACE,qBAAqB,KACvB,GACA,OACF,EAAA,CAEwC,aACrC,QAAQ,OAAO,GAAG,oBAAoB,CAAC,CACvC,KAAK,OAAO,GAAG,oBAAoB;CAEtC,IAAI,CAAC,yBAAyB,QAC5B;CAGF,IAAI,0BAA0B;CAC9B,KAAK,MAAM,SAAS,0BAClB,2BAA2B;CAG7B,MAAM,6BAA6BC,qBAAAA,OAAO,wBAAwB,KAAK;CAEvE,MAAM,0BACJ,0BAA0B,OAAO,yBAAyB,MAAM;CAElE,OAAO,6BAA6B,0BAChC,0BACA;AACN"}
@@ -1,7 +1,7 @@
1
1
  import { SDKClient } from "@lifi/sdk";
2
2
  import { Address } from "viem";
3
3
  export interface IsSafeSignatureProps {
4
- hash: string;
4
+ hash: unknown;
5
5
  chainId: number;
6
6
  address?: Address;
7
7
  }
@@ -1,6 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_utils_getSafeApiKey = require("../utils/getSafeApiKey.js");
3
3
  const require_actions_isSafeWallet = require("./isSafeWallet.js");
4
+ let viem = require("viem");
4
5
  // src/actions/isSafeSignature.ts
5
6
  /**
6
7
  * Check if a transaction response is a Safe wallet signature (queued transaction)
@@ -9,7 +10,7 @@ const require_actions_isSafeWallet = require("./isSafeWallet.js");
9
10
  * a transaction hash (32 bytes = 66 chars) for queued transactions.
10
11
  */
11
12
  async function isSafeSignature(client, { hash, chainId, address }) {
12
- if (!hash.startsWith("0x") || hash.length <= 66) return false;
13
+ if (!(0, viem.isHex)(hash) || hash.length <= 66) return false;
13
14
  if (!address) return false;
14
15
  const safeApiKey = require_utils_getSafeApiKey.getSafeApiKey(client);
15
16
  return require_actions_isSafeWallet.isSafeWallet({
@@ -1 +1 @@
1
- {"version":3,"file":"isSafeSignature.js","names":["getSafeApiKey","isSafeWallet"],"sources":["../../../src/actions/isSafeSignature.ts"],"sourcesContent":["import type { SDKClient } from '@lifi/sdk'\nimport type { Address } from 'viem'\nimport { getSafeApiKey } from '../utils/getSafeApiKey.js'\nimport { isSafeWallet } from './isSafeWallet.js'\n\nexport interface IsSafeSignatureProps {\n hash: string\n chainId: number\n address?: Address\n}\n\n/**\n * Check if a transaction response is a Safe wallet signature (queued transaction)\n *\n * Safe wallets via Rabby return a signature (65 bytes = 132 chars) instead of\n * a transaction hash (32 bytes = 66 chars) for queued transactions.\n */\nexport async function isSafeSignature(\n client: SDKClient,\n { hash, chainId, address }: IsSafeSignatureProps\n): Promise<boolean> {\n // Signature: 65 bytes = 130 hex chars + 0x prefix = 132 chars\n // Tx hash: 32 bytes = 64 hex chars + 0x prefix = 66 chars\n if (!hash.startsWith('0x') || hash.length <= 66) {\n return false\n }\n\n if (!address) {\n return false\n }\n\n const safeApiKey = getSafeApiKey(client)\n return isSafeWallet({ client, chainId, address, safeApiKey })\n}\n"],"mappings":";;;;;;;;;;AAiBA,eAAsB,gBACpB,QACA,EAAE,MAAM,SAAS,WACC;CAGlB,IAAI,CAAC,KAAK,WAAW,IAAI,KAAK,KAAK,UAAU,IAC3C,OAAO;CAGT,IAAI,CAAC,SACH,OAAO;CAGT,MAAM,aAAaA,4BAAAA,cAAc,MAAM;CACvC,OAAOC,6BAAAA,aAAa;EAAE;EAAQ;EAAS;EAAS;CAAW,CAAC;AAC9D"}
1
+ {"version":3,"file":"isSafeSignature.js","names":["isHex","getSafeApiKey","isSafeWallet"],"sources":["../../../src/actions/isSafeSignature.ts"],"sourcesContent":["import type { SDKClient } from '@lifi/sdk'\nimport { type Address, isHex } from 'viem'\nimport { getSafeApiKey } from '../utils/getSafeApiKey.js'\nimport { isSafeWallet } from './isSafeWallet.js'\n\nexport interface IsSafeSignatureProps {\n hash: unknown\n chainId: number\n address?: Address\n}\n\n/**\n * Check if a transaction response is a Safe wallet signature (queued transaction)\n *\n * Safe wallets via Rabby return a signature (65 bytes = 132 chars) instead of\n * a transaction hash (32 bytes = 66 chars) for queued transactions.\n */\nexport async function isSafeSignature(\n client: SDKClient,\n { hash, chainId, address }: IsSafeSignatureProps\n): Promise<boolean> {\n // Signature: 65 bytes = 130 hex chars + 0x prefix = 132 chars\n // Tx hash: 32 bytes = 64 hex chars + 0x prefix = 66 chars\n if (!isHex(hash) || hash.length <= 66) {\n return false\n }\n\n if (!address) {\n return false\n }\n\n const safeApiKey = getSafeApiKey(client)\n return isSafeWallet({ client, chainId, address, safeApiKey })\n}\n"],"mappings":";;;;;;;;;;;AAiBA,eAAsB,gBACpB,QACA,EAAE,MAAM,SAAS,WACC;CAGlB,IAAI,EAAA,GAACA,KAAAA,MAAAA,CAAM,IAAI,KAAK,KAAK,UAAU,IACjC,OAAO;CAGT,IAAI,CAAC,SACH,OAAO;CAGT,MAAM,aAAaC,4BAAAA,cAAc,MAAM;CACvC,OAAOC,6BAAAA,aAAa;EAAE;EAAQ;EAAS;EAAS;CAAW,CAAC;AAC9D"}
@@ -2,15 +2,19 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_actions_isSafeSignature = require("./isSafeSignature.js");
3
3
  const require_actions_waitForSafeTransactionExecution = require("./waitForSafeTransactionExecution.js");
4
4
  let _lifi_sdk = require("@lifi/sdk");
5
+ let viem = require("viem");
5
6
  // src/actions/resolveTransactionHash.ts
6
7
  const resolveTransactionHash = async (client, viemClient, txHashOrSignature, chainId) => {
7
8
  if (!await require_actions_isSafeSignature.isSafeSignature(client, {
8
9
  hash: txHashOrSignature,
9
10
  chainId,
10
11
  address: viemClient.account?.address
11
- })) return txHashOrSignature;
12
+ })) {
13
+ if (!(0, viem.isHex)(txHashOrSignature) || txHashOrSignature.length < 66) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionFailed, "The wallet did not return a transaction hash. The wallet may have sent the transaction. Before you try again, check the activity in your wallet.");
14
+ return txHashOrSignature;
15
+ }
12
16
  const safeAddress = viemClient.account?.address;
13
- if (!safeAddress || !txHashOrSignature) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionFailed, "Safe address or signature not available for transaction tracking.");
17
+ if (!safeAddress) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionFailed, "Safe address not available for transaction tracking.");
14
18
  return await require_actions_waitForSafeTransactionExecution.waitForSafeTransactionExecution(client, {
15
19
  chainId,
16
20
  safeAddress,
@@ -1 +1 @@
1
- {"version":3,"file":"resolveTransactionHash.js","names":["isSafeSignature","TransactionError","LiFiErrorCode","waitForSafeTransactionExecution"],"sources":["../../../src/actions/resolveTransactionHash.ts"],"sourcesContent":["import { LiFiErrorCode, type SDKClient, TransactionError } from '@lifi/sdk'\nimport type { Client, Hash } from 'viem'\nimport { isSafeSignature } from './isSafeSignature.js'\nimport { waitForSafeTransactionExecution } from './waitForSafeTransactionExecution.js'\n\nexport const resolveTransactionHash = async (\n client: SDKClient,\n viemClient: Client,\n txHashOrSignature: Hash,\n chainId: number\n): Promise<Hash> => {\n const isSignature = await isSafeSignature(client, {\n hash: txHashOrSignature,\n chainId,\n address: viemClient.account?.address,\n })\n\n if (!isSignature) {\n return txHashOrSignature\n }\n\n const safeAddress = viemClient.account?.address\n if (!safeAddress || !txHashOrSignature) {\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n 'Safe address or signature not available for transaction tracking.'\n )\n }\n\n return await waitForSafeTransactionExecution(client, {\n chainId,\n safeAddress,\n signature: txHashOrSignature,\n pollingInterval: 5_000,\n })\n}\n"],"mappings":";;;;;AAKA,MAAa,yBAAyB,OACpC,QACA,YACA,mBACA,YACkB;CAOlB,IAAI,CAAC,MANqBA,gCAAAA,gBAAgB,QAAQ;EAChD,MAAM;EACN;EACA,SAAS,WAAW,SAAS;CAC/B,CAAC,GAGC,OAAO;CAGT,MAAM,cAAc,WAAW,SAAS;CACxC,IAAI,CAAC,eAAe,CAAC,mBACnB,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,mBACd,mEACF;CAGF,OAAO,MAAMC,gDAAAA,gCAAgC,QAAQ;EACnD;EACA;EACA,WAAW;EACX,iBAAiB;CACnB,CAAC;AACH"}
1
+ {"version":3,"file":"resolveTransactionHash.js","names":["isSafeSignature","isHex","TransactionError","LiFiErrorCode","waitForSafeTransactionExecution"],"sources":["../../../src/actions/resolveTransactionHash.ts"],"sourcesContent":["import { LiFiErrorCode, type SDKClient, TransactionError } from '@lifi/sdk'\nimport { type Client, type Hash, isHex } from 'viem'\nimport { isSafeSignature } from './isSafeSignature.js'\nimport { waitForSafeTransactionExecution } from './waitForSafeTransactionExecution.js'\n\nexport const resolveTransactionHash = async (\n client: SDKClient,\n viemClient: Client,\n txHashOrSignature: Hash,\n chainId: number\n): Promise<Hash> => {\n const isSignature = await isSafeSignature(client, {\n hash: txHashOrSignature,\n chainId,\n address: viemClient.account?.address,\n })\n\n if (!isSignature) {\n // Unchecked wallet answer; longer hex can be a Safe signature the lookup missed.\n if (!isHex(txHashOrSignature) || txHashOrSignature.length < 66) {\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n 'The wallet did not return a transaction hash. The wallet may have sent the transaction. Before you try again, check the activity in your wallet.'\n )\n }\n return txHashOrSignature\n }\n\n const safeAddress = viemClient.account?.address\n if (!safeAddress) {\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n 'Safe address not available for transaction tracking.'\n )\n }\n\n return await waitForSafeTransactionExecution(client, {\n chainId,\n safeAddress,\n signature: txHashOrSignature,\n pollingInterval: 5_000,\n })\n}\n"],"mappings":";;;;;;AAKA,MAAa,yBAAyB,OACpC,QACA,YACA,mBACA,YACkB;CAOlB,IAAI,CAAC,MANqBA,gCAAAA,gBAAgB,QAAQ;EAChD,MAAM;EACN;EACA,SAAS,WAAW,SAAS;CAC/B,CAAC,GAEiB;EAEhB,IAAI,EAAA,GAACC,KAAAA,MAAAA,CAAM,iBAAiB,KAAK,kBAAkB,SAAS,IAC1D,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,mBACd,kJACF;EAEF,OAAO;CACT;CAEA,MAAM,cAAc,WAAW,SAAS;CACxC,IAAI,CAAC,aACH,MAAM,IAAID,UAAAA,iBACRC,UAAAA,cAAc,mBACd,sDACF;CAGF,OAAO,MAAMC,gDAAAA,gCAAgC,QAAQ;EACnD;EACA;EACA,WAAW;EACX,iBAAiB;CACnB,CAAC;AACH"}
@@ -1,7 +1,7 @@
1
1
  import { ApproveTokenRequest, RevokeApprovalRequest } from "../types.js";
2
2
  import { ExecutionOptions, SDKClient } from "@lifi/sdk";
3
- import { Address, Client, Hash, Hex } from "viem";
4
- export declare const setAllowance: (client: SDKClient, viemClient: Client, tokenAddress: Address, contractAddress: Address, amount: bigint, executionOptions?: ExecutionOptions, returnPopulatedTransaction?: boolean) => Promise<Hash | Hex>;
3
+ import { Address, Chain, Client, Hash, Hex } from "viem";
4
+ export declare const setAllowance: (client: SDKClient, viemClient: Client, tokenAddress: Address, contractAddress: Address, amount: bigint, executionOptions?: ExecutionOptions, returnPopulatedTransaction?: boolean, chain?: Chain) => Promise<Hash | Hex>;
5
5
  /**
6
6
  * Set approval for a certain token and amount.
7
7
  * @param client - The SDK client
@@ -1,5 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_utils_abi = require("../utils/abi.js");
3
+ const require_utils_convertExtendedChain = require("../utils/convertExtendedChain.js");
4
+ const require_utils_getSendChain = require("../utils/getSendChain.js");
3
5
  const require_utils_isZeroAddress = require("../utils/isZeroAddress.js");
4
6
  const require_actions_getAllowance = require("./getAllowance.js");
5
7
  const require_actions_getMaxPriorityFeePerGas = require("./getMaxPriorityFeePerGas.js");
@@ -7,7 +9,7 @@ let viem = require("viem");
7
9
  let viem_actions = require("viem/actions");
8
10
  let viem_utils = require("viem/utils");
9
11
  // src/actions/setAllowance.ts
10
- const setAllowance = async (client, viemClient, tokenAddress, contractAddress, amount, executionOptions, returnPopulatedTransaction) => {
12
+ const setAllowance = async (client, viemClient, tokenAddress, contractAddress, amount, executionOptions, returnPopulatedTransaction, chain) => {
11
13
  const data = (0, viem.encodeFunctionData)({
12
14
  abi: require_utils_abi.approveAbi,
13
15
  functionName: "approve",
@@ -17,7 +19,7 @@ const setAllowance = async (client, viemClient, tokenAddress, contractAddress, a
17
19
  let transactionRequest = {
18
20
  to: tokenAddress,
19
21
  data,
20
- maxPriorityFeePerGas: viemClient.account?.type === "local" ? await require_actions_getMaxPriorityFeePerGas.getMaxPriorityFeePerGas(client, viemClient) : void 0
22
+ maxPriorityFeePerGas: viemClient.account?.type === "local" ? await require_actions_getMaxPriorityFeePerGas.getMaxPriorityFeePerGas(client, viemClient, chain?.id ?? viemClient.chain?.id) : void 0
21
23
  };
22
24
  if (executionOptions?.updateTransactionRequestHook) {
23
25
  const customizedTransactionRequest = await executionOptions.updateTransactionRequestHook({
@@ -36,9 +38,11 @@ const setAllowance = async (client, viemClient, tokenAddress, contractAddress, a
36
38
  gas: transactionRequest.gas,
37
39
  gasPrice: transactionRequest.gasPrice,
38
40
  maxFeePerGas: transactionRequest.maxFeePerGas,
39
- maxPriorityFeePerGas: transactionRequest.maxPriorityFeePerGas
41
+ maxPriorityFeePerGas: transactionRequest.maxPriorityFeePerGas,
42
+ ...chain && { chain: require_utils_getSendChain.getSendChain(viemClient, chain) }
40
43
  });
41
44
  };
45
+ const getTokenChain = (client, chainId) => client.getChainById(chainId).then(require_utils_convertExtendedChain.convertExtendedChain, () => void 0);
42
46
  /**
43
47
  * Set approval for a certain token and amount.
44
48
  * @param client - The SDK client
@@ -51,7 +55,7 @@ const setAllowance = async (client, viemClient, tokenAddress, contractAddress, a
51
55
  */
52
56
  const setTokenAllowance = async (client, { walletClient, token, spenderAddress, amount }) => {
53
57
  if (require_utils_isZeroAddress.isZeroAddress(token.address)) return;
54
- if (amount > await require_actions_getAllowance.getAllowance(client, walletClient, token.address, walletClient.account.address, spenderAddress)) return await setAllowance(client, walletClient, token.address, spenderAddress, amount);
58
+ if (amount > await require_actions_getAllowance.getAllowance(client, walletClient, token.address, walletClient.account.address, spenderAddress, token.chainId)) return await setAllowance(client, walletClient, token.address, spenderAddress, amount, void 0, false, await getTokenChain(client, token.chainId));
55
59
  };
56
60
  /**
57
61
  * Revoke approval for a certain token.
@@ -64,7 +68,7 @@ const setTokenAllowance = async (client, { walletClient, token, spenderAddress,
64
68
  */
65
69
  const revokeTokenApproval = async (client, { walletClient, token, spenderAddress }) => {
66
70
  if (require_utils_isZeroAddress.isZeroAddress(token.address)) return;
67
- if (await require_actions_getAllowance.getAllowance(client, walletClient, token.address, walletClient.account.address, spenderAddress) > 0) return await setAllowance(client, walletClient, token.address, spenderAddress, 0n);
71
+ if (await require_actions_getAllowance.getAllowance(client, walletClient, token.address, walletClient.account.address, spenderAddress, token.chainId) > 0) return await setAllowance(client, walletClient, token.address, spenderAddress, 0n, void 0, false, await getTokenChain(client, token.chainId));
68
72
  };
69
73
  exports.revokeTokenApproval = revokeTokenApproval;
70
74
  exports.setAllowance = setAllowance;
@@ -1 +1 @@
1
- {"version":3,"file":"setAllowance.js","names":["encodeFunctionData","approveAbi","getMaxPriorityFeePerGas","getAction","sendTransaction","isZeroAddress","getAllowance"],"sources":["../../../src/actions/setAllowance.ts"],"sourcesContent":["import type {\n ExecutionOptions,\n SDKClient,\n TransactionParameters,\n} from '@lifi/sdk'\nimport type {\n Address,\n Client,\n Hash,\n Hex,\n SendTransactionParameters,\n} from 'viem'\nimport { encodeFunctionData } from 'viem'\nimport { sendTransaction } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport type { ApproveTokenRequest, RevokeApprovalRequest } from '../types.js'\nimport { approveAbi } from '../utils/abi.js'\nimport { isZeroAddress } from '../utils/isZeroAddress.js'\nimport { getAllowance } from './getAllowance.js'\nimport { getMaxPriorityFeePerGas } from './getMaxPriorityFeePerGas.js'\n\nexport const setAllowance = async (\n client: SDKClient,\n viemClient: Client,\n tokenAddress: Address,\n contractAddress: Address,\n amount: bigint,\n executionOptions?: ExecutionOptions,\n returnPopulatedTransaction?: boolean\n): Promise<Hash | Hex> => {\n const data = encodeFunctionData({\n abi: approveAbi,\n functionName: 'approve',\n args: [contractAddress, amount],\n })\n\n if (returnPopulatedTransaction) {\n return data\n }\n\n let transactionRequest: TransactionParameters = {\n to: tokenAddress,\n data,\n maxPriorityFeePerGas:\n viemClient.account?.type === 'local'\n ? await getMaxPriorityFeePerGas(client, viemClient)\n : undefined,\n }\n\n if (executionOptions?.updateTransactionRequestHook) {\n const customizedTransactionRequest: TransactionParameters =\n await executionOptions.updateTransactionRequestHook({\n requestType: 'approve',\n ...transactionRequest,\n })\n\n transactionRequest = {\n ...transactionRequest,\n ...customizedTransactionRequest,\n }\n }\n\n return getAction(\n viemClient,\n sendTransaction,\n 'sendTransaction'\n )({\n to: transactionRequest.to,\n account: viemClient.account!,\n data: transactionRequest.data,\n gas: transactionRequest.gas,\n gasPrice: transactionRequest.gasPrice,\n maxFeePerGas: transactionRequest.maxFeePerGas,\n maxPriorityFeePerGas: transactionRequest.maxPriorityFeePerGas,\n } as SendTransactionParameters)\n}\n\n/**\n * Set approval for a certain token and amount.\n * @param client - The SDK client\n * @param request - The approval request\n * @param request.walletClient - The Viem wallet client used to send the transaction\n * @param request.token - The token for which to set the allowance\n * @param request.spenderAddress - The address of the spender\n * @param request.amount - The amount of tokens to approve\n * @returns Returns Hash or nothing\n */\nexport const setTokenAllowance = async (\n client: SDKClient,\n { walletClient, token, spenderAddress, amount }: ApproveTokenRequest\n): Promise<Hash | void> => {\n // native token don't need approval\n if (isZeroAddress(token.address)) {\n return\n }\n const approvedAmount = await getAllowance(\n client,\n walletClient,\n token.address as Address,\n walletClient.account!.address,\n spenderAddress as Address\n )\n\n if (amount > approvedAmount) {\n const approveTx = await setAllowance(\n client,\n walletClient,\n token.address as Address,\n spenderAddress as Address,\n amount\n )\n\n return approveTx\n }\n}\n\n/**\n * Revoke approval for a certain token.\n * @param client - The SDK client\n * @param request - The revoke request\n * @param request.walletClient - The Viem wallet client used to send the transaction\n * @param request.token - The token for which to revoke the allowance\n * @param request.spenderAddress - The address of the spender\n * @returns Returns Hash or nothing\n */\nexport const revokeTokenApproval = async (\n client: SDKClient,\n { walletClient, token, spenderAddress }: RevokeApprovalRequest\n): Promise<Hash | void> => {\n // native token don't need approval\n if (isZeroAddress(token.address)) {\n return\n }\n const approvedAmount = await getAllowance(\n client,\n walletClient,\n token.address as Address,\n walletClient.account!.address,\n spenderAddress as Address\n )\n if (approvedAmount > 0) {\n const approveTx = await setAllowance(\n client,\n walletClient,\n token.address as Address,\n spenderAddress as Address,\n 0n\n )\n\n return approveTx\n }\n}\n"],"mappings":";;;;;;;;;AAqBA,MAAa,eAAe,OAC1B,QACA,YACA,cACA,iBACA,QACA,kBACA,+BACwB;CACxB,MAAM,QAAA,GAAOA,KAAAA,mBAAAA,CAAmB;EAC9B,KAAKC,kBAAAA;EACL,cAAc;EACd,MAAM,CAAC,iBAAiB,MAAM;CAChC,CAAC;CAED,IAAI,4BACF,OAAO;CAGT,IAAI,qBAA4C;EAC9C,IAAI;EACJ;EACA,sBACE,WAAW,SAAS,SAAS,UACzB,MAAMC,wCAAAA,wBAAwB,QAAQ,UAAU,IAChD,KAAA;CACR;CAEA,IAAI,kBAAkB,8BAA8B;EAClD,MAAM,+BACJ,MAAM,iBAAiB,6BAA6B;GAClD,aAAa;GACb,GAAG;EACL,CAAC;EAEH,qBAAqB;GACnB,GAAG;GACH,GAAG;EACL;CACF;CAEA,QAAA,GAAOC,WAAAA,UAAAA,CACL,YACAC,aAAAA,iBACA,iBACF,CAAC,CAAC;EACA,IAAI,mBAAmB;EACvB,SAAS,WAAW;EACpB,MAAM,mBAAmB;EACzB,KAAK,mBAAmB;EACxB,UAAU,mBAAmB;EAC7B,cAAc,mBAAmB;EACjC,sBAAsB,mBAAmB;CAC3C,CAA8B;AAChC;;;;;;;;;;;AAYA,MAAa,oBAAoB,OAC/B,QACA,EAAE,cAAc,OAAO,gBAAgB,aACd;CAEzB,IAAIC,4BAAAA,cAAc,MAAM,OAAO,GAC7B;CAUF,IAAI,SAAS,MARgBC,6BAAAA,aAC3B,QACA,cACA,MAAM,SACN,aAAa,QAAS,SACtB,cACF,GAWE,OAAO,MARiB,aACtB,QACA,cACA,MAAM,SACN,gBACA,MACF;AAIJ;;;;;;;;;;AAWA,MAAa,sBAAsB,OACjC,QACA,EAAE,cAAc,OAAO,qBACE;CAEzB,IAAID,4BAAAA,cAAc,MAAM,OAAO,GAC7B;CASF,IAAI,MAPyBC,6BAAAA,aAC3B,QACA,cACA,MAAM,SACN,aAAa,QAAS,SACtB,cACF,IACqB,GASnB,OAAO,MARiB,aACtB,QACA,cACA,MAAM,SACN,gBACA,EACF;AAIJ"}
1
+ {"version":3,"file":"setAllowance.js","names":["encodeFunctionData","approveAbi","getMaxPriorityFeePerGas","getAction","sendTransaction","getSendChain","convertExtendedChain","isZeroAddress","getAllowance"],"sources":["../../../src/actions/setAllowance.ts"],"sourcesContent":["import type {\n ExecutionOptions,\n SDKClient,\n TransactionParameters,\n} from '@lifi/sdk'\nimport type {\n Address,\n Chain,\n Client,\n Hash,\n Hex,\n SendTransactionParameters,\n} from 'viem'\nimport { encodeFunctionData } from 'viem'\nimport { sendTransaction } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport type { ApproveTokenRequest, RevokeApprovalRequest } from '../types.js'\nimport { approveAbi } from '../utils/abi.js'\nimport { convertExtendedChain } from '../utils/convertExtendedChain.js'\nimport { getSendChain } from '../utils/getSendChain.js'\nimport { isZeroAddress } from '../utils/isZeroAddress.js'\nimport { getAllowance } from './getAllowance.js'\nimport { getMaxPriorityFeePerGas } from './getMaxPriorityFeePerGas.js'\n\nexport const setAllowance = async (\n client: SDKClient,\n viemClient: Client,\n tokenAddress: Address,\n contractAddress: Address,\n amount: bigint,\n executionOptions?: ExecutionOptions,\n returnPopulatedTransaction?: boolean,\n // Without it viem uses `viemClient.chain`, which can be stale.\n chain?: Chain\n): Promise<Hash | Hex> => {\n const data = encodeFunctionData({\n abi: approveAbi,\n functionName: 'approve',\n args: [contractAddress, amount],\n })\n\n if (returnPopulatedTransaction) {\n return data\n }\n\n let transactionRequest: TransactionParameters = {\n to: tokenAddress,\n data,\n maxPriorityFeePerGas:\n viemClient.account?.type === 'local'\n ? await getMaxPriorityFeePerGas(\n client,\n viemClient,\n chain?.id ?? viemClient.chain?.id\n )\n : undefined,\n }\n\n if (executionOptions?.updateTransactionRequestHook) {\n const customizedTransactionRequest: TransactionParameters =\n await executionOptions.updateTransactionRequestHook({\n requestType: 'approve',\n ...transactionRequest,\n })\n\n transactionRequest = {\n ...transactionRequest,\n ...customizedTransactionRequest,\n }\n }\n\n return getAction(\n viemClient,\n sendTransaction,\n 'sendTransaction'\n )({\n to: transactionRequest.to,\n account: viemClient.account!,\n data: transactionRequest.data,\n gas: transactionRequest.gas,\n gasPrice: transactionRequest.gasPrice,\n maxFeePerGas: transactionRequest.maxFeePerGas,\n maxPriorityFeePerGas: transactionRequest.maxPriorityFeePerGas,\n ...(chain && { chain: getSendChain(viemClient, chain) }),\n } as SendTransactionParameters)\n}\n\n// Without a known chain, viem keeps `walletClient.chain`, as before.\nconst getTokenChain = (\n client: SDKClient,\n chainId: number\n): Promise<Chain | undefined> =>\n client.getChainById(chainId).then(convertExtendedChain, () => undefined)\n\n/**\n * Set approval for a certain token and amount.\n * @param client - The SDK client\n * @param request - The approval request\n * @param request.walletClient - The Viem wallet client used to send the transaction\n * @param request.token - The token for which to set the allowance\n * @param request.spenderAddress - The address of the spender\n * @param request.amount - The amount of tokens to approve\n * @returns Returns Hash or nothing\n */\nexport const setTokenAllowance = async (\n client: SDKClient,\n { walletClient, token, spenderAddress, amount }: ApproveTokenRequest\n): Promise<Hash | void> => {\n // native token don't need approval\n if (isZeroAddress(token.address)) {\n return\n }\n const approvedAmount = await getAllowance(\n client,\n walletClient,\n token.address as Address,\n walletClient.account!.address,\n spenderAddress as Address,\n token.chainId\n )\n\n if (amount > approvedAmount) {\n const approveTx = await setAllowance(\n client,\n walletClient,\n token.address as Address,\n spenderAddress as Address,\n amount,\n undefined,\n false,\n await getTokenChain(client, token.chainId)\n )\n\n return approveTx\n }\n}\n\n/**\n * Revoke approval for a certain token.\n * @param client - The SDK client\n * @param request - The revoke request\n * @param request.walletClient - The Viem wallet client used to send the transaction\n * @param request.token - The token for which to revoke the allowance\n * @param request.spenderAddress - The address of the spender\n * @returns Returns Hash or nothing\n */\nexport const revokeTokenApproval = async (\n client: SDKClient,\n { walletClient, token, spenderAddress }: RevokeApprovalRequest\n): Promise<Hash | void> => {\n // native token don't need approval\n if (isZeroAddress(token.address)) {\n return\n }\n const approvedAmount = await getAllowance(\n client,\n walletClient,\n token.address as Address,\n walletClient.account!.address,\n spenderAddress as Address,\n token.chainId\n )\n if (approvedAmount > 0) {\n const approveTx = await setAllowance(\n client,\n walletClient,\n token.address as Address,\n spenderAddress as Address,\n 0n,\n undefined,\n false,\n await getTokenChain(client, token.chainId)\n )\n\n return approveTx\n }\n}\n"],"mappings":";;;;;;;;;;;AAwBA,MAAa,eAAe,OAC1B,QACA,YACA,cACA,iBACA,QACA,kBACA,4BAEA,UACwB;CACxB,MAAM,QAAA,GAAOA,KAAAA,mBAAAA,CAAmB;EAC9B,KAAKC,kBAAAA;EACL,cAAc;EACd,MAAM,CAAC,iBAAiB,MAAM;CAChC,CAAC;CAED,IAAI,4BACF,OAAO;CAGT,IAAI,qBAA4C;EAC9C,IAAI;EACJ;EACA,sBACE,WAAW,SAAS,SAAS,UACzB,MAAMC,wCAAAA,wBACJ,QACA,YACA,OAAO,MAAM,WAAW,OAAO,EACjC,IACA,KAAA;CACR;CAEA,IAAI,kBAAkB,8BAA8B;EAClD,MAAM,+BACJ,MAAM,iBAAiB,6BAA6B;GAClD,aAAa;GACb,GAAG;EACL,CAAC;EAEH,qBAAqB;GACnB,GAAG;GACH,GAAG;EACL;CACF;CAEA,QAAA,GAAOC,WAAAA,UAAAA,CACL,YACAC,aAAAA,iBACA,iBACF,CAAC,CAAC;EACA,IAAI,mBAAmB;EACvB,SAAS,WAAW;EACpB,MAAM,mBAAmB;EACzB,KAAK,mBAAmB;EACxB,UAAU,mBAAmB;EAC7B,cAAc,mBAAmB;EACjC,sBAAsB,mBAAmB;EACzC,GAAI,SAAS,EAAE,OAAOC,2BAAAA,aAAa,YAAY,KAAK,EAAE;CACxD,CAA8B;AAChC;AAGA,MAAM,iBACJ,QACA,YAEA,OAAO,aAAa,OAAO,CAAC,CAAC,KAAKC,mCAAAA,4BAA4B,KAAA,CAAS;;;;;;;;;;;AAYzE,MAAa,oBAAoB,OAC/B,QACA,EAAE,cAAc,OAAO,gBAAgB,aACd;CAEzB,IAAIC,4BAAAA,cAAc,MAAM,OAAO,GAC7B;CAWF,IAAI,SAAS,MATgBC,6BAAAA,aAC3B,QACA,cACA,MAAM,SACN,aAAa,QAAS,SACtB,gBACA,MAAM,OACR,GAcE,OAAO,MAXiB,aACtB,QACA,cACA,MAAM,SACN,gBACA,QACA,KAAA,GACA,OACA,MAAM,cAAc,QAAQ,MAAM,OAAO,CAC3C;AAIJ;;;;;;;;;;AAWA,MAAa,sBAAsB,OACjC,QACA,EAAE,cAAc,OAAO,qBACE;CAEzB,IAAID,4BAAAA,cAAc,MAAM,OAAO,GAC7B;CAUF,IAAI,MARyBC,6BAAAA,aAC3B,QACA,cACA,MAAM,SACN,aAAa,QAAS,SACtB,gBACA,MAAM,OACR,IACqB,GAYnB,OAAO,MAXiB,aACtB,QACA,cACA,MAAM,SACN,gBACA,IACA,KAAA,GACA,OACA,MAAM,cAAc,QAAQ,MAAM,OAAO,CAC3C;AAIJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"waitForRelayedTransactionReceipt.js","names":["getPublicClient","getAction","getTransactionReceipt","isGaslessStep","waitForResult","TransactionError","LiFiErrorCode","getStatus","getRelayedTransactionStatus"],"sources":["../../../src/actions/waitForRelayedTransactionReceipt.ts"],"sourcesContent":["import type { SDKClient } from '@lifi/sdk'\nimport {\n type ExtendedTransactionInfo,\n type FullStatusData,\n getRelayedTransactionStatus,\n getStatus,\n isGaslessStep,\n LiFiErrorCode,\n type LiFiStep,\n type RelayStatusResponseData,\n TransactionError,\n waitForResult,\n} from '@lifi/sdk'\nimport type { Hash } from 'viem'\nimport { getTransactionReceipt } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport { getPublicClient } from '../client/publicClient.js'\nimport type { WalletCallReceipt } from '../types.js'\n\n/**\n * Status errors in a row that end the wait. A failed request, `NOT_FOUND`, the\n * 422/1004 answer of a failed lookup and a source receipt that cannot be\n * loaded each count; a PENDING answer resets the count, so a long relay does\n * not collect errors over its whole wait.\n */\nconst MAX_STATUS_ERRORS = 5\n\n/** The on-chain outcome of a source transaction, or `undefined` when its receipt cannot be loaded. */\nconst getSourceOutcome = async (\n client: SDKClient,\n chainId: number,\n hash: Hash\n): Promise<'success' | 'reverted' | undefined> => {\n try {\n const publicClient = await getPublicClient(client, chainId)\n const receipt = await getAction(\n publicClient,\n getTransactionReceipt,\n 'getTransactionReceipt'\n )({ hash })\n return receipt.status\n } catch {\n return undefined\n }\n}\n\n/**\n * Polls the relayer until the relayed transaction is done or has failed.\n *\n * @param client - {@link SDKClient}\n * @param taskId - The relayer task id.\n * @param step - The step the task belongs to.\n * @param timeout - How long to wait for a result in milliseconds. Defaults to 24 hours.\n * @param signal - Ends the wait: no status request starts after it aborts, and the request in flight and the sleep end at once.\n * @returns The receipt of the relayed transaction.\n * @throws {TransactionError} If the transaction failed, the status was not found after five status errors in a row, or no result arrived before the timeout. Only the failed transaction is a final outcome.\n * @throws The abort reason of `signal` once it aborts.\n */\nexport const waitForRelayedTransactionReceipt = async (\n client: SDKClient,\n taskId: Hash,\n step: LiFiStep,\n timeout: number = 3_600_000 * 24,\n signal?: AbortSignal\n): Promise<WalletCallReceipt> => {\n const startTime = Date.now()\n const isGasless = isGaslessStep(step)\n const isCrossChain = step.action.fromChainId !== step.action.toChainId\n let statusErrors = 0\n return waitForResult(\n async () => {\n // Without this check, a task that stays PENDING is polled forever:\n // PENDING is no status error, so the error limit does not apply. An\n // error the poll throws ends it. Not final:\n // the relayer may still execute the task, so the action keeps its task\n // id and a resume waits for it again instead of signing a new one.\n if (Date.now() - startTime > timeout) {\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n 'Relayed transaction timed out waiting for a result.'\n )\n }\n\n // A gasless task id is a hash like a 1inch `Order` task id, so the step\n // selects the endpoint. The task id alone routes a gasless request: a\n // `bridge` would let a proxy such as the Jumper backend answer it with\n // its own order lookup. The cast is the one `getRelayedTransactionStatus`\n // makes for the Hyperliquid answer of the same endpoint.\n const result = await (isGasless\n ? (getStatus(\n client,\n { taskId },\n { signal }\n ) as unknown as Promise<RelayStatusResponseData>)\n : getRelayedTransactionStatus(\n client,\n {\n taskId,\n fromChain: step.action.fromChainId,\n toChain: step.action.toChainId,\n ...(step.tool !== 'custom' && { bridge: step.tool }),\n },\n { signal }\n )\n ).catch((e) => {\n // A request that the abort ended is no failure of the relayer.\n if (process.env.NODE_ENV === 'development' && !signal?.aborted) {\n console.debug('Fetching status from relayer failed.', e)\n }\n return undefined\n })\n\n // A gasless answer is the transfer status of `/v1/status`: it reports\n // the relayed source transaction in `sending` once the relayer sent it.\n // Only a bridge transfer ends the wait at its source; on one chain the\n // relayed transaction is the whole transfer.\n const gaslessStatus = isGasless\n ? (result as unknown as FullStatusData | undefined)\n : undefined\n const bridgeSource =\n isCrossChain && gaslessStatus?.sending?.txHash\n ? ({\n status: 'success',\n transactionHash: gaslessStatus.sending.txHash,\n transactionLink: gaslessStatus.sending.txLink,\n } as unknown as WalletCallReceipt)\n : undefined\n\n const statusError = (error: TransactionError): undefined => {\n statusErrors++\n if (statusErrors < MAX_STATUS_ERRORS) {\n return undefined\n }\n throw error\n }\n\n switch (result?.status) {\n case 'PENDING':\n statusErrors = 0\n // A gasless bridge transfer whose source transaction landed waits for\n // its destination. The source wait ends here, so a later bridge\n // failure reaches the status task, not the FAILED below.\n return gaslessStatus?.substatus === 'WAIT_DESTINATION_TRANSACTION'\n ? bridgeSource\n : undefined\n case 'DONE': {\n const sending: ExtendedTransactionInfo | undefined =\n (result?.transactionStatus?.sending as ExtendedTransactionInfo) ||\n ((result as unknown as FullStatusData)\n ?.sending as ExtendedTransactionInfo)\n return {\n status: 'success',\n gasUsed: sending?.gasUsed,\n transactionHash: result?.metadata?.txHash || sending?.txHash,\n transactionLink: sending?.txLink,\n } as unknown as WalletCallReceipt\n }\n case 'FAILED':\n // FAILED with a hash is mostly a relayed source transaction that\n // reverted and moved nothing, so a resume may sign again. A bridge\n // can also fail after its source landed: the tokens left the wallet,\n // and a resume must not sign and relay a second transfer. The status\n // task follows that transfer, as for any bridge. The source receipt\n // tells the two apart.\n if (bridgeSource) {\n const outcome = await getSourceOutcome(\n client,\n step.action.fromChainId,\n bridgeSource.transactionHash\n )\n if (outcome === 'success') {\n return bridgeSource\n }\n if (outcome === undefined) {\n // The node may not have the receipt yet, so this counts as a\n // status error. Not final: a resume waits for the same task and\n // checks again.\n return statusError(\n new TransactionError(\n LiFiErrorCode.TransactionFailed,\n 'The relayed transaction failed, and its source transaction could not be checked.'\n )\n )\n }\n }\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n 'Transaction was reverted.',\n undefined,\n { final: true }\n )\n default:\n return statusError(\n new TransactionError(\n LiFiErrorCode.TransactionNotFound,\n 'Transaction not found.'\n )\n )\n }\n },\n 5000,\n undefined,\n // The poll counts its own status errors, so every error it throws ends\n // the wait.\n () => false,\n signal\n )\n}\n"],"mappings":";;;;;;;;;;;;AAyBA,MAAM,oBAAoB;;AAG1B,MAAM,mBAAmB,OACvB,QACA,SACA,SACgD;CAChD,IAAI;EACF,MAAM,eAAe,MAAMA,4BAAAA,gBAAgB,QAAQ,OAAO;EAM1D,QAAO,OAAA,GALeC,WAAAA,UAAAA,CACpB,cACAC,aAAAA,uBACA,uBACF,CAAC,CAAC,EAAE,KAAK,CAAC,EAAA,CACK;CACjB,QAAQ;EACN;CACF;AACF;;;;;;;;;;;;;AAcA,MAAa,mCAAmC,OAC9C,QACA,QACA,MACA,UAAkB,OAClB,WAC+B;CAC/B,MAAM,YAAY,KAAK,IAAI;CAC3B,MAAM,aAAA,GAAYC,UAAAA,cAAAA,CAAc,IAAI;CACpC,MAAM,eAAe,KAAK,OAAO,gBAAgB,KAAK,OAAO;CAC7D,IAAI,eAAe;CACnB,QAAA,GAAOC,UAAAA,cAAAA,CACL,YAAY;EAMV,IAAI,KAAK,IAAI,IAAI,YAAY,SAC3B,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,mBACd,qDACF;EAQF,MAAM,SAAS,OAAO,aAAA,GACjBC,UAAAA,UAAAA,CACC,QACA,EAAE,OAAO,GACT,EAAE,OAAO,CACX,KAAA,GACAC,UAAAA,4BAAAA,CACE,QACA;GACE;GACA,WAAW,KAAK,OAAO;GACvB,SAAS,KAAK,OAAO;GACrB,GAAI,KAAK,SAAS,YAAY,EAAE,QAAQ,KAAK,KAAK;EACpD,GACA,EAAE,OAAO,CACX,EAAA,CACF,OAAO,MAAM;GAEb,IAAI,QAAQ,IAAI,aAAa,iBAAiB,CAAC,QAAQ,SACrD,QAAQ,MAAM,wCAAwC,CAAC;EAG3D,CAAC;EAMD,MAAM,gBAAgB,YACjB,SACD,KAAA;EACJ,MAAM,eACJ,gBAAgB,eAAe,SAAS,SACnC;GACC,QAAQ;GACR,iBAAiB,cAAc,QAAQ;GACvC,iBAAiB,cAAc,QAAQ;EACzC,IACA,KAAA;EAEN,MAAM,eAAe,UAAuC;GAC1D;GACA,IAAI,eAAe,mBACjB;GAEF,MAAM;EACR;EAEA,QAAQ,QAAQ,QAAhB;GACE,KAAK;IACH,eAAe;IAIf,OAAO,eAAe,cAAc,iCAChC,eACA,KAAA;GACN,KAAK,QAAQ;IACX,MAAM,UACH,QAAQ,mBAAmB,WAC1B,QACE;IACN,OAAO;KACL,QAAQ;KACR,SAAS,SAAS;KAClB,iBAAiB,QAAQ,UAAU,UAAU,SAAS;KACtD,iBAAiB,SAAS;IAC5B;GACF;GACA,KAAK;IAOH,IAAI,cAAc;KAChB,MAAM,UAAU,MAAM,iBACpB,QACA,KAAK,OAAO,aACZ,aAAa,eACf;KACA,IAAI,YAAY,WACd,OAAO;KAET,IAAI,YAAY,KAAA,GAId,OAAO,YACL,IAAIH,UAAAA,iBACFC,UAAAA,cAAc,mBACd,kFACF,CACF;IAEJ;IACA,MAAM,IAAID,UAAAA,iBACRC,UAAAA,cAAc,mBACd,6BACA,KAAA,GACA,EAAE,OAAO,KAAK,CAChB;GACF,SACE,OAAO,YACL,IAAID,UAAAA,iBACFC,UAAAA,cAAc,qBACd,wBACF,CACF;EACJ;CACF,GACA,KACA,KAAA,SAGM,OACN,MACF;AACF"}
1
+ {"version":3,"file":"waitForRelayedTransactionReceipt.js","names":["getPublicClient","getAction","getTransactionReceipt","isGaslessStep","waitForResult","TransactionError","LiFiErrorCode","getStatus","getRelayedTransactionStatus"],"sources":["../../../src/actions/waitForRelayedTransactionReceipt.ts"],"sourcesContent":["import type { SDKClient } from '@lifi/sdk'\nimport {\n type ExtendedTransactionInfo,\n type FullStatusData,\n getRelayedTransactionStatus,\n getStatus,\n isGaslessStep,\n LiFiErrorCode,\n type LiFiStep,\n type RelayStatusResponseData,\n TransactionError,\n waitForResult,\n} from '@lifi/sdk'\nimport type { Hash } from 'viem'\nimport { getTransactionReceipt } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport { getPublicClient } from '../client/publicClient.js'\nimport type { WalletCallReceipt } from '../types.js'\n\n/**\n * Status errors in a row that end the wait. A failed request, `NOT_FOUND`, the\n * 422/1004 answer of a failed lookup and a source receipt that cannot be\n * loaded each count; a PENDING answer resets the count, so a long relay does\n * not collect errors over its whole wait.\n */\nconst MAX_STATUS_ERRORS = 5\n\n/** The on-chain outcome of a source transaction, or `undefined` when its receipt cannot be loaded. */\nconst getSourceOutcome = async (\n client: SDKClient,\n chainId: number,\n hash: Hash\n): Promise<'success' | 'reverted' | undefined> => {\n try {\n const publicClient = await getPublicClient(client, chainId)\n const receipt = await getAction(\n publicClient,\n getTransactionReceipt,\n 'getTransactionReceipt'\n )({ hash })\n return receipt.status\n } catch {\n return undefined\n }\n}\n\n/**\n * Polls the relayer until the relayed transaction is done or has failed.\n *\n * @param client - {@link SDKClient}\n * @param taskId - The relayer task id.\n * @param step - The step the task belongs to.\n * @param timeout - How long to wait for a result in milliseconds. Defaults to 24 hours.\n * @param signal - Ends the wait: no status request starts after it aborts, and the request in flight and the sleep end at once.\n * @returns The receipt of the relayed transaction.\n * @throws {TransactionError} If the transaction failed, the status was not found after five status errors in a row, or no result arrived before the timeout. Only the failed transaction is a final outcome.\n * @throws The abort reason of `signal` once it aborts.\n */\nexport const waitForRelayedTransactionReceipt = async (\n client: SDKClient,\n taskId: Hash,\n step: LiFiStep,\n timeout: number = 3_600_000 * 24,\n signal?: AbortSignal\n): Promise<WalletCallReceipt> => {\n const startTime = Date.now()\n const isGasless = isGaslessStep(step)\n const isCrossChain = step.action.fromChainId !== step.action.toChainId\n let statusErrors = 0\n return waitForResult(\n async () => {\n // Without this check, a task that stays PENDING is polled forever:\n // PENDING is no status error, so the error limit does not apply. An\n // error the poll throws ends it. Not final:\n // the relayer may still execute the task, so the action keeps its task\n // id and a resume waits for it again instead of signing a new one.\n if (Date.now() - startTime > timeout) {\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n 'Relayed transaction timed out waiting for a result.'\n )\n }\n\n // A gasless task id is a hash like a 1inch `Order` task id, so the step\n // selects the endpoint. The task id alone routes a gasless request: a\n // `bridge` would let a proxy such as the Jumper backend answer it with\n // its own order lookup. The cast is the one `getRelayedTransactionStatus`\n // makes for the Hyperliquid answer of the same endpoint.\n const result = await (\n isGasless\n ? (getStatus(\n client,\n { taskId },\n { signal }\n ) as unknown as Promise<RelayStatusResponseData>)\n : getRelayedTransactionStatus(\n client,\n {\n taskId,\n fromChain: step.action.fromChainId,\n toChain: step.action.toChainId,\n ...(step.tool !== 'custom' && { bridge: step.tool }),\n },\n { signal }\n )\n ).catch((e) => {\n // A request that the abort ended is no failure of the relayer.\n if (process.env.NODE_ENV === 'development' && !signal?.aborted) {\n console.debug('Fetching status from relayer failed.', e)\n }\n return undefined\n })\n\n // A gasless answer is the transfer status of `/v1/status`: it reports\n // the relayed source transaction in `sending` once the relayer sent it.\n // Only a bridge transfer ends the wait at its source; on one chain the\n // relayed transaction is the whole transfer.\n const gaslessStatus = isGasless\n ? (result as unknown as FullStatusData | undefined)\n : undefined\n const bridgeSource =\n isCrossChain && gaslessStatus?.sending?.txHash\n ? ({\n status: 'success',\n transactionHash: gaslessStatus.sending.txHash,\n transactionLink: gaslessStatus.sending.txLink,\n } as unknown as WalletCallReceipt)\n : undefined\n\n const statusError = (error: TransactionError): undefined => {\n statusErrors++\n if (statusErrors < MAX_STATUS_ERRORS) {\n return undefined\n }\n throw error\n }\n\n switch (result?.status) {\n case 'PENDING':\n statusErrors = 0\n // A gasless bridge transfer whose source transaction landed waits for\n // its destination. The source wait ends here, so a later bridge\n // failure reaches the status task, not the FAILED below.\n return gaslessStatus?.substatus === 'WAIT_DESTINATION_TRANSACTION'\n ? bridgeSource\n : undefined\n case 'DONE': {\n const sending: ExtendedTransactionInfo | undefined =\n (result?.transactionStatus?.sending as ExtendedTransactionInfo) ||\n ((result as unknown as FullStatusData)\n ?.sending as ExtendedTransactionInfo)\n return {\n status: 'success',\n gasUsed: sending?.gasUsed,\n transactionHash: result?.metadata?.txHash || sending?.txHash,\n transactionLink: sending?.txLink,\n } as unknown as WalletCallReceipt\n }\n case 'FAILED':\n // FAILED with a hash is mostly a relayed source transaction that\n // reverted and moved nothing, so a resume may sign again. A bridge\n // can also fail after its source landed: the tokens left the wallet,\n // and a resume must not sign and relay a second transfer. The status\n // task follows that transfer, as for any bridge. The source receipt\n // tells the two apart.\n if (bridgeSource) {\n const outcome = await getSourceOutcome(\n client,\n step.action.fromChainId,\n bridgeSource.transactionHash\n )\n if (outcome === 'success') {\n return bridgeSource\n }\n if (outcome === undefined) {\n // The node may not have the receipt yet, so this counts as a\n // status error. Not final: a resume waits for the same task and\n // checks again.\n return statusError(\n new TransactionError(\n LiFiErrorCode.TransactionFailed,\n 'The relayed transaction failed, and its source transaction could not be checked.'\n )\n )\n }\n }\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n 'Transaction was reverted.',\n undefined,\n { final: true }\n )\n default:\n return statusError(\n new TransactionError(\n LiFiErrorCode.TransactionNotFound,\n 'Transaction not found.'\n )\n )\n }\n },\n 5000,\n undefined,\n // The poll counts its own status errors, so every error it throws ends\n // the wait.\n () => false,\n signal\n )\n}\n"],"mappings":";;;;;;;;;;;;AAyBA,MAAM,oBAAoB;;AAG1B,MAAM,mBAAmB,OACvB,QACA,SACA,SACgD;CAChD,IAAI;EACF,MAAM,eAAe,MAAMA,4BAAAA,gBAAgB,QAAQ,OAAO;EAM1D,QAAO,OAAA,GALeC,WAAAA,UAAAA,CACpB,cACAC,aAAAA,uBACA,uBACF,CAAC,CAAC,EAAE,KAAK,CAAC,EAAA,CACK;CACjB,QAAQ;EACN;CACF;AACF;;;;;;;;;;;;;AAcA,MAAa,mCAAmC,OAC9C,QACA,QACA,MACA,UAAkB,OAClB,WAC+B;CAC/B,MAAM,YAAY,KAAK,IAAI;CAC3B,MAAM,aAAA,GAAYC,UAAAA,cAAAA,CAAc,IAAI;CACpC,MAAM,eAAe,KAAK,OAAO,gBAAgB,KAAK,OAAO;CAC7D,IAAI,eAAe;CACnB,QAAA,GAAOC,UAAAA,cAAAA,CACL,YAAY;EAMV,IAAI,KAAK,IAAI,IAAI,YAAY,SAC3B,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,mBACd,qDACF;EAQF,MAAM,SAAS,OACb,aAAA,GACKC,UAAAA,UAAAA,CACC,QACA,EAAE,OAAO,GACT,EAAE,OAAO,CACX,KAAA,GACAC,UAAAA,4BAAAA,CACE,QACA;GACE;GACA,WAAW,KAAK,OAAO;GACvB,SAAS,KAAK,OAAO;GACrB,GAAI,KAAK,SAAS,YAAY,EAAE,QAAQ,KAAK,KAAK;EACpD,GACA,EAAE,OAAO,CACX,EAAA,CACJ,OAAO,MAAM;GAEb,IAAI,QAAQ,IAAI,aAAa,iBAAiB,CAAC,QAAQ,SACrD,QAAQ,MAAM,wCAAwC,CAAC;EAG3D,CAAC;EAMD,MAAM,gBAAgB,YACjB,SACD,KAAA;EACJ,MAAM,eACJ,gBAAgB,eAAe,SAAS,SACnC;GACC,QAAQ;GACR,iBAAiB,cAAc,QAAQ;GACvC,iBAAiB,cAAc,QAAQ;EACzC,IACA,KAAA;EAEN,MAAM,eAAe,UAAuC;GAC1D;GACA,IAAI,eAAe,mBACjB;GAEF,MAAM;EACR;EAEA,QAAQ,QAAQ,QAAhB;GACE,KAAK;IACH,eAAe;IAIf,OAAO,eAAe,cAAc,iCAChC,eACA,KAAA;GACN,KAAK,QAAQ;IACX,MAAM,UACH,QAAQ,mBAAmB,WAC1B,QACE;IACN,OAAO;KACL,QAAQ;KACR,SAAS,SAAS;KAClB,iBAAiB,QAAQ,UAAU,UAAU,SAAS;KACtD,iBAAiB,SAAS;IAC5B;GACF;GACA,KAAK;IAOH,IAAI,cAAc;KAChB,MAAM,UAAU,MAAM,iBACpB,QACA,KAAK,OAAO,aACZ,aAAa,eACf;KACA,IAAI,YAAY,WACd,OAAO;KAET,IAAI,YAAY,KAAA,GAId,OAAO,YACL,IAAIH,UAAAA,iBACFC,UAAAA,cAAc,mBACd,kFACF,CACF;IAEJ;IACA,MAAM,IAAID,UAAAA,iBACRC,UAAAA,cAAc,mBACd,6BACA,KAAA,GACA,EAAE,OAAO,KAAK,CAChB;GACF,SACE,OAAO,YACL,IAAID,UAAAA,iBACFC,UAAAA,cAAc,qBACd,wBACF,CACF;EACJ;CACF,GACA,KACA,KAAA,SAGM,OACN,MACF;AACF"}
@@ -1,4 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_utils_convertExtendedChain = require("../../utils/convertExtendedChain.js");
3
+ const require_utils_getSendChain = require("../../utils/getSendChain.js");
2
4
  let _lifi_sdk = require("@lifi/sdk");
3
5
  let viem_actions = require("viem/actions");
4
6
  let viem_utils = require("viem/utils");
@@ -22,7 +24,8 @@ var EthereumBatchedSignAndExecuteTask = class extends _lifi_sdk.BaseStepExecutio
22
24
  (0, _lifi_sdk.assertNoOpenTransaction)(statusManager.findAction(step, action.type));
23
25
  const { id } = await (0, viem_utils.getAction)(updatedClient, viem_actions.sendCalls, "sendCalls")({
24
26
  account: updatedClient.account,
25
- calls
27
+ calls,
28
+ chain: require_utils_getSendChain.getSendChain(updatedClient, require_utils_convertExtendedChain.convertExtendedChain(fromChain))
26
29
  });
27
30
  statusManager.updateAction(step, action.type, "PENDING", {
28
31
  ..._lifi_sdk.CLEARED_TRANSACTION_FIELDS,
@@ -1 +1 @@
1
- {"version":3,"file":"EthereumBatchedSignAndExecuteTask.js","names":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","getAction","sendCalls","CLEARED_TRANSACTION_FIELDS"],"sources":["../../../../src/core/tasks/EthereumBatchedSignAndExecuteTask.ts"],"sourcesContent":["import {\n assertNoOpenTransaction,\n BaseStepExecutionTask,\n CLEARED_TRANSACTION_FIELDS,\n LiFiErrorCode,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport type { Address, Hash, Hex } from 'viem'\nimport { sendCalls } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport type { Call, EthereumStepExecutorContext } from '../../types.js'\n\nexport class EthereumBatchedSignAndExecuteTask extends BaseStepExecutionTask {\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n fromChain,\n statusManager,\n checkClient,\n transactionRequest,\n calls: currentCalls,\n isBridgeExecution,\n } = context\n\n const calls = [...currentCalls]\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n // Make sure that the chain is still correct\n const updatedClient = await checkClient(step)\n if (!updatedClient) {\n return { status: 'PAUSED' }\n }\n\n if (!transactionRequest) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Transaction request is not found.'\n )\n }\n\n const transferCall: Call = {\n chainId: fromChain.id,\n data: transactionRequest.data as Hex,\n to: transactionRequest.to as Address,\n value: transactionRequest.value,\n }\n\n calls.push(transferCall)\n\n // Checked again right before the wallet: a late write of an older run\n // can merge its transaction into this action during the awaits above\n // (strategy, chain switch).\n assertNoOpenTransaction(statusManager.findAction(step, action.type))\n\n const { id } = await getAction(\n updatedClient,\n sendCalls,\n 'sendCalls'\n )({\n account: updatedClient.account!,\n calls,\n })\n\n statusManager.updateAction(step, action.type, 'PENDING', {\n // A new transaction: nothing of the previous one may survive, least of\n // all its `txFinal` verdict.\n ...CLEARED_TRANSACTION_FIELDS,\n taskId: id as Hash,\n txType: 'batched',\n callCount: calls.length,\n signedAt: Date.now(),\n })\n\n return { status: 'COMPLETED', context: { calls } }\n }\n}\n"],"mappings":";;;;;AAaA,IAAa,oCAAb,cAAuDA,UAAAA,sBAAsB;CAC3E,MAAM,IAAI,SAA2D;EACnE,MAAM,EACJ,MACA,WACA,eACA,aACA,oBACA,OAAO,cACP,sBACE;EAEJ,MAAM,QAAQ,CAAC,GAAG,YAAY;EAE9B,MAAM,SAAS,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,MACtC;EACA,IAAI,CAAC,QACH,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,uBACd,kDACF;EAIF,MAAM,gBAAgB,MAAM,YAAY,IAAI;EAC5C,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;EAG5B,IAAI,CAAC,oBACH,MAAM,IAAID,UAAAA,iBACRC,UAAAA,cAAc,uBACd,kEACF;EAGF,MAAM,eAAqB;GACzB,SAAS,UAAU;GACnB,MAAM,mBAAmB;GACzB,IAAI,mBAAmB;GACvB,OAAO,mBAAmB;EAC5B;EAEA,MAAM,KAAK,YAAY;EAKvB,CAAA,GAAA,UAAA,wBAAA,CAAwB,cAAc,WAAW,MAAM,OAAO,IAAI,CAAC;EAEnE,MAAM,EAAE,OAAO,OAAA,GAAMC,WAAAA,UAAAA,CACnB,eACAC,aAAAA,WACA,WACF,CAAC,CAAC;GACA,SAAS,cAAc;GACvB;EACF,CAAC;EAED,cAAc,aAAa,MAAM,OAAO,MAAM,WAAW;GAGvD,GAAGC,UAAAA;GACH,QAAQ;GACR,QAAQ;GACR,WAAW,MAAM;GACjB,UAAU,KAAK,IAAI;EACrB,CAAC;EAED,OAAO;GAAE,QAAQ;GAAa,SAAS,EAAE,MAAM;EAAE;CACnD;AACF"}
1
+ {"version":3,"file":"EthereumBatchedSignAndExecuteTask.js","names":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","getAction","sendCalls","getSendChain","convertExtendedChain","CLEARED_TRANSACTION_FIELDS"],"sources":["../../../../src/core/tasks/EthereumBatchedSignAndExecuteTask.ts"],"sourcesContent":["import {\n assertNoOpenTransaction,\n BaseStepExecutionTask,\n CLEARED_TRANSACTION_FIELDS,\n LiFiErrorCode,\n type TaskResult,\n TransactionError,\n} from '@lifi/sdk'\nimport type { Address, Hash, Hex } from 'viem'\nimport { sendCalls } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport type { Call, EthereumStepExecutorContext } from '../../types.js'\nimport { convertExtendedChain } from '../../utils/convertExtendedChain.js'\nimport { getSendChain } from '../../utils/getSendChain.js'\n\nexport class EthereumBatchedSignAndExecuteTask extends BaseStepExecutionTask {\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n fromChain,\n statusManager,\n checkClient,\n transactionRequest,\n calls: currentCalls,\n isBridgeExecution,\n } = context\n\n const calls = [...currentCalls]\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n // Make sure that the chain is still correct\n const updatedClient = await checkClient(step)\n if (!updatedClient) {\n return { status: 'PAUSED' }\n }\n\n if (!transactionRequest) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Transaction request is not found.'\n )\n }\n\n const transferCall: Call = {\n chainId: fromChain.id,\n data: transactionRequest.data as Hex,\n to: transactionRequest.to as Address,\n value: transactionRequest.value,\n }\n\n calls.push(transferCall)\n\n // Checked again right before the wallet: a late write of an older run\n // can merge its transaction into this action during the awaits above\n // (strategy, chain switch).\n assertNoOpenTransaction(statusManager.findAction(step, action.type))\n\n const { id } = await getAction(\n updatedClient,\n sendCalls,\n 'sendCalls'\n )({\n account: updatedClient.account!,\n calls,\n // Without it `sendCalls` uses `client.chain`, which can be stale.\n chain: getSendChain(updatedClient, convertExtendedChain(fromChain)),\n })\n\n statusManager.updateAction(step, action.type, 'PENDING', {\n // A new transaction: nothing of the previous one may survive, least of\n // all its `txFinal` verdict.\n ...CLEARED_TRANSACTION_FIELDS,\n taskId: id as Hash,\n txType: 'batched',\n callCount: calls.length,\n signedAt: Date.now(),\n })\n\n return { status: 'COMPLETED', context: { calls } }\n }\n}\n"],"mappings":";;;;;;;AAeA,IAAa,oCAAb,cAAuDA,UAAAA,sBAAsB;CAC3E,MAAM,IAAI,SAA2D;EACnE,MAAM,EACJ,MACA,WACA,eACA,aACA,oBACA,OAAO,cACP,sBACE;EAEJ,MAAM,QAAQ,CAAC,GAAG,YAAY;EAE9B,MAAM,SAAS,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,MACtC;EACA,IAAI,CAAC,QACH,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,uBACd,kDACF;EAIF,MAAM,gBAAgB,MAAM,YAAY,IAAI;EAC5C,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;EAG5B,IAAI,CAAC,oBACH,MAAM,IAAID,UAAAA,iBACRC,UAAAA,cAAc,uBACd,kEACF;EAGF,MAAM,eAAqB;GACzB,SAAS,UAAU;GACnB,MAAM,mBAAmB;GACzB,IAAI,mBAAmB;GACvB,OAAO,mBAAmB;EAC5B;EAEA,MAAM,KAAK,YAAY;EAKvB,CAAA,GAAA,UAAA,wBAAA,CAAwB,cAAc,WAAW,MAAM,OAAO,IAAI,CAAC;EAEnE,MAAM,EAAE,OAAO,OAAA,GAAMC,WAAAA,UAAAA,CACnB,eACAC,aAAAA,WACA,WACF,CAAC,CAAC;GACA,SAAS,cAAc;GACvB;GAEA,OAAOC,2BAAAA,aAAa,eAAeC,mCAAAA,qBAAqB,SAAS,CAAC;EACpE,CAAC;EAED,cAAc,aAAa,MAAM,OAAO,MAAM,WAAW;GAGvD,GAAGC,UAAAA;GACH,QAAQ;GACR,QAAQ;GACR,WAAW,MAAM;GACjB,UAAU,KAAK,IAAI;EACrB,CAAC;EAED,OAAO;GAAE,QAAQ;GAAa,SAAS,EAAE,MAAM;EAAE;CACnD;AACF"}
@@ -9,7 +9,7 @@ var EthereumCheckAllowanceTask = class extends _lifi_sdk.BaseStepExecutionTask {
9
9
  return !context.hasMatchingPermit;
10
10
  }
11
11
  async run(context) {
12
- const { step, checkClient, client, statusManager } = context;
12
+ const { step, checkClient, client, statusManager, fromChain } = context;
13
13
  const action = statusManager.initializeAction({
14
14
  step,
15
15
  type: "CHECK_ALLOWANCE",
@@ -21,7 +21,7 @@ var EthereumCheckAllowanceTask = class extends _lifi_sdk.BaseStepExecutionTask {
21
21
  const fromAmount = BigInt(step.action.fromAmount);
22
22
  const updatedClient = await checkClient(step);
23
23
  if (!updatedClient) return { status: "PAUSED" };
24
- const allowance = await require_actions_getAllowance.getAllowance(client, updatedClient, step.action.fromToken.address, updatedClient.account.address, spenderAddress);
24
+ const allowance = await require_actions_getAllowance.getAllowance(client, updatedClient, step.action.fromToken.address, updatedClient.account.address, spenderAddress, fromChain.id);
25
25
  statusManager.updateAction(step, action.type, "DONE");
26
26
  return {
27
27
  status: "COMPLETED",
@@ -1 +1 @@
1
- {"version":3,"file":"EthereumCheckAllowanceTask.js","names":["BaseStepExecutionTask","getEthereumExecutionStrategy","resolveAllowanceSpender","getAllowance"],"sources":["../../../../src/core/tasks/EthereumCheckAllowanceTask.ts"],"sourcesContent":["import { BaseStepExecutionTask, type TaskResult } from '@lifi/sdk'\nimport type { Address } from 'viem'\nimport { getAllowance } from '../../actions/getAllowance.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { getEthereumExecutionStrategy } from './helpers/getEthereumExecutionStrategy.js'\nimport { resolveAllowanceSpender } from './helpers/resolveAllowanceSpender.js'\n\nexport class EthereumCheckAllowanceTask extends BaseStepExecutionTask {\n override async shouldRun(\n context: EthereumStepExecutorContext\n ): Promise<boolean> {\n return !context.hasMatchingPermit\n }\n\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const { step, checkClient, client, statusManager } = context\n\n // Start new allowance check\n const action = statusManager.initializeAction({\n step,\n type: 'CHECK_ALLOWANCE',\n chainId: step.action.fromChainId,\n status: 'STARTED',\n })\n\n const executionStrategy = await getEthereumExecutionStrategy(context)\n const { spenderAddress } = await resolveAllowanceSpender(\n context,\n executionStrategy\n )\n\n const fromAmount = BigInt(step.action.fromAmount)\n\n const updatedClient = await checkClient(step)\n if (!updatedClient) {\n return { status: 'PAUSED' }\n }\n\n const allowance = await getAllowance(\n client,\n updatedClient,\n step.action.fromToken.address as Address,\n updatedClient.account!.address,\n spenderAddress\n )\n\n statusManager.updateAction(step, action.type, 'DONE')\n\n return {\n status: 'COMPLETED',\n context: {\n hasAllowance: allowance > 0n,\n hasSufficientAllowance: fromAmount <= allowance,\n executionStrategy,\n allowanceSpender: spenderAddress,\n },\n }\n }\n}\n"],"mappings":";;;;;;AAOA,IAAa,6BAAb,cAAgDA,UAAAA,sBAAsB;CACpE,MAAe,UACb,SACkB;EAClB,OAAO,CAAC,QAAQ;CAClB;CAEA,MAAM,IAAI,SAA2D;EACnE,MAAM,EAAE,MAAM,aAAa,QAAQ,kBAAkB;EAGrD,MAAM,SAAS,cAAc,iBAAiB;GAC5C;GACA,MAAM;GACN,SAAS,KAAK,OAAO;GACrB,QAAQ;EACV,CAAC;EAED,MAAM,oBAAoB,MAAMC,wDAAAA,6BAA6B,OAAO;EACpE,MAAM,EAAE,mBAAmB,MAAMC,mDAAAA,wBAC/B,SACA,iBACF;EAEA,MAAM,aAAa,OAAO,KAAK,OAAO,UAAU;EAEhD,MAAM,gBAAgB,MAAM,YAAY,IAAI;EAC5C,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;EAG5B,MAAM,YAAY,MAAMC,6BAAAA,aACtB,QACA,eACA,KAAK,OAAO,UAAU,SACtB,cAAc,QAAS,SACvB,cACF;EAEA,cAAc,aAAa,MAAM,OAAO,MAAM,MAAM;EAEpD,OAAO;GACL,QAAQ;GACR,SAAS;IACP,cAAc,YAAY;IAC1B,wBAAwB,cAAc;IACtC;IACA,kBAAkB;GACpB;EACF;CACF;AACF"}
1
+ {"version":3,"file":"EthereumCheckAllowanceTask.js","names":["BaseStepExecutionTask","getEthereumExecutionStrategy","resolveAllowanceSpender","getAllowance"],"sources":["../../../../src/core/tasks/EthereumCheckAllowanceTask.ts"],"sourcesContent":["import { BaseStepExecutionTask, type TaskResult } from '@lifi/sdk'\nimport type { Address } from 'viem'\nimport { getAllowance } from '../../actions/getAllowance.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { getEthereumExecutionStrategy } from './helpers/getEthereumExecutionStrategy.js'\nimport { resolveAllowanceSpender } from './helpers/resolveAllowanceSpender.js'\n\nexport class EthereumCheckAllowanceTask extends BaseStepExecutionTask {\n override async shouldRun(\n context: EthereumStepExecutorContext\n ): Promise<boolean> {\n return !context.hasMatchingPermit\n }\n\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const { step, checkClient, client, statusManager, fromChain } = context\n\n // Start new allowance check\n const action = statusManager.initializeAction({\n step,\n type: 'CHECK_ALLOWANCE',\n chainId: step.action.fromChainId,\n status: 'STARTED',\n })\n\n const executionStrategy = await getEthereumExecutionStrategy(context)\n const { spenderAddress } = await resolveAllowanceSpender(\n context,\n executionStrategy\n )\n\n const fromAmount = BigInt(step.action.fromAmount)\n\n const updatedClient = await checkClient(step)\n if (!updatedClient) {\n return { status: 'PAUSED' }\n }\n\n const allowance = await getAllowance(\n client,\n updatedClient,\n step.action.fromToken.address as Address,\n updatedClient.account!.address,\n spenderAddress,\n fromChain.id\n )\n\n statusManager.updateAction(step, action.type, 'DONE')\n\n return {\n status: 'COMPLETED',\n context: {\n hasAllowance: allowance > 0n,\n hasSufficientAllowance: fromAmount <= allowance,\n executionStrategy,\n allowanceSpender: spenderAddress,\n },\n }\n }\n}\n"],"mappings":";;;;;;AAOA,IAAa,6BAAb,cAAgDA,UAAAA,sBAAsB;CACpE,MAAe,UACb,SACkB;EAClB,OAAO,CAAC,QAAQ;CAClB;CAEA,MAAM,IAAI,SAA2D;EACnE,MAAM,EAAE,MAAM,aAAa,QAAQ,eAAe,cAAc;EAGhE,MAAM,SAAS,cAAc,iBAAiB;GAC5C;GACA,MAAM;GACN,SAAS,KAAK,OAAO;GACrB,QAAQ;EACV,CAAC;EAED,MAAM,oBAAoB,MAAMC,wDAAAA,6BAA6B,OAAO;EACpE,MAAM,EAAE,mBAAmB,MAAMC,mDAAAA,wBAC/B,SACA,iBACF;EAEA,MAAM,aAAa,OAAO,KAAK,OAAO,UAAU;EAEhD,MAAM,gBAAgB,MAAM,YAAY,IAAI;EAC5C,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;EAG5B,MAAM,YAAY,MAAMC,6BAAAA,aACtB,QACA,eACA,KAAK,OAAO,UAAU,SACtB,cAAc,QAAS,SACvB,gBACA,UAAU,EACZ;EAEA,cAAc,aAAa,MAAM,OAAO,MAAM,MAAM;EAEpD,OAAO;GACL,QAAQ;GACR,SAAS;IACP,cAAc,YAAY;IAC1B,wBAAwB,cAAc;IACtC;IACA,kBAAkB;GACpB;EACF;CACF;AACF"}
@@ -36,7 +36,7 @@ var EthereumNativePermitTask = class extends _lifi_sdk.BaseStepExecutionTask {
36
36
  spenderAddress: fromChain.permit2Proxy,
37
37
  amount: fromAmount,
38
38
  ownerAddress: updatedClient.account.address
39
- });
39
+ }, fromChain.id);
40
40
  if (!nativePermitData) {
41
41
  statusManager.updateAction(step, action.type, "DONE");
42
42
  return { status: "COMPLETED" };
@@ -1 +1 @@
1
- {"version":3,"file":"EthereumNativePermitTask.js","names":["BaseStepExecutionTask","isPermit2AllowanceLane","getEthereumExecutionStrategy","getActionWithFallback","getNativePermit","isNativePermitValid","getAction","signTypedData","isValidSignature"],"sources":["../../../../src/core/tasks/EthereumNativePermitTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n type SignedTypedData,\n type TaskResult,\n} from '@lifi/sdk'\nimport type { Address } from 'viem'\nimport { signTypedData } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport { getNativePermit } from '../../permits/getNativePermit.js'\nimport { isNativePermitValid } from '../../permits/isNativePermitValid.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { getActionWithFallback } from '../../utils/getActionWithFallback.js'\nimport { isPermit2AllowanceLane } from '../../utils/getTypedDataLane.js'\nimport { isValidSignature } from '../../utils/isValidSignature.js'\nimport { getEthereumExecutionStrategy } from './helpers/getEthereumExecutionStrategy.js'\n\nexport class EthereumNativePermitTask extends BaseStepExecutionTask {\n override async shouldRun(\n context: EthereumStepExecutorContext\n ): Promise<boolean> {\n const {\n step,\n fromChain,\n hasMatchingPermit,\n hasSufficientAllowance,\n disableMessageSigning,\n } = context\n\n if (hasMatchingPermit || hasSufficientAllowance) {\n return false\n }\n\n if (isPermit2AllowanceLane(step, fromChain)) {\n return false\n }\n\n const executionStrategy = await getEthereumExecutionStrategy(context)\n const batchingSupported = executionStrategy === 'batched'\n // Check if proxy contract is available and message signing is not disabled, also not available for atomic batch\n const isNativePermitAvailable =\n !!fromChain.permit2Proxy &&\n !batchingSupported &&\n !disableMessageSigning &&\n !step.estimate.skipPermit\n return isNativePermitAvailable\n }\n\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n client,\n fromChain,\n statusManager,\n allowUserInteraction,\n checkClient,\n signedTypedData: currentSignedTypedData,\n } = context\n\n const action = statusManager.initializeAction({\n step,\n type: 'NATIVE_PERMIT',\n chainId: step.action.fromChainId,\n status: 'STARTED',\n })\n\n const updatedClient = await checkClient(step)\n if (!updatedClient) {\n return { status: 'PAUSED' }\n }\n\n const fromAmount = BigInt(step.action.fromAmount)\n\n const nativePermitData = await getActionWithFallback(\n client,\n updatedClient,\n getNativePermit,\n 'getNativePermit',\n {\n client,\n viemClient: updatedClient,\n chainId: fromChain.id,\n tokenAddress: step.action.fromToken.address as Address,\n spenderAddress: fromChain.permit2Proxy as Address,\n amount: fromAmount,\n ownerAddress: updatedClient.account!.address,\n }\n )\n\n if (!nativePermitData) {\n statusManager.updateAction(step, action.type, 'DONE')\n return { status: 'COMPLETED' }\n }\n\n const signedTypedData = [...currentSignedTypedData]\n\n // Check if we already have a valid permit for this chain and requirements\n const signedTypedDataForChain = signedTypedData.find((signedTypedData) =>\n isNativePermitValid(signedTypedData, nativePermitData)\n )\n\n if (!signedTypedDataForChain) {\n statusManager.updateAction(step, action.type, 'ACTION_REQUIRED')\n\n if (!allowUserInteraction) {\n return { status: 'PAUSED' }\n }\n\n // Sign the permit\n const signature = await getAction(\n updatedClient,\n signTypedData,\n 'signTypedData'\n )({\n account: updatedClient.account!,\n domain: nativePermitData.domain,\n types: nativePermitData.types,\n primaryType: nativePermitData.primaryType,\n message: nativePermitData.message,\n })\n\n // Some wallets resolve signTypedData with a nullish or empty value\n // instead of rejecting — skip the permit and fall back to the\n // Permit2/standard approval flow\n if (!isValidSignature(signature)) {\n statusManager.updateAction(step, action.type, 'DONE')\n return { status: 'COMPLETED' }\n }\n\n // Add the new permit to the signed permits array\n const signedPermit: SignedTypedData = {\n ...nativePermitData,\n signature,\n }\n signedTypedData.push(signedPermit)\n }\n\n statusManager.updateAction(step, action.type, 'DONE')\n\n return {\n status: 'COMPLETED',\n context: { signedTypedData, hasMatchingPermit: true },\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AAgBA,IAAa,2BAAb,cAA8CA,UAAAA,sBAAsB;CAClE,MAAe,UACb,SACkB;EAClB,MAAM,EACJ,MACA,WACA,mBACA,wBACA,0BACE;EAEJ,IAAI,qBAAqB,wBACvB,OAAO;EAGT,IAAIC,+BAAAA,uBAAuB,MAAM,SAAS,GACxC,OAAO;EAIT,MAAM,oBAAoB,MADMC,wDAAAA,6BAA6B,OAAO,MACpB;EAOhD,OAJE,CAAC,CAAC,UAAU,gBACZ,CAAC,qBACD,CAAC,yBACD,CAAC,KAAK,SAAS;CAEnB;CAEA,MAAM,IAAI,SAA2D;EACnE,MAAM,EACJ,MACA,QACA,WACA,eACA,sBACA,aACA,iBAAiB,2BACf;EAEJ,MAAM,SAAS,cAAc,iBAAiB;GAC5C;GACA,MAAM;GACN,SAAS,KAAK,OAAO;GACrB,QAAQ;EACV,CAAC;EAED,MAAM,gBAAgB,MAAM,YAAY,IAAI;EAC5C,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;EAG5B,MAAM,aAAa,OAAO,KAAK,OAAO,UAAU;EAEhD,MAAM,mBAAmB,MAAMC,oCAAAA,sBAC7B,QACA,eACAC,gCAAAA,iBACA,mBACA;GACE;GACA,YAAY;GACZ,SAAS,UAAU;GACnB,cAAc,KAAK,OAAO,UAAU;GACpC,gBAAgB,UAAU;GAC1B,QAAQ;GACR,cAAc,cAAc,QAAS;EACvC,CACF;EAEA,IAAI,CAAC,kBAAkB;GACrB,cAAc,aAAa,MAAM,OAAO,MAAM,MAAM;GACpD,OAAO,EAAE,QAAQ,YAAY;EAC/B;EAEA,MAAM,kBAAkB,CAAC,GAAG,sBAAsB;EAOlD,IAAI,CAJ4B,gBAAgB,MAAM,oBACpDC,oCAAAA,oBAAoB,iBAAiB,gBAAgB,CAG5B,GAAG;GAC5B,cAAc,aAAa,MAAM,OAAO,MAAM,iBAAiB;GAE/D,IAAI,CAAC,sBACH,OAAO,EAAE,QAAQ,SAAS;GAI5B,MAAM,YAAY,OAAA,GAAMC,WAAAA,UAAAA,CACtB,eACAC,aAAAA,eACA,eACF,CAAC,CAAC;IACA,SAAS,cAAc;IACvB,QAAQ,iBAAiB;IACzB,OAAO,iBAAiB;IACxB,aAAa,iBAAiB;IAC9B,SAAS,iBAAiB;GAC5B,CAAC;GAKD,IAAI,CAACC,+BAAAA,iBAAiB,SAAS,GAAG;IAChC,cAAc,aAAa,MAAM,OAAO,MAAM,MAAM;IACpD,OAAO,EAAE,QAAQ,YAAY;GAC/B;GAGA,MAAM,eAAgC;IACpC,GAAG;IACH;GACF;GACA,gBAAgB,KAAK,YAAY;EACnC;EAEA,cAAc,aAAa,MAAM,OAAO,MAAM,MAAM;EAEpD,OAAO;GACL,QAAQ;GACR,SAAS;IAAE;IAAiB,mBAAmB;GAAK;EACtD;CACF;AACF"}
1
+ {"version":3,"file":"EthereumNativePermitTask.js","names":["BaseStepExecutionTask","isPermit2AllowanceLane","getEthereumExecutionStrategy","getActionWithFallback","getNativePermit","isNativePermitValid","getAction","signTypedData","isValidSignature"],"sources":["../../../../src/core/tasks/EthereumNativePermitTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n type SignedTypedData,\n type TaskResult,\n} from '@lifi/sdk'\nimport type { Address } from 'viem'\nimport { signTypedData } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport { getNativePermit } from '../../permits/getNativePermit.js'\nimport { isNativePermitValid } from '../../permits/isNativePermitValid.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { getActionWithFallback } from '../../utils/getActionWithFallback.js'\nimport { isPermit2AllowanceLane } from '../../utils/getTypedDataLane.js'\nimport { isValidSignature } from '../../utils/isValidSignature.js'\nimport { getEthereumExecutionStrategy } from './helpers/getEthereumExecutionStrategy.js'\n\nexport class EthereumNativePermitTask extends BaseStepExecutionTask {\n override async shouldRun(\n context: EthereumStepExecutorContext\n ): Promise<boolean> {\n const {\n step,\n fromChain,\n hasMatchingPermit,\n hasSufficientAllowance,\n disableMessageSigning,\n } = context\n\n if (hasMatchingPermit || hasSufficientAllowance) {\n return false\n }\n\n if (isPermit2AllowanceLane(step, fromChain)) {\n return false\n }\n\n const executionStrategy = await getEthereumExecutionStrategy(context)\n const batchingSupported = executionStrategy === 'batched'\n // Check if proxy contract is available and message signing is not disabled, also not available for atomic batch\n const isNativePermitAvailable =\n !!fromChain.permit2Proxy &&\n !batchingSupported &&\n !disableMessageSigning &&\n !step.estimate.skipPermit\n return isNativePermitAvailable\n }\n\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n client,\n fromChain,\n statusManager,\n allowUserInteraction,\n checkClient,\n signedTypedData: currentSignedTypedData,\n } = context\n\n const action = statusManager.initializeAction({\n step,\n type: 'NATIVE_PERMIT',\n chainId: step.action.fromChainId,\n status: 'STARTED',\n })\n\n const updatedClient = await checkClient(step)\n if (!updatedClient) {\n return { status: 'PAUSED' }\n }\n\n const fromAmount = BigInt(step.action.fromAmount)\n\n const nativePermitData = await getActionWithFallback(\n client,\n updatedClient,\n getNativePermit,\n 'getNativePermit',\n {\n client,\n viemClient: updatedClient,\n chainId: fromChain.id,\n tokenAddress: step.action.fromToken.address as Address,\n spenderAddress: fromChain.permit2Proxy as Address,\n amount: fromAmount,\n ownerAddress: updatedClient.account!.address,\n },\n fromChain.id\n )\n\n if (!nativePermitData) {\n statusManager.updateAction(step, action.type, 'DONE')\n return { status: 'COMPLETED' }\n }\n\n const signedTypedData = [...currentSignedTypedData]\n\n // Check if we already have a valid permit for this chain and requirements\n const signedTypedDataForChain = signedTypedData.find((signedTypedData) =>\n isNativePermitValid(signedTypedData, nativePermitData)\n )\n\n if (!signedTypedDataForChain) {\n statusManager.updateAction(step, action.type, 'ACTION_REQUIRED')\n\n if (!allowUserInteraction) {\n return { status: 'PAUSED' }\n }\n\n // Sign the permit\n const signature = await getAction(\n updatedClient,\n signTypedData,\n 'signTypedData'\n )({\n account: updatedClient.account!,\n domain: nativePermitData.domain,\n types: nativePermitData.types,\n primaryType: nativePermitData.primaryType,\n message: nativePermitData.message,\n })\n\n // Some wallets resolve signTypedData with a nullish or empty value\n // instead of rejecting — skip the permit and fall back to the\n // Permit2/standard approval flow\n if (!isValidSignature(signature)) {\n statusManager.updateAction(step, action.type, 'DONE')\n return { status: 'COMPLETED' }\n }\n\n // Add the new permit to the signed permits array\n const signedPermit: SignedTypedData = {\n ...nativePermitData,\n signature,\n }\n signedTypedData.push(signedPermit)\n }\n\n statusManager.updateAction(step, action.type, 'DONE')\n\n return {\n status: 'COMPLETED',\n context: { signedTypedData, hasMatchingPermit: true },\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AAgBA,IAAa,2BAAb,cAA8CA,UAAAA,sBAAsB;CAClE,MAAe,UACb,SACkB;EAClB,MAAM,EACJ,MACA,WACA,mBACA,wBACA,0BACE;EAEJ,IAAI,qBAAqB,wBACvB,OAAO;EAGT,IAAIC,+BAAAA,uBAAuB,MAAM,SAAS,GACxC,OAAO;EAIT,MAAM,oBAAoB,MADMC,wDAAAA,6BAA6B,OAAO,MACpB;EAOhD,OAJE,CAAC,CAAC,UAAU,gBACZ,CAAC,qBACD,CAAC,yBACD,CAAC,KAAK,SAAS;CAEnB;CAEA,MAAM,IAAI,SAA2D;EACnE,MAAM,EACJ,MACA,QACA,WACA,eACA,sBACA,aACA,iBAAiB,2BACf;EAEJ,MAAM,SAAS,cAAc,iBAAiB;GAC5C;GACA,MAAM;GACN,SAAS,KAAK,OAAO;GACrB,QAAQ;EACV,CAAC;EAED,MAAM,gBAAgB,MAAM,YAAY,IAAI;EAC5C,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;EAG5B,MAAM,aAAa,OAAO,KAAK,OAAO,UAAU;EAEhD,MAAM,mBAAmB,MAAMC,oCAAAA,sBAC7B,QACA,eACAC,gCAAAA,iBACA,mBACA;GACE;GACA,YAAY;GACZ,SAAS,UAAU;GACnB,cAAc,KAAK,OAAO,UAAU;GACpC,gBAAgB,UAAU;GAC1B,QAAQ;GACR,cAAc,cAAc,QAAS;EACvC,GACA,UAAU,EACZ;EAEA,IAAI,CAAC,kBAAkB;GACrB,cAAc,aAAa,MAAM,OAAO,MAAM,MAAM;GACpD,OAAO,EAAE,QAAQ,YAAY;EAC/B;EAEA,MAAM,kBAAkB,CAAC,GAAG,sBAAsB;EAOlD,IAAI,CAJ4B,gBAAgB,MAAM,oBACpDC,oCAAAA,oBAAoB,iBAAiB,gBAAgB,CAG5B,GAAG;GAC5B,cAAc,aAAa,MAAM,OAAO,MAAM,iBAAiB;GAE/D,IAAI,CAAC,sBACH,OAAO,EAAE,QAAQ,SAAS;GAI5B,MAAM,YAAY,OAAA,GAAMC,WAAAA,UAAAA,CACtB,eACAC,aAAAA,eACA,eACF,CAAC,CAAC;IACA,SAAS,cAAc;IACvB,QAAQ,iBAAiB;IACzB,OAAO,iBAAiB;IACxB,aAAa,iBAAiB;IAC9B,SAAS,iBAAiB;GAC5B,CAAC;GAKD,IAAI,CAACC,+BAAAA,iBAAiB,SAAS,GAAG;IAChC,cAAc,aAAa,MAAM,OAAO,MAAM,MAAM;IACpD,OAAO,EAAE,QAAQ,YAAY;GAC/B;GAGA,MAAM,eAAgC;IACpC,GAAG;IACH;GACF;GACA,gBAAgB,KAAK,YAAY;EACnC;EAEA,cAAc,aAAa,MAAM,OAAO,MAAM,MAAM;EAEpD,OAAO;GACL,QAAQ;GACR,SAAS;IAAE;IAAiB,mBAAmB;GAAK;EACtD;CACF;AACF"}
@@ -36,7 +36,7 @@ var EthereumPrepareTransactionTask = class extends _lifi_sdk.BaseStepExecutionTa
36
36
  if (ethereumClient.account?.type === "local") {
37
37
  const updatedClient = await checkClient(step);
38
38
  if (!updatedClient) return { status: "PAUSED" };
39
- maxPriorityFeePerGas = await require_actions_getMaxPriorityFeePerGas.getMaxPriorityFeePerGas(client, updatedClient);
39
+ maxPriorityFeePerGas = await require_actions_getMaxPriorityFeePerGas.getMaxPriorityFeePerGas(client, updatedClient, fromChain.id);
40
40
  } else maxPriorityFeePerGas = step.transactionRequest.maxPriorityFeePerGas ? BigInt(step.transactionRequest.maxPriorityFeePerGas) : void 0;
41
41
  transactionRequest = {
42
42
  chainId: step.transactionRequest.chainId,