@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,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>;
|
|
@@ -17,6 +17,7 @@ const errors_1 = require("../utils/errors");
|
|
|
17
17
|
* @param step
|
|
18
18
|
* @param switchChainHook
|
|
19
19
|
* @param allowUserInteraction
|
|
20
|
+
* @returns New WalletClient
|
|
20
21
|
*/
|
|
21
22
|
const switchChain = async (walletClient, statusManager, step, switchChainHook, allowUserInteraction) => {
|
|
22
23
|
// 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/cjs/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/cjs/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/cjs/index.js
CHANGED
|
@@ -14,11 +14,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.LiFi = void 0;
|
|
17
|
+
exports.LiFiError = exports.LiFi = void 0;
|
|
18
18
|
// expose types and helpers
|
|
19
|
-
__exportStar(require("
|
|
20
|
-
__exportStar(require("./helpers"), exports);
|
|
19
|
+
__exportStar(require("@lifi/types"), exports);
|
|
21
20
|
var LiFi_1 = require("./LiFi");
|
|
22
21
|
Object.defineProperty(exports, "LiFi", { enumerable: true, get: function () { return LiFi_1.LiFi; } });
|
|
22
|
+
__exportStar(require("./execution"), exports);
|
|
23
|
+
__exportStar(require("./helpers"), exports);
|
|
23
24
|
__exportStar(require("./types"), exports);
|
|
24
25
|
__exportStar(require("./utils/errors"), exports);
|
|
26
|
+
var errors_1 = require("./utils/errors");
|
|
27
|
+
Object.defineProperty(exports, "LiFiError", { enumerable: true, get: function () { return errors_1.LiFiError; } });
|
|
@@ -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,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EVMProvider = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const EVMStepExecutor_1 = require("../execution/EVMStepExecutor");
|
|
6
|
+
const BaseProvider_1 = require("./BaseProvider");
|
|
7
|
+
class EVMProvider extends BaseProvider_1.BaseProvider {
|
|
8
|
+
constructor(options) {
|
|
9
|
+
super();
|
|
10
|
+
this.getWalletClient = options?.getWalletClient;
|
|
11
|
+
}
|
|
12
|
+
isProviderStep(step) {
|
|
13
|
+
const isProviderStep = (0, viem_1.isAddress)(step.action.fromAddress);
|
|
14
|
+
return isProviderStep;
|
|
15
|
+
}
|
|
16
|
+
async getStepExecutor(options) {
|
|
17
|
+
if (!this.getWalletClient) {
|
|
18
|
+
throw new Error(`getWalletClient is not provided.`);
|
|
19
|
+
}
|
|
20
|
+
const walletClient = await this.getWalletClient();
|
|
21
|
+
const executor = new EVMStepExecutor_1.EVMStepExecutor({ walletClient, ...options });
|
|
22
|
+
return executor;
|
|
23
|
+
}
|
|
24
|
+
setOptions(options) {
|
|
25
|
+
this.getWalletClient = options.getWalletClient;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.EVMProvider = EVMProvider;
|
|
@@ -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,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SolanaProvider = void 0;
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
const BaseProvider_1 = require("./BaseProvider");
|
|
6
|
+
class SolanaProvider extends BaseProvider_1.BaseProvider {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
super();
|
|
9
|
+
this.getWalletClient = options?.getWalletClient;
|
|
10
|
+
}
|
|
11
|
+
isProviderStep(step) {
|
|
12
|
+
try {
|
|
13
|
+
const publickKey = new web3_js_1.PublicKey(step.action.fromAddress);
|
|
14
|
+
const isProviderStep = web3_js_1.PublicKey.isOnCurve(publickKey);
|
|
15
|
+
return isProviderStep;
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
async getStepExecutor(options) {
|
|
22
|
+
if (!this.getWalletClient) {
|
|
23
|
+
throw new Error(`getWalletClient is not provided.`);
|
|
24
|
+
}
|
|
25
|
+
const walletClient = await this.getWalletClient();
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
setOptions(options) {
|
|
29
|
+
this.getWalletClient = options.getWalletClient;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.SolanaProvider = SolanaProvider;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/dist/cjs/request.js
CHANGED
|
@@ -14,32 +14,38 @@ exports.requestSettings = {
|
|
|
14
14
|
const request = async (url, options = {
|
|
15
15
|
retries: exports.requestSettings.retries,
|
|
16
16
|
}) => {
|
|
17
|
-
const { userId, integrator, widgetVersion } = ConfigService_1.default.getInstance().getConfig();
|
|
17
|
+
const { userId, integrator, widgetVersion, apiKey } = ConfigService_1.default.getInstance().getConfig();
|
|
18
18
|
options.retries = options.retries ?? exports.requestSettings.retries;
|
|
19
19
|
try {
|
|
20
20
|
if (!options.skipTrackingHeaders) {
|
|
21
|
+
if (apiKey) {
|
|
22
|
+
options.headers = {
|
|
23
|
+
...options?.headers,
|
|
24
|
+
'x-lifi-api-key': apiKey,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
21
27
|
if (userId) {
|
|
22
28
|
options.headers = {
|
|
23
29
|
...options?.headers,
|
|
24
|
-
'
|
|
30
|
+
'x-lifi-userid': userId,
|
|
25
31
|
};
|
|
26
32
|
}
|
|
27
33
|
if (widgetVersion) {
|
|
28
34
|
options.headers = {
|
|
29
35
|
...options?.headers,
|
|
30
|
-
'
|
|
36
|
+
'x-lifi-widget': widgetVersion,
|
|
31
37
|
};
|
|
32
38
|
}
|
|
33
39
|
if (version_1.version) {
|
|
34
40
|
options.headers = {
|
|
35
41
|
...options?.headers,
|
|
36
|
-
'
|
|
42
|
+
'x-lifi-sdk': version_1.version,
|
|
37
43
|
};
|
|
38
44
|
}
|
|
39
45
|
// integrator is mandatory during SDK initialization
|
|
40
46
|
options.headers = {
|
|
41
47
|
...options?.headers,
|
|
42
|
-
'
|
|
48
|
+
'x-lifi-integrator': integrator,
|
|
43
49
|
};
|
|
44
50
|
}
|
|
45
51
|
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>;
|
|
@@ -281,10 +281,10 @@ const getAvailableConnections = async (connectionRequest) => {
|
|
|
281
281
|
url.searchParams.append('fromToken', fromToken);
|
|
282
282
|
}
|
|
283
283
|
if (toChain) {
|
|
284
|
-
url.searchParams.append('
|
|
284
|
+
url.searchParams.append('toChain', toChain);
|
|
285
285
|
}
|
|
286
286
|
if (toToken) {
|
|
287
|
-
url.searchParams.append('
|
|
287
|
+
url.searchParams.append('toToken', toToken);
|
|
288
288
|
}
|
|
289
289
|
const connectionRequestArrayParams = [
|
|
290
290
|
'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,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const types_1 = require("
|
|
3
|
+
const types_1 = require("@lifi/types");
|
|
4
4
|
const DefaultExecutionSettings = {
|
|
5
|
-
/* eslint-disable-next-line @typescript-eslint/no-empty-function */
|
|
6
5
|
updateRouteHook: () => { },
|
|
7
6
|
switchChainHook: () => Promise.resolve(undefined),
|
|
8
7
|
acceptExchangeRateUpdateHook: () => Promise.resolve(undefined),
|
|
@@ -38,6 +37,7 @@ class ConfigService {
|
|
|
38
37
|
this.config.defaultExecutionSettings = Object.assign(this.config.defaultExecutionSettings, configUpdate.defaultExecutionSettings);
|
|
39
38
|
// OPTIONS
|
|
40
39
|
this.config.defaultRouteOptions = Object.assign(this.config.defaultRouteOptions, configUpdate.defaultRouteOptions);
|
|
40
|
+
this.config.apiKey = configUpdate.apiKey || this.config.apiKey;
|
|
41
41
|
this.config.userId = configUpdate.userId || this.config.userId;
|
|
42
42
|
this.config.integrator = configUpdate.integrator || this.config.integrator;
|
|
43
43
|
this.config.defaultRouteOptions.integrator =
|
|
@@ -46,7 +46,7 @@ class ConfigService {
|
|
|
46
46
|
this.config.integrator;
|
|
47
47
|
this.config.widgetVersion =
|
|
48
48
|
configUpdate.widgetVersion || this.config.widgetVersion;
|
|
49
|
-
this.config.multisig = configUpdate.
|
|
49
|
+
this.config.multisig = configUpdate.multisig || this.config.multisig;
|
|
50
50
|
return this.config;
|
|
51
51
|
};
|
|
52
52
|
this.updateChains = (chains) => {
|
package/dist/cjs/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/cjs/types/index.js
CHANGED
|
@@ -14,9 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.LiFiError = void 0;
|
|
18
|
-
__exportStar(require("@lifi/types"), exports);
|
|
19
|
-
var errors_1 = require("../utils/errors");
|
|
20
|
-
Object.defineProperty(exports, "LiFiError", { enumerable: true, get: function () { return errors_1.LiFiError; } });
|
|
21
17
|
__exportStar(require("./abi"), exports);
|
|
22
|
-
__exportStar(require("./internal
|
|
18
|
+
__exportStar(require("./internal"), exports);
|
|
@@ -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
|
+
}
|
|
@@ -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/cjs/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/cjs/version.js
CHANGED
package/dist/connectors.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { ChainId } from '@lifi/types';
|
|
1
2
|
import type { PublicClient } from 'viem';
|
|
2
3
|
import type { Chain } from 'viem/chains';
|
|
3
|
-
import type { ChainId } from './types';
|
|
4
4
|
export declare const getChainById: (chainId: ChainId) => Chain | undefined;
|
|
5
5
|
export declare const getRpcUrl: (chainId: ChainId) => Promise<string>;
|
|
6
6
|
export declare const getRpcUrls: (chainId: ChainId) => Promise<string[]>;
|