@lifi/sdk 2.4.3 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/request.js +5 -5
- package/dist/cjs/services/ChainsService.d.ts +1 -0
- package/dist/cjs/services/ChainsService.js +17 -7
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/request.js +5 -5
- package/dist/services/ChainsService.d.ts +1 -0
- package/dist/services/ChainsService.js +17 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +12 -13
package/dist/cjs/request.js
CHANGED
|
@@ -20,31 +20,31 @@ const request = async (url, options = {
|
|
|
20
20
|
if (!options.skipTrackingHeaders) {
|
|
21
21
|
if (apiKey) {
|
|
22
22
|
options.headers = {
|
|
23
|
-
...options
|
|
23
|
+
...options.headers,
|
|
24
24
|
'x-lifi-api-key': apiKey,
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
if (userId) {
|
|
28
28
|
options.headers = {
|
|
29
|
-
...options
|
|
29
|
+
...options.headers,
|
|
30
30
|
'x-lifi-userid': userId,
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
if (widgetVersion) {
|
|
34
34
|
options.headers = {
|
|
35
|
-
...options
|
|
35
|
+
...options.headers,
|
|
36
36
|
'x-lifi-widget': widgetVersion,
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
if (version_1.version) {
|
|
40
40
|
options.headers = {
|
|
41
|
-
...options
|
|
41
|
+
...options.headers,
|
|
42
42
|
'x-lifi-sdk': version_1.version,
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
// integrator is mandatory during SDK initialization
|
|
46
46
|
options.headers = {
|
|
47
|
-
...options
|
|
47
|
+
...options.headers,
|
|
48
48
|
'x-lifi-integrator': integrator,
|
|
49
49
|
};
|
|
50
50
|
}
|
|
@@ -11,7 +11,21 @@ class ChainsService {
|
|
|
11
11
|
this.loadingPromise = this.loadAvailableChains();
|
|
12
12
|
}
|
|
13
13
|
async loadAvailableChains() {
|
|
14
|
-
|
|
14
|
+
try {
|
|
15
|
+
this.chains = await ApiService_1.default.getChains();
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
// We try to load chains during initialization of the LiFi class and
|
|
19
|
+
// because we no longer in scope of the constructor we fail silently here
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async checkLoading() {
|
|
23
|
+
if (this.loadingPromise) {
|
|
24
|
+
await this.loadingPromise;
|
|
25
|
+
}
|
|
26
|
+
if (!this.chains.length) {
|
|
27
|
+
await this.loadAvailableChains();
|
|
28
|
+
}
|
|
15
29
|
}
|
|
16
30
|
static getInstance() {
|
|
17
31
|
if (!this.instance) {
|
|
@@ -20,9 +34,7 @@ class ChainsService {
|
|
|
20
34
|
return this.instance;
|
|
21
35
|
}
|
|
22
36
|
async getChainById(chainId) {
|
|
23
|
-
|
|
24
|
-
await this.loadingPromise;
|
|
25
|
-
}
|
|
37
|
+
await this.checkLoading();
|
|
26
38
|
const chain = this.chains.find((chain) => chain.id === chainId);
|
|
27
39
|
if (!chain) {
|
|
28
40
|
throw new errors_1.ValidationError(`Unknown chainId passed: ${chainId}.`);
|
|
@@ -30,9 +42,7 @@ class ChainsService {
|
|
|
30
42
|
return chain;
|
|
31
43
|
}
|
|
32
44
|
async getChains() {
|
|
33
|
-
|
|
34
|
-
await this.loadingPromise;
|
|
35
|
-
}
|
|
45
|
+
await this.checkLoading();
|
|
36
46
|
return this.chains;
|
|
37
47
|
}
|
|
38
48
|
}
|
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
|
+
export declare const version = "2.5.0";
|
package/dist/cjs/version.js
CHANGED
package/dist/request.js
CHANGED
|
@@ -14,31 +14,31 @@ export const request = async (url, options = {
|
|
|
14
14
|
if (!options.skipTrackingHeaders) {
|
|
15
15
|
if (apiKey) {
|
|
16
16
|
options.headers = {
|
|
17
|
-
...options
|
|
17
|
+
...options.headers,
|
|
18
18
|
'x-lifi-api-key': apiKey,
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
if (userId) {
|
|
22
22
|
options.headers = {
|
|
23
|
-
...options
|
|
23
|
+
...options.headers,
|
|
24
24
|
'x-lifi-userid': userId,
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
if (widgetVersion) {
|
|
28
28
|
options.headers = {
|
|
29
|
-
...options
|
|
29
|
+
...options.headers,
|
|
30
30
|
'x-lifi-widget': widgetVersion,
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
if (version) {
|
|
34
34
|
options.headers = {
|
|
35
|
-
...options
|
|
35
|
+
...options.headers,
|
|
36
36
|
'x-lifi-sdk': version,
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
// integrator is mandatory during SDK initialization
|
|
40
40
|
options.headers = {
|
|
41
|
-
...options
|
|
41
|
+
...options.headers,
|
|
42
42
|
'x-lifi-integrator': integrator,
|
|
43
43
|
};
|
|
44
44
|
}
|
|
@@ -6,7 +6,21 @@ export default class ChainsService {
|
|
|
6
6
|
this.loadingPromise = this.loadAvailableChains();
|
|
7
7
|
}
|
|
8
8
|
async loadAvailableChains() {
|
|
9
|
-
|
|
9
|
+
try {
|
|
10
|
+
this.chains = await ApiService.getChains();
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
// We try to load chains during initialization of the LiFi class and
|
|
14
|
+
// because we no longer in scope of the constructor we fail silently here
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
async checkLoading() {
|
|
18
|
+
if (this.loadingPromise) {
|
|
19
|
+
await this.loadingPromise;
|
|
20
|
+
}
|
|
21
|
+
if (!this.chains.length) {
|
|
22
|
+
await this.loadAvailableChains();
|
|
23
|
+
}
|
|
10
24
|
}
|
|
11
25
|
static getInstance() {
|
|
12
26
|
if (!this.instance) {
|
|
@@ -15,9 +29,7 @@ export default class ChainsService {
|
|
|
15
29
|
return this.instance;
|
|
16
30
|
}
|
|
17
31
|
async getChainById(chainId) {
|
|
18
|
-
|
|
19
|
-
await this.loadingPromise;
|
|
20
|
-
}
|
|
32
|
+
await this.checkLoading();
|
|
21
33
|
const chain = this.chains.find((chain) => chain.id === chainId);
|
|
22
34
|
if (!chain) {
|
|
23
35
|
throw new ValidationError(`Unknown chainId passed: ${chainId}.`);
|
|
@@ -25,9 +37,7 @@ export default class ChainsService {
|
|
|
25
37
|
return chain;
|
|
26
38
|
}
|
|
27
39
|
async getChains() {
|
|
28
|
-
|
|
29
|
-
await this.loadingPromise;
|
|
30
|
-
}
|
|
40
|
+
await this.checkLoading();
|
|
31
41
|
return this.chains;
|
|
32
42
|
}
|
|
33
43
|
}
|
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
|
+
export declare const version = "2.5.0";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/sdk';
|
|
2
|
-
export const version = '2.
|
|
2
|
+
export const version = '2.5.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
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,34 +77,33 @@
|
|
|
77
77
|
"dependencies": {
|
|
78
78
|
"@ethersproject/abi": "^5.7.0",
|
|
79
79
|
"@ethersproject/contracts": "^5.7.0",
|
|
80
|
-
"@lifi/types": "^9.0
|
|
80
|
+
"@lifi/types": "^9.3.0",
|
|
81
81
|
"bignumber.js": "^9.1.2",
|
|
82
82
|
"eth-rpc-errors": "^4.0.3",
|
|
83
83
|
"ethers": "^5.7.2"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@commitlint/cli": "^
|
|
87
|
-
"@commitlint/config-conventional": "^
|
|
88
|
-
"@
|
|
89
|
-
"@typescript-eslint/
|
|
90
|
-
"@typescript-eslint/parser": "^6.7.2",
|
|
86
|
+
"@commitlint/cli": "^18.2.0",
|
|
87
|
+
"@commitlint/config-conventional": "^18.1.0",
|
|
88
|
+
"@typescript-eslint/eslint-plugin": "^6.9.1",
|
|
89
|
+
"@typescript-eslint/parser": "^6.9.1",
|
|
91
90
|
"@vitest/coverage-c8": "^0.33.0",
|
|
92
91
|
"cross-fetch": "^4.0.0",
|
|
93
|
-
"eslint": "^8.
|
|
92
|
+
"eslint": "^8.52.0",
|
|
94
93
|
"eslint-config-prettier": "^9.0.0",
|
|
95
|
-
"eslint-plugin-prettier": "^5.0.
|
|
94
|
+
"eslint-plugin-prettier": "^5.0.1",
|
|
96
95
|
"husky": "^8.0.3",
|
|
97
|
-
"lint-staged": "^
|
|
98
|
-
"msw": "
|
|
96
|
+
"lint-staged": "^15.0.2",
|
|
97
|
+
"msw": "^2.0.1",
|
|
99
98
|
"npm-run-all": "^4.1.5",
|
|
100
99
|
"pinst": "^3.0.0",
|
|
101
100
|
"prettier": "^3.0.3",
|
|
102
101
|
"standard-version": "^9.5.0",
|
|
103
102
|
"typescript": "^5.2.2",
|
|
104
|
-
"vitest": "^0.34.
|
|
103
|
+
"vitest": "^0.34.6"
|
|
105
104
|
},
|
|
106
105
|
"directories": {
|
|
107
106
|
"test": "test"
|
|
108
107
|
},
|
|
109
|
-
"packageManager": "yarn@
|
|
108
|
+
"packageManager": "yarn@4.0.1"
|
|
110
109
|
}
|