@lifi/sdk 2.3.0 → 2.4.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 +14 -1
- package/dist/LiFi.js +18 -0
- package/dist/allowance/checkAllowance.js +1 -1
- package/dist/allowance/utils.d.ts +1 -2
- package/dist/allowance/utils.js +2 -7
- package/dist/cjs/LiFi.d.ts +14 -1
- package/dist/cjs/LiFi.js +18 -0
- package/dist/cjs/allowance/checkAllowance.js +1 -1
- package/dist/cjs/allowance/utils.d.ts +1 -2
- package/dist/cjs/allowance/utils.js +2 -7
- package/dist/cjs/services/ApiService.d.ts +3 -1
- package/dist/cjs/services/ApiService.js +54 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/services/ApiService.d.ts +3 -1
- package/dist/services/ApiService.js +54 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +13 -13
package/dist/LiFi.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FallbackProvider } from '@ethersproject/providers';
|
|
2
|
-
import { ChainId, ChainKey, ConnectionsRequest, ConnectionsResponse, ContractCallQuoteRequest, ExtendedChain, GasRecommendationRequest, GasRecommendationResponse, GetStatusRequest, LifiStep, PossibilitiesRequest, PossibilitiesResponse, QuoteRequest, RequestOptions, RoutesRequest, RoutesResponse, StatusResponse, Token, TokenAmount, TokensRequest, TokensResponse, ToolsRequest, ToolsResponse } from '@lifi/types';
|
|
2
|
+
import { ChainId, ChainKey, ConnectionsRequest, ConnectionsResponse, ContractCallQuoteRequest, ContractCallsQuoteRequest, ExtendedChain, GasRecommendationRequest, GasRecommendationResponse, GetStatusRequest, LifiStep, PossibilitiesRequest, PossibilitiesResponse, QuoteRequest, RequestOptions, RoutesRequest, RoutesResponse, StatusResponse, Token, TokenAmount, TokensRequest, TokensResponse, ToolsRequest, ToolsResponse } from '@lifi/types';
|
|
3
3
|
import { Signer } from 'ethers';
|
|
4
4
|
import { ApproveTokenRequest, RevokeApprovalRequest } from './allowance';
|
|
5
5
|
import { RouteExecutionManager } from './execution/RouteExecutionManager';
|
|
@@ -55,8 +55,15 @@ export declare class LiFi extends RouteExecutionManager {
|
|
|
55
55
|
* Get a quote for a destination contract call
|
|
56
56
|
* @param {ContractCallQuoteRequest} request - The configuration of the requested destination call
|
|
57
57
|
* @throws {LifiError} - Throws a LifiError if request fails
|
|
58
|
+
* @deprecated This method is deprecated, please use `getContractCallsQuote` instead
|
|
58
59
|
*/
|
|
59
60
|
getContractCallQuote: (request: ContractCallQuoteRequest, options?: RequestOptions) => Promise<LifiStep>;
|
|
61
|
+
/**
|
|
62
|
+
* Get a quotes for multiple destination contract call
|
|
63
|
+
* @param {ContractCallsQuoteRequest} request - The configuration of the requested destination call
|
|
64
|
+
* @throws {LifiError} - Throws a LifiError if request fails
|
|
65
|
+
*/
|
|
66
|
+
getContractCallsQuote: (request: ContractCallsQuoteRequest, options?: RequestOptions) => Promise<LifiStep>;
|
|
60
67
|
/**
|
|
61
68
|
* Check the status of a transfer. For cross chain transfers, the "bridge" parameter is required.
|
|
62
69
|
* @param {GetStatusRequest} request - Configuration of the requested status
|
|
@@ -161,4 +168,10 @@ export declare class LiFi extends RouteExecutionManager {
|
|
|
161
168
|
* @returns ConnectionsResponse
|
|
162
169
|
*/
|
|
163
170
|
getConnections: (connectionRequest: ConnectionsRequest) => Promise<ConnectionsResponse>;
|
|
171
|
+
/**
|
|
172
|
+
* Get all the transaction history for swap/bridging done via LiFi
|
|
173
|
+
* @param address string
|
|
174
|
+
* @returns StatusResponse[]
|
|
175
|
+
*/
|
|
176
|
+
getTransactionHistory: (address: string) => Promise<StatusResponse[]>;
|
|
164
177
|
}
|
package/dist/LiFi.js
CHANGED
|
@@ -73,10 +73,19 @@ export class LiFi extends RouteExecutionManager {
|
|
|
73
73
|
* Get a quote for a destination contract call
|
|
74
74
|
* @param {ContractCallQuoteRequest} request - The configuration of the requested destination call
|
|
75
75
|
* @throws {LifiError} - Throws a LifiError if request fails
|
|
76
|
+
* @deprecated This method is deprecated, please use `getContractCallsQuote` instead
|
|
76
77
|
*/
|
|
77
78
|
this.getContractCallQuote = async (request, options) => {
|
|
78
79
|
return ApiService.getContractCallQuote(request, options);
|
|
79
80
|
};
|
|
81
|
+
/**
|
|
82
|
+
* Get a quotes for multiple destination contract call
|
|
83
|
+
* @param {ContractCallsQuoteRequest} request - The configuration of the requested destination call
|
|
84
|
+
* @throws {LifiError} - Throws a LifiError if request fails
|
|
85
|
+
*/
|
|
86
|
+
this.getContractCallsQuote = async (request, options) => {
|
|
87
|
+
return ApiService.getContractCallsQuote(request, options);
|
|
88
|
+
};
|
|
80
89
|
/**
|
|
81
90
|
* Check the status of a transfer. For cross chain transfers, the "bridge" parameter is required.
|
|
82
91
|
* @param {GetStatusRequest} request - Configuration of the requested status
|
|
@@ -226,6 +235,15 @@ export class LiFi extends RouteExecutionManager {
|
|
|
226
235
|
const connections = await ApiService.getAvailableConnections(connectionRequest);
|
|
227
236
|
return connections;
|
|
228
237
|
};
|
|
238
|
+
/**
|
|
239
|
+
* Get all the transaction history for swap/bridging done via LiFi
|
|
240
|
+
* @param address string
|
|
241
|
+
* @returns StatusResponse[]
|
|
242
|
+
*/
|
|
243
|
+
this.getTransactionHistory = async (address) => {
|
|
244
|
+
const connections = await ApiService.getTransactionHistory(address);
|
|
245
|
+
return connections;
|
|
246
|
+
};
|
|
229
247
|
this.chainsService = ChainsService.getInstance();
|
|
230
248
|
this.chainsService.getChains().then((chains) => {
|
|
231
249
|
this.configService.updateChains(chains);
|
|
@@ -33,7 +33,7 @@ export const checkAllowance = async (signer, step, statusManager, settings, chai
|
|
|
33
33
|
if (!approvalRequest.to) {
|
|
34
34
|
throw new Error('Missing ERC20 contract address');
|
|
35
35
|
}
|
|
36
|
-
const approved = await getApproved(signer, approvalRequest.from, approvalRequest.to
|
|
36
|
+
const approved = await getApproved(signer, approvalRequest.from, approvalRequest.to);
|
|
37
37
|
if (new BigNumber(step.action.fromAmount).gt(approved)) {
|
|
38
38
|
if (!allowUserInteraction) {
|
|
39
39
|
return;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { TransactionRequest } from '@ethersproject/abstract-provider';
|
|
2
1
|
import { ChainId, Token } from '@lifi/types';
|
|
3
2
|
import BigNumber from 'bignumber.js';
|
|
4
3
|
import { ContractTransaction, PopulatedTransaction, Signer } from 'ethers';
|
|
5
4
|
import { RevokeTokenData } from '../types';
|
|
6
|
-
export declare const getApproved: (signer: Signer, tokenAddress: string, contractAddress: string
|
|
5
|
+
export declare const getApproved: (signer: Signer, tokenAddress: string, contractAddress: string) => Promise<BigNumber>;
|
|
7
6
|
export declare const setApproval: (signer: Signer, tokenAddress: string, contractAddress: string, amount: string, returnPopulatedTransaction?: boolean) => Promise<ContractTransaction | PopulatedTransaction>;
|
|
8
7
|
export declare const getAllowanceViaMulticall: (signer: Signer, chainId: ChainId, tokenData: RevokeTokenData[]) => Promise<{
|
|
9
8
|
token: Token;
|
package/dist/allowance/utils.js
CHANGED
|
@@ -4,16 +4,11 @@ import ChainsService from '../services/ChainsService';
|
|
|
4
4
|
import { ERC20_ABI } from '../types';
|
|
5
5
|
import { ServerError } from '../utils/errors';
|
|
6
6
|
import { fetchDataUsingMulticall } from '../utils/multicall';
|
|
7
|
-
export const getApproved = async (signer, tokenAddress, contractAddress
|
|
7
|
+
export const getApproved = async (signer, tokenAddress, contractAddress) => {
|
|
8
8
|
const signerAddress = await signer.getAddress();
|
|
9
9
|
const erc20 = new Contract(tokenAddress, ERC20_ABI, signer);
|
|
10
10
|
try {
|
|
11
|
-
const approved = await erc20.allowance(signerAddress, contractAddress
|
|
12
|
-
gasLimit: transactionRequest?.gasLimit,
|
|
13
|
-
gasPrice: transactionRequest?.gasPrice,
|
|
14
|
-
maxFeePerGas: transactionRequest?.maxFeePerGas,
|
|
15
|
-
maxPriorityFeePerGas: transactionRequest?.maxPriorityFeePerGas,
|
|
16
|
-
});
|
|
11
|
+
const approved = await erc20.allowance(signerAddress, contractAddress);
|
|
17
12
|
return new BigNumber(approved.toString());
|
|
18
13
|
}
|
|
19
14
|
catch (e) {
|
package/dist/cjs/LiFi.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FallbackProvider } from '@ethersproject/providers';
|
|
2
|
-
import { ChainId, ChainKey, ConnectionsRequest, ConnectionsResponse, ContractCallQuoteRequest, ExtendedChain, GasRecommendationRequest, GasRecommendationResponse, GetStatusRequest, LifiStep, PossibilitiesRequest, PossibilitiesResponse, QuoteRequest, RequestOptions, RoutesRequest, RoutesResponse, StatusResponse, Token, TokenAmount, TokensRequest, TokensResponse, ToolsRequest, ToolsResponse } from '@lifi/types';
|
|
2
|
+
import { ChainId, ChainKey, ConnectionsRequest, ConnectionsResponse, ContractCallQuoteRequest, ContractCallsQuoteRequest, ExtendedChain, GasRecommendationRequest, GasRecommendationResponse, GetStatusRequest, LifiStep, PossibilitiesRequest, PossibilitiesResponse, QuoteRequest, RequestOptions, RoutesRequest, RoutesResponse, StatusResponse, Token, TokenAmount, TokensRequest, TokensResponse, ToolsRequest, ToolsResponse } from '@lifi/types';
|
|
3
3
|
import { Signer } from 'ethers';
|
|
4
4
|
import { ApproveTokenRequest, RevokeApprovalRequest } from './allowance';
|
|
5
5
|
import { RouteExecutionManager } from './execution/RouteExecutionManager';
|
|
@@ -55,8 +55,15 @@ export declare class LiFi extends RouteExecutionManager {
|
|
|
55
55
|
* Get a quote for a destination contract call
|
|
56
56
|
* @param {ContractCallQuoteRequest} request - The configuration of the requested destination call
|
|
57
57
|
* @throws {LifiError} - Throws a LifiError if request fails
|
|
58
|
+
* @deprecated This method is deprecated, please use `getContractCallsQuote` instead
|
|
58
59
|
*/
|
|
59
60
|
getContractCallQuote: (request: ContractCallQuoteRequest, options?: RequestOptions) => Promise<LifiStep>;
|
|
61
|
+
/**
|
|
62
|
+
* Get a quotes for multiple destination contract call
|
|
63
|
+
* @param {ContractCallsQuoteRequest} request - The configuration of the requested destination call
|
|
64
|
+
* @throws {LifiError} - Throws a LifiError if request fails
|
|
65
|
+
*/
|
|
66
|
+
getContractCallsQuote: (request: ContractCallsQuoteRequest, options?: RequestOptions) => Promise<LifiStep>;
|
|
60
67
|
/**
|
|
61
68
|
* Check the status of a transfer. For cross chain transfers, the "bridge" parameter is required.
|
|
62
69
|
* @param {GetStatusRequest} request - Configuration of the requested status
|
|
@@ -161,4 +168,10 @@ export declare class LiFi extends RouteExecutionManager {
|
|
|
161
168
|
* @returns ConnectionsResponse
|
|
162
169
|
*/
|
|
163
170
|
getConnections: (connectionRequest: ConnectionsRequest) => Promise<ConnectionsResponse>;
|
|
171
|
+
/**
|
|
172
|
+
* Get all the transaction history for swap/bridging done via LiFi
|
|
173
|
+
* @param address string
|
|
174
|
+
* @returns StatusResponse[]
|
|
175
|
+
*/
|
|
176
|
+
getTransactionHistory: (address: string) => Promise<StatusResponse[]>;
|
|
164
177
|
}
|
package/dist/cjs/LiFi.js
CHANGED
|
@@ -102,10 +102,19 @@ class LiFi extends RouteExecutionManager_1.RouteExecutionManager {
|
|
|
102
102
|
* Get a quote for a destination contract call
|
|
103
103
|
* @param {ContractCallQuoteRequest} request - The configuration of the requested destination call
|
|
104
104
|
* @throws {LifiError} - Throws a LifiError if request fails
|
|
105
|
+
* @deprecated This method is deprecated, please use `getContractCallsQuote` instead
|
|
105
106
|
*/
|
|
106
107
|
this.getContractCallQuote = async (request, options) => {
|
|
107
108
|
return ApiService_1.default.getContractCallQuote(request, options);
|
|
108
109
|
};
|
|
110
|
+
/**
|
|
111
|
+
* Get a quotes for multiple destination contract call
|
|
112
|
+
* @param {ContractCallsQuoteRequest} request - The configuration of the requested destination call
|
|
113
|
+
* @throws {LifiError} - Throws a LifiError if request fails
|
|
114
|
+
*/
|
|
115
|
+
this.getContractCallsQuote = async (request, options) => {
|
|
116
|
+
return ApiService_1.default.getContractCallsQuote(request, options);
|
|
117
|
+
};
|
|
109
118
|
/**
|
|
110
119
|
* Check the status of a transfer. For cross chain transfers, the "bridge" parameter is required.
|
|
111
120
|
* @param {GetStatusRequest} request - Configuration of the requested status
|
|
@@ -255,6 +264,15 @@ class LiFi extends RouteExecutionManager_1.RouteExecutionManager {
|
|
|
255
264
|
const connections = await ApiService_1.default.getAvailableConnections(connectionRequest);
|
|
256
265
|
return connections;
|
|
257
266
|
};
|
|
267
|
+
/**
|
|
268
|
+
* Get all the transaction history for swap/bridging done via LiFi
|
|
269
|
+
* @param address string
|
|
270
|
+
* @returns StatusResponse[]
|
|
271
|
+
*/
|
|
272
|
+
this.getTransactionHistory = async (address) => {
|
|
273
|
+
const connections = await ApiService_1.default.getTransactionHistory(address);
|
|
274
|
+
return connections;
|
|
275
|
+
};
|
|
258
276
|
this.chainsService = ChainsService_1.default.getInstance();
|
|
259
277
|
this.chainsService.getChains().then((chains) => {
|
|
260
278
|
this.configService.updateChains(chains);
|
|
@@ -39,7 +39,7 @@ const checkAllowance = async (signer, step, statusManager, settings, chain, allo
|
|
|
39
39
|
if (!approvalRequest.to) {
|
|
40
40
|
throw new Error('Missing ERC20 contract address');
|
|
41
41
|
}
|
|
42
|
-
const approved = await (0, utils_1.getApproved)(signer, approvalRequest.from, approvalRequest.to
|
|
42
|
+
const approved = await (0, utils_1.getApproved)(signer, approvalRequest.from, approvalRequest.to);
|
|
43
43
|
if (new bignumber_js_1.default(step.action.fromAmount).gt(approved)) {
|
|
44
44
|
if (!allowUserInteraction) {
|
|
45
45
|
return;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { TransactionRequest } from '@ethersproject/abstract-provider';
|
|
2
1
|
import { ChainId, Token } from '@lifi/types';
|
|
3
2
|
import BigNumber from 'bignumber.js';
|
|
4
3
|
import { ContractTransaction, PopulatedTransaction, Signer } from 'ethers';
|
|
5
4
|
import { RevokeTokenData } from '../types';
|
|
6
|
-
export declare const getApproved: (signer: Signer, tokenAddress: string, contractAddress: string
|
|
5
|
+
export declare const getApproved: (signer: Signer, tokenAddress: string, contractAddress: string) => Promise<BigNumber>;
|
|
7
6
|
export declare const setApproval: (signer: Signer, tokenAddress: string, contractAddress: string, amount: string, returnPopulatedTransaction?: boolean) => Promise<ContractTransaction | PopulatedTransaction>;
|
|
8
7
|
export declare const getAllowanceViaMulticall: (signer: Signer, chainId: ChainId, tokenData: RevokeTokenData[]) => Promise<{
|
|
9
8
|
token: Token;
|
|
@@ -10,16 +10,11 @@ const ChainsService_1 = __importDefault(require("../services/ChainsService"));
|
|
|
10
10
|
const types_1 = require("../types");
|
|
11
11
|
const errors_1 = require("../utils/errors");
|
|
12
12
|
const multicall_1 = require("../utils/multicall");
|
|
13
|
-
const getApproved = async (signer, tokenAddress, contractAddress
|
|
13
|
+
const getApproved = async (signer, tokenAddress, contractAddress) => {
|
|
14
14
|
const signerAddress = await signer.getAddress();
|
|
15
15
|
const erc20 = new ethers_1.Contract(tokenAddress, types_1.ERC20_ABI, signer);
|
|
16
16
|
try {
|
|
17
|
-
const approved = await erc20.allowance(signerAddress, contractAddress
|
|
18
|
-
gasLimit: transactionRequest?.gasLimit,
|
|
19
|
-
gasPrice: transactionRequest?.gasPrice,
|
|
20
|
-
maxFeePerGas: transactionRequest?.maxFeePerGas,
|
|
21
|
-
maxPriorityFeePerGas: transactionRequest?.maxPriorityFeePerGas,
|
|
22
|
-
});
|
|
17
|
+
const approved = await erc20.allowance(signerAddress, contractAddress);
|
|
23
18
|
return new bignumber_js_1.default(approved.toString());
|
|
24
19
|
}
|
|
25
20
|
catch (e) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { ConnectionsRequest, ConnectionsResponse, ContractCallQuoteRequest, GasRecommendationRequest, GasRecommendationResponse, GetStatusRequest, LifiStep, QuoteRequest, RequestOptions, TokensRequest, TokensResponse } from '@lifi/types';
|
|
1
|
+
import { ConnectionsRequest, ConnectionsResponse, ContractCallQuoteRequest, ContractCallsQuoteRequest, GasRecommendationRequest, GasRecommendationResponse, GetStatusRequest, LifiStep, QuoteRequest, RequestOptions, TokensRequest, TokensResponse } from '@lifi/types';
|
|
2
2
|
import { ChainId, ChainKey, ExtendedChain, PossibilitiesRequest, PossibilitiesResponse, RoutesRequest, RoutesResponse, StatusResponse, Token, ToolsRequest, ToolsResponse } from '../types';
|
|
3
3
|
declare const _default: {
|
|
4
4
|
getChains: (options?: RequestOptions | undefined) => Promise<ExtendedChain[]>;
|
|
5
5
|
getContractCallQuote: (requestConfig: ContractCallQuoteRequest, options?: RequestOptions | undefined) => Promise<LifiStep>;
|
|
6
|
+
getContractCallsQuote: (requestConfig: ContractCallsQuoteRequest, options?: RequestOptions | undefined) => Promise<LifiStep>;
|
|
6
7
|
getGasRecommendation: ({ chainId, fromChain, fromToken }: GasRecommendationRequest, options?: RequestOptions | undefined) => Promise<GasRecommendationResponse>;
|
|
7
8
|
getPossibilities: (requestConfig?: PossibilitiesRequest | undefined, options?: RequestOptions | undefined) => Promise<PossibilitiesResponse>;
|
|
8
9
|
getQuote: (requestConfig: QuoteRequest, options?: RequestOptions | undefined) => Promise<LifiStep>;
|
|
@@ -13,5 +14,6 @@ declare const _default: {
|
|
|
13
14
|
getTokens: (requestConfig?: TokensRequest | undefined, options?: RequestOptions | undefined) => Promise<TokensResponse>;
|
|
14
15
|
getTools: (requestConfig?: ToolsRequest | undefined, options?: RequestOptions | undefined) => Promise<ToolsResponse>;
|
|
15
16
|
getAvailableConnections: (connectionRequest: ConnectionsRequest) => Promise<ConnectionsResponse>;
|
|
17
|
+
getTransactionHistory: (address: string) => Promise<StatusResponse[]>;
|
|
16
18
|
};
|
|
17
19
|
export default _default;
|
|
@@ -148,6 +148,53 @@ const getContractCallQuote = async (requestConfig, options) => {
|
|
|
148
148
|
throw await (0, parseError_1.parseBackendError)(e);
|
|
149
149
|
}
|
|
150
150
|
};
|
|
151
|
+
const getContractCallsQuote = async (requestConfig, options) => {
|
|
152
|
+
const config = ConfigService_1.default.getInstance().getConfig();
|
|
153
|
+
// validation
|
|
154
|
+
const requiredParameters = [
|
|
155
|
+
'fromChain',
|
|
156
|
+
'fromToken',
|
|
157
|
+
'fromAddress',
|
|
158
|
+
'toChain',
|
|
159
|
+
'toToken',
|
|
160
|
+
'toAmount',
|
|
161
|
+
'contractCalls',
|
|
162
|
+
];
|
|
163
|
+
if (requestConfig.contractCalls.length === 0) {
|
|
164
|
+
throw new errors_1.ValidationError(`Parameter "contractCalls" is empty.`);
|
|
165
|
+
}
|
|
166
|
+
requiredParameters.forEach((requiredParameter) => {
|
|
167
|
+
if (!requestConfig[requiredParameter]) {
|
|
168
|
+
throw new errors_1.ValidationError(`Required parameter "${requiredParameter}" is missing.`);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
// apply defaults
|
|
172
|
+
// option.order is not used in this endpoint
|
|
173
|
+
requestConfig.slippage || (requestConfig.slippage = config.defaultRouteOptions.slippage);
|
|
174
|
+
requestConfig.integrator || (requestConfig.integrator = config.defaultRouteOptions.integrator);
|
|
175
|
+
requestConfig.referrer || (requestConfig.referrer = config.defaultRouteOptions.referrer);
|
|
176
|
+
requestConfig.allowBridges || (requestConfig.allowBridges = config.defaultRouteOptions.bridges?.allow);
|
|
177
|
+
requestConfig.denyBridges || (requestConfig.denyBridges = config.defaultRouteOptions.bridges?.deny);
|
|
178
|
+
requestConfig.preferBridges || (requestConfig.preferBridges = config.defaultRouteOptions.bridges?.prefer);
|
|
179
|
+
requestConfig.allowExchanges || (requestConfig.allowExchanges = config.defaultRouteOptions.exchanges?.allow);
|
|
180
|
+
requestConfig.denyExchanges || (requestConfig.denyExchanges = config.defaultRouteOptions.exchanges?.deny);
|
|
181
|
+
requestConfig.preferExchanges || (requestConfig.preferExchanges = config.defaultRouteOptions.exchanges?.prefer);
|
|
182
|
+
// send request
|
|
183
|
+
try {
|
|
184
|
+
const response = await (0, request_1.request)(`${config.apiUrl}/quote/contractCalls`, {
|
|
185
|
+
method: 'POST',
|
|
186
|
+
headers: {
|
|
187
|
+
'Content-Type': 'application/json',
|
|
188
|
+
},
|
|
189
|
+
body: JSON.stringify(requestConfig),
|
|
190
|
+
signal: options?.signal,
|
|
191
|
+
});
|
|
192
|
+
return response;
|
|
193
|
+
}
|
|
194
|
+
catch (e) {
|
|
195
|
+
throw await (0, parseError_1.parseBackendError)(e);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
151
198
|
const getStatus = async (requestConfig, options) => {
|
|
152
199
|
if (!requestConfig.txHash) {
|
|
153
200
|
throw new errors_1.ValidationError('Required parameter "txHash" is missing.');
|
|
@@ -308,9 +355,15 @@ const getAvailableConnections = async (connectionRequest) => {
|
|
|
308
355
|
throw await (0, parseError_1.parseBackendError)(e);
|
|
309
356
|
}
|
|
310
357
|
};
|
|
358
|
+
const getTransactionHistory = async (address) => {
|
|
359
|
+
const config = ConfigService_1.default.getInstance().getConfig();
|
|
360
|
+
const response = await (0, request_1.request)(`${config.apiUrl}/analytics/wallets/${address}`);
|
|
361
|
+
return response;
|
|
362
|
+
};
|
|
311
363
|
exports.default = {
|
|
312
364
|
getChains,
|
|
313
365
|
getContractCallQuote,
|
|
366
|
+
getContractCallsQuote,
|
|
314
367
|
getGasRecommendation,
|
|
315
368
|
getPossibilities,
|
|
316
369
|
getQuote,
|
|
@@ -321,4 +374,5 @@ exports.default = {
|
|
|
321
374
|
getTokens,
|
|
322
375
|
getTools,
|
|
323
376
|
getAvailableConnections,
|
|
377
|
+
getTransactionHistory,
|
|
324
378
|
};
|
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.4.0";
|
package/dist/cjs/version.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { ConnectionsRequest, ConnectionsResponse, ContractCallQuoteRequest, GasRecommendationRequest, GasRecommendationResponse, GetStatusRequest, LifiStep, QuoteRequest, RequestOptions, TokensRequest, TokensResponse } from '@lifi/types';
|
|
1
|
+
import { ConnectionsRequest, ConnectionsResponse, ContractCallQuoteRequest, ContractCallsQuoteRequest, GasRecommendationRequest, GasRecommendationResponse, GetStatusRequest, LifiStep, QuoteRequest, RequestOptions, TokensRequest, TokensResponse } from '@lifi/types';
|
|
2
2
|
import { ChainId, ChainKey, ExtendedChain, PossibilitiesRequest, PossibilitiesResponse, RoutesRequest, RoutesResponse, StatusResponse, Token, ToolsRequest, ToolsResponse } from '../types';
|
|
3
3
|
declare const _default: {
|
|
4
4
|
getChains: (options?: RequestOptions | undefined) => Promise<ExtendedChain[]>;
|
|
5
5
|
getContractCallQuote: (requestConfig: ContractCallQuoteRequest, options?: RequestOptions | undefined) => Promise<LifiStep>;
|
|
6
|
+
getContractCallsQuote: (requestConfig: ContractCallsQuoteRequest, options?: RequestOptions | undefined) => Promise<LifiStep>;
|
|
6
7
|
getGasRecommendation: ({ chainId, fromChain, fromToken }: GasRecommendationRequest, options?: RequestOptions | undefined) => Promise<GasRecommendationResponse>;
|
|
7
8
|
getPossibilities: (requestConfig?: PossibilitiesRequest | undefined, options?: RequestOptions | undefined) => Promise<PossibilitiesResponse>;
|
|
8
9
|
getQuote: (requestConfig: QuoteRequest, options?: RequestOptions | undefined) => Promise<LifiStep>;
|
|
@@ -13,5 +14,6 @@ declare const _default: {
|
|
|
13
14
|
getTokens: (requestConfig?: TokensRequest | undefined, options?: RequestOptions | undefined) => Promise<TokensResponse>;
|
|
14
15
|
getTools: (requestConfig?: ToolsRequest | undefined, options?: RequestOptions | undefined) => Promise<ToolsResponse>;
|
|
15
16
|
getAvailableConnections: (connectionRequest: ConnectionsRequest) => Promise<ConnectionsResponse>;
|
|
17
|
+
getTransactionHistory: (address: string) => Promise<StatusResponse[]>;
|
|
16
18
|
};
|
|
17
19
|
export default _default;
|
|
@@ -143,6 +143,53 @@ const getContractCallQuote = async (requestConfig, options) => {
|
|
|
143
143
|
throw await parseBackendError(e);
|
|
144
144
|
}
|
|
145
145
|
};
|
|
146
|
+
const getContractCallsQuote = async (requestConfig, options) => {
|
|
147
|
+
const config = ConfigService.getInstance().getConfig();
|
|
148
|
+
// validation
|
|
149
|
+
const requiredParameters = [
|
|
150
|
+
'fromChain',
|
|
151
|
+
'fromToken',
|
|
152
|
+
'fromAddress',
|
|
153
|
+
'toChain',
|
|
154
|
+
'toToken',
|
|
155
|
+
'toAmount',
|
|
156
|
+
'contractCalls',
|
|
157
|
+
];
|
|
158
|
+
if (requestConfig.contractCalls.length === 0) {
|
|
159
|
+
throw new ValidationError(`Parameter "contractCalls" is empty.`);
|
|
160
|
+
}
|
|
161
|
+
requiredParameters.forEach((requiredParameter) => {
|
|
162
|
+
if (!requestConfig[requiredParameter]) {
|
|
163
|
+
throw new ValidationError(`Required parameter "${requiredParameter}" is missing.`);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
// apply defaults
|
|
167
|
+
// option.order is not used in this endpoint
|
|
168
|
+
requestConfig.slippage || (requestConfig.slippage = config.defaultRouteOptions.slippage);
|
|
169
|
+
requestConfig.integrator || (requestConfig.integrator = config.defaultRouteOptions.integrator);
|
|
170
|
+
requestConfig.referrer || (requestConfig.referrer = config.defaultRouteOptions.referrer);
|
|
171
|
+
requestConfig.allowBridges || (requestConfig.allowBridges = config.defaultRouteOptions.bridges?.allow);
|
|
172
|
+
requestConfig.denyBridges || (requestConfig.denyBridges = config.defaultRouteOptions.bridges?.deny);
|
|
173
|
+
requestConfig.preferBridges || (requestConfig.preferBridges = config.defaultRouteOptions.bridges?.prefer);
|
|
174
|
+
requestConfig.allowExchanges || (requestConfig.allowExchanges = config.defaultRouteOptions.exchanges?.allow);
|
|
175
|
+
requestConfig.denyExchanges || (requestConfig.denyExchanges = config.defaultRouteOptions.exchanges?.deny);
|
|
176
|
+
requestConfig.preferExchanges || (requestConfig.preferExchanges = config.defaultRouteOptions.exchanges?.prefer);
|
|
177
|
+
// send request
|
|
178
|
+
try {
|
|
179
|
+
const response = await request(`${config.apiUrl}/quote/contractCalls`, {
|
|
180
|
+
method: 'POST',
|
|
181
|
+
headers: {
|
|
182
|
+
'Content-Type': 'application/json',
|
|
183
|
+
},
|
|
184
|
+
body: JSON.stringify(requestConfig),
|
|
185
|
+
signal: options?.signal,
|
|
186
|
+
});
|
|
187
|
+
return response;
|
|
188
|
+
}
|
|
189
|
+
catch (e) {
|
|
190
|
+
throw await parseBackendError(e);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
146
193
|
const getStatus = async (requestConfig, options) => {
|
|
147
194
|
if (!requestConfig.txHash) {
|
|
148
195
|
throw new ValidationError('Required parameter "txHash" is missing.');
|
|
@@ -303,9 +350,15 @@ const getAvailableConnections = async (connectionRequest) => {
|
|
|
303
350
|
throw await parseBackendError(e);
|
|
304
351
|
}
|
|
305
352
|
};
|
|
353
|
+
const getTransactionHistory = async (address) => {
|
|
354
|
+
const config = ConfigService.getInstance().getConfig();
|
|
355
|
+
const response = await request(`${config.apiUrl}/analytics/wallets/${address}`);
|
|
356
|
+
return response;
|
|
357
|
+
};
|
|
306
358
|
export default {
|
|
307
359
|
getChains,
|
|
308
360
|
getContractCallQuote,
|
|
361
|
+
getContractCallsQuote,
|
|
309
362
|
getGasRecommendation,
|
|
310
363
|
getPossibilities,
|
|
311
364
|
getQuote,
|
|
@@ -316,4 +369,5 @@ export default {
|
|
|
316
369
|
getTokens,
|
|
317
370
|
getTools,
|
|
318
371
|
getAvailableConnections,
|
|
372
|
+
getTransactionHistory,
|
|
319
373
|
};
|
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.4.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.4.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.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,31 +77,31 @@
|
|
|
77
77
|
"dependencies": {
|
|
78
78
|
"@ethersproject/abi": "^5.7.0",
|
|
79
79
|
"@ethersproject/contracts": "^5.7.0",
|
|
80
|
-
"@lifi/types": "^8.
|
|
81
|
-
"bignumber.js": "^9.1.
|
|
80
|
+
"@lifi/types": "^8.7.1",
|
|
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": "^17.
|
|
87
|
-
"@commitlint/config-conventional": "^17.
|
|
86
|
+
"@commitlint/cli": "^17.7.1",
|
|
87
|
+
"@commitlint/config-conventional": "^17.7.0",
|
|
88
88
|
"@mswjs/interceptors": "^0.22.16",
|
|
89
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
90
|
-
"@typescript-eslint/parser": "^6.
|
|
89
|
+
"@typescript-eslint/eslint-plugin": "^6.7.2",
|
|
90
|
+
"@typescript-eslint/parser": "^6.7.2",
|
|
91
91
|
"@vitest/coverage-c8": "^0.33.0",
|
|
92
92
|
"cross-fetch": "^4.0.0",
|
|
93
|
-
"eslint": "^8.
|
|
94
|
-
"eslint-config-prettier": "^
|
|
93
|
+
"eslint": "^8.49.0",
|
|
94
|
+
"eslint-config-prettier": "^9.0.0",
|
|
95
95
|
"eslint-plugin-prettier": "^5.0.0",
|
|
96
96
|
"husky": "^8.0.3",
|
|
97
|
-
"lint-staged": "^
|
|
97
|
+
"lint-staged": "^14.0.1",
|
|
98
98
|
"msw": "1.0.1",
|
|
99
99
|
"npm-run-all": "^4.1.5",
|
|
100
100
|
"pinst": "^3.0.0",
|
|
101
|
-
"prettier": "^3.0.
|
|
101
|
+
"prettier": "^3.0.3",
|
|
102
102
|
"standard-version": "^9.5.0",
|
|
103
|
-
"typescript": "^5.
|
|
104
|
-
"vitest": "^0.
|
|
103
|
+
"typescript": "^5.2.2",
|
|
104
|
+
"vitest": "^0.34.4"
|
|
105
105
|
},
|
|
106
106
|
"directories": {
|
|
107
107
|
"test": "test"
|