@lifi/sdk 3.0.0-alpha.6 → 3.0.0-alpha.7
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/dist/LiFi.d.ts +21 -18
- package/dist/LiFi.js +15 -12
- package/dist/allowance/setAllowance.d.ts +1 -1
- package/dist/cjs/LiFi.d.ts +21 -18
- package/dist/cjs/LiFi.js +15 -12
- package/dist/cjs/allowance/setAllowance.d.ts +1 -1
- package/dist/cjs/connectors.d.ts +1 -1
- package/dist/cjs/execution/BaseStepExecutor.d.ts +12 -0
- package/dist/cjs/execution/BaseStepExecutor.js +27 -0
- package/dist/cjs/execution/EVMStepExecutor.d.ts +13 -0
- package/dist/cjs/execution/EVMStepExecutor.js +292 -0
- package/dist/cjs/execution/RouteExecutionManager.d.ts +6 -7
- package/dist/cjs/execution/RouteExecutionManager.js +19 -19
- package/dist/cjs/execution/StatusManager.d.ts +8 -7
- package/dist/cjs/execution/StatusManager.js +1 -1
- package/dist/cjs/execution/StepExecutionManager.d.ts +3 -3
- package/dist/cjs/execution/StepExecutionManager.js +4 -4
- package/dist/cjs/execution/checkAllowance.d.ts +3 -2
- package/dist/cjs/execution/checkBalance.d.ts +2 -2
- package/dist/cjs/execution/index.d.ts +1 -0
- package/dist/cjs/execution/index.js +1 -0
- package/dist/cjs/execution/multisig.d.ts +2 -2
- package/dist/cjs/execution/prepareRestart.d.ts +2 -3
- package/dist/cjs/execution/prepareRestart.js +2 -2
- package/dist/cjs/execution/stepComparison.d.ts +4 -3
- package/dist/cjs/execution/stepComparison.js +1 -1
- package/dist/cjs/execution/switchChain.d.ts +4 -3
- package/dist/cjs/execution/switchChain.js +1 -0
- package/dist/cjs/{types/internal.types.d.ts → execution/types.d.ts} +33 -96
- package/dist/cjs/execution/utils.d.ts +2 -2
- package/dist/cjs/execution/waitForReceivingTransaction.d.ts +3 -3
- package/dist/cjs/helpers.d.ts +2 -2
- package/dist/cjs/index.d.ts +3 -1
- package/dist/cjs/index.js +6 -3
- package/dist/cjs/providers/BaseProvider.d.ts +7 -0
- package/dist/cjs/providers/BaseProvider.js +6 -0
- package/dist/cjs/providers/EVMProvider.d.ts +16 -0
- package/dist/cjs/providers/EVMProvider.js +28 -0
- package/dist/cjs/providers/SolanaProvider.d.ts +15 -0
- package/dist/cjs/providers/SolanaProvider.js +32 -0
- package/dist/cjs/providers/types.d.ts +0 -0
- package/dist/cjs/providers/types.js +1 -0
- package/dist/cjs/request.js +11 -5
- package/dist/cjs/services/ApiService.d.ts +4 -5
- package/dist/cjs/services/ApiService.js +2 -2
- package/dist/cjs/services/ConfigService.d.ts +6 -5
- package/dist/cjs/services/ConfigService.js +3 -3
- package/dist/cjs/typeguards.d.ts +2 -2
- package/dist/cjs/types/index.d.ts +1 -3
- package/dist/cjs/types/index.js +1 -5
- package/dist/cjs/types/internal.d.ts +60 -0
- package/dist/cjs/types/internal.js +2 -0
- package/dist/cjs/utils/parseError.d.ts +4 -4
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/connectors.d.ts +1 -1
- package/dist/execution/BaseStepExecutor.d.ts +12 -0
- package/dist/execution/BaseStepExecutor.js +23 -0
- package/dist/execution/EVMStepExecutor.d.ts +13 -0
- package/dist/execution/EVMStepExecutor.js +285 -0
- package/dist/execution/RouteExecutionManager.d.ts +6 -7
- package/dist/execution/RouteExecutionManager.js +19 -19
- package/dist/execution/StatusManager.d.ts +8 -7
- package/dist/execution/StatusManager.js +1 -1
- package/dist/execution/StepExecutionManager.d.ts +3 -3
- package/dist/execution/StepExecutionManager.js +4 -4
- package/dist/execution/checkAllowance.d.ts +3 -2
- package/dist/execution/checkBalance.d.ts +2 -2
- package/dist/execution/index.d.ts +1 -0
- package/dist/execution/index.js +1 -0
- package/dist/execution/multisig.d.ts +2 -2
- package/dist/execution/prepareRestart.d.ts +2 -3
- package/dist/execution/prepareRestart.js +2 -2
- package/dist/execution/stepComparison.d.ts +4 -3
- package/dist/execution/stepComparison.js +1 -1
- package/dist/execution/switchChain.d.ts +4 -3
- package/dist/execution/switchChain.js +1 -0
- package/dist/{types/internal.types.d.ts → execution/types.d.ts} +33 -96
- package/dist/execution/utils.d.ts +2 -2
- package/dist/execution/waitForReceivingTransaction.d.ts +3 -3
- package/dist/helpers.d.ts +2 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/providers/BaseProvider.d.ts +7 -0
- package/dist/providers/BaseProvider.js +2 -0
- package/dist/providers/EVMProvider.d.ts +16 -0
- package/dist/providers/EVMProvider.js +24 -0
- package/dist/providers/SolanaProvider.d.ts +15 -0
- package/dist/providers/SolanaProvider.js +28 -0
- package/dist/providers/types.d.ts +0 -0
- package/dist/providers/types.js +1 -0
- package/dist/request.js +11 -5
- package/dist/services/ApiService.d.ts +4 -5
- package/dist/services/ApiService.js +2 -2
- package/dist/services/ConfigService.d.ts +6 -5
- package/dist/services/ConfigService.js +3 -3
- package/dist/typeguards.d.ts +2 -2
- package/dist/types/index.d.ts +1 -3
- package/dist/types/index.js +1 -3
- package/dist/types/internal.d.ts +60 -0
- package/dist/types/internal.js +1 -0
- package/dist/utils/parseError.d.ts +4 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -5
- package/dist/cjs/execution/StepExecutor.d.ts +0 -15
- package/dist/cjs/execution/StepExecutor.js +0 -62
- package/dist/execution/StepExecutor.d.ts +0 -15
- package/dist/execution/StepExecutor.js +0 -58
- /package/dist/cjs/{types/internal.types.js → execution/types.js} +0 -0
- /package/dist/{types/internal.types.js → execution/types.js} +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LiFiStep } from '@lifi/types';
|
|
2
2
|
import type { StatusManager } from './StatusManager';
|
|
3
|
+
import type { InternalExecutionSettings } from './types';
|
|
3
4
|
/**
|
|
4
5
|
* This method checks whether the new and updated Step meets the required exchange rate conditions.
|
|
5
6
|
* If yes it returns the updated Step.
|
|
@@ -9,6 +10,6 @@ import type { StatusManager } from './StatusManager';
|
|
|
9
10
|
* @param newStep
|
|
10
11
|
* @param settings
|
|
11
12
|
* @param allowUserInteraction
|
|
12
|
-
* @returns Return
|
|
13
|
+
* @returns Return LiFiStep
|
|
13
14
|
*/
|
|
14
|
-
export declare const stepComparison: (statusManager: StatusManager, oldStep:
|
|
15
|
+
export declare const stepComparison: (statusManager: StatusManager, oldStep: LiFiStep, newStep: LiFiStep, settings: InternalExecutionSettings, allowUserInteraction: boolean) => Promise<LiFiStep>;
|
|
@@ -9,7 +9,7 @@ import { checkStepSlippageThreshold } from './utils';
|
|
|
9
9
|
* @param newStep
|
|
10
10
|
* @param settings
|
|
11
11
|
* @param allowUserInteraction
|
|
12
|
-
* @returns Return
|
|
12
|
+
* @returns Return LiFiStep
|
|
13
13
|
*/
|
|
14
14
|
export const stepComparison = async (statusManager, oldStep, newStep, settings, allowUserInteraction) => {
|
|
15
15
|
// Check if changed exchange rate is in the range of slippage threshold
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LiFiStep } from '@lifi/types';
|
|
2
2
|
import type { WalletClient } from 'viem';
|
|
3
|
-
import type { SwitchChainHook } from '../types';
|
|
4
3
|
import type { StatusManager } from './StatusManager';
|
|
4
|
+
import type { SwitchChainHook } from './types';
|
|
5
5
|
/**
|
|
6
6
|
* This method checks whether the wallet client is configured for the correct chain.
|
|
7
7
|
* If yes it returns the wallet clien.
|
|
@@ -17,5 +17,6 @@ import type { StatusManager } from './StatusManager';
|
|
|
17
17
|
* @param step
|
|
18
18
|
* @param switchChainHook
|
|
19
19
|
* @param allowUserInteraction
|
|
20
|
+
* @returns New WalletClient
|
|
20
21
|
*/
|
|
21
|
-
export declare const switchChain: (walletClient: WalletClient, statusManager: StatusManager, step:
|
|
22
|
+
export declare const switchChain: (walletClient: WalletClient, statusManager: StatusManager, step: LiFiStep, switchChainHook: SwitchChainHook, allowUserInteraction: boolean) => Promise<WalletClient | undefined>;
|
|
@@ -14,6 +14,7 @@ import { LiFiErrorCode, ProviderError } from '../utils/errors';
|
|
|
14
14
|
* @param step
|
|
15
15
|
* @param switchChainHook
|
|
16
16
|
* @param allowUserInteraction
|
|
17
|
+
* @returns New WalletClient
|
|
17
18
|
*/
|
|
18
19
|
export const switchChain = async (walletClient, statusManager, step, switchChainHook, allowUserInteraction) => {
|
|
19
20
|
// if we are already on the correct chain we can proceed directly
|
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LiFiStep, Route, Token } from '@lifi/types';
|
|
2
2
|
import type { Hash, Hex, WalletClient } from 'viem';
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
3
|
+
import type { BaseStepExecutor } from './BaseStepExecutor';
|
|
4
|
+
import type { StatusManager } from './StatusManager';
|
|
5
|
+
export interface StepExecutorOptions {
|
|
6
|
+
statusManager: StatusManager;
|
|
7
|
+
settings: InternalExecutionSettings;
|
|
8
|
+
}
|
|
9
|
+
export interface RouteExecutionData {
|
|
10
|
+
route: Route;
|
|
11
|
+
executors: BaseStepExecutor[];
|
|
12
|
+
settings: InternalExecutionSettings;
|
|
13
|
+
}
|
|
14
|
+
export type RouteExecutionDictionary = Partial<Record<string, RouteExecutionData>>;
|
|
15
|
+
export type RouteExecutionPromiseDictionary = Partial<Record<string, Promise<Route>>>;
|
|
5
16
|
export type TransactionParameters = {
|
|
6
17
|
chainId?: number;
|
|
7
18
|
to?: string;
|
|
@@ -14,59 +25,11 @@ export type TransactionParameters = {
|
|
|
14
25
|
maxFeePerGas?: bigint;
|
|
15
26
|
maxPriorityFeePerGas?: bigint;
|
|
16
27
|
};
|
|
17
|
-
export interface ExecutionParams {
|
|
18
|
-
walletClient: WalletClient;
|
|
19
|
-
step: LifiStep;
|
|
20
|
-
statusManager: StatusManager;
|
|
21
|
-
settings: InternalExecutionSettings;
|
|
22
|
-
}
|
|
23
28
|
export type UpdateRouteHook = (updatedRoute: Route) => void;
|
|
24
29
|
export interface TransactionRequestParameters extends TransactionParameters {
|
|
25
30
|
requestType: 'approve' | 'transaction';
|
|
26
31
|
}
|
|
27
32
|
export type TransactionRequestUpdateHook = (updatedTxRequest: TransactionRequestParameters) => Promise<TransactionParameters>;
|
|
28
|
-
export type Config = {
|
|
29
|
-
apiUrl: string;
|
|
30
|
-
rpcs: Record<ChainId, string[]>;
|
|
31
|
-
multicallAddresses: Record<ChainId, string | undefined>;
|
|
32
|
-
defaultExecutionSettings: InternalExecutionSettings;
|
|
33
|
-
defaultRouteOptions: RouteOptions;
|
|
34
|
-
disableVersionCheck?: boolean;
|
|
35
|
-
userId?: string;
|
|
36
|
-
integrator: string;
|
|
37
|
-
widgetVersion?: string;
|
|
38
|
-
multisig?: MultisigConfig;
|
|
39
|
-
};
|
|
40
|
-
export interface MultisigTxDetails {
|
|
41
|
-
status: 'DONE' | 'FAILED' | 'PENDING' | 'CANCELLED';
|
|
42
|
-
txHash?: Hash;
|
|
43
|
-
}
|
|
44
|
-
export interface MultisigTransactionResponse {
|
|
45
|
-
hash: string;
|
|
46
|
-
}
|
|
47
|
-
export interface BaseTransaction {
|
|
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: BaseTransaction[]) => Promise<Hash>;
|
|
56
|
-
shouldBatchTransactions?: boolean;
|
|
57
|
-
}
|
|
58
|
-
export type ConfigUpdate = {
|
|
59
|
-
apiUrl?: string;
|
|
60
|
-
rpcs?: Record<number, string[]>;
|
|
61
|
-
multicallAddresses?: Record<number, string | undefined>;
|
|
62
|
-
defaultExecutionSettings?: ExecutionSettings;
|
|
63
|
-
defaultRouteOptions?: RouteOptions;
|
|
64
|
-
disableVersionCheck?: boolean;
|
|
65
|
-
userId?: string;
|
|
66
|
-
integrator: string;
|
|
67
|
-
widgetVersion?: string;
|
|
68
|
-
multisigConfig?: MultisigConfig;
|
|
69
|
-
};
|
|
70
33
|
export type SwitchChainHook = (requiredChainId: number) => Promise<WalletClient | undefined>;
|
|
71
34
|
export interface AcceptSlippageUpdateHookParams {
|
|
72
35
|
toToken: Token;
|
|
@@ -82,11 +45,6 @@ export interface ExchangeRateUpdateParams {
|
|
|
82
45
|
newToAmount: string;
|
|
83
46
|
}
|
|
84
47
|
export type AcceptExchangeRateUpdateHook = (params: ExchangeRateUpdateParams) => Promise<boolean | undefined>;
|
|
85
|
-
export interface RouteExecutionData {
|
|
86
|
-
route: Route;
|
|
87
|
-
executors: StepExecutor[];
|
|
88
|
-
settings: InternalExecutionSettings;
|
|
89
|
-
}
|
|
90
48
|
export type ExecutionSettings = Partial<InternalExecutionSettings>;
|
|
91
49
|
export interface InternalExecutionSettings {
|
|
92
50
|
acceptExchangeRateUpdateHook: AcceptExchangeRateUpdateHook;
|
|
@@ -96,50 +54,29 @@ export interface InternalExecutionSettings {
|
|
|
96
54
|
executeInBackground: boolean;
|
|
97
55
|
infiniteApproval: boolean;
|
|
98
56
|
}
|
|
99
|
-
export
|
|
100
|
-
|
|
57
|
+
export interface ExecutionParams {
|
|
58
|
+
walletClient: WalletClient;
|
|
59
|
+
step: LiFiStep;
|
|
60
|
+
statusManager: StatusManager;
|
|
61
|
+
settings: InternalExecutionSettings;
|
|
62
|
+
}
|
|
101
63
|
export interface InteractionSettings {
|
|
102
64
|
allowInteraction?: boolean;
|
|
103
65
|
allowUpdates?: boolean;
|
|
104
|
-
|
|
66
|
+
allowExecution?: boolean;
|
|
105
67
|
}
|
|
106
|
-
export interface
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
gas: number;
|
|
112
|
-
gas_price: number;
|
|
113
|
-
gas_fee_cap: number;
|
|
114
|
-
gas_tip_cap: number;
|
|
115
|
-
cumulative_gas_used: number;
|
|
116
|
-
gas_used: number;
|
|
117
|
-
effective_gas_price: number;
|
|
118
|
-
input: string;
|
|
119
|
-
nonce: number;
|
|
68
|
+
export interface MultisigTxDetails {
|
|
69
|
+
status: 'DONE' | 'FAILED' | 'PENDING' | 'CANCELLED';
|
|
70
|
+
txHash?: Hash;
|
|
71
|
+
}
|
|
72
|
+
export interface BaseTransaction {
|
|
120
73
|
to: string;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
access_list: any;
|
|
124
|
-
status: boolean;
|
|
125
|
-
addresses: string[];
|
|
126
|
-
contract_ids: string[];
|
|
127
|
-
network_id: string;
|
|
128
|
-
timestamp: string;
|
|
129
|
-
function_selector: string;
|
|
130
|
-
l1_block_number: number;
|
|
131
|
-
l1_timestamp: number;
|
|
132
|
-
deposit_tx: boolean;
|
|
133
|
-
system_tx: boolean;
|
|
134
|
-
mint: number;
|
|
135
|
-
sig: Signature;
|
|
136
|
-
error_message: string;
|
|
137
|
-
method: string;
|
|
138
|
-
decoded_input: any;
|
|
139
|
-
call_trace: any;
|
|
74
|
+
value?: bigint;
|
|
75
|
+
data: string;
|
|
140
76
|
}
|
|
141
|
-
export interface
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
77
|
+
export interface MultisigConfig {
|
|
78
|
+
isMultisigWalletClient: boolean;
|
|
79
|
+
getMultisigTransactionDetails: (txHash: Hash, fromChainId: number, updateIntermediateStatus?: () => void) => Promise<MultisigTxDetails>;
|
|
80
|
+
sendBatchTransaction?: (batchTransactions: BaseTransaction[]) => Promise<Hash>;
|
|
81
|
+
shouldBatchTransactions?: boolean;
|
|
145
82
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LiFiStep, ProcessType, Status, StatusMessage, Substatus } from '@lifi/types';
|
|
2
2
|
export declare function getProcessMessage(type: ProcessType, status: Status): string | undefined;
|
|
3
3
|
export declare function getSubstatusMessage(status: StatusMessage, substatus?: Substatus): string | undefined;
|
|
4
4
|
/**
|
|
@@ -9,4 +9,4 @@ export declare function getSubstatusMessage(status: StatusMessage, substatus?: S
|
|
|
9
9
|
* @param newStep
|
|
10
10
|
* @returns Boolean
|
|
11
11
|
*/
|
|
12
|
-
export declare function checkStepSlippageThreshold(oldStep:
|
|
12
|
+
export declare function checkStepSlippageThreshold(oldStep: LiFiStep, newStep: LiFiStep): boolean;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { StatusManager } from '
|
|
3
|
-
export declare function waitForReceivingTransaction(txHash: string, statusManager: StatusManager, processType: ProcessType, step:
|
|
1
|
+
import type { LiFiStep, ProcessType, StatusResponse } from '@lifi/types';
|
|
2
|
+
import type { StatusManager } from './StatusManager';
|
|
3
|
+
export declare function waitForReceivingTransaction(txHash: string, statusManager: StatusManager, processType: ProcessType, step: LiFiStep): Promise<StatusResponse>;
|
package/dist/helpers.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LiFiStep, Route } from '@lifi/types';
|
|
2
2
|
import type { TenderlyResponse } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Returns a random number between min (inclusive) and max (inclusive)
|
|
@@ -14,5 +14,5 @@ export declare const checkPackageUpdates: (packageName?: string, packageVersion?
|
|
|
14
14
|
* @returns - The route to be executed.
|
|
15
15
|
* @throws {ValidationError} Throws a ValidationError if the step has missing values.
|
|
16
16
|
*/
|
|
17
|
-
export declare const convertQuoteToRoute: (step:
|
|
17
|
+
export declare const convertQuoteToRoute: (step: LiFiStep) => Route;
|
|
18
18
|
export declare const fetchTxErrorDetails: (txHash: string, chainId: number) => Promise<TenderlyResponse>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
export * from '@lifi/types';
|
|
2
|
+
export { LiFi } from './LiFi';
|
|
1
3
|
export * from './execution';
|
|
2
4
|
export * from './helpers';
|
|
3
|
-
export { LiFi } from './LiFi';
|
|
4
5
|
export * from './types';
|
|
5
6
|
export * from './utils/errors';
|
|
7
|
+
export { ErrorCode, LiFiError } from './utils/errors';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// expose types and helpers
|
|
2
|
+
export * from '@lifi/types';
|
|
3
|
+
export { LiFi } from './LiFi';
|
|
2
4
|
export * from './execution';
|
|
3
5
|
export * from './helpers';
|
|
4
|
-
export { LiFi } from './LiFi';
|
|
5
6
|
export * from './types';
|
|
6
7
|
export * from './utils/errors';
|
|
8
|
+
export { LiFiError } from './utils/errors';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LiFiStep } from '@lifi/types';
|
|
2
|
+
import type { BaseStepExecutor } from '../execution/BaseStepExecutor';
|
|
3
|
+
import type { StepExecutorOptions } from '../execution/types';
|
|
4
|
+
export declare abstract class BaseProvider {
|
|
5
|
+
abstract isProviderStep(step: LiFiStep): boolean;
|
|
6
|
+
abstract getStepExecutor(options: StepExecutorOptions): Promise<BaseStepExecutor>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { LiFiStep } from '@lifi/types';
|
|
2
|
+
import { type WalletClient } from 'viem';
|
|
3
|
+
import type { BaseStepExecutor } from '../execution/BaseStepExecutor';
|
|
4
|
+
import type { StepExecutorOptions } from '../execution/types';
|
|
5
|
+
import { BaseProvider } from './BaseProvider';
|
|
6
|
+
export type GetEVMWalletClient = () => Promise<WalletClient>;
|
|
7
|
+
export interface EVMProviderOptions {
|
|
8
|
+
getWalletClient: GetEVMWalletClient;
|
|
9
|
+
}
|
|
10
|
+
export declare class EVMProvider extends BaseProvider {
|
|
11
|
+
getWalletClient?: GetEVMWalletClient;
|
|
12
|
+
constructor(options?: EVMProviderOptions);
|
|
13
|
+
isProviderStep(step: LiFiStep): boolean;
|
|
14
|
+
getStepExecutor(options: StepExecutorOptions): Promise<BaseStepExecutor>;
|
|
15
|
+
setOptions(options: EVMProviderOptions): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { isAddress } from 'viem';
|
|
2
|
+
import { EVMStepExecutor } from '../execution/EVMStepExecutor';
|
|
3
|
+
import { BaseProvider } from './BaseProvider';
|
|
4
|
+
export class EVMProvider extends BaseProvider {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
super();
|
|
7
|
+
this.getWalletClient = options?.getWalletClient;
|
|
8
|
+
}
|
|
9
|
+
isProviderStep(step) {
|
|
10
|
+
const isProviderStep = isAddress(step.action.fromAddress);
|
|
11
|
+
return isProviderStep;
|
|
12
|
+
}
|
|
13
|
+
async getStepExecutor(options) {
|
|
14
|
+
if (!this.getWalletClient) {
|
|
15
|
+
throw new Error(`getWalletClient is not provided.`);
|
|
16
|
+
}
|
|
17
|
+
const walletClient = await this.getWalletClient();
|
|
18
|
+
const executor = new EVMStepExecutor({ walletClient, ...options });
|
|
19
|
+
return executor;
|
|
20
|
+
}
|
|
21
|
+
setOptions(options) {
|
|
22
|
+
this.getWalletClient = options.getWalletClient;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { LiFiStep } from '@lifi/types';
|
|
2
|
+
import type { BaseStepExecutor } from '../execution/BaseStepExecutor';
|
|
3
|
+
import type { StepExecutorOptions } from '../execution/types';
|
|
4
|
+
import { BaseProvider } from './BaseProvider';
|
|
5
|
+
export type GetSolanaWalletClient = () => Promise<unknown>;
|
|
6
|
+
export interface SolanaProviderOptions {
|
|
7
|
+
getWalletClient: GetSolanaWalletClient;
|
|
8
|
+
}
|
|
9
|
+
export declare class SolanaProvider extends BaseProvider {
|
|
10
|
+
getWalletClient?: GetSolanaWalletClient;
|
|
11
|
+
constructor(options?: SolanaProviderOptions);
|
|
12
|
+
isProviderStep(step: LiFiStep): boolean;
|
|
13
|
+
getStepExecutor(options: StepExecutorOptions): Promise<BaseStepExecutor>;
|
|
14
|
+
setOptions(options: SolanaProviderOptions): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PublicKey } from '@solana/web3.js';
|
|
2
|
+
import { BaseProvider } from './BaseProvider';
|
|
3
|
+
export class SolanaProvider extends BaseProvider {
|
|
4
|
+
constructor(options) {
|
|
5
|
+
super();
|
|
6
|
+
this.getWalletClient = options?.getWalletClient;
|
|
7
|
+
}
|
|
8
|
+
isProviderStep(step) {
|
|
9
|
+
try {
|
|
10
|
+
const publickKey = new PublicKey(step.action.fromAddress);
|
|
11
|
+
const isProviderStep = PublicKey.isOnCurve(publickKey);
|
|
12
|
+
return isProviderStep;
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
async getStepExecutor(options) {
|
|
19
|
+
if (!this.getWalletClient) {
|
|
20
|
+
throw new Error(`getWalletClient is not provided.`);
|
|
21
|
+
}
|
|
22
|
+
const walletClient = await this.getWalletClient();
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
setOptions(options) {
|
|
26
|
+
this.getWalletClient = options.getWalletClient;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/dist/request.js
CHANGED
|
@@ -8,32 +8,38 @@ export const requestSettings = {
|
|
|
8
8
|
export const request = async (url, options = {
|
|
9
9
|
retries: requestSettings.retries,
|
|
10
10
|
}) => {
|
|
11
|
-
const { userId, integrator, widgetVersion } = ConfigService.getInstance().getConfig();
|
|
11
|
+
const { userId, integrator, widgetVersion, apiKey } = ConfigService.getInstance().getConfig();
|
|
12
12
|
options.retries = options.retries ?? requestSettings.retries;
|
|
13
13
|
try {
|
|
14
14
|
if (!options.skipTrackingHeaders) {
|
|
15
|
+
if (apiKey) {
|
|
16
|
+
options.headers = {
|
|
17
|
+
...options?.headers,
|
|
18
|
+
'x-lifi-api-key': apiKey,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
15
21
|
if (userId) {
|
|
16
22
|
options.headers = {
|
|
17
23
|
...options?.headers,
|
|
18
|
-
'
|
|
24
|
+
'x-lifi-userid': userId,
|
|
19
25
|
};
|
|
20
26
|
}
|
|
21
27
|
if (widgetVersion) {
|
|
22
28
|
options.headers = {
|
|
23
29
|
...options?.headers,
|
|
24
|
-
'
|
|
30
|
+
'x-lifi-widget': widgetVersion,
|
|
25
31
|
};
|
|
26
32
|
}
|
|
27
33
|
if (version) {
|
|
28
34
|
options.headers = {
|
|
29
35
|
...options?.headers,
|
|
30
|
-
'
|
|
36
|
+
'x-lifi-sdk': version,
|
|
31
37
|
};
|
|
32
38
|
}
|
|
33
39
|
// integrator is mandatory during SDK initialization
|
|
34
40
|
options.headers = {
|
|
35
41
|
...options?.headers,
|
|
36
|
-
'
|
|
42
|
+
'x-lifi-integrator': integrator,
|
|
37
43
|
};
|
|
38
44
|
}
|
|
39
45
|
const response = await fetch(url, options);
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import type { ConnectionsRequest, ConnectionsResponse, ContractCallQuoteRequest, GasRecommendationRequest, GasRecommendationResponse, GetStatusRequest,
|
|
2
|
-
import type { ChainId, ChainKey, ExtendedChain, PossibilitiesRequest, PossibilitiesResponse, RoutesRequest, RoutesResponse, StatusResponse, Token, ToolsRequest, ToolsResponse } from '../types';
|
|
1
|
+
import type { ChainId, ChainKey, ConnectionsRequest, ConnectionsResponse, ContractCallQuoteRequest, ExtendedChain, GasRecommendationRequest, GasRecommendationResponse, GetStatusRequest, LiFiStep, PossibilitiesRequest, PossibilitiesResponse, QuoteRequest, RequestOptions, RoutesRequest, RoutesResponse, StatusResponse, Token, TokensRequest, TokensResponse, ToolsRequest, ToolsResponse } from '@lifi/types';
|
|
3
2
|
declare const _default: {
|
|
4
3
|
getChains: (options?: RequestOptions | undefined) => Promise<ExtendedChain[]>;
|
|
5
|
-
getContractCallQuote: (requestConfig: ContractCallQuoteRequest, options?: RequestOptions | undefined) => Promise<
|
|
4
|
+
getContractCallQuote: (requestConfig: ContractCallQuoteRequest, options?: RequestOptions | undefined) => Promise<LiFiStep>;
|
|
6
5
|
getGasRecommendation: ({ chainId, fromChain, fromToken }: GasRecommendationRequest, options?: RequestOptions | undefined) => Promise<GasRecommendationResponse>;
|
|
7
6
|
getPossibilities: (requestConfig?: PossibilitiesRequest | undefined, options?: RequestOptions | undefined) => Promise<PossibilitiesResponse>;
|
|
8
|
-
getQuote: (requestConfig: QuoteRequest, options?: RequestOptions | undefined) => Promise<
|
|
7
|
+
getQuote: (requestConfig: QuoteRequest, options?: RequestOptions | undefined) => Promise<LiFiStep>;
|
|
9
8
|
getRoutes: (requestConfig: RoutesRequest, options?: RequestOptions | undefined) => Promise<RoutesResponse>;
|
|
10
9
|
getStatus: (requestConfig: GetStatusRequest, options?: RequestOptions | undefined) => Promise<StatusResponse>;
|
|
11
|
-
getStepTransaction: (step:
|
|
10
|
+
getStepTransaction: (step: LiFiStep, options?: RequestOptions | undefined) => Promise<LiFiStep>;
|
|
12
11
|
getToken: (chain: ChainId | ChainKey, token: string, options?: RequestOptions | undefined) => Promise<Token>;
|
|
13
12
|
getTokens: (requestConfig?: TokensRequest | undefined, options?: RequestOptions | undefined) => Promise<TokensResponse>;
|
|
14
13
|
getTools: (requestConfig?: ToolsRequest | undefined, options?: RequestOptions | undefined) => Promise<ToolsResponse>;
|
|
@@ -276,10 +276,10 @@ const getAvailableConnections = async (connectionRequest) => {
|
|
|
276
276
|
url.searchParams.append('fromToken', fromToken);
|
|
277
277
|
}
|
|
278
278
|
if (toChain) {
|
|
279
|
-
url.searchParams.append('
|
|
279
|
+
url.searchParams.append('toChain', toChain);
|
|
280
280
|
}
|
|
281
281
|
if (toToken) {
|
|
282
|
-
url.searchParams.append('
|
|
282
|
+
url.searchParams.append('toToken', toToken);
|
|
283
283
|
}
|
|
284
284
|
const connectionRequestArrayParams = [
|
|
285
285
|
'allowBridges',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Chain
|
|
1
|
+
import type { Chain } from '@lifi/types';
|
|
2
|
+
import type { SDKConfig, SDKOptions } from '../types';
|
|
2
3
|
export default class ConfigService {
|
|
3
4
|
private static instance;
|
|
4
5
|
private readonly config;
|
|
@@ -12,12 +13,12 @@ export default class ConfigService {
|
|
|
12
13
|
* This call immediately returns the current config. It does not make sure that all chain data is already loaded
|
|
13
14
|
* Use this if you need access to basic information like API urls or settings
|
|
14
15
|
*/
|
|
15
|
-
getConfig: () =>
|
|
16
|
+
getConfig: () => SDKConfig;
|
|
16
17
|
/**
|
|
17
18
|
* This call waits for all setup promises to be done.
|
|
18
19
|
* Use this if you need access to chain data (RPCs or multicalls)
|
|
19
20
|
*/
|
|
20
|
-
getConfigAsync: () => Promise<
|
|
21
|
-
updateConfig: (configUpdate: Partial<
|
|
22
|
-
updateChains: (chains: Chain[]) =>
|
|
21
|
+
getConfigAsync: () => Promise<SDKConfig>;
|
|
22
|
+
updateConfig: (configUpdate: Partial<SDKOptions>) => SDKConfig;
|
|
23
|
+
updateChains: (chains: Chain[]) => SDKConfig;
|
|
23
24
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ChainId } from '
|
|
1
|
+
import { ChainId } from '@lifi/types';
|
|
2
2
|
const DefaultExecutionSettings = {
|
|
3
|
-
/* eslint-disable-next-line @typescript-eslint/no-empty-function */
|
|
4
3
|
updateRouteHook: () => { },
|
|
5
4
|
switchChainHook: () => Promise.resolve(undefined),
|
|
6
5
|
acceptExchangeRateUpdateHook: () => Promise.resolve(undefined),
|
|
@@ -36,6 +35,7 @@ class ConfigService {
|
|
|
36
35
|
this.config.defaultExecutionSettings = Object.assign(this.config.defaultExecutionSettings, configUpdate.defaultExecutionSettings);
|
|
37
36
|
// OPTIONS
|
|
38
37
|
this.config.defaultRouteOptions = Object.assign(this.config.defaultRouteOptions, configUpdate.defaultRouteOptions);
|
|
38
|
+
this.config.apiKey = configUpdate.apiKey || this.config.apiKey;
|
|
39
39
|
this.config.userId = configUpdate.userId || this.config.userId;
|
|
40
40
|
this.config.integrator = configUpdate.integrator || this.config.integrator;
|
|
41
41
|
this.config.defaultRouteOptions.integrator =
|
|
@@ -44,7 +44,7 @@ class ConfigService {
|
|
|
44
44
|
this.config.integrator;
|
|
45
45
|
this.config.widgetVersion =
|
|
46
46
|
configUpdate.widgetVersion || this.config.widgetVersion;
|
|
47
|
-
this.config.multisig = configUpdate.
|
|
47
|
+
this.config.multisig = configUpdate.multisig || this.config.multisig;
|
|
48
48
|
return this.config;
|
|
49
49
|
};
|
|
50
50
|
this.updateChains = (chains) => {
|
package/dist/typeguards.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LiFiStep, RoutesRequest, StaticToken } from '@lifi/types';
|
|
2
2
|
export declare const isRoutesRequest: (routesRequest: RoutesRequest) => routesRequest is RoutesRequest;
|
|
3
|
-
export declare const isStep: (step:
|
|
3
|
+
export declare const isStep: (step: LiFiStep) => step is LiFiStep;
|
|
4
4
|
export declare const isToken: (token: StaticToken) => token is StaticToken;
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ChainId, RouteOptions } from '@lifi/types';
|
|
2
|
+
import type { ExecutionSettings, InternalExecutionSettings, MultisigConfig } from '../execution/types';
|
|
3
|
+
import type { BaseProvider } from '../providers/BaseProvider';
|
|
4
|
+
export interface SDKConfig {
|
|
5
|
+
apiUrl: string;
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
rpcs: Record<ChainId, string[]>;
|
|
8
|
+
multicallAddresses: Record<ChainId, string | undefined>;
|
|
9
|
+
defaultExecutionSettings: InternalExecutionSettings;
|
|
10
|
+
defaultRouteOptions: RouteOptions;
|
|
11
|
+
disableVersionCheck?: boolean;
|
|
12
|
+
userId?: string;
|
|
13
|
+
integrator: string;
|
|
14
|
+
widgetVersion?: string;
|
|
15
|
+
multisig?: MultisigConfig;
|
|
16
|
+
providers?: BaseProvider[];
|
|
17
|
+
}
|
|
18
|
+
export interface SDKOptions extends Partial<Omit<SDKConfig, 'defaultExecutionSettings' | 'integrator'>> {
|
|
19
|
+
defaultExecutionSettings?: ExecutionSettings;
|
|
20
|
+
integrator: string;
|
|
21
|
+
}
|
|
22
|
+
export interface TenderlyResponse {
|
|
23
|
+
hash: string;
|
|
24
|
+
block_hash: string;
|
|
25
|
+
block_number: number;
|
|
26
|
+
from: string;
|
|
27
|
+
gas: number;
|
|
28
|
+
gas_price: number;
|
|
29
|
+
gas_fee_cap: number;
|
|
30
|
+
gas_tip_cap: number;
|
|
31
|
+
cumulative_gas_used: number;
|
|
32
|
+
gas_used: number;
|
|
33
|
+
effective_gas_price: number;
|
|
34
|
+
input: string;
|
|
35
|
+
nonce: number;
|
|
36
|
+
to: string;
|
|
37
|
+
index: number;
|
|
38
|
+
value: string;
|
|
39
|
+
access_list: unknown;
|
|
40
|
+
status: boolean;
|
|
41
|
+
addresses: string[];
|
|
42
|
+
contract_ids: string[];
|
|
43
|
+
network_id: string;
|
|
44
|
+
timestamp: string;
|
|
45
|
+
function_selector: string;
|
|
46
|
+
l1_block_number: number;
|
|
47
|
+
l1_timestamp: number;
|
|
48
|
+
deposit_tx: boolean;
|
|
49
|
+
system_tx: boolean;
|
|
50
|
+
mint: number;
|
|
51
|
+
sig: {
|
|
52
|
+
v: string;
|
|
53
|
+
r: string;
|
|
54
|
+
s: string;
|
|
55
|
+
};
|
|
56
|
+
error_message: string;
|
|
57
|
+
method: string;
|
|
58
|
+
decoded_input: unknown;
|
|
59
|
+
call_trace: unknown;
|
|
60
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LiFiStep, Process } from '@lifi/types';
|
|
2
2
|
import { LiFiError } from './errors';
|
|
3
3
|
/**
|
|
4
4
|
* Available MetaMask error codes:
|
|
@@ -31,7 +31,7 @@ import { LiFiError } from './errors';
|
|
|
31
31
|
* https://eips.ethereum.org/EIPS/eip-1474#error-codes
|
|
32
32
|
* https://eips.ethereum.org/EIPS/eip-1193#provider-errors
|
|
33
33
|
*/
|
|
34
|
-
export declare const getTransactionNotSentMessage: (step?:
|
|
35
|
-
export declare const getTransactionFailedMessage: (step:
|
|
36
|
-
export declare const parseError: (e: any, step?:
|
|
34
|
+
export declare const getTransactionNotSentMessage: (step?: LiFiStep, process?: Process) => Promise<string>;
|
|
35
|
+
export declare const getTransactionFailedMessage: (step: LiFiStep, txLink?: string) => Promise<string>;
|
|
36
|
+
export declare const parseError: (e: any, step?: LiFiStep, process?: Process) => Promise<LiFiError>;
|
|
37
37
|
export declare const parseBackendError: (e: any) => Promise<LiFiError>;
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/sdk";
|
|
2
|
-
export declare const version = "3.0.0-alpha.
|
|
2
|
+
export declare const version = "3.0.0-alpha.7";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/sdk';
|
|
2
|
-
export const version = '3.0.0-alpha.
|
|
2
|
+
export const version = '3.0.0-alpha.7';
|