@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
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { EthereumStepExecutorContext } from "../../../types.js";
|
|
2
|
+
import { TransactionMethodType } from "@lifi/sdk";
|
|
3
|
+
//#region src/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Whether the allowance work done in `preparedFor` does not fit `needed`, the
|
|
6
|
+
* strategy prepare established. Two things can break:
|
|
7
|
+
* - Calls queued for a batch are sent only by the batched task.
|
|
8
|
+
* - The spender: `resolvePermit2Support` never picks Permit2 for `batched`, but
|
|
9
|
+
* can for the other strategies. An allowance that is sufficient for the wrong
|
|
10
|
+
* spender queues nothing, so the calls alone do not show it.
|
|
11
|
+
*
|
|
12
|
+
* The spender recorded by `EthereumCheckAllowanceTask` is compared, because
|
|
13
|
+
* prepare has already replaced the step with the re-quote.
|
|
14
|
+
*/
|
|
15
|
+
export declare const isAllowancePreparedForAnotherStrategy: (context: EthereumStepExecutorContext, preparedFor: TransactionMethodType, needed: TransactionMethodType) => Promise<boolean>;
|
|
16
|
+
//#endregion
|
|
17
|
+
//# sourceMappingURL=isAllowancePreparedForAnotherStrategy.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_core_tasks_helpers_resolveAllowanceSpender = require("./resolveAllowanceSpender.js");
|
|
3
|
+
//#region src/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.ts
|
|
4
|
+
/**
|
|
5
|
+
* Whether the allowance work done in `preparedFor` does not fit `needed`, the
|
|
6
|
+
* strategy prepare established. Two things can break:
|
|
7
|
+
* - Calls queued for a batch are sent only by the batched task.
|
|
8
|
+
* - The spender: `resolvePermit2Support` never picks Permit2 for `batched`, but
|
|
9
|
+
* can for the other strategies. An allowance that is sufficient for the wrong
|
|
10
|
+
* spender queues nothing, so the calls alone do not show it.
|
|
11
|
+
*
|
|
12
|
+
* The spender recorded by `EthereumCheckAllowanceTask` is compared, because
|
|
13
|
+
* prepare has already replaced the step with the re-quote.
|
|
14
|
+
*/
|
|
15
|
+
const isAllowancePreparedForAnotherStrategy = async (context, preparedFor, needed) => {
|
|
16
|
+
if (preparedFor === needed) return false;
|
|
17
|
+
if (preparedFor === "batched" && context.calls.length) return true;
|
|
18
|
+
if (context.hasMatchingPermit) return false;
|
|
19
|
+
const { allowanceSpender } = context;
|
|
20
|
+
if (!allowanceSpender) return false;
|
|
21
|
+
const { spenderAddress } = await require_core_tasks_helpers_resolveAllowanceSpender.resolveAllowanceSpender(context, needed);
|
|
22
|
+
return allowanceSpender.toLowerCase() !== spenderAddress?.toLowerCase();
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.isAllowancePreparedForAnotherStrategy = isAllowancePreparedForAnotherStrategy;
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=isAllowancePreparedForAnotherStrategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isAllowancePreparedForAnotherStrategy.js","names":["resolveAllowanceSpender"],"sources":["../../../../../src/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.ts"],"sourcesContent":["import type { TransactionMethodType } from '@lifi/sdk'\nimport type { EthereumStepExecutorContext } from '../../../types.js'\nimport { resolveAllowanceSpender } from './resolveAllowanceSpender.js'\n\n/**\n * Whether the allowance work done in `preparedFor` does not fit `needed`, the\n * strategy prepare established. Two things can break:\n * - Calls queued for a batch are sent only by the batched task.\n * - The spender: `resolvePermit2Support` never picks Permit2 for `batched`, but\n * can for the other strategies. An allowance that is sufficient for the wrong\n * spender queues nothing, so the calls alone do not show it.\n *\n * The spender recorded by `EthereumCheckAllowanceTask` is compared, because\n * prepare has already replaced the step with the re-quote.\n */\nexport const isAllowancePreparedForAnotherStrategy = async (\n context: EthereumStepExecutorContext,\n preparedFor: TransactionMethodType,\n needed: TransactionMethodType\n): Promise<boolean> => {\n if (preparedFor === needed) {\n return false\n }\n if (preparedFor === 'batched' && context.calls.length) {\n return true\n }\n // A signed native permit covers the allowance, and the re-quote carries it.\n if (context.hasMatchingPermit) {\n return false\n }\n const { allowanceSpender } = context\n if (!allowanceSpender) {\n return false\n }\n const { spenderAddress } = await resolveAllowanceSpender(context, needed)\n return allowanceSpender.toLowerCase() !== spenderAddress?.toLowerCase()\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAa,wCAAwC,OACnD,SACA,aACA,WACqB;CACrB,IAAI,gBAAgB,QAClB,OAAO;CAET,IAAI,gBAAgB,aAAa,QAAQ,MAAM,QAC7C,OAAO;CAGT,IAAI,QAAQ,mBACV,OAAO;CAET,MAAM,EAAE,qBAAqB;CAC7B,IAAI,CAAC,kBACH,OAAO;CAET,MAAM,EAAE,mBAAmB,MAAMA,mDAAAA,wBAAwB,SAAS,MAAM;CACxE,OAAO,iBAAiB,YAAY,MAAM,gBAAgB,YAAY;AACxE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EthereumStepExecutorContext } from "../../../types.js";
|
|
2
|
+
import { TransactionMethodType } from "@lifi/sdk";
|
|
3
|
+
import { Address } from "viem";
|
|
4
|
+
//#region src/core/tasks/helpers/resolveAllowanceSpender.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* The spender the allowance tasks check and approve in `strategy`: canonical
|
|
7
|
+
* Permit2 when the step takes the Permit2 flow there, `approvalAddress`
|
|
8
|
+
* otherwise. Every allowance task and the prepare-time check use this one
|
|
9
|
+
* derivation, so they cannot disagree.
|
|
10
|
+
*/
|
|
11
|
+
export declare const resolveAllowanceSpender: (context: EthereumStepExecutorContext, strategy: TransactionMethodType) => Promise<{
|
|
12
|
+
permit2Supported: boolean;
|
|
13
|
+
spenderAddress: Address;
|
|
14
|
+
}>;
|
|
15
|
+
//#endregion
|
|
16
|
+
//# sourceMappingURL=resolveAllowanceSpender.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_core_tasks_helpers_resolvePermit2Support = require("./resolvePermit2Support.js");
|
|
3
|
+
//#region src/core/tasks/helpers/resolveAllowanceSpender.ts
|
|
4
|
+
/**
|
|
5
|
+
* The spender the allowance tasks check and approve in `strategy`: canonical
|
|
6
|
+
* Permit2 when the step takes the Permit2 flow there, `approvalAddress`
|
|
7
|
+
* otherwise. Every allowance task and the prepare-time check use this one
|
|
8
|
+
* derivation, so they cannot disagree.
|
|
9
|
+
*/
|
|
10
|
+
const resolveAllowanceSpender = async (context, strategy) => {
|
|
11
|
+
const permit2Supported = await require_core_tasks_helpers_resolvePermit2Support.resolvePermit2Support(context, strategy);
|
|
12
|
+
const { fromChain, step } = context;
|
|
13
|
+
return {
|
|
14
|
+
permit2Supported,
|
|
15
|
+
spenderAddress: permit2Supported ? fromChain.permit2 : step.estimate.approvalAddress
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.resolveAllowanceSpender = resolveAllowanceSpender;
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=resolveAllowanceSpender.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveAllowanceSpender.js","names":["resolvePermit2Support"],"sources":["../../../../../src/core/tasks/helpers/resolveAllowanceSpender.ts"],"sourcesContent":["import type { TransactionMethodType } from '@lifi/sdk'\nimport type { Address } from 'viem'\nimport type { EthereumStepExecutorContext } from '../../../types.js'\nimport { resolvePermit2Support } from './resolvePermit2Support.js'\n\n/**\n * The spender the allowance tasks check and approve in `strategy`: canonical\n * Permit2 when the step takes the Permit2 flow there, `approvalAddress`\n * otherwise. Every allowance task and the prepare-time check use this one\n * derivation, so they cannot disagree.\n */\nexport const resolveAllowanceSpender = async (\n context: EthereumStepExecutorContext,\n strategy: TransactionMethodType\n): Promise<{ permit2Supported: boolean; spenderAddress: Address }> => {\n const permit2Supported = await resolvePermit2Support(context, strategy)\n const { fromChain, step } = context\n return {\n permit2Supported,\n spenderAddress: (permit2Supported\n ? fromChain.permit2\n : step.estimate.approvalAddress) as Address,\n }\n}\n"],"mappings":";;;;;;;;;AAWA,MAAa,0BAA0B,OACrC,SACA,aACoE;CACpE,MAAM,mBAAmB,MAAMA,iDAAAA,sBAAsB,SAAS,QAAQ;CACtE,MAAM,EAAE,WAAW,SAAS;CAC5B,OAAO;EACL;EACA,gBAAiB,mBACb,UAAU,UACV,KAAK,SAAS;CACpB;AACF"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _lifi_sdk = require("@lifi/sdk");
|
|
2
3
|
//#region src/core/tasks/helpers/shouldCheckForAllowance.ts
|
|
3
4
|
const shouldCheckForAllowance = (step, isBridgeExecution, isFromNativeToken, statusManager) => {
|
|
4
5
|
const exchangeActionType = isBridgeExecution ? "CROSS_CHAIN" : "SWAP";
|
|
5
6
|
const swapOrBridgeAction = statusManager.findAction(step, exchangeActionType);
|
|
6
|
-
return !
|
|
7
|
+
return !(0, _lifi_sdk.hasOpenTransaction)(swapOrBridgeAction) && !isFromNativeToken && !!step.estimate.approvalAddress && !step.estimate.skipApproval;
|
|
7
8
|
};
|
|
8
9
|
//#endregion
|
|
9
10
|
exports.shouldCheckForAllowance = shouldCheckForAllowance;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shouldCheckForAllowance.js","names":[],"sources":["../../../../../src/core/tasks/helpers/shouldCheckForAllowance.ts"],"sourcesContent":["import type
|
|
1
|
+
{"version":3,"file":"shouldCheckForAllowance.js","names":["hasOpenTransaction"],"sources":["../../../../../src/core/tasks/helpers/shouldCheckForAllowance.ts"],"sourcesContent":["import {\n hasOpenTransaction,\n type LiFiStepExtended,\n type StatusManager,\n} from '@lifi/sdk'\n\nexport const shouldCheckForAllowance = (\n step: LiFiStepExtended,\n isBridgeExecution: boolean,\n isFromNativeToken: boolean,\n statusManager: StatusManager\n): boolean => {\n const exchangeActionType = isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n\n const swapOrBridgeAction = statusManager.findAction(step, exchangeActionType)\n\n return (\n // No swap/bridge transaction (hash, batch/relay id or stored bytes) that may\n // still land. A FAILED action with a final outcome does not count, so the\n // allowance is checked again before the new transaction.\n !hasOpenTransaction(swapOrBridgeAction) &&\n // Token is not native (address is not zero)\n !isFromNativeToken &&\n // Approval address is required for allowance checks, but may be null in special cases (e.g. direct transfers)\n !!step.estimate.approvalAddress &&\n !step.estimate.skipApproval\n )\n}\n"],"mappings":";;;AAMA,MAAa,2BACX,MACA,mBACA,mBACA,kBACY;CACZ,MAAM,qBAAqB,oBAAoB,gBAAgB;CAE/D,MAAM,qBAAqB,cAAc,WAAW,MAAM,kBAAkB;CAE5E,OAIE,EAAA,GAACA,UAAAA,mBAAAA,CAAmB,kBAAkB,KAEtC,CAAC,qBAED,CAAC,CAAC,KAAK,SAAS,mBAChB,CAAC,KAAK,SAAS;AAEnB"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { EthereumStepExecutorContext } from "../../../types.js";
|
|
2
2
|
import { SignedTypedData, TypedData } from "@lifi/sdk";
|
|
3
3
|
//#region src/core/tasks/helpers/signHyperliquidTypedData.d.ts
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* `beforeSignature` runs right before each signature, the agent's included,
|
|
6
|
+
* after every await before it; it throws to stop the signing.
|
|
7
|
+
*/
|
|
8
|
+
export declare const signHyperliquidTypedData: (context: EthereumStepExecutorContext, allowanceTypedData: TypedData[], beforeSignature?: () => void) => Promise<SignedTypedData[] | undefined>;
|
|
5
9
|
//#endregion
|
|
6
10
|
//# sourceMappingURL=signHyperliquidTypedData.d.ts.map
|
|
@@ -6,7 +6,11 @@ const require_hyperliquid_agentWallet = require("../../../hyperliquid/agentWalle
|
|
|
6
6
|
let viem_actions = require("viem/actions");
|
|
7
7
|
let viem_utils = require("viem/utils");
|
|
8
8
|
//#region src/core/tasks/helpers/signHyperliquidTypedData.ts
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* `beforeSignature` runs right before each signature, the agent's included,
|
|
11
|
+
* after every await before it; it throws to stop the signing.
|
|
12
|
+
*/
|
|
13
|
+
const signHyperliquidTypedData = async (context, allowanceTypedData, beforeSignature) => {
|
|
10
14
|
const { step, fromChain, client, allowUserInteraction, checkClient, ethereumClient, getStorage } = context;
|
|
11
15
|
if (!allowUserInteraction) return;
|
|
12
16
|
const signedResults = [];
|
|
@@ -23,6 +27,7 @@ const signHyperliquidTypedData = async (context, allowanceTypedData) => {
|
|
|
23
27
|
};
|
|
24
28
|
const updatedClient = await checkClient(step, require_utils_getDomainChainId.getDomainChainId(typedData.domain) || fromChain.id);
|
|
25
29
|
if (!updatedClient) return;
|
|
30
|
+
beforeSignature?.();
|
|
26
31
|
const signature = await (0, viem_utils.getAction)(updatedClient, viem_actions.signTypedData, "signTypedData")({
|
|
27
32
|
account: updatedClient.account,
|
|
28
33
|
primaryType: typedData.primaryType,
|
|
@@ -39,6 +44,7 @@ const signHyperliquidTypedData = async (context, allowanceTypedData) => {
|
|
|
39
44
|
} else if (require_hyperliquid_isHyperliquidAgentStep.isApproveBuilderFeeMessage(typedData)) {
|
|
40
45
|
const updatedClient = await checkClient(step, require_utils_getDomainChainId.getDomainChainId(typedData.domain) || fromChain.id);
|
|
41
46
|
if (!updatedClient) return;
|
|
47
|
+
beforeSignature?.();
|
|
42
48
|
const signature = await (0, viem_utils.getAction)(updatedClient, viem_actions.signTypedData, "signTypedData")({
|
|
43
49
|
account: updatedClient.account,
|
|
44
50
|
primaryType: typedData.primaryType,
|
|
@@ -52,6 +58,7 @@ const signHyperliquidTypedData = async (context, allowanceTypedData) => {
|
|
|
52
58
|
signature
|
|
53
59
|
});
|
|
54
60
|
} else if (require_hyperliquid_isHyperliquidAgentStep.isHyperliquidOrderMessage(typedData)) {
|
|
61
|
+
beforeSignature?.();
|
|
55
62
|
const signature = await agentAccount.signTypedData({
|
|
56
63
|
domain: typedData.domain,
|
|
57
64
|
types: typedData.types,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signHyperliquidTypedData.js","names":["isApproveAgentMessage","getOrCreateAgentWallet","getDomainChainId","getAction","signTypedData","isApproveBuilderFeeMessage","isHyperliquidOrderMessage"],"sources":["../../../../../src/core/tasks/helpers/signHyperliquidTypedData.ts"],"sourcesContent":["import type { SignedTypedData, TypedData } from '@lifi/sdk'\nimport { signTypedData } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport { getOrCreateAgentWallet } from '../../../hyperliquid/agentWallet.js'\nimport {\n isApproveAgentMessage,\n isApproveBuilderFeeMessage,\n isHyperliquidOrderMessage,\n} from '../../../hyperliquid/isHyperliquidAgentStep.js'\nimport type { EthereumStepExecutorContext } from '../../../types.js'\nimport { getDomainChainId } from '../../../utils/getDomainChainId.js'\nimport { assertValidSignature } from '../../../utils/isValidSignature.js'\n\nexport const signHyperliquidTypedData = async (\n context: EthereumStepExecutorContext,\n allowanceTypedData: TypedData[]\n): Promise<SignedTypedData[] | undefined> => {\n const {\n step,\n fromChain,\n client,\n allowUserInteraction,\n checkClient,\n ethereumClient,\n getStorage,\n } = context\n\n if (!allowUserInteraction) {\n return\n }\n\n const signedResults: SignedTypedData[] = []\n const ownerAddress = ethereumClient.account!.address\n const storage = getStorage(client)\n\n const approveMessage = allowanceTypedData.find(isApproveAgentMessage)\n const existingAgentAddress = approveMessage?.message.agentAddress as\n | string\n | undefined\n\n const {\n account: agentAccount,\n needsApproval,\n expiresAt,\n } = await getOrCreateAgentWallet(storage, ownerAddress, existingAgentAddress)\n\n for (const typedData of allowanceTypedData) {\n if (isApproveAgentMessage(typedData)) {\n if (!needsApproval) {\n continue\n }\n\n const message = {\n ...typedData.message,\n agentAddress: agentAccount.address.toLowerCase(),\n agentName: `${typedData.message.agentName} valid_until ${expiresAt}`,\n }\n const typedDataChainId =\n getDomainChainId(typedData.domain) || fromChain.id\n\n const updatedClient = await checkClient(step, typedDataChainId)\n if (!updatedClient) {\n return\n }\n\n const signature = await getAction(\n updatedClient,\n signTypedData,\n 'signTypedData'\n )({\n account: updatedClient.account!,\n primaryType: typedData.primaryType,\n domain: typedData.domain,\n types: typedData.types,\n message,\n })\n assertValidSignature(signature)\n signedResults.push({ ...typedData, message, signature })\n } else if (isApproveBuilderFeeMessage(typedData)) {\n const typedDataChainId =\n getDomainChainId(typedData.domain) || fromChain.id\n\n const updatedClient = await checkClient(step, typedDataChainId)\n if (!updatedClient) {\n return\n }\n\n const signature = await getAction(\n updatedClient,\n signTypedData,\n 'signTypedData'\n )({\n account: updatedClient.account!,\n primaryType: typedData.primaryType,\n domain: typedData.domain,\n types: typedData.types,\n message: typedData.message,\n })\n assertValidSignature(signature)\n signedResults.push({ ...typedData, signature })\n } else if (isHyperliquidOrderMessage(typedData)) {\n const signature = await agentAccount.signTypedData({\n domain: typedData.domain,\n types: typedData.types,\n primaryType: typedData.primaryType,\n message: typedData.message,\n })\n signedResults.push({ ...typedData, signature })\n }\n }\n\n return signedResults\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"signHyperliquidTypedData.js","names":["isApproveAgentMessage","getOrCreateAgentWallet","getDomainChainId","getAction","signTypedData","isApproveBuilderFeeMessage","isHyperliquidOrderMessage"],"sources":["../../../../../src/core/tasks/helpers/signHyperliquidTypedData.ts"],"sourcesContent":["import type { SignedTypedData, TypedData } from '@lifi/sdk'\nimport { signTypedData } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport { getOrCreateAgentWallet } from '../../../hyperliquid/agentWallet.js'\nimport {\n isApproveAgentMessage,\n isApproveBuilderFeeMessage,\n isHyperliquidOrderMessage,\n} from '../../../hyperliquid/isHyperliquidAgentStep.js'\nimport type { EthereumStepExecutorContext } from '../../../types.js'\nimport { getDomainChainId } from '../../../utils/getDomainChainId.js'\nimport { assertValidSignature } from '../../../utils/isValidSignature.js'\n\n/**\n * `beforeSignature` runs right before each signature, the agent's included,\n * after every await before it; it throws to stop the signing.\n */\nexport const signHyperliquidTypedData = async (\n context: EthereumStepExecutorContext,\n allowanceTypedData: TypedData[],\n beforeSignature?: () => void\n): Promise<SignedTypedData[] | undefined> => {\n const {\n step,\n fromChain,\n client,\n allowUserInteraction,\n checkClient,\n ethereumClient,\n getStorage,\n } = context\n\n if (!allowUserInteraction) {\n return\n }\n\n const signedResults: SignedTypedData[] = []\n const ownerAddress = ethereumClient.account!.address\n const storage = getStorage(client)\n\n const approveMessage = allowanceTypedData.find(isApproveAgentMessage)\n const existingAgentAddress = approveMessage?.message.agentAddress as\n | string\n | undefined\n\n const {\n account: agentAccount,\n needsApproval,\n expiresAt,\n } = await getOrCreateAgentWallet(storage, ownerAddress, existingAgentAddress)\n\n for (const typedData of allowanceTypedData) {\n if (isApproveAgentMessage(typedData)) {\n if (!needsApproval) {\n continue\n }\n\n const message = {\n ...typedData.message,\n agentAddress: agentAccount.address.toLowerCase(),\n agentName: `${typedData.message.agentName} valid_until ${expiresAt}`,\n }\n const typedDataChainId =\n getDomainChainId(typedData.domain) || fromChain.id\n\n const updatedClient = await checkClient(step, typedDataChainId)\n if (!updatedClient) {\n return\n }\n\n beforeSignature?.()\n const signature = await getAction(\n updatedClient,\n signTypedData,\n 'signTypedData'\n )({\n account: updatedClient.account!,\n primaryType: typedData.primaryType,\n domain: typedData.domain,\n types: typedData.types,\n message,\n })\n assertValidSignature(signature)\n signedResults.push({ ...typedData, message, signature })\n } else if (isApproveBuilderFeeMessage(typedData)) {\n const typedDataChainId =\n getDomainChainId(typedData.domain) || fromChain.id\n\n const updatedClient = await checkClient(step, typedDataChainId)\n if (!updatedClient) {\n return\n }\n\n beforeSignature?.()\n const signature = await getAction(\n updatedClient,\n signTypedData,\n 'signTypedData'\n )({\n account: updatedClient.account!,\n primaryType: typedData.primaryType,\n domain: typedData.domain,\n types: typedData.types,\n message: typedData.message,\n })\n assertValidSignature(signature)\n signedResults.push({ ...typedData, signature })\n } else if (isHyperliquidOrderMessage(typedData)) {\n beforeSignature?.()\n const signature = await agentAccount.signTypedData({\n domain: typedData.domain,\n types: typedData.types,\n primaryType: typedData.primaryType,\n message: typedData.message,\n })\n signedResults.push({ ...typedData, signature })\n }\n }\n\n return signedResults\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAa,2BAA2B,OACtC,SACA,oBACA,oBAC2C;CAC3C,MAAM,EACJ,MACA,WACA,QACA,sBACA,aACA,gBACA,eACE;CAEJ,IAAI,CAAC,sBACH;CAGF,MAAM,gBAAmC,CAAC;CAC1C,MAAM,eAAe,eAAe,QAAS;CAC7C,MAAM,UAAU,WAAW,MAAM;CAGjC,MAAM,uBADiB,mBAAmB,KAAKA,2CAAAA,qBACL,CAAC,EAAE,QAAQ;CAIrD,MAAM,EACJ,SAAS,cACT,eACA,cACE,MAAMC,gCAAAA,uBAAuB,SAAS,cAAc,oBAAoB;CAE5E,KAAK,MAAM,aAAa,oBACtB,IAAID,2CAAAA,sBAAsB,SAAS,GAAG;EACpC,IAAI,CAAC,eACH;EAGF,MAAM,UAAU;GACd,GAAG,UAAU;GACb,cAAc,aAAa,QAAQ,YAAY;GAC/C,WAAW,GAAG,UAAU,QAAQ,UAAU,eAAe;EAC3D;EAIA,MAAM,gBAAgB,MAAM,YAAY,MAFtCE,+BAAAA,iBAAiB,UAAU,MAAM,KAAK,UAAU,EAEY;EAC9D,IAAI,CAAC,eACH;EAGF,kBAAkB;EAClB,MAAM,YAAY,OAAA,GAAMC,WAAAA,UAAAA,CACtB,eACAC,aAAAA,eACA,eACF,CAAC,CAAC;GACA,SAAS,cAAc;GACvB,aAAa,UAAU;GACvB,QAAQ,UAAU;GAClB,OAAO,UAAU;GACjB;EACF,CAAC;EACD,+BAAA,qBAAqB,SAAS;EAC9B,cAAc,KAAK;GAAE,GAAG;GAAW;GAAS;EAAU,CAAC;CACzD,OAAO,IAAIC,2CAAAA,2BAA2B,SAAS,GAAG;EAIhD,MAAM,gBAAgB,MAAM,YAAY,MAFtCH,+BAAAA,iBAAiB,UAAU,MAAM,KAAK,UAAU,EAEY;EAC9D,IAAI,CAAC,eACH;EAGF,kBAAkB;EAClB,MAAM,YAAY,OAAA,GAAMC,WAAAA,UAAAA,CACtB,eACAC,aAAAA,eACA,eACF,CAAC,CAAC;GACA,SAAS,cAAc;GACvB,aAAa,UAAU;GACvB,QAAQ,UAAU;GAClB,OAAO,UAAU;GACjB,SAAS,UAAU;EACrB,CAAC;EACD,+BAAA,qBAAqB,SAAS;EAC9B,cAAc,KAAK;GAAE,GAAG;GAAW;EAAU,CAAC;CAChD,OAAO,IAAIE,2CAAAA,0BAA0B,SAAS,GAAG;EAC/C,kBAAkB;EAClB,MAAM,YAAY,MAAM,aAAa,cAAc;GACjD,QAAQ,UAAU;GAClB,OAAO,UAAU;GACjB,aAAa,UAAU;GACvB,SAAS,UAAU;EACrB,CAAC;EACD,cAAc,KAAK;GAAE,GAAG;GAAW;EAAU,CAAC;CAChD;CAGF,OAAO;AACT"}
|
|
@@ -7,7 +7,11 @@ export type SignTypedDataEntriesResult = {
|
|
|
7
7
|
status: "COMPLETED";
|
|
8
8
|
signedTypedData: SignedTypedData[];
|
|
9
9
|
};
|
|
10
|
-
/**
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Signs the entries in order, switching chains per entry, and appends the
|
|
12
|
+
* signatures. `beforeSignature` runs right before each wallet call, after the
|
|
13
|
+
* chain switch; it throws to stop the signing.
|
|
14
|
+
*/
|
|
15
|
+
export declare function signTypedDataEntries(context: EthereumStepExecutorContext, entries: TypedData[], actionType: ExecutionActionType, actionStatus?: ExecutionActionStatus, beforeSignature?: () => void): Promise<SignTypedDataEntriesResult>;
|
|
12
16
|
//#endregion
|
|
13
17
|
//# sourceMappingURL=signTypedDataEntries.d.ts.map
|
|
@@ -4,8 +4,12 @@ const require_utils_isValidSignature = require("../../../utils/isValidSignature.
|
|
|
4
4
|
let viem_actions = require("viem/actions");
|
|
5
5
|
let viem_utils = require("viem/utils");
|
|
6
6
|
//#region src/core/tasks/helpers/signTypedDataEntries.ts
|
|
7
|
-
/**
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Signs the entries in order, switching chains per entry, and appends the
|
|
9
|
+
* signatures. `beforeSignature` runs right before each wallet call, after the
|
|
10
|
+
* chain switch; it throws to stop the signing.
|
|
11
|
+
*/
|
|
12
|
+
async function signTypedDataEntries(context, entries, actionType, actionStatus = "ACTION_REQUIRED", beforeSignature) {
|
|
9
13
|
const { step, statusManager, allowUserInteraction, checkClient, signedTypedData: currentSignedTypedData } = context;
|
|
10
14
|
const signedTypedData = [...currentSignedTypedData];
|
|
11
15
|
if (entries.length) statusManager.updateAction(step, actionType, actionStatus);
|
|
@@ -13,6 +17,7 @@ async function signTypedDataEntries(context, entries, actionType, actionStatus =
|
|
|
13
17
|
if (!allowUserInteraction) return { status: "PAUSED" };
|
|
14
18
|
const client = await checkClient(step, require_utils_getDomainChainId.getDomainChainId(typedData.domain) || step.action.fromChainId);
|
|
15
19
|
if (!client) return { status: "PAUSED" };
|
|
20
|
+
beforeSignature?.();
|
|
16
21
|
const signature = await (0, viem_utils.getAction)(client, viem_actions.signTypedData, "signTypedData")({
|
|
17
22
|
account: client.account,
|
|
18
23
|
domain: typedData.domain,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signTypedDataEntries.js","names":["getDomainChainId","getAction","signTypedData"],"sources":["../../../../../src/core/tasks/helpers/signTypedDataEntries.ts"],"sourcesContent":["import type {\n ExecutionActionStatus,\n ExecutionActionType,\n SignedTypedData,\n TypedData,\n} from '@lifi/sdk'\nimport { signTypedData } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport type { EthereumStepExecutorContext } from '../../../types.js'\nimport { getDomainChainId } from '../../../utils/getDomainChainId.js'\nimport { assertValidSignature } from '../../../utils/isValidSignature.js'\n\nexport type SignTypedDataEntriesResult =\n | { status: 'PAUSED' }\n | { status: 'COMPLETED'; signedTypedData: SignedTypedData[] }\n\n
|
|
1
|
+
{"version":3,"file":"signTypedDataEntries.js","names":["getDomainChainId","getAction","signTypedData"],"sources":["../../../../../src/core/tasks/helpers/signTypedDataEntries.ts"],"sourcesContent":["import type {\n ExecutionActionStatus,\n ExecutionActionType,\n SignedTypedData,\n TypedData,\n} from '@lifi/sdk'\nimport { signTypedData } from 'viem/actions'\nimport { getAction } from 'viem/utils'\nimport type { EthereumStepExecutorContext } from '../../../types.js'\nimport { getDomainChainId } from '../../../utils/getDomainChainId.js'\nimport { assertValidSignature } from '../../../utils/isValidSignature.js'\n\nexport type SignTypedDataEntriesResult =\n | { status: 'PAUSED' }\n | { status: 'COMPLETED'; signedTypedData: SignedTypedData[] }\n\n/**\n * Signs the entries in order, switching chains per entry, and appends the\n * signatures. `beforeSignature` runs right before each wallet call, after the\n * chain switch; it throws to stop the signing.\n */\nexport async function signTypedDataEntries(\n context: EthereumStepExecutorContext,\n entries: TypedData[],\n actionType: ExecutionActionType,\n actionStatus: ExecutionActionStatus = 'ACTION_REQUIRED',\n beforeSignature?: () => void\n): Promise<SignTypedDataEntriesResult> {\n const {\n step,\n statusManager,\n allowUserInteraction,\n checkClient,\n signedTypedData: currentSignedTypedData,\n } = context\n\n const signedTypedData = [...currentSignedTypedData]\n\n // Announced once for the round, not once per entry. Relay-from-Hyperliquid\n // carries two messages, and main told the consumer `MESSAGE_REQUIRED` once.\n if (entries.length) {\n statusManager.updateAction(step, actionType, actionStatus)\n }\n\n for (const typedData of entries) {\n if (!allowUserInteraction) {\n return { status: 'PAUSED' }\n }\n\n const typedDataChainId =\n getDomainChainId(typedData.domain) || step.action.fromChainId\n\n const client = await checkClient(step, typedDataChainId)\n if (!client) {\n return { status: 'PAUSED' }\n }\n\n beforeSignature?.()\n const signature = await getAction(\n client,\n signTypedData,\n 'signTypedData'\n )({\n account: client.account!,\n domain: typedData.domain,\n types: typedData.types,\n primaryType: typedData.primaryType,\n message: typedData.message,\n })\n assertValidSignature(signature)\n\n signedTypedData.push({ ...typedData, signature })\n }\n\n return { status: 'COMPLETED', signedTypedData }\n}\n"],"mappings":";;;;;;;;;;;AAqBA,eAAsB,qBACpB,SACA,SACA,YACA,eAAsC,mBACtC,iBACqC;CACrC,MAAM,EACJ,MACA,eACA,sBACA,aACA,iBAAiB,2BACf;CAEJ,MAAM,kBAAkB,CAAC,GAAG,sBAAsB;CAIlD,IAAI,QAAQ,QACV,cAAc,aAAa,MAAM,YAAY,YAAY;CAG3D,KAAK,MAAM,aAAa,SAAS;EAC/B,IAAI,CAAC,sBACH,OAAO,EAAE,QAAQ,SAAS;EAM5B,MAAM,SAAS,MAAM,YAAY,MAF/BA,+BAAAA,iBAAiB,UAAU,MAAM,KAAK,KAAK,OAAO,WAEG;EACvD,IAAI,CAAC,QACH,OAAO,EAAE,QAAQ,SAAS;EAG5B,kBAAkB;EAClB,MAAM,YAAY,OAAA,GAAMC,WAAAA,UAAAA,CACtB,QACAC,aAAAA,eACA,eACF,CAAC,CAAC;GACA,SAAS,OAAO;GAChB,QAAQ,UAAU;GAClB,OAAO,UAAU;GACjB,aAAa,UAAU;GACvB,SAAS,UAAU;EACrB,CAAC;EACD,+BAAA,qBAAqB,SAAS;EAE9B,gBAAgB,KAAK;GAAE,GAAG;GAAW;EAAU,CAAC;CAClD;CAEA,OAAO;EAAE,QAAQ;EAAa;CAAgB;AAChD"}
|
|
@@ -3,7 +3,8 @@ let _lifi_sdk = require("@lifi/sdk");
|
|
|
3
3
|
let viem = require("viem");
|
|
4
4
|
//#region src/errors/parseEthereumErrors.ts
|
|
5
5
|
const parseEthereumErrors = async (e, step, action, retryParams) => {
|
|
6
|
-
if (
|
|
6
|
+
if (e instanceof _lifi_sdk.ExecuteStepRetryError) return e;
|
|
7
|
+
if (isAtomicReadyWalletRejectedUpgradeError(e) && !retryParams) return new _lifi_sdk.ExecuteStepRetryError("Wallet rejected 7702 upgrade based on the EIP-5792 capabilities; retry with atomicityNotReady", { atomicityNotReady: true }, e);
|
|
7
8
|
if (e instanceof _lifi_sdk.SDKError) {
|
|
8
9
|
e.step = e.step ?? step;
|
|
9
10
|
e.action = e.action ?? action;
|
|
@@ -13,7 +14,14 @@ const parseEthereumErrors = async (e, step, action, retryParams) => {
|
|
|
13
14
|
return new _lifi_sdk.SDKError(baseError, step, action);
|
|
14
15
|
};
|
|
15
16
|
const handleSpecificErrors = async (e, step, action) => {
|
|
16
|
-
if (e.name === "UserRejectedRequestError" || e.cause?.name === "UserRejectedRequestError"
|
|
17
|
+
if (e.name === "UserRejectedRequestError" || e.cause?.name === "UserRejectedRequestError") return new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.SignatureRejected, e.message, e);
|
|
18
|
+
/**
|
|
19
|
+
* The wallet has no record of an EIP-5792 bundle (5730), so the outcome is unknown: the bundle may still land.
|
|
20
|
+
* No call reaches this branch today, because `waitForBatchTransactionReceipt` handles 5730 first. A later call that reaches it gets the unknown outcome.
|
|
21
|
+
* Only the error itself matches: an error of the batched wait carries it as a cause and keeps its own code.
|
|
22
|
+
* @see https://github.com/MetaMask/core/blob/main/packages/eip-5792-middleware/src/hooks/getCallsStatus.ts
|
|
23
|
+
*/
|
|
24
|
+
if (e.name === "UnknownBundleIdError") return new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.CallBundleNotFound, e.message, e);
|
|
17
25
|
/**
|
|
18
26
|
* Safe Wallet via WalletConnect returns -32000 code when user rejects the signature
|
|
19
27
|
* {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseEthereumErrors.js","names":["ExecuteStepRetryError","SDKError","TransactionError","LiFiErrorCode","ErrorMessage","fetchTxErrorDetails","BaseError","UnknownError","AtomicReadyWalletRejectedUpgradeError"],"sources":["../../../src/errors/parseEthereumErrors.ts"],"sourcesContent":["import {\n BaseError,\n ErrorMessage,\n ExecuteStepRetryError,\n type ExecuteStepRetryParams,\n type ExecutionAction,\n fetchTxErrorDetails,\n LiFiErrorCode,\n type LiFiStep,\n SDKError,\n TransactionError,\n UnknownError,\n} from '@lifi/sdk'\nimport { AtomicReadyWalletRejectedUpgradeError } from 'viem'\n\nexport const parseEthereumErrors = async (\n e: Error,\n step?: LiFiStep,\n action?: ExecutionAction,\n retryParams?: ExecuteStepRetryParams\n): Promise<SDKError | ExecuteStepRetryError> => {\n if (\n isAtomicReadyWalletRejectedUpgradeError(e)
|
|
1
|
+
{"version":3,"file":"parseEthereumErrors.js","names":["ExecuteStepRetryError","SDKError","TransactionError","LiFiErrorCode","ErrorMessage","fetchTxErrorDetails","BaseError","UnknownError","AtomicReadyWalletRejectedUpgradeError"],"sources":["../../../src/errors/parseEthereumErrors.ts"],"sourcesContent":["import {\n BaseError,\n ErrorMessage,\n ExecuteStepRetryError,\n type ExecuteStepRetryParams,\n type ExecutionAction,\n fetchTxErrorDetails,\n LiFiErrorCode,\n type LiFiStep,\n SDKError,\n TransactionError,\n UnknownError,\n} from '@lifi/sdk'\nimport { AtomicReadyWalletRejectedUpgradeError } from 'viem'\n\nexport const parseEthereumErrors = async (\n e: Error,\n step?: LiFiStep,\n action?: ExecutionAction,\n retryParams?: ExecuteStepRetryParams\n): Promise<SDKError | ExecuteStepRetryError> => {\n // A task raised it to request a replay; it is not an error to classify.\n if (e instanceof ExecuteStepRetryError) {\n return e\n }\n\n // `executeRoute` replays a step only once, so only the first attempt asks for\n // this retry.\n if (isAtomicReadyWalletRejectedUpgradeError(e) && !retryParams) {\n return new ExecuteStepRetryError(\n 'Wallet rejected 7702 upgrade based on the EIP-5792 capabilities; retry with atomicityNotReady',\n { atomicityNotReady: true },\n e\n )\n }\n\n if (e instanceof SDKError) {\n e.step = e.step ?? step\n e.action = e.action ?? action\n return e\n }\n\n const baseError = await handleSpecificErrors(e, step, action)\n\n return new SDKError(baseError, step, action)\n}\n\nconst handleSpecificErrors = async (\n e: any,\n step?: LiFiStep,\n action?: ExecutionAction\n) => {\n if (\n e.name === 'UserRejectedRequestError' ||\n e.cause?.name === 'UserRejectedRequestError'\n ) {\n return new TransactionError(LiFiErrorCode.SignatureRejected, e.message, e)\n }\n /**\n * The wallet has no record of an EIP-5792 bundle (5730), so the outcome is unknown: the bundle may still land.\n * No call reaches this branch today, because `waitForBatchTransactionReceipt` handles 5730 first. A later call that reaches it gets the unknown outcome.\n * Only the error itself matches: an error of the batched wait carries it as a cause and keeps its own code.\n * @see https://github.com/MetaMask/core/blob/main/packages/eip-5792-middleware/src/hooks/getCallsStatus.ts\n */\n if (e.name === 'UnknownBundleIdError') {\n return new TransactionError(LiFiErrorCode.CallBundleNotFound, e.message, e)\n }\n /**\n * Safe Wallet via WalletConnect returns -32000 code when user rejects the signature\n * {\n * code: -32000,\n * message: 'User rejected transaction',\n * }\n */\n if (\n e.cause?.code === -32000 ||\n // Safe doesn't return proper code, but the error details includes 'rejected'\n (e.name === 'TransactionExecutionError' &&\n e.cause?.details?.includes('rejected'))\n ) {\n return new TransactionError(LiFiErrorCode.SignatureRejected, e.message, e)\n }\n /**\n * Some wallets reject transactions sometimes with this code because of internal and JSON-RPC errors, e.g.:\n * {\n * \"code\": -32603,\n * \"message\": \"Pop up window failed to open\",\n * \"docUrl\": \"https://docs.cloud.coinbase.com/wallet-sdk/docs/errors\"\n * }\n */\n if (e.cause?.code === -32603) {\n return new TransactionError(LiFiErrorCode.TransactionRejected, e.message, e)\n }\n\n /**\n * This error is specific to Smart Accounts and thrown when the user doesn't have enough gas to pay for the transaction.\n */\n if (\n e.name === 'InsufficientPrefundError' ||\n e.cause?.name === 'InsufficientPrefundError' ||\n e.cause?.cause?.name === 'InsufficientPrefundError'\n ) {\n return new TransactionError(LiFiErrorCode.InsufficientGas, e.message, e)\n }\n\n if (\n step &&\n action?.txHash &&\n e.code === LiFiErrorCode.TransactionFailed &&\n e.message === ErrorMessage.TransactionReverted\n ) {\n const response = await fetchTxErrorDetails(\n action.txHash,\n step.action.fromChainId\n )\n\n const errorMessage = (response as Record<string, string>)?.error_message\n\n if (errorMessage?.toLowerCase().includes('out of gas')) {\n return new TransactionError(\n LiFiErrorCode.GasLimitError,\n ErrorMessage.GasLimitLow,\n e\n )\n }\n }\n\n if (e instanceof BaseError) {\n return e\n }\n\n return new UnknownError(e.message || ErrorMessage.UnknownError, e)\n}\n\nexport const isAtomicReadyWalletRejectedUpgradeError = (e: any): boolean => {\n if (e.cause?.code === AtomicReadyWalletRejectedUpgradeError.code) {\n return true\n }\n\n const details = e.cause?.details?.toLowerCase()\n const isTransactionError =\n e.name === 'TransactionExecutionError' ||\n e.cause?.name === 'TransactionExecutionError'\n const hasRejectedUpgrade =\n details?.includes('rejected') && details?.includes('upgrade')\n const has7702ErrorCode = details?.includes('7702')\n\n return isTransactionError && (hasRejectedUpgrade || has7702ErrorCode)\n}\n"],"mappings":";;;;AAeA,MAAa,sBAAsB,OACjC,GACA,MACA,QACA,gBAC8C;CAE9C,IAAI,aAAaA,UAAAA,uBACf,OAAO;CAKT,IAAI,wCAAwC,CAAC,KAAK,CAAC,aACjD,OAAO,IAAIA,UAAAA,sBACT,iGACA,EAAE,mBAAmB,KAAK,GAC1B,CACF;CAGF,IAAI,aAAaC,UAAAA,UAAU;EACzB,EAAE,OAAO,EAAE,QAAQ;EACnB,EAAE,SAAS,EAAE,UAAU;EACvB,OAAO;CACT;CAEA,MAAM,YAAY,MAAM,qBAAqB,GAAG,MAAM,MAAM;CAE5D,OAAO,IAAIA,UAAAA,SAAS,WAAW,MAAM,MAAM;AAC7C;AAEA,MAAM,uBAAuB,OAC3B,GACA,MACA,WACG;CACH,IACE,EAAE,SAAS,8BACX,EAAE,OAAO,SAAS,4BAElB,OAAO,IAAIC,UAAAA,iBAAiBC,UAAAA,cAAc,mBAAmB,EAAE,SAAS,CAAC;;;;;;;CAQ3E,IAAI,EAAE,SAAS,wBACb,OAAO,IAAID,UAAAA,iBAAiBC,UAAAA,cAAc,oBAAoB,EAAE,SAAS,CAAC;;;;;;;;CAS5E,IACE,EAAE,OAAO,SAAS,SAEjB,EAAE,SAAS,+BACV,EAAE,OAAO,SAAS,SAAS,UAAU,GAEvC,OAAO,IAAID,UAAAA,iBAAiBC,UAAAA,cAAc,mBAAmB,EAAE,SAAS,CAAC;;;;;;;;;CAU3E,IAAI,EAAE,OAAO,SAAS,QACpB,OAAO,IAAID,UAAAA,iBAAiBC,UAAAA,cAAc,qBAAqB,EAAE,SAAS,CAAC;;;;CAM7E,IACE,EAAE,SAAS,8BACX,EAAE,OAAO,SAAS,8BAClB,EAAE,OAAO,OAAO,SAAS,4BAEzB,OAAO,IAAID,UAAAA,iBAAiBC,UAAAA,cAAc,iBAAiB,EAAE,SAAS,CAAC;CAGzE,IACE,QACA,QAAQ,UACR,EAAE,SAASA,UAAAA,cAAc,qBACzB,EAAE,YAAYC,UAAAA,aAAa,qBAOL;QAAA,OAAA,GALCC,UAAAA,oBAAAA,CACrB,OAAO,QACP,KAAK,OAAO,WACd,EAAA,EAE2D,cAAA,EAEzC,YAAY,CAAC,CAAC,SAAS,YAAY,GACnD,OAAO,IAAIH,UAAAA,iBACTC,UAAAA,cAAc,eACdC,UAAAA,aAAa,aACb,CACF;CAAA;CAIJ,IAAI,aAAaE,UAAAA,WACf,OAAO;CAGT,OAAO,IAAIC,UAAAA,aAAa,EAAE,WAAWH,UAAAA,aAAa,cAAc,CAAC;AACnE;AAEA,MAAa,2CAA2C,MAAoB;CAC1E,IAAI,EAAE,OAAO,SAASI,KAAAA,sCAAsC,MAC1D,OAAO;CAGT,MAAM,UAAU,EAAE,OAAO,SAAS,YAAY;CAC9C,MAAM,qBACJ,EAAE,SAAS,+BACX,EAAE,OAAO,SAAS;CACpB,MAAM,qBACJ,SAAS,SAAS,UAAU,KAAK,SAAS,SAAS,SAAS;CAC9D,MAAM,mBAAmB,SAAS,SAAS,MAAM;CAEjD,OAAO,uBAAuB,sBAAsB;AACtD"}
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -17,6 +17,12 @@ export interface EthereumTaskContext {
|
|
|
17
17
|
hasMatchingPermit?: boolean;
|
|
18
18
|
hasAllowance?: boolean;
|
|
19
19
|
hasSufficientAllowance?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The spender `EthereumCheckAllowanceTask` checked the allowance against. The
|
|
22
|
+
* other allowance tasks approve the same one. Prepare compares it with the
|
|
23
|
+
* spender of the strategy it establishes.
|
|
24
|
+
*/
|
|
25
|
+
allowanceSpender?: Address;
|
|
20
26
|
/**
|
|
21
27
|
* Whether the signer can produce a Permit2-verifiable signature — the
|
|
22
28
|
* in-flight or settled lookup, memoized per execution by
|
package/dist/cjs/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["ChainType"],"sources":["../../src/types.ts"],"sourcesContent":["import {\n type BaseToken,\n ChainType,\n type LiFiStep,\n type LiFiStepExtended,\n type SDKClient,\n type SDKProvider,\n type SDKStorage,\n type SignedTypedData,\n type StepExecutorContext,\n type TransactionMethodType,\n type TransactionParameters,\n} from '@lifi/sdk'\nimport type {\n WalletCallReceipt as _WalletCallReceipt,\n Address,\n Client,\n FallbackTransportConfig,\n Hex,\n} from 'viem'\n\nexport interface EthereumProviderOptions {\n getWalletClient?: () => Promise<Client>\n switchChain?: (chainId: number) => Promise<Client | undefined>\n fallbackTransportConfig?: FallbackTransportConfig\n safeApiKey?: string\n disableMessageSigning?: boolean\n}\n\nexport interface EthereumTaskContext {\n disableMessageSigning: boolean\n transactionRequest?: TransactionParameters\n executionStrategy?: TransactionMethodType\n calls: Call[]\n signedTypedData: SignedTypedData[]\n hasMatchingPermit?: boolean\n hasAllowance?: boolean\n hasSufficientAllowance?: boolean\n /**\n * Whether the signer can produce a Permit2-verifiable signature — the\n * in-flight or settled lookup, memoized per execution by\n * `resolvePermit2Support` so the allowance tasks and the sign-and-execute task\n * can't disagree. Deliberately the promise and not a `boolean`: that would\n * be a tri-state (unresolved / yes / no) whose `false` case is\n * indistinguishable from \"not looked up yet\" under a truthiness check.\n */\n permit2SignerSupported?: Promise<boolean>\n}\n\nexport interface EthereumStepExecutorContext\n extends StepExecutorContext,\n EthereumTaskContext {\n isFromNativeToken: boolean\n ethereumClient: Client\n checkClient: (\n step: LiFiStepExtended,\n targetChainId?: number\n ) => Promise<Client | undefined>\n switchChain?: (chainId: number) => Promise<Client | undefined>\n getStorage: (client: SDKClient) => SDKStorage\n /** Params passed when retrying executeStep (e.g. atomicityNotReady for 7702). */\n retryParams?: Record<string, unknown>\n}\n\nexport interface EthereumSDKProvider extends SDKProvider {\n options: EthereumProviderOptions\n setOptions(options: EthereumProviderOptions): void\n getWalletClient?(): Promise<Client>\n}\n\nexport function isEthereumProvider(\n provider: SDKProvider\n): provider is EthereumSDKProvider {\n return provider.type === ChainType.EVM\n}\n\nexport type TokenSpender = {\n token: BaseToken\n spenderAddress: string\n}\n\nexport type TokenAllowance = {\n token: BaseToken\n allowance?: bigint\n}\n\nexport type TokenSpenderAllowance = {\n token: BaseToken\n spenderAddress: string\n allowance?: bigint\n}\n\nexport interface ApproveTokenRequest {\n walletClient: Client\n token: BaseToken\n spenderAddress: string\n amount: bigint\n}\n\nexport interface RevokeApprovalRequest {\n walletClient: Client\n token: BaseToken\n spenderAddress: string\n}\n\nexport type Call = {\n to: Address\n data?: Hex\n value?: bigint\n chainId?: number\n}\n\nexport type WalletCallReceipt = _WalletCallReceipt<\n bigint,\n 'success' | 'reverted'\n> & {\n transactionLink?: string\n}\n\nexport type RelayerStep = (LiFiStepExtended | LiFiStep) & {\n typedData: NonNullable<(LiFiStepExtended | LiFiStep)['typedData']>\n}\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","names":["ChainType"],"sources":["../../src/types.ts"],"sourcesContent":["import {\n type BaseToken,\n ChainType,\n type LiFiStep,\n type LiFiStepExtended,\n type SDKClient,\n type SDKProvider,\n type SDKStorage,\n type SignedTypedData,\n type StepExecutorContext,\n type TransactionMethodType,\n type TransactionParameters,\n} from '@lifi/sdk'\nimport type {\n WalletCallReceipt as _WalletCallReceipt,\n Address,\n Client,\n FallbackTransportConfig,\n Hex,\n} from 'viem'\n\nexport interface EthereumProviderOptions {\n getWalletClient?: () => Promise<Client>\n switchChain?: (chainId: number) => Promise<Client | undefined>\n fallbackTransportConfig?: FallbackTransportConfig\n safeApiKey?: string\n disableMessageSigning?: boolean\n}\n\nexport interface EthereumTaskContext {\n disableMessageSigning: boolean\n transactionRequest?: TransactionParameters\n executionStrategy?: TransactionMethodType\n calls: Call[]\n signedTypedData: SignedTypedData[]\n hasMatchingPermit?: boolean\n hasAllowance?: boolean\n hasSufficientAllowance?: boolean\n /**\n * The spender `EthereumCheckAllowanceTask` checked the allowance against. The\n * other allowance tasks approve the same one. Prepare compares it with the\n * spender of the strategy it establishes.\n */\n allowanceSpender?: Address\n /**\n * Whether the signer can produce a Permit2-verifiable signature — the\n * in-flight or settled lookup, memoized per execution by\n * `resolvePermit2Support` so the allowance tasks and the sign-and-execute task\n * can't disagree. Deliberately the promise and not a `boolean`: that would\n * be a tri-state (unresolved / yes / no) whose `false` case is\n * indistinguishable from \"not looked up yet\" under a truthiness check.\n */\n permit2SignerSupported?: Promise<boolean>\n}\n\nexport interface EthereumStepExecutorContext\n extends StepExecutorContext,\n EthereumTaskContext {\n isFromNativeToken: boolean\n ethereumClient: Client\n checkClient: (\n step: LiFiStepExtended,\n targetChainId?: number\n ) => Promise<Client | undefined>\n switchChain?: (chainId: number) => Promise<Client | undefined>\n getStorage: (client: SDKClient) => SDKStorage\n /** Params passed when retrying executeStep (e.g. atomicityNotReady for 7702). */\n retryParams?: Record<string, unknown>\n}\n\nexport interface EthereumSDKProvider extends SDKProvider {\n options: EthereumProviderOptions\n setOptions(options: EthereumProviderOptions): void\n getWalletClient?(): Promise<Client>\n}\n\nexport function isEthereumProvider(\n provider: SDKProvider\n): provider is EthereumSDKProvider {\n return provider.type === ChainType.EVM\n}\n\nexport type TokenSpender = {\n token: BaseToken\n spenderAddress: string\n}\n\nexport type TokenAllowance = {\n token: BaseToken\n allowance?: bigint\n}\n\nexport type TokenSpenderAllowance = {\n token: BaseToken\n spenderAddress: string\n allowance?: bigint\n}\n\nexport interface ApproveTokenRequest {\n walletClient: Client\n token: BaseToken\n spenderAddress: string\n amount: bigint\n}\n\nexport interface RevokeApprovalRequest {\n walletClient: Client\n token: BaseToken\n spenderAddress: string\n}\n\nexport type Call = {\n to: Address\n data?: Hex\n value?: bigint\n chainId?: number\n}\n\nexport type WalletCallReceipt = _WalletCallReceipt<\n bigint,\n 'success' | 'reverted'\n> & {\n transactionLink?: string\n}\n\nexport type RelayerStep = (LiFiStepExtended | LiFiStep) & {\n typedData: NonNullable<(LiFiStepExtended | LiFiStep)['typedData']>\n}\n"],"mappings":";;;AA4EA,SAAgB,mBACd,UACiC;CACjC,OAAO,SAAS,SAASA,UAAAA,UAAU;AACrC"}
|
package/dist/cjs/version.d.ts
CHANGED
package/dist/cjs/version.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/version.ts
|
|
3
3
|
const name = "@lifi/sdk-provider-ethereum";
|
|
4
|
-
const version = "4.2.
|
|
4
|
+
const version = "4.2.8";
|
|
5
5
|
//#endregion
|
|
6
6
|
exports.name = name;
|
|
7
7
|
exports.version = version;
|
package/dist/cjs/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-ethereum'\nexport const version = '4.2.
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-ethereum'\nexport const version = '4.2.8'\n"],"mappings":";;AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumProvider.d.ts","names":[],"sources":["../../src/EthereumProvider.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"EthereumProvider.d.ts","names":[],"sources":["../../src/EthereumProvider.ts"],"mappings":";;wBAiBgB,iBACd,UAAU,0BACT"}
|
|
@@ -8,6 +8,10 @@ import { isAddress } from "viem";
|
|
|
8
8
|
function isEthereumTokenAddress(address) {
|
|
9
9
|
return isAddress(address, { strict: false });
|
|
10
10
|
}
|
|
11
|
+
/** viem reads a second argument as options, so a chain ID must not reach it. */
|
|
12
|
+
function isEthereumAddress(address) {
|
|
13
|
+
return isAddress(address);
|
|
14
|
+
}
|
|
11
15
|
function EthereumProvider(options) {
|
|
12
16
|
const _options = options ?? {};
|
|
13
17
|
return {
|
|
@@ -17,7 +21,7 @@ function EthereumProvider(options) {
|
|
|
17
21
|
get options() {
|
|
18
22
|
return _options;
|
|
19
23
|
},
|
|
20
|
-
isAddress,
|
|
24
|
+
isAddress: isEthereumAddress,
|
|
21
25
|
isTokenAddress: isEthereumTokenAddress,
|
|
22
26
|
resolveAddress: resolveEthereumAddress,
|
|
23
27
|
getBalance: getEthereumBalance,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumProvider.js","names":[],"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,OAAO,UAAU,SAAS,EAAE,QAAQ,MAAM,CAAC;AAC7C;AAEA,SAAgB,iBACd,SACqB;CACrB,MAAM,WAAoC,WAAW,CAAC;CACtD,OAAO;EACL,IAAI,OAAO;GACT,OAAO,UAAU;EACnB;EACA,IAAI,UAAU;GACZ,OAAO;EACT;EACA;
|
|
1
|
+
{"version":3,"file":"EthereumProvider.js","names":[],"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,OAAO,UAAU,SAAS,EAAE,QAAQ,MAAM,CAAC;AAC7C;;AAGA,SAAS,kBAAkB,SAA0B;CACnD,OAAO,UAAU,OAAO;AAC1B;AAEA,SAAgB,iBACd,SACqB;CACrB,MAAM,WAAoC,WAAW,CAAC;CACtD,OAAO;EACL,IAAI,OAAO;GACT,OAAO,UAAU;EACnB;EACA,IAAI,UAAU;GACZ,OAAO;EACT;EACA,WAAW;EACX,gBAAgB;EAChB,gBAAgB;EAChB,YAAY;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,IAVc,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waitForBatchTransactionReceipt.d.ts","names":["WalletCallReceipt"],"sources":["../../../src/actions/waitForBatchTransactionReceipt.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"waitForBatchTransactionReceipt.d.ts","names":["WalletCallReceipt"],"sources":["../../../src/actions/waitForBatchTransactionReceipt.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;qBA+Ca,iCACX,QAAQ,QACR,WAAW,QAET,UACA,UACA;EAEA,YAAY,QAAQ;EACpB;EACA;MAED,QAAQA"}
|
|
@@ -1,14 +1,61 @@
|
|
|
1
1
|
import { LiFiErrorCode, TransactionError } from "@lifi/sdk";
|
|
2
|
+
import { UnknownBundleIdError } from "viem";
|
|
2
3
|
import { waitForCallsStatus } from "viem/actions";
|
|
3
4
|
import { getAction } from "viem/utils";
|
|
4
5
|
//#region src/actions/waitForBatchTransactionReceipt.ts
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const DROPPED_BUNDLE_MAX_AGE_MS = 6e5;
|
|
7
|
+
const isUnknownBundleIdError = (error) => error?.name === "UnknownBundleIdError" || error?.cause?.name === "UnknownBundleIdError" || error?.code === UnknownBundleIdError.code;
|
|
8
|
+
/**
|
|
9
|
+
* Unknown signing time is never in the window. Nor is a signing time in the
|
|
10
|
+
* future, as in `isResendAllowed`.
|
|
11
|
+
*/
|
|
12
|
+
const isWithinDropWindow = (signedAt) => {
|
|
13
|
+
const now = Date.now();
|
|
14
|
+
return signedAt !== void 0 && now >= signedAt && now - signedAt < DROPPED_BUNDLE_MAX_AGE_MS;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Waits until the wallet reports the EIP-5792 call bundle as done or failed.
|
|
18
|
+
*
|
|
19
|
+
* MetaMask returns the id of a single-call bundle before the user approves
|
|
20
|
+
* it, and removes the bundle on a reject: `wallet_getCallsStatus` then fails
|
|
21
|
+
* with 5730 (`UnknownBundleIdError`). It returns the id of a bundle of two or
|
|
22
|
+
* more calls only after it sent the bundle. Thus the SDK treats a bundle as
|
|
23
|
+
* never sent only when all of these are true: its stored `callCount` is 1,
|
|
24
|
+
* the wallet answered for it in this wait and then has no record of it, and
|
|
25
|
+
* this happens within `DROPPED_BUNDLE_MAX_AGE_MS` of signing.
|
|
26
|
+
*
|
|
27
|
+
* @param client - The wallet client that sent the bundle.
|
|
28
|
+
* @param batchHash - The bundle id that `wallet_sendCalls` returned.
|
|
29
|
+
* @param options.onFailed - Gets the wallet's answer for a failed bundle, before the error is thrown.
|
|
30
|
+
* @param options.signedAt - The signing time of the step (`execution.signedAt`).
|
|
31
|
+
* @param options.callCount - The stored number of calls of the bundle (`action.callCount`).
|
|
32
|
+
* @returns The receipt of the last call of the bundle.
|
|
33
|
+
* @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.
|
|
34
|
+
* @throws Any other error of the wallet, unchanged.
|
|
35
|
+
*/
|
|
36
|
+
const waitForBatchTransactionReceipt = async (client, batchHash, { onFailed, signedAt, callCount } = {}) => {
|
|
37
|
+
let known = false;
|
|
38
|
+
let result;
|
|
39
|
+
try {
|
|
40
|
+
result = await getAction(client, waitForCallsStatus, "waitForCallsStatus")({
|
|
41
|
+
id: batchHash,
|
|
42
|
+
timeout: 864e5,
|
|
43
|
+
status: ({ statusCode }) => {
|
|
44
|
+
known = true;
|
|
45
|
+
return statusCode === 200 || statusCode >= 300;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
} catch (error) {
|
|
49
|
+
if (!isUnknownBundleIdError(error)) throw error;
|
|
50
|
+
if (known && callCount === 1 && isWithinDropWindow(signedAt)) throw new TransactionError(LiFiErrorCode.SignatureRejected, "The wallet has no record of the call bundle. The SDK treats it as never sent.", error, { final: true });
|
|
51
|
+
throw new TransactionError(LiFiErrorCode.CallBundleNotFound, "The wallet has no record of the call bundle.", error);
|
|
52
|
+
}
|
|
10
53
|
if (result.status === "success") {
|
|
11
|
-
if (
|
|
54
|
+
if (result.receipts?.some((receipt) => receipt.status === "reverted")) {
|
|
55
|
+
onFailed?.(result);
|
|
56
|
+
throw new TransactionError(LiFiErrorCode.TransactionFailed, "Transaction was reverted.", void 0, { final: true });
|
|
57
|
+
}
|
|
58
|
+
if (!result.receipts?.length || !result.receipts.every((receipt) => receipt.transactionHash)) {
|
|
12
59
|
onFailed?.(result);
|
|
13
60
|
throw new TransactionError(LiFiErrorCode.TransactionFailed, "Transaction was reverted.");
|
|
14
61
|
}
|
|
@@ -16,9 +63,10 @@ const waitForBatchTransactionReceipt = async (client, batchHash, onFailed) => {
|
|
|
16
63
|
}
|
|
17
64
|
if (result.statusCode >= 400 && result.statusCode < 500) {
|
|
18
65
|
onFailed?.(result);
|
|
19
|
-
throw new TransactionError(LiFiErrorCode.TransactionCanceled, "Transaction was canceled.");
|
|
66
|
+
throw new TransactionError(LiFiErrorCode.TransactionCanceled, "Transaction was canceled.", void 0, { final: true });
|
|
20
67
|
}
|
|
21
68
|
onFailed?.(result);
|
|
69
|
+
if (result.statusCode === 500) throw new TransactionError(LiFiErrorCode.TransactionFailed, "Transaction failed.", void 0, { final: true });
|
|
22
70
|
throw new TransactionError(LiFiErrorCode.TransactionFailed, "Transaction failed.");
|
|
23
71
|
};
|
|
24
72
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waitForBatchTransactionReceipt.js","names":[],"sources":["../../../src/actions/waitForBatchTransactionReceipt.ts"],"sourcesContent":["import { LiFiErrorCode, TransactionError } from '@lifi/sdk'\nimport type
|
|
1
|
+
{"version":3,"file":"waitForBatchTransactionReceipt.js","names":[],"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,SAAS,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,MAAM,UACb,QACA,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,IAAI,iBACR,cAAc,mBACd,iFACA,OACA,EAAE,OAAO,KAAK,CAChB;EAMF,MAAM,IAAI,iBACR,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,IAAI,iBACR,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,IAAI,iBACR,cAAc,mBACd,2BACF;EACF;EAEA,OAD2B,OAAO,SAAS,GAAG,EACtB;CAC1B;CACA,IAAI,OAAO,cAAc,OAAO,OAAO,aAAa,KAAK;EACvD,WAAW,MAAM;EACjB,MAAM,IAAI,iBACR,cAAc,qBACd,6BACA,KAAA,GACA,EAAE,OAAO,KAAK,CAChB;CACF;CACA,WAAW,MAAM;CAGjB,IAAI,OAAO,eAAe,KACxB,MAAM,IAAI,iBACR,cAAc,mBACd,uBACA,KAAA,GACA,EAAE,OAAO,KAAK,CAChB;CAEF,MAAM,IAAI,iBACR,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waitForRelayedTransactionReceipt.d.ts","names":["WalletCallReceipt"],"sources":["../../../src/actions/waitForRelayedTransactionReceipt.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"waitForRelayedTransactionReceipt.d.ts","names":["WalletCallReceipt"],"sources":["../../../src/actions/waitForRelayedTransactionReceipt.ts"],"mappings":";;;;;;;;;;;;;;;;qBAyBa,mCACX,QAAQ,WACR,QAAQ,MACR,MAAM,UACN,kBACA,SAAS,gBACR,QAAQA"}
|