@lifi/sdk 2.0.1 → 2.1.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/LiFi.d.ts +1 -1
- package/dist/LiFi.js +1 -1
- package/dist/allowance/utils.js +12 -3
- package/dist/cjs/LiFi.d.ts +1 -1
- package/dist/cjs/LiFi.js +1 -1
- package/dist/cjs/allowance/utils.js +11 -2
- package/dist/cjs/execution/StepExecutionManager.js +6 -5
- package/dist/cjs/execution/utils.js +1 -3
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/execution/StepExecutionManager.js +6 -5
- package/dist/execution/utils.js +1 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +9 -9
package/dist/LiFi.d.ts
CHANGED
|
@@ -90,7 +90,7 @@ export declare class LiFi extends RouteExecutionManager {
|
|
|
90
90
|
/**
|
|
91
91
|
* Get the transaction data for a single step of a route
|
|
92
92
|
* @param {LifiStep} step - The step object.
|
|
93
|
-
* @return {Promise<
|
|
93
|
+
* @return {Promise<LifiStep>} The step populated with the transaction data.
|
|
94
94
|
* @throws {LifiError} Throws a LifiError if request fails.
|
|
95
95
|
*/
|
|
96
96
|
getStepTransaction: (step: LifiStep, options?: RequestOptions) => Promise<LifiStep>;
|
package/dist/LiFi.js
CHANGED
|
@@ -120,7 +120,7 @@ export class LiFi extends RouteExecutionManager {
|
|
|
120
120
|
/**
|
|
121
121
|
* Get the transaction data for a single step of a route
|
|
122
122
|
* @param {LifiStep} step - The step object.
|
|
123
|
-
* @return {Promise<
|
|
123
|
+
* @return {Promise<LifiStep>} The step populated with the transaction data.
|
|
124
124
|
* @throws {LifiError} Throws a LifiError if request fails.
|
|
125
125
|
*/
|
|
126
126
|
this.getStepTransaction = async (step, options) => {
|
package/dist/allowance/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
|
-
import { Contract } from 'ethers';
|
|
2
|
+
import { Contract, ethers } from 'ethers';
|
|
3
3
|
import ChainsService from '../services/ChainsService';
|
|
4
4
|
import { ERC20_ABI } from '../types';
|
|
5
5
|
import { ServerError } from '../utils/errors';
|
|
@@ -20,9 +20,18 @@ export const getApproved = async (signer, tokenAddress, contractAddress, transac
|
|
|
20
20
|
return new BigNumber(0);
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
-
export const setApproval = (signer, tokenAddress, contractAddress, amount) => {
|
|
23
|
+
export const setApproval = async (signer, tokenAddress, contractAddress, amount) => {
|
|
24
24
|
const erc20 = new Contract(tokenAddress, ERC20_ABI, signer);
|
|
25
|
-
|
|
25
|
+
const transactionRequest = await erc20.populateTransaction.approve(contractAddress, amount);
|
|
26
|
+
try {
|
|
27
|
+
const estimatedGasLimit = await signer.estimateGas(transactionRequest);
|
|
28
|
+
if (estimatedGasLimit) {
|
|
29
|
+
const formattedGasLimit = ethers.utils.parseEther(`${(BigInt(estimatedGasLimit.toString()) * 125n) / 100n}`);
|
|
30
|
+
transactionRequest.gasLimit = formattedGasLimit;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch (error) { }
|
|
34
|
+
return signer.sendTransaction(transactionRequest);
|
|
26
35
|
};
|
|
27
36
|
export const getAllowanceViaMulticall = async (signer, chainId, tokenData) => {
|
|
28
37
|
const chainsService = ChainsService.getInstance();
|
package/dist/cjs/LiFi.d.ts
CHANGED
|
@@ -90,7 +90,7 @@ export declare class LiFi extends RouteExecutionManager {
|
|
|
90
90
|
/**
|
|
91
91
|
* Get the transaction data for a single step of a route
|
|
92
92
|
* @param {LifiStep} step - The step object.
|
|
93
|
-
* @return {Promise<
|
|
93
|
+
* @return {Promise<LifiStep>} The step populated with the transaction data.
|
|
94
94
|
* @throws {LifiError} Throws a LifiError if request fails.
|
|
95
95
|
*/
|
|
96
96
|
getStepTransaction: (step: LifiStep, options?: RequestOptions) => Promise<LifiStep>;
|
package/dist/cjs/LiFi.js
CHANGED
|
@@ -149,7 +149,7 @@ class LiFi extends RouteExecutionManager_1.RouteExecutionManager {
|
|
|
149
149
|
/**
|
|
150
150
|
* Get the transaction data for a single step of a route
|
|
151
151
|
* @param {LifiStep} step - The step object.
|
|
152
|
-
* @return {Promise<
|
|
152
|
+
* @return {Promise<LifiStep>} The step populated with the transaction data.
|
|
153
153
|
* @throws {LifiError} Throws a LifiError if request fails.
|
|
154
154
|
*/
|
|
155
155
|
this.getStepTransaction = async (step, options) => {
|
|
@@ -27,9 +27,18 @@ const getApproved = async (signer, tokenAddress, contractAddress, transactionReq
|
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
exports.getApproved = getApproved;
|
|
30
|
-
const setApproval = (signer, tokenAddress, contractAddress, amount) => {
|
|
30
|
+
const setApproval = async (signer, tokenAddress, contractAddress, amount) => {
|
|
31
31
|
const erc20 = new ethers_1.Contract(tokenAddress, types_1.ERC20_ABI, signer);
|
|
32
|
-
|
|
32
|
+
const transactionRequest = await erc20.populateTransaction.approve(contractAddress, amount);
|
|
33
|
+
try {
|
|
34
|
+
const estimatedGasLimit = await signer.estimateGas(transactionRequest);
|
|
35
|
+
if (estimatedGasLimit) {
|
|
36
|
+
const formattedGasLimit = ethers_1.ethers.utils.parseEther(`${(BigInt(estimatedGasLimit.toString()) * 125n) / 100n}`);
|
|
37
|
+
transactionRequest.gasLimit = formattedGasLimit;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (error) { }
|
|
41
|
+
return signer.sendTransaction(transactionRequest);
|
|
33
42
|
};
|
|
34
43
|
exports.setApproval = setApproval;
|
|
35
44
|
const getAllowanceViaMulticall = async (signer, chainId, tokenData) => {
|
|
@@ -155,20 +155,21 @@ class StepExecutionManager {
|
|
|
155
155
|
if (!processTxHash) {
|
|
156
156
|
throw new Error('Transaction hash is undefined.');
|
|
157
157
|
}
|
|
158
|
-
statusResponse = await (0, utils_2.waitForReceivingTransaction)(processTxHash, statusManager, process.type, step);
|
|
158
|
+
statusResponse = (await (0, utils_2.waitForReceivingTransaction)(processTxHash, statusManager, process.type, step));
|
|
159
|
+
const statusReceiving = statusResponse.receiving;
|
|
159
160
|
process = statusManager.updateProcess(step, process.type, 'DONE', {
|
|
160
161
|
substatus: statusResponse.substatus,
|
|
161
162
|
substatusMessage: statusResponse.substatusMessage ||
|
|
162
163
|
(0, utils_2.getSubstatusMessage)(statusResponse.status, statusResponse.substatus),
|
|
163
|
-
txHash:
|
|
164
|
+
txHash: statusReceiving?.txHash,
|
|
164
165
|
txLink: toChain.metamask.blockExplorerUrls[0] +
|
|
165
166
|
'tx/' +
|
|
166
|
-
|
|
167
|
+
statusReceiving?.txHash,
|
|
167
168
|
});
|
|
168
169
|
statusManager.updateExecution(step, 'DONE', {
|
|
169
170
|
fromAmount: statusResponse.sending.amount,
|
|
170
|
-
toAmount:
|
|
171
|
-
toToken:
|
|
171
|
+
toAmount: statusReceiving?.amount,
|
|
172
|
+
toToken: statusReceiving?.token,
|
|
172
173
|
gasAmount: statusResponse.sending.gasAmount,
|
|
173
174
|
gasAmountUSD: statusResponse.sending.gasAmountUSD,
|
|
174
175
|
gasPrice: statusResponse.sending.gasPrice,
|
|
@@ -32,9 +32,7 @@ async function waitForReceivingTransaction(txHash, statusManager, processType, s
|
|
|
32
32
|
substatus: statusResponse.substatus,
|
|
33
33
|
substatusMessage: statusResponse.substatusMessage ||
|
|
34
34
|
getSubstatusMessage(statusResponse.status, statusResponse.substatus),
|
|
35
|
-
|
|
36
|
-
txLink: statusResponse.bridgeExplorerLink,
|
|
37
|
-
}),
|
|
35
|
+
txLink: statusResponse.bridgeExplorerLink,
|
|
38
36
|
});
|
|
39
37
|
return resolve(undefined);
|
|
40
38
|
case 'NOT_FOUND':
|
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.0
|
|
2
|
+
export declare const version = "2.1.0";
|
package/dist/cjs/version.js
CHANGED
|
@@ -149,20 +149,21 @@ export class StepExecutionManager {
|
|
|
149
149
|
if (!processTxHash) {
|
|
150
150
|
throw new Error('Transaction hash is undefined.');
|
|
151
151
|
}
|
|
152
|
-
statusResponse = await waitForReceivingTransaction(processTxHash, statusManager, process.type, step);
|
|
152
|
+
statusResponse = (await waitForReceivingTransaction(processTxHash, statusManager, process.type, step));
|
|
153
|
+
const statusReceiving = statusResponse.receiving;
|
|
153
154
|
process = statusManager.updateProcess(step, process.type, 'DONE', {
|
|
154
155
|
substatus: statusResponse.substatus,
|
|
155
156
|
substatusMessage: statusResponse.substatusMessage ||
|
|
156
157
|
getSubstatusMessage(statusResponse.status, statusResponse.substatus),
|
|
157
|
-
txHash:
|
|
158
|
+
txHash: statusReceiving?.txHash,
|
|
158
159
|
txLink: toChain.metamask.blockExplorerUrls[0] +
|
|
159
160
|
'tx/' +
|
|
160
|
-
|
|
161
|
+
statusReceiving?.txHash,
|
|
161
162
|
});
|
|
162
163
|
statusManager.updateExecution(step, 'DONE', {
|
|
163
164
|
fromAmount: statusResponse.sending.amount,
|
|
164
|
-
toAmount:
|
|
165
|
-
toToken:
|
|
165
|
+
toAmount: statusReceiving?.amount,
|
|
166
|
+
toToken: statusReceiving?.token,
|
|
166
167
|
gasAmount: statusResponse.sending.gasAmount,
|
|
167
168
|
gasAmountUSD: statusResponse.sending.gasAmountUSD,
|
|
168
169
|
gasPrice: statusResponse.sending.gasPrice,
|
package/dist/execution/utils.js
CHANGED
|
@@ -26,9 +26,7 @@ export async function waitForReceivingTransaction(txHash, statusManager, process
|
|
|
26
26
|
substatus: statusResponse.substatus,
|
|
27
27
|
substatusMessage: statusResponse.substatusMessage ||
|
|
28
28
|
getSubstatusMessage(statusResponse.status, statusResponse.substatus),
|
|
29
|
-
|
|
30
|
-
txLink: statusResponse.bridgeExplorerLink,
|
|
31
|
-
}),
|
|
29
|
+
txLink: statusResponse.bridgeExplorerLink,
|
|
32
30
|
});
|
|
33
31
|
return resolve(undefined);
|
|
34
32
|
case 'NOT_FOUND':
|
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
|
|
2
|
+
export declare const version = "2.1.0";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/sdk';
|
|
2
|
-
export const version = '2.0
|
|
2
|
+
export const version = '2.1.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/sdk",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.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",
|
|
@@ -76,20 +76,20 @@
|
|
|
76
76
|
"dependencies": {
|
|
77
77
|
"@ethersproject/abi": "^5.7.0",
|
|
78
78
|
"@ethersproject/contracts": "^5.7.0",
|
|
79
|
-
"@lifi/types": "^
|
|
79
|
+
"@lifi/types": "^8.0.0",
|
|
80
80
|
"bignumber.js": "^9.1.1",
|
|
81
81
|
"eth-rpc-errors": "^4.0.3",
|
|
82
82
|
"ethers": "^5.7.2"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
|
-
"@commitlint/cli": "^17.6.
|
|
86
|
-
"@commitlint/config-conventional": "^17.6.
|
|
85
|
+
"@commitlint/cli": "^17.6.6",
|
|
86
|
+
"@commitlint/config-conventional": "^17.6.6",
|
|
87
87
|
"@mswjs/interceptors": "^0.22.15",
|
|
88
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
89
|
-
"@typescript-eslint/parser": "^5.
|
|
90
|
-
"@vitest/coverage-c8": "^0.32.
|
|
88
|
+
"@typescript-eslint/eslint-plugin": "^5.60.1",
|
|
89
|
+
"@typescript-eslint/parser": "^5.60.1",
|
|
90
|
+
"@vitest/coverage-c8": "^0.32.2",
|
|
91
91
|
"cross-fetch": "^3.1.6",
|
|
92
|
-
"eslint": "^8.
|
|
92
|
+
"eslint": "^8.43.0",
|
|
93
93
|
"eslint-config-prettier": "^8.8.0",
|
|
94
94
|
"eslint-plugin-prettier": "^4.2.1",
|
|
95
95
|
"husky": "^8.0.3",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"prettier": "^2.8.8",
|
|
101
101
|
"standard-version": "^9.5.0",
|
|
102
102
|
"typescript": "^5.1.3",
|
|
103
|
-
"vitest": "^0.32.
|
|
103
|
+
"vitest": "^0.32.2"
|
|
104
104
|
},
|
|
105
105
|
"directories": {
|
|
106
106
|
"test": "test"
|