@lifi/sdk 2.0.0-beta.1 → 2.0.0-beta.3

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  import { FallbackProvider } from '@ethersproject/providers';
2
- import { ChainId, ChainKey, ContractCallQuoteRequest, ExtendedChain, GetStatusRequest, PossibilitiesRequest, PossibilitiesResponse, QuoteRequest, RequestOptions, Route, RoutesRequest, RoutesResponse, StatusResponse, Step, Token, TokenAmount, TokensRequest, TokensResponse, ToolsRequest, ToolsResponse } from '@lifi/types';
2
+ import { ChainId, ChainKey, ContractCallQuoteRequest, ExtendedChain, GasRecommendationRequest, GasRecommendationResponse, GetStatusRequest, PossibilitiesRequest, PossibilitiesResponse, QuoteRequest, RequestOptions, Route, RoutesRequest, RoutesResponse, StatusResponse, Step, 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 { Config, ConfigUpdate, ExecutionSettings, RevokeTokenData } from './types';
@@ -83,7 +83,7 @@ export default class LIFI {
83
83
  getChains: () => Promise<ExtendedChain[]>;
84
84
  /**
85
85
  * Get a set of routes for a request that describes a transfer of tokens.
86
- * @param {RoutesRequest} routesRequest - A description of the transfer.
86
+ * @param {RoutesRequest} request - A description of the transfer.
87
87
  * @return {Promise<RoutesResponse>} The resulting routes that can be used to realize the described transfer of tokens.
88
88
  * @throws {LifiError} Throws a LifiError if request fails.
89
89
  */
@@ -95,6 +95,12 @@ export default class LIFI {
95
95
  * @throws {LifiError} Throws a LifiError if request fails.
96
96
  */
97
97
  getStepTransaction: (step: Step, options?: RequestOptions) => Promise<Step>;
98
+ /**
99
+ * Get gas recommendation for a certain chain
100
+ * @param {GasRecommendationRequest} request - Configuration of the requested recommendation.
101
+ * @throws {LifiError} Throws a LifiError if request fails.
102
+ */
103
+ getGasRecommendation: (request: GasRecommendationRequest, options?: RequestOptions) => Promise<GasRecommendationResponse>;
98
104
  /**
99
105
  * Stops the execution of an active route.
100
106
  * @param {Route} route - A route that is currently in execution.
package/dist/Lifi.js CHANGED
@@ -113,7 +113,7 @@ export default class LIFI {
113
113
  };
114
114
  /**
115
115
  * Get a set of routes for a request that describes a transfer of tokens.
116
- * @param {RoutesRequest} routesRequest - A description of the transfer.
116
+ * @param {RoutesRequest} request - A description of the transfer.
117
117
  * @return {Promise<RoutesResponse>} The resulting routes that can be used to realize the described transfer of tokens.
118
118
  * @throws {LifiError} Throws a LifiError if request fails.
119
119
  */
@@ -129,6 +129,14 @@ export default class LIFI {
129
129
  this.getStepTransaction = async (step, options) => {
130
130
  return ApiService.getStepTransaction(step, options);
131
131
  };
132
+ /**
133
+ * Get gas recommendation for a certain chain
134
+ * @param {GasRecommendationRequest} request - Configuration of the requested recommendation.
135
+ * @throws {LifiError} Throws a LifiError if request fails.
136
+ */
137
+ this.getGasRecommendation = async (request, options) => {
138
+ return ApiService.getGasRecommendation(request, options);
139
+ };
132
140
  /**
133
141
  * Stops the execution of an active route.
134
142
  * @param {Route} route - A route that is currently in execution.
@@ -1,5 +1,5 @@
1
1
  import { FallbackProvider } from '@ethersproject/providers';
2
- import { ChainId, ChainKey, ContractCallQuoteRequest, ExtendedChain, GetStatusRequest, PossibilitiesRequest, PossibilitiesResponse, QuoteRequest, RequestOptions, Route, RoutesRequest, RoutesResponse, StatusResponse, Step, Token, TokenAmount, TokensRequest, TokensResponse, ToolsRequest, ToolsResponse } from '@lifi/types';
2
+ import { ChainId, ChainKey, ContractCallQuoteRequest, ExtendedChain, GasRecommendationRequest, GasRecommendationResponse, GetStatusRequest, PossibilitiesRequest, PossibilitiesResponse, QuoteRequest, RequestOptions, Route, RoutesRequest, RoutesResponse, StatusResponse, Step, 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 { Config, ConfigUpdate, ExecutionSettings, RevokeTokenData } from './types';
@@ -83,7 +83,7 @@ export default class LIFI {
83
83
  getChains: () => Promise<ExtendedChain[]>;
84
84
  /**
85
85
  * Get a set of routes for a request that describes a transfer of tokens.
86
- * @param {RoutesRequest} routesRequest - A description of the transfer.
86
+ * @param {RoutesRequest} request - A description of the transfer.
87
87
  * @return {Promise<RoutesResponse>} The resulting routes that can be used to realize the described transfer of tokens.
88
88
  * @throws {LifiError} Throws a LifiError if request fails.
89
89
  */
@@ -95,6 +95,12 @@ export default class LIFI {
95
95
  * @throws {LifiError} Throws a LifiError if request fails.
96
96
  */
97
97
  getStepTransaction: (step: Step, options?: RequestOptions) => Promise<Step>;
98
+ /**
99
+ * Get gas recommendation for a certain chain
100
+ * @param {GasRecommendationRequest} request - Configuration of the requested recommendation.
101
+ * @throws {LifiError} Throws a LifiError if request fails.
102
+ */
103
+ getGasRecommendation: (request: GasRecommendationRequest, options?: RequestOptions) => Promise<GasRecommendationResponse>;
98
104
  /**
99
105
  * Stops the execution of an active route.
100
106
  * @param {Route} route - A route that is currently in execution.
package/dist/cjs/Lifi.js CHANGED
@@ -141,7 +141,7 @@ class LIFI {
141
141
  };
142
142
  /**
143
143
  * Get a set of routes for a request that describes a transfer of tokens.
144
- * @param {RoutesRequest} routesRequest - A description of the transfer.
144
+ * @param {RoutesRequest} request - A description of the transfer.
145
145
  * @return {Promise<RoutesResponse>} The resulting routes that can be used to realize the described transfer of tokens.
146
146
  * @throws {LifiError} Throws a LifiError if request fails.
147
147
  */
@@ -157,6 +157,14 @@ class LIFI {
157
157
  this.getStepTransaction = async (step, options) => {
158
158
  return ApiService_1.default.getStepTransaction(step, options);
159
159
  };
160
+ /**
161
+ * Get gas recommendation for a certain chain
162
+ * @param {GasRecommendationRequest} request - Configuration of the requested recommendation.
163
+ * @throws {LifiError} Throws a LifiError if request fails.
164
+ */
165
+ this.getGasRecommendation = async (request, options) => {
166
+ return ApiService_1.default.getGasRecommendation(request, options);
167
+ };
160
168
  /**
161
169
  * Stops the execution of an active route.
162
170
  * @param {Route} route - A route that is currently in execution.
@@ -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: ({ chainId, fromChain, fromToken }: GasRecommendationRequest, options?: RequestOptions | undefined) => Promise<GasRecommendationResponse>;
6
+ getGasRecommendation: (requestConfig: 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>;
@@ -277,15 +277,17 @@ const getTokens = async (requestConfig, options) => {
277
277
  });
278
278
  return response;
279
279
  };
280
- const getGasRecommendation = async ({ chainId, fromChain, fromToken }, options) => {
280
+ const getGasRecommendation = async (requestConfig, options) => {
281
281
  const config = ConfigService_1.default.getInstance().getConfig();
282
- if (!chainId) {
282
+ Object.keys(requestConfig).forEach((key) => !requestConfig[key] &&
283
+ delete requestConfig[key]);
284
+ if (!requestConfig.chainId) {
283
285
  throw new errors_1.ValidationError('Required parameter "chainId" is missing.');
284
286
  }
285
287
  try {
286
- const response = await (0, helpers_1.request)(`${config.apiUrl}/gas/suggestion/${chainId}?${new URLSearchParams({
287
- fromChain,
288
- fromToken,
288
+ const response = await (0, helpers_1.request)(`${config.apiUrl}/gas/suggestion/${requestConfig.chainId}?${new URLSearchParams({
289
+ fromChain: requestConfig.fromChain,
290
+ fromToken: requestConfig.fromToken,
289
291
  })}`, {
290
292
  signal: options?.signal,
291
293
  });
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/sdk";
2
- export declare const version = "2.0.0-beta.1";
2
+ export declare const version = "2.0.0-beta.3";
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = exports.name = void 0;
4
4
  exports.name = '@lifi/sdk';
5
- exports.version = '2.0.0-beta.1';
5
+ exports.version = '2.0.0-beta.3';
@@ -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: ({ chainId, fromChain, fromToken }: GasRecommendationRequest, options?: RequestOptions | undefined) => Promise<GasRecommendationResponse>;
6
+ getGasRecommendation: (requestConfig: 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,15 +272,17 @@ const getTokens = async (requestConfig, options) => {
272
272
  });
273
273
  return response;
274
274
  };
275
- const getGasRecommendation = async ({ chainId, fromChain, fromToken }, options) => {
275
+ const getGasRecommendation = async (requestConfig, options) => {
276
276
  const config = ConfigService.getInstance().getConfig();
277
- if (!chainId) {
277
+ Object.keys(requestConfig).forEach((key) => !requestConfig[key] &&
278
+ delete requestConfig[key]);
279
+ if (!requestConfig.chainId) {
278
280
  throw new ValidationError('Required parameter "chainId" is missing.');
279
281
  }
280
282
  try {
281
- const response = await request(`${config.apiUrl}/gas/suggestion/${chainId}?${new URLSearchParams({
282
- fromChain,
283
- fromToken,
283
+ const response = await request(`${config.apiUrl}/gas/suggestion/${requestConfig.chainId}?${new URLSearchParams({
284
+ fromChain: requestConfig.fromChain,
285
+ fromToken: requestConfig.fromToken,
284
286
  })}`, {
285
287
  signal: options?.signal,
286
288
  });
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.1";
2
+ export declare const version = "2.0.0-beta.3";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/sdk';
2
- export const version = '2.0.0-beta.1';
2
+ export const version = '2.0.0-beta.3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/sdk",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.3",
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",