@lifi/sdk-provider-ethereum 4.1.0 → 4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/README.md +24 -8
- package/dist/cjs/core/EthereumStepExecutor.js +2 -0
- package/dist/cjs/core/EthereumStepExecutor.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumCheckBalanceTask.d.ts +2 -2
- package/dist/cjs/core/tasks/EthereumCheckBalanceTask.js +6 -5
- package/dist/cjs/core/tasks/EthereumCheckBalanceTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumCheckPermitsTask.js +11 -29
- package/dist/cjs/core/tasks/EthereumCheckPermitsTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumNativePermitTask.js +2 -0
- package/dist/cjs/core/tasks/EthereumNativePermitTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumPermit2AllowanceTask.d.ts +10 -0
- package/dist/cjs/core/tasks/EthereumPermit2AllowanceTask.js +33 -0
- package/dist/cjs/core/tasks/EthereumPermit2AllowanceTask.js.map +1 -0
- package/dist/cjs/core/tasks/EthereumPrepareTransactionTask.js +6 -4
- package/dist/cjs/core/tasks/EthereumPrepareTransactionTask.js.map +1 -1
- package/dist/cjs/core/tasks/EthereumRelayedSignAndExecuteTask.js +14 -27
- package/dist/cjs/core/tasks/EthereumRelayedSignAndExecuteTask.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/EthereumStandardSignAndExecuteTask.js +3 -4
- package/dist/cjs/core/tasks/EthereumStandardSignAndExecuteTask.js.map +1 -1
- package/dist/cjs/core/tasks/helpers/findSignedNativePermit.d.ts +7 -0
- package/dist/cjs/core/tasks/helpers/findSignedNativePermit.js +15 -0
- package/dist/cjs/core/tasks/helpers/findSignedNativePermit.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/getApprovalAmount.d.ts +6 -0
- package/dist/cjs/core/tasks/helpers/getApprovalAmount.js +16 -0
- package/dist/cjs/core/tasks/helpers/getApprovalAmount.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/getEthereumExecutionStrategy.d.ts +7 -1
- package/dist/cjs/core/tasks/helpers/getEthereumExecutionStrategy.js +12 -4
- package/dist/cjs/core/tasks/helpers/getEthereumExecutionStrategy.js.map +1 -1
- package/dist/cjs/core/tasks/helpers/getUpdatedStep.d.ts +3 -2
- package/dist/cjs/core/tasks/helpers/getUpdatedStep.js +4 -4
- package/dist/cjs/core/tasks/helpers/getUpdatedStep.js.map +1 -1
- package/dist/cjs/core/tasks/helpers/hasPermit2AllowanceInFlight.d.ts +8 -0
- package/dist/cjs/core/tasks/helpers/hasPermit2AllowanceInFlight.js +17 -0
- package/dist/cjs/core/tasks/helpers/hasPermit2AllowanceInFlight.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/isTypedDataAlreadySigned.d.ts +6 -0
- package/dist/cjs/core/tasks/helpers/isTypedDataAlreadySigned.js +29 -0
- package/dist/cjs/core/tasks/helpers/isTypedDataAlreadySigned.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/preservePermit2Allowances.d.ts +11 -0
- package/dist/cjs/core/tasks/helpers/preservePermit2Allowances.js +22 -0
- package/dist/cjs/core/tasks/helpers/preservePermit2Allowances.js.map +1 -0
- package/dist/cjs/core/tasks/helpers/resolvePermit2Support.js +2 -1
- package/dist/cjs/core/tasks/helpers/resolvePermit2Support.js.map +1 -1
- package/dist/cjs/core/tasks/helpers/signHyperliquidTypedData.d.ts +1 -1
- package/dist/cjs/core/tasks/helpers/signHyperliquidTypedData.js +3 -3
- package/dist/cjs/core/tasks/helpers/signHyperliquidTypedData.js.map +1 -1
- package/dist/cjs/core/tasks/helpers/signTypedDataEntries.d.ts +13 -0
- package/dist/cjs/core/tasks/helpers/signTypedDataEntries.js +37 -0
- package/dist/cjs/core/tasks/helpers/signTypedDataEntries.js.map +1 -0
- package/dist/cjs/index.d.ts +1 -2
- package/dist/cjs/index.js +1 -3
- package/dist/cjs/utils/getTypedDataLane.d.ts +15 -0
- package/dist/cjs/utils/getTypedDataLane.js +33 -0
- package/dist/cjs/utils/getTypedDataLane.js.map +1 -0
- package/dist/cjs/utils/isGaslessStep.d.ts +3 -1
- package/dist/cjs/utils/isGaslessStep.js +7 -1
- package/dist/cjs/utils/isGaslessStep.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/core/EthereumStepExecutor.d.ts.map +1 -1
- package/dist/esm/core/EthereumStepExecutor.js +2 -0
- package/dist/esm/core/EthereumStepExecutor.js.map +1 -1
- package/dist/esm/core/tasks/EthereumCheckBalanceTask.d.ts +2 -2
- package/dist/esm/core/tasks/EthereumCheckBalanceTask.js +6 -5
- package/dist/esm/core/tasks/EthereumCheckBalanceTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumCheckPermitsTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumCheckPermitsTask.js +11 -29
- package/dist/esm/core/tasks/EthereumCheckPermitsTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumNativePermitTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumNativePermitTask.js +2 -0
- package/dist/esm/core/tasks/EthereumNativePermitTask.js.map +1 -1
- package/dist/esm/core/tasks/EthereumPermit2AllowanceTask.d.ts +10 -0
- package/dist/esm/core/tasks/EthereumPermit2AllowanceTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/EthereumPermit2AllowanceTask.js +32 -0
- package/dist/esm/core/tasks/EthereumPermit2AllowanceTask.js.map +1 -0
- package/dist/esm/core/tasks/EthereumPrepareTransactionTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumPrepareTransactionTask.js +6 -4
- 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 +14 -27
- package/dist/esm/core/tasks/EthereumRelayedSignAndExecuteTask.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/EthereumStandardSignAndExecuteTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.js +3 -4
- package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.js.map +1 -1
- package/dist/esm/core/tasks/helpers/findSignedNativePermit.d.ts +7 -0
- package/dist/esm/core/tasks/helpers/findSignedNativePermit.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/findSignedNativePermit.js +14 -0
- package/dist/esm/core/tasks/helpers/findSignedNativePermit.js.map +1 -0
- package/dist/esm/core/tasks/helpers/getApprovalAmount.d.ts +6 -0
- package/dist/esm/core/tasks/helpers/getApprovalAmount.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/getApprovalAmount.js +15 -0
- package/dist/esm/core/tasks/helpers/getApprovalAmount.js.map +1 -0
- package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.d.ts +7 -1
- package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.js +12 -4
- package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.js.map +1 -1
- package/dist/esm/core/tasks/helpers/getUpdatedStep.d.ts +3 -2
- package/dist/esm/core/tasks/helpers/getUpdatedStep.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/getUpdatedStep.js +4 -4
- package/dist/esm/core/tasks/helpers/getUpdatedStep.js.map +1 -1
- package/dist/esm/core/tasks/helpers/hasPermit2AllowanceInFlight.d.ts +8 -0
- package/dist/esm/core/tasks/helpers/hasPermit2AllowanceInFlight.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/hasPermit2AllowanceInFlight.js +15 -0
- package/dist/esm/core/tasks/helpers/hasPermit2AllowanceInFlight.js.map +1 -0
- package/dist/esm/core/tasks/helpers/isTypedDataAlreadySigned.d.ts +6 -0
- package/dist/esm/core/tasks/helpers/isTypedDataAlreadySigned.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/isTypedDataAlreadySigned.js +28 -0
- package/dist/esm/core/tasks/helpers/isTypedDataAlreadySigned.js.map +1 -0
- package/dist/esm/core/tasks/helpers/preservePermit2Allowances.d.ts +11 -0
- package/dist/esm/core/tasks/helpers/preservePermit2Allowances.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/preservePermit2Allowances.js +21 -0
- package/dist/esm/core/tasks/helpers/preservePermit2Allowances.js.map +1 -0
- package/dist/esm/core/tasks/helpers/resolvePermit2Support.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/resolvePermit2Support.js +2 -1
- package/dist/esm/core/tasks/helpers/resolvePermit2Support.js.map +1 -1
- package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.d.ts +1 -1
- package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.d.ts.map +1 -1
- package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.js +3 -3
- package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.js.map +1 -1
- package/dist/esm/core/tasks/helpers/signTypedDataEntries.d.ts +13 -0
- package/dist/esm/core/tasks/helpers/signTypedDataEntries.d.ts.map +1 -0
- package/dist/esm/core/tasks/helpers/signTypedDataEntries.js +36 -0
- package/dist/esm/core/tasks/helpers/signTypedDataEntries.js.map +1 -0
- package/dist/esm/index.d.ts +1 -2
- package/dist/esm/index.js +2 -3
- package/dist/esm/utils/getTypedDataLane.d.ts +15 -0
- package/dist/esm/utils/getTypedDataLane.d.ts.map +1 -0
- package/dist/esm/utils/getTypedDataLane.js +28 -0
- package/dist/esm/utils/getTypedDataLane.js.map +1 -0
- package/dist/esm/utils/isGaslessStep.d.ts +3 -1
- package/dist/esm/utils/isGaslessStep.d.ts.map +1 -1
- package/dist/esm/utils/isGaslessStep.js +7 -2
- package/dist/esm/utils/isGaslessStep.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/core/EthereumStepExecutor.ts +2 -0
- package/src/core/tasks/EthereumCheckBalanceTask.ts +6 -7
- package/src/core/tasks/EthereumCheckPermitsTask.ts +31 -63
- package/src/core/tasks/EthereumNativePermitTask.ts +5 -0
- package/src/core/tasks/EthereumPermit2AllowanceTask.ts +53 -0
- package/src/core/tasks/EthereumPrepareTransactionTask.ts +11 -2
- package/src/core/tasks/EthereumRelayedSignAndExecuteTask.ts +25 -47
- package/src/core/tasks/EthereumSetAllowanceTask.ts +2 -3
- package/src/core/tasks/EthereumStandardSignAndExecuteTask.ts +2 -9
- package/src/core/tasks/helpers/findSignedNativePermit.ts +23 -0
- package/src/core/tasks/helpers/getApprovalAmount.ts +30 -0
- package/src/core/tasks/helpers/getEthereumExecutionStrategy.ts +31 -5
- package/src/core/tasks/helpers/getUpdatedStep.ts +7 -2
- package/src/core/tasks/helpers/hasPermit2AllowanceInFlight.ts +31 -0
- package/src/core/tasks/helpers/isTypedDataAlreadySigned.ts +56 -0
- package/src/core/tasks/helpers/preservePermit2Allowances.ts +44 -0
- package/src/core/tasks/helpers/resolvePermit2Support.ts +3 -1
- package/src/core/tasks/helpers/signHyperliquidTypedData.ts +3 -3
- package/src/core/tasks/helpers/signTypedDataEntries.ts +70 -0
- package/src/index.ts +0 -1
- package/src/utils/getTypedDataLane.ts +76 -0
- package/src/utils/isGaslessStep.ts +22 -9
- package/src/version.ts +1 -1
- package/dist/cjs/utils/isRelayerStep.d.ts +0 -6
- package/dist/cjs/utils/isRelayerStep.js +0 -9
- package/dist/cjs/utils/isRelayerStep.js.map +0 -1
- package/dist/esm/utils/isRelayerStep.d.ts +0 -6
- package/dist/esm/utils/isRelayerStep.d.ts.map +0 -1
- package/dist/esm/utils/isRelayerStep.js +0 -8
- package/dist/esm/utils/isRelayerStep.js.map +0 -1
- package/src/utils/isRelayerStep.ts +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @lifi/sdk-provider-ethereum
|
|
2
2
|
|
|
3
|
+
## 4.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`621d410`](https://github.com/lifinance/sdk/commit/621d410db320188677df50f5ec5bf4a1c65bf818)]:
|
|
8
|
+
- @lifi/sdk@4.8.1
|
|
9
|
+
|
|
10
|
+
## 4.2.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- [#475](https://github.com/lifinance/sdk/pull/475) [`252a06d`](https://github.com/lifinance/sdk/commit/252a06de1db75fad3d8501e05cc128b0a4c9d914) Thanks [@chybisov](https://github.com/chybisov)! - Sign a caller-supplied Permit2 `PermitSingle` inline and send the swap as one ordinary user transaction. A custom swap provider can now attach a Permit2 message for its own spender — Uniswap's Universal Router, for example — to its quote step; the SDK signs it before `/advanced/stepTransaction`, which returns router calldata with the signature embedded. No relayer, no LI.FI Permit2 proxy, and no hand-rolled approve/relay/status steps.
|
|
15
|
+
|
|
16
|
+
Execution routing no longer keys off the mere presence of `step.typedData`. One classifier assigns each entry to a lane — `native-permit` for EIP-2612, `permit2-allowance` for a Permit2 `PermitSingle` the user signs and then spends itself, and `relayer-message` for anything the LI.FI relayer submits — and each decision point reads the lane. Concretely:
|
|
17
|
+
|
|
18
|
+
- A step whose only typed data is a Permit2 allowance executes as `standard` or `batched` instead of being force-routed to the relayer. That is the sole shape carved out: every other typed-data step — native permits, Order-based tools and gasless steps included — keeps the relayer route it already had.
|
|
19
|
+
- `EthereumCheckBalanceTask` keeps the gas check for a Permit2 allowance step, because the user funds that transaction.
|
|
20
|
+
- The token approval to Permit2 is unlimited when `estimate.approvalAddress` is the same contract every Permit2 allowance on the step names in `domain.verifyingContract`, so repeat swaps need a signature only. It stays at the swap amount otherwise, including when message signing is disabled and the allowance is therefore never signed.
|
|
21
|
+
- `isRelayerStep` is removed. Use `isGaslessStep` to ask whether the relayer pays the gas. `isRelayerStep` only told you the step carried typed data, which no longer says how the step executes: a caller-supplied Permit2 allowance is signed inline and sent by the user. It had no callers left inside the SDK.
|
|
22
|
+
- A step the API marks `executionType: 'message'` routes to the relayer even before its typed data arrives. The backend declares that at routes time while `typedData` only arrives at `/advanced/stepTransaction`, and in that window the SDK used to queue an approval into a batch the relayer then discarded. It is an additional signal, never a replacement: the gasless lane reports `executionType: 'transaction'` while being signature-only, so it still relies on the typed-data inference.
|
|
23
|
+
- A step that carries typed data and receives no `transactionRequest` executes through the relayer. `batched` needs a transaction request and `standard` throws without one, so that is the only path a signature-only step can take. The strategy applies that test only after the step is prepared, because before prepare a Permit2 allowance that will receive a transaction and one that never will look identical — testing there would cost every batchable step its EIP-5792 batch.
|
|
24
|
+
- The relayer never asks for a signature it already holds. An entry already in `signedTypedData` — a Permit2 allowance signed before prepare, for example — is relayed with that signature instead of being signed a second time, so a signature-only step raises one wallet prompt and not two.
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- [#484](https://github.com/lifinance/sdk/pull/484) [`13c19c4`](https://github.com/lifinance/sdk/commit/13c19c4441341683b9dbaa8943e950b8f7571304) Thanks [@chybisov](https://github.com/chybisov)! - Refresh runtime dependencies: `@lifi/types` to `^18.10.0`, `viem` to `^2.56.8`,
|
|
29
|
+
`@mysten/sui` to `^2.31.3`, `@solana/kit` to `^8.3.0`,
|
|
30
|
+
`@solana/wallet-standard-features` to `^1.5.0`, `@stellar/stellar-sdk` to `^17.1.0`,
|
|
31
|
+
`@bigmi/core` to `^0.9.2` and `tronweb` to `^6.5.1`.
|
|
32
|
+
- Updated dependencies [[`13c19c4`](https://github.com/lifinance/sdk/commit/13c19c4441341683b9dbaa8943e950b8f7571304), [`252a06d`](https://github.com/lifinance/sdk/commit/252a06de1db75fad3d8501e05cc128b0a4c9d914), [`252a06d`](https://github.com/lifinance/sdk/commit/252a06de1db75fad3d8501e05cc128b0a4c9d914)]:
|
|
33
|
+
- @lifi/sdk@4.8.0
|
|
34
|
+
|
|
3
35
|
## 4.1.0
|
|
4
36
|
|
|
5
37
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
|
|
14
14
|
[**LI.FI SDK**](https://docs.li.fi/sdk/overview) features include:
|
|
15
15
|
|
|
16
|
-
- **Modular architecture** - Install only the provider packages you need for your supported blockchain ecosystems (EVM, Solana, Bitcoin, Sui, Tron)
|
|
16
|
+
- **Modular architecture** - Install only the provider packages you need for your supported blockchain ecosystems (EVM, Solana, Bitcoin, Sui, Tron, Stellar)
|
|
17
17
|
- All ecosystems, chains, bridges, exchanges, and solvers that [LI.FI](https://docs.li.fi/introduction/chains) supports
|
|
18
18
|
- Complete functionality covering full-cycle from obtaining routes/quotes to executing transactions
|
|
19
19
|
- Easy tracking of the route and quote execution through the robust event and hooks handling
|
|
20
20
|
- Highly customizable settings to tailor the SDK to your specific needs including configuration of RPCs and options to allow or deny certain chains, tokens, bridges, exchanges, solvers
|
|
21
21
|
- Supports widely adopted industry standards, including [EIP-5792](https://eips.ethereum.org/EIPS/eip-5792), [ERC-2612](https://eips.ethereum.org/EIPS/eip-2612), [EIP-712](https://eips.ethereum.org/EIPS/eip-712), and [Permit2](https://github.com/Uniswap/permit2)
|
|
22
|
-
- SDK ecosystem providers are based on industry-standard libraries ([Viem](https://viem.sh/) for EVM, [Solana Kit](https://github.com/
|
|
22
|
+
- SDK ecosystem providers are based on industry-standard libraries ([Viem](https://viem.sh/) for EVM, [Solana Kit](https://github.com/anza-xyz/kit) for Solana, [Bigmi](https://github.com/lifinance/bigmi) for Bitcoin, [Mysten Sui SDK](https://github.com/MystenLabs/sui/tree/main/sdk) for Sui, [TronWeb](https://tronweb.network/) for Tron, [Stellar SDK](https://github.com/stellar/js-stellar-sdk) for Stellar)
|
|
23
23
|
- Support for arbitrary contract calls on the destination chain
|
|
24
24
|
- Designed for optimal performance with tree-shaking and dead-code elimination, ensuring minimal bundle sizes and faster page load times in front-end environments
|
|
25
25
|
- Compatibility tested with Node.js and popular front-end tools like Vite
|
|
@@ -42,33 +42,47 @@ npm install --save @lifi/sdk
|
|
|
42
42
|
|
|
43
43
|
### Provider Packages
|
|
44
44
|
|
|
45
|
-
Install provider packages based on the blockchain ecosystems you want to support
|
|
45
|
+
Install provider packages based on the blockchain ecosystems you want to support.
|
|
46
|
+
|
|
47
|
+
Each provider bundles its ecosystem library, but you configure a provider by handing it a
|
|
48
|
+
wallet or client object that **you** construct — so install the ecosystem library alongside
|
|
49
|
+
the provider whenever you import from it in your own code:
|
|
46
50
|
|
|
47
51
|
**EVM Chains (Ethereum, Polygon, Arbitrum, Optimism, etc.)**
|
|
48
52
|
```bash
|
|
49
|
-
pnpm add @lifi/sdk-provider-ethereum
|
|
53
|
+
pnpm add @lifi/sdk-provider-ethereum viem
|
|
50
54
|
```
|
|
51
55
|
|
|
52
56
|
**Solana**
|
|
53
57
|
```bash
|
|
54
|
-
pnpm add @lifi/sdk-provider-solana
|
|
58
|
+
pnpm add @lifi/sdk-provider-solana @wallet-standard/base
|
|
55
59
|
```
|
|
56
60
|
|
|
57
61
|
**Bitcoin**
|
|
58
62
|
```bash
|
|
59
|
-
pnpm add @lifi/sdk-provider-bitcoin
|
|
63
|
+
pnpm add @lifi/sdk-provider-bitcoin @bigmi/core
|
|
60
64
|
```
|
|
61
65
|
|
|
62
66
|
**Sui**
|
|
63
67
|
```bash
|
|
64
|
-
pnpm add @lifi/sdk-provider-sui
|
|
68
|
+
pnpm add @lifi/sdk-provider-sui @mysten/sui
|
|
65
69
|
```
|
|
66
70
|
|
|
67
71
|
**Tron**
|
|
68
72
|
```bash
|
|
69
|
-
pnpm add @lifi/sdk-provider-tron
|
|
73
|
+
pnpm add @lifi/sdk-provider-tron @tronweb3/tronwallet-abstract-adapter
|
|
70
74
|
```
|
|
71
75
|
|
|
76
|
+
**Stellar**
|
|
77
|
+
```bash
|
|
78
|
+
pnpm add @lifi/sdk-provider-stellar
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
`StellarProvider` takes a small `StellarWallet` interface the package defines itself, so it
|
|
82
|
+
needs no ecosystem library. To discover and connect browser wallets such as Freighter,
|
|
83
|
+
xBull, or Lobstr, we recommend
|
|
84
|
+
[Stellar Wallets Kit](https://github.com/Creit-Tech/Stellar-Wallets-Kit).
|
|
85
|
+
|
|
72
86
|
## Architecture
|
|
73
87
|
|
|
74
88
|
The LI.FI SDK uses a modular provider architecture:
|
|
@@ -119,6 +133,7 @@ import { SolanaProvider } from '@lifi/sdk-provider-solana'
|
|
|
119
133
|
import { BitcoinProvider } from '@lifi/sdk-provider-bitcoin'
|
|
120
134
|
import { SuiProvider } from '@lifi/sdk-provider-sui'
|
|
121
135
|
import { TronProvider } from '@lifi/sdk-provider-tron'
|
|
136
|
+
import { StellarProvider } from '@lifi/sdk-provider-stellar'
|
|
122
137
|
|
|
123
138
|
const client = createClient({
|
|
124
139
|
integrator: 'Your dApp/company name',
|
|
@@ -128,6 +143,7 @@ const client = createClient({
|
|
|
128
143
|
BitcoinProvider({ /* options */ }),
|
|
129
144
|
SuiProvider({ /* options */ }),
|
|
130
145
|
TronProvider({ /* options */ }),
|
|
146
|
+
StellarProvider({ /* options */ }),
|
|
131
147
|
],
|
|
132
148
|
})
|
|
133
149
|
```
|
|
@@ -5,6 +5,7 @@ const require_core_tasks_EthereumCheckAllowanceTask = require("./tasks/EthereumC
|
|
|
5
5
|
const require_core_tasks_EthereumCheckBalanceTask = require("./tasks/EthereumCheckBalanceTask.js");
|
|
6
6
|
const require_core_tasks_EthereumCheckPermitsTask = require("./tasks/EthereumCheckPermitsTask.js");
|
|
7
7
|
const require_core_tasks_EthereumNativePermitTask = require("./tasks/EthereumNativePermitTask.js");
|
|
8
|
+
const require_core_tasks_EthereumPermit2AllowanceTask = require("./tasks/EthereumPermit2AllowanceTask.js");
|
|
8
9
|
const require_core_tasks_EthereumPrepareTransactionTask = require("./tasks/EthereumPrepareTransactionTask.js");
|
|
9
10
|
const require_core_tasks_EthereumResetAllowanceTask = require("./tasks/EthereumResetAllowanceTask.js");
|
|
10
11
|
const require_core_tasks_EthereumSetAllowanceTask = require("./tasks/EthereumSetAllowanceTask.js");
|
|
@@ -65,6 +66,7 @@ var EthereumStepExecutor = class extends _lifi_sdk.BaseStepExecutor {
|
|
|
65
66
|
new require_core_tasks_EthereumResetAllowanceTask.EthereumResetAllowanceTask(),
|
|
66
67
|
new require_core_tasks_EthereumSetAllowanceTask.EthereumSetAllowanceTask(),
|
|
67
68
|
new require_core_tasks_EthereumCheckBalanceTask.EthereumCheckBalanceTask(),
|
|
69
|
+
new require_core_tasks_EthereumPermit2AllowanceTask.EthereumPermit2AllowanceTask(),
|
|
68
70
|
new require_core_tasks_EthereumPrepareTransactionTask.EthereumPrepareTransactionTask(),
|
|
69
71
|
new require_core_tasks_EthereumSignAndExecuteTask.EthereumSignAndExecuteTask(),
|
|
70
72
|
new require_core_tasks_EthereumWaitForTransactionTask.EthereumWaitForTransactionTask(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumStepExecutor.js","names":["BaseStepExecutor","createDefaultStorage","parseEthereumErrors","switchChain","getAction","getAddresses","TransactionError","LiFiErrorCode","isZeroAddress","EthereumCheckPermitsTask","EthereumCheckAllowanceTask","EthereumNativePermitTask","EthereumResetAllowanceTask","EthereumSetAllowanceTask","EthereumCheckBalanceTask","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 { 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 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 taskName: string\n if (doCheckAllowance) {\n taskName = EthereumCheckPermitsTask.name\n } else {\n const swapOrBridgeAction = this.statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n taskName =\n swapOrBridgeAction?.txHash || swapOrBridgeAction?.taskId\n ? swapOrBridgeAction?.status === 'DONE'\n ? EthereumWaitForTransactionStatusTask.name\n : EthereumWaitForTransactionTask.name\n : EthereumCheckBalanceTask.name\n }\n\n const firstTaskIndex = tasks.findIndex(\n (task) => task.constructor.name === taskName\n )\n\n const tasksToRun = tasks.slice(firstTaskIndex)\n\n return new TaskPipeline(tasksToRun)\n }\n}\n"],"mappings":"
|
|
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 taskName: string\n if (doCheckAllowance) {\n taskName = EthereumCheckPermitsTask.name\n } else {\n const swapOrBridgeAction = this.statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n taskName =\n swapOrBridgeAction?.txHash || swapOrBridgeAction?.taskId\n ? swapOrBridgeAction?.status === 'DONE'\n ? EthereumWaitForTransactionStatusTask.name\n : EthereumWaitForTransactionTask.name\n : EthereumCheckBalanceTask.name\n }\n\n const firstTaskIndex = tasks.findIndex(\n (task) => task.constructor.name === taskName\n )\n\n const tasksToRun = tasks.slice(firstTaskIndex)\n\n return new TaskPipeline(tasksToRun)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA0CA,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;EACJ,IAAI,kBACF,WAAWX,4CAAAA,yBAAyB;OAC/B;GACL,MAAM,qBAAqB,KAAK,cAAc,WAC5C,MACA,oBAAoB,gBAAgB,MACtC;GACA,WACE,oBAAoB,UAAU,oBAAoB,SAC9C,oBAAoB,WAAW,SAC7BU,wDAAAA,qCAAqC,OACrCD,kDAAAA,+BAA+B,OACjCJ,4CAAAA,yBAAyB;EACjC;EAEA,MAAM,iBAAiB,MAAM,WAC1B,SAAS,KAAK,YAAY,SAAS,QACtC;EAEA,MAAM,aAAa,MAAM,MAAM,cAAc;EAE7C,OAAO,IAAIO,UAAAA,aAAa,UAAU;CACpC;AACF"}
|
|
@@ -4,8 +4,8 @@ import { CheckBalanceOptions, CheckBalanceTask } from "@lifi/sdk";
|
|
|
4
4
|
/**
|
|
5
5
|
* Skips the outer-tx gas check for steps where the wallet doesn't fund it:
|
|
6
6
|
* smart-contract wallets (Safe Apps, 4337, 7579, …) where the
|
|
7
|
-
* executor / bundler / paymaster pays, and
|
|
8
|
-
* and non-included native fees are still verified.
|
|
7
|
+
* executor / bundler / paymaster pays, and typed-data steps the user does not
|
|
8
|
+
* fund. Source amount and non-included native fees are still verified.
|
|
9
9
|
*
|
|
10
10
|
* Skip-bias is intentional: a wrong skip is caught by the wallet rejecting
|
|
11
11
|
* the tx; a wrong enforce blocks a tx that would have succeeded.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
2
|
+
const require_utils_getTypedDataLane = require("../../utils/getTypedDataLane.js");
|
|
3
3
|
const require_actions_getAccountCode = require("../../actions/getAccountCode.js");
|
|
4
4
|
const require_actions_isSmartContractWallet = require("../../actions/isSmartContractWallet.js");
|
|
5
5
|
let _lifi_sdk = require("@lifi/sdk");
|
|
@@ -7,16 +7,17 @@ let _lifi_sdk = require("@lifi/sdk");
|
|
|
7
7
|
/**
|
|
8
8
|
* Skips the outer-tx gas check for steps where the wallet doesn't fund it:
|
|
9
9
|
* smart-contract wallets (Safe Apps, 4337, 7579, …) where the
|
|
10
|
-
* executor / bundler / paymaster pays, and
|
|
11
|
-
* and non-included native fees are still verified.
|
|
10
|
+
* executor / bundler / paymaster pays, and typed-data steps the user does not
|
|
11
|
+
* fund. Source amount and non-included native fees are still verified.
|
|
12
12
|
*
|
|
13
13
|
* Skip-bias is intentional: a wrong skip is caught by the wallet rejecting
|
|
14
14
|
* the tx; a wrong enforce blocks a tx that would have succeeded.
|
|
15
15
|
*/
|
|
16
16
|
var EthereumCheckBalanceTask = class extends _lifi_sdk.CheckBalanceTask {
|
|
17
17
|
async getCheckBalanceOptions(context) {
|
|
18
|
-
const { client, step } = context;
|
|
19
|
-
|
|
18
|
+
const { client, step, fromChain } = context;
|
|
19
|
+
const userFundsTransaction = require_utils_getTypedDataLane.isPermit2AllowanceLane(step, fromChain);
|
|
20
|
+
if (step.typedData?.length && !userFundsTransaction) return { walletPaysGas: false };
|
|
20
21
|
const fromAddress = step.action.fromAddress;
|
|
21
22
|
if (!fromAddress) return {};
|
|
22
23
|
const code = await require_actions_getAccountCode.getAccountCode({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumCheckBalanceTask.js","names":["CheckBalanceTask","
|
|
1
|
+
{"version":3,"file":"EthereumCheckBalanceTask.js","names":["CheckBalanceTask","isPermit2AllowanceLane","getAccountCode","isSmartContractWalletCode"],"sources":["../../../../src/core/tasks/EthereumCheckBalanceTask.ts"],"sourcesContent":["import { type CheckBalanceOptions, CheckBalanceTask } from '@lifi/sdk'\nimport type { Address } from 'viem'\nimport { getAccountCode } from '../../actions/getAccountCode.js'\nimport { isSmartContractWalletCode } from '../../actions/isSmartContractWallet.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { isPermit2AllowanceLane } from '../../utils/getTypedDataLane.js'\n\n/**\n * Skips the outer-tx gas check for steps where the wallet doesn't fund it:\n * smart-contract wallets (Safe Apps, 4337, 7579, …) where the\n * executor / bundler / paymaster pays, and typed-data steps the user does not\n * fund. Source amount and non-included native fees are still verified.\n *\n * Skip-bias is intentional: a wrong skip is caught by the wallet rejecting\n * the tx; a wrong enforce blocks a tx that would have succeeded.\n */\nexport class EthereumCheckBalanceTask extends CheckBalanceTask {\n protected override async getCheckBalanceOptions(\n context: EthereumStepExecutorContext\n ): Promise<CheckBalanceOptions> {\n const { client, step, fromChain } = context\n\n const userFundsTransaction = isPermit2AllowanceLane(step, fromChain)\n if (step.typedData?.length && !userFundsTransaction) {\n return { walletPaysGas: false }\n }\n\n // Funding wallet (NOT signer) — for Safe Apps these usually match, but\n // the balance question is about the funder. Compare with\n // `canAccountUseNativePermits`, which uses the signer.\n const fromAddress = step.action.fromAddress as Address | undefined\n if (!fromAddress) {\n return {}\n }\n\n // `step.action.fromChainId` (NOT wallet's connected chain) so cross-\n // chain / post-chain-switch flows query the chain that executes the step.\n const code = await getAccountCode({\n client,\n chainId: step.action.fromChainId,\n address: fromAddress,\n })\n\n // `code === undefined` on RPC failure → falls through to \"treat as EOA\"\n // since `isSmartContractWalletCode(undefined)` is `false` (conservative:\n // strict gas check stays on, today's behavior).\n return { walletPaysGas: !isSmartContractWalletCode(code) }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,IAAa,2BAAb,cAA8CA,UAAAA,iBAAiB;CAC7D,MAAyB,uBACvB,SAC8B;EAC9B,MAAM,EAAE,QAAQ,MAAM,cAAc;EAEpC,MAAM,uBAAuBC,+BAAAA,uBAAuB,MAAM,SAAS;EACnE,IAAI,KAAK,WAAW,UAAU,CAAC,sBAC7B,OAAO,EAAE,eAAe,MAAM;EAMhC,MAAM,cAAc,KAAK,OAAO;EAChC,IAAI,CAAC,aACH,OAAO,CAAC;EAKV,MAAM,OAAO,MAAMC,+BAAAA,eAAe;GAChC;GACA,SAAS,KAAK,OAAO;GACrB,SAAS;EACX,CAAC;EAKD,OAAO,EAAE,eAAe,CAACC,sCAAAA,0BAA0B,IAAI,EAAE;CAC3D;AACF"}
|
|
@@ -1,51 +1,33 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_utils_getTypedDataLane = require("../../utils/getTypedDataLane.js");
|
|
2
3
|
const require_utils_getDomainChainId = require("../../utils/getDomainChainId.js");
|
|
3
|
-
const
|
|
4
|
+
const require_core_tasks_helpers_signTypedDataEntries = require("./helpers/signTypedDataEntries.js");
|
|
4
5
|
let _lifi_sdk = require("@lifi/sdk");
|
|
5
|
-
let viem_actions = require("viem/actions");
|
|
6
|
-
let viem_utils = require("viem/utils");
|
|
7
6
|
//#region src/core/tasks/EthereumCheckPermitsTask.ts
|
|
8
7
|
var EthereumCheckPermitsTask = class extends _lifi_sdk.BaseStepExecutionTask {
|
|
9
8
|
async shouldRun(context) {
|
|
10
|
-
const { step, disableMessageSigning } = context;
|
|
11
|
-
return !!
|
|
9
|
+
const { step, fromChain, disableMessageSigning } = context;
|
|
10
|
+
return !!step.typedData?.some((typedData) => require_utils_getTypedDataLane.getTypedDataLane(typedData, fromChain) === "native-permit") && !disableMessageSigning;
|
|
12
11
|
}
|
|
13
12
|
async run(context) {
|
|
14
|
-
const { step,
|
|
13
|
+
const { step, fromChain, statusManager } = context;
|
|
15
14
|
const action = statusManager.initializeAction({
|
|
16
15
|
step,
|
|
17
16
|
type: "PERMIT",
|
|
18
17
|
chainId: step.action.fromChainId,
|
|
19
18
|
status: "STARTED"
|
|
20
19
|
});
|
|
21
|
-
const permitTypedData =
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const permitClient = await checkClient(step, require_utils_getDomainChainId.getDomainChainId(typedData.domain) || step.action.fromChainId);
|
|
27
|
-
if (!permitClient) return { status: "PAUSED" };
|
|
28
|
-
const signature = await (0, viem_utils.getAction)(permitClient, viem_actions.signTypedData, "signTypedData")({
|
|
29
|
-
account: permitClient.account,
|
|
30
|
-
domain: typedData.domain,
|
|
31
|
-
types: typedData.types,
|
|
32
|
-
primaryType: typedData.primaryType,
|
|
33
|
-
message: typedData.message
|
|
34
|
-
});
|
|
35
|
-
require_utils_isValidSignature.assertValidSignature(signature);
|
|
36
|
-
const signedPermit = {
|
|
37
|
-
...typedData,
|
|
38
|
-
signature
|
|
39
|
-
};
|
|
40
|
-
signedTypedData.push(signedPermit);
|
|
41
|
-
}
|
|
42
|
-
const matchingPermit = signedTypedData.find((signedTypedData) => require_utils_getDomainChainId.getDomainChainId(signedTypedData.domain) === step.action.fromChainId);
|
|
20
|
+
const permitTypedData = require_utils_getTypedDataLane.getTypedDataInLane(step, "native-permit", fromChain);
|
|
21
|
+
const result = await require_core_tasks_helpers_signTypedDataEntries.signTypedDataEntries(context, permitTypedData, action.type);
|
|
22
|
+
if (result.status === "PAUSED") return { status: "PAUSED" };
|
|
23
|
+
const { signedTypedData } = result;
|
|
24
|
+
const matchingPermit = signedTypedData.find((entry) => entry.primaryType === "Permit" && require_utils_getDomainChainId.getDomainChainId(entry.domain) === step.action.fromChainId);
|
|
43
25
|
statusManager.updateAction(step, action.type, "DONE");
|
|
44
26
|
return {
|
|
45
27
|
status: "COMPLETED",
|
|
46
28
|
context: {
|
|
47
29
|
signedTypedData,
|
|
48
|
-
hasMatchingPermit: !!matchingPermit
|
|
30
|
+
hasMatchingPermit: !!matchingPermit && !require_utils_getTypedDataLane.isPermit2AllowanceLane(step, fromChain)
|
|
49
31
|
}
|
|
50
32
|
};
|
|
51
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumCheckPermitsTask.js","names":["BaseStepExecutionTask","
|
|
1
|
+
{"version":3,"file":"EthereumCheckPermitsTask.js","names":["BaseStepExecutionTask","getTypedDataLane","getTypedDataInLane","signTypedDataEntries","getDomainChainId","isPermit2AllowanceLane"],"sources":["../../../../src/core/tasks/EthereumCheckPermitsTask.ts"],"sourcesContent":["import { BaseStepExecutionTask, type TaskResult } from '@lifi/sdk'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { getDomainChainId } from '../../utils/getDomainChainId.js'\nimport {\n getTypedDataInLane,\n getTypedDataLane,\n isPermit2AllowanceLane,\n} from '../../utils/getTypedDataLane.js'\nimport { signTypedDataEntries } from './helpers/signTypedDataEntries.js'\n\nexport class EthereumCheckPermitsTask extends BaseStepExecutionTask {\n override async shouldRun(\n context: EthereumStepExecutorContext\n ): Promise<boolean> {\n const { step, fromChain, disableMessageSigning } = context\n\n return (\n !!step.typedData?.some(\n (typedData) =>\n getTypedDataLane(typedData, fromChain) === 'native-permit'\n ) && !disableMessageSigning\n )\n }\n\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const { step, fromChain, statusManager } = context\n\n const action = statusManager.initializeAction({\n step,\n type: 'PERMIT',\n chainId: step.action.fromChainId,\n status: 'STARTED',\n })\n\n const permitTypedData = getTypedDataInLane(step, 'native-permit', fromChain)\n\n const result = await signTypedDataEntries(\n context,\n permitTypedData,\n action.type\n )\n if (result.status === 'PAUSED') {\n return { status: 'PAUSED' }\n }\n const { signedTypedData } = result\n\n const matchingPermit = signedTypedData.find(\n (entry) =>\n entry.primaryType === 'Permit' &&\n getDomainChainId(entry.domain) === step.action.fromChainId\n )\n\n statusManager.updateAction(step, action.type, 'DONE')\n\n return {\n status: 'COMPLETED',\n context: {\n signedTypedData,\n hasMatchingPermit:\n !!matchingPermit && !isPermit2AllowanceLane(step, fromChain),\n },\n }\n }\n}\n"],"mappings":";;;;;;AAUA,IAAa,2BAAb,cAA8CA,UAAAA,sBAAsB;CAClE,MAAe,UACb,SACkB;EAClB,MAAM,EAAE,MAAM,WAAW,0BAA0B;EAEnD,OACE,CAAC,CAAC,KAAK,WAAW,MACf,cACCC,+BAAAA,iBAAiB,WAAW,SAAS,MAAM,eAC/C,KAAK,CAAC;CAEV;CAEA,MAAM,IAAI,SAA2D;EACnE,MAAM,EAAE,MAAM,WAAW,kBAAkB;EAE3C,MAAM,SAAS,cAAc,iBAAiB;GAC5C;GACA,MAAM;GACN,SAAS,KAAK,OAAO;GACrB,QAAQ;EACV,CAAC;EAED,MAAM,kBAAkBC,+BAAAA,mBAAmB,MAAM,iBAAiB,SAAS;EAE3E,MAAM,SAAS,MAAMC,gDAAAA,qBACnB,SACA,iBACA,OAAO,IACT;EACA,IAAI,OAAO,WAAW,UACpB,OAAO,EAAE,QAAQ,SAAS;EAE5B,MAAM,EAAE,oBAAoB;EAE5B,MAAM,iBAAiB,gBAAgB,MACpC,UACC,MAAM,gBAAgB,YACtBC,+BAAAA,iBAAiB,MAAM,MAAM,MAAM,KAAK,OAAO,WACnD;EAEA,cAAc,aAAa,MAAM,OAAO,MAAM,MAAM;EAEpD,OAAO;GACL,QAAQ;GACR,SAAS;IACP;IACA,mBACE,CAAC,CAAC,kBAAkB,CAACC,+BAAAA,uBAAuB,MAAM,SAAS;GAC/D;EACF;CACF;AACF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_utils_getActionWithFallback = require("../../utils/getActionWithFallback.js");
|
|
3
|
+
const require_utils_getTypedDataLane = require("../../utils/getTypedDataLane.js");
|
|
3
4
|
const require_core_tasks_helpers_getEthereumExecutionStrategy = require("./helpers/getEthereumExecutionStrategy.js");
|
|
4
5
|
const require_utils_isValidSignature = require("../../utils/isValidSignature.js");
|
|
5
6
|
const require_permits_getNativePermit = require("../../permits/getNativePermit.js");
|
|
@@ -12,6 +13,7 @@ var EthereumNativePermitTask = class extends _lifi_sdk.BaseStepExecutionTask {
|
|
|
12
13
|
async shouldRun(context) {
|
|
13
14
|
const { step, fromChain, hasMatchingPermit, hasSufficientAllowance, disableMessageSigning } = context;
|
|
14
15
|
if (hasMatchingPermit || hasSufficientAllowance) return false;
|
|
16
|
+
if (require_utils_getTypedDataLane.isPermit2AllowanceLane(step, fromChain)) return false;
|
|
15
17
|
const batchingSupported = await require_core_tasks_helpers_getEthereumExecutionStrategy.getEthereumExecutionStrategy(context) === "batched";
|
|
16
18
|
return !!fromChain.permit2Proxy && !batchingSupported && !disableMessageSigning && !step.estimate.skipPermit;
|
|
17
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumNativePermitTask.js","names":["BaseStepExecutionTask","getEthereumExecutionStrategy","getActionWithFallback","getNativePermit","isNativePermitValid","getAction","signTypedData","isValidSignature"],"sources":["../../../../src/core/tasks/EthereumNativePermitTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n type SignedTypedData,\n type TaskResult,\n} from '@lifi/sdk'\nimport type { Address } from 'viem'\nimport { signTypedData } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport { getNativePermit } from '../../permits/getNativePermit.js'\nimport { isNativePermitValid } from '../../permits/isNativePermitValid.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { getActionWithFallback } from '../../utils/getActionWithFallback.js'\nimport { isValidSignature } from '../../utils/isValidSignature.js'\nimport { getEthereumExecutionStrategy } from './helpers/getEthereumExecutionStrategy.js'\n\nexport class EthereumNativePermitTask extends BaseStepExecutionTask {\n override async shouldRun(\n context: EthereumStepExecutorContext\n ): Promise<boolean> {\n const {\n step,\n fromChain,\n hasMatchingPermit,\n hasSufficientAllowance,\n disableMessageSigning,\n } = context\n\n if (hasMatchingPermit || hasSufficientAllowance) {\n return false\n }\n\n const executionStrategy = await getEthereumExecutionStrategy(context)\n const batchingSupported = executionStrategy === 'batched'\n // Check if proxy contract is available and message signing is not disabled, also not available for atomic batch\n const isNativePermitAvailable =\n !!fromChain.permit2Proxy &&\n !batchingSupported &&\n !disableMessageSigning &&\n !step.estimate.skipPermit\n return isNativePermitAvailable\n }\n\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n client,\n fromChain,\n statusManager,\n allowUserInteraction,\n checkClient,\n signedTypedData: currentSignedTypedData,\n } = context\n\n const action = statusManager.initializeAction({\n step,\n type: 'NATIVE_PERMIT',\n chainId: step.action.fromChainId,\n status: 'STARTED',\n })\n\n const updatedClient = await checkClient(step)\n if (!updatedClient) {\n return { status: 'PAUSED' }\n }\n\n const fromAmount = BigInt(step.action.fromAmount)\n\n const nativePermitData = await getActionWithFallback(\n client,\n updatedClient,\n getNativePermit,\n 'getNativePermit',\n {\n client,\n viemClient: updatedClient,\n chainId: fromChain.id,\n tokenAddress: step.action.fromToken.address as Address,\n spenderAddress: fromChain.permit2Proxy as Address,\n amount: fromAmount,\n ownerAddress: updatedClient.account!.address,\n }\n )\n\n if (!nativePermitData) {\n statusManager.updateAction(step, action.type, 'DONE')\n return { status: 'COMPLETED' }\n }\n\n const signedTypedData = [...currentSignedTypedData]\n\n // Check if we already have a valid permit for this chain and requirements\n const signedTypedDataForChain = signedTypedData.find((signedTypedData) =>\n isNativePermitValid(signedTypedData, nativePermitData)\n )\n\n if (!signedTypedDataForChain) {\n statusManager.updateAction(step, action.type, 'ACTION_REQUIRED')\n\n if (!allowUserInteraction) {\n return { status: 'PAUSED' }\n }\n\n // Sign the permit\n const signature = await getAction(\n updatedClient,\n signTypedData,\n 'signTypedData'\n )({\n account: updatedClient.account!,\n domain: nativePermitData.domain,\n types: nativePermitData.types,\n primaryType: nativePermitData.primaryType,\n message: nativePermitData.message,\n })\n\n // Some wallets resolve signTypedData with a nullish or empty value\n // instead of rejecting — skip the permit and fall back to the\n // Permit2/standard approval flow\n if (!isValidSignature(signature)) {\n statusManager.updateAction(step, action.type, 'DONE')\n return { status: 'COMPLETED' }\n }\n\n // Add the new permit to the signed permits array\n const signedPermit: SignedTypedData = {\n ...nativePermitData,\n signature,\n }\n signedTypedData.push(signedPermit)\n }\n\n statusManager.updateAction(step, action.type, 'DONE')\n\n return {\n status: 'COMPLETED',\n context: { signedTypedData, hasMatchingPermit: true },\n }\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EthereumNativePermitTask.js","names":["BaseStepExecutionTask","isPermit2AllowanceLane","getEthereumExecutionStrategy","getActionWithFallback","getNativePermit","isNativePermitValid","getAction","signTypedData","isValidSignature"],"sources":["../../../../src/core/tasks/EthereumNativePermitTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n type SignedTypedData,\n type TaskResult,\n} from '@lifi/sdk'\nimport type { Address } from 'viem'\nimport { signTypedData } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport { getNativePermit } from '../../permits/getNativePermit.js'\nimport { isNativePermitValid } from '../../permits/isNativePermitValid.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { getActionWithFallback } from '../../utils/getActionWithFallback.js'\nimport { isPermit2AllowanceLane } from '../../utils/getTypedDataLane.js'\nimport { isValidSignature } from '../../utils/isValidSignature.js'\nimport { getEthereumExecutionStrategy } from './helpers/getEthereumExecutionStrategy.js'\n\nexport class EthereumNativePermitTask extends BaseStepExecutionTask {\n override async shouldRun(\n context: EthereumStepExecutorContext\n ): Promise<boolean> {\n const {\n step,\n fromChain,\n hasMatchingPermit,\n hasSufficientAllowance,\n disableMessageSigning,\n } = context\n\n if (hasMatchingPermit || hasSufficientAllowance) {\n return false\n }\n\n if (isPermit2AllowanceLane(step, fromChain)) {\n return false\n }\n\n const executionStrategy = await getEthereumExecutionStrategy(context)\n const batchingSupported = executionStrategy === 'batched'\n // Check if proxy contract is available and message signing is not disabled, also not available for atomic batch\n const isNativePermitAvailable =\n !!fromChain.permit2Proxy &&\n !batchingSupported &&\n !disableMessageSigning &&\n !step.estimate.skipPermit\n return isNativePermitAvailable\n }\n\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n client,\n fromChain,\n statusManager,\n allowUserInteraction,\n checkClient,\n signedTypedData: currentSignedTypedData,\n } = context\n\n const action = statusManager.initializeAction({\n step,\n type: 'NATIVE_PERMIT',\n chainId: step.action.fromChainId,\n status: 'STARTED',\n })\n\n const updatedClient = await checkClient(step)\n if (!updatedClient) {\n return { status: 'PAUSED' }\n }\n\n const fromAmount = BigInt(step.action.fromAmount)\n\n const nativePermitData = await getActionWithFallback(\n client,\n updatedClient,\n getNativePermit,\n 'getNativePermit',\n {\n client,\n viemClient: updatedClient,\n chainId: fromChain.id,\n tokenAddress: step.action.fromToken.address as Address,\n spenderAddress: fromChain.permit2Proxy as Address,\n amount: fromAmount,\n ownerAddress: updatedClient.account!.address,\n }\n )\n\n if (!nativePermitData) {\n statusManager.updateAction(step, action.type, 'DONE')\n return { status: 'COMPLETED' }\n }\n\n const signedTypedData = [...currentSignedTypedData]\n\n // Check if we already have a valid permit for this chain and requirements\n const signedTypedDataForChain = signedTypedData.find((signedTypedData) =>\n isNativePermitValid(signedTypedData, nativePermitData)\n )\n\n if (!signedTypedDataForChain) {\n statusManager.updateAction(step, action.type, 'ACTION_REQUIRED')\n\n if (!allowUserInteraction) {\n return { status: 'PAUSED' }\n }\n\n // Sign the permit\n const signature = await getAction(\n updatedClient,\n signTypedData,\n 'signTypedData'\n )({\n account: updatedClient.account!,\n domain: nativePermitData.domain,\n types: nativePermitData.types,\n primaryType: nativePermitData.primaryType,\n message: nativePermitData.message,\n })\n\n // Some wallets resolve signTypedData with a nullish or empty value\n // instead of rejecting — skip the permit and fall back to the\n // Permit2/standard approval flow\n if (!isValidSignature(signature)) {\n statusManager.updateAction(step, action.type, 'DONE')\n return { status: 'COMPLETED' }\n }\n\n // Add the new permit to the signed permits array\n const signedPermit: SignedTypedData = {\n ...nativePermitData,\n signature,\n }\n signedTypedData.push(signedPermit)\n }\n\n statusManager.updateAction(step, action.type, 'DONE')\n\n return {\n status: 'COMPLETED',\n context: { signedTypedData, hasMatchingPermit: true },\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AAgBA,IAAa,2BAAb,cAA8CA,UAAAA,sBAAsB;CAClE,MAAe,UACb,SACkB;EAClB,MAAM,EACJ,MACA,WACA,mBACA,wBACA,0BACE;EAEJ,IAAI,qBAAqB,wBACvB,OAAO;EAGT,IAAIC,+BAAAA,uBAAuB,MAAM,SAAS,GACxC,OAAO;EAIT,MAAM,oBAAoB,MADMC,wDAAAA,6BAA6B,OAAO,MACpB;EAOhD,OAJE,CAAC,CAAC,UAAU,gBACZ,CAAC,qBACD,CAAC,yBACD,CAAC,KAAK,SAAS;CAEnB;CAEA,MAAM,IAAI,SAA2D;EACnE,MAAM,EACJ,MACA,QACA,WACA,eACA,sBACA,aACA,iBAAiB,2BACf;EAEJ,MAAM,SAAS,cAAc,iBAAiB;GAC5C;GACA,MAAM;GACN,SAAS,KAAK,OAAO;GACrB,QAAQ;EACV,CAAC;EAED,MAAM,gBAAgB,MAAM,YAAY,IAAI;EAC5C,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;EAG5B,MAAM,aAAa,OAAO,KAAK,OAAO,UAAU;EAEhD,MAAM,mBAAmB,MAAMC,oCAAAA,sBAC7B,QACA,eACAC,gCAAAA,iBACA,mBACA;GACE;GACA,YAAY;GACZ,SAAS,UAAU;GACnB,cAAc,KAAK,OAAO,UAAU;GACpC,gBAAgB,UAAU;GAC1B,QAAQ;GACR,cAAc,cAAc,QAAS;EACvC,CACF;EAEA,IAAI,CAAC,kBAAkB;GACrB,cAAc,aAAa,MAAM,OAAO,MAAM,MAAM;GACpD,OAAO,EAAE,QAAQ,YAAY;EAC/B;EAEA,MAAM,kBAAkB,CAAC,GAAG,sBAAsB;EAOlD,IAAI,CAJ4B,gBAAgB,MAAM,oBACpDC,oCAAAA,oBAAoB,iBAAiB,gBAAgB,CAG5B,GAAG;GAC5B,cAAc,aAAa,MAAM,OAAO,MAAM,iBAAiB;GAE/D,IAAI,CAAC,sBACH,OAAO,EAAE,QAAQ,SAAS;GAI5B,MAAM,YAAY,OAAA,GAAMC,WAAAA,UAAAA,CACtB,eACAC,aAAAA,eACA,eACF,CAAC,CAAC;IACA,SAAS,cAAc;IACvB,QAAQ,iBAAiB;IACzB,OAAO,iBAAiB;IACxB,aAAa,iBAAiB;IAC9B,SAAS,iBAAiB;GAC5B,CAAC;GAKD,IAAI,CAACC,+BAAAA,iBAAiB,SAAS,GAAG;IAChC,cAAc,aAAa,MAAM,OAAO,MAAM,MAAM;IACpD,OAAO,EAAE,QAAQ,YAAY;GAC/B;GAGA,MAAM,eAAgC;IACpC,GAAG;IACH;GACF;GACA,gBAAgB,KAAK,YAAY;EACnC;EAEA,cAAc,aAAa,MAAM,OAAO,MAAM,MAAM;EAEpD,OAAO;GACL,QAAQ;GACR,SAAS;IAAE;IAAiB,mBAAmB;GAAK;EACtD;CACF;AACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EthereumStepExecutorContext } from "../../types.js";
|
|
2
|
+
import { BaseStepExecutionTask, TaskResult } from "@lifi/sdk";
|
|
3
|
+
//#region src/core/tasks/EthereumPermit2AllowanceTask.d.ts
|
|
4
|
+
/** Signs the Permit2 allowances a caller attached to its own step, before prepare. */
|
|
5
|
+
export declare class EthereumPermit2AllowanceTask extends BaseStepExecutionTask {
|
|
6
|
+
override shouldRun(context: EthereumStepExecutorContext): Promise<boolean>;
|
|
7
|
+
run(context: EthereumStepExecutorContext): Promise<TaskResult>;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
//# sourceMappingURL=EthereumPermit2AllowanceTask.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_utils_getTypedDataLane = require("../../utils/getTypedDataLane.js");
|
|
3
|
+
const require_core_tasks_helpers_signTypedDataEntries = require("./helpers/signTypedDataEntries.js");
|
|
4
|
+
let _lifi_sdk = require("@lifi/sdk");
|
|
5
|
+
//#region src/core/tasks/EthereumPermit2AllowanceTask.ts
|
|
6
|
+
/** Signs the Permit2 allowances a caller attached to its own step, before prepare. */
|
|
7
|
+
var EthereumPermit2AllowanceTask = class extends _lifi_sdk.BaseStepExecutionTask {
|
|
8
|
+
async shouldRun(context) {
|
|
9
|
+
const { step, fromChain, disableMessageSigning } = context;
|
|
10
|
+
return require_utils_getTypedDataLane.isPermit2AllowanceLane(step, fromChain) && !disableMessageSigning;
|
|
11
|
+
}
|
|
12
|
+
async run(context) {
|
|
13
|
+
const { step, fromChain, statusManager } = context;
|
|
14
|
+
const action = statusManager.initializeAction({
|
|
15
|
+
step,
|
|
16
|
+
type: "PERMIT",
|
|
17
|
+
chainId: step.action.fromChainId,
|
|
18
|
+
status: "STARTED"
|
|
19
|
+
});
|
|
20
|
+
const allowanceTypedData = require_utils_getTypedDataLane.getTypedDataInLane(step, "permit2-allowance", fromChain);
|
|
21
|
+
const result = await require_core_tasks_helpers_signTypedDataEntries.signTypedDataEntries(context, allowanceTypedData, action.type);
|
|
22
|
+
if (result.status === "PAUSED") return { status: "PAUSED" };
|
|
23
|
+
statusManager.updateAction(step, action.type, "DONE");
|
|
24
|
+
return {
|
|
25
|
+
status: "COMPLETED",
|
|
26
|
+
context: { signedTypedData: result.signedTypedData }
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
exports.EthereumPermit2AllowanceTask = EthereumPermit2AllowanceTask;
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=EthereumPermit2AllowanceTask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EthereumPermit2AllowanceTask.js","names":["BaseStepExecutionTask","isPermit2AllowanceLane","getTypedDataInLane","signTypedDataEntries"],"sources":["../../../../src/core/tasks/EthereumPermit2AllowanceTask.ts"],"sourcesContent":["import { BaseStepExecutionTask, type TaskResult } from '@lifi/sdk'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport {\n getTypedDataInLane,\n isPermit2AllowanceLane,\n} from '../../utils/getTypedDataLane.js'\nimport { signTypedDataEntries } from './helpers/signTypedDataEntries.js'\n\n/** Signs the Permit2 allowances a caller attached to its own step, before prepare. */\nexport class EthereumPermit2AllowanceTask extends BaseStepExecutionTask {\n override async shouldRun(\n context: EthereumStepExecutorContext\n ): Promise<boolean> {\n const { step, fromChain, disableMessageSigning } = context\n\n return isPermit2AllowanceLane(step, fromChain) && !disableMessageSigning\n }\n\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const { step, fromChain, statusManager } = context\n\n const action = statusManager.initializeAction({\n step,\n type: 'PERMIT',\n chainId: step.action.fromChainId,\n status: 'STARTED',\n })\n\n const allowanceTypedData = getTypedDataInLane(\n step,\n 'permit2-allowance',\n fromChain\n )\n\n // `ACTION_REQUIRED`, not `MESSAGE_REQUIRED`: the widget maps no `PERMIT`\n // text for it. Pinned by `emits exactly STARTED, ACTION_REQUIRED and DONE`.\n const result = await signTypedDataEntries(\n context,\n allowanceTypedData,\n action.type\n )\n if (result.status === 'PAUSED') {\n return { status: 'PAUSED' }\n }\n\n statusManager.updateAction(step, action.type, 'DONE')\n\n return {\n status: 'COMPLETED',\n context: { signedTypedData: result.signedTypedData },\n }\n }\n}\n"],"mappings":";;;;;;AASA,IAAa,+BAAb,cAAkDA,UAAAA,sBAAsB;CACtE,MAAe,UACb,SACkB;EAClB,MAAM,EAAE,MAAM,WAAW,0BAA0B;EAEnD,OAAOC,+BAAAA,uBAAuB,MAAM,SAAS,KAAK,CAAC;CACrD;CAEA,MAAM,IAAI,SAA2D;EACnE,MAAM,EAAE,MAAM,WAAW,kBAAkB;EAE3C,MAAM,SAAS,cAAc,iBAAiB;GAC5C;GACA,MAAM;GACN,SAAS,KAAK,OAAO;GACrB,QAAQ;EACV,CAAC;EAED,MAAM,qBAAqBC,+BAAAA,mBACzB,MACA,qBACA,SACF;EAIA,MAAM,SAAS,MAAMC,gDAAAA,qBACnB,SACA,oBACA,OAAO,IACT;EACA,IAAI,OAAO,WAAW,UACpB,OAAO,EAAE,QAAQ,SAAS;EAG5B,cAAc,aAAa,MAAM,OAAO,MAAM,MAAM;EAEpD,OAAO;GACL,QAAQ;GACR,SAAS,EAAE,iBAAiB,OAAO,gBAAgB;EACrD;CACF;AACF"}
|
|
@@ -2,20 +2,22 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_core_tasks_helpers_getEthereumExecutionStrategy = require("./helpers/getEthereumExecutionStrategy.js");
|
|
3
3
|
const require_actions_getMaxPriorityFeePerGas = require("../../actions/getMaxPriorityFeePerGas.js");
|
|
4
4
|
const require_core_tasks_helpers_getUpdatedStep = require("./helpers/getUpdatedStep.js");
|
|
5
|
+
const require_core_tasks_helpers_preservePermit2Allowances = require("./helpers/preservePermit2Allowances.js");
|
|
5
6
|
let _lifi_sdk = require("@lifi/sdk");
|
|
6
7
|
//#region src/core/tasks/EthereumPrepareTransactionTask.ts
|
|
7
8
|
var EthereumPrepareTransactionTask = class extends _lifi_sdk.BaseStepExecutionTask {
|
|
8
9
|
async run(context) {
|
|
9
|
-
const { step, client, executionOptions, statusManager, allowUserInteraction, checkClient, isBridgeExecution, signedTypedData, ethereumClient } = context;
|
|
10
|
+
const { step, client, executionOptions, statusManager, allowUserInteraction, checkClient, isBridgeExecution, signedTypedData, ethereumClient, fromChain } = context;
|
|
10
11
|
if (!statusManager.findAction(step, isBridgeExecution ? "CROSS_CHAIN" : "SWAP")) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionUnprepared, "Unable to prepare transaction. Action not found.");
|
|
11
|
-
const updatedStep = await require_core_tasks_helpers_getUpdatedStep.getUpdatedStep(client, step, executionOptions, signedTypedData);
|
|
12
|
+
const updatedStep = await require_core_tasks_helpers_getUpdatedStep.getUpdatedStep(client, step, fromChain, executionOptions, signedTypedData);
|
|
12
13
|
const comparedStep = await (0, _lifi_sdk.stepComparison)(statusManager, step, updatedStep, allowUserInteraction, executionOptions);
|
|
14
|
+
const answeredTypedData = updatedStep.typedData ?? step.typedData;
|
|
13
15
|
Object.assign(step, {
|
|
14
16
|
...comparedStep,
|
|
15
17
|
execution: step.execution,
|
|
16
|
-
typedData: updatedStep.typedData
|
|
18
|
+
typedData: require_core_tasks_helpers_preservePermit2Allowances.preservePermit2Allowances(step, updatedStep.typedData, fromChain)
|
|
17
19
|
});
|
|
18
|
-
if (!step.transactionRequest && !
|
|
20
|
+
if (!step.transactionRequest && !answeredTypedData?.length) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionUnprepared, "Unable to prepare transaction. Transaction request is not found.");
|
|
19
21
|
let transactionRequest;
|
|
20
22
|
if (step.transactionRequest) {
|
|
21
23
|
let maxPriorityFeePerGas;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumPrepareTransactionTask.js","names":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","getUpdatedStep","stepComparison","getMaxPriorityFeePerGas","getEthereumExecutionStrategy"],"sources":["../../../../src/core/tasks/EthereumPrepareTransactionTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n LiFiErrorCode,\n stepComparison,\n type TaskResult,\n TransactionError,\n type TransactionParameters,\n} from '@lifi/sdk'\nimport { getMaxPriorityFeePerGas } from '../../actions/getMaxPriorityFeePerGas.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { getEthereumExecutionStrategy } from './helpers/getEthereumExecutionStrategy.js'\nimport { getUpdatedStep } from './helpers/getUpdatedStep.js'\n\nexport class EthereumPrepareTransactionTask extends BaseStepExecutionTask {\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n client,\n executionOptions,\n statusManager,\n allowUserInteraction,\n checkClient,\n isBridgeExecution,\n signedTypedData,\n ethereumClient,\n } = context\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n // Try to prepare a new transaction request and update the step with typed data\n const updatedStep = await getUpdatedStep(\n client,\n step,\n executionOptions,\n signedTypedData\n )\n\n const comparedStep = await stepComparison(\n statusManager,\n step,\n updatedStep,\n allowUserInteraction,\n executionOptions\n )\n\n Object.assign(step, {\n ...comparedStep,\n execution: step.execution,\n typedData: updatedStep.typedData
|
|
1
|
+
{"version":3,"file":"EthereumPrepareTransactionTask.js","names":["BaseStepExecutionTask","TransactionError","LiFiErrorCode","getUpdatedStep","stepComparison","preservePermit2Allowances","getMaxPriorityFeePerGas","getEthereumExecutionStrategy"],"sources":["../../../../src/core/tasks/EthereumPrepareTransactionTask.ts"],"sourcesContent":["import {\n BaseStepExecutionTask,\n LiFiErrorCode,\n stepComparison,\n type TaskResult,\n TransactionError,\n type TransactionParameters,\n} from '@lifi/sdk'\nimport { getMaxPriorityFeePerGas } from '../../actions/getMaxPriorityFeePerGas.js'\nimport type { EthereumStepExecutorContext } from '../../types.js'\nimport { getEthereumExecutionStrategy } from './helpers/getEthereumExecutionStrategy.js'\nimport { getUpdatedStep } from './helpers/getUpdatedStep.js'\nimport { preservePermit2Allowances } from './helpers/preservePermit2Allowances.js'\n\nexport class EthereumPrepareTransactionTask extends BaseStepExecutionTask {\n async run(context: EthereumStepExecutorContext): Promise<TaskResult> {\n const {\n step,\n client,\n executionOptions,\n statusManager,\n allowUserInteraction,\n checkClient,\n isBridgeExecution,\n signedTypedData,\n ethereumClient,\n fromChain,\n } = context\n\n const action = statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n\n if (!action) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Action not found.'\n )\n }\n\n // Try to prepare a new transaction request and update the step with typed data\n const updatedStep = await getUpdatedStep(\n client,\n step,\n fromChain,\n executionOptions,\n signedTypedData\n )\n\n const comparedStep = await stepComparison(\n statusManager,\n step,\n updatedStep,\n allowUserInteraction,\n executionOptions\n )\n\n const answeredTypedData = updatedStep.typedData ?? step.typedData\n\n Object.assign(step, {\n ...comparedStep,\n execution: step.execution,\n typedData: preservePermit2Allowances(\n step,\n updatedStep.typedData,\n fromChain\n ),\n })\n\n if (!step.transactionRequest && !answeredTypedData?.length) {\n throw new TransactionError(\n LiFiErrorCode.TransactionUnprepared,\n 'Unable to prepare transaction. Transaction request is not found.'\n )\n }\n\n let transactionRequest: TransactionParameters | undefined\n if (step.transactionRequest) {\n // Only fetch maxPriorityFeePerGas for local accounts\n let maxPriorityFeePerGas: bigint | undefined\n if (ethereumClient.account?.type === 'local') {\n const updatedClient = await checkClient(step)\n if (!updatedClient) {\n return { status: 'PAUSED' }\n }\n maxPriorityFeePerGas = await getMaxPriorityFeePerGas(\n client,\n updatedClient\n )\n } else {\n maxPriorityFeePerGas = step.transactionRequest.maxPriorityFeePerGas\n ? BigInt(step.transactionRequest.maxPriorityFeePerGas)\n : undefined\n }\n transactionRequest = {\n chainId: step.transactionRequest.chainId,\n to: step.transactionRequest.to,\n from: step.transactionRequest.from,\n data: step.transactionRequest.data,\n value: step.transactionRequest.value\n ? BigInt(step.transactionRequest.value)\n : undefined,\n gas: step.transactionRequest.gasLimit\n ? BigInt(step.transactionRequest.gasLimit)\n : undefined,\n // gasPrice: step.transactionRequest.gasPrice\n // ? BigInt(step.transactionRequest.gasPrice as string)\n // : undefined,\n // maxFeePerGas: step.transactionRequest.maxFeePerGas\n // ? BigInt(step.transactionRequest.maxFeePerGas as string)\n // : undefined,\n maxPriorityFeePerGas,\n }\n }\n\n if (executionOptions?.updateTransactionRequestHook && transactionRequest) {\n const customizedTransactionRequest: TransactionParameters =\n await executionOptions.updateTransactionRequestHook({\n requestType: 'transaction',\n ...transactionRequest,\n })\n transactionRequest = {\n ...transactionRequest,\n ...customizedTransactionRequest,\n }\n }\n\n // Recompute execution strategy after PrepareTransaction mutates step\n const executionStrategy = await getEthereumExecutionStrategy(context, true)\n\n return {\n status: 'COMPLETED',\n context: { transactionRequest, executionStrategy },\n }\n }\n}\n"],"mappings":";;;;;;;AAcA,IAAa,iCAAb,cAAoDA,UAAAA,sBAAsB;CACxE,MAAM,IAAI,SAA2D;EACnE,MAAM,EACJ,MACA,QACA,kBACA,eACA,sBACA,aACA,mBACA,iBACA,gBACA,cACE;EAOJ,IAAI,CALW,cAAc,WAC3B,MACA,oBAAoB,gBAAgB,MAG5B,GACR,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,uBACd,kDACF;EAIF,MAAM,cAAc,MAAMC,0CAAAA,eACxB,QACA,MACA,WACA,kBACA,eACF;EAEA,MAAM,eAAe,OAAA,GAAMC,UAAAA,eAAAA,CACzB,eACA,MACA,aACA,sBACA,gBACF;EAEA,MAAM,oBAAoB,YAAY,aAAa,KAAK;EAExD,OAAO,OAAO,MAAM;GAClB,GAAG;GACH,WAAW,KAAK;GAChB,WAAWC,qDAAAA,0BACT,MACA,YAAY,WACZ,SACF;EACF,CAAC;EAED,IAAI,CAAC,KAAK,sBAAsB,CAAC,mBAAmB,QAClD,MAAM,IAAIJ,UAAAA,iBACRC,UAAAA,cAAc,uBACd,kEACF;EAGF,IAAI;EACJ,IAAI,KAAK,oBAAoB;GAE3B,IAAI;GACJ,IAAI,eAAe,SAAS,SAAS,SAAS;IAC5C,MAAM,gBAAgB,MAAM,YAAY,IAAI;IAC5C,IAAI,CAAC,eACH,OAAO,EAAE,QAAQ,SAAS;IAE5B,uBAAuB,MAAMI,wCAAAA,wBAC3B,QACA,aACF;GACF,OACE,uBAAuB,KAAK,mBAAmB,uBAC3C,OAAO,KAAK,mBAAmB,oBAAoB,IACnD,KAAA;GAEN,qBAAqB;IACnB,SAAS,KAAK,mBAAmB;IACjC,IAAI,KAAK,mBAAmB;IAC5B,MAAM,KAAK,mBAAmB;IAC9B,MAAM,KAAK,mBAAmB;IAC9B,OAAO,KAAK,mBAAmB,QAC3B,OAAO,KAAK,mBAAmB,KAAK,IACpC,KAAA;IACJ,KAAK,KAAK,mBAAmB,WACzB,OAAO,KAAK,mBAAmB,QAAQ,IACvC,KAAA;IAOJ;GACF;EACF;EAEA,IAAI,kBAAkB,gCAAgC,oBAAoB;GACxE,MAAM,+BACJ,MAAM,iBAAiB,6BAA6B;IAClD,aAAa;IACb,GAAG;GACL,CAAC;GACH,qBAAqB;IACnB,GAAG;IACH,GAAG;GACL;EACF;EAGA,MAAM,oBAAoB,MAAMC,wDAAAA,6BAA6B,SAAS,IAAI;EAE1E,OAAO;GACL,QAAQ;GACR,SAAS;IAAE;IAAoB;GAAkB;EACnD;CACF;AACF"}
|
|
@@ -1,42 +1,29 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
const require_utils_isValidSignature = require("../../utils/isValidSignature.js");
|
|
2
|
+
const require_core_tasks_helpers_signTypedDataEntries = require("./helpers/signTypedDataEntries.js");
|
|
4
3
|
const require_permits_isNativePermitValid = require("../../permits/isNativePermitValid.js");
|
|
5
4
|
const require_hyperliquid_isHyperliquidAgentStep = require("../../hyperliquid/isHyperliquidAgentStep.js");
|
|
5
|
+
const require_core_tasks_helpers_isTypedDataAlreadySigned = require("./helpers/isTypedDataAlreadySigned.js");
|
|
6
6
|
const require_core_tasks_helpers_signHyperliquidTypedData = require("./helpers/signHyperliquidTypedData.js");
|
|
7
7
|
let _lifi_sdk = require("@lifi/sdk");
|
|
8
|
-
let viem_actions = require("viem/actions");
|
|
9
|
-
let viem_utils = require("viem/utils");
|
|
10
8
|
//#region src/core/tasks/EthereumRelayedSignAndExecuteTask.ts
|
|
11
9
|
var EthereumRelayedSignAndExecuteTask = class extends _lifi_sdk.BaseStepExecutionTask {
|
|
12
10
|
async run(context) {
|
|
13
|
-
const { step,
|
|
14
|
-
const signedTypedData = [...currentSignedTypedData];
|
|
11
|
+
const { step, client, statusManager, isBridgeExecution, signedTypedData: currentSignedTypedData } = context;
|
|
15
12
|
const action = statusManager.findAction(step, isBridgeExecution ? "CROSS_CHAIN" : "SWAP");
|
|
16
13
|
if (!action) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionUnprepared, "Unable to prepare transaction. Action not found.");
|
|
17
|
-
const
|
|
18
|
-
if (!
|
|
19
|
-
|
|
14
|
+
const allowanceTypedData = step.typedData?.filter((typedData) => !currentSignedTypedData.some((signedPermit) => require_permits_isNativePermitValid.isNativePermitValid(signedPermit, typedData)));
|
|
15
|
+
if (!allowanceTypedData?.length) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionUnprepared, "Unable to prepare transaction. Typed data for transfer is not found.");
|
|
16
|
+
const unsignedTypedData = allowanceTypedData.filter((typedData) => !require_core_tasks_helpers_isTypedDataAlreadySigned.isTypedDataAlreadySigned(currentSignedTypedData, typedData));
|
|
17
|
+
let signedTypedData;
|
|
20
18
|
if (require_hyperliquid_isHyperliquidAgentStep.isHyperliquidAgentStep(step)) {
|
|
21
|
-
|
|
19
|
+
statusManager.updateAction(step, action.type, "MESSAGE_REQUIRED");
|
|
20
|
+
const signedResults = await require_core_tasks_helpers_signHyperliquidTypedData.signHyperliquidTypedData(context, unsignedTypedData);
|
|
22
21
|
if (!signedResults) return { status: "PAUSED" };
|
|
23
|
-
signedTypedData
|
|
24
|
-
} else
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const signature = await (0, viem_utils.getAction)(updatedClient, viem_actions.signTypedData, "signTypedData")({
|
|
29
|
-
account: updatedClient.account,
|
|
30
|
-
primaryType: typedData.primaryType,
|
|
31
|
-
domain: typedData.domain,
|
|
32
|
-
types: typedData.types,
|
|
33
|
-
message: typedData.message
|
|
34
|
-
});
|
|
35
|
-
require_utils_isValidSignature.assertValidSignature(signature);
|
|
36
|
-
signedTypedData.push({
|
|
37
|
-
...typedData,
|
|
38
|
-
signature
|
|
39
|
-
});
|
|
22
|
+
signedTypedData = [...currentSignedTypedData, ...signedResults];
|
|
23
|
+
} else {
|
|
24
|
+
const result = await require_core_tasks_helpers_signTypedDataEntries.signTypedDataEntries(context, unsignedTypedData, action.type, "MESSAGE_REQUIRED");
|
|
25
|
+
if (result.status === "PAUSED") return { status: "PAUSED" };
|
|
26
|
+
signedTypedData = result.signedTypedData;
|
|
40
27
|
}
|
|
41
28
|
statusManager.updateAction(step, action.type, "PENDING");
|
|
42
29
|
const { execution, ...stepBase } = step;
|