@lifi/sdk 2.0.0-beta.3 → 2.0.0-beta.5
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 → LiFi.d.ts} +4 -60
- package/dist/{Lifi.js → LiFi.js} +3 -213
- package/dist/cjs/{Lifi.d.ts → LiFi.d.ts} +4 -60
- package/dist/cjs/{Lifi.js → LiFi.js} +5 -214
- package/dist/cjs/execution/RouteExecutionManager.d.ts +65 -0
- package/dist/cjs/execution/RouteExecutionManager.js +220 -0
- package/dist/cjs/execution/{ExecutionManager.d.ts → StepExecutionManager.d.ts} +1 -1
- package/dist/cjs/execution/{ExecutionManager.js → StepExecutionManager.js} +3 -3
- package/dist/cjs/execution/StepExecutor.d.ts +2 -2
- package/dist/cjs/execution/StepExecutor.js +4 -4
- package/dist/cjs/helpers.d.ts +1 -1
- package/dist/cjs/helpers.js +33 -1
- package/dist/cjs/index.d.ts +1 -2
- package/dist/cjs/index.js +3 -6
- package/dist/cjs/services/ApiService.d.ts +1 -1
- package/dist/cjs/services/ApiService.js +10 -8
- package/dist/cjs/services/ConfigService.js +6 -1
- package/dist/cjs/types/internal.types.d.ts +9 -7
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/execution/RouteExecutionManager.d.ts +65 -0
- package/dist/execution/RouteExecutionManager.js +213 -0
- package/dist/execution/{ExecutionManager.d.ts → StepExecutionManager.d.ts} +1 -1
- package/dist/execution/{ExecutionManager.js → StepExecutionManager.js} +1 -1
- package/dist/execution/StepExecutor.d.ts +2 -2
- package/dist/execution/StepExecutor.js +4 -4
- package/dist/helpers.d.ts +1 -1
- package/dist/helpers.js +30 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -3
- package/dist/services/ApiService.d.ts +1 -1
- package/dist/services/ApiService.js +10 -8
- package/dist/services/ConfigService.js +7 -1
- package/dist/types/internal.types.d.ts +9 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +9 -9
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import ConfigService from '../services/ConfigService';
|
|
2
|
+
import { ValidationError } from '../utils/errors';
|
|
3
|
+
import { handlePreRestart } from '../utils/preRestart';
|
|
4
|
+
import { StatusManager } from './StatusManager';
|
|
5
|
+
import { StepExecutor } from './StepExecutor';
|
|
6
|
+
export class RouteExecutionManager {
|
|
7
|
+
constructor(configUpdate) {
|
|
8
|
+
this.executionDictionary = {};
|
|
9
|
+
this.executionPromiseDictionary = {};
|
|
10
|
+
/**
|
|
11
|
+
* Execute a route.
|
|
12
|
+
* @param {Signer} signer - The signer required to send the transactions.
|
|
13
|
+
* @param {Route} route - The route that should be executed. Cannot be an active route.
|
|
14
|
+
* @param {ExecutionSettings} settings - An object containing settings and callbacks.
|
|
15
|
+
* @return {Promise<Route>} The executed route.
|
|
16
|
+
* @throws {LifiError} Throws a LifiError if the execution fails.
|
|
17
|
+
*/
|
|
18
|
+
this.executeRoute = async (signer, route, settings) => {
|
|
19
|
+
// Deep clone to prevent side effects
|
|
20
|
+
const clonedRoute = structuredClone(route);
|
|
21
|
+
let executionPromise = this.executionPromiseDictionary[clonedRoute.id];
|
|
22
|
+
// Check if route is already running
|
|
23
|
+
if (executionPromise) {
|
|
24
|
+
return executionPromise;
|
|
25
|
+
}
|
|
26
|
+
executionPromise = this.executeSteps(signer, clonedRoute, settings);
|
|
27
|
+
this.executionPromiseDictionary[clonedRoute.id] = executionPromise;
|
|
28
|
+
return executionPromise;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Resume the execution of a route that has been stopped or had an error while executing.
|
|
32
|
+
* @param {Signer} signer - The signer required to send the transactions.
|
|
33
|
+
* @param {Route} route - The route that is to be executed. Cannot be an active route.
|
|
34
|
+
* @param {ExecutionSettings} settings - An object containing settings and callbacks.
|
|
35
|
+
* @return {Promise<Route>} The executed route.
|
|
36
|
+
* @throws {LifiError} Throws a LifiError if the execution fails.
|
|
37
|
+
*/
|
|
38
|
+
this.resumeRoute = async (signer, route, settings) => {
|
|
39
|
+
// Deep clone to prevent side effects
|
|
40
|
+
const clonedRoute = structuredClone(route);
|
|
41
|
+
const execution = this.executionDictionary[clonedRoute.id];
|
|
42
|
+
if (execution) {
|
|
43
|
+
const executionHalted = execution.executors.some((executor) => executor.executionStopped);
|
|
44
|
+
if (!executionHalted) {
|
|
45
|
+
// Check if we want to resume route execution in the background
|
|
46
|
+
this.updateRouteExecution(route, {
|
|
47
|
+
executeInBackground: settings?.executeInBackground,
|
|
48
|
+
});
|
|
49
|
+
const executionPromise = this.executionPromiseDictionary[clonedRoute.id];
|
|
50
|
+
return executionPromise ?? clonedRoute;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
handlePreRestart(clonedRoute);
|
|
54
|
+
const executionPromise = this.executeSteps(signer, clonedRoute, settings);
|
|
55
|
+
this.executionPromiseDictionary[clonedRoute.id] = executionPromise;
|
|
56
|
+
return executionPromise;
|
|
57
|
+
};
|
|
58
|
+
this.executeSteps = async (signer, route, settings) => {
|
|
59
|
+
const config = this.configService.getConfig();
|
|
60
|
+
const execution = {
|
|
61
|
+
route,
|
|
62
|
+
executors: [],
|
|
63
|
+
settings: { ...config.defaultExecutionSettings, ...settings },
|
|
64
|
+
};
|
|
65
|
+
this.executionDictionary[route.id] = execution;
|
|
66
|
+
const statusManager = new StatusManager(route, execution.settings, (route) => {
|
|
67
|
+
if (this.executionDictionary[route.id]) {
|
|
68
|
+
execution.route = route;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
// Loop over steps and execute them
|
|
72
|
+
for (let index = 0; index < route.steps.length; index++) {
|
|
73
|
+
const execution = this.executionDictionary[route.id];
|
|
74
|
+
// Check if execution has stopped in the meantime
|
|
75
|
+
if (!execution) {
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
const step = route.steps[index];
|
|
79
|
+
const previousStep = route.steps[index - 1];
|
|
80
|
+
// Check if the step is already done
|
|
81
|
+
//
|
|
82
|
+
if (step.execution?.status === 'DONE') {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
// Update amount using output of previous execution. In the future this should be handled by calling `updateRoute`
|
|
86
|
+
if (previousStep?.execution?.toAmount) {
|
|
87
|
+
step.action.fromAmount = previousStep.execution.toAmount;
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
const stepExecutor = new StepExecutor(statusManager, execution.settings);
|
|
91
|
+
execution.executors.push(stepExecutor);
|
|
92
|
+
// Check if we want to execute this step in the background
|
|
93
|
+
this.updateRouteExecution(route, execution.settings);
|
|
94
|
+
const executedStep = await stepExecutor.executeStep(signer, step);
|
|
95
|
+
// We may reach this point if user interaction isn't allowed. We want to stop execution until we resume it
|
|
96
|
+
if (executedStep.execution?.status !== 'DONE') {
|
|
97
|
+
this.stopExecution(route);
|
|
98
|
+
}
|
|
99
|
+
// Execution stopped during the current step, we don't want to continue to the next step so we return already
|
|
100
|
+
if (stepExecutor.executionStopped) {
|
|
101
|
+
return route;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch (e) {
|
|
105
|
+
this.stopExecution(route);
|
|
106
|
+
throw e;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// Clean up after the execution
|
|
110
|
+
delete this.executionDictionary[route.id];
|
|
111
|
+
return route;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Updates route execution to background or foreground state.
|
|
115
|
+
* @param {Route} route - A route that is currently in execution.
|
|
116
|
+
* @param {boolean} settings - An object with execution settings.
|
|
117
|
+
*/
|
|
118
|
+
this.updateRouteExecution = (route, settings) => {
|
|
119
|
+
const execution = this.executionDictionary[route.id];
|
|
120
|
+
if (!execution) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
for (const executor of execution.executors) {
|
|
124
|
+
executor.setInteraction({
|
|
125
|
+
allowInteraction: !settings.executeInBackground,
|
|
126
|
+
allowUpdates: true,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
// Update active route settings so we know what the current state of execution is
|
|
130
|
+
execution.settings = {
|
|
131
|
+
...execution.settings,
|
|
132
|
+
...settings,
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Update the ExecutionSettings for an active route.
|
|
137
|
+
* @param {ExecutionSettings} settings - An object with execution settings.
|
|
138
|
+
* @param {Route} route - The active route that gets the new execution settings.
|
|
139
|
+
* @throws {ValidationError} Throws a ValidationError if parameters are invalid.
|
|
140
|
+
*/
|
|
141
|
+
this.updateExecutionSettings = (settings, route) => {
|
|
142
|
+
const execution = this.executionDictionary[route.id];
|
|
143
|
+
if (!execution) {
|
|
144
|
+
throw new ValidationError("Can't set ExecutionSettings for the inactive route.");
|
|
145
|
+
}
|
|
146
|
+
const config = this.configService.getConfig();
|
|
147
|
+
execution.settings = {
|
|
148
|
+
...config.defaultExecutionSettings,
|
|
149
|
+
...settings,
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Executes a route until a user interaction is necessary (signing transactions, etc.) and then halts until the route is resumed.
|
|
154
|
+
* @param {Route} route - A route that is currently in execution.
|
|
155
|
+
* @deprecated use updateRouteExecution instead.
|
|
156
|
+
*/
|
|
157
|
+
this.moveExecutionToBackground = (route) => {
|
|
158
|
+
const execution = this.executionDictionary[route.id];
|
|
159
|
+
if (!execution) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
for (const executor of execution.executors) {
|
|
163
|
+
executor.setInteraction({ allowInteraction: false, allowUpdates: true });
|
|
164
|
+
}
|
|
165
|
+
execution.settings = {
|
|
166
|
+
...execution.settings,
|
|
167
|
+
executeInBackground: true,
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* Stops the execution of an active route.
|
|
172
|
+
* @param {Route} route - A route that is currently in execution.
|
|
173
|
+
* @return {Route} The stopped route.
|
|
174
|
+
*/
|
|
175
|
+
this.stopExecution = (route) => {
|
|
176
|
+
const execution = this.executionDictionary[route.id];
|
|
177
|
+
if (!execution) {
|
|
178
|
+
return route;
|
|
179
|
+
}
|
|
180
|
+
for (const executor of execution.executors) {
|
|
181
|
+
executor.setInteraction({
|
|
182
|
+
allowInteraction: false,
|
|
183
|
+
allowUpdates: false,
|
|
184
|
+
stopExecution: true,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
delete this.executionDictionary[route.id];
|
|
188
|
+
return route;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* Get the list of active routes.
|
|
192
|
+
* @return {Route[]} A list of routes.
|
|
193
|
+
*/
|
|
194
|
+
this.getActiveRoutes = () => {
|
|
195
|
+
return Object.values(this.executionDictionary)
|
|
196
|
+
.map((dict) => dict?.route)
|
|
197
|
+
.filter(Boolean);
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* Return the current route information for given route. The route has to be active.
|
|
201
|
+
* @param {Route} route - A route object.
|
|
202
|
+
* @return {Route} The updated route.
|
|
203
|
+
*/
|
|
204
|
+
this.getActiveRoute = (route) => {
|
|
205
|
+
return this.executionDictionary[route.id]?.route;
|
|
206
|
+
};
|
|
207
|
+
this.configService = ConfigService.getInstance();
|
|
208
|
+
if (configUpdate) {
|
|
209
|
+
// Update API urls before we request chains
|
|
210
|
+
this.configService.updateConfig(configUpdate);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Execution } from '@lifi/types';
|
|
2
2
|
import { ExecutionParams } from '../types';
|
|
3
|
-
export declare class
|
|
3
|
+
export declare class StepExecutionManager {
|
|
4
4
|
allowUserInteraction: boolean;
|
|
5
5
|
allowInteraction: (value: boolean) => void;
|
|
6
6
|
execute: ({ signer, step, statusManager, settings, }: ExecutionParams) => Promise<Execution>;
|
|
@@ -9,7 +9,7 @@ import { isZeroAddress, personalizeStep } from '../utils/utils';
|
|
|
9
9
|
import { stepComparison } from './stepComparison';
|
|
10
10
|
import { switchChain } from './switchChain';
|
|
11
11
|
import { getSubstatusMessage, waitForReceivingTransaction } from './utils';
|
|
12
|
-
export class
|
|
12
|
+
export class StepExecutionManager {
|
|
13
13
|
constructor() {
|
|
14
14
|
this.allowUserInteraction = true;
|
|
15
15
|
this.allowInteraction = (value) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Signer } from 'ethers';
|
|
2
2
|
import { InteractionSettings, InternalExecutionSettings, Step } from '../types';
|
|
3
|
-
import { ExecutionManager } from './ExecutionManager';
|
|
4
3
|
import { StatusManager } from './StatusManager';
|
|
4
|
+
import { StepExecutionManager } from './StepExecutionManager';
|
|
5
5
|
export declare class StepExecutor {
|
|
6
|
-
|
|
6
|
+
stepExecutionManager: StepExecutionManager;
|
|
7
7
|
statusManager: StatusManager;
|
|
8
8
|
settings: InternalExecutionSettings;
|
|
9
9
|
allowUserInteraction: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StepExecutionManager } from './StepExecutionManager';
|
|
2
2
|
import { switchChain } from './switchChain';
|
|
3
3
|
// Please be careful when changing the defaults as it may break the behavior (e.g., background execution)
|
|
4
4
|
const defaultInteractionSettings = {
|
|
@@ -16,7 +16,7 @@ export class StepExecutor {
|
|
|
16
16
|
...settings,
|
|
17
17
|
};
|
|
18
18
|
this.allowUserInteraction = interactionSettings.allowInteraction;
|
|
19
|
-
this.
|
|
19
|
+
this.stepExecutionManager.allowInteraction(interactionSettings.allowInteraction);
|
|
20
20
|
this.statusManager.allowUpdates(interactionSettings.allowUpdates);
|
|
21
21
|
this.executionStopped = interactionSettings.stopExecution;
|
|
22
22
|
};
|
|
@@ -40,10 +40,10 @@ export class StepExecutor {
|
|
|
40
40
|
settings: this.settings,
|
|
41
41
|
statusManager: this.statusManager,
|
|
42
42
|
};
|
|
43
|
-
await this.
|
|
43
|
+
await this.stepExecutionManager.execute(parameters);
|
|
44
44
|
return step;
|
|
45
45
|
};
|
|
46
|
-
this.
|
|
46
|
+
this.stepExecutionManager = new StepExecutionManager();
|
|
47
47
|
this.statusManager = statusManager;
|
|
48
48
|
this.settings = settings;
|
|
49
49
|
}
|
package/dist/helpers.d.ts
CHANGED
|
@@ -27,4 +27,4 @@ export declare const convertQuoteToRoute: (step: Step) => Route;
|
|
|
27
27
|
export declare const requestSettings: {
|
|
28
28
|
retries: number;
|
|
29
29
|
};
|
|
30
|
-
export declare const request: <T = Response>(url:
|
|
30
|
+
export declare const request: <T = Response>(url: RequestInfo | URL, options?: RequestInit, retries?: number) => Promise<T>;
|
package/dist/helpers.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import ConfigService from './services/ConfigService';
|
|
1
2
|
import { HTTPError, ValidationError } from './utils/errors';
|
|
2
3
|
import { sleep } from './utils/utils';
|
|
3
4
|
import { name, version } from './version';
|
|
@@ -101,6 +102,7 @@ export const convertQuoteToRoute = (step) => {
|
|
|
101
102
|
toAmountUSD: step.estimate.toAmountUSD,
|
|
102
103
|
steps: [lifiStep],
|
|
103
104
|
toAmountMin: step.estimate.toAmountMin,
|
|
105
|
+
insurance: { state: 'NOT_INSURABLE', feeAmountUsd: '0' },
|
|
104
106
|
};
|
|
105
107
|
return route;
|
|
106
108
|
};
|
|
@@ -108,8 +110,35 @@ export const requestSettings = {
|
|
|
108
110
|
retries: 1,
|
|
109
111
|
};
|
|
110
112
|
export const request = async (url, options, retries = requestSettings.retries) => {
|
|
113
|
+
const { userId, integrator, widgetVersion } = ConfigService.getInstance().getConfig();
|
|
111
114
|
try {
|
|
112
|
-
const
|
|
115
|
+
const updatedOptions = {
|
|
116
|
+
...(options ?? {}),
|
|
117
|
+
};
|
|
118
|
+
if (userId) {
|
|
119
|
+
updatedOptions.headers = {
|
|
120
|
+
...options?.headers,
|
|
121
|
+
'X-LIFI-UserId': userId,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
if (widgetVersion) {
|
|
125
|
+
updatedOptions.headers = {
|
|
126
|
+
...options?.headers,
|
|
127
|
+
'X-LIFI-Widget': widgetVersion,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
if (version) {
|
|
131
|
+
updatedOptions.headers = {
|
|
132
|
+
...options?.headers,
|
|
133
|
+
'X-LIFI-SDK': version,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
// integrator is mandatory during SDK initialization
|
|
137
|
+
updatedOptions.headers = {
|
|
138
|
+
...options?.headers,
|
|
139
|
+
'X-LIFI-Integrator': integrator,
|
|
140
|
+
};
|
|
141
|
+
const response = await fetch(url, updatedOptions);
|
|
113
142
|
if (!response.ok) {
|
|
114
143
|
throw new HTTPError(response);
|
|
115
144
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { ChainId, ChainKey, ExtendedChain, PossibilitiesRequest, PossibilitiesRe
|
|
|
3
3
|
declare const _default: {
|
|
4
4
|
getChains: (options?: RequestOptions | undefined) => Promise<ExtendedChain[]>;
|
|
5
5
|
getContractCallQuote: (requestConfig: ContractCallQuoteRequest, options?: RequestOptions | undefined) => Promise<Step>;
|
|
6
|
-
getGasRecommendation: (
|
|
6
|
+
getGasRecommendation: ({ chainId, fromChain, fromToken }: GasRecommendationRequest, options?: RequestOptions | undefined) => Promise<GasRecommendationResponse>;
|
|
7
7
|
getPossibilities: (requestConfig?: PossibilitiesRequest | undefined, options?: RequestOptions | undefined) => Promise<PossibilitiesResponse>;
|
|
8
8
|
getQuote: (requestConfig: QuoteRequest, options?: RequestOptions | undefined) => Promise<Step>;
|
|
9
9
|
getRoutes: (requestConfig: RoutesRequest, options?: RequestOptions | undefined) => Promise<RoutesResponse>;
|
|
@@ -272,18 +272,20 @@ const getTokens = async (requestConfig, options) => {
|
|
|
272
272
|
});
|
|
273
273
|
return response;
|
|
274
274
|
};
|
|
275
|
-
const getGasRecommendation = async (
|
|
275
|
+
const getGasRecommendation = async ({ chainId, fromChain, fromToken }, options) => {
|
|
276
276
|
const config = ConfigService.getInstance().getConfig();
|
|
277
|
-
|
|
278
|
-
delete requestConfig[key]);
|
|
279
|
-
if (!requestConfig.chainId) {
|
|
277
|
+
if (!chainId) {
|
|
280
278
|
throw new ValidationError('Required parameter "chainId" is missing.');
|
|
281
279
|
}
|
|
280
|
+
const url = new URL(`${config.apiUrl}/gas/suggestion/${chainId}`);
|
|
281
|
+
if (fromChain) {
|
|
282
|
+
url.searchParams.append('fromChain', fromChain);
|
|
283
|
+
}
|
|
284
|
+
if (fromToken) {
|
|
285
|
+
url.searchParams.append('fromToken', fromToken);
|
|
286
|
+
}
|
|
282
287
|
try {
|
|
283
|
-
const response = await request(
|
|
284
|
-
fromChain: requestConfig.fromChain,
|
|
285
|
-
fromToken: requestConfig.fromToken,
|
|
286
|
-
})}`, {
|
|
288
|
+
const response = await request(url, {
|
|
287
289
|
signal: options?.signal,
|
|
288
290
|
});
|
|
289
291
|
return response;
|
|
@@ -8,7 +8,7 @@ const DefaultExecutionSettings = {
|
|
|
8
8
|
infiniteApproval: false,
|
|
9
9
|
executeInBackground: false,
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
class ConfigService {
|
|
12
12
|
constructor() {
|
|
13
13
|
this.resolveSetupPromise = undefined;
|
|
14
14
|
/**
|
|
@@ -37,6 +37,10 @@ export default class ConfigService {
|
|
|
37
37
|
this.config.defaultExecutionSettings = Object.assign(this.config.defaultExecutionSettings, configUpdate.defaultExecutionSettings);
|
|
38
38
|
// OPTIONS
|
|
39
39
|
this.config.defaultRouteOptions = Object.assign(this.config.defaultRouteOptions, configUpdate.defaultRouteOptions);
|
|
40
|
+
this.config.userId = configUpdate.userId || this.config.userId;
|
|
41
|
+
this.config.integrator = configUpdate.integrator || this.config.integrator;
|
|
42
|
+
this.config.widgetVersion =
|
|
43
|
+
configUpdate.widgetVersion || this.config.widgetVersion;
|
|
40
44
|
return this.config;
|
|
41
45
|
};
|
|
42
46
|
this.updateChains = (chains) => {
|
|
@@ -85,5 +89,7 @@ ConfigService.getDefaultConfig = () => {
|
|
|
85
89
|
defaultRouteOptions: {
|
|
86
90
|
integrator: 'lifi-sdk',
|
|
87
91
|
},
|
|
92
|
+
integrator: 'lifi-sdk',
|
|
88
93
|
};
|
|
89
94
|
};
|
|
95
|
+
export default ConfigService;
|
|
@@ -30,6 +30,9 @@ export type Config = {
|
|
|
30
30
|
defaultExecutionSettings: InternalExecutionSettings;
|
|
31
31
|
defaultRouteOptions: RouteOptions;
|
|
32
32
|
disableVersionCheck?: boolean;
|
|
33
|
+
userId?: string;
|
|
34
|
+
integrator: string;
|
|
35
|
+
widgetVersion?: string;
|
|
33
36
|
};
|
|
34
37
|
export type ConfigUpdate = {
|
|
35
38
|
apiUrl?: string;
|
|
@@ -38,6 +41,9 @@ export type ConfigUpdate = {
|
|
|
38
41
|
defaultExecutionSettings?: ExecutionSettings;
|
|
39
42
|
defaultRouteOptions?: RouteOptions;
|
|
40
43
|
disableVersionCheck?: boolean;
|
|
44
|
+
userId?: string;
|
|
45
|
+
integrator: string;
|
|
46
|
+
widgetVersion?: string;
|
|
41
47
|
};
|
|
42
48
|
export type SwitchChainHook = (requiredChainId: number) => Promise<Signer | undefined>;
|
|
43
49
|
export interface AcceptSlippageUpdateHookParams {
|
|
@@ -54,7 +60,7 @@ export interface ExchangeRateUpdateParams {
|
|
|
54
60
|
newToAmount: string;
|
|
55
61
|
}
|
|
56
62
|
export type AcceptExchangeRateUpdateHook = (params: ExchangeRateUpdateParams) => Promise<boolean | undefined>;
|
|
57
|
-
export interface
|
|
63
|
+
export interface RouteExecutionData {
|
|
58
64
|
route: Route;
|
|
59
65
|
executors: StepExecutor[];
|
|
60
66
|
settings: InternalExecutionSettings;
|
|
@@ -71,12 +77,8 @@ export interface InternalExecutionSettings {
|
|
|
71
77
|
export type EnforcedObjectProperties<T> = T & {
|
|
72
78
|
[P in keyof T]-?: T[P];
|
|
73
79
|
};
|
|
74
|
-
export
|
|
75
|
-
|
|
76
|
-
executionData: ExecutionData;
|
|
77
|
-
executionPromise: Promise<Route>;
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
+
export type RouteExecutionDictionary = Partial<Record<string, RouteExecutionData>>;
|
|
81
|
+
export type RouteExecutionPromiseDictionary = Partial<Record<string, Promise<Route>>>;
|
|
80
82
|
export type RevokeTokenData = {
|
|
81
83
|
token: Token;
|
|
82
84
|
approvalAddress: string;
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/sdk";
|
|
2
|
-
export declare const version = "2.0.0-beta.
|
|
2
|
+
export declare const version = "2.0.0-beta.5";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/sdk';
|
|
2
|
-
export const version = '2.0.0-beta.
|
|
2
|
+
export const version = '2.0.0-beta.5';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/sdk",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.5",
|
|
4
4
|
"description": "LI.FI Any-to-Any Cross-Chain-Swap SDK",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"dependencies": {
|
|
77
77
|
"@ethersproject/abi": "^5.7.0",
|
|
78
78
|
"@ethersproject/contracts": "^5.7.0",
|
|
79
|
-
"@lifi/types": "^2.
|
|
79
|
+
"@lifi/types": "^2.5.2",
|
|
80
80
|
"bignumber.js": "^9.1.1",
|
|
81
81
|
"eth-rpc-errors": "^4.0.3",
|
|
82
82
|
"ethers": "^5.7.2"
|
|
@@ -84,23 +84,23 @@
|
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@commitlint/cli": "^17.4.4",
|
|
86
86
|
"@commitlint/config-conventional": "^17.4.4",
|
|
87
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
88
|
-
"@typescript-eslint/parser": "^5.
|
|
89
|
-
"@vitest/coverage-c8": "^0.29.
|
|
87
|
+
"@typescript-eslint/eslint-plugin": "^5.55.0",
|
|
88
|
+
"@typescript-eslint/parser": "^5.55.0",
|
|
89
|
+
"@vitest/coverage-c8": "^0.29.3",
|
|
90
90
|
"cross-fetch": "^3.1.5",
|
|
91
|
-
"eslint": "^8.
|
|
91
|
+
"eslint": "^8.36.0",
|
|
92
92
|
"eslint-config-prettier": "^8.7.0",
|
|
93
93
|
"eslint-plugin-prettier": "^4.2.1",
|
|
94
94
|
"husky": "^8.0.3",
|
|
95
|
-
"lint-staged": "^13.
|
|
95
|
+
"lint-staged": "^13.2.0",
|
|
96
96
|
"msw": "1.0.1",
|
|
97
97
|
"npm-run-all": "^4.1.5",
|
|
98
98
|
"pinst": "^3.0.0",
|
|
99
99
|
"prettier": "^2.8.4",
|
|
100
100
|
"standard-version": "^9.5.0",
|
|
101
101
|
"ts-loader": "^9.4.2",
|
|
102
|
-
"typescript": "^
|
|
103
|
-
"vitest": "^0.29.
|
|
102
|
+
"typescript": "^5.0.2",
|
|
103
|
+
"vitest": "^0.29.3"
|
|
104
104
|
},
|
|
105
105
|
"directories": {
|
|
106
106
|
"test": "test"
|