@lifi/sdk 2.0.0-beta.6 → 2.0.0-beta.8

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.
Files changed (47) hide show
  1. package/dist/LiFi.d.ts +11 -5
  2. package/dist/LiFi.js +10 -1
  3. package/dist/allowance/checkAllowance.d.ts +2 -2
  4. package/dist/balance/checkBalance.d.ts +2 -2
  5. package/dist/balance/index.d.ts +1 -1
  6. package/dist/cjs/LiFi.d.ts +11 -5
  7. package/dist/cjs/LiFi.js +12 -2
  8. package/dist/cjs/allowance/checkAllowance.d.ts +2 -2
  9. package/dist/cjs/balance/checkBalance.d.ts +2 -2
  10. package/dist/cjs/balance/index.d.ts +1 -1
  11. package/dist/cjs/execution/StatusManager.d.ts +12 -12
  12. package/dist/cjs/execution/StatusManager.js +5 -5
  13. package/dist/cjs/execution/StepExecutor.d.ts +2 -2
  14. package/dist/cjs/execution/stepComparison.d.ts +2 -2
  15. package/dist/cjs/execution/switchChain.d.ts +2 -2
  16. package/dist/cjs/execution/utils.d.ts +3 -3
  17. package/dist/cjs/helpers.d.ts +3 -7
  18. package/dist/cjs/helpers.js +5 -62
  19. package/dist/cjs/request.d.ts +9 -0
  20. package/dist/cjs/request.js +60 -0
  21. package/dist/cjs/services/ApiService.d.ts +7 -6
  22. package/dist/cjs/services/ApiService.js +45 -28
  23. package/dist/cjs/typeguards.d.ts +2 -2
  24. package/dist/cjs/types/internal.types.d.ts +2 -2
  25. package/dist/cjs/utils/parseError.d.ts +4 -4
  26. package/dist/cjs/utils/utils.d.ts +3 -3
  27. package/dist/cjs/version.d.ts +1 -1
  28. package/dist/cjs/version.js +1 -1
  29. package/dist/execution/StatusManager.d.ts +12 -12
  30. package/dist/execution/StatusManager.js +5 -5
  31. package/dist/execution/StepExecutor.d.ts +2 -2
  32. package/dist/execution/stepComparison.d.ts +2 -2
  33. package/dist/execution/switchChain.d.ts +2 -2
  34. package/dist/execution/utils.d.ts +3 -3
  35. package/dist/helpers.d.ts +3 -7
  36. package/dist/helpers.js +5 -58
  37. package/dist/request.d.ts +9 -0
  38. package/dist/request.js +53 -0
  39. package/dist/services/ApiService.d.ts +7 -6
  40. package/dist/services/ApiService.js +35 -18
  41. package/dist/typeguards.d.ts +2 -2
  42. package/dist/types/internal.types.d.ts +2 -2
  43. package/dist/utils/parseError.d.ts +4 -4
  44. package/dist/utils/utils.d.ts +3 -3
  45. package/dist/version.d.ts +1 -1
  46. package/dist/version.js +1 -1
  47. package/package.json +11 -11
@@ -1,4 +1,4 @@
1
- import { request } from '../helpers';
1
+ import { request } from '../request';
2
2
  import { isRoutesRequest, isStep } from '../typeguards';
3
3
  import { ValidationError } from '../utils/errors';
4
4
  import { parseBackendError } from '../utils/parseError';
@@ -161,27 +161,14 @@ const getContractCallQuote = async (requestConfig, options) => {
161
161
  throw await parseBackendError(e);
162
162
  }
163
163
  };
164
- const getStatus = async ({ bridge, fromChain, toChain, txHash }, options) => {
165
- if (fromChain !== toChain && !bridge) {
166
- throw new ValidationError('Parameter "bridge" is required for cross chain transfers.');
167
- }
168
- if (!fromChain) {
169
- throw new ValidationError('Required parameter "fromChain" is missing.');
170
- }
171
- if (!toChain) {
172
- throw new ValidationError('Required parameter "toChain" is missing.');
173
- }
174
- if (!txHash) {
164
+ const getStatus = async (requestConfig, options) => {
165
+ if (!requestConfig.txHash) {
175
166
  throw new ValidationError('Required parameter "txHash" is missing.');
176
167
  }
177
168
  const config = ConfigService.getInstance().getConfig();
169
+ const queryParams = new URLSearchParams(requestConfig);
178
170
  try {
179
- const response = await request(`${config.apiUrl}/status?${new URLSearchParams({
180
- bridge,
181
- fromChain,
182
- toChain,
183
- txHash,
184
- })}`, {
171
+ const response = await request(`${config.apiUrl}/status?${queryParams}`, {
185
172
  signal: options?.signal,
186
173
  });
187
174
  return response;
@@ -294,6 +281,35 @@ const getGasRecommendation = async ({ chainId, fromChain, fromToken }, options)
294
281
  throw await parseBackendError(e);
295
282
  }
296
283
  };
284
+ const getAvailableConnections = async (connectionRequest) => {
285
+ const config = ConfigService.getInstance().getConfig();
286
+ const url = new URL(`${config.apiUrl}/connections`);
287
+ const { fromChain, fromToken, toChain, toToken, allowBridges } = connectionRequest;
288
+ if (fromChain) {
289
+ url.searchParams.append('fromChain', fromChain);
290
+ }
291
+ if (fromToken) {
292
+ url.searchParams.append('fromToken', fromToken);
293
+ }
294
+ if (toChain) {
295
+ url.searchParams.append('fromToken', toChain);
296
+ }
297
+ if (toToken) {
298
+ url.searchParams.append('fromToken', toToken);
299
+ }
300
+ if (allowBridges?.length) {
301
+ allowBridges.forEach((bridge) => {
302
+ url.searchParams.append('allowBridges', bridge);
303
+ });
304
+ }
305
+ try {
306
+ const response = await request(url);
307
+ return response;
308
+ }
309
+ catch (e) {
310
+ throw await parseBackendError(e);
311
+ }
312
+ };
297
313
  export default {
298
314
  getChains,
299
315
  getContractCallQuote,
@@ -306,4 +322,5 @@ export default {
306
322
  getToken,
307
323
  getTokens,
308
324
  getTools,
325
+ getAvailableConnections,
309
326
  };
@@ -1,4 +1,4 @@
1
- import { RoutesRequest, Step, Token } from './types';
1
+ import { LifiStep, RoutesRequest, Token } from './types';
2
2
  export declare const isRoutesRequest: (routesRequest: RoutesRequest) => routesRequest is RoutesRequest;
3
- export declare const isStep: (step: Step) => step is Step;
3
+ export declare const isStep: (step: LifiStep) => step is LifiStep;
4
4
  export declare const isToken: (token: Token) => token is Token;
@@ -1,4 +1,4 @@
1
- import { Route, RouteOptions, Step, Token } from '@lifi/types';
1
+ import { LifiStep, Route, RouteOptions, Token } from '@lifi/types';
2
2
  import BigNumber from 'bignumber.js';
3
3
  import { Signer } from 'ethers';
4
4
  import { ChainId } from '.';
@@ -18,7 +18,7 @@ export type ParsedReceipt = {
18
18
  };
19
19
  export interface ExecutionParams {
20
20
  signer: Signer;
21
- step: Step;
21
+ step: LifiStep;
22
22
  statusManager: StatusManager;
23
23
  settings: InternalExecutionSettings;
24
24
  }
@@ -1,4 +1,4 @@
1
- import { Process, Step } from '@lifi/types';
1
+ import { LifiStep, Process } from '@lifi/types';
2
2
  import { LifiError } from './errors';
3
3
  /**
4
4
  * Available MetaMask error codes:
@@ -31,7 +31,7 @@ import { LifiError } from './errors';
31
31
  * https://eips.ethereum.org/EIPS/eip-1474#error-codes
32
32
  * https://eips.ethereum.org/EIPS/eip-1193#provider-errors
33
33
  */
34
- export declare const getTransactionNotSentMessage: (step?: Step, process?: Process) => Promise<string>;
35
- export declare const getTransactionFailedMessage: (step: Step, txLink?: string) => Promise<string>;
36
- export declare const parseError: (e: any, step?: Step, process?: Process) => Promise<LifiError>;
34
+ export declare const getTransactionNotSentMessage: (step?: LifiStep, process?: Process) => Promise<string>;
35
+ export declare const getTransactionFailedMessage: (step: LifiStep, txLink?: string) => Promise<string>;
36
+ export declare const parseError: (e: any, step?: LifiStep, process?: Process) => Promise<LifiError>;
37
37
  export declare const parseBackendError: (e: any) => Promise<LifiError>;
@@ -1,10 +1,10 @@
1
1
  import { TransactionReceipt } from '@ethersproject/providers';
2
- import { Token } from '@lifi/types';
2
+ import { LifiStep, Token } from '@lifi/types';
3
3
  import BigNumber from 'bignumber.js';
4
4
  import { Signer } from 'ethers';
5
- import { ChainId, Step } from '../types';
5
+ import { ChainId } from '../types';
6
6
  export declare const sleep: (mills: number) => Promise<undefined>;
7
- export declare const personalizeStep: (signer: Signer, step: Step) => Promise<Step>;
7
+ export declare const personalizeStep: (signer: Signer, step: LifiStep) => Promise<LifiStep>;
8
8
  export declare const splitListIntoChunks: <T>(list: T[], chunkSize: number) => T[][];
9
9
  export declare const formatTokenAmountOnly: (token: Token, amount: string | BigNumber | undefined) => string;
10
10
  /**
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.6";
2
+ export declare const version = "2.0.0-beta.8";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/sdk';
2
- export const version = '2.0.0-beta.6';
2
+ export const version = '2.0.0-beta.8';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/sdk",
3
- "version": "2.0.0-beta.6",
3
+ "version": "2.0.0-beta.8",
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,31 +76,31 @@
76
76
  "dependencies": {
77
77
  "@ethersproject/abi": "^5.7.0",
78
78
  "@ethersproject/contracts": "^5.7.0",
79
- "@lifi/types": "^2.5.7",
79
+ "@lifi/types": "^3.2.1",
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.4.4",
85
+ "@commitlint/cli": "^17.5.1",
86
86
  "@commitlint/config-conventional": "^17.4.4",
87
- "@typescript-eslint/eslint-plugin": "^5.56.0",
88
- "@typescript-eslint/parser": "^5.56.0",
89
- "@vitest/coverage-c8": "^0.29.7",
87
+ "@typescript-eslint/eslint-plugin": "^5.58.0",
88
+ "@typescript-eslint/parser": "^5.58.0",
89
+ "@vitest/coverage-c8": "^0.30.0",
90
90
  "cross-fetch": "^3.1.5",
91
- "eslint": "^8.36.0",
91
+ "eslint": "^8.38.0",
92
92
  "eslint-config-prettier": "^8.8.0",
93
93
  "eslint-plugin-prettier": "^4.2.1",
94
94
  "husky": "^8.0.3",
95
- "lint-staged": "^13.2.0",
95
+ "lint-staged": "^13.2.1",
96
96
  "msw": "1.0.1",
97
97
  "npm-run-all": "^4.1.5",
98
98
  "pinst": "^3.0.0",
99
- "prettier": "^2.8.5",
99
+ "prettier": "^2.8.7",
100
100
  "standard-version": "^9.5.0",
101
101
  "ts-loader": "^9.4.2",
102
- "typescript": "^5.0.2",
103
- "vitest": "^0.29.7"
102
+ "typescript": "^5.0.4",
103
+ "vitest": "^0.30.0"
104
104
  },
105
105
  "directories": {
106
106
  "test": "test"