@lifi/sdk 3.0.0-alpha.6 → 3.0.0-alpha.7

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 (111) hide show
  1. package/dist/LiFi.d.ts +21 -18
  2. package/dist/LiFi.js +15 -12
  3. package/dist/allowance/setAllowance.d.ts +1 -1
  4. package/dist/cjs/LiFi.d.ts +21 -18
  5. package/dist/cjs/LiFi.js +15 -12
  6. package/dist/cjs/allowance/setAllowance.d.ts +1 -1
  7. package/dist/cjs/connectors.d.ts +1 -1
  8. package/dist/cjs/execution/BaseStepExecutor.d.ts +12 -0
  9. package/dist/cjs/execution/BaseStepExecutor.js +27 -0
  10. package/dist/cjs/execution/EVMStepExecutor.d.ts +13 -0
  11. package/dist/cjs/execution/EVMStepExecutor.js +292 -0
  12. package/dist/cjs/execution/RouteExecutionManager.d.ts +6 -7
  13. package/dist/cjs/execution/RouteExecutionManager.js +19 -19
  14. package/dist/cjs/execution/StatusManager.d.ts +8 -7
  15. package/dist/cjs/execution/StatusManager.js +1 -1
  16. package/dist/cjs/execution/StepExecutionManager.d.ts +3 -3
  17. package/dist/cjs/execution/StepExecutionManager.js +4 -4
  18. package/dist/cjs/execution/checkAllowance.d.ts +3 -2
  19. package/dist/cjs/execution/checkBalance.d.ts +2 -2
  20. package/dist/cjs/execution/index.d.ts +1 -0
  21. package/dist/cjs/execution/index.js +1 -0
  22. package/dist/cjs/execution/multisig.d.ts +2 -2
  23. package/dist/cjs/execution/prepareRestart.d.ts +2 -3
  24. package/dist/cjs/execution/prepareRestart.js +2 -2
  25. package/dist/cjs/execution/stepComparison.d.ts +4 -3
  26. package/dist/cjs/execution/stepComparison.js +1 -1
  27. package/dist/cjs/execution/switchChain.d.ts +4 -3
  28. package/dist/cjs/execution/switchChain.js +1 -0
  29. package/dist/cjs/{types/internal.types.d.ts → execution/types.d.ts} +33 -96
  30. package/dist/cjs/execution/utils.d.ts +2 -2
  31. package/dist/cjs/execution/waitForReceivingTransaction.d.ts +3 -3
  32. package/dist/cjs/helpers.d.ts +2 -2
  33. package/dist/cjs/index.d.ts +3 -1
  34. package/dist/cjs/index.js +6 -3
  35. package/dist/cjs/providers/BaseProvider.d.ts +7 -0
  36. package/dist/cjs/providers/BaseProvider.js +6 -0
  37. package/dist/cjs/providers/EVMProvider.d.ts +16 -0
  38. package/dist/cjs/providers/EVMProvider.js +28 -0
  39. package/dist/cjs/providers/SolanaProvider.d.ts +15 -0
  40. package/dist/cjs/providers/SolanaProvider.js +32 -0
  41. package/dist/cjs/providers/types.d.ts +0 -0
  42. package/dist/cjs/providers/types.js +1 -0
  43. package/dist/cjs/request.js +11 -5
  44. package/dist/cjs/services/ApiService.d.ts +4 -5
  45. package/dist/cjs/services/ApiService.js +2 -2
  46. package/dist/cjs/services/ConfigService.d.ts +6 -5
  47. package/dist/cjs/services/ConfigService.js +3 -3
  48. package/dist/cjs/typeguards.d.ts +2 -2
  49. package/dist/cjs/types/index.d.ts +1 -3
  50. package/dist/cjs/types/index.js +1 -5
  51. package/dist/cjs/types/internal.d.ts +60 -0
  52. package/dist/cjs/types/internal.js +2 -0
  53. package/dist/cjs/utils/parseError.d.ts +4 -4
  54. package/dist/cjs/version.d.ts +1 -1
  55. package/dist/cjs/version.js +1 -1
  56. package/dist/connectors.d.ts +1 -1
  57. package/dist/execution/BaseStepExecutor.d.ts +12 -0
  58. package/dist/execution/BaseStepExecutor.js +23 -0
  59. package/dist/execution/EVMStepExecutor.d.ts +13 -0
  60. package/dist/execution/EVMStepExecutor.js +285 -0
  61. package/dist/execution/RouteExecutionManager.d.ts +6 -7
  62. package/dist/execution/RouteExecutionManager.js +19 -19
  63. package/dist/execution/StatusManager.d.ts +8 -7
  64. package/dist/execution/StatusManager.js +1 -1
  65. package/dist/execution/StepExecutionManager.d.ts +3 -3
  66. package/dist/execution/StepExecutionManager.js +4 -4
  67. package/dist/execution/checkAllowance.d.ts +3 -2
  68. package/dist/execution/checkBalance.d.ts +2 -2
  69. package/dist/execution/index.d.ts +1 -0
  70. package/dist/execution/index.js +1 -0
  71. package/dist/execution/multisig.d.ts +2 -2
  72. package/dist/execution/prepareRestart.d.ts +2 -3
  73. package/dist/execution/prepareRestart.js +2 -2
  74. package/dist/execution/stepComparison.d.ts +4 -3
  75. package/dist/execution/stepComparison.js +1 -1
  76. package/dist/execution/switchChain.d.ts +4 -3
  77. package/dist/execution/switchChain.js +1 -0
  78. package/dist/{types/internal.types.d.ts → execution/types.d.ts} +33 -96
  79. package/dist/execution/utils.d.ts +2 -2
  80. package/dist/execution/waitForReceivingTransaction.d.ts +3 -3
  81. package/dist/helpers.d.ts +2 -2
  82. package/dist/index.d.ts +3 -1
  83. package/dist/index.js +3 -1
  84. package/dist/providers/BaseProvider.d.ts +7 -0
  85. package/dist/providers/BaseProvider.js +2 -0
  86. package/dist/providers/EVMProvider.d.ts +16 -0
  87. package/dist/providers/EVMProvider.js +24 -0
  88. package/dist/providers/SolanaProvider.d.ts +15 -0
  89. package/dist/providers/SolanaProvider.js +28 -0
  90. package/dist/providers/types.d.ts +0 -0
  91. package/dist/providers/types.js +1 -0
  92. package/dist/request.js +11 -5
  93. package/dist/services/ApiService.d.ts +4 -5
  94. package/dist/services/ApiService.js +2 -2
  95. package/dist/services/ConfigService.d.ts +6 -5
  96. package/dist/services/ConfigService.js +3 -3
  97. package/dist/typeguards.d.ts +2 -2
  98. package/dist/types/index.d.ts +1 -3
  99. package/dist/types/index.js +1 -3
  100. package/dist/types/internal.d.ts +60 -0
  101. package/dist/types/internal.js +1 -0
  102. package/dist/utils/parseError.d.ts +4 -4
  103. package/dist/version.d.ts +1 -1
  104. package/dist/version.js +1 -1
  105. package/package.json +6 -5
  106. package/dist/cjs/execution/StepExecutor.d.ts +0 -15
  107. package/dist/cjs/execution/StepExecutor.js +0 -62
  108. package/dist/execution/StepExecutor.d.ts +0 -15
  109. package/dist/execution/StepExecutor.js +0 -58
  110. /package/dist/cjs/{types/internal.types.js → execution/types.js} +0 -0
  111. /package/dist/{types/internal.types.js → execution/types.js} +0 -0
package/dist/LiFi.d.ts CHANGED
@@ -1,21 +1,21 @@
1
- import type { 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';
1
+ import type { 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
2
  import type { Hash, PublicClient } from 'viem';
3
3
  import type { ApproveTokenRequest, RevokeApprovalRequest, TokenAllowance, TokenSpender } from './allowance';
4
4
  import { RouteExecutionManager } from './execution/RouteExecutionManager';
5
- import type { Config, ConfigUpdate } from './types';
5
+ import type { SDKConfig, SDKOptions } from './types';
6
6
  export declare class LiFi extends RouteExecutionManager {
7
7
  private chainsService;
8
- constructor(configUpdate: ConfigUpdate);
8
+ constructor(options: SDKOptions);
9
9
  /**
10
10
  * Get the current configuration of the SDK
11
11
  * @returns - The config object
12
12
  */
13
- getConfig: () => Config;
13
+ getConfig: () => SDKConfig;
14
14
  /**
15
15
  * Get the SDK configuration after all setup calls are finished
16
16
  * @returns - The config object
17
17
  */
18
- getConfigAsync: () => Promise<Config>;
18
+ getConfigAsync: () => Promise<SDKConfig>;
19
19
  /**
20
20
  * Get an instance of a provider for a specific chain
21
21
  * @param chainId - Id of the chain the provider is for
@@ -27,11 +27,11 @@ export declare class LiFi extends RouteExecutionManager {
27
27
  * @param configUpdate - An object containing the configuration fields that should be updated.
28
28
  * @returns The renewed config object
29
29
  */
30
- setConfig: (configUpdate: Partial<ConfigUpdate>) => Config;
30
+ setConfig: (configUpdate: Partial<SDKOptions>) => SDKConfig;
31
31
  /**
32
32
  * Get a set of current possibilities based on a request that specifies which chains, exchanges and bridges are preferred or unwanted.
33
33
  * @param request - Object defining preferences regarding chain, exchanges and bridges
34
- * @param options
34
+ * @param options - Request options
35
35
  * @returns Object listing current possibilities for any-to-any cross-chain-swaps based on the provided preferences.
36
36
  * @throws {LiFiError} Throws a LiFiError if request fails.
37
37
  * @deprecated We don't want to support this endpoint anymore in the future. /chains, /tools, /connections, and /tokens should be used instead
@@ -41,25 +41,27 @@ export declare class LiFi extends RouteExecutionManager {
41
41
  * Fetch information about a Token
42
42
  * @param chain - Id or key of the chain that contains the token
43
43
  * @param token - Address or symbol of the token on the requested chain
44
- * @param options
44
+ * @param options - Request options
45
45
  * @throws {LiFiError} - Throws a LiFiError if request fails
46
+ * @returns Token information
46
47
  */
47
48
  getToken: (chain: ChainKey | ChainId, token: string, options?: RequestOptions) => Promise<Token>;
48
49
  /**
49
50
  * Get a quote for a token transfer
50
51
  * @param request - The configuration of the requested quote
51
- * @param options
52
+ * @param options - Request options
52
53
  * @throws {LiFiError} - Throws a LiFiError if request fails
54
+ * @returns Quote for a token transfer
53
55
  */
54
- getQuote: (request: QuoteRequest, options?: RequestOptions) => Promise<LifiStep>;
56
+ getQuote: (request: QuoteRequest, options?: RequestOptions) => Promise<LiFiStep>;
55
57
  /**
56
58
  * Get a quote for a destination contract call
57
59
  * @param request - The configuration of the requested destination call
58
- * @param options
60
+ * @param options - Request options
59
61
  * @throws {LiFiError} - Throws a LiFiError if request fails
60
62
  * @returns - Returns step.
61
63
  */
62
- getContractCallQuote: (request: ContractCallQuoteRequest, options?: RequestOptions) => Promise<LifiStep>;
64
+ getContractCallQuote: (request: ContractCallQuoteRequest, options?: RequestOptions) => Promise<LiFiStep>;
63
65
  /**
64
66
  * Check the status of a transfer. For cross chain transfers, the "bridge" parameter is required.
65
67
  * @param request - Configuration of the requested status
@@ -71,14 +73,14 @@ export declare class LiFi extends RouteExecutionManager {
71
73
  /**
72
74
  * Get the available tools to bridge and swap tokens.
73
75
  * @param request - The configuration of the requested tools
74
- * @param options
76
+ * @param options - Request options
75
77
  * @returns The tools that are available on the requested chains
76
78
  */
77
79
  getTools: (request?: ToolsRequest, options?: RequestOptions) => Promise<ToolsResponse>;
78
80
  /**
79
81
  * Get all known tokens.
80
82
  * @param request - The configuration of the requested tokens
81
- * @param options
83
+ * @param options - Request options
82
84
  * @returns The tokens that are available on the requested chains
83
85
  */
84
86
  getTokens: (request?: TokensRequest, options?: RequestOptions) => Promise<TokensResponse>;
@@ -91,7 +93,7 @@ export declare class LiFi extends RouteExecutionManager {
91
93
  /**
92
94
  * Get a set of routes for a request that describes a transfer of tokens.
93
95
  * @param request - A description of the transfer.
94
- * @param options
96
+ * @param options - Request options
95
97
  * @returns The resulting routes that can be used to realize the described transfer of tokens.
96
98
  * @throws {LiFiError} Throws a LiFiError if request fails.
97
99
  */
@@ -99,16 +101,17 @@ export declare class LiFi extends RouteExecutionManager {
99
101
  /**
100
102
  * Get the transaction data for a single step of a route
101
103
  * @param step - The step object.
102
- * @param options
104
+ * @param options - Request options
103
105
  * @returns The step populated with the transaction data.
104
106
  * @throws {LiFiError} Throws a LiFiError if request fails.
105
107
  */
106
- getStepTransaction: (step: LifiStep, options?: RequestOptions) => Promise<LifiStep>;
108
+ getStepTransaction: (step: LiFiStep, options?: RequestOptions) => Promise<LiFiStep>;
107
109
  /**
108
110
  * Get gas recommendation for a certain chain
109
111
  * @param request - Configuration of the requested recommendation.
110
- * @param options
112
+ * @param options - Request options
111
113
  * @throws {LiFiError} Throws a LiFiError if request fails.
114
+ * @returns Gas recommendation response.
112
115
  */
113
116
  getGasRecommendation: (request: GasRecommendationRequest, options?: RequestOptions) => Promise<GasRecommendationResponse>;
114
117
  /**
package/dist/LiFi.js CHANGED
@@ -9,8 +9,8 @@ import { isToken } from './typeguards';
9
9
  import { ValidationError } from './utils/errors';
10
10
  import { name, version } from './version';
11
11
  export class LiFi extends RouteExecutionManager {
12
- constructor(configUpdate) {
13
- super(configUpdate);
12
+ constructor(options) {
13
+ super(options);
14
14
  /**
15
15
  * Get the current configuration of the SDK
16
16
  * @returns - The config object
@@ -44,7 +44,7 @@ export class LiFi extends RouteExecutionManager {
44
44
  /**
45
45
  * Get a set of current possibilities based on a request that specifies which chains, exchanges and bridges are preferred or unwanted.
46
46
  * @param request - Object defining preferences regarding chain, exchanges and bridges
47
- * @param options
47
+ * @param options - Request options
48
48
  * @returns Object listing current possibilities for any-to-any cross-chain-swaps based on the provided preferences.
49
49
  * @throws {LiFiError} Throws a LiFiError if request fails.
50
50
  * @deprecated We don't want to support this endpoint anymore in the future. /chains, /tools, /connections, and /tokens should be used instead
@@ -56,8 +56,9 @@ export class LiFi extends RouteExecutionManager {
56
56
  * Fetch information about a Token
57
57
  * @param chain - Id or key of the chain that contains the token
58
58
  * @param token - Address or symbol of the token on the requested chain
59
- * @param options
59
+ * @param options - Request options
60
60
  * @throws {LiFiError} - Throws a LiFiError if request fails
61
+ * @returns Token information
61
62
  */
62
63
  this.getToken = async (chain, token, options) => {
63
64
  return ApiService.getToken(chain, token, options);
@@ -65,8 +66,9 @@ export class LiFi extends RouteExecutionManager {
65
66
  /**
66
67
  * Get a quote for a token transfer
67
68
  * @param request - The configuration of the requested quote
68
- * @param options
69
+ * @param options - Request options
69
70
  * @throws {LiFiError} - Throws a LiFiError if request fails
71
+ * @returns Quote for a token transfer
70
72
  */
71
73
  this.getQuote = async (request, options) => {
72
74
  return ApiService.getQuote(request, options);
@@ -74,7 +76,7 @@ export class LiFi extends RouteExecutionManager {
74
76
  /**
75
77
  * Get a quote for a destination contract call
76
78
  * @param request - The configuration of the requested destination call
77
- * @param options
79
+ * @param options - Request options
78
80
  * @throws {LiFiError} - Throws a LiFiError if request fails
79
81
  * @returns - Returns step.
80
82
  */
@@ -94,7 +96,7 @@ export class LiFi extends RouteExecutionManager {
94
96
  /**
95
97
  * Get the available tools to bridge and swap tokens.
96
98
  * @param request - The configuration of the requested tools
97
- * @param options
99
+ * @param options - Request options
98
100
  * @returns The tools that are available on the requested chains
99
101
  */
100
102
  this.getTools = async (request, options) => {
@@ -103,7 +105,7 @@ export class LiFi extends RouteExecutionManager {
103
105
  /**
104
106
  * Get all known tokens.
105
107
  * @param request - The configuration of the requested tokens
106
- * @param options
108
+ * @param options - Request options
107
109
  * @returns The tokens that are available on the requested chains
108
110
  */
109
111
  this.getTokens = async (request, options) => {
@@ -120,7 +122,7 @@ export class LiFi extends RouteExecutionManager {
120
122
  /**
121
123
  * Get a set of routes for a request that describes a transfer of tokens.
122
124
  * @param request - A description of the transfer.
123
- * @param options
125
+ * @param options - Request options
124
126
  * @returns The resulting routes that can be used to realize the described transfer of tokens.
125
127
  * @throws {LiFiError} Throws a LiFiError if request fails.
126
128
  */
@@ -130,7 +132,7 @@ export class LiFi extends RouteExecutionManager {
130
132
  /**
131
133
  * Get the transaction data for a single step of a route
132
134
  * @param step - The step object.
133
- * @param options
135
+ * @param options - Request options
134
136
  * @returns The step populated with the transaction data.
135
137
  * @throws {LiFiError} Throws a LiFiError if request fails.
136
138
  */
@@ -140,8 +142,9 @@ export class LiFi extends RouteExecutionManager {
140
142
  /**
141
143
  * Get gas recommendation for a certain chain
142
144
  * @param request - Configuration of the requested recommendation.
143
- * @param options
145
+ * @param options - Request options
144
146
  * @throws {LiFiError} Throws a LiFiError if request fails.
147
+ * @returns Gas recommendation response.
145
148
  */
146
149
  this.getGasRecommendation = async (request, options) => {
147
150
  return ApiService.getGasRecommendation(request, options);
@@ -245,6 +248,6 @@ export class LiFi extends RouteExecutionManager {
245
248
  this.chainsService.getChains().then((chains) => {
246
249
  this.configService.updateChains(chains);
247
250
  });
248
- checkPackageUpdates(name, version, configUpdate.disableVersionCheck);
251
+ checkPackageUpdates(name, version, options.disableVersionCheck);
249
252
  }
250
253
  }
@@ -1,5 +1,5 @@
1
1
  import type { Hash, WalletClient } from 'viem';
2
- import type { InternalExecutionSettings } from '../types';
2
+ import type { InternalExecutionSettings } from '../execution/types';
3
3
  import type { ApproveTokenRequest, RevokeApprovalRequest } from './types';
4
4
  export declare const setAllowance: (walletClient: WalletClient, tokenAddress: string, contractAddress: string, amount: bigint, settings?: InternalExecutionSettings, returnPopulatedTransaction?: boolean) => Promise<Hash>;
5
5
  export declare const setTokenAllowance: ({ walletClient, token, spenderAddress, amount, infiniteApproval, }: ApproveTokenRequest) => Promise<Hash | undefined>;
@@ -1,21 +1,21 @@
1
- import type { 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';
1
+ import type { 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
2
  import type { Hash, PublicClient } from 'viem';
3
3
  import type { ApproveTokenRequest, RevokeApprovalRequest, TokenAllowance, TokenSpender } from './allowance';
4
4
  import { RouteExecutionManager } from './execution/RouteExecutionManager';
5
- import type { Config, ConfigUpdate } from './types';
5
+ import type { SDKConfig, SDKOptions } from './types';
6
6
  export declare class LiFi extends RouteExecutionManager {
7
7
  private chainsService;
8
- constructor(configUpdate: ConfigUpdate);
8
+ constructor(options: SDKOptions);
9
9
  /**
10
10
  * Get the current configuration of the SDK
11
11
  * @returns - The config object
12
12
  */
13
- getConfig: () => Config;
13
+ getConfig: () => SDKConfig;
14
14
  /**
15
15
  * Get the SDK configuration after all setup calls are finished
16
16
  * @returns - The config object
17
17
  */
18
- getConfigAsync: () => Promise<Config>;
18
+ getConfigAsync: () => Promise<SDKConfig>;
19
19
  /**
20
20
  * Get an instance of a provider for a specific chain
21
21
  * @param chainId - Id of the chain the provider is for
@@ -27,11 +27,11 @@ export declare class LiFi extends RouteExecutionManager {
27
27
  * @param configUpdate - An object containing the configuration fields that should be updated.
28
28
  * @returns The renewed config object
29
29
  */
30
- setConfig: (configUpdate: Partial<ConfigUpdate>) => Config;
30
+ setConfig: (configUpdate: Partial<SDKOptions>) => SDKConfig;
31
31
  /**
32
32
  * Get a set of current possibilities based on a request that specifies which chains, exchanges and bridges are preferred or unwanted.
33
33
  * @param request - Object defining preferences regarding chain, exchanges and bridges
34
- * @param options
34
+ * @param options - Request options
35
35
  * @returns Object listing current possibilities for any-to-any cross-chain-swaps based on the provided preferences.
36
36
  * @throws {LiFiError} Throws a LiFiError if request fails.
37
37
  * @deprecated We don't want to support this endpoint anymore in the future. /chains, /tools, /connections, and /tokens should be used instead
@@ -41,25 +41,27 @@ export declare class LiFi extends RouteExecutionManager {
41
41
  * Fetch information about a Token
42
42
  * @param chain - Id or key of the chain that contains the token
43
43
  * @param token - Address or symbol of the token on the requested chain
44
- * @param options
44
+ * @param options - Request options
45
45
  * @throws {LiFiError} - Throws a LiFiError if request fails
46
+ * @returns Token information
46
47
  */
47
48
  getToken: (chain: ChainKey | ChainId, token: string, options?: RequestOptions) => Promise<Token>;
48
49
  /**
49
50
  * Get a quote for a token transfer
50
51
  * @param request - The configuration of the requested quote
51
- * @param options
52
+ * @param options - Request options
52
53
  * @throws {LiFiError} - Throws a LiFiError if request fails
54
+ * @returns Quote for a token transfer
53
55
  */
54
- getQuote: (request: QuoteRequest, options?: RequestOptions) => Promise<LifiStep>;
56
+ getQuote: (request: QuoteRequest, options?: RequestOptions) => Promise<LiFiStep>;
55
57
  /**
56
58
  * Get a quote for a destination contract call
57
59
  * @param request - The configuration of the requested destination call
58
- * @param options
60
+ * @param options - Request options
59
61
  * @throws {LiFiError} - Throws a LiFiError if request fails
60
62
  * @returns - Returns step.
61
63
  */
62
- getContractCallQuote: (request: ContractCallQuoteRequest, options?: RequestOptions) => Promise<LifiStep>;
64
+ getContractCallQuote: (request: ContractCallQuoteRequest, options?: RequestOptions) => Promise<LiFiStep>;
63
65
  /**
64
66
  * Check the status of a transfer. For cross chain transfers, the "bridge" parameter is required.
65
67
  * @param request - Configuration of the requested status
@@ -71,14 +73,14 @@ export declare class LiFi extends RouteExecutionManager {
71
73
  /**
72
74
  * Get the available tools to bridge and swap tokens.
73
75
  * @param request - The configuration of the requested tools
74
- * @param options
76
+ * @param options - Request options
75
77
  * @returns The tools that are available on the requested chains
76
78
  */
77
79
  getTools: (request?: ToolsRequest, options?: RequestOptions) => Promise<ToolsResponse>;
78
80
  /**
79
81
  * Get all known tokens.
80
82
  * @param request - The configuration of the requested tokens
81
- * @param options
83
+ * @param options - Request options
82
84
  * @returns The tokens that are available on the requested chains
83
85
  */
84
86
  getTokens: (request?: TokensRequest, options?: RequestOptions) => Promise<TokensResponse>;
@@ -91,7 +93,7 @@ export declare class LiFi extends RouteExecutionManager {
91
93
  /**
92
94
  * Get a set of routes for a request that describes a transfer of tokens.
93
95
  * @param request - A description of the transfer.
94
- * @param options
96
+ * @param options - Request options
95
97
  * @returns The resulting routes that can be used to realize the described transfer of tokens.
96
98
  * @throws {LiFiError} Throws a LiFiError if request fails.
97
99
  */
@@ -99,16 +101,17 @@ export declare class LiFi extends RouteExecutionManager {
99
101
  /**
100
102
  * Get the transaction data for a single step of a route
101
103
  * @param step - The step object.
102
- * @param options
104
+ * @param options - Request options
103
105
  * @returns The step populated with the transaction data.
104
106
  * @throws {LiFiError} Throws a LiFiError if request fails.
105
107
  */
106
- getStepTransaction: (step: LifiStep, options?: RequestOptions) => Promise<LifiStep>;
108
+ getStepTransaction: (step: LiFiStep, options?: RequestOptions) => Promise<LiFiStep>;
107
109
  /**
108
110
  * Get gas recommendation for a certain chain
109
111
  * @param request - Configuration of the requested recommendation.
110
- * @param options
112
+ * @param options - Request options
111
113
  * @throws {LiFiError} Throws a LiFiError if request fails.
114
+ * @returns Gas recommendation response.
112
115
  */
113
116
  getGasRecommendation: (request: GasRecommendationRequest, options?: RequestOptions) => Promise<GasRecommendationResponse>;
114
117
  /**
package/dist/cjs/LiFi.js CHANGED
@@ -38,8 +38,8 @@ const typeguards_1 = require("./typeguards");
38
38
  const errors_1 = require("./utils/errors");
39
39
  const version_1 = require("./version");
40
40
  class LiFi extends RouteExecutionManager_1.RouteExecutionManager {
41
- constructor(configUpdate) {
42
- super(configUpdate);
41
+ constructor(options) {
42
+ super(options);
43
43
  /**
44
44
  * Get the current configuration of the SDK
45
45
  * @returns - The config object
@@ -73,7 +73,7 @@ class LiFi extends RouteExecutionManager_1.RouteExecutionManager {
73
73
  /**
74
74
  * Get a set of current possibilities based on a request that specifies which chains, exchanges and bridges are preferred or unwanted.
75
75
  * @param request - Object defining preferences regarding chain, exchanges and bridges
76
- * @param options
76
+ * @param options - Request options
77
77
  * @returns Object listing current possibilities for any-to-any cross-chain-swaps based on the provided preferences.
78
78
  * @throws {LiFiError} Throws a LiFiError if request fails.
79
79
  * @deprecated We don't want to support this endpoint anymore in the future. /chains, /tools, /connections, and /tokens should be used instead
@@ -85,8 +85,9 @@ class LiFi extends RouteExecutionManager_1.RouteExecutionManager {
85
85
  * Fetch information about a Token
86
86
  * @param chain - Id or key of the chain that contains the token
87
87
  * @param token - Address or symbol of the token on the requested chain
88
- * @param options
88
+ * @param options - Request options
89
89
  * @throws {LiFiError} - Throws a LiFiError if request fails
90
+ * @returns Token information
90
91
  */
91
92
  this.getToken = async (chain, token, options) => {
92
93
  return ApiService_1.default.getToken(chain, token, options);
@@ -94,8 +95,9 @@ class LiFi extends RouteExecutionManager_1.RouteExecutionManager {
94
95
  /**
95
96
  * Get a quote for a token transfer
96
97
  * @param request - The configuration of the requested quote
97
- * @param options
98
+ * @param options - Request options
98
99
  * @throws {LiFiError} - Throws a LiFiError if request fails
100
+ * @returns Quote for a token transfer
99
101
  */
100
102
  this.getQuote = async (request, options) => {
101
103
  return ApiService_1.default.getQuote(request, options);
@@ -103,7 +105,7 @@ class LiFi extends RouteExecutionManager_1.RouteExecutionManager {
103
105
  /**
104
106
  * Get a quote for a destination contract call
105
107
  * @param request - The configuration of the requested destination call
106
- * @param options
108
+ * @param options - Request options
107
109
  * @throws {LiFiError} - Throws a LiFiError if request fails
108
110
  * @returns - Returns step.
109
111
  */
@@ -123,7 +125,7 @@ class LiFi extends RouteExecutionManager_1.RouteExecutionManager {
123
125
  /**
124
126
  * Get the available tools to bridge and swap tokens.
125
127
  * @param request - The configuration of the requested tools
126
- * @param options
128
+ * @param options - Request options
127
129
  * @returns The tools that are available on the requested chains
128
130
  */
129
131
  this.getTools = async (request, options) => {
@@ -132,7 +134,7 @@ class LiFi extends RouteExecutionManager_1.RouteExecutionManager {
132
134
  /**
133
135
  * Get all known tokens.
134
136
  * @param request - The configuration of the requested tokens
135
- * @param options
137
+ * @param options - Request options
136
138
  * @returns The tokens that are available on the requested chains
137
139
  */
138
140
  this.getTokens = async (request, options) => {
@@ -149,7 +151,7 @@ class LiFi extends RouteExecutionManager_1.RouteExecutionManager {
149
151
  /**
150
152
  * Get a set of routes for a request that describes a transfer of tokens.
151
153
  * @param request - A description of the transfer.
152
- * @param options
154
+ * @param options - Request options
153
155
  * @returns The resulting routes that can be used to realize the described transfer of tokens.
154
156
  * @throws {LiFiError} Throws a LiFiError if request fails.
155
157
  */
@@ -159,7 +161,7 @@ class LiFi extends RouteExecutionManager_1.RouteExecutionManager {
159
161
  /**
160
162
  * Get the transaction data for a single step of a route
161
163
  * @param step - The step object.
162
- * @param options
164
+ * @param options - Request options
163
165
  * @returns The step populated with the transaction data.
164
166
  * @throws {LiFiError} Throws a LiFiError if request fails.
165
167
  */
@@ -169,8 +171,9 @@ class LiFi extends RouteExecutionManager_1.RouteExecutionManager {
169
171
  /**
170
172
  * Get gas recommendation for a certain chain
171
173
  * @param request - Configuration of the requested recommendation.
172
- * @param options
174
+ * @param options - Request options
173
175
  * @throws {LiFiError} Throws a LiFiError if request fails.
176
+ * @returns Gas recommendation response.
174
177
  */
175
178
  this.getGasRecommendation = async (request, options) => {
176
179
  return ApiService_1.default.getGasRecommendation(request, options);
@@ -274,7 +277,7 @@ class LiFi extends RouteExecutionManager_1.RouteExecutionManager {
274
277
  this.chainsService.getChains().then((chains) => {
275
278
  this.configService.updateChains(chains);
276
279
  });
277
- (0, helpers_1.checkPackageUpdates)(version_1.name, version_1.version, configUpdate.disableVersionCheck);
280
+ (0, helpers_1.checkPackageUpdates)(version_1.name, version_1.version, options.disableVersionCheck);
278
281
  }
279
282
  }
280
283
  exports.LiFi = LiFi;
@@ -1,5 +1,5 @@
1
1
  import type { Hash, WalletClient } from 'viem';
2
- import type { InternalExecutionSettings } from '../types';
2
+ import type { InternalExecutionSettings } from '../execution/types';
3
3
  import type { ApproveTokenRequest, RevokeApprovalRequest } from './types';
4
4
  export declare const setAllowance: (walletClient: WalletClient, tokenAddress: string, contractAddress: string, amount: bigint, settings?: InternalExecutionSettings, returnPopulatedTransaction?: boolean) => Promise<Hash>;
5
5
  export declare const setTokenAllowance: ({ walletClient, token, spenderAddress, amount, infiniteApproval, }: ApproveTokenRequest) => Promise<Hash | undefined>;
@@ -1,6 +1,6 @@
1
+ import type { ChainId } from '@lifi/types';
1
2
  import type { PublicClient } from 'viem';
2
3
  import type { Chain } from 'viem/chains';
3
- import type { ChainId } from './types';
4
4
  export declare const getChainById: (chainId: ChainId) => Chain | undefined;
5
5
  export declare const getRpcUrl: (chainId: ChainId) => Promise<string>;
6
6
  export declare const getRpcUrls: (chainId: ChainId) => Promise<string[]>;
@@ -0,0 +1,12 @@
1
+ import type { LiFiStep } from '@lifi/types';
2
+ import type { StatusManager } from './StatusManager';
3
+ import type { InteractionSettings, InternalExecutionSettings, StepExecutorOptions } from './types';
4
+ export declare abstract class BaseStepExecutor {
5
+ settings: InternalExecutionSettings;
6
+ statusManager: StatusManager;
7
+ allowUserInteraction: boolean;
8
+ allowExecution: boolean;
9
+ constructor(options: StepExecutorOptions);
10
+ setInteraction: (settings?: InteractionSettings) => void;
11
+ abstract executeStep(step: LiFiStep): Promise<LiFiStep>;
12
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseStepExecutor = void 0;
4
+ // Please be careful when changing the defaults as it may break the behavior (e.g., background execution)
5
+ const defaultInteractionSettings = {
6
+ allowInteraction: true,
7
+ allowUpdates: true,
8
+ allowExecution: true,
9
+ };
10
+ class BaseStepExecutor {
11
+ constructor(options) {
12
+ this.allowUserInteraction = true;
13
+ this.allowExecution = true;
14
+ this.setInteraction = (settings) => {
15
+ const interactionSettings = {
16
+ ...defaultInteractionSettings,
17
+ ...settings,
18
+ };
19
+ this.allowUserInteraction = interactionSettings.allowInteraction;
20
+ this.statusManager.allowUpdates(interactionSettings.allowUpdates);
21
+ this.allowExecution = interactionSettings.allowExecution;
22
+ };
23
+ this.statusManager = options.statusManager;
24
+ this.settings = options.settings;
25
+ }
26
+ }
27
+ exports.BaseStepExecutor = BaseStepExecutor;
@@ -0,0 +1,13 @@
1
+ import type { LiFiStep } from '@lifi/types';
2
+ import type { WalletClient } from 'viem';
3
+ import { BaseStepExecutor } from './BaseStepExecutor';
4
+ import type { StepExecutorOptions } from './types';
5
+ export interface EVMStepExecutorOptions extends StepExecutorOptions {
6
+ walletClient: WalletClient;
7
+ }
8
+ export declare class EVMStepExecutor extends BaseStepExecutor {
9
+ walletClient: WalletClient;
10
+ constructor(options: EVMStepExecutorOptions);
11
+ checkChain: () => never;
12
+ executeStep: (step: LiFiStep) => Promise<LiFiStep>;
13
+ }