@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
package/dist/LiFi.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { FallbackProvider } from '@ethersproject/providers';
2
- import { ChainId, ChainKey, ContractCallQuoteRequest, ExtendedChain, GasRecommendationRequest, GasRecommendationResponse, GetStatusRequest, PossibilitiesRequest, PossibilitiesResponse, QuoteRequest, RequestOptions, RoutesRequest, RoutesResponse, StatusResponse, Step, Token, TokenAmount, TokensRequest, TokensResponse, ToolsRequest, ToolsResponse } from '@lifi/types';
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';
3
3
  import { Signer } from 'ethers';
4
4
  import { ApproveTokenRequest, RevokeApprovalRequest } from './allowance';
5
5
  import { RouteExecutionManager } from './execution/RouteExecutionManager';
@@ -49,13 +49,13 @@ export declare class LiFi extends RouteExecutionManager {
49
49
  * @param {QuoteRequest} request - The configuration of the requested quote
50
50
  * @throws {LifiError} - Throws a LifiError if request fails
51
51
  */
52
- getQuote: (request: QuoteRequest, options?: RequestOptions) => Promise<Step>;
52
+ getQuote: (request: QuoteRequest, options?: RequestOptions) => Promise<LifiStep>;
53
53
  /**
54
54
  * Get a quote for a destination contract call
55
55
  * @param {ContractCallQuoteRequest} request - The configuration of the requested destination call
56
56
  * @throws {LifiError} - Throws a LifiError if request fails
57
57
  */
58
- getContractCallQuote: (request: ContractCallQuoteRequest, options?: RequestOptions) => Promise<Step>;
58
+ getContractCallQuote: (request: ContractCallQuoteRequest, options?: RequestOptions) => Promise<LifiStep>;
59
59
  /**
60
60
  * Check the status of a transfer. For cross chain transfers, the "bridge" parameter is required.
61
61
  * @param {GetStatusRequest} request - Configuration of the requested status
@@ -89,11 +89,11 @@ export declare class LiFi extends RouteExecutionManager {
89
89
  getRoutes: (request: RoutesRequest, options?: RequestOptions) => Promise<RoutesResponse>;
90
90
  /**
91
91
  * Get the transaction data for a single step of a route
92
- * @param {Step} step - The step object.
92
+ * @param {LifiStep} step - The step object.
93
93
  * @return {Promise<Step>} The step populated with the transaction data.
94
94
  * @throws {LifiError} Throws a LifiError if request fails.
95
95
  */
96
- getStepTransaction: (step: Step, options?: RequestOptions) => Promise<Step>;
96
+ getStepTransaction: (step: LifiStep, options?: RequestOptions) => Promise<LifiStep>;
97
97
  /**
98
98
  * Get gas recommendation for a certain chain
99
99
  * @param {GasRecommendationRequest} request - Configuration of the requested recommendation.
@@ -155,3 +155,9 @@ export declare class LiFi extends RouteExecutionManager {
155
155
  */
156
156
  revokeTokenApproval: (request: RevokeApprovalRequest) => Promise<void>;
157
157
  }
158
+ /**
159
+ * Get all the available connections for swap/bridging tokens
160
+ * @param connectionRequest ConnectionsRequest
161
+ * @returns ConnectionsResponse
162
+ */
163
+ export declare const getConnections: (connectionRequest: ConnectionsRequest) => Promise<ConnectionsResponse>;
package/dist/LiFi.js CHANGED
@@ -119,7 +119,7 @@ export class LiFi extends RouteExecutionManager {
119
119
  };
120
120
  /**
121
121
  * Get the transaction data for a single step of a route
122
- * @param {Step} step - The step object.
122
+ * @param {LifiStep} step - The step object.
123
123
  * @return {Promise<Step>} The step populated with the transaction data.
124
124
  * @throws {LifiError} Throws a LifiError if request fails.
125
125
  */
@@ -223,3 +223,12 @@ export class LiFi extends RouteExecutionManager {
223
223
  checkPackageUpdates(name, version, configUpdate?.disableVersionCheck);
224
224
  }
225
225
  }
226
+ /**
227
+ * Get all the available connections for swap/bridging tokens
228
+ * @param connectionRequest ConnectionsRequest
229
+ * @returns ConnectionsResponse
230
+ */
231
+ export const getConnections = async (connectionRequest) => {
232
+ const connections = await ApiService.getAvailableConnections(connectionRequest);
233
+ return connections;
234
+ };
@@ -1,4 +1,4 @@
1
1
  import { Signer } from 'ethers';
2
2
  import { StatusManager } from '../execution/StatusManager';
3
- import { Chain, InternalExecutionSettings, Step } from '../types';
4
- export declare const checkAllowance: (signer: Signer, step: Step, statusManager: StatusManager, settings: InternalExecutionSettings, chain: Chain, allowUserInteraction?: boolean) => Promise<void>;
3
+ import { Chain, InternalExecutionSettings, LifiStep } from '../types';
4
+ export declare const checkAllowance: (signer: Signer, step: LifiStep, statusManager: StatusManager, settings: InternalExecutionSettings, chain: Chain, allowUserInteraction?: boolean) => Promise<void>;
@@ -1,3 +1,3 @@
1
1
  import { ethers } from 'ethers';
2
- import { Step } from '..';
3
- export declare const checkBalance: (signer: ethers.Signer, step: Step, depth?: number) => Promise<void>;
2
+ import { LifiStep } from '..';
3
+ export declare const checkBalance: (signer: ethers.Signer, step: LifiStep, depth?: number) => Promise<void>;
@@ -1,7 +1,7 @@
1
1
  export * from './checkBalance';
2
2
  export * from './getTokenBalance';
3
3
  declare const _default: {
4
- checkBalance: (signer: import("ethers").Signer, step: import("@lifi/types").Step, depth?: number) => Promise<void>;
4
+ checkBalance: (signer: import("ethers").Signer, step: import("@lifi/types").LifiStep, depth?: number) => Promise<void>;
5
5
  getTokenBalance: (walletAddress: string, token: import("@lifi/types").Token) => Promise<import("@lifi/types").TokenAmount | null>;
6
6
  getTokenBalances: (walletAddress: string, tokens: import("@lifi/types").Token[]) => Promise<import("@lifi/types").TokenAmount[]>;
7
7
  getTokenBalancesForChains: (walletAddress: string, tokensByChain: {
@@ -1,5 +1,5 @@
1
1
  import { FallbackProvider } from '@ethersproject/providers';
2
- import { ChainId, ChainKey, ContractCallQuoteRequest, ExtendedChain, GasRecommendationRequest, GasRecommendationResponse, GetStatusRequest, PossibilitiesRequest, PossibilitiesResponse, QuoteRequest, RequestOptions, RoutesRequest, RoutesResponse, StatusResponse, Step, Token, TokenAmount, TokensRequest, TokensResponse, ToolsRequest, ToolsResponse } from '@lifi/types';
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';
3
3
  import { Signer } from 'ethers';
4
4
  import { ApproveTokenRequest, RevokeApprovalRequest } from './allowance';
5
5
  import { RouteExecutionManager } from './execution/RouteExecutionManager';
@@ -49,13 +49,13 @@ export declare class LiFi extends RouteExecutionManager {
49
49
  * @param {QuoteRequest} request - The configuration of the requested quote
50
50
  * @throws {LifiError} - Throws a LifiError if request fails
51
51
  */
52
- getQuote: (request: QuoteRequest, options?: RequestOptions) => Promise<Step>;
52
+ getQuote: (request: QuoteRequest, options?: RequestOptions) => Promise<LifiStep>;
53
53
  /**
54
54
  * Get a quote for a destination contract call
55
55
  * @param {ContractCallQuoteRequest} request - The configuration of the requested destination call
56
56
  * @throws {LifiError} - Throws a LifiError if request fails
57
57
  */
58
- getContractCallQuote: (request: ContractCallQuoteRequest, options?: RequestOptions) => Promise<Step>;
58
+ getContractCallQuote: (request: ContractCallQuoteRequest, options?: RequestOptions) => Promise<LifiStep>;
59
59
  /**
60
60
  * Check the status of a transfer. For cross chain transfers, the "bridge" parameter is required.
61
61
  * @param {GetStatusRequest} request - Configuration of the requested status
@@ -89,11 +89,11 @@ export declare class LiFi extends RouteExecutionManager {
89
89
  getRoutes: (request: RoutesRequest, options?: RequestOptions) => Promise<RoutesResponse>;
90
90
  /**
91
91
  * Get the transaction data for a single step of a route
92
- * @param {Step} step - The step object.
92
+ * @param {LifiStep} step - The step object.
93
93
  * @return {Promise<Step>} The step populated with the transaction data.
94
94
  * @throws {LifiError} Throws a LifiError if request fails.
95
95
  */
96
- getStepTransaction: (step: Step, options?: RequestOptions) => Promise<Step>;
96
+ getStepTransaction: (step: LifiStep, options?: RequestOptions) => Promise<LifiStep>;
97
97
  /**
98
98
  * Get gas recommendation for a certain chain
99
99
  * @param {GasRecommendationRequest} request - Configuration of the requested recommendation.
@@ -155,3 +155,9 @@ export declare class LiFi extends RouteExecutionManager {
155
155
  */
156
156
  revokeTokenApproval: (request: RevokeApprovalRequest) => Promise<void>;
157
157
  }
158
+ /**
159
+ * Get all the available connections for swap/bridging tokens
160
+ * @param connectionRequest ConnectionsRequest
161
+ * @returns ConnectionsResponse
162
+ */
163
+ export declare const getConnections: (connectionRequest: ConnectionsRequest) => Promise<ConnectionsResponse>;
package/dist/cjs/LiFi.js CHANGED
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.LiFi = void 0;
29
+ exports.getConnections = exports.LiFi = void 0;
30
30
  const allowance_1 = require("./allowance");
31
31
  const balance = __importStar(require("./balance"));
32
32
  const connectors_1 = require("./connectors");
@@ -148,7 +148,7 @@ class LiFi extends RouteExecutionManager_1.RouteExecutionManager {
148
148
  };
149
149
  /**
150
150
  * Get the transaction data for a single step of a route
151
- * @param {Step} step - The step object.
151
+ * @param {LifiStep} step - The step object.
152
152
  * @return {Promise<Step>} The step populated with the transaction data.
153
153
  * @throws {LifiError} Throws a LifiError if request fails.
154
154
  */
@@ -253,3 +253,13 @@ class LiFi extends RouteExecutionManager_1.RouteExecutionManager {
253
253
  }
254
254
  }
255
255
  exports.LiFi = LiFi;
256
+ /**
257
+ * Get all the available connections for swap/bridging tokens
258
+ * @param connectionRequest ConnectionsRequest
259
+ * @returns ConnectionsResponse
260
+ */
261
+ const getConnections = async (connectionRequest) => {
262
+ const connections = await ApiService_1.default.getAvailableConnections(connectionRequest);
263
+ return connections;
264
+ };
265
+ exports.getConnections = getConnections;
@@ -1,4 +1,4 @@
1
1
  import { Signer } from 'ethers';
2
2
  import { StatusManager } from '../execution/StatusManager';
3
- import { Chain, InternalExecutionSettings, Step } from '../types';
4
- export declare const checkAllowance: (signer: Signer, step: Step, statusManager: StatusManager, settings: InternalExecutionSettings, chain: Chain, allowUserInteraction?: boolean) => Promise<void>;
3
+ import { Chain, InternalExecutionSettings, LifiStep } from '../types';
4
+ export declare const checkAllowance: (signer: Signer, step: LifiStep, statusManager: StatusManager, settings: InternalExecutionSettings, chain: Chain, allowUserInteraction?: boolean) => Promise<void>;
@@ -1,3 +1,3 @@
1
1
  import { ethers } from 'ethers';
2
- import { Step } from '..';
3
- export declare const checkBalance: (signer: ethers.Signer, step: Step, depth?: number) => Promise<void>;
2
+ import { LifiStep } from '..';
3
+ export declare const checkBalance: (signer: ethers.Signer, step: LifiStep, depth?: number) => Promise<void>;
@@ -1,7 +1,7 @@
1
1
  export * from './checkBalance';
2
2
  export * from './getTokenBalance';
3
3
  declare const _default: {
4
- checkBalance: (signer: import("ethers").Signer, step: import("@lifi/types").Step, depth?: number) => Promise<void>;
4
+ checkBalance: (signer: import("ethers").Signer, step: import("@lifi/types").LifiStep, depth?: number) => Promise<void>;
5
5
  getTokenBalance: (walletAddress: string, token: import("@lifi/types").Token) => Promise<import("@lifi/types").TokenAmount | null>;
6
6
  getTokenBalances: (walletAddress: string, tokens: import("@lifi/types").Token[]) => Promise<import("@lifi/types").TokenAmount[]>;
7
7
  getTokenBalancesForChains: (walletAddress: string, tokensByChain: {
@@ -1,4 +1,4 @@
1
- import { Execution, InternalExecutionSettings, Process, ProcessType, Route, Status, Step, Token } from '../types';
1
+ import { Execution, InternalExecutionSettings, LifiStep, Process, ProcessType, Route, Status, Token } from '../types';
2
2
  interface Receipt {
3
3
  fromAmount?: string;
4
4
  toAmount?: string;
@@ -26,43 +26,43 @@ export declare class StatusManager {
26
26
  constructor(route: Route, settings: InternalExecutionSettings, internalUpdateRouteCallback: InternalUpdateRouteCallback);
27
27
  /**
28
28
  * Initializes the execution object of a Step.
29
- * @param {Step} step The current step in execution
29
+ * @param {LifiStep} step The current step in execution
30
30
  * @return {Execution} The initialized execution object for this step and a function to update this step
31
31
  */
32
- initExecutionObject: (step: Step) => Execution;
32
+ initExecutionObject: (step: LifiStep) => Execution;
33
33
  /**
34
34
  * Updates the execution object of a Step.
35
- * @param {Step} step The current step in execution
35
+ * @param {LifiStep} step The current step in execution
36
36
  * @param {Status} status The status for the execution
37
37
  * @param {Receipt} receipt Optional. Information about received tokens
38
38
  * @return {Step} The step with the updated execution object
39
39
  */
40
- updateExecution(step: Step, status: Status, receipt?: Receipt): Step;
40
+ updateExecution(step: LifiStep, status: Status, receipt?: Receipt): LifiStep;
41
41
  /**
42
42
  * Create and push a new process into the execution.
43
43
  * @param {ProcessType} type Type of the process. Used to identify already existing processes.
44
- * @param {Step} step The step that should contain the new process.
44
+ * @param {LifiStep} step The step that should contain the new process.
45
45
  * @param {Status} status By default created procces is set to the STARTED status. We can override new process with the needed status.
46
46
  * @return {Process}
47
47
  */
48
- findOrCreateProcess: (step: Step, type: ProcessType, status?: Status) => Process;
48
+ findOrCreateProcess: (step: LifiStep, type: ProcessType, status?: Status) => Process;
49
49
  /**
50
50
  * Update a process object.
51
- * @param {Step} step The step where the process should be updated
51
+ * @param {LifiStep} step The step where the process should be updated
52
52
  * @param {ProcessType} type The process type to update
53
53
  * @param {Status} status The status the process gets.
54
54
  * @param {object} [params] Additional parameters to append to the process.
55
55
  * @return {Process} The update process
56
56
  */
57
- updateProcess: (step: Step, type: ProcessType, status: Status, params?: OptionalParameters) => Process;
57
+ updateProcess: (step: LifiStep, type: ProcessType, status: Status, params?: OptionalParameters) => Process;
58
58
  /**
59
59
  * Remove a process from the execution
60
- * @param {Step} step The step where the process should be removed from
60
+ * @param {LifiStep} step The step where the process should be removed from
61
61
  * @param {ProcessType} type The process type to remove
62
62
  * @return {void}
63
63
  */
64
- removeProcess: (step: Step, type: ProcessType) => void;
65
- updateStepInRoute: (step: Step) => Step;
64
+ removeProcess: (step: LifiStep, type: ProcessType) => void;
65
+ updateStepInRoute: (step: LifiStep) => LifiStep;
66
66
  allowUpdates(value: boolean): void;
67
67
  }
68
68
  export {};
@@ -15,7 +15,7 @@ class StatusManager {
15
15
  this.shouldUpdate = true;
16
16
  /**
17
17
  * Initializes the execution object of a Step.
18
- * @param {Step} step The current step in execution
18
+ * @param {LifiStep} step The current step in execution
19
19
  * @return {Execution} The initialized execution object for this step and a function to update this step
20
20
  */
21
21
  this.initExecutionObject = (step) => {
@@ -35,7 +35,7 @@ class StatusManager {
35
35
  /**
36
36
  * Create and push a new process into the execution.
37
37
  * @param {ProcessType} type Type of the process. Used to identify already existing processes.
38
- * @param {Step} step The step that should contain the new process.
38
+ * @param {LifiStep} step The step that should contain the new process.
39
39
  * @param {Status} status By default created procces is set to the STARTED status. We can override new process with the needed status.
40
40
  * @return {Process}
41
41
  */
@@ -63,7 +63,7 @@ class StatusManager {
63
63
  };
64
64
  /**
65
65
  * Update a process object.
66
- * @param {Step} step The step where the process should be updated
66
+ * @param {LifiStep} step The step where the process should be updated
67
67
  * @param {ProcessType} type The process type to update
68
68
  * @param {Status} status The status the process gets.
69
69
  * @param {object} [params] Additional parameters to append to the process.
@@ -115,7 +115,7 @@ class StatusManager {
115
115
  };
116
116
  /**
117
117
  * Remove a process from the execution
118
- * @param {Step} step The step where the process should be removed from
118
+ * @param {LifiStep} step The step where the process should be removed from
119
119
  * @param {ProcessType} type The process type to remove
120
120
  * @return {void}
121
121
  */
@@ -146,7 +146,7 @@ class StatusManager {
146
146
  }
147
147
  /**
148
148
  * Updates the execution object of a Step.
149
- * @param {Step} step The current step in execution
149
+ * @param {LifiStep} step The current step in execution
150
150
  * @param {Status} status The status for the execution
151
151
  * @param {Receipt} receipt Optional. Information about received tokens
152
152
  * @return {Step} The step with the updated execution object
@@ -1,5 +1,5 @@
1
1
  import { Signer } from 'ethers';
2
- import { InteractionSettings, InternalExecutionSettings, Step } from '../types';
2
+ import { InteractionSettings, InternalExecutionSettings, LifiStep } from '../types';
3
3
  import { StatusManager } from './StatusManager';
4
4
  import { StepExecutionManager } from './StepExecutionManager';
5
5
  export declare class StepExecutor {
@@ -11,5 +11,5 @@ export declare class StepExecutor {
11
11
  constructor(statusManager: StatusManager, settings: InternalExecutionSettings);
12
12
  setInteraction: (settings?: InteractionSettings) => void;
13
13
  checkChain: () => never;
14
- executeStep: (signer: Signer, step: Step) => Promise<Step>;
14
+ executeStep: (signer: Signer, step: LifiStep) => Promise<LifiStep>;
15
15
  }
@@ -1,5 +1,5 @@
1
1
  import { StatusManager } from '.';
2
- import { InternalExecutionSettings, Step } from '../types';
2
+ import { InternalExecutionSettings, LifiStep } from '../types';
3
3
  /**
4
4
  * This method checks whether the new and updated Step meets the required exchange rate conditions.
5
5
  * If yes it returns the updated Step.
@@ -11,4 +11,4 @@ import { InternalExecutionSettings, Step } from '../types';
11
11
  * @param acceptSlippageUpdateHook
12
12
  * @param allowUserInteraction
13
13
  */
14
- export declare const stepComparison: (statusManager: StatusManager, oldStep: Step, newStep: Step, settings: InternalExecutionSettings, allowUserInteraction: boolean) => Promise<Step>;
14
+ export declare const stepComparison: (statusManager: StatusManager, oldStep: LifiStep, newStep: LifiStep, settings: InternalExecutionSettings, allowUserInteraction: boolean) => Promise<LifiStep>;
@@ -1,4 +1,4 @@
1
- import { Step } from '@lifi/types';
1
+ import { LifiStep } from '@lifi/types';
2
2
  import { Signer } from 'ethers';
3
3
  import { SwitchChainHook } from '../types';
4
4
  import { StatusManager } from './StatusManager';
@@ -13,4 +13,4 @@ import { StatusManager } from './StatusManager';
13
13
  * @param switchChainHook
14
14
  * @param allowUserInteraction
15
15
  */
16
- export declare const switchChain: (signer: Signer, statusManager: StatusManager, step: Step, switchChainHook: SwitchChainHook, allowUserInteraction: boolean) => Promise<Signer | undefined>;
16
+ export declare const switchChain: (signer: Signer, statusManager: StatusManager, step: LifiStep, switchChainHook: SwitchChainHook, allowUserInteraction: boolean) => Promise<Signer | undefined>;
@@ -1,6 +1,6 @@
1
- import { ProcessType, Status, StatusMessage, StatusResponse, Step, Substatus } from '@lifi/types';
1
+ import { LifiStep, ProcessType, Status, StatusMessage, StatusResponse, Substatus } from '@lifi/types';
2
2
  import { StatusManager } from '..';
3
- export declare function waitForReceivingTransaction(txHash: string, statusManager: StatusManager, processType: ProcessType, step: Step): Promise<StatusResponse>;
3
+ export declare function waitForReceivingTransaction(txHash: string, statusManager: StatusManager, processType: ProcessType, step: LifiStep): Promise<StatusResponse>;
4
4
  export declare function getProcessMessage(type: ProcessType, status: Status): string | undefined;
5
5
  export declare function getSubstatusMessage(status: StatusMessage, substatus?: Substatus): string | undefined;
6
- export declare function checkStepSlippageThreshold(oldStep: Step, newStep: Step): boolean;
6
+ export declare function checkStepSlippageThreshold(oldStep: LifiStep, newStep: LifiStep): boolean;
@@ -1,4 +1,4 @@
1
- import { Route, Step, Token } from '@lifi/types';
1
+ import { LifiStep, Route, Token } from '@lifi/types';
2
2
  /**
3
3
  * Predefined hook that decrypts calldata using EIP-1193 compliant wallet functions.
4
4
  * @param {string} walletAddress - The wallet address of the user that should decrypt the calldata.
@@ -19,12 +19,8 @@ export declare const isSameToken: (tokenA: Token, tokenB: Token) => boolean;
19
19
  export declare const checkPackageUpdates: (packageName?: string, packageVersion?: string, disableCheck?: boolean) => Promise<void>;
20
20
  /**
21
21
  * Converts a quote to Route
22
- * @param {Step} step - Step returned from the quote endpoint.
22
+ * @param {LifiStep} step - Step returned from the quote endpoint.
23
23
  * @return {Route} - The route to be executed.
24
24
  * @throws {ValidationError} Throws a ValidationError if the step has missing values.
25
25
  */
26
- export declare const convertQuoteToRoute: (step: Step) => Route;
27
- export declare const requestSettings: {
28
- retries: number;
29
- };
30
- export declare const request: <T = Response>(url: RequestInfo | URL, options?: RequestInit, retries?: number) => Promise<T>;
26
+ export declare const convertQuoteToRoute: (step: LifiStep) => Route;
@@ -1,12 +1,8 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.request = exports.requestSettings = exports.convertQuoteToRoute = exports.checkPackageUpdates = exports.isSameToken = exports.getRandomNumber = exports.getEthereumPublicKeyHook = exports.getEthereumDecryptionHook = void 0;
7
- const ConfigService_1 = __importDefault(require("./services/ConfigService"));
3
+ exports.convertQuoteToRoute = exports.checkPackageUpdates = exports.isSameToken = exports.getRandomNumber = exports.getEthereumPublicKeyHook = exports.getEthereumDecryptionHook = void 0;
4
+ const request_1 = require("./request");
8
5
  const errors_1 = require("./utils/errors");
9
- const utils_1 = require("./utils/utils");
10
6
  const version_1 = require("./version");
11
7
  const ethereumRequest = async (method, params) => {
12
8
  // If ethereum.request() exists, the provider is probably EIP-1193 compliant.
@@ -69,7 +65,7 @@ const checkPackageUpdates = async (packageName, packageVersion, disableCheck) =>
69
65
  }
70
66
  try {
71
67
  const pkgName = packageName ?? version_1.name;
72
- const response = await (0, exports.request)(`https://registry.npmjs.org/${pkgName}/latest`);
68
+ const response = await (0, request_1.request)(`https://registry.npmjs.org/${pkgName}/latest`, { skipTrackingHeaders: true });
73
69
  const latestVersion = response.version;
74
70
  const currentVersion = packageVersion ?? version_1.version;
75
71
  if (semverCompare(latestVersion, currentVersion)) {
@@ -85,7 +81,7 @@ const checkPackageUpdates = async (packageName, packageVersion, disableCheck) =>
85
81
  exports.checkPackageUpdates = checkPackageUpdates;
86
82
  /**
87
83
  * Converts a quote to Route
88
- * @param {Step} step - Step returned from the quote endpoint.
84
+ * @param {LifiStep} step - Step returned from the quote endpoint.
89
85
  * @return {Route} - The route to be executed.
90
86
  * @throws {ValidationError} Throws a ValidationError if the step has missing values.
91
87
  */
@@ -96,11 +92,6 @@ const convertQuoteToRoute = (step) => {
96
92
  if (!step.estimate.toAmountUSD) {
97
93
  throw new errors_1.ValidationError("Missing 'toAmountUSD' in step estimate.");
98
94
  }
99
- const lifiStep = {
100
- ...step,
101
- type: 'lifi',
102
- includedSteps: [],
103
- };
104
95
  const route = {
105
96
  fromToken: step.action.fromToken,
106
97
  toToken: step.action.toToken,
@@ -111,58 +102,10 @@ const convertQuoteToRoute = (step) => {
111
102
  toChainId: step.action.toToken.chainId,
112
103
  fromAmountUSD: step.estimate.fromAmountUSD,
113
104
  toAmountUSD: step.estimate.toAmountUSD,
114
- steps: [lifiStep],
105
+ steps: [step],
115
106
  toAmountMin: step.estimate.toAmountMin,
116
107
  insurance: { state: 'NOT_INSURABLE', feeAmountUsd: '0' },
117
108
  };
118
109
  return route;
119
110
  };
120
111
  exports.convertQuoteToRoute = convertQuoteToRoute;
121
- exports.requestSettings = {
122
- retries: 1,
123
- };
124
- const request = async (url, options, retries = exports.requestSettings.retries) => {
125
- const { userId, integrator, widgetVersion } = ConfigService_1.default.getInstance().getConfig();
126
- try {
127
- const updatedOptions = {
128
- ...(options ?? {}),
129
- };
130
- if (userId) {
131
- updatedOptions.headers = {
132
- ...options?.headers,
133
- 'X-LIFI-UserId': userId,
134
- };
135
- }
136
- if (widgetVersion) {
137
- updatedOptions.headers = {
138
- ...options?.headers,
139
- 'X-LIFI-Widget': widgetVersion,
140
- };
141
- }
142
- if (version_1.version) {
143
- updatedOptions.headers = {
144
- ...options?.headers,
145
- 'X-LIFI-SDK': version_1.version,
146
- };
147
- }
148
- // integrator is mandatory during SDK initialization
149
- updatedOptions.headers = {
150
- ...options?.headers,
151
- 'X-LIFI-Integrator': integrator,
152
- };
153
- const response = await fetch(url, updatedOptions);
154
- if (!response.ok) {
155
- throw new errors_1.HTTPError(response);
156
- }
157
- const data = await response.json();
158
- return data;
159
- }
160
- catch (error) {
161
- if (retries > 0 && error?.status === 500) {
162
- await (0, utils_1.sleep)(500);
163
- return (0, exports.request)(url, options, retries - 1);
164
- }
165
- throw error;
166
- }
167
- };
168
- exports.request = request;
@@ -0,0 +1,9 @@
1
+ export declare const requestSettings: {
2
+ retries: number;
3
+ };
4
+ interface ExtendedRequestInit extends RequestInit {
5
+ retries?: number;
6
+ skipTrackingHeaders?: boolean;
7
+ }
8
+ export declare const request: <T = Response>(url: RequestInfo | URL, options?: ExtendedRequestInit) => Promise<T>;
9
+ export {};
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.request = exports.requestSettings = void 0;
7
+ const ConfigService_1 = __importDefault(require("./services/ConfigService"));
8
+ const errors_1 = require("./utils/errors");
9
+ const utils_1 = require("./utils/utils");
10
+ const version_1 = require("./version");
11
+ exports.requestSettings = {
12
+ retries: 1,
13
+ };
14
+ const request = async (url, options = {
15
+ retries: exports.requestSettings.retries,
16
+ }) => {
17
+ const { userId, integrator, widgetVersion } = ConfigService_1.default.getInstance().getConfig();
18
+ options.retries = options.retries ?? exports.requestSettings.retries;
19
+ try {
20
+ if (!options.skipTrackingHeaders) {
21
+ if (userId) {
22
+ options.headers = {
23
+ ...options?.headers,
24
+ 'X-LIFI-UserId': userId,
25
+ };
26
+ }
27
+ if (widgetVersion) {
28
+ options.headers = {
29
+ ...options?.headers,
30
+ 'X-LIFI-Widget': widgetVersion,
31
+ };
32
+ }
33
+ if (version_1.version) {
34
+ options.headers = {
35
+ ...options?.headers,
36
+ 'X-LIFI-SDK': version_1.version,
37
+ };
38
+ }
39
+ // integrator is mandatory during SDK initialization
40
+ options.headers = {
41
+ ...options?.headers,
42
+ 'X-LIFI-Integrator': integrator,
43
+ };
44
+ }
45
+ const response = await fetch(url, options);
46
+ if (!response.ok) {
47
+ throw new errors_1.HTTPError(response);
48
+ }
49
+ const data = await response.json();
50
+ return data;
51
+ }
52
+ catch (error) {
53
+ if (options.retries > 0 && error?.status === 500) {
54
+ await (0, utils_1.sleep)(500);
55
+ return (0, exports.request)(url, { ...options, retries: options.retries - 1 });
56
+ }
57
+ throw error;
58
+ }
59
+ };
60
+ exports.request = request;
@@ -1,16 +1,17 @@
1
- import { ContractCallQuoteRequest, GasRecommendationRequest, GasRecommendationResponse, GetStatusRequest, QuoteRequest, RequestOptions, TokensRequest, TokensResponse } from '@lifi/types';
2
- import { ChainId, ChainKey, ExtendedChain, PossibilitiesRequest, PossibilitiesResponse, RoutesRequest, RoutesResponse, StatusResponse, Step, Token, ToolsRequest, ToolsResponse } from '../types';
1
+ import { ConnectionsRequest, ConnectionsResponse, ContractCallQuoteRequest, GasRecommendationRequest, GasRecommendationResponse, GetStatusRequest, LifiStep, QuoteRequest, RequestOptions, TokensRequest, TokensResponse } from '@lifi/types';
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
- getContractCallQuote: (requestConfig: ContractCallQuoteRequest, options?: RequestOptions | undefined) => Promise<Step>;
5
+ getContractCallQuote: (requestConfig: ContractCallQuoteRequest, options?: RequestOptions | undefined) => Promise<LifiStep>;
6
6
  getGasRecommendation: ({ chainId, fromChain, fromToken }: GasRecommendationRequest, options?: RequestOptions | undefined) => Promise<GasRecommendationResponse>;
7
7
  getPossibilities: (requestConfig?: PossibilitiesRequest | undefined, options?: RequestOptions | undefined) => Promise<PossibilitiesResponse>;
8
- getQuote: (requestConfig: QuoteRequest, options?: RequestOptions | undefined) => Promise<Step>;
8
+ getQuote: (requestConfig: QuoteRequest, options?: RequestOptions | undefined) => Promise<LifiStep>;
9
9
  getRoutes: (requestConfig: RoutesRequest, options?: RequestOptions | undefined) => Promise<RoutesResponse>;
10
- getStatus: ({ bridge, fromChain, toChain, txHash }: GetStatusRequest, options?: RequestOptions | undefined) => Promise<StatusResponse>;
11
- getStepTransaction: (step: Step, options?: RequestOptions | undefined) => Promise<Step>;
10
+ getStatus: (requestConfig: GetStatusRequest, options?: RequestOptions | undefined) => Promise<StatusResponse>;
11
+ getStepTransaction: (step: LifiStep, options?: RequestOptions | undefined) => Promise<LifiStep>;
12
12
  getToken: (chain: ChainKey | ChainId, token: string, options?: RequestOptions | undefined) => Promise<Token>;
13
13
  getTokens: (requestConfig?: TokensRequest | undefined, options?: RequestOptions | undefined) => Promise<TokensResponse>;
14
14
  getTools: (requestConfig?: ToolsRequest | undefined, options?: RequestOptions | undefined) => Promise<ToolsResponse>;
15
+ getAvailableConnections: (connectionRequest: ConnectionsRequest) => Promise<ConnectionsResponse>;
15
16
  };
16
17
  export default _default;