@lifi/sdk 2.2.0 → 2.2.2
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/cjs/services/ApiService.js +38 -48
- package/dist/cjs/services/ConfigService.js +4 -0
- package/dist/cjs/types/internal.types.d.ts +2 -3
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/services/ApiService.js +38 -48
- package/dist/services/ConfigService.js +4 -0
- package/dist/types/internal.types.d.ts +2 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -7
|
@@ -64,7 +64,6 @@ const getToken = async (chain, token, options) => {
|
|
|
64
64
|
};
|
|
65
65
|
const getQuote = async (requestConfig, options) => {
|
|
66
66
|
const config = ConfigService_1.default.getInstance().getConfig();
|
|
67
|
-
// validation
|
|
68
67
|
const requiredParameters = [
|
|
69
68
|
'fromChain',
|
|
70
69
|
'fromToken',
|
|
@@ -79,27 +78,17 @@ const getQuote = async (requestConfig, options) => {
|
|
|
79
78
|
}
|
|
80
79
|
});
|
|
81
80
|
// apply defaults
|
|
82
|
-
requestConfig.order
|
|
83
|
-
requestConfig.slippage =
|
|
84
|
-
|
|
85
|
-
requestConfig.
|
|
86
|
-
|
|
87
|
-
requestConfig.
|
|
88
|
-
|
|
89
|
-
requestConfig.
|
|
90
|
-
requestConfig.
|
|
91
|
-
|
|
92
|
-
requestConfig.
|
|
93
|
-
requestConfig.denyBridges || config.defaultRouteOptions.bridges?.deny;
|
|
94
|
-
requestConfig.preferBridges =
|
|
95
|
-
requestConfig.preferBridges || config.defaultRouteOptions.bridges?.prefer;
|
|
96
|
-
requestConfig.allowExchanges =
|
|
97
|
-
requestConfig.allowExchanges || config.defaultRouteOptions.exchanges?.allow;
|
|
98
|
-
requestConfig.denyExchanges =
|
|
99
|
-
requestConfig.denyExchanges || config.defaultRouteOptions.exchanges?.deny;
|
|
100
|
-
requestConfig.preferExchanges =
|
|
101
|
-
requestConfig.preferExchanges ||
|
|
102
|
-
config.defaultRouteOptions.exchanges?.prefer;
|
|
81
|
+
requestConfig.order || (requestConfig.order = config.defaultRouteOptions.order);
|
|
82
|
+
requestConfig.slippage || (requestConfig.slippage = config.defaultRouteOptions.slippage);
|
|
83
|
+
requestConfig.integrator || (requestConfig.integrator = config.defaultRouteOptions.integrator);
|
|
84
|
+
requestConfig.referrer || (requestConfig.referrer = config.defaultRouteOptions.referrer);
|
|
85
|
+
requestConfig.fee || (requestConfig.fee = config.defaultRouteOptions.fee);
|
|
86
|
+
requestConfig.allowBridges || (requestConfig.allowBridges = config.defaultRouteOptions.bridges?.allow);
|
|
87
|
+
requestConfig.denyBridges || (requestConfig.denyBridges = config.defaultRouteOptions.bridges?.deny);
|
|
88
|
+
requestConfig.preferBridges || (requestConfig.preferBridges = config.defaultRouteOptions.bridges?.prefer);
|
|
89
|
+
requestConfig.allowExchanges || (requestConfig.allowExchanges = config.defaultRouteOptions.exchanges?.allow);
|
|
90
|
+
requestConfig.denyExchanges || (requestConfig.denyExchanges = config.defaultRouteOptions.exchanges?.deny);
|
|
91
|
+
requestConfig.preferExchanges || (requestConfig.preferExchanges = config.defaultRouteOptions.exchanges?.prefer);
|
|
103
92
|
Object.keys(requestConfig).forEach((key) => !requestConfig[key] &&
|
|
104
93
|
delete requestConfig[key]);
|
|
105
94
|
try {
|
|
@@ -133,26 +122,16 @@ const getContractCallQuote = async (requestConfig, options) => {
|
|
|
133
122
|
});
|
|
134
123
|
// apply defaults
|
|
135
124
|
// option.order is not used in this endpoint
|
|
136
|
-
requestConfig.slippage =
|
|
137
|
-
|
|
138
|
-
requestConfig.
|
|
139
|
-
|
|
140
|
-
requestConfig.
|
|
141
|
-
|
|
142
|
-
requestConfig.
|
|
143
|
-
requestConfig.
|
|
144
|
-
|
|
145
|
-
requestConfig.
|
|
146
|
-
requestConfig.denyBridges || config.defaultRouteOptions.bridges?.deny;
|
|
147
|
-
requestConfig.preferBridges =
|
|
148
|
-
requestConfig.preferBridges || config.defaultRouteOptions.bridges?.prefer;
|
|
149
|
-
requestConfig.allowExchanges =
|
|
150
|
-
requestConfig.allowExchanges || config.defaultRouteOptions.exchanges?.allow;
|
|
151
|
-
requestConfig.denyExchanges =
|
|
152
|
-
requestConfig.denyExchanges || config.defaultRouteOptions.exchanges?.deny;
|
|
153
|
-
requestConfig.preferExchanges =
|
|
154
|
-
requestConfig.preferExchanges ||
|
|
155
|
-
config.defaultRouteOptions.exchanges?.prefer;
|
|
125
|
+
requestConfig.slippage || (requestConfig.slippage = config.defaultRouteOptions.slippage);
|
|
126
|
+
requestConfig.integrator || (requestConfig.integrator = config.defaultRouteOptions.integrator);
|
|
127
|
+
requestConfig.referrer || (requestConfig.referrer = config.defaultRouteOptions.referrer);
|
|
128
|
+
requestConfig.fee || (requestConfig.fee = config.defaultRouteOptions.fee);
|
|
129
|
+
requestConfig.allowBridges || (requestConfig.allowBridges = config.defaultRouteOptions.bridges?.allow);
|
|
130
|
+
requestConfig.denyBridges || (requestConfig.denyBridges = config.defaultRouteOptions.bridges?.deny);
|
|
131
|
+
requestConfig.preferBridges || (requestConfig.preferBridges = config.defaultRouteOptions.bridges?.prefer);
|
|
132
|
+
requestConfig.allowExchanges || (requestConfig.allowExchanges = config.defaultRouteOptions.exchanges?.allow);
|
|
133
|
+
requestConfig.denyExchanges || (requestConfig.denyExchanges = config.defaultRouteOptions.exchanges?.deny);
|
|
134
|
+
requestConfig.preferExchanges || (requestConfig.preferExchanges = config.defaultRouteOptions.exchanges?.prefer);
|
|
156
135
|
// send request
|
|
157
136
|
try {
|
|
158
137
|
const response = await (0, request_1.request)(`${config.apiUrl}/quote/contractCall`, {
|
|
@@ -292,7 +271,7 @@ const getGasRecommendation = async ({ chainId, fromChain, fromToken }, options)
|
|
|
292
271
|
const getAvailableConnections = async (connectionRequest) => {
|
|
293
272
|
const config = ConfigService_1.default.getInstance().getConfig();
|
|
294
273
|
const url = new URL(`${config.apiUrl}/connections`);
|
|
295
|
-
const { fromChain, fromToken, toChain, toToken
|
|
274
|
+
const { fromChain, fromToken, toChain, toToken } = connectionRequest;
|
|
296
275
|
if (fromChain) {
|
|
297
276
|
url.searchParams.append('fromChain', fromChain);
|
|
298
277
|
}
|
|
@@ -305,11 +284,22 @@ const getAvailableConnections = async (connectionRequest) => {
|
|
|
305
284
|
if (toToken) {
|
|
306
285
|
url.searchParams.append('fromToken', toToken);
|
|
307
286
|
}
|
|
308
|
-
|
|
309
|
-
allowBridges
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
287
|
+
const connectionRequestArrayParams = [
|
|
288
|
+
'allowBridges',
|
|
289
|
+
'denyBridges',
|
|
290
|
+
'preferBridges',
|
|
291
|
+
'allowExchanges',
|
|
292
|
+
'denyExchanges',
|
|
293
|
+
'preferExchanges',
|
|
294
|
+
];
|
|
295
|
+
connectionRequestArrayParams.forEach((parameter) => {
|
|
296
|
+
const connectionRequestArrayParam = connectionRequest[parameter];
|
|
297
|
+
if (connectionRequestArrayParam?.length) {
|
|
298
|
+
connectionRequestArrayParam?.forEach((value) => {
|
|
299
|
+
url.searchParams.append(parameter, value);
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
});
|
|
313
303
|
try {
|
|
314
304
|
const response = await (0, request_1.request)(url);
|
|
315
305
|
return response;
|
|
@@ -40,6 +40,10 @@ class ConfigService {
|
|
|
40
40
|
this.config.defaultRouteOptions = Object.assign(this.config.defaultRouteOptions, configUpdate.defaultRouteOptions);
|
|
41
41
|
this.config.userId = configUpdate.userId || this.config.userId;
|
|
42
42
|
this.config.integrator = configUpdate.integrator || this.config.integrator;
|
|
43
|
+
this.config.defaultRouteOptions.integrator =
|
|
44
|
+
configUpdate.integrator ||
|
|
45
|
+
configUpdate.defaultRouteOptions?.integrator ||
|
|
46
|
+
this.config.integrator;
|
|
43
47
|
this.config.widgetVersion =
|
|
44
48
|
configUpdate.widgetVersion || this.config.widgetVersion;
|
|
45
49
|
this.config.multisigConfig =
|
|
@@ -39,7 +39,6 @@ export type Config = {
|
|
|
39
39
|
};
|
|
40
40
|
export interface MultisigTxDetails {
|
|
41
41
|
status: 'DONE' | 'FAILED' | 'PENDING' | 'CANCELLED';
|
|
42
|
-
message: string;
|
|
43
42
|
txHash?: string;
|
|
44
43
|
}
|
|
45
44
|
export interface MultisigTransactionResponse {
|
|
@@ -51,8 +50,8 @@ export interface BaseTransaction {
|
|
|
51
50
|
data: string;
|
|
52
51
|
}
|
|
53
52
|
export interface MultisigConfig {
|
|
54
|
-
isMultisigSigner
|
|
55
|
-
getMultisigTransactionDetails
|
|
53
|
+
isMultisigSigner?: boolean;
|
|
54
|
+
getMultisigTransactionDetails?: (txHash: string, fromChainId: number, updateIntermediateStatus?: () => void) => Promise<MultisigTxDetails>;
|
|
56
55
|
sendBatchTransaction?: (batchTransactions: BaseTransaction[]) => Promise<MultisigTransactionResponse>;
|
|
57
56
|
shouldBatchTransactions?: boolean;
|
|
58
57
|
}
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/sdk";
|
|
2
|
-
export declare const version = "2.2.
|
|
2
|
+
export declare const version = "2.2.2";
|
package/dist/cjs/version.js
CHANGED
|
@@ -59,7 +59,6 @@ const getToken = async (chain, token, options) => {
|
|
|
59
59
|
};
|
|
60
60
|
const getQuote = async (requestConfig, options) => {
|
|
61
61
|
const config = ConfigService.getInstance().getConfig();
|
|
62
|
-
// validation
|
|
63
62
|
const requiredParameters = [
|
|
64
63
|
'fromChain',
|
|
65
64
|
'fromToken',
|
|
@@ -74,27 +73,17 @@ const getQuote = async (requestConfig, options) => {
|
|
|
74
73
|
}
|
|
75
74
|
});
|
|
76
75
|
// apply defaults
|
|
77
|
-
requestConfig.order
|
|
78
|
-
requestConfig.slippage =
|
|
79
|
-
|
|
80
|
-
requestConfig.
|
|
81
|
-
|
|
82
|
-
requestConfig.
|
|
83
|
-
|
|
84
|
-
requestConfig.
|
|
85
|
-
requestConfig.
|
|
86
|
-
|
|
87
|
-
requestConfig.
|
|
88
|
-
requestConfig.denyBridges || config.defaultRouteOptions.bridges?.deny;
|
|
89
|
-
requestConfig.preferBridges =
|
|
90
|
-
requestConfig.preferBridges || config.defaultRouteOptions.bridges?.prefer;
|
|
91
|
-
requestConfig.allowExchanges =
|
|
92
|
-
requestConfig.allowExchanges || config.defaultRouteOptions.exchanges?.allow;
|
|
93
|
-
requestConfig.denyExchanges =
|
|
94
|
-
requestConfig.denyExchanges || config.defaultRouteOptions.exchanges?.deny;
|
|
95
|
-
requestConfig.preferExchanges =
|
|
96
|
-
requestConfig.preferExchanges ||
|
|
97
|
-
config.defaultRouteOptions.exchanges?.prefer;
|
|
76
|
+
requestConfig.order || (requestConfig.order = config.defaultRouteOptions.order);
|
|
77
|
+
requestConfig.slippage || (requestConfig.slippage = config.defaultRouteOptions.slippage);
|
|
78
|
+
requestConfig.integrator || (requestConfig.integrator = config.defaultRouteOptions.integrator);
|
|
79
|
+
requestConfig.referrer || (requestConfig.referrer = config.defaultRouteOptions.referrer);
|
|
80
|
+
requestConfig.fee || (requestConfig.fee = config.defaultRouteOptions.fee);
|
|
81
|
+
requestConfig.allowBridges || (requestConfig.allowBridges = config.defaultRouteOptions.bridges?.allow);
|
|
82
|
+
requestConfig.denyBridges || (requestConfig.denyBridges = config.defaultRouteOptions.bridges?.deny);
|
|
83
|
+
requestConfig.preferBridges || (requestConfig.preferBridges = config.defaultRouteOptions.bridges?.prefer);
|
|
84
|
+
requestConfig.allowExchanges || (requestConfig.allowExchanges = config.defaultRouteOptions.exchanges?.allow);
|
|
85
|
+
requestConfig.denyExchanges || (requestConfig.denyExchanges = config.defaultRouteOptions.exchanges?.deny);
|
|
86
|
+
requestConfig.preferExchanges || (requestConfig.preferExchanges = config.defaultRouteOptions.exchanges?.prefer);
|
|
98
87
|
Object.keys(requestConfig).forEach((key) => !requestConfig[key] &&
|
|
99
88
|
delete requestConfig[key]);
|
|
100
89
|
try {
|
|
@@ -128,26 +117,16 @@ const getContractCallQuote = async (requestConfig, options) => {
|
|
|
128
117
|
});
|
|
129
118
|
// apply defaults
|
|
130
119
|
// option.order is not used in this endpoint
|
|
131
|
-
requestConfig.slippage =
|
|
132
|
-
|
|
133
|
-
requestConfig.
|
|
134
|
-
|
|
135
|
-
requestConfig.
|
|
136
|
-
|
|
137
|
-
requestConfig.
|
|
138
|
-
requestConfig.
|
|
139
|
-
|
|
140
|
-
requestConfig.
|
|
141
|
-
requestConfig.denyBridges || config.defaultRouteOptions.bridges?.deny;
|
|
142
|
-
requestConfig.preferBridges =
|
|
143
|
-
requestConfig.preferBridges || config.defaultRouteOptions.bridges?.prefer;
|
|
144
|
-
requestConfig.allowExchanges =
|
|
145
|
-
requestConfig.allowExchanges || config.defaultRouteOptions.exchanges?.allow;
|
|
146
|
-
requestConfig.denyExchanges =
|
|
147
|
-
requestConfig.denyExchanges || config.defaultRouteOptions.exchanges?.deny;
|
|
148
|
-
requestConfig.preferExchanges =
|
|
149
|
-
requestConfig.preferExchanges ||
|
|
150
|
-
config.defaultRouteOptions.exchanges?.prefer;
|
|
120
|
+
requestConfig.slippage || (requestConfig.slippage = config.defaultRouteOptions.slippage);
|
|
121
|
+
requestConfig.integrator || (requestConfig.integrator = config.defaultRouteOptions.integrator);
|
|
122
|
+
requestConfig.referrer || (requestConfig.referrer = config.defaultRouteOptions.referrer);
|
|
123
|
+
requestConfig.fee || (requestConfig.fee = config.defaultRouteOptions.fee);
|
|
124
|
+
requestConfig.allowBridges || (requestConfig.allowBridges = config.defaultRouteOptions.bridges?.allow);
|
|
125
|
+
requestConfig.denyBridges || (requestConfig.denyBridges = config.defaultRouteOptions.bridges?.deny);
|
|
126
|
+
requestConfig.preferBridges || (requestConfig.preferBridges = config.defaultRouteOptions.bridges?.prefer);
|
|
127
|
+
requestConfig.allowExchanges || (requestConfig.allowExchanges = config.defaultRouteOptions.exchanges?.allow);
|
|
128
|
+
requestConfig.denyExchanges || (requestConfig.denyExchanges = config.defaultRouteOptions.exchanges?.deny);
|
|
129
|
+
requestConfig.preferExchanges || (requestConfig.preferExchanges = config.defaultRouteOptions.exchanges?.prefer);
|
|
151
130
|
// send request
|
|
152
131
|
try {
|
|
153
132
|
const response = await request(`${config.apiUrl}/quote/contractCall`, {
|
|
@@ -287,7 +266,7 @@ const getGasRecommendation = async ({ chainId, fromChain, fromToken }, options)
|
|
|
287
266
|
const getAvailableConnections = async (connectionRequest) => {
|
|
288
267
|
const config = ConfigService.getInstance().getConfig();
|
|
289
268
|
const url = new URL(`${config.apiUrl}/connections`);
|
|
290
|
-
const { fromChain, fromToken, toChain, toToken
|
|
269
|
+
const { fromChain, fromToken, toChain, toToken } = connectionRequest;
|
|
291
270
|
if (fromChain) {
|
|
292
271
|
url.searchParams.append('fromChain', fromChain);
|
|
293
272
|
}
|
|
@@ -300,11 +279,22 @@ const getAvailableConnections = async (connectionRequest) => {
|
|
|
300
279
|
if (toToken) {
|
|
301
280
|
url.searchParams.append('fromToken', toToken);
|
|
302
281
|
}
|
|
303
|
-
|
|
304
|
-
allowBridges
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
282
|
+
const connectionRequestArrayParams = [
|
|
283
|
+
'allowBridges',
|
|
284
|
+
'denyBridges',
|
|
285
|
+
'preferBridges',
|
|
286
|
+
'allowExchanges',
|
|
287
|
+
'denyExchanges',
|
|
288
|
+
'preferExchanges',
|
|
289
|
+
];
|
|
290
|
+
connectionRequestArrayParams.forEach((parameter) => {
|
|
291
|
+
const connectionRequestArrayParam = connectionRequest[parameter];
|
|
292
|
+
if (connectionRequestArrayParam?.length) {
|
|
293
|
+
connectionRequestArrayParam?.forEach((value) => {
|
|
294
|
+
url.searchParams.append(parameter, value);
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
});
|
|
308
298
|
try {
|
|
309
299
|
const response = await request(url);
|
|
310
300
|
return response;
|
|
@@ -38,6 +38,10 @@ class ConfigService {
|
|
|
38
38
|
this.config.defaultRouteOptions = Object.assign(this.config.defaultRouteOptions, configUpdate.defaultRouteOptions);
|
|
39
39
|
this.config.userId = configUpdate.userId || this.config.userId;
|
|
40
40
|
this.config.integrator = configUpdate.integrator || this.config.integrator;
|
|
41
|
+
this.config.defaultRouteOptions.integrator =
|
|
42
|
+
configUpdate.integrator ||
|
|
43
|
+
configUpdate.defaultRouteOptions?.integrator ||
|
|
44
|
+
this.config.integrator;
|
|
41
45
|
this.config.widgetVersion =
|
|
42
46
|
configUpdate.widgetVersion || this.config.widgetVersion;
|
|
43
47
|
this.config.multisigConfig =
|
|
@@ -39,7 +39,6 @@ export type Config = {
|
|
|
39
39
|
};
|
|
40
40
|
export interface MultisigTxDetails {
|
|
41
41
|
status: 'DONE' | 'FAILED' | 'PENDING' | 'CANCELLED';
|
|
42
|
-
message: string;
|
|
43
42
|
txHash?: string;
|
|
44
43
|
}
|
|
45
44
|
export interface MultisigTransactionResponse {
|
|
@@ -51,8 +50,8 @@ export interface BaseTransaction {
|
|
|
51
50
|
data: string;
|
|
52
51
|
}
|
|
53
52
|
export interface MultisigConfig {
|
|
54
|
-
isMultisigSigner
|
|
55
|
-
getMultisigTransactionDetails
|
|
53
|
+
isMultisigSigner?: boolean;
|
|
54
|
+
getMultisigTransactionDetails?: (txHash: string, fromChainId: number, updateIntermediateStatus?: () => void) => Promise<MultisigTxDetails>;
|
|
56
55
|
sendBatchTransaction?: (batchTransactions: BaseTransaction[]) => Promise<MultisigTransactionResponse>;
|
|
57
56
|
shouldBatchTransactions?: boolean;
|
|
58
57
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/sdk";
|
|
2
|
-
export declare const version = "2.2.
|
|
2
|
+
export declare const version = "2.2.2";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/sdk';
|
|
2
|
-
export const version = '2.2.
|
|
2
|
+
export const version = '2.2.2';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/sdk",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
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",
|
|
@@ -77,20 +77,20 @@
|
|
|
77
77
|
"dependencies": {
|
|
78
78
|
"@ethersproject/abi": "^5.7.0",
|
|
79
79
|
"@ethersproject/contracts": "^5.7.0",
|
|
80
|
-
"@lifi/types": "^8.0.
|
|
80
|
+
"@lifi/types": "^8.0.4",
|
|
81
81
|
"bignumber.js": "^9.1.1",
|
|
82
82
|
"eth-rpc-errors": "^4.0.3",
|
|
83
83
|
"ethers": "^5.7.2"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@commitlint/cli": "^17.6.
|
|
87
|
-
"@commitlint/config-conventional": "^17.6.
|
|
86
|
+
"@commitlint/cli": "^17.6.7",
|
|
87
|
+
"@commitlint/config-conventional": "^17.6.7",
|
|
88
88
|
"@mswjs/interceptors": "^0.22.16",
|
|
89
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
90
|
-
"@typescript-eslint/parser": "^6.
|
|
89
|
+
"@typescript-eslint/eslint-plugin": "^6.1.0",
|
|
90
|
+
"@typescript-eslint/parser": "^6.1.0",
|
|
91
91
|
"@vitest/coverage-c8": "^0.33.0",
|
|
92
92
|
"cross-fetch": "^4.0.0",
|
|
93
|
-
"eslint": "^8.
|
|
93
|
+
"eslint": "^8.45.0",
|
|
94
94
|
"eslint-config-prettier": "^8.8.0",
|
|
95
95
|
"eslint-plugin-prettier": "^5.0.0",
|
|
96
96
|
"husky": "^8.0.3",
|