@lifi/sdk-provider-ethereum 4.2.6 → 4.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/README.md +9 -0
- package/dist/cjs/EthereumProvider.js +5 -1
- package/dist/cjs/EthereumProvider.js.map +1 -1
- package/dist/cjs/actions/waitForBatchTransactionReceipt.d.ts +25 -1
- package/dist/cjs/actions/waitForBatchTransactionReceipt.js +55 -7
- package/dist/cjs/actions/waitForBatchTransactionReceipt.js.map +1 -1
- package/dist/cjs/actions/waitForRelayedTransactionReceipt.d.ts +13 -1
- package/dist/cjs/actions/waitForRelayedTransactionReceipt.js +19 -5
- package/dist/cjs/actions/waitForRelayedTransactionReceipt.js.map +1 -1
- package/dist/cjs/actions/waitForSafeTransactionExecution.js +2 -2
- package/dist/cjs/actions/waitForSafeTransactionExecution.js.map +1 -1
- package/dist/cjs/actions/waitForTransactionReceipt.js +2 -2
- package/dist/cjs/actions/waitForTransactionReceipt.js.map +1 -1
- package/dist/cjs/client/publicClient.js +14 -5
- package/dist/cjs/client/publicClient.js.map +1 -1
- package/dist/cjs/core/EthereumStepExecutor.js +1 -1
- package/dist/cjs/core/EthereumStepExecutor.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumBatchedSignAndExecuteTask.js +3 -0
- package/dist/cjs/core/tasks/EthereumBatchedSignAndExecuteTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumBatchedWaitForTransactionTask.js +7 -3
- package/dist/cjs/core/tasks/EthereumBatchedWaitForTransactionTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumCheckAllowanceTask.js +5 -4
- package/dist/cjs/core/tasks/EthereumCheckAllowanceTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumPrepareTransactionTask.js +10 -1
- package/dist/cjs/core/tasks/EthereumPrepareTransactionTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumRelayedSignAndExecuteTask.js +5 -2
- package/dist/cjs/core/tasks/EthereumRelayedSignAndExecuteTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumRelayedWaitForTransactionTask.js +10 -2
- package/dist/cjs/core/tasks/EthereumRelayedWaitForTransactionTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumResetAllowanceTask.js +2 -2
- package/dist/cjs/core/tasks/EthereumResetAllowanceTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumSetAllowanceTask.js +2 -3
- package/dist/cjs/core/tasks/EthereumSetAllowanceTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumSignAndExecuteTask.js +1 -0
- package/dist/cjs/core/tasks/EthereumSignAndExecuteTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumStandardSignAndExecuteTask.js +2 -0
- package/dist/cjs/core/tasks/EthereumStandardSignAndExecuteTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumWaitForTransactionTask.js +8 -1
- package/dist/cjs/core/tasks/EthereumWaitForTransactionTask.js.map +1 -1
- package/dist/cjs/core/tasks/helpers/getEthereumExecutionStrategy.d.ts +6 -0
- package/dist/cjs/core/tasks/helpers/getEthereumExecutionStrategy.js +15 -0
- package/dist/cjs/core/tasks/helpers/getEthereumExecutionStrategy.js.map +1 -1
- package/dist/cjs/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.d.ts +17 -0
- package/dist/cjs/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.js +27 -0
- package/dist/cjs/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/resolveAllowanceSpender.d.ts +16 -0
- package/dist/cjs/core/tasks/helpers/resolveAllowanceSpender.js +21 -0
- package/dist/cjs/core/tasks/helpers/resolveAllowanceSpender.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/shouldCheckForAllowance.js +2 -1
- package/dist/cjs/core/tasks/helpers/shouldCheckForAllowance.js.map +1 -1
- package/dist/cjs/core/tasks/helpers/signHyperliquidTypedData.d.ts +5 -1
- package/dist/cjs/core/tasks/helpers/signHyperliquidTypedData.js +8 -1
- package/dist/cjs/core/tasks/helpers/signHyperliquidTypedData.js.map +1 -1
- package/dist/cjs/core/tasks/helpers/signTypedDataEntries.d.ts +6 -2
- package/dist/cjs/core/tasks/helpers/signTypedDataEntries.js +7 -2
- package/dist/cjs/core/tasks/helpers/signTypedDataEntries.js.map +1 -1
- package/dist/cjs/errors/parseEthereumErrors.js +10 -2
- package/dist/cjs/errors/parseEthereumErrors.js.map +1 -1
- package/dist/cjs/types.d.ts +6 -0
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/EthereumProvider.d.ts.map +1 -1
- package/dist/esm/EthereumProvider.js +5 -1
- package/dist/esm/EthereumProvider.js.map +1 -1
- package/dist/esm/actions/waitForBatchTransactionReceipt.d.ts +25 -1
- package/dist/esm/actions/waitForBatchTransactionReceipt.d.ts.map +1 -1
- package/dist/esm/actions/waitForBatchTransactionReceipt.js +55 -7
- package/dist/esm/actions/waitForBatchTransactionReceipt.js.map +1 -1
- package/dist/esm/actions/waitForRelayedTransactionReceipt.d.ts +13 -1
- package/dist/esm/actions/waitForRelayedTransactionReceipt.d.ts.map +1 -1
- package/dist/esm/actions/waitForRelayedTransactionReceipt.js +19 -5
- package/dist/esm/actions/waitForRelayedTransactionReceipt.js.map +1 -1
- package/dist/esm/actions/waitForSafeTransactionExecution.js +2 -2
- package/dist/esm/actions/waitForSafeTransactionExecution.js.map +1 -1
- package/dist/esm/actions/waitForTransactionReceipt.js +2 -2
- package/dist/esm/actions/waitForTransactionReceipt.js.map +1 -1
- package/dist/esm/client/publicClient.d.ts.map +1 -1
- package/dist/esm/client/publicClient.js +14 -5
- package/dist/esm/client/publicClient.js.map +1 -1
- package/dist/esm/core/EthereumStepExecutor.d.ts.map +1 -1
- package/dist/esm/core/EthereumStepExecutor.js +2 -2
- package/dist/esm/core/EthereumStepExecutor.js.map +1 -1
- package/dist/esm/core/tasks/EthereumBatchedSignAndExecuteTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumBatchedSignAndExecuteTask.js +4 -1
- package/dist/esm/core/tasks/EthereumBatchedSignAndExecuteTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumBatchedWaitForTransactionTask.js +7 -3
- package/dist/esm/core/tasks/EthereumBatchedWaitForTransactionTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumCheckAllowanceTask.js +5 -4
- package/dist/esm/core/tasks/EthereumCheckAllowanceTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumPrepareTransactionTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumPrepareTransactionTask.js +12 -3
- package/dist/esm/core/tasks/EthereumPrepareTransactionTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumRelayedSignAndExecuteTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumRelayedSignAndExecuteTask.js +6 -3
- package/dist/esm/core/tasks/EthereumRelayedSignAndExecuteTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumRelayedWaitForTransactionTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumRelayedWaitForTransactionTask.js +10 -2
- package/dist/esm/core/tasks/EthereumRelayedWaitForTransactionTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumResetAllowanceTask.js +2 -2
- package/dist/esm/core/tasks/EthereumResetAllowanceTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumSetAllowanceTask.js +2 -3
- package/dist/esm/core/tasks/EthereumSetAllowanceTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumSignAndExecuteTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumSignAndExecuteTask.js +2 -1
- package/dist/esm/core/tasks/EthereumSignAndExecuteTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.js +3 -1
- package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumWaitForTransactionTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumWaitForTransactionTask.js +9 -2
- package/dist/esm/core/tasks/EthereumWaitForTransactionTask.js.map +1 -1
- package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.d.ts +6 -0
- package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.js +15 -1
- package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.js.map +1 -1
- package/dist/esm/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.d.ts +17 -0
- package/dist/esm/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.js +26 -0
- package/dist/esm/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.js.map +1 -0
- package/dist/esm/core/tasks/helpers/resolveAllowanceSpender.d.ts +16 -0
- package/dist/esm/core/tasks/helpers/resolveAllowanceSpender.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/resolveAllowanceSpender.js +20 -0
- package/dist/esm/core/tasks/helpers/resolveAllowanceSpender.js.map +1 -0
- package/dist/esm/core/tasks/helpers/shouldCheckForAllowance.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/shouldCheckForAllowance.js +2 -1
- package/dist/esm/core/tasks/helpers/shouldCheckForAllowance.js.map +1 -1
- package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.d.ts +5 -1
- package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.js +8 -1
- package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.js.map +1 -1
- package/dist/esm/core/tasks/helpers/signTypedDataEntries.d.ts +6 -2
- package/dist/esm/core/tasks/helpers/signTypedDataEntries.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/signTypedDataEntries.js +7 -2
- package/dist/esm/core/tasks/helpers/signTypedDataEntries.js.map +1 -1
- package/dist/esm/errors/parseEthereumErrors.d.ts.map +1 -1
- package/dist/esm/errors/parseEthereumErrors.js +10 -2
- package/dist/esm/errors/parseEthereumErrors.js.map +1 -1
- package/dist/esm/types.d.ts +6 -0
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/package.json +3 -3
- package/src/EthereumProvider.ts +6 -1
- package/src/actions/waitForBatchTransactionReceipt.ts +119 -13
- package/src/actions/waitForRelayedTransactionReceipt.ts +45 -10
- package/src/actions/waitForSafeTransactionExecution.ts +6 -2
- package/src/actions/waitForTransactionReceipt.ts +6 -2
- package/src/client/publicClient.ts +20 -8
- package/src/core/EthereumStepExecutor.ts +8 -6
- package/src/core/tasks/EthereumBatchedSignAndExecuteTask.ts +11 -0
- package/src/core/tasks/EthereumBatchedWaitForTransactionTask.ts +17 -13
- package/src/core/tasks/EthereumCheckAllowanceTask.ts +5 -7
- package/src/core/tasks/EthereumPrepareTransactionTask.ts +47 -4
- package/src/core/tasks/EthereumRelayedSignAndExecuteTask.ts +22 -2
- package/src/core/tasks/EthereumRelayedWaitForTransactionTask.ts +40 -8
- package/src/core/tasks/EthereumResetAllowanceTask.ts +3 -6
- package/src/core/tasks/EthereumSetAllowanceTask.ts +4 -8
- package/src/core/tasks/EthereumSignAndExecuteTask.ts +5 -0
- package/src/core/tasks/EthereumStandardSignAndExecuteTask.ts +10 -0
- package/src/core/tasks/EthereumWaitForTransactionTask.ts +33 -2
- package/src/core/tasks/helpers/getEthereumExecutionStrategy.ts +28 -0
- package/src/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.ts +37 -0
- package/src/core/tasks/helpers/resolveAllowanceSpender.ts +24 -0
- package/src/core/tasks/helpers/shouldCheckForAllowance.ts +9 -5
- package/src/core/tasks/helpers/signHyperliquidTypedData.ts +9 -1
- package/src/core/tasks/helpers/signTypedDataEntries.ts +8 -2
- package/src/errors/parseEthereumErrors.ts +18 -10
- package/src/types.ts +6 -0
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @lifi/sdk-provider-ethereum
|
|
2
2
|
|
|
3
|
+
## 4.2.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#514](https://github.com/lifinance/sdk/pull/514) [`5dc9cc5`](https://github.com/lifinance/sdk/commit/5dc9cc5f52b0308962b822cfacd766dbf27bab3c) Thanks [@chybisov](https://github.com/chybisov)! - After a user rejected a single-call EIP-5792 bundle in MetaMask, every "Try again" failed with "This bundle id is unknown". The wallet showed no new prompt. MetaMask returns the bundle id before the user approves the bundle. When the user rejects the bundle, MetaMask removes it.
|
|
8
|
+
|
|
9
|
+
Now the SDK uses a new rule for a bundle with one call. If the wallet reports the bundle and then has no record of it in the same wait, the SDK treats the bundle as never sent. The step fails with a final `SignatureRejected`. The action keeps the bundle id with `txFinal: true`, so the action is closed, and "Try again" signs a new bundle. The SDK uses this rule only for 10 minutes after signing. Some wallets get the bundle status from a remote service, and that service can forget an old bundle.
|
|
10
|
+
|
|
11
|
+
This rule applies only to a bundle with one call. MetaMask returns the id of a bundle with two or more calls only after it sent the bundle. The action stores the number of calls in `callCount`, so the rule also works after a page reload. A bundle that the SDK stored before this release has no `callCount`, and the rule does not apply to it.
|
|
12
|
+
|
|
13
|
+
One limit stays for a bundle with one call. If the wallet sends it and then loses its record of it within 10 minutes of signing, "Try again" can sign a second bundle. Examples are "Delete activity and nonce data" or "Reset account" in MetaMask, or a remote status service that forgets the bundle.
|
|
14
|
+
|
|
15
|
+
When the wallet has no record of the bundle at its first answer, the step fails with the new code `LiFiErrorCode.CallBundleNotFound`. A page reload after the reject is an example. The step also fails with this code when the rule does not apply. An example is a wallet that loses the bundle 10 minutes or more after signing. The SDK cannot know if the wallet sent this bundle. Thus the action keeps the bundle id, and "Try again" waits for the bundle again and does not sign. A route that is stuck after a reject on `@lifi/sdk` 4.11.0 fails with `CallBundleNotFound` on its next "Try again".
|
|
16
|
+
|
|
17
|
+
If an "unknown bundle id" error (5730) reaches the error parser from another call, the step also fails with `CallBundleNotFound`, not with `SignatureRejected`.
|
|
18
|
+
- Updated dependencies [[`5dc9cc5`](https://github.com/lifinance/sdk/commit/5dc9cc5f52b0308962b822cfacd766dbf27bab3c)]:
|
|
19
|
+
- @lifi/sdk@4.12.0
|
|
20
|
+
|
|
21
|
+
## 4.2.7
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- [#510](https://github.com/lifinance/sdk/pull/510) [`bb964c0`](https://github.com/lifinance/sdk/commit/bb964c03d8ea1770303ab1bba803373a80e6388f) Thanks [@chybisov](https://github.com/chybisov)! - Bump runtime dependencies: viem to 2.57.3, @stellar/stellar-sdk to 17.2.1,
|
|
26
|
+
@mysten/sui to 2.35.0, @lifi/types to 18.13.0 and @bigmi/core to 0.9.3.
|
|
27
|
+
|
|
28
|
+
- [#509](https://github.com/lifinance/sdk/pull/509) [`34ecf9c`](https://github.com/lifinance/sdk/commit/34ecf9c4dcfa54cb2e60cacc931257fdc700c682) Thanks [@chybisov](https://github.com/chybisov)! - Concurrent first calls for a chain now share one public client instead of each building one. With `fallbackTransportConfig.rank` set, each extra client also ran its own transport ranking loop that never stopped.
|
|
29
|
+
|
|
30
|
+
- [#503](https://github.com/lifinance/sdk/pull/503) [`c7f1d3b`](https://github.com/lifinance/sdk/commit/c7f1d3b9fdf88f75a0dcbe49f0cc1de139368a02) Thanks [@chybisov](https://github.com/chybisov)! - Send the token approval when a step only turns out to be relayed at `/stepTransaction`. With an EIP-5792 wallet, a step that carries no typed data and no `executionType: 'message'` at routes time looks batchable, so the allowance tasks prepared the approval for a batch. When `/stepTransaction` then answered with typed data only, the relayer path ran: a queued approve was dropped without an error while `SET_ALLOWANCE` read `DONE`, and an allowance already found sufficient for the batch spender could be the wrong one for the relayed lane, which pulls through Permit2. Prepare now checks whether the work done for the batch still holds in the strategy the re-quote establishes, against the spender the allowance check recorded. If it does not, the step replays once in that strategy, before anything reaches the wallet, and the allowance tasks derive the spender again and send the approve as its own transaction. If the replay's re-quote changes the strategy again, the step fails with `TransactionUnprepared`, and a wallet that declines the EIP-7702 upgrade during a replay fails the step instead of asking for a second retry.
|
|
31
|
+
|
|
32
|
+
- [#507](https://github.com/lifinance/sdk/pull/507) [`14f4ecc`](https://github.com/lifinance/sdk/commit/14f4ecc2714799449d57b61ff06b040df505184e) Thanks [@chybisov](https://github.com/chybisov)! - Mark reverted, cancelled, replaced and relayed-failed transactions as final so "Try again" signs a new transaction, while any other failure after broadcast is re-checked instead. The sign task refuses to sign while the step has an open transaction. The relayed sign task checks the action again after the wallet returns: if a stopped run's transaction merged into it while the prompt was open, the step fails with `TransactionConflict` and the new signature is not relayed. The wait for a relayed transaction now ends after 24 hours (before, a task that stayed PENDING was polled every 5 seconds forever) and at once after `stopRouteExecution`; neither end is a final outcome, so the action keeps its task id and "Try again" waits for the same task instead of signing again. After `stopRouteExecution`, the wait ends without a write to the route, and the run's `executeRoute` promise resolves with the route, as for the `/status` wait. A resume waits on the lane that sent the open transaction, as stored in the action's `txType`, so a relayed step without a `transactionRequest` waits for its relayer task again, not for a transaction receipt or a wallet call bundle. A Safe wallet is not covered: the hash is stored only after the Safe transaction executes, so a resume during that wait, or after its 24-hour timeout, still creates a second proposal (unchanged).
|
|
33
|
+
- Updated dependencies [[`bb964c0`](https://github.com/lifinance/sdk/commit/bb964c03d8ea1770303ab1bba803373a80e6388f), [`48af3ae`](https://github.com/lifinance/sdk/commit/48af3aeb250299ef9d2ff9eb79a38a6b8f52d409), [`14f4ecc`](https://github.com/lifinance/sdk/commit/14f4ecc2714799449d57b61ff06b040df505184e)]:
|
|
34
|
+
- @lifi/sdk@4.11.0
|
|
35
|
+
|
|
3
36
|
## 4.2.6
|
|
4
37
|
|
|
5
38
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -83,6 +83,13 @@ needs no ecosystem library. To discover and connect browser wallets such as Frei
|
|
|
83
83
|
xBull, or Lobstr, we recommend
|
|
84
84
|
[Stellar Wallets Kit](https://github.com/Creit-Tech/Stellar-Wallets-Kit).
|
|
85
85
|
|
|
86
|
+
**Zcash**
|
|
87
|
+
```bash
|
|
88
|
+
pnpm add @lifi/sdk-provider-zcash
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
ZEC is a destination-only chain: `ZcashProvider` validates transparent `t1` and `t3` receivers, and unified `u1` receivers that carry an Orchard receiver, and needs no wallet. Register it after `BitcoinProvider`; it serves ZEC only.
|
|
92
|
+
|
|
86
93
|
## Architecture
|
|
87
94
|
|
|
88
95
|
The LI.FI SDK uses a modular provider architecture:
|
|
@@ -134,6 +141,7 @@ import { BitcoinProvider } from '@lifi/sdk-provider-bitcoin'
|
|
|
134
141
|
import { SuiProvider } from '@lifi/sdk-provider-sui'
|
|
135
142
|
import { TronProvider } from '@lifi/sdk-provider-tron'
|
|
136
143
|
import { StellarProvider } from '@lifi/sdk-provider-stellar'
|
|
144
|
+
import { ZcashProvider } from '@lifi/sdk-provider-zcash'
|
|
137
145
|
|
|
138
146
|
const client = createClient({
|
|
139
147
|
integrator: 'Your dApp/company name',
|
|
@@ -144,6 +152,7 @@ const client = createClient({
|
|
|
144
152
|
SuiProvider({ /* options */ }),
|
|
145
153
|
TronProvider({ /* options */ }),
|
|
146
154
|
StellarProvider({ /* options */ }),
|
|
155
|
+
ZcashProvider(),
|
|
147
156
|
],
|
|
148
157
|
})
|
|
149
158
|
```
|
|
@@ -9,6 +9,10 @@ let viem = require("viem");
|
|
|
9
9
|
function isEthereumTokenAddress(address) {
|
|
10
10
|
return (0, viem.isAddress)(address, { strict: false });
|
|
11
11
|
}
|
|
12
|
+
/** viem reads a second argument as options, so a chain ID must not reach it. */
|
|
13
|
+
function isEthereumAddress(address) {
|
|
14
|
+
return (0, viem.isAddress)(address);
|
|
15
|
+
}
|
|
12
16
|
function EthereumProvider(options) {
|
|
13
17
|
const _options = options ?? {};
|
|
14
18
|
return {
|
|
@@ -18,7 +22,7 @@ function EthereumProvider(options) {
|
|
|
18
22
|
get options() {
|
|
19
23
|
return _options;
|
|
20
24
|
},
|
|
21
|
-
isAddress:
|
|
25
|
+
isAddress: isEthereumAddress,
|
|
22
26
|
isTokenAddress: isEthereumTokenAddress,
|
|
23
27
|
resolveAddress: require_actions_resolveEthereumAddress.resolveEthereumAddress,
|
|
24
28
|
getBalance: require_actions_getEthereumBalance.getEthereumBalance,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumProvider.js","names":["isAddress","ChainType","resolveEthereumAddress","getEthereumBalance","EthereumStepExecutor"],"sources":["../../src/EthereumProvider.ts"],"sourcesContent":["import { ChainType, type StepExecutorOptions } from '@lifi/sdk'\nimport { isAddress } from 'viem'\nimport { getEthereumBalance } from './actions/getEthereumBalance.js'\nimport { resolveEthereumAddress } from './actions/resolveEthereumAddress.js'\nimport { EthereumStepExecutor } from './core/EthereumStepExecutor.js'\nimport type { EthereumProviderOptions, EthereumSDKProvider } from './types.js'\n\n/** The wallet format without the checksum: a pasted address keeps its case. */\nfunction isEthereumTokenAddress(address: string): boolean {\n return isAddress(address, { strict: false })\n}\n\nexport function EthereumProvider(\n options?: EthereumProviderOptions\n): EthereumSDKProvider {\n const _options: EthereumProviderOptions = options ?? {}\n return {\n get type() {\n return ChainType.EVM\n },\n get options() {\n return _options\n },\n isAddress,\n isTokenAddress: isEthereumTokenAddress,\n resolveAddress: resolveEthereumAddress,\n getBalance: getEthereumBalance,\n getWalletClient: _options.getWalletClient,\n async getStepExecutor(\n options: StepExecutorOptions\n ): Promise<EthereumStepExecutor> {\n if (!_options.getWalletClient) {\n throw new Error('Client is not provided.')\n }\n\n const walletClient = await _options.getWalletClient()\n\n const executor = new EthereumStepExecutor({\n client: walletClient,\n switchChain: _options.switchChain,\n disableMessageSigning: _options.disableMessageSigning,\n routeId: options.routeId,\n executionOptions: {\n ...options.executionOptions,\n },\n })\n\n return executor\n },\n setOptions(options: EthereumProviderOptions) {\n Object.assign(_options, options)\n },\n }\n}\n"],"mappings":";;;;;;;;AAQA,SAAS,uBAAuB,SAA0B;CACxD,QAAA,GAAOA,KAAAA,UAAAA,CAAU,SAAS,EAAE,QAAQ,MAAM,CAAC;AAC7C;AAEA,SAAgB,iBACd,SACqB;CACrB,MAAM,WAAoC,WAAW,CAAC;CACtD,OAAO;EACL,IAAI,OAAO;GACT,OAAOC,UAAAA,UAAU;EACnB;EACA,IAAI,UAAU;GACZ,OAAO;EACT;EACA,
|
|
1
|
+
{"version":3,"file":"EthereumProvider.js","names":["isAddress","ChainType","resolveEthereumAddress","getEthereumBalance","EthereumStepExecutor"],"sources":["../../src/EthereumProvider.ts"],"sourcesContent":["import { ChainType, type StepExecutorOptions } from '@lifi/sdk'\nimport { isAddress } from 'viem'\nimport { getEthereumBalance } from './actions/getEthereumBalance.js'\nimport { resolveEthereumAddress } from './actions/resolveEthereumAddress.js'\nimport { EthereumStepExecutor } from './core/EthereumStepExecutor.js'\nimport type { EthereumProviderOptions, EthereumSDKProvider } from './types.js'\n\n/** The wallet format without the checksum: a pasted address keeps its case. */\nfunction isEthereumTokenAddress(address: string): boolean {\n return isAddress(address, { strict: false })\n}\n\n/** viem reads a second argument as options, so a chain ID must not reach it. */\nfunction isEthereumAddress(address: string): boolean {\n return isAddress(address)\n}\n\nexport function EthereumProvider(\n options?: EthereumProviderOptions\n): EthereumSDKProvider {\n const _options: EthereumProviderOptions = options ?? {}\n return {\n get type() {\n return ChainType.EVM\n },\n get options() {\n return _options\n },\n isAddress: isEthereumAddress,\n isTokenAddress: isEthereumTokenAddress,\n resolveAddress: resolveEthereumAddress,\n getBalance: getEthereumBalance,\n getWalletClient: _options.getWalletClient,\n async getStepExecutor(\n options: StepExecutorOptions\n ): Promise<EthereumStepExecutor> {\n if (!_options.getWalletClient) {\n throw new Error('Client is not provided.')\n }\n\n const walletClient = await _options.getWalletClient()\n\n const executor = new EthereumStepExecutor({\n client: walletClient,\n switchChain: _options.switchChain,\n disableMessageSigning: _options.disableMessageSigning,\n routeId: options.routeId,\n executionOptions: {\n ...options.executionOptions,\n },\n })\n\n return executor\n },\n setOptions(options: EthereumProviderOptions) {\n Object.assign(_options, options)\n },\n }\n}\n"],"mappings":";;;;;;;;AAQA,SAAS,uBAAuB,SAA0B;CACxD,QAAA,GAAOA,KAAAA,UAAAA,CAAU,SAAS,EAAE,QAAQ,MAAM,CAAC;AAC7C;;AAGA,SAAS,kBAAkB,SAA0B;CACnD,QAAA,GAAOA,KAAAA,UAAAA,CAAU,OAAO;AAC1B;AAEA,SAAgB,iBACd,SACqB;CACrB,MAAM,WAAoC,WAAW,CAAC;CACtD,OAAO;EACL,IAAI,OAAO;GACT,OAAOC,UAAAA,UAAU;EACnB;EACA,IAAI,UAAU;GACZ,OAAO;EACT;EACA,WAAW;EACX,gBAAgB;EAChB,gBAAgBC,uCAAAA;EAChB,YAAYC,mCAAAA;EACZ,iBAAiB,SAAS;EAC1B,MAAM,gBACJ,SAC+B;GAC/B,IAAI,CAAC,SAAS,iBACZ,MAAM,IAAI,MAAM,yBAAyB;GAG3C,MAAM,eAAe,MAAM,SAAS,gBAAgB;GAYpD,OAAO,IAVcC,kCAAAA,qBAAqB;IACxC,QAAQ;IACR,aAAa,SAAS;IACtB,uBAAuB,SAAS;IAChC,SAAS,QAAQ;IACjB,kBAAkB,EAChB,GAAG,QAAQ,iBACb;GACF,CAEc;EAChB;EACA,WAAW,SAAkC;GAC3C,OAAO,OAAO,UAAU,OAAO;EACjC;CACF;AACF"}
|
|
@@ -2,6 +2,30 @@ import { WalletCallReceipt as WalletCallReceipt$1 } from "../types.js";
|
|
|
2
2
|
import { Client, Hash } from "viem";
|
|
3
3
|
import { GetCallsStatusReturnType } from "viem/actions";
|
|
4
4
|
//#region src/actions/waitForBatchTransactionReceipt.d.ts
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Waits until the wallet reports the EIP-5792 call bundle as done or failed.
|
|
7
|
+
*
|
|
8
|
+
* MetaMask returns the id of a single-call bundle before the user approves
|
|
9
|
+
* it, and removes the bundle on a reject: `wallet_getCallsStatus` then fails
|
|
10
|
+
* with 5730 (`UnknownBundleIdError`). It returns the id of a bundle of two or
|
|
11
|
+
* more calls only after it sent the bundle. Thus the SDK treats a bundle as
|
|
12
|
+
* never sent only when all of these are true: its stored `callCount` is 1,
|
|
13
|
+
* the wallet answered for it in this wait and then has no record of it, and
|
|
14
|
+
* this happens within `DROPPED_BUNDLE_MAX_AGE_MS` of signing.
|
|
15
|
+
*
|
|
16
|
+
* @param client - The wallet client that sent the bundle.
|
|
17
|
+
* @param batchHash - The bundle id that `wallet_sendCalls` returned.
|
|
18
|
+
* @param options.onFailed - Gets the wallet's answer for a failed bundle, before the error is thrown.
|
|
19
|
+
* @param options.signedAt - The signing time of the step (`execution.signedAt`).
|
|
20
|
+
* @param options.callCount - The stored number of calls of the bundle (`action.callCount`).
|
|
21
|
+
* @returns The receipt of the last call of the bundle.
|
|
22
|
+
* @throws {TransactionError} If the bundle failed, was canceled, or the wallet has no record of it. A bundle that the SDK treats as never sent is a final `SignatureRejected`. Any other bundle without a record is `CallBundleNotFound`, which is not final.
|
|
23
|
+
* @throws Any other error of the wallet, unchanged.
|
|
24
|
+
*/
|
|
25
|
+
export declare const waitForBatchTransactionReceipt: (client: Client, batchHash: Hash, { onFailed, signedAt, callCount }?: {
|
|
26
|
+
onFailed?: (result: GetCallsStatusReturnType) => void;
|
|
27
|
+
signedAt?: number;
|
|
28
|
+
callCount?: number;
|
|
29
|
+
}) => Promise<WalletCallReceipt$1>;
|
|
6
30
|
//#endregion
|
|
7
31
|
//# sourceMappingURL=waitForBatchTransactionReceipt.d.ts.map
|
|
@@ -1,15 +1,62 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
let _lifi_sdk = require("@lifi/sdk");
|
|
3
|
+
let viem = require("viem");
|
|
3
4
|
let viem_actions = require("viem/actions");
|
|
4
5
|
let viem_utils = require("viem/utils");
|
|
5
6
|
//#region src/actions/waitForBatchTransactionReceipt.ts
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const DROPPED_BUNDLE_MAX_AGE_MS = 6e5;
|
|
8
|
+
const isUnknownBundleIdError = (error) => error?.name === "UnknownBundleIdError" || error?.cause?.name === "UnknownBundleIdError" || error?.code === viem.UnknownBundleIdError.code;
|
|
9
|
+
/**
|
|
10
|
+
* Unknown signing time is never in the window. Nor is a signing time in the
|
|
11
|
+
* future, as in `isResendAllowed`.
|
|
12
|
+
*/
|
|
13
|
+
const isWithinDropWindow = (signedAt) => {
|
|
14
|
+
const now = Date.now();
|
|
15
|
+
return signedAt !== void 0 && now >= signedAt && now - signedAt < DROPPED_BUNDLE_MAX_AGE_MS;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Waits until the wallet reports the EIP-5792 call bundle as done or failed.
|
|
19
|
+
*
|
|
20
|
+
* MetaMask returns the id of a single-call bundle before the user approves
|
|
21
|
+
* it, and removes the bundle on a reject: `wallet_getCallsStatus` then fails
|
|
22
|
+
* with 5730 (`UnknownBundleIdError`). It returns the id of a bundle of two or
|
|
23
|
+
* more calls only after it sent the bundle. Thus the SDK treats a bundle as
|
|
24
|
+
* never sent only when all of these are true: its stored `callCount` is 1,
|
|
25
|
+
* the wallet answered for it in this wait and then has no record of it, and
|
|
26
|
+
* this happens within `DROPPED_BUNDLE_MAX_AGE_MS` of signing.
|
|
27
|
+
*
|
|
28
|
+
* @param client - The wallet client that sent the bundle.
|
|
29
|
+
* @param batchHash - The bundle id that `wallet_sendCalls` returned.
|
|
30
|
+
* @param options.onFailed - Gets the wallet's answer for a failed bundle, before the error is thrown.
|
|
31
|
+
* @param options.signedAt - The signing time of the step (`execution.signedAt`).
|
|
32
|
+
* @param options.callCount - The stored number of calls of the bundle (`action.callCount`).
|
|
33
|
+
* @returns The receipt of the last call of the bundle.
|
|
34
|
+
* @throws {TransactionError} If the bundle failed, was canceled, or the wallet has no record of it. A bundle that the SDK treats as never sent is a final `SignatureRejected`. Any other bundle without a record is `CallBundleNotFound`, which is not final.
|
|
35
|
+
* @throws Any other error of the wallet, unchanged.
|
|
36
|
+
*/
|
|
37
|
+
const waitForBatchTransactionReceipt = async (client, batchHash, { onFailed, signedAt, callCount } = {}) => {
|
|
38
|
+
let known = false;
|
|
39
|
+
let result;
|
|
40
|
+
try {
|
|
41
|
+
result = await (0, viem_utils.getAction)(client, viem_actions.waitForCallsStatus, "waitForCallsStatus")({
|
|
42
|
+
id: batchHash,
|
|
43
|
+
timeout: 864e5,
|
|
44
|
+
status: ({ statusCode }) => {
|
|
45
|
+
known = true;
|
|
46
|
+
return statusCode === 200 || statusCode >= 300;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
} catch (error) {
|
|
50
|
+
if (!isUnknownBundleIdError(error)) throw error;
|
|
51
|
+
if (known && callCount === 1 && isWithinDropWindow(signedAt)) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.SignatureRejected, "The wallet has no record of the call bundle. The SDK treats it as never sent.", error, { final: true });
|
|
52
|
+
throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.CallBundleNotFound, "The wallet has no record of the call bundle.", error);
|
|
53
|
+
}
|
|
11
54
|
if (result.status === "success") {
|
|
12
|
-
if (
|
|
55
|
+
if (result.receipts?.some((receipt) => receipt.status === "reverted")) {
|
|
56
|
+
onFailed?.(result);
|
|
57
|
+
throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionFailed, "Transaction was reverted.", void 0, { final: true });
|
|
58
|
+
}
|
|
59
|
+
if (!result.receipts?.length || !result.receipts.every((receipt) => receipt.transactionHash)) {
|
|
13
60
|
onFailed?.(result);
|
|
14
61
|
throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionFailed, "Transaction was reverted.");
|
|
15
62
|
}
|
|
@@ -17,9 +64,10 @@ const waitForBatchTransactionReceipt = async (client, batchHash, onFailed) => {
|
|
|
17
64
|
}
|
|
18
65
|
if (result.statusCode >= 400 && result.statusCode < 500) {
|
|
19
66
|
onFailed?.(result);
|
|
20
|
-
throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionCanceled, "Transaction was canceled.");
|
|
67
|
+
throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionCanceled, "Transaction was canceled.", void 0, { final: true });
|
|
21
68
|
}
|
|
22
69
|
onFailed?.(result);
|
|
70
|
+
if (result.statusCode === 500) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionFailed, "Transaction failed.", void 0, { final: true });
|
|
23
71
|
throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionFailed, "Transaction failed.");
|
|
24
72
|
};
|
|
25
73
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waitForBatchTransactionReceipt.js","names":["getAction","waitForCallsStatus","TransactionError","LiFiErrorCode"],"sources":["../../../src/actions/waitForBatchTransactionReceipt.ts"],"sourcesContent":["import { LiFiErrorCode, TransactionError } from '@lifi/sdk'\nimport type
|
|
1
|
+
{"version":3,"file":"waitForBatchTransactionReceipt.js","names":["UnknownBundleIdError","getAction","waitForCallsStatus","TransactionError","LiFiErrorCode"],"sources":["../../../src/actions/waitForBatchTransactionReceipt.ts"],"sourcesContent":["import { LiFiErrorCode, TransactionError } from '@lifi/sdk'\nimport { type Client, type Hash, UnknownBundleIdError } from 'viem'\nimport { type GetCallsStatusReturnType, waitForCallsStatus } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport type { WalletCallReceipt } from '../types.js'\n\n// Some wallets answer from a remote service that can forget an old bundle.\nconst DROPPED_BUNDLE_MAX_AGE_MS = 10 * 60_000\n\nconst isUnknownBundleIdError = (error: any): boolean =>\n error?.name === 'UnknownBundleIdError' ||\n error?.cause?.name === 'UnknownBundleIdError' ||\n error?.code === UnknownBundleIdError.code\n\n/**\n * Unknown signing time is never in the window. Nor is a signing time in the\n * future, as in `isResendAllowed`.\n */\nconst isWithinDropWindow = (signedAt: number | undefined): boolean => {\n const now = Date.now()\n return (\n signedAt !== undefined &&\n now >= signedAt &&\n now - signedAt < DROPPED_BUNDLE_MAX_AGE_MS\n )\n}\n\n/**\n * Waits until the wallet reports the EIP-5792 call bundle as done or failed.\n *\n * MetaMask returns the id of a single-call bundle before the user approves\n * it, and removes the bundle on a reject: `wallet_getCallsStatus` then fails\n * with 5730 (`UnknownBundleIdError`). It returns the id of a bundle of two or\n * more calls only after it sent the bundle. Thus the SDK treats a bundle as\n * never sent only when all of these are true: its stored `callCount` is 1,\n * the wallet answered for it in this wait and then has no record of it, and\n * this happens within `DROPPED_BUNDLE_MAX_AGE_MS` of signing.\n *\n * @param client - The wallet client that sent the bundle.\n * @param batchHash - The bundle id that `wallet_sendCalls` returned.\n * @param options.onFailed - Gets the wallet's answer for a failed bundle, before the error is thrown.\n * @param options.signedAt - The signing time of the step (`execution.signedAt`).\n * @param options.callCount - The stored number of calls of the bundle (`action.callCount`).\n * @returns The receipt of the last call of the bundle.\n * @throws {TransactionError} If the bundle failed, was canceled, or the wallet has no record of it. A bundle that the SDK treats as never sent is a final `SignatureRejected`. Any other bundle without a record is `CallBundleNotFound`, which is not final.\n * @throws Any other error of the wallet, unchanged.\n */\nexport const waitForBatchTransactionReceipt = async (\n client: Client,\n batchHash: Hash,\n {\n onFailed,\n signedAt,\n callCount,\n }: {\n onFailed?: (result: GetCallsStatusReturnType) => void\n signedAt?: number\n callCount?: number\n } = {}\n): Promise<WalletCallReceipt> => {\n let known = false\n let result: GetCallsStatusReturnType\n try {\n result = await getAction(\n client,\n waitForCallsStatus,\n 'waitForCallsStatus'\n )({\n id: batchHash,\n timeout: 3_600_000 * 24,\n // viem's default, and a record that the wallet answered for this id.\n // viem shares one poll between waits for the same client and id, and\n // calls only the predicate of the wait that started it.\n status: ({ statusCode }) => {\n known = true\n return statusCode === 200 || statusCode >= 300\n },\n })\n } catch (error) {\n if (!isUnknownBundleIdError(error)) {\n throw error\n }\n // MetaMask removes a single-call bundle in this way only before it sends\n // it. The SDK treats the bundle as never sent: a final rejection, so\n // \"Try again\" signs anew.\n if (known && callCount === 1 && isWithinDropWindow(signedAt)) {\n throw new TransactionError(\n LiFiErrorCode.SignatureRejected,\n 'The wallet has no record of the call bundle. The SDK treats it as never sent.',\n error as Error,\n { final: true }\n )\n }\n // Unknown from the first answer (a reload after the reject, another\n // wallet), too long after signing, or no stored count of one call (two\n // or more calls, or a route stored without the count): the bundle may\n // still land.\n throw new TransactionError(\n LiFiErrorCode.CallBundleNotFound,\n 'The wallet has no record of the call bundle.',\n error as Error\n )\n }\n\n if (result.status === 'success') {\n if (result.receipts?.some((receipt) => receipt.status === 'reverted')) {\n onFailed?.(result)\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n 'Transaction was reverted.',\n undefined,\n { final: true }\n )\n }\n // The wallet reports the batch as executed, but without a complete set of\n // receipts we cannot prove the outcome: it stays unknown.\n if (\n !result.receipts?.length ||\n !result.receipts.every((receipt) => receipt.transactionHash)\n ) {\n onFailed?.(result)\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n 'Transaction was reverted.'\n )\n }\n const transactionReceipt = result.receipts.at(-1)!\n return transactionReceipt\n }\n if (result.statusCode >= 400 && result.statusCode < 500) {\n onFailed?.(result)\n throw new TransactionError(\n LiFiErrorCode.TransactionCanceled,\n 'Transaction was canceled.',\n undefined,\n { final: true }\n )\n }\n onFailed?.(result)\n // Only 500 (reverted completely) is final. Some calls of a partial batch\n // (600) may be onchain, and other codes are undefined: the outcome is unknown.\n if (result.statusCode === 500) {\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n 'Transaction failed.',\n undefined,\n { final: true }\n )\n }\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n 'Transaction failed.'\n )\n}\n"],"mappings":";;;;;;AAOA,MAAM,4BAA4B;AAElC,MAAM,0BAA0B,UAC9B,OAAO,SAAS,0BAChB,OAAO,OAAO,SAAS,0BACvB,OAAO,SAASA,KAAAA,qBAAqB;;;;;AAMvC,MAAM,sBAAsB,aAA0C;CACpE,MAAM,MAAM,KAAK,IAAI;CACrB,OACE,aAAa,KAAA,KACb,OAAO,YACP,MAAM,WAAW;AAErB;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,iCAAiC,OAC5C,QACA,WACA,EACE,UACA,UACA,cAKE,CAAC,MAC0B;CAC/B,IAAI,QAAQ;CACZ,IAAI;CACJ,IAAI;EACF,SAAS,OAAA,GAAMC,WAAAA,UAAAA,CACb,QACAC,aAAAA,oBACA,oBACF,CAAC,CAAC;GACA,IAAI;GACJ,SAAS;GAIT,SAAS,EAAE,iBAAiB;IAC1B,QAAQ;IACR,OAAO,eAAe,OAAO,cAAc;GAC7C;EACF,CAAC;CACH,SAAS,OAAO;EACd,IAAI,CAAC,uBAAuB,KAAK,GAC/B,MAAM;EAKR,IAAI,SAAS,cAAc,KAAK,mBAAmB,QAAQ,GACzD,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,mBACd,iFACA,OACA,EAAE,OAAO,KAAK,CAChB;EAMF,MAAM,IAAID,UAAAA,iBACRC,UAAAA,cAAc,oBACd,gDACA,KACF;CACF;CAEA,IAAI,OAAO,WAAW,WAAW;EAC/B,IAAI,OAAO,UAAU,MAAM,YAAY,QAAQ,WAAW,UAAU,GAAG;GACrE,WAAW,MAAM;GACjB,MAAM,IAAID,UAAAA,iBACRC,UAAAA,cAAc,mBACd,6BACA,KAAA,GACA,EAAE,OAAO,KAAK,CAChB;EACF;EAGA,IACE,CAAC,OAAO,UAAU,UAClB,CAAC,OAAO,SAAS,OAAO,YAAY,QAAQ,eAAe,GAC3D;GACA,WAAW,MAAM;GACjB,MAAM,IAAID,UAAAA,iBACRC,UAAAA,cAAc,mBACd,2BACF;EACF;EAEA,OAD2B,OAAO,SAAS,GAAG,EACtB;CAC1B;CACA,IAAI,OAAO,cAAc,OAAO,OAAO,aAAa,KAAK;EACvD,WAAW,MAAM;EACjB,MAAM,IAAID,UAAAA,iBACRC,UAAAA,cAAc,qBACd,6BACA,KAAA,GACA,EAAE,OAAO,KAAK,CAChB;CACF;CACA,WAAW,MAAM;CAGjB,IAAI,OAAO,eAAe,KACxB,MAAM,IAAID,UAAAA,iBACRC,UAAAA,cAAc,mBACd,uBACA,KAAA,GACA,EAAE,OAAO,KAAK,CAChB;CAEF,MAAM,IAAID,UAAAA,iBACRC,UAAAA,cAAc,mBACd,qBACF;AACF"}
|
|
@@ -2,6 +2,18 @@ import { WalletCallReceipt as WalletCallReceipt$1 } from "../types.js";
|
|
|
2
2
|
import { LiFiStep, SDKClient } from "@lifi/sdk";
|
|
3
3
|
import { Hash } from "viem";
|
|
4
4
|
//#region src/actions/waitForRelayedTransactionReceipt.d.ts
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Polls the relayer until the relayed transaction is done or has failed.
|
|
7
|
+
*
|
|
8
|
+
* @param client - {@link SDKClient}
|
|
9
|
+
* @param taskId - The relayer task id.
|
|
10
|
+
* @param step - The step the task belongs to.
|
|
11
|
+
* @param timeout - How long to wait for a result in milliseconds. Defaults to 24 hours.
|
|
12
|
+
* @param signal - Ends the wait: no status request starts after it aborts, and the request in flight and the sleep end at once.
|
|
13
|
+
* @returns The receipt of the relayed transaction.
|
|
14
|
+
* @throws {TransactionError} If the transaction failed, was not found, or no result arrived before the timeout. Only the failed transaction is a final outcome.
|
|
15
|
+
* @throws The abort reason of `signal` once it aborts.
|
|
16
|
+
*/
|
|
17
|
+
export declare const waitForRelayedTransactionReceipt: (client: SDKClient, taskId: Hash, step: LiFiStep, timeout?: number, signal?: AbortSignal) => Promise<WalletCallReceipt$1>;
|
|
6
18
|
//#endregion
|
|
7
19
|
//# sourceMappingURL=waitForRelayedTransactionReceipt.d.ts.map
|
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
let _lifi_sdk = require("@lifi/sdk");
|
|
3
3
|
//#region src/actions/waitForRelayedTransactionReceipt.ts
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Polls the relayer until the relayed transaction is done or has failed.
|
|
6
|
+
*
|
|
7
|
+
* @param client - {@link SDKClient}
|
|
8
|
+
* @param taskId - The relayer task id.
|
|
9
|
+
* @param step - The step the task belongs to.
|
|
10
|
+
* @param timeout - How long to wait for a result in milliseconds. Defaults to 24 hours.
|
|
11
|
+
* @param signal - Ends the wait: no status request starts after it aborts, and the request in flight and the sleep end at once.
|
|
12
|
+
* @returns The receipt of the relayed transaction.
|
|
13
|
+
* @throws {TransactionError} If the transaction failed, was not found, or no result arrived before the timeout. Only the failed transaction is a final outcome.
|
|
14
|
+
* @throws The abort reason of `signal` once it aborts.
|
|
15
|
+
*/
|
|
16
|
+
const waitForRelayedTransactionReceipt = async (client, taskId, step, timeout = 864e5, signal) => {
|
|
17
|
+
const startTime = Date.now();
|
|
5
18
|
return (0, _lifi_sdk.waitForResult)(async () => {
|
|
19
|
+
if (Date.now() - startTime > timeout) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionFailed, "Relayed transaction timed out waiting for a result.");
|
|
6
20
|
const result = await (0, _lifi_sdk.getRelayedTransactionStatus)(client, {
|
|
7
21
|
taskId,
|
|
8
22
|
fromChain: step.action.fromChainId,
|
|
9
23
|
toChain: step.action.toChainId,
|
|
10
24
|
...step.tool !== "custom" && { bridge: step.tool }
|
|
11
|
-
}).catch((e) => {
|
|
12
|
-
if (process.env.NODE_ENV === "development") console.debug("Fetching status from relayer failed.", e);
|
|
25
|
+
}, { signal }).catch((e) => {
|
|
26
|
+
if (process.env.NODE_ENV === "development" && !signal?.aborted) console.debug("Fetching status from relayer failed.", e);
|
|
13
27
|
});
|
|
14
28
|
switch (result?.status) {
|
|
15
29
|
case "PENDING": return;
|
|
@@ -22,12 +36,12 @@ const waitForRelayedTransactionReceipt = async (client, taskId, step) => {
|
|
|
22
36
|
transactionLink: sending?.txLink
|
|
23
37
|
};
|
|
24
38
|
}
|
|
25
|
-
case "FAILED": throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionFailed, "Transaction was reverted.");
|
|
39
|
+
case "FAILED": throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionFailed, "Transaction was reverted.", void 0, { final: true });
|
|
26
40
|
default: throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionNotFound, "Transaction not found.");
|
|
27
41
|
}
|
|
28
42
|
}, 5e3, 3, (_, error) => {
|
|
29
43
|
return !(error instanceof _lifi_sdk.TransactionError && error.code === _lifi_sdk.LiFiErrorCode.TransactionFailed);
|
|
30
|
-
});
|
|
44
|
+
}, signal);
|
|
31
45
|
};
|
|
32
46
|
//#endregion
|
|
33
47
|
exports.waitForRelayedTransactionReceipt = waitForRelayedTransactionReceipt;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waitForRelayedTransactionReceipt.js","names":["waitForResult","
|
|
1
|
+
{"version":3,"file":"waitForRelayedTransactionReceipt.js","names":["waitForResult","TransactionError","LiFiErrorCode","getRelayedTransactionStatus"],"sources":["../../../src/actions/waitForRelayedTransactionReceipt.ts"],"sourcesContent":["import type { SDKClient } from '@lifi/sdk'\nimport {\n type ExtendedTransactionInfo,\n type FullStatusData,\n getRelayedTransactionStatus,\n LiFiErrorCode,\n type LiFiStep,\n TransactionError,\n waitForResult,\n} from '@lifi/sdk'\nimport type { Hash } from 'viem'\nimport type { WalletCallReceipt } from '../types.js'\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, was not found, 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 return waitForResult(\n async () => {\n // Without this check, a task that stays PENDING is polled forever:\n // PENDING is not an error, so the retry limit does not apply.\n // TransactionFailed is not retried, so this ends the poll. 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 const result = await 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 ).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 switch (result?.status) {\n case 'PENDING':\n return 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 throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n 'Transaction was reverted.',\n undefined,\n { final: true }\n )\n default:\n throw new TransactionError(\n LiFiErrorCode.TransactionNotFound,\n 'Transaction not found.'\n )\n }\n },\n 5000,\n 3,\n (_, error) => {\n return !(\n error instanceof TransactionError &&\n error.code === LiFiErrorCode.TransactionFailed\n )\n },\n signal\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;AAyBA,MAAa,mCAAmC,OAC9C,QACA,QACA,MACA,UAAkB,OAClB,WAC+B;CAC/B,MAAM,YAAY,KAAK,IAAI;CAC3B,QAAA,GAAOA,UAAAA,cAAAA,CACL,YAAY;EAMV,IAAI,KAAK,IAAI,IAAI,YAAY,SAC3B,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,mBACd,qDACF;EAGF,MAAM,SAAS,OAAA,GAAMC,UAAAA,4BAAAA,CACnB,QACA;GACE;GACA,WAAW,KAAK,OAAO;GACvB,SAAS,KAAK,OAAO;GACrB,GAAI,KAAK,SAAS,YAAY,EAAE,QAAQ,KAAK,KAAK;EACpD,GACA,EAAE,OAAO,CACX,CAAC,CAAC,OAAO,MAAM;GAEb,IAAI,QAAQ,IAAI,aAAa,iBAAiB,CAAC,QAAQ,SACrD,QAAQ,MAAM,wCAAwC,CAAC;EAG3D,CAAC;EAED,QAAQ,QAAQ,QAAhB;GACE,KAAK,WACH;GACF,KAAK,QAAQ;IACX,MAAM,UACH,QAAQ,mBAAmB,WAC1B,QACE;IACN,OAAO;KACL,QAAQ;KACR,SAAS,SAAS;KAClB,iBAAiB,QAAQ,SAAS,UAAU,SAAS;KACrD,iBAAiB,SAAS;IAC5B;GACF;GACA,KAAK,UACH,MAAM,IAAIF,UAAAA,iBACRC,UAAAA,cAAc,mBACd,6BACA,KAAA,GACA,EAAE,OAAO,KAAK,CAChB;GACF,SACE,MAAM,IAAID,UAAAA,iBACRC,UAAAA,cAAc,qBACd,wBACF;EACJ;CACF,GACA,KACA,IACC,GAAG,UAAU;EACZ,OAAO,EACL,iBAAiBD,UAAAA,oBACjB,MAAM,SAASC,UAAAA,cAAc;CAEjC,GACA,MACF;AACF"}
|
|
@@ -35,13 +35,13 @@ async function waitForSafeTransactionExecution(client, { chainId, safeAddress, s
|
|
|
35
35
|
}
|
|
36
36
|
const tx = await safeClient.getTransaction(safeTxHash);
|
|
37
37
|
if (tx.isExecuted) {
|
|
38
|
-
if (!tx.isSuccessful) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionFailed, "Safe transaction failed.");
|
|
38
|
+
if (!tx.isSuccessful) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionFailed, "Safe transaction failed.", void 0, { final: true });
|
|
39
39
|
if (!tx.transactionHash) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionFailed, "Safe transaction executed but no transaction hash returned.");
|
|
40
40
|
return tx.transactionHash;
|
|
41
41
|
}
|
|
42
42
|
if (pollCount % 3 === 0) {
|
|
43
43
|
const { results } = await safeClient.getTransactions(safeAddress);
|
|
44
|
-
if (results.find((t) => t.isExecuted && Number(t.nonce) >= originalNonce && t.safeTxHash !== safeTxHash)) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionCanceled, "Safe transaction was replaced by another transaction.");
|
|
44
|
+
if (results.find((t) => t.isExecuted && Number(t.nonce) >= originalNonce && t.safeTxHash !== safeTxHash)) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionCanceled, "Safe transaction was replaced by another transaction.", void 0, { final: true });
|
|
45
45
|
}
|
|
46
46
|
}, (poll) => Math.min(basePollingInterval + poll * 2e3, 3e4), Number.MAX_SAFE_INTEGER, (_attempts, error) => !(error instanceof _lifi_sdk.TransactionError));
|
|
47
47
|
} catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waitForSafeTransactionExecution.js","names":["getSafeApiKey","getSafeClient","waitForResult","TransactionError","LiFiErrorCode"],"sources":["../../../src/actions/waitForSafeTransactionExecution.ts"],"sourcesContent":["import {\n LiFiErrorCode,\n type SDKClient,\n TransactionError,\n waitForResult,\n} from '@lifi/sdk'\nimport type { Address, Hash } from 'viem'\nimport { getSafeClient } from '../client/safeClient.js'\nimport { getSafeApiKey } from '../utils/getSafeApiKey.js'\n\nexport interface WaitForSafeTransactionExecutionProps {\n chainId: number\n safeAddress: Address\n signature: string\n pollingInterval?: number\n timeout?: number\n}\n\n/**\n * Polls the Safe Transaction Service until the transaction matching the given signature\n * is executed, then resolves with the on-chain transaction hash.\n *\n * @param client - {@link SDKClient}\n * @param props - {@link WaitForSafeTransactionExecutionProps}\n * @returns The on-chain transaction hash once the Safe transaction is executed.\n * @throws {TransactionError} If the transaction fails, is replaced, or polling times out.\n */\nexport async function waitForSafeTransactionExecution(\n client: SDKClient,\n {\n chainId,\n safeAddress,\n signature,\n pollingInterval,\n timeout: timeoutMs,\n }: WaitForSafeTransactionExecutionProps\n): Promise<Hash> {\n const basePollingInterval = pollingInterval ?? 10_000\n const timeout = timeoutMs ?? 3_600_000 * 24 // 24 hours default\n const safeApiKey = getSafeApiKey(client)\n const safeClient = getSafeClient(chainId, safeApiKey)\n let safeTxHash: Hash | undefined\n let originalNonce: number | undefined\n let pollCount = 0\n const normalizedSignature = signature.toLowerCase()\n const startTime = Date.now()\n\n try {\n return await waitForResult<Hash>(\n async () => {\n pollCount++\n\n if (Date.now() - startTime > timeout) {\n throw new Error('Safe transaction polling timed out')\n }\n\n // Resolve signature to safeTxHash\n if (!safeTxHash) {\n const { results } = await safeClient.getTransactions(safeAddress)\n\n const match = results.find((tx) =>\n tx.confirmations?.some(\n (c) => c.signature?.toLowerCase() === normalizedSignature\n )\n )\n if (!match) {\n return undefined\n }\n safeTxHash = match.safeTxHash as Hash\n originalNonce = Number(match.nonce)\n }\n\n // single-tx lookup for execution status\n const tx = await safeClient.getTransaction(safeTxHash)\n\n if (tx.isExecuted) {\n if (!tx.isSuccessful) {\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n 'Safe transaction failed.'\n )\n }\n if (!tx.transactionHash) {\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n 'Safe transaction executed but no transaction hash returned.'\n )\n }\n return tx.transactionHash as Hash\n }\n\n // Check for replacement every 3rd poll\n if (pollCount % 3 === 0) {\n const { results } = await safeClient.getTransactions(safeAddress)\n const replaced = results.find(\n (t) =>\n t.isExecuted &&\n Number(t.nonce) >= originalNonce! &&\n t.safeTxHash !== safeTxHash\n )\n if (replaced) {\n throw new TransactionError(\n LiFiErrorCode.TransactionCanceled,\n 'Safe transaction was replaced by another transaction.'\n )\n }\n }\n\n return undefined\n },\n // Dynamic backoff: 10s → 30s, increasing by 2s each poll\n (poll) => Math.min(basePollingInterval + poll * 2_000, 30_000),\n Number.MAX_SAFE_INTEGER,\n (_attempts, error) => !(error instanceof TransactionError)\n )\n } catch (error) {\n if (error instanceof TransactionError) {\n throw error\n }\n // Timeout or maxRetries exhausted\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n 'Safe transaction timed out waiting for execution.'\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA2BA,eAAsB,gCACpB,QACA,EACE,SACA,aACA,WACA,iBACA,SAAS,aAEI;CACf,MAAM,sBAAsB,mBAAmB;CAC/C,MAAM,UAAU,aAAa;CAC7B,MAAM,aAAaA,4BAAAA,cAAc,MAAM;CACvC,MAAM,aAAaC,0BAAAA,cAAc,SAAS,UAAU;CACpD,IAAI;CACJ,IAAI;CACJ,IAAI,YAAY;CAChB,MAAM,sBAAsB,UAAU,YAAY;CAClD,MAAM,YAAY,KAAK,IAAI;CAE3B,IAAI;EACF,OAAO,OAAA,GAAMC,UAAAA,cAAAA,CACX,YAAY;GACV;GAEA,IAAI,KAAK,IAAI,IAAI,YAAY,SAC3B,MAAM,IAAI,MAAM,oCAAoC;GAItD,IAAI,CAAC,YAAY;IACf,MAAM,EAAE,YAAY,MAAM,WAAW,gBAAgB,WAAW;IAEhE,MAAM,QAAQ,QAAQ,MAAM,OAC1B,GAAG,eAAe,MACf,MAAM,EAAE,WAAW,YAAY,MAAM,mBACxC,CACF;IACA,IAAI,CAAC,OACH;IAEF,aAAa,MAAM;IACnB,gBAAgB,OAAO,MAAM,KAAK;GACpC;GAGA,MAAM,KAAK,MAAM,WAAW,eAAe,UAAU;GAErD,IAAI,GAAG,YAAY;IACjB,IAAI,CAAC,GAAG,cACN,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,mBACd,
|
|
1
|
+
{"version":3,"file":"waitForSafeTransactionExecution.js","names":["getSafeApiKey","getSafeClient","waitForResult","TransactionError","LiFiErrorCode"],"sources":["../../../src/actions/waitForSafeTransactionExecution.ts"],"sourcesContent":["import {\n LiFiErrorCode,\n type SDKClient,\n TransactionError,\n waitForResult,\n} from '@lifi/sdk'\nimport type { Address, Hash } from 'viem'\nimport { getSafeClient } from '../client/safeClient.js'\nimport { getSafeApiKey } from '../utils/getSafeApiKey.js'\n\nexport interface WaitForSafeTransactionExecutionProps {\n chainId: number\n safeAddress: Address\n signature: string\n pollingInterval?: number\n timeout?: number\n}\n\n/**\n * Polls the Safe Transaction Service until the transaction matching the given signature\n * is executed, then resolves with the on-chain transaction hash.\n *\n * @param client - {@link SDKClient}\n * @param props - {@link WaitForSafeTransactionExecutionProps}\n * @returns The on-chain transaction hash once the Safe transaction is executed.\n * @throws {TransactionError} If the transaction fails, is replaced, or polling times out.\n */\nexport async function waitForSafeTransactionExecution(\n client: SDKClient,\n {\n chainId,\n safeAddress,\n signature,\n pollingInterval,\n timeout: timeoutMs,\n }: WaitForSafeTransactionExecutionProps\n): Promise<Hash> {\n const basePollingInterval = pollingInterval ?? 10_000\n const timeout = timeoutMs ?? 3_600_000 * 24 // 24 hours default\n const safeApiKey = getSafeApiKey(client)\n const safeClient = getSafeClient(chainId, safeApiKey)\n let safeTxHash: Hash | undefined\n let originalNonce: number | undefined\n let pollCount = 0\n const normalizedSignature = signature.toLowerCase()\n const startTime = Date.now()\n\n try {\n return await waitForResult<Hash>(\n async () => {\n pollCount++\n\n if (Date.now() - startTime > timeout) {\n throw new Error('Safe transaction polling timed out')\n }\n\n // Resolve signature to safeTxHash\n if (!safeTxHash) {\n const { results } = await safeClient.getTransactions(safeAddress)\n\n const match = results.find((tx) =>\n tx.confirmations?.some(\n (c) => c.signature?.toLowerCase() === normalizedSignature\n )\n )\n if (!match) {\n return undefined\n }\n safeTxHash = match.safeTxHash as Hash\n originalNonce = Number(match.nonce)\n }\n\n // single-tx lookup for execution status\n const tx = await safeClient.getTransaction(safeTxHash)\n\n if (tx.isExecuted) {\n if (!tx.isSuccessful) {\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n 'Safe transaction failed.',\n undefined,\n { final: true }\n )\n }\n if (!tx.transactionHash) {\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n 'Safe transaction executed but no transaction hash returned.'\n )\n }\n return tx.transactionHash as Hash\n }\n\n // Check for replacement every 3rd poll\n if (pollCount % 3 === 0) {\n const { results } = await safeClient.getTransactions(safeAddress)\n const replaced = results.find(\n (t) =>\n t.isExecuted &&\n Number(t.nonce) >= originalNonce! &&\n t.safeTxHash !== safeTxHash\n )\n if (replaced) {\n throw new TransactionError(\n LiFiErrorCode.TransactionCanceled,\n 'Safe transaction was replaced by another transaction.',\n undefined,\n { final: true }\n )\n }\n }\n\n return undefined\n },\n // Dynamic backoff: 10s → 30s, increasing by 2s each poll\n (poll) => Math.min(basePollingInterval + poll * 2_000, 30_000),\n Number.MAX_SAFE_INTEGER,\n (_attempts, error) => !(error instanceof TransactionError)\n )\n } catch (error) {\n if (error instanceof TransactionError) {\n throw error\n }\n // Timeout or maxRetries exhausted\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n 'Safe transaction timed out waiting for execution.'\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA2BA,eAAsB,gCACpB,QACA,EACE,SACA,aACA,WACA,iBACA,SAAS,aAEI;CACf,MAAM,sBAAsB,mBAAmB;CAC/C,MAAM,UAAU,aAAa;CAC7B,MAAM,aAAaA,4BAAAA,cAAc,MAAM;CACvC,MAAM,aAAaC,0BAAAA,cAAc,SAAS,UAAU;CACpD,IAAI;CACJ,IAAI;CACJ,IAAI,YAAY;CAChB,MAAM,sBAAsB,UAAU,YAAY;CAClD,MAAM,YAAY,KAAK,IAAI;CAE3B,IAAI;EACF,OAAO,OAAA,GAAMC,UAAAA,cAAAA,CACX,YAAY;GACV;GAEA,IAAI,KAAK,IAAI,IAAI,YAAY,SAC3B,MAAM,IAAI,MAAM,oCAAoC;GAItD,IAAI,CAAC,YAAY;IACf,MAAM,EAAE,YAAY,MAAM,WAAW,gBAAgB,WAAW;IAEhE,MAAM,QAAQ,QAAQ,MAAM,OAC1B,GAAG,eAAe,MACf,MAAM,EAAE,WAAW,YAAY,MAAM,mBACxC,CACF;IACA,IAAI,CAAC,OACH;IAEF,aAAa,MAAM;IACnB,gBAAgB,OAAO,MAAM,KAAK;GACpC;GAGA,MAAM,KAAK,MAAM,WAAW,eAAe,UAAU;GAErD,IAAI,GAAG,YAAY;IACjB,IAAI,CAAC,GAAG,cACN,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,mBACd,4BACA,KAAA,GACA,EAAE,OAAO,KAAK,CAChB;IAEF,IAAI,CAAC,GAAG,iBACN,MAAM,IAAID,UAAAA,iBACRC,UAAAA,cAAc,mBACd,6DACF;IAEF,OAAO,GAAG;GACZ;GAGA,IAAI,YAAY,MAAM,GAAG;IACvB,MAAM,EAAE,YAAY,MAAM,WAAW,gBAAgB,WAAW;IAOhE,IANiB,QAAQ,MACtB,MACC,EAAE,cACF,OAAO,EAAE,KAAK,KAAK,iBACnB,EAAE,eAAe,UAEV,GACT,MAAM,IAAID,UAAAA,iBACRC,UAAAA,cAAc,qBACd,yDACA,KAAA,GACA,EAAE,OAAO,KAAK,CAChB;GAEJ;EAGF,IAEC,SAAS,KAAK,IAAI,sBAAsB,OAAO,KAAO,GAAM,GAC7D,OAAO,mBACN,WAAW,UAAU,EAAE,iBAAiBD,UAAAA,iBAC3C;CACF,SAAS,OAAO;EACd,IAAI,iBAAiBA,UAAAA,kBACnB,MAAM;EAGR,MAAM,IAAIA,UAAAA,iBACRC,UAAAA,cAAc,mBACd,mDACF;CACF;AACF"}
|
|
@@ -10,8 +10,8 @@ async function waitForTransactionReceipt(client, { client: viemClient, chainId,
|
|
|
10
10
|
transactionReceipt = result.transactionReceipt;
|
|
11
11
|
replacementReason = result.replacementReason;
|
|
12
12
|
}
|
|
13
|
-
if (transactionReceipt?.status === "reverted") throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionFailed, "Transaction was reverted.");
|
|
14
|
-
if (replacementReason === "cancelled" || replacementReason === "replaced") throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionCanceled, "Transaction was canceled or replaced.");
|
|
13
|
+
if (transactionReceipt?.status === "reverted") throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionFailed, "Transaction was reverted.", void 0, { final: true });
|
|
14
|
+
if (replacementReason === "cancelled" || replacementReason === "replaced") throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionCanceled, "Transaction was canceled or replaced.", void 0, { final: true });
|
|
15
15
|
return transactionReceipt;
|
|
16
16
|
}
|
|
17
17
|
async function waitForReceipt(client, txHash, onReplaced) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waitForTransactionReceipt.js","names":["getPublicClient","TransactionError","LiFiErrorCode","waitForTransactionReceiptInternal"],"sources":["../../../src/actions/waitForTransactionReceipt.ts"],"sourcesContent":["import {\n type ChainId,\n LiFiErrorCode,\n type SDKClient,\n TransactionError,\n} from '@lifi/sdk'\nimport type {\n Chain,\n Client,\n Hash,\n ReplacementReason,\n ReplacementReturnType,\n TransactionReceipt,\n} from 'viem'\nimport { waitForTransactionReceipt as waitForTransactionReceiptInternal } from 'viem/actions'\nimport { getPublicClient } from '../client/publicClient.js'\n\ninterface WaitForTransactionReceiptProps {\n client: Client\n chainId: ChainId\n txHash: Hash\n onReplaced?: (response: ReplacementReturnType<Chain | undefined>) => void\n}\n\nexport async function waitForTransactionReceipt(\n client: SDKClient,\n {\n client: viemClient,\n chainId,\n txHash,\n onReplaced,\n }: WaitForTransactionReceiptProps\n): Promise<TransactionReceipt | undefined> {\n let { transactionReceipt, replacementReason } = await waitForReceipt(\n viemClient,\n txHash,\n onReplaced\n )\n\n if (!transactionReceipt?.status) {\n const publicClient = await getPublicClient(client, chainId)\n const result = await waitForReceipt(publicClient, txHash, onReplaced)\n transactionReceipt = result.transactionReceipt\n replacementReason = result.replacementReason\n }\n\n if (transactionReceipt?.status === 'reverted') {\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n 'Transaction was reverted.'\n )\n }\n // We should only allow repriced transaction to continue the execution.\n // Cancelled and replaced transactions should be treated as failed.\n if (replacementReason === 'cancelled' || replacementReason === 'replaced') {\n throw new TransactionError(\n LiFiErrorCode.TransactionCanceled,\n 'Transaction was canceled or replaced.'\n )\n }\n\n return transactionReceipt\n}\n\nasync function waitForReceipt(\n client: Client,\n txHash: Hash,\n onReplaced?: (response: ReplacementReturnType<Chain | undefined>) => void\n): Promise<{\n transactionReceipt?: TransactionReceipt\n replacementReason?: ReplacementReason\n}> {\n let replacementReason: ReplacementReason | undefined\n let transactionReceipt: TransactionReceipt | undefined\n\n try {\n transactionReceipt = await waitForTransactionReceiptInternal(client, {\n hash: txHash,\n onReplaced: (response) => {\n replacementReason = response.reason\n onReplaced?.(response)\n },\n })\n } catch {\n // We can ignore errors from waitForTransactionReceipt as we have a status check fallback\n }\n\n return { transactionReceipt, replacementReason }\n}\n"],"mappings":";;;;;AAwBA,eAAsB,0BACpB,QACA,EACE,QAAQ,YACR,SACA,QACA,cAEuC;CACzC,IAAI,EAAE,oBAAoB,sBAAsB,MAAM,eACpD,YACA,QACA,UACF;CAEA,IAAI,CAAC,oBAAoB,QAAQ;EAE/B,MAAM,SAAS,MAAM,eAAe,MADTA,4BAAAA,gBAAgB,QAAQ,OAAO,GACR,QAAQ,UAAU;EACpE,qBAAqB,OAAO;EAC5B,oBAAoB,OAAO;CAC7B;CAEA,IAAI,oBAAoB,WAAW,YACjC,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,mBACd,
|
|
1
|
+
{"version":3,"file":"waitForTransactionReceipt.js","names":["getPublicClient","TransactionError","LiFiErrorCode","waitForTransactionReceiptInternal"],"sources":["../../../src/actions/waitForTransactionReceipt.ts"],"sourcesContent":["import {\n type ChainId,\n LiFiErrorCode,\n type SDKClient,\n TransactionError,\n} from '@lifi/sdk'\nimport type {\n Chain,\n Client,\n Hash,\n ReplacementReason,\n ReplacementReturnType,\n TransactionReceipt,\n} from 'viem'\nimport { waitForTransactionReceipt as waitForTransactionReceiptInternal } from 'viem/actions'\nimport { getPublicClient } from '../client/publicClient.js'\n\ninterface WaitForTransactionReceiptProps {\n client: Client\n chainId: ChainId\n txHash: Hash\n onReplaced?: (response: ReplacementReturnType<Chain | undefined>) => void\n}\n\nexport async function waitForTransactionReceipt(\n client: SDKClient,\n {\n client: viemClient,\n chainId,\n txHash,\n onReplaced,\n }: WaitForTransactionReceiptProps\n): Promise<TransactionReceipt | undefined> {\n let { transactionReceipt, replacementReason } = await waitForReceipt(\n viemClient,\n txHash,\n onReplaced\n )\n\n if (!transactionReceipt?.status) {\n const publicClient = await getPublicClient(client, chainId)\n const result = await waitForReceipt(publicClient, txHash, onReplaced)\n transactionReceipt = result.transactionReceipt\n replacementReason = result.replacementReason\n }\n\n if (transactionReceipt?.status === 'reverted') {\n throw new TransactionError(\n LiFiErrorCode.TransactionFailed,\n 'Transaction was reverted.',\n undefined,\n { final: true }\n )\n }\n // We should only allow repriced transaction to continue the execution.\n // Cancelled and replaced transactions should be treated as failed.\n if (replacementReason === 'cancelled' || replacementReason === 'replaced') {\n throw new TransactionError(\n LiFiErrorCode.TransactionCanceled,\n 'Transaction was canceled or replaced.',\n undefined,\n { final: true }\n )\n }\n\n return transactionReceipt\n}\n\nasync function waitForReceipt(\n client: Client,\n txHash: Hash,\n onReplaced?: (response: ReplacementReturnType<Chain | undefined>) => void\n): Promise<{\n transactionReceipt?: TransactionReceipt\n replacementReason?: ReplacementReason\n}> {\n let replacementReason: ReplacementReason | undefined\n let transactionReceipt: TransactionReceipt | undefined\n\n try {\n transactionReceipt = await waitForTransactionReceiptInternal(client, {\n hash: txHash,\n onReplaced: (response) => {\n replacementReason = response.reason\n onReplaced?.(response)\n },\n })\n } catch {\n // We can ignore errors from waitForTransactionReceipt as we have a status check fallback\n }\n\n return { transactionReceipt, replacementReason }\n}\n"],"mappings":";;;;;AAwBA,eAAsB,0BACpB,QACA,EACE,QAAQ,YACR,SACA,QACA,cAEuC;CACzC,IAAI,EAAE,oBAAoB,sBAAsB,MAAM,eACpD,YACA,QACA,UACF;CAEA,IAAI,CAAC,oBAAoB,QAAQ;EAE/B,MAAM,SAAS,MAAM,eAAe,MADTA,4BAAAA,gBAAgB,QAAQ,OAAO,GACR,QAAQ,UAAU;EACpE,qBAAqB,OAAO;EAC5B,oBAAoB,OAAO;CAC7B;CAEA,IAAI,oBAAoB,WAAW,YACjC,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,mBACd,6BACA,KAAA,GACA,EAAE,OAAO,KAAK,CAChB;CAIF,IAAI,sBAAsB,eAAe,sBAAsB,YAC7D,MAAM,IAAID,UAAAA,iBACRC,UAAAA,cAAc,qBACd,yCACA,KAAA,GACA,EAAE,OAAO,KAAK,CAChB;CAGF,OAAO;AACT;AAEA,eAAe,eACb,QACA,QACA,YAIC;CACD,IAAI;CACJ,IAAI;CAEJ,IAAI;EACF,qBAAqB,OAAA,GAAMC,aAAAA,0BAAAA,CAAkC,QAAQ;GACnE,MAAM;GACN,aAAa,aAAa;IACxB,oBAAoB,SAAS;IAC7B,aAAa,QAAQ;GACvB;EACF,CAAC;CACH,QAAQ,CAER;CAEA,OAAO;EAAE;EAAoB;CAAkB;AACjD"}
|
|
@@ -4,15 +4,25 @@ let _lifi_sdk = require("@lifi/sdk");
|
|
|
4
4
|
let viem = require("viem");
|
|
5
5
|
let viem_chains = require("viem/chains");
|
|
6
6
|
//#region src/client/publicClient.ts
|
|
7
|
-
const publicClients =
|
|
7
|
+
const publicClients = /* @__PURE__ */ new Map();
|
|
8
8
|
/**
|
|
9
9
|
* Get an instance of a provider for a specific chain
|
|
10
10
|
* @param client - The SDK client
|
|
11
11
|
* @param chainId - Id of the chain the provider is for
|
|
12
12
|
* @returns The public client for the given chain
|
|
13
13
|
*/
|
|
14
|
-
const getPublicClient =
|
|
15
|
-
|
|
14
|
+
const getPublicClient = (client, chainId) => {
|
|
15
|
+
let publicClient = publicClients.get(chainId);
|
|
16
|
+
if (!publicClient) {
|
|
17
|
+
publicClient = buildPublicClient(client, chainId).catch((error) => {
|
|
18
|
+
publicClients.delete(chainId);
|
|
19
|
+
throw error;
|
|
20
|
+
});
|
|
21
|
+
publicClients.set(chainId, publicClient);
|
|
22
|
+
}
|
|
23
|
+
return publicClient;
|
|
24
|
+
};
|
|
25
|
+
const buildPublicClient = async (client, chainId) => {
|
|
16
26
|
const fallbackTransports = (await client.getRpcUrlsByChainId(chainId)).map((url) => url.startsWith("wss") ? (0, viem.webSocket)(url) : (0, viem.http)(url, { batch: { batchSize: 64 } }));
|
|
17
27
|
const _chain = await client.getChainById(chainId);
|
|
18
28
|
const chain = {
|
|
@@ -36,12 +46,11 @@ const getPublicClient = async (client, chainId) => {
|
|
|
36
46
|
};
|
|
37
47
|
}
|
|
38
48
|
const provider = client.getProvider(_lifi_sdk.ChainType.EVM);
|
|
39
|
-
|
|
49
|
+
return (0, viem.createClient)({
|
|
40
50
|
chain,
|
|
41
51
|
transport: (0, viem.fallback)(fallbackTransports, provider?.options?.fallbackTransportConfig),
|
|
42
52
|
batch: { multicall: true }
|
|
43
53
|
});
|
|
44
|
-
return publicClients[chainId];
|
|
45
54
|
};
|
|
46
55
|
//#endregion
|
|
47
56
|
exports.getPublicClient = getPublicClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publicClient.js","names":["webSocket","http","ChainId","mainnet","UNS_PROXY_READER_ADDRESSES","ChainType","createClient","fallback"],"sources":["../../../src/client/publicClient.ts"],"sourcesContent":["import { ChainId, ChainType, type SDKClient } from '@lifi/sdk'\nimport type { Client } from 'viem'\nimport { type Address, createClient, fallback, http, webSocket } from 'viem'\nimport { type Chain, mainnet } from 'viem/chains'\nimport { UNS_PROXY_READER_ADDRESSES } from '../actions/constants.js'\nimport type { EthereumSDKProvider } from '../types.js'\n\n//
|
|
1
|
+
{"version":3,"file":"publicClient.js","names":["webSocket","http","ChainId","mainnet","UNS_PROXY_READER_ADDRESSES","ChainType","createClient","fallback"],"sources":["../../../src/client/publicClient.ts"],"sourcesContent":["import { ChainId, ChainType, type SDKClient } from '@lifi/sdk'\nimport type { Client } from 'viem'\nimport { type Address, createClient, fallback, http, webSocket } from 'viem'\nimport { type Chain, mainnet } from 'viem/chains'\nimport { UNS_PROXY_READER_ADDRESSES } from '../actions/constants.js'\nimport type { EthereumSDKProvider } from '../types.js'\n\n// One client per chain. The cache holds the build promise, not the client,\n// so concurrent first calls share one build: each extra client would keep\n// its own fallback ranking loop running.\nconst publicClients = new Map<number, Promise<Client>>()\n\n/**\n * Get an instance of a provider for a specific chain\n * @param client - The SDK client\n * @param chainId - Id of the chain the provider is for\n * @returns The public client for the given chain\n */\nexport const getPublicClient = (\n client: SDKClient,\n chainId: number\n): Promise<Client> => {\n let publicClient = publicClients.get(chainId)\n if (!publicClient) {\n // A failed build is removed, so the next call builds again.\n publicClient = buildPublicClient(client, chainId).catch((error) => {\n publicClients.delete(chainId)\n throw error\n })\n publicClients.set(chainId, publicClient)\n }\n return publicClient\n}\n\nconst buildPublicClient = async (\n client: SDKClient,\n chainId: number\n): Promise<Client> => {\n const urls = await client.getRpcUrlsByChainId(chainId)\n const fallbackTransports = urls.map((url) =>\n url.startsWith('wss')\n ? webSocket(url)\n : http(url, {\n batch: {\n batchSize: 64,\n },\n })\n )\n const _chain = await client.getChainById(chainId)\n const chain: Chain = {\n ..._chain,\n ..._chain.metamask,\n name: _chain.metamask.chainName,\n rpcUrls: {\n default: { http: _chain.metamask.rpcUrls },\n public: { http: _chain.metamask.rpcUrls },\n },\n }\n // Add ENS contracts\n if (chain.id === ChainId.ETH) {\n chain.contracts = {\n ...mainnet.contracts,\n ...chain.contracts,\n }\n }\n\n // Add UNS contracts for supported chains\n if (chain.id === ChainId.ETH || chain.id === ChainId.POL) {\n const unsProxyAddress = UNS_PROXY_READER_ADDRESSES[chain.id]\n\n chain.contracts = {\n ...chain.contracts,\n unsProxyReader: { address: unsProxyAddress as Address },\n }\n }\n\n const provider = client.getProvider(ChainType.EVM) as\n | EthereumSDKProvider\n | undefined\n return createClient({\n chain: chain,\n transport: fallback(\n fallbackTransports,\n provider?.options?.fallbackTransportConfig\n ),\n batch: {\n multicall: true,\n },\n })\n}\n"],"mappings":";;;;;;AAUA,MAAM,gCAAgB,IAAI,IAA6B;;;;;;;AAQvD,MAAa,mBACX,QACA,YACoB;CACpB,IAAI,eAAe,cAAc,IAAI,OAAO;CAC5C,IAAI,CAAC,cAAc;EAEjB,eAAe,kBAAkB,QAAQ,OAAO,CAAC,CAAC,OAAO,UAAU;GACjE,cAAc,OAAO,OAAO;GAC5B,MAAM;EACR,CAAC;EACD,cAAc,IAAI,SAAS,YAAY;CACzC;CACA,OAAO;AACT;AAEA,MAAM,oBAAoB,OACxB,QACA,YACoB;CAEpB,MAAM,sBAAqB,MADR,OAAO,oBAAoB,OAAO,EAAA,CACrB,KAAK,QACnC,IAAI,WAAW,KAAK,KAAA,GAChBA,KAAAA,UAAAA,CAAU,GAAG,KAAA,GACbC,KAAAA,KAAAA,CAAK,KAAK,EACR,OAAO,EACL,WAAW,GACb,EACF,CAAC,CACP;CACA,MAAM,SAAS,MAAM,OAAO,aAAa,OAAO;CAChD,MAAM,QAAe;EACnB,GAAG;EACH,GAAG,OAAO;EACV,MAAM,OAAO,SAAS;EACtB,SAAS;GACP,SAAS,EAAE,MAAM,OAAO,SAAS,QAAQ;GACzC,QAAQ,EAAE,MAAM,OAAO,SAAS,QAAQ;EAC1C;CACF;CAEA,IAAI,MAAM,OAAOC,UAAAA,QAAQ,KACvB,MAAM,YAAY;EAChB,GAAGC,YAAAA,QAAQ;EACX,GAAG,MAAM;CACX;CAIF,IAAI,MAAM,OAAOD,UAAAA,QAAQ,OAAO,MAAM,OAAOA,UAAAA,QAAQ,KAAK;EACxD,MAAM,kBAAkBE,0BAAAA,2BAA2B,MAAM;EAEzD,MAAM,YAAY;GAChB,GAAG,MAAM;GACT,gBAAgB,EAAE,SAAS,gBAA2B;EACxD;CACF;CAEA,MAAM,WAAW,OAAO,YAAYC,UAAAA,UAAU,GAAG;CAGjD,QAAA,GAAOC,KAAAA,aAAAA,CAAa;EACX;EACP,YAAA,GAAWC,KAAAA,SAAAA,CACT,oBACA,UAAU,SAAS,uBACrB;EACA,OAAO,EACL,WAAW,KACb;CACF,CAAC;AACH"}
|
|
@@ -77,7 +77,7 @@ var EthereumStepExecutor = class extends _lifi_sdk.BaseStepExecutor {
|
|
|
77
77
|
if (doCheckAllowance) firstTask = require_core_tasks_EthereumCheckPermitsTask.EthereumCheckPermitsTask;
|
|
78
78
|
else {
|
|
79
79
|
const swapOrBridgeAction = this.statusManager.findAction(step, isBridgeExecution ? "CROSS_CHAIN" : "SWAP");
|
|
80
|
-
firstTask =
|
|
80
|
+
firstTask = (0, _lifi_sdk.hasOpenTransaction)(swapOrBridgeAction) ? swapOrBridgeAction?.status === "DONE" ? require_core_tasks_EthereumWaitForTransactionStatusTask.EthereumWaitForTransactionStatusTask : require_core_tasks_EthereumWaitForTransactionTask.EthereumWaitForTransactionTask : require_core_tasks_EthereumCheckBalanceTask.EthereumCheckBalanceTask;
|
|
81
81
|
}
|
|
82
82
|
const firstTaskIndex = tasks.findIndex((task) => task.constructor === firstTask);
|
|
83
83
|
if (firstTaskIndex === -1) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.InternalError, "EthereumStepExecutor.createPipeline: first task not found");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumStepExecutor.js","names":["BaseStepExecutor","createDefaultStorage","parseEthereumErrors","switchChain","getAction","getAddresses","TransactionError","LiFiErrorCode","isZeroAddress","EthereumCheckPermitsTask","EthereumCheckAllowanceTask","EthereumNativePermitTask","EthereumResetAllowanceTask","EthereumSetAllowanceTask","EthereumCheckBalanceTask","EthereumPermit2AllowanceTask","EthereumPrepareTransactionTask","EthereumSignAndExecuteTask","EthereumWaitForTransactionTask","EthereumWaitForTransactionStatusTask","shouldCheckForAllowance","TaskPipeline"],"sources":["../../../src/core/EthereumStepExecutor.ts"],"sourcesContent":["import {\n BaseStepExecutor,\n createDefaultStorage,\n type ExecuteStepRetryError,\n type ExecuteStepRetryParams,\n type ExecutionAction,\n LiFiErrorCode,\n type LiFiStepExtended,\n type SDKClient,\n type SDKError,\n type SDKStorage,\n type StepExecutorBaseContext,\n type StepExecutorOptions,\n TaskPipeline,\n TransactionError,\n} from '@lifi/sdk'\nimport type { Client, GetAddressesReturnType } from 'viem'\nimport { getAddresses } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport { parseEthereumErrors } from '../errors/parseEthereumErrors.js'\nimport type { EthereumStepExecutorContext } from '../types.js'\nimport { isZeroAddress } from '../utils/isZeroAddress.js'\nimport { EthereumCheckAllowanceTask } from './tasks/EthereumCheckAllowanceTask.js'\nimport { EthereumCheckBalanceTask } from './tasks/EthereumCheckBalanceTask.js'\nimport { EthereumCheckPermitsTask } from './tasks/EthereumCheckPermitsTask.js'\nimport { EthereumNativePermitTask } from './tasks/EthereumNativePermitTask.js'\nimport { EthereumPermit2AllowanceTask } from './tasks/EthereumPermit2AllowanceTask.js'\nimport { EthereumPrepareTransactionTask } from './tasks/EthereumPrepareTransactionTask.js'\nimport { EthereumResetAllowanceTask } from './tasks/EthereumResetAllowanceTask.js'\nimport { EthereumSetAllowanceTask } from './tasks/EthereumSetAllowanceTask.js'\nimport { EthereumSignAndExecuteTask } from './tasks/EthereumSignAndExecuteTask.js'\nimport { EthereumWaitForTransactionStatusTask } from './tasks/EthereumWaitForTransactionStatusTask.js'\nimport { EthereumWaitForTransactionTask } from './tasks/EthereumWaitForTransactionTask.js'\nimport { shouldCheckForAllowance } from './tasks/helpers/shouldCheckForAllowance.js'\nimport { switchChain } from './tasks/helpers/switchChain.js'\n\ninterface EthereumStepExecutorOptions extends StepExecutorOptions {\n client: Client\n switchChain?: (chainId: number) => Promise<Client | undefined>\n disableMessageSigning?: boolean\n}\n\nexport class EthereumStepExecutor extends BaseStepExecutor {\n private client: Client\n private switchChain?: (chainId: number) => Promise<Client | undefined>\n private storage?: SDKStorage\n private disableMessageSigning?: boolean\n\n constructor(options: EthereumStepExecutorOptions) {\n super(options)\n this.client = options.client\n this.switchChain = options.switchChain\n this.disableMessageSigning = options.disableMessageSigning\n }\n\n private getStorage = (client: SDKClient): SDKStorage => {\n if (!this.storage) {\n this.storage = client.config.storage ?? createDefaultStorage()\n }\n return this.storage\n }\n\n override parseErrors = (\n error: Error,\n step?: LiFiStepExtended,\n action?: ExecutionAction,\n retryParams?: ExecuteStepRetryParams\n ): Promise<SDKError | ExecuteStepRetryError> =>\n parseEthereumErrors(error, step, action, retryParams)\n\n // Ensure that we are using the right chain and wallet when executing transactions.\n checkClient = async (\n step: LiFiStepExtended,\n targetChainId?: number\n ): Promise<Client | undefined> => {\n const updatedClient = await switchChain(\n this.client,\n targetChainId ?? step.action.fromChainId,\n this.allowUserInteraction,\n this.switchChain\n )\n if (updatedClient) {\n this.client = updatedClient\n }\n\n // Prevent execution of the quote by wallet different from the one which requested the quote\n let accountAddress = this.client.account?.address\n if (!accountAddress) {\n const accountAddresses = (await getAction(\n this.client,\n getAddresses,\n 'getAddresses'\n )(undefined)) as GetAddressesReturnType\n accountAddress = accountAddresses?.[0]\n }\n if (\n accountAddress?.toLowerCase() !== step.action.fromAddress?.toLowerCase()\n ) {\n throw new TransactionError(\n LiFiErrorCode.WalletChangedDuringExecution,\n 'The wallet address that requested the quote does not match the wallet address attempting to sign the transaction.'\n )\n }\n return updatedClient\n }\n\n override createContext = async (\n baseContext: StepExecutorBaseContext\n ): Promise<EthereumStepExecutorContext> => {\n const { step, fromChain } = baseContext\n\n const isFromNativeToken =\n fromChain.nativeToken.address === step.action.fromToken.address &&\n isZeroAddress(step.action.fromToken.address)\n\n // Check if message signing is disabled - useful for smart contract wallets\n // We also disable message signing for custom steps\n const disableMessageSigning =\n !!this.disableMessageSigning || step.type !== 'lifi'\n\n return {\n ...baseContext,\n isFromNativeToken,\n disableMessageSigning,\n ethereumClient: this.client,\n checkClient: this.checkClient,\n getStorage: this.getStorage,\n // Signed typed data for native permits and other messages\n signedTypedData: [],\n // Calls for atomic batch transactions (EIP-5792)\n calls: [],\n }\n }\n\n override createPipeline = (\n context: EthereumStepExecutorContext\n ): TaskPipeline => {\n const { step, isBridgeExecution, isFromNativeToken } = context\n\n const tasks = [\n new EthereumCheckPermitsTask(),\n new EthereumCheckAllowanceTask(),\n new EthereumNativePermitTask(),\n new EthereumResetAllowanceTask(),\n new EthereumSetAllowanceTask(),\n new EthereumCheckBalanceTask(),\n new EthereumPermit2AllowanceTask(),\n new EthereumPrepareTransactionTask(),\n new EthereumSignAndExecuteTask(),\n new EthereumWaitForTransactionTask(),\n new EthereumWaitForTransactionStatusTask(),\n ]\n\n const doCheckAllowance = shouldCheckForAllowance(\n step,\n isBridgeExecution,\n isFromNativeToken,\n this.statusManager\n )\n\n let firstTask:\n | typeof EthereumCheckPermitsTask\n | typeof EthereumCheckBalanceTask\n | typeof EthereumWaitForTransactionTask\n | typeof EthereumWaitForTransactionStatusTask\n if (doCheckAllowance) {\n firstTask = EthereumCheckPermitsTask\n } else {\n const swapOrBridgeAction = this.statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n
|
|
1
|
+
{"version":3,"file":"EthereumStepExecutor.js","names":["BaseStepExecutor","createDefaultStorage","parseEthereumErrors","switchChain","getAction","getAddresses","TransactionError","LiFiErrorCode","isZeroAddress","EthereumCheckPermitsTask","EthereumCheckAllowanceTask","EthereumNativePermitTask","EthereumResetAllowanceTask","EthereumSetAllowanceTask","EthereumCheckBalanceTask","EthereumPermit2AllowanceTask","EthereumPrepareTransactionTask","EthereumSignAndExecuteTask","EthereumWaitForTransactionTask","EthereumWaitForTransactionStatusTask","shouldCheckForAllowance","hasOpenTransaction","TaskPipeline"],"sources":["../../../src/core/EthereumStepExecutor.ts"],"sourcesContent":["import {\n BaseStepExecutor,\n createDefaultStorage,\n type ExecuteStepRetryError,\n type ExecuteStepRetryParams,\n type ExecutionAction,\n hasOpenTransaction,\n LiFiErrorCode,\n type LiFiStepExtended,\n type SDKClient,\n type SDKError,\n type SDKStorage,\n type StepExecutorBaseContext,\n type StepExecutorOptions,\n TaskPipeline,\n TransactionError,\n} from '@lifi/sdk'\nimport type { Client, GetAddressesReturnType } from 'viem'\nimport { getAddresses } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport { parseEthereumErrors } from '../errors/parseEthereumErrors.js'\nimport type { EthereumStepExecutorContext } from '../types.js'\nimport { isZeroAddress } from '../utils/isZeroAddress.js'\nimport { EthereumCheckAllowanceTask } from './tasks/EthereumCheckAllowanceTask.js'\nimport { EthereumCheckBalanceTask } from './tasks/EthereumCheckBalanceTask.js'\nimport { EthereumCheckPermitsTask } from './tasks/EthereumCheckPermitsTask.js'\nimport { EthereumNativePermitTask } from './tasks/EthereumNativePermitTask.js'\nimport { EthereumPermit2AllowanceTask } from './tasks/EthereumPermit2AllowanceTask.js'\nimport { EthereumPrepareTransactionTask } from './tasks/EthereumPrepareTransactionTask.js'\nimport { EthereumResetAllowanceTask } from './tasks/EthereumResetAllowanceTask.js'\nimport { EthereumSetAllowanceTask } from './tasks/EthereumSetAllowanceTask.js'\nimport { EthereumSignAndExecuteTask } from './tasks/EthereumSignAndExecuteTask.js'\nimport { EthereumWaitForTransactionStatusTask } from './tasks/EthereumWaitForTransactionStatusTask.js'\nimport { EthereumWaitForTransactionTask } from './tasks/EthereumWaitForTransactionTask.js'\nimport { shouldCheckForAllowance } from './tasks/helpers/shouldCheckForAllowance.js'\nimport { switchChain } from './tasks/helpers/switchChain.js'\n\ninterface EthereumStepExecutorOptions extends StepExecutorOptions {\n client: Client\n switchChain?: (chainId: number) => Promise<Client | undefined>\n disableMessageSigning?: boolean\n}\n\nexport class EthereumStepExecutor extends BaseStepExecutor {\n private client: Client\n private switchChain?: (chainId: number) => Promise<Client | undefined>\n private storage?: SDKStorage\n private disableMessageSigning?: boolean\n\n constructor(options: EthereumStepExecutorOptions) {\n super(options)\n this.client = options.client\n this.switchChain = options.switchChain\n this.disableMessageSigning = options.disableMessageSigning\n }\n\n private getStorage = (client: SDKClient): SDKStorage => {\n if (!this.storage) {\n this.storage = client.config.storage ?? createDefaultStorage()\n }\n return this.storage\n }\n\n override parseErrors = (\n error: Error,\n step?: LiFiStepExtended,\n action?: ExecutionAction,\n retryParams?: ExecuteStepRetryParams\n ): Promise<SDKError | ExecuteStepRetryError> =>\n parseEthereumErrors(error, step, action, retryParams)\n\n // Ensure that we are using the right chain and wallet when executing transactions.\n checkClient = async (\n step: LiFiStepExtended,\n targetChainId?: number\n ): Promise<Client | undefined> => {\n const updatedClient = await switchChain(\n this.client,\n targetChainId ?? step.action.fromChainId,\n this.allowUserInteraction,\n this.switchChain\n )\n if (updatedClient) {\n this.client = updatedClient\n }\n\n // Prevent execution of the quote by wallet different from the one which requested the quote\n let accountAddress = this.client.account?.address\n if (!accountAddress) {\n const accountAddresses = (await getAction(\n this.client,\n getAddresses,\n 'getAddresses'\n )(undefined)) as GetAddressesReturnType\n accountAddress = accountAddresses?.[0]\n }\n if (\n accountAddress?.toLowerCase() !== step.action.fromAddress?.toLowerCase()\n ) {\n throw new TransactionError(\n LiFiErrorCode.WalletChangedDuringExecution,\n 'The wallet address that requested the quote does not match the wallet address attempting to sign the transaction.'\n )\n }\n return updatedClient\n }\n\n override createContext = async (\n baseContext: StepExecutorBaseContext\n ): Promise<EthereumStepExecutorContext> => {\n const { step, fromChain } = baseContext\n\n const isFromNativeToken =\n fromChain.nativeToken.address === step.action.fromToken.address &&\n isZeroAddress(step.action.fromToken.address)\n\n // Check if message signing is disabled - useful for smart contract wallets\n // We also disable message signing for custom steps\n const disableMessageSigning =\n !!this.disableMessageSigning || step.type !== 'lifi'\n\n return {\n ...baseContext,\n isFromNativeToken,\n disableMessageSigning,\n ethereumClient: this.client,\n checkClient: this.checkClient,\n getStorage: this.getStorage,\n // Signed typed data for native permits and other messages\n signedTypedData: [],\n // Calls for atomic batch transactions (EIP-5792)\n calls: [],\n }\n }\n\n override createPipeline = (\n context: EthereumStepExecutorContext\n ): TaskPipeline => {\n const { step, isBridgeExecution, isFromNativeToken } = context\n\n const tasks = [\n new EthereumCheckPermitsTask(),\n new EthereumCheckAllowanceTask(),\n new EthereumNativePermitTask(),\n new EthereumResetAllowanceTask(),\n new EthereumSetAllowanceTask(),\n new EthereumCheckBalanceTask(),\n new EthereumPermit2AllowanceTask(),\n new EthereumPrepareTransactionTask(),\n new EthereumSignAndExecuteTask(),\n new EthereumWaitForTransactionTask(),\n new EthereumWaitForTransactionStatusTask(),\n ]\n\n const doCheckAllowance = shouldCheckForAllowance(\n step,\n isBridgeExecution,\n isFromNativeToken,\n this.statusManager\n )\n\n let firstTask:\n | typeof EthereumCheckPermitsTask\n | typeof EthereumCheckBalanceTask\n | typeof EthereumWaitForTransactionTask\n | typeof EthereumWaitForTransactionStatusTask\n if (doCheckAllowance) {\n firstTask = EthereumCheckPermitsTask\n } else {\n const swapOrBridgeAction = this.statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n // Same predicate as the pre-sign guard: an open transaction is waited\n // for, a FAILED action with a final outcome signs again.\n firstTask = hasOpenTransaction(swapOrBridgeAction)\n ? swapOrBridgeAction?.status === 'DONE'\n ? EthereumWaitForTransactionStatusTask\n : EthereumWaitForTransactionTask\n : EthereumCheckBalanceTask\n }\n\n // Compare classes, not names: a minifier can give two task classes the\n // same name.\n const firstTaskIndex = tasks.findIndex(\n (task) => task.constructor === firstTask\n )\n if (firstTaskIndex === -1) {\n throw new TransactionError(\n LiFiErrorCode.InternalError,\n 'EthereumStepExecutor.createPipeline: first task not found'\n )\n }\n\n const tasksToRun = tasks.slice(firstTaskIndex)\n\n return new TaskPipeline(tasksToRun)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2CA,IAAa,uBAAb,cAA0CA,UAAAA,iBAAiB;CACzD;CACA;CACA;CACA;CAEA,YAAY,SAAsC;EAChD,MAAM,OAAO;EACb,KAAK,SAAS,QAAQ;EACtB,KAAK,cAAc,QAAQ;EAC3B,KAAK,wBAAwB,QAAQ;CACvC;CAEA,cAAsB,WAAkC;EACtD,IAAI,CAAC,KAAK,SACR,KAAK,UAAU,OAAO,OAAO,YAAA,GAAWC,UAAAA,qBAAAA,CAAqB;EAE/D,OAAO,KAAK;CACd;CAEA,eACE,OACA,MACA,QACA,gBAEAC,mCAAAA,oBAAoB,OAAO,MAAM,QAAQ,WAAW;CAGtD,cAAc,OACZ,MACA,kBACgC;EAChC,MAAM,gBAAgB,MAAMC,uCAAAA,YAC1B,KAAK,QACL,iBAAiB,KAAK,OAAO,aAC7B,KAAK,sBACL,KAAK,WACP;EACA,IAAI,eACF,KAAK,SAAS;EAIhB,IAAI,iBAAiB,KAAK,OAAO,SAAS;EAC1C,IAAI,CAAC,gBAMH,kBAAiB,OAAA,GALeC,WAAAA,UAAAA,CAC9B,KAAK,QACLC,aAAAA,cACA,cACF,CAAC,CAAC,KAAA,CAAS,EAAA,GACyB;EAEtC,IACE,gBAAgB,YAAY,MAAM,KAAK,OAAO,aAAa,YAAY,GAEvE,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,8BACd,mHACF;EAEF,OAAO;CACT;CAEA,gBAAyB,OACvB,gBACyC;EACzC,MAAM,EAAE,MAAM,cAAc;EAE5B,MAAM,oBACJ,UAAU,YAAY,YAAY,KAAK,OAAO,UAAU,WACxDC,4BAAAA,cAAc,KAAK,OAAO,UAAU,OAAO;EAI7C,MAAM,wBACJ,CAAC,CAAC,KAAK,yBAAyB,KAAK,SAAS;EAEhD,OAAO;GACL,GAAG;GACH;GACA;GACA,gBAAgB,KAAK;GACrB,aAAa,KAAK;GAClB,YAAY,KAAK;GAEjB,iBAAiB,CAAC;GAElB,OAAO,CAAC;EACV;CACF;CAEA,kBACE,YACiB;EACjB,MAAM,EAAE,MAAM,mBAAmB,sBAAsB;EAEvD,MAAM,QAAQ;GACZ,IAAIC,4CAAAA,yBAAyB;GAC7B,IAAIC,8CAAAA,2BAA2B;GAC/B,IAAIC,4CAAAA,yBAAyB;GAC7B,IAAIC,8CAAAA,2BAA2B;GAC/B,IAAIC,4CAAAA,yBAAyB;GAC7B,IAAIC,4CAAAA,yBAAyB;GAC7B,IAAIC,gDAAAA,6BAA6B;GACjC,IAAIC,kDAAAA,+BAA+B;GACnC,IAAIC,8CAAAA,2BAA2B;GAC/B,IAAIC,kDAAAA,+BAA+B;GACnC,IAAIC,wDAAAA,qCAAqC;EAC3C;EAEA,MAAM,mBAAmBC,mDAAAA,wBACvB,MACA,mBACA,mBACA,KAAK,aACP;EAEA,IAAI;EAKJ,IAAI,kBACF,YAAYX,4CAAAA;OACP;GACL,MAAM,qBAAqB,KAAK,cAAc,WAC5C,MACA,oBAAoB,gBAAgB,MACtC;GAGA,aAAA,GAAYY,UAAAA,mBAAAA,CAAmB,kBAAkB,IAC7C,oBAAoB,WAAW,SAC7BF,wDAAAA,uCACAD,kDAAAA,iCACFJ,4CAAAA;EACN;EAIA,MAAM,iBAAiB,MAAM,WAC1B,SAAS,KAAK,gBAAgB,SACjC;EACA,IAAI,mBAAmB,IACrB,MAAM,IAAIR,UAAAA,iBACRC,UAAAA,cAAc,eACd,2DACF;EAGF,MAAM,aAAa,MAAM,MAAM,cAAc;EAE7C,OAAO,IAAIe,UAAAA,aAAa,UAAU;CACpC;AACF"}
|
|
@@ -19,13 +19,16 @@ var EthereumBatchedSignAndExecuteTask = class extends _lifi_sdk.BaseStepExecutio
|
|
|
19
19
|
value: transactionRequest.value
|
|
20
20
|
};
|
|
21
21
|
calls.push(transferCall);
|
|
22
|
+
(0, _lifi_sdk.assertNoOpenTransaction)(statusManager.findAction(step, action.type));
|
|
22
23
|
const { id } = await (0, viem_utils.getAction)(updatedClient, viem_actions.sendCalls, "sendCalls")({
|
|
23
24
|
account: updatedClient.account,
|
|
24
25
|
calls
|
|
25
26
|
});
|
|
26
27
|
statusManager.updateAction(step, action.type, "PENDING", {
|
|
28
|
+
..._lifi_sdk.CLEARED_TRANSACTION_FIELDS,
|
|
27
29
|
taskId: id,
|
|
28
30
|
txType: "batched",
|
|
31
|
+
callCount: calls.length,
|
|
29
32
|
signedAt: Date.now()
|
|
30
33
|
});
|
|
31
34
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumBatchedSignAndExecuteTask.js","names":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","getAction","sendCalls"],"sources":["../../../../src/core/tasks/EthereumBatchedSignAndExecuteTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\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 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 taskId: id as Hash,\n txType: 'batched',\n signedAt: Date.now(),\n })\n\n return { status: 'COMPLETED', context: { calls } }\n }\n}\n"],"mappings":";;;;;
|
|
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"}
|