@lifi/sdk 3.5.0-beta.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -7
- package/src/_cjs/constants.js +2 -4
- package/src/_cjs/constants.js.map +1 -1
- package/src/_cjs/core/EVM/EVM.js +4 -0
- package/src/_cjs/core/EVM/EVM.js.map +1 -1
- package/src/_cjs/core/EVM/EVMStepExecutor.js +77 -98
- package/src/_cjs/core/EVM/EVMStepExecutor.js.map +1 -1
- package/src/_cjs/core/EVM/abi.js +43 -36
- package/src/_cjs/core/EVM/abi.js.map +1 -1
- package/src/_cjs/core/EVM/checkAllowance.js +30 -36
- package/src/_cjs/core/EVM/checkAllowance.js.map +1 -1
- package/src/_cjs/core/EVM/getAllowance.js.map +1 -1
- package/src/_cjs/core/EVM/getEVMBalance.js.map +1 -1
- package/src/_cjs/core/EVM/multisig.js +29 -0
- package/src/_cjs/core/EVM/multisig.js.map +1 -0
- package/src/_cjs/core/EVM/parseEVMErrors.js +0 -3
- package/src/_cjs/core/EVM/parseEVMErrors.js.map +1 -1
- package/src/_cjs/core/EVM/setAllowance.js +6 -4
- package/src/_cjs/core/EVM/setAllowance.js.map +1 -1
- package/src/_cjs/core/EVM/switchChain.js +3 -2
- package/src/_cjs/core/EVM/switchChain.js.map +1 -1
- package/src/_cjs/core/EVM/types.js.map +1 -1
- package/src/_cjs/core/EVM/utils.js +1 -2
- package/src/_cjs/core/EVM/utils.js.map +1 -1
- package/src/_cjs/core/checkBalance.js +3 -3
- package/src/_cjs/core/checkBalance.js.map +1 -1
- package/src/_cjs/index.js.map +1 -1
- package/src/_cjs/version.js +1 -1
- package/src/_cjs/version.js.map +1 -1
- package/src/_esm/constants.js +1 -3
- package/src/_esm/constants.js.map +1 -1
- package/src/_esm/core/EVM/EVM.js +4 -0
- package/src/_esm/core/EVM/EVM.js.map +1 -1
- package/src/_esm/core/EVM/EVMStepExecutor.js +87 -126
- package/src/_esm/core/EVM/EVMStepExecutor.js.map +1 -1
- package/src/_esm/core/EVM/abi.js +42 -37
- package/src/_esm/core/EVM/abi.js.map +1 -1
- package/src/_esm/core/EVM/checkAllowance.js +32 -41
- package/src/_esm/core/EVM/checkAllowance.js.map +1 -1
- package/src/_esm/core/EVM/getAllowance.js.map +1 -1
- package/src/_esm/core/EVM/getEVMBalance.js.map +1 -1
- package/src/_esm/core/EVM/multisig.js +25 -0
- package/src/_esm/core/EVM/multisig.js.map +1 -0
- package/src/_esm/core/EVM/parseEVMErrors.js +0 -8
- package/src/_esm/core/EVM/parseEVMErrors.js.map +1 -1
- package/src/_esm/core/EVM/setAllowance.js +6 -4
- package/src/_esm/core/EVM/setAllowance.js.map +1 -1
- package/src/_esm/core/EVM/switchChain.js +3 -2
- package/src/_esm/core/EVM/switchChain.js.map +1 -1
- package/src/_esm/core/EVM/types.js.map +1 -1
- package/src/_esm/core/EVM/utils.js +1 -2
- package/src/_esm/core/EVM/utils.js.map +1 -1
- package/src/_esm/core/checkBalance.js +3 -3
- package/src/_esm/core/checkBalance.js.map +1 -1
- package/src/_esm/index.js.map +1 -1
- package/src/_esm/version.js +1 -1
- package/src/_esm/version.js.map +1 -1
- package/src/_types/constants.d.ts +1 -3
- package/src/_types/constants.d.ts.map +1 -1
- package/src/_types/core/EVM/EVM.d.ts.map +1 -1
- package/src/_types/core/EVM/EVMStepExecutor.d.ts +4 -7
- package/src/_types/core/EVM/EVMStepExecutor.d.ts.map +1 -1
- package/src/_types/core/EVM/abi.d.ts +5 -202
- package/src/_types/core/EVM/abi.d.ts.map +1 -1
- package/src/_types/core/EVM/checkAllowance.d.ts +2 -12
- package/src/_types/core/EVM/checkAllowance.d.ts.map +1 -1
- package/src/_types/core/EVM/getAllowance.d.ts +4 -5
- package/src/_types/core/EVM/getAllowance.d.ts.map +1 -1
- package/src/_types/core/EVM/getEVMBalance.d.ts +1 -2
- package/src/_types/core/EVM/getEVMBalance.d.ts.map +1 -1
- package/src/_types/core/EVM/multisig.d.ts +6 -0
- package/src/_types/core/EVM/multisig.d.ts.map +1 -0
- package/src/_types/core/EVM/setAllowance.d.ts +2 -2
- package/src/_types/core/EVM/setAllowance.d.ts.map +1 -1
- package/src/_types/core/EVM/switchChain.d.ts.map +1 -1
- package/src/_types/core/EVM/types.d.ts +18 -1
- package/src/_types/core/EVM/types.d.ts.map +1 -1
- package/src/_types/core/EVM/utils.d.ts +2 -2
- package/src/_types/core/EVM/utils.d.ts.map +1 -1
- package/src/_types/core/checkBalance.d.ts.map +1 -1
- package/src/_types/index.d.ts +1 -1
- package/src/_types/index.d.ts.map +1 -1
- package/src/_types/version.d.ts +1 -1
- package/src/_types/version.d.ts.map +1 -1
- package/src/constants.ts +1 -6
- package/src/core/EVM/EVM.ts +4 -0
- package/src/core/EVM/EVMStepExecutor.ts +145 -174
- package/src/core/EVM/abi.ts +43 -40
- package/src/core/EVM/checkAllowance.ts +92 -96
- package/src/core/EVM/getAllowance.ts +8 -8
- package/src/core/EVM/getEVMBalance.ts +2 -2
- package/src/core/EVM/multisig.ts +54 -0
- package/src/core/EVM/parseEVMErrors.ts +0 -8
- package/src/core/EVM/setAllowance.ts +21 -15
- package/src/core/EVM/switchChain.ts +12 -3
- package/src/core/EVM/types.ts +27 -1
- package/src/core/EVM/utils.ts +3 -4
- package/src/core/checkBalance.ts +3 -6
- package/src/index.ts +3 -0
- package/src/version.ts +1 -1
- package/src/_cjs/core/EVM/getNativePermit.js +0 -90
- package/src/_cjs/core/EVM/getNativePermit.js.map +0 -1
- package/src/_cjs/core/EVM/permit2/allowanceTransfer.js +0 -100
- package/src/_cjs/core/EVM/permit2/allowanceTransfer.js.map +0 -1
- package/src/_cjs/core/EVM/permit2/constants.js +0 -12
- package/src/_cjs/core/EVM/permit2/constants.js.map +0 -1
- package/src/_cjs/core/EVM/permit2/domain.js +0 -12
- package/src/_cjs/core/EVM/permit2/domain.js.map +0 -1
- package/src/_cjs/core/EVM/permit2/signatureTransfer.js +0 -121
- package/src/_cjs/core/EVM/permit2/signatureTransfer.js.map +0 -1
- package/src/_cjs/core/EVM/signPermitMessage.js +0 -168
- package/src/_cjs/core/EVM/signPermitMessage.js.map +0 -1
- package/src/_cjs/core/EVM/waitForBatchTransactionReceipt.js +0 -29
- package/src/_cjs/core/EVM/waitForBatchTransactionReceipt.js.map +0 -1
- package/src/_cjs/utils/invariant.js +0 -17
- package/src/_cjs/utils/invariant.js.map +0 -1
- package/src/_esm/core/EVM/getNativePermit.js +0 -95
- package/src/_esm/core/EVM/getNativePermit.js.map +0 -1
- package/src/_esm/core/EVM/permit2/allowanceTransfer.js +0 -93
- package/src/_esm/core/EVM/permit2/allowanceTransfer.js.map +0 -1
- package/src/_esm/core/EVM/permit2/constants.js +0 -9
- package/src/_esm/core/EVM/permit2/constants.js.map +0 -1
- package/src/_esm/core/EVM/permit2/domain.js +0 -9
- package/src/_esm/core/EVM/permit2/domain.js.map +0 -1
- package/src/_esm/core/EVM/permit2/signatureTransfer.js +0 -117
- package/src/_esm/core/EVM/permit2/signatureTransfer.js.map +0 -1
- package/src/_esm/core/EVM/signPermitMessage.js +0 -162
- package/src/_esm/core/EVM/signPermitMessage.js.map +0 -1
- package/src/_esm/core/EVM/waitForBatchTransactionReceipt.js +0 -25
- package/src/_esm/core/EVM/waitForBatchTransactionReceipt.js.map +0 -1
- package/src/_esm/utils/invariant.js +0 -43
- package/src/_esm/utils/invariant.js.map +0 -1
- package/src/_types/core/EVM/getNativePermit.d.ts +0 -18
- package/src/_types/core/EVM/getNativePermit.d.ts.map +0 -1
- package/src/_types/core/EVM/permit2/allowanceTransfer.d.ts +0 -41
- package/src/_types/core/EVM/permit2/allowanceTransfer.d.ts.map +0 -1
- package/src/_types/core/EVM/permit2/constants.d.ts +0 -8
- package/src/_types/core/EVM/permit2/constants.d.ts.map +0 -1
- package/src/_types/core/EVM/permit2/domain.d.ts +0 -8
- package/src/_types/core/EVM/permit2/domain.d.ts.map +0 -1
- package/src/_types/core/EVM/permit2/signatureTransfer.d.ts +0 -42
- package/src/_types/core/EVM/permit2/signatureTransfer.d.ts.map +0 -1
- package/src/_types/core/EVM/signPermitMessage.d.ts +0 -22
- package/src/_types/core/EVM/signPermitMessage.d.ts.map +0 -1
- package/src/_types/core/EVM/waitForBatchTransactionReceipt.d.ts +0 -4
- package/src/_types/core/EVM/waitForBatchTransactionReceipt.d.ts.map +0 -1
- package/src/_types/utils/invariant.d.ts +0 -22
- package/src/_types/utils/invariant.d.ts.map +0 -1
- package/src/core/EVM/getNativePermit.ts +0 -113
- package/src/core/EVM/permit2/allowanceTransfer.ts +0 -168
- package/src/core/EVM/permit2/constants.ts +0 -11
- package/src/core/EVM/permit2/domain.ts +0 -20
- package/src/core/EVM/permit2/signatureTransfer.ts +0 -214
- package/src/core/EVM/signPermitMessage.ts +0 -248
- package/src/core/EVM/waitForBatchTransactionReceipt.ts +0 -49
- package/src/utils/invariant.ts +0 -51
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Client, Hash } from 'viem';
|
|
2
2
|
import type { ExecutionOptions } from '../types.js';
|
|
3
3
|
import type { ApproveTokenRequest, RevokeApprovalRequest } from './types.js';
|
|
4
|
-
export declare const setAllowance: (client: Client, tokenAddress:
|
|
4
|
+
export declare const setAllowance: (client: Client, tokenAddress: string, contractAddress: string, amount: bigint, settings?: ExecutionOptions, returnPopulatedTransaction?: boolean) => Promise<Hash>;
|
|
5
5
|
/**
|
|
6
6
|
* Set approval for a certain token and amount.
|
|
7
7
|
* @param request - The approval request
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setAllowance.d.ts","sourceRoot":"","sources":["../../../core/EVM/setAllowance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"setAllowance.d.ts","sourceRoot":"","sources":["../../../core/EVM/setAllowance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAA6B,MAAM,MAAM,CAAA;AAKnE,OAAO,KAAK,EAAE,gBAAgB,EAAyB,MAAM,aAAa,CAAA;AAG1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAG5E,eAAO,MAAM,YAAY,WACf,MAAM,gBACA,MAAM,mBACH,MAAM,UACf,MAAM,aACH,gBAAgB,+BACE,OAAO,KACnC,OAAO,CAAC,IAAI,CA+Cd,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,qDAK3B,mBAAmB,KAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAsB3C,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,6CAI7B,qBAAqB,KAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAqB7C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switchChain.d.ts","sourceRoot":"","sources":["../../../core/EVM/switchChain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"switchChain.d.ts","sourceRoot":"","sources":["../../../core/EVM/switchChain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAwB,MAAM,MAAM,CAAA;AAKxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAEpE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,WAAW,WACd,MAAM,iBACC,aAAa,QACtB,gBAAgB,wBACA,OAAO,oBACX,eAAe,KAChC,OAAO,CAAC,MAAM,GAAG,SAAS,CA2D5B,CAAA"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { type BaseToken } from '@lifi/types';
|
|
2
|
-
import type { Client } from 'viem';
|
|
2
|
+
import type { Client, Hash } from 'viem';
|
|
3
3
|
import type { SwitchChainHook } from '../types.js';
|
|
4
4
|
import type { SDKProvider } from '../types.js';
|
|
5
5
|
export interface EVMProviderOptions {
|
|
6
6
|
getWalletClient?: () => Promise<Client>;
|
|
7
7
|
switchChain?: SwitchChainHook;
|
|
8
|
+
multisig?: MultisigConfig;
|
|
8
9
|
}
|
|
9
10
|
export interface EVMProvider extends SDKProvider {
|
|
10
11
|
setOptions(options: EVMProviderOptions): void;
|
|
12
|
+
multisig?: MultisigConfig;
|
|
11
13
|
}
|
|
12
14
|
export declare function isEVM(provider: SDKProvider): provider is EVMProvider;
|
|
13
15
|
export type TokenSpender = {
|
|
@@ -38,4 +40,19 @@ export interface RevokeApprovalRequest {
|
|
|
38
40
|
token: BaseToken;
|
|
39
41
|
spenderAddress: string;
|
|
40
42
|
}
|
|
43
|
+
export interface MultisigTxDetails {
|
|
44
|
+
status: 'DONE' | 'FAILED' | 'PENDING' | 'CANCELLED';
|
|
45
|
+
txHash?: Hash;
|
|
46
|
+
}
|
|
47
|
+
export interface MultisigTransaction {
|
|
48
|
+
to: string;
|
|
49
|
+
value?: bigint;
|
|
50
|
+
data: string;
|
|
51
|
+
}
|
|
52
|
+
export interface MultisigConfig {
|
|
53
|
+
isMultisigWalletClient: boolean;
|
|
54
|
+
getMultisigTransactionDetails: (txHash: Hash, fromChainId: number, updateIntermediateStatus?: () => void) => Promise<MultisigTxDetails>;
|
|
55
|
+
sendBatchTransaction?: (batchTransactions: MultisigTransaction[]) => Promise<Hash>;
|
|
56
|
+
shouldBatchTransactions?: boolean;
|
|
57
|
+
}
|
|
41
58
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../core/EVM/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,aAAa,CAAA;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../core/EVM/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,aAAa,CAAA;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C,MAAM,WAAW,kBAAkB;IACjC,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;IACvC,WAAW,CAAC,EAAE,eAAe,CAAA;IAC7B,QAAQ,CAAC,EAAE,cAAc,CAAA;CAC1B;AAED,MAAM,WAAW,WAAY,SAAQ,WAAW;IAC9C,UAAU,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAAA;IAC7C,QAAQ,CAAC,EAAE,cAAc,CAAA;CAC1B;AAED,wBAAgB,KAAK,CAAC,QAAQ,EAAE,WAAW,GAAG,QAAQ,IAAI,WAAW,CAEpE;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,SAAS,CAAA;IAChB,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,SAAS,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,SAAS,CAAA;IAChB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,SAAS,CAAA;IAChB,cAAc,EAAE,MAAM,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,SAAS,CAAA;IAChB,cAAc,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAA;IACnD,MAAM,CAAC,EAAE,IAAI,CAAA;CACd;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,cAAc;IAC7B,sBAAsB,EAAE,OAAO,CAAA;IAC/B,6BAA6B,EAAE,CAC7B,MAAM,EAAE,IAAI,EACZ,WAAW,EAAE,MAAM,EACnB,wBAAwB,CAAC,EAAE,MAAM,IAAI,KAClC,OAAO,CAAC,iBAAiB,CAAC,CAAA;IAC/B,oBAAoB,CAAC,EAAE,CACrB,iBAAiB,EAAE,mBAAmB,EAAE,KACrC,OAAO,CAAC,IAAI,CAAC,CAAA;IAClB,uBAAuB,CAAC,EAAE,OAAO,CAAA;CAClC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ChainId } from '@lifi/types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Client } from 'viem';
|
|
3
3
|
export declare const getMaxPriorityFeePerGas: (client: Client) => Promise<bigint | undefined>;
|
|
4
|
-
export declare const getMulticallAddress: (chainId: ChainId) => Promise<
|
|
4
|
+
export declare const getMulticallAddress: (chainId: ChainId) => Promise<string | undefined>;
|
|
5
5
|
export declare const retryDelay: ({ count }: {
|
|
6
6
|
count: number;
|
|
7
7
|
error: Error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../core/EVM/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../core/EVM/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,MAAM,CAAA;AAK/C,eAAO,MAAM,uBAAuB,WAC1B,MAAM,KACb,OAAO,CAAC,MAAM,GAAG,SAAS,CA0B5B,CAAA;AAGD,eAAO,MAAM,mBAAmB,YACrB,OAAO,KACf,OAAO,CAAC,MAAM,GAAG,SAAS,CAG5B,CAAA;AAGD,eAAO,MAAM,UAAU,cAAe;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,WAC/B,CAAA;AAEtC,eAAO,MAAM,UAAU,KAAK,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkBalance.d.ts","sourceRoot":"","sources":["../../core/checkBalance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAM3C,eAAO,MAAM,YAAY,kBACR,MAAM,QACf,QAAQ,qBAEb,OAAO,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"checkBalance.d.ts","sourceRoot":"","sources":["../../core/checkBalance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAM3C,eAAO,MAAM,YAAY,kBACR,MAAM,QACf,QAAQ,qBAEb,OAAO,CAAC,IAAI,CA8Bd,CAAA"}
|
package/src/_types/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { EVM } from './core/EVM/EVM.js';
|
|
|
4
4
|
export { getTokenAllowance, getTokenAllowanceMulticall, } from './core/EVM/getAllowance.js';
|
|
5
5
|
export { revokeTokenApproval, setTokenAllowance, } from './core/EVM/setAllowance.js';
|
|
6
6
|
export { isEVM } from './core/EVM/types.js';
|
|
7
|
-
export type { EVMProvider, EVMProviderOptions, } from './core/EVM/types.js';
|
|
7
|
+
export type { EVMProvider, EVMProviderOptions, MultisigConfig, MultisigTransaction, MultisigTxDetails, } from './core/EVM/types.js';
|
|
8
8
|
export { StatusManager } from './core/StatusManager.js';
|
|
9
9
|
export { executeRoute, getActiveRoute, getActiveRoutes, resumeRoute, stopRouteExecution, updateRouteExecution, } from './core/execution.js';
|
|
10
10
|
export type { AcceptExchangeRateUpdateHook, AcceptSlippageUpdateHook, AcceptSlippageUpdateHookParams, ExchangeRateUpdateParams, ExecutionOptions, InteractionSettings, LiFiStepExtended, RouteExecutionData, RouteExecutionDataDictionary, RouteExecutionDictionary, RouteExtended, SDKProvider, StepExecutor, StepExecutorOptions, StepExtended, SwitchChainHook, TransactionParameters, TransactionRequestParameters, TransactionRequestUpdateHook, UpdateRouteHook, } from './core/types.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAEA,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AACvC,OAAO,EACL,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,4BAA4B,CAAA;AACnC,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,YAAY,EACV,WAAW,EACX,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAEA,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AACvC,OAAO,EACL,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,4BAA4B,CAAA;AACnC,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,YAAY,EACV,WAAW,EACX,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EACL,YAAY,EACZ,cAAc,EACd,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EACV,4BAA4B,EAC5B,wBAAwB,EACxB,8BAA8B,EAC9B,wBAAwB,EACxB,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,4BAA4B,EAC5B,wBAAwB,EACxB,aAAa,EACb,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,4BAA4B,EAC5B,4BAA4B,EAC5B,eAAe,GAChB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAC5D,OAAO,EACL,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjD,YAAY,EACV,cAAc,EACd,qBAAqB,GACtB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAC7C,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,SAAS,EACT,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,QAAQ,EACR,SAAS,EACT,SAAS,EACT,kBAAkB,EAClB,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,qBAAqB,GACtB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAA;AAC3E,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EACL,YAAY,EACZ,SAAS,EACT,aAAa,GACd,MAAM,uBAAuB,CAAA;AAC9B,YAAY,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EACL,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,eAAe,GAChB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA"}
|
package/src/_types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,cAAc,CAAA;AAC/B,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,cAAc,CAAA;AAC/B,eAAO,MAAM,OAAO,UAAU,CAAA"}
|
package/src/constants.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
export const AddressZero = '0x0000000000000000000000000000000000000000'
|
|
2
2
|
export const AlternativeAddressZero =
|
|
3
3
|
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'
|
|
4
|
-
|
|
4
|
+
export const wrappedSolAddress = 'So11111111111111111111111111111111111111112'
|
|
5
5
|
export const SolSystemProgram = '11111111111111111111111111111111'
|
|
6
|
-
|
|
7
|
-
export const MaxUint48 = BigInt('0xffffffffffff')
|
|
8
|
-
export const MaxUint160 = BigInt('0xffffffffffffffffffffffffffffffffffffffff')
|
|
9
|
-
export const MaxUint256 =
|
|
10
|
-
BigInt(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn)
|
package/src/core/EVM/EVM.ts
CHANGED
|
@@ -12,6 +12,9 @@ export function EVM(options?: EVMProviderOptions): EVMProvider {
|
|
|
12
12
|
get type() {
|
|
13
13
|
return ChainType.EVM
|
|
14
14
|
},
|
|
15
|
+
get multisig() {
|
|
16
|
+
return _options.multisig
|
|
17
|
+
},
|
|
15
18
|
isAddress,
|
|
16
19
|
resolveAddress: getENSAddress,
|
|
17
20
|
getBalance: getEVMBalance,
|
|
@@ -26,6 +29,7 @@ export function EVM(options?: EVMProviderOptions): EVMProvider {
|
|
|
26
29
|
|
|
27
30
|
const executor = new EVMStepExecutor({
|
|
28
31
|
client: walletClient,
|
|
32
|
+
multisig: _options.multisig,
|
|
29
33
|
routeId: options.routeId,
|
|
30
34
|
executionOptions: {
|
|
31
35
|
...options.executionOptions,
|
|
@@ -4,18 +4,16 @@ import type {
|
|
|
4
4
|
Process,
|
|
5
5
|
} from '@lifi/types'
|
|
6
6
|
import type {
|
|
7
|
-
Address,
|
|
8
7
|
Client,
|
|
8
|
+
GetAddressesReturnType,
|
|
9
9
|
Hash,
|
|
10
|
-
Hex,
|
|
11
10
|
SendTransactionParameters,
|
|
12
|
-
TransactionReceipt,
|
|
13
11
|
} from 'viem'
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
12
|
+
import { getAddresses, sendTransaction } from 'viem/actions'
|
|
13
|
+
import { getAction } from 'viem/utils'
|
|
16
14
|
import { config } from '../../config.js'
|
|
17
15
|
import { LiFiErrorCode } from '../../errors/constants.js'
|
|
18
|
-
import { TransactionError } from '../../errors/errors.js'
|
|
16
|
+
import { TransactionError, ValidationError } from '../../errors/errors.js'
|
|
19
17
|
import { getStepTransaction } from '../../services/api.js'
|
|
20
18
|
import { getTransactionFailedMessage } from '../../utils/getTransactionMessage.js'
|
|
21
19
|
import { isZeroAddress } from '../../utils/isZeroAddress.js'
|
|
@@ -30,38 +28,33 @@ import type {
|
|
|
30
28
|
} from '../types.js'
|
|
31
29
|
import { waitForReceivingTransaction } from '../waitForReceivingTransaction.js'
|
|
32
30
|
import { checkAllowance } from './checkAllowance.js'
|
|
33
|
-
import {
|
|
31
|
+
import { updateMultisigRouteProcess } from './multisig.js'
|
|
34
32
|
import { parseEVMErrors } from './parseEVMErrors.js'
|
|
35
|
-
import { signPermitMessage } from './signPermitMessage.js'
|
|
36
33
|
import { switchChain } from './switchChain.js'
|
|
34
|
+
import type { MultisigConfig, MultisigTransaction } from './types.js'
|
|
37
35
|
import { getMaxPriorityFeePerGas } from './utils.js'
|
|
38
|
-
import {
|
|
39
|
-
type WalletCallReceipt,
|
|
40
|
-
waitForBatchTransactionReceipt,
|
|
41
|
-
} from './waitForBatchTransactionReceipt.js'
|
|
42
36
|
import { waitForTransactionReceipt } from './waitForTransactionReceipt.js'
|
|
43
37
|
|
|
44
|
-
export type Call = {
|
|
45
|
-
data?: Hex
|
|
46
|
-
to?: Address
|
|
47
|
-
value?: bigint
|
|
48
|
-
chainId?: number
|
|
49
|
-
}
|
|
50
|
-
|
|
51
38
|
export interface EVMStepExecutorOptions extends StepExecutorOptions {
|
|
52
39
|
client: Client
|
|
40
|
+
multisig?: MultisigConfig
|
|
53
41
|
}
|
|
54
42
|
|
|
55
43
|
export class EVMStepExecutor extends BaseStepExecutor {
|
|
56
44
|
private client: Client
|
|
45
|
+
private multisig?: MultisigConfig
|
|
57
46
|
|
|
58
47
|
constructor(options: EVMStepExecutorOptions) {
|
|
59
48
|
super(options)
|
|
60
49
|
this.client = options.client
|
|
50
|
+
this.multisig = options.multisig
|
|
61
51
|
}
|
|
62
52
|
|
|
63
53
|
// Ensure that we are using the right chain and wallet when executing transactions.
|
|
64
|
-
checkClient = async (
|
|
54
|
+
checkClient = async (
|
|
55
|
+
step: LiFiStepExtended,
|
|
56
|
+
process?: Process
|
|
57
|
+
): Promise<Client | undefined> => {
|
|
65
58
|
const updatedClient = await switchChain(
|
|
66
59
|
this.client,
|
|
67
60
|
this.statusManager,
|
|
@@ -76,7 +69,11 @@ export class EVMStepExecutor extends BaseStepExecutor {
|
|
|
76
69
|
// Prevent execution of the quote by wallet different from the one which requested the quote
|
|
77
70
|
let accountAddress = this.client.account?.address
|
|
78
71
|
if (!accountAddress) {
|
|
79
|
-
const accountAddresses = await
|
|
72
|
+
const accountAddresses = (await getAction(
|
|
73
|
+
this.client,
|
|
74
|
+
getAddresses,
|
|
75
|
+
'getAddresses'
|
|
76
|
+
)(undefined)) as GetAddressesReturnType
|
|
80
77
|
accountAddress = accountAddresses?.[0]
|
|
81
78
|
}
|
|
82
79
|
if (accountAddress !== step.action.fromAddress) {
|
|
@@ -128,81 +125,49 @@ export class EVMStepExecutor extends BaseStepExecutor {
|
|
|
128
125
|
}
|
|
129
126
|
}
|
|
130
127
|
|
|
131
|
-
const
|
|
132
|
-
const
|
|
128
|
+
const isMultisigClient = !!this.multisig?.isMultisigWalletClient
|
|
129
|
+
const multisigBatchTransactions: MultisigTransaction[] = []
|
|
133
130
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
atomicBatchSupported = capabilities[fromChain.id]?.atomicBatch?.supported
|
|
138
|
-
} catch {
|
|
139
|
-
// If the wallet does not support getCapabilities, we assume that atomic batch is not supported
|
|
140
|
-
}
|
|
131
|
+
const shouldBatchTransactions =
|
|
132
|
+
this.multisig?.shouldBatchTransactions &&
|
|
133
|
+
!!this.multisig.sendBatchTransaction
|
|
141
134
|
|
|
142
|
-
const
|
|
135
|
+
const fromChain = await config.getChainById(step.action.fromChainId)
|
|
136
|
+
const toChain = await config.getChainById(step.action.toChainId)
|
|
143
137
|
|
|
144
138
|
const isBridgeExecution = fromChain.id !== toChain.id
|
|
145
139
|
const currentProcessType = isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'
|
|
146
140
|
|
|
147
141
|
// STEP 1: Check allowance
|
|
148
|
-
// Find existing swap/bridge process
|
|
149
142
|
const existingProcess = step.execution.process.find(
|
|
150
143
|
(p) => p.type === currentProcessType
|
|
151
144
|
)
|
|
152
145
|
|
|
153
|
-
// Check if token
|
|
154
|
-
// Native tokens (like ETH) don't need approval since they're not ERC20 tokens
|
|
155
|
-
// We should support different permit types:
|
|
156
|
-
// 1. Native permits (EIP-2612)
|
|
157
|
-
// 2. Permit2 - Universal permit implementation by Uniswap (limited to certain chains)
|
|
158
|
-
// 3. Standard ERC20 approval
|
|
159
|
-
const nativePermit = await getNativePermit(
|
|
160
|
-
this.client,
|
|
161
|
-
fromChain,
|
|
162
|
-
step.action.fromToken.address as Address
|
|
163
|
-
)
|
|
164
|
-
// Check if proxy contract is available and token supports native permits, not available for atomic batch
|
|
165
|
-
const nativePermitSupported =
|
|
166
|
-
!!fromChain.permit2Proxy &&
|
|
167
|
-
nativePermit.supported &&
|
|
168
|
-
!atomicBatchSupported
|
|
169
|
-
// Check if chain has Permit2 contract deployed. Permit2 should not be available for atomic batch.
|
|
170
|
-
const permit2Supported =
|
|
171
|
-
!!fromChain.permit2 && !!fromChain.permit2Proxy && !atomicBatchSupported
|
|
172
|
-
// Token supports either native permits or Permit2
|
|
173
|
-
const permitSupported = permit2Supported || nativePermitSupported
|
|
174
|
-
|
|
146
|
+
// Check token approval only if fromToken is not the native token => no approval needed in that case
|
|
175
147
|
const checkForAllowance =
|
|
176
|
-
// No existing swap/bridgetransaction is pending
|
|
177
148
|
!existingProcess?.txHash &&
|
|
178
|
-
// Token is not native (address is not zero)
|
|
179
149
|
!isZeroAddress(step.action.fromToken.address) &&
|
|
180
|
-
|
|
181
|
-
!nativePermitSupported
|
|
150
|
+
(shouldBatchTransactions || !isMultisigClient)
|
|
182
151
|
|
|
183
152
|
if (checkForAllowance) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
chain: fromChain,
|
|
153
|
+
const data = await checkAllowance(
|
|
154
|
+
this.client,
|
|
155
|
+
fromChain,
|
|
188
156
|
step,
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
})
|
|
157
|
+
this.statusManager,
|
|
158
|
+
this.executionOptions,
|
|
159
|
+
this.allowUserInteraction,
|
|
160
|
+
shouldBatchTransactions
|
|
161
|
+
)
|
|
195
162
|
|
|
196
163
|
if (data) {
|
|
197
|
-
//
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
chainId: step.action.fromToken.chainId,
|
|
202
|
-
to: step.action.fromToken.address as Address,
|
|
203
|
-
data,
|
|
204
|
-
})
|
|
164
|
+
// allowance doesn't need value
|
|
165
|
+
const baseTransaction: MultisigTransaction = {
|
|
166
|
+
to: step.action.fromToken.address,
|
|
167
|
+
data,
|
|
205
168
|
}
|
|
169
|
+
|
|
170
|
+
multisigBatchTransactions.push(baseTransaction)
|
|
206
171
|
}
|
|
207
172
|
}
|
|
208
173
|
|
|
@@ -214,7 +179,28 @@ export class EVMStepExecutor extends BaseStepExecutor {
|
|
|
214
179
|
})
|
|
215
180
|
|
|
216
181
|
if (process.status !== 'DONE') {
|
|
182
|
+
const multisigProcess = step.execution.process.find(
|
|
183
|
+
(p) => !!p.multisigTxHash
|
|
184
|
+
)
|
|
185
|
+
|
|
217
186
|
try {
|
|
187
|
+
if (isMultisigClient && multisigProcess) {
|
|
188
|
+
const multisigTxHash = multisigProcess.multisigTxHash as Hash
|
|
189
|
+
if (!multisigTxHash) {
|
|
190
|
+
throw new ValidationError(
|
|
191
|
+
'Multisig internal transaction hash is undefined.'
|
|
192
|
+
)
|
|
193
|
+
}
|
|
194
|
+
await updateMultisigRouteProcess(
|
|
195
|
+
multisigTxHash,
|
|
196
|
+
step,
|
|
197
|
+
process.type,
|
|
198
|
+
fromChain,
|
|
199
|
+
this.statusManager,
|
|
200
|
+
this.multisig
|
|
201
|
+
)
|
|
202
|
+
}
|
|
203
|
+
|
|
218
204
|
let txHash: Hash
|
|
219
205
|
if (process.txHash) {
|
|
220
206
|
// Make sure that the chain is still correct
|
|
@@ -235,7 +221,7 @@ export class EVMStepExecutor extends BaseStepExecutor {
|
|
|
235
221
|
// Check balance
|
|
236
222
|
await checkBalance(this.client.account!.address, step)
|
|
237
223
|
|
|
238
|
-
// Create new transaction
|
|
224
|
+
// Create new transaction
|
|
239
225
|
if (!step.transactionRequest) {
|
|
240
226
|
const { execution, ...stepBase } = step
|
|
241
227
|
const updatedStep = await getStepTransaction(stepBase)
|
|
@@ -259,6 +245,23 @@ export class EVMStepExecutor extends BaseStepExecutor {
|
|
|
259
245
|
)
|
|
260
246
|
}
|
|
261
247
|
|
|
248
|
+
// STEP 3: Send the transaction
|
|
249
|
+
// Make sure that the chain is still correct
|
|
250
|
+
const updatedClient = await this.checkClient(step, process)
|
|
251
|
+
if (!updatedClient) {
|
|
252
|
+
return step
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
process = this.statusManager.updateProcess(
|
|
256
|
+
step,
|
|
257
|
+
process.type,
|
|
258
|
+
'ACTION_REQUIRED'
|
|
259
|
+
)
|
|
260
|
+
|
|
261
|
+
if (!this.allowUserInteraction) {
|
|
262
|
+
return step
|
|
263
|
+
}
|
|
264
|
+
|
|
262
265
|
let transactionRequest: TransactionParameters = {
|
|
263
266
|
to: step.transactionRequest.to,
|
|
264
267
|
from: step.transactionRequest.from,
|
|
@@ -296,72 +299,30 @@ export class EVMStepExecutor extends BaseStepExecutor {
|
|
|
296
299
|
}
|
|
297
300
|
}
|
|
298
301
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
process = this.statusManager.updateProcess(
|
|
307
|
-
step,
|
|
308
|
-
process.type,
|
|
309
|
-
permitSupported ? 'PERMIT_REQUIRED' : 'ACTION_REQUIRED'
|
|
310
|
-
)
|
|
311
|
-
|
|
312
|
-
if (!this.allowUserInteraction) {
|
|
313
|
-
return step
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
if (atomicBatchSupported) {
|
|
317
|
-
const transferCall: Call = {
|
|
318
|
-
chainId: fromChain.id,
|
|
319
|
-
data: transactionRequest.data as Hex,
|
|
320
|
-
to: transactionRequest.to as Address,
|
|
321
|
-
value: transactionRequest.value,
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
calls.push(transferCall)
|
|
325
|
-
|
|
326
|
-
txHash = (await sendCalls(this.client, {
|
|
327
|
-
account: this.client.account!,
|
|
328
|
-
calls,
|
|
329
|
-
})) as Address
|
|
330
|
-
} else {
|
|
331
|
-
if (permitSupported) {
|
|
332
|
-
const { data } = await signPermitMessage(
|
|
333
|
-
this.client,
|
|
334
|
-
transactionRequest,
|
|
335
|
-
fromChain,
|
|
336
|
-
step.action.fromToken.address as Address,
|
|
337
|
-
BigInt(step.action.fromAmount),
|
|
338
|
-
nativePermit
|
|
339
|
-
)
|
|
340
|
-
|
|
341
|
-
transactionRequest.to = fromChain.permit2Proxy
|
|
342
|
-
transactionRequest.data = data
|
|
343
|
-
|
|
344
|
-
try {
|
|
345
|
-
// Try to re-estimate the gas due to additional Permit data
|
|
346
|
-
transactionRequest.gas = await estimateGas(this.client, {
|
|
347
|
-
account: this.client.account!,
|
|
348
|
-
to: transactionRequest.to as Address,
|
|
349
|
-
data: transactionRequest.data as Hex,
|
|
350
|
-
value: transactionRequest.value,
|
|
351
|
-
})
|
|
352
|
-
} catch {
|
|
353
|
-
// Let the wallet estimate the gas in case of failure
|
|
354
|
-
transactionRequest.gas = undefined
|
|
302
|
+
if (shouldBatchTransactions && this.multisig?.sendBatchTransaction) {
|
|
303
|
+
if (transactionRequest.to && transactionRequest.data) {
|
|
304
|
+
const populatedTransaction: MultisigTransaction = {
|
|
305
|
+
value: transactionRequest.value,
|
|
306
|
+
to: transactionRequest.to,
|
|
307
|
+
data: transactionRequest.data,
|
|
355
308
|
}
|
|
309
|
+
multisigBatchTransactions.push(populatedTransaction)
|
|
356
310
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
311
|
+
txHash = await this.multisig?.sendBatchTransaction(
|
|
312
|
+
multisigBatchTransactions
|
|
313
|
+
)
|
|
314
|
+
} else {
|
|
315
|
+
throw new TransactionError(
|
|
316
|
+
LiFiErrorCode.TransactionUnprepared,
|
|
317
|
+
'Unable to prepare transaction.'
|
|
361
318
|
)
|
|
362
319
|
}
|
|
363
|
-
|
|
364
|
-
txHash = await
|
|
320
|
+
} else {
|
|
321
|
+
txHash = await getAction(
|
|
322
|
+
this.client,
|
|
323
|
+
sendTransaction,
|
|
324
|
+
'sendTransaction'
|
|
325
|
+
)({
|
|
365
326
|
to: transactionRequest.to,
|
|
366
327
|
account: this.client.account!,
|
|
367
328
|
data: transactionRequest.data,
|
|
@@ -370,53 +331,62 @@ export class EVMStepExecutor extends BaseStepExecutor {
|
|
|
370
331
|
gasPrice: transactionRequest.gasPrice,
|
|
371
332
|
maxFeePerGas: transactionRequest.maxFeePerGas,
|
|
372
333
|
maxPriorityFeePerGas: transactionRequest.maxPriorityFeePerGas,
|
|
334
|
+
chain: null,
|
|
373
335
|
} as SendTransactionParameters)
|
|
374
336
|
}
|
|
375
337
|
|
|
376
338
|
// STEP 4: Wait for the transaction
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
339
|
+
if (isMultisigClient) {
|
|
340
|
+
process = this.statusManager.updateProcess(
|
|
341
|
+
step,
|
|
342
|
+
process.type,
|
|
343
|
+
'ACTION_REQUIRED',
|
|
344
|
+
{
|
|
345
|
+
multisigTxHash: txHash,
|
|
346
|
+
}
|
|
347
|
+
)
|
|
348
|
+
} else {
|
|
349
|
+
process = this.statusManager.updateProcess(
|
|
350
|
+
step,
|
|
351
|
+
process.type,
|
|
352
|
+
'PENDING',
|
|
353
|
+
{
|
|
354
|
+
txHash: txHash,
|
|
355
|
+
txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${txHash}`,
|
|
356
|
+
}
|
|
357
|
+
)
|
|
358
|
+
}
|
|
391
359
|
}
|
|
392
360
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
361
|
+
const transactionReceipt = await waitForTransactionReceipt({
|
|
362
|
+
client: this.client,
|
|
363
|
+
chainId: fromChain.id,
|
|
364
|
+
txHash,
|
|
365
|
+
onReplaced: (response) => {
|
|
366
|
+
this.statusManager.updateProcess(step, process.type, 'PENDING', {
|
|
367
|
+
txHash: response.transaction.hash,
|
|
368
|
+
txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${response.transaction.hash}`,
|
|
369
|
+
})
|
|
370
|
+
},
|
|
371
|
+
})
|
|
397
372
|
|
|
398
|
-
if
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
373
|
+
// if it's multisig wallet client and the process is in ACTION_REQUIRED
|
|
374
|
+
// then signatures are still needed
|
|
375
|
+
if (isMultisigClient && process.status === 'ACTION_REQUIRED') {
|
|
376
|
+
await updateMultisigRouteProcess(
|
|
377
|
+
transactionReceipt?.transactionHash || txHash,
|
|
378
|
+
step,
|
|
379
|
+
process.type,
|
|
380
|
+
fromChain,
|
|
381
|
+
this.statusManager,
|
|
382
|
+
this.multisig
|
|
402
383
|
)
|
|
403
|
-
} else {
|
|
404
|
-
transactionReceipt = await waitForTransactionReceipt({
|
|
405
|
-
client: this.client,
|
|
406
|
-
chainId: fromChain.id,
|
|
407
|
-
txHash,
|
|
408
|
-
onReplaced: (response) => {
|
|
409
|
-
this.statusManager.updateProcess(step, process.type, 'PENDING', {
|
|
410
|
-
txHash: response.transaction.hash,
|
|
411
|
-
txLink: `${fromChain.metamask.blockExplorerUrls[0]}tx/${response.transaction.hash}`,
|
|
412
|
-
})
|
|
413
|
-
},
|
|
414
|
-
})
|
|
415
384
|
}
|
|
416
385
|
|
|
417
386
|
// Update pending process if the transaction hash from the receipt is different.
|
|
418
387
|
// This might happen if the transaction was replaced.
|
|
419
388
|
if (
|
|
389
|
+
!isMultisigClient &&
|
|
420
390
|
transactionReceipt?.transactionHash &&
|
|
421
391
|
transactionReceipt.transactionHash !== txHash
|
|
422
392
|
) {
|
|
@@ -463,12 +433,13 @@ export class EVMStepExecutor extends BaseStepExecutor {
|
|
|
463
433
|
chainId: toChain.id,
|
|
464
434
|
})
|
|
465
435
|
}
|
|
436
|
+
let statusResponse: FullStatusData
|
|
466
437
|
|
|
467
438
|
try {
|
|
468
439
|
if (!processTxHash) {
|
|
469
440
|
throw new Error('Transaction hash is undefined.')
|
|
470
441
|
}
|
|
471
|
-
|
|
442
|
+
statusResponse = (await waitForReceivingTransaction(
|
|
472
443
|
processTxHash,
|
|
473
444
|
this.statusManager,
|
|
474
445
|
process.type,
|