@lifi/sdk 3.0.0-alpha.6 → 3.0.0-alpha.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.
- package/dist/LiFi.d.ts +21 -18
- package/dist/LiFi.js +16 -13
- package/dist/allowance/setAllowance.d.ts +1 -1
- package/dist/cjs/LiFi.d.ts +21 -18
- package/dist/cjs/LiFi.js +17 -14
- package/dist/cjs/allowance/setAllowance.d.ts +1 -1
- package/dist/cjs/connectors.d.ts +1 -1
- package/dist/cjs/connectors.js +3 -6
- package/dist/cjs/execution/BaseStepExecutor.d.ts +12 -0
- package/dist/cjs/execution/BaseStepExecutor.js +27 -0
- package/dist/cjs/execution/EVMStepExecutor.d.ts +13 -0
- package/dist/cjs/execution/EVMStepExecutor.js +292 -0
- package/dist/cjs/execution/RouteExecutionManager.d.ts +9 -8
- package/dist/cjs/execution/RouteExecutionManager.js +26 -24
- package/dist/cjs/execution/StatusManager.d.ts +8 -7
- package/dist/cjs/execution/StatusManager.js +1 -1
- package/dist/cjs/execution/StepExecutionManager.d.ts +3 -3
- package/dist/cjs/execution/StepExecutionManager.js +8 -8
- package/dist/cjs/execution/checkAllowance.d.ts +3 -2
- package/dist/cjs/execution/checkBalance.d.ts +2 -2
- package/dist/cjs/execution/index.d.ts +1 -0
- package/dist/cjs/execution/index.js +1 -0
- package/dist/cjs/execution/multisig.d.ts +2 -2
- package/dist/cjs/execution/multisig.js +2 -5
- package/dist/cjs/execution/prepareRestart.d.ts +2 -3
- package/dist/cjs/execution/prepareRestart.js +2 -2
- package/dist/cjs/execution/stepComparison.d.ts +4 -3
- package/dist/cjs/execution/stepComparison.js +1 -1
- package/dist/cjs/execution/switchChain.d.ts +4 -3
- package/dist/cjs/execution/switchChain.js +1 -0
- package/dist/cjs/{types/internal.types.d.ts → execution/types.d.ts} +33 -96
- package/dist/cjs/execution/utils.d.ts +2 -2
- package/dist/cjs/execution/waitForReceivingTransaction.d.ts +3 -3
- package/dist/cjs/helpers.d.ts +2 -2
- package/dist/cjs/index.d.ts +5 -1
- package/dist/cjs/index.js +10 -4
- package/dist/cjs/providers/EVM.d.ts +10 -0
- package/dist/cjs/providers/EVM.js +34 -0
- package/dist/cjs/providers/Solana.d.ts +9 -0
- package/dist/cjs/providers/Solana.js +38 -0
- package/dist/cjs/providers/index.d.ts +1 -0
- package/dist/cjs/providers/index.js +17 -0
- package/dist/cjs/providers/types.d.ts +12 -0
- package/dist/cjs/providers/types.js +8 -0
- package/dist/cjs/request.js +12 -9
- package/dist/cjs/services/ApiService.d.ts +4 -5
- package/dist/cjs/services/ApiService.js +15 -18
- package/dist/cjs/services/ChainsService.d.ts +1 -1
- package/dist/cjs/services/ChainsService.js +2 -1
- package/dist/cjs/services/ConfigService.d.ts +9 -6
- package/dist/cjs/services/ConfigService.js +7 -4
- package/dist/cjs/typeguards.d.ts +2 -2
- package/dist/cjs/types/index.d.ts +1 -3
- package/dist/cjs/types/index.js +1 -5
- package/dist/cjs/types/internal.d.ts +60 -0
- package/dist/cjs/types/internal.js +2 -0
- package/dist/cjs/utils/parseError.d.ts +4 -4
- package/dist/cjs/utils/parseError.js +3 -6
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/connectors.d.ts +1 -1
- package/dist/connectors.js +1 -1
- package/dist/execution/BaseStepExecutor.d.ts +12 -0
- package/dist/execution/BaseStepExecutor.js +23 -0
- package/dist/execution/EVMStepExecutor.d.ts +13 -0
- package/dist/execution/EVMStepExecutor.js +285 -0
- package/dist/execution/RouteExecutionManager.d.ts +9 -8
- package/dist/execution/RouteExecutionManager.js +25 -20
- package/dist/execution/StatusManager.d.ts +8 -7
- package/dist/execution/StatusManager.js +1 -1
- package/dist/execution/StepExecutionManager.d.ts +3 -3
- package/dist/execution/StepExecutionManager.js +6 -6
- package/dist/execution/checkAllowance.d.ts +3 -2
- package/dist/execution/checkBalance.d.ts +2 -2
- package/dist/execution/index.d.ts +1 -0
- package/dist/execution/index.js +1 -0
- package/dist/execution/multisig.d.ts +2 -2
- package/dist/execution/multisig.js +1 -1
- package/dist/execution/prepareRestart.d.ts +2 -3
- package/dist/execution/prepareRestart.js +2 -2
- package/dist/execution/stepComparison.d.ts +4 -3
- package/dist/execution/stepComparison.js +1 -1
- package/dist/execution/switchChain.d.ts +4 -3
- package/dist/execution/switchChain.js +1 -0
- package/dist/{types/internal.types.d.ts → execution/types.d.ts} +33 -96
- package/dist/execution/utils.d.ts +2 -2
- package/dist/execution/waitForReceivingTransaction.d.ts +3 -3
- package/dist/helpers.d.ts +2 -2
- package/dist/index.d.ts +5 -1
- package/dist/index.js +5 -2
- package/dist/providers/EVM.d.ts +10 -0
- package/dist/providers/EVM.js +29 -0
- package/dist/providers/Solana.d.ts +9 -0
- package/dist/providers/Solana.js +33 -0
- package/dist/providers/index.d.ts +1 -0
- package/dist/providers/index.js +1 -0
- package/dist/providers/types.d.ts +12 -0
- package/dist/providers/types.js +5 -0
- package/dist/request.js +12 -6
- package/dist/services/ApiService.d.ts +4 -5
- package/dist/services/ApiService.js +3 -3
- package/dist/services/ChainsService.d.ts +1 -1
- package/dist/services/ChainsService.js +1 -1
- package/dist/services/ConfigService.d.ts +9 -6
- package/dist/services/ConfigService.js +6 -5
- package/dist/typeguards.d.ts +2 -2
- package/dist/types/index.d.ts +1 -3
- package/dist/types/index.js +1 -3
- package/dist/types/internal.d.ts +60 -0
- package/dist/types/internal.js +1 -0
- package/dist/utils/parseError.d.ts +4 -4
- package/dist/utils/parseError.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -5
- package/dist/cjs/execution/StepExecutor.d.ts +0 -15
- package/dist/cjs/execution/StepExecutor.js +0 -62
- package/dist/execution/StepExecutor.d.ts +0 -15
- package/dist/execution/StepExecutor.js +0 -58
- /package/dist/cjs/{types/internal.types.js → execution/types.js} +0 -0
- /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,
|
|
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 {
|
|
5
|
+
import type { SDKConfig, SDKOptions } from './types';
|
|
6
6
|
export declare class LiFi extends RouteExecutionManager {
|
|
7
7
|
private chainsService;
|
|
8
|
-
constructor(
|
|
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: () =>
|
|
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<
|
|
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<
|
|
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<
|
|
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<
|
|
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:
|
|
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
|
@@ -4,13 +4,13 @@ import { getPublicClient } from './connectors';
|
|
|
4
4
|
import { RouteExecutionManager } from './execution/RouteExecutionManager';
|
|
5
5
|
import { checkPackageUpdates } from './helpers';
|
|
6
6
|
import ApiService from './services/ApiService';
|
|
7
|
-
import ChainsService from './services/ChainsService';
|
|
7
|
+
import { ChainsService } from './services/ChainsService';
|
|
8
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(
|
|
13
|
-
super(
|
|
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,
|
|
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>;
|
package/dist/cjs/LiFi.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import type { ChainId, ChainKey, ConnectionsRequest, ConnectionsResponse, ContractCallQuoteRequest, ExtendedChain, GasRecommendationRequest, GasRecommendationResponse, GetStatusRequest,
|
|
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 {
|
|
5
|
+
import type { SDKConfig, SDKOptions } from './types';
|
|
6
6
|
export declare class LiFi extends RouteExecutionManager {
|
|
7
7
|
private chainsService;
|
|
8
|
-
constructor(
|
|
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: () =>
|
|
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<
|
|
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<
|
|
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<
|
|
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<
|
|
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:
|
|
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
|
@@ -33,13 +33,13 @@ const connectors_1 = require("./connectors");
|
|
|
33
33
|
const RouteExecutionManager_1 = require("./execution/RouteExecutionManager");
|
|
34
34
|
const helpers_1 = require("./helpers");
|
|
35
35
|
const ApiService_1 = __importDefault(require("./services/ApiService"));
|
|
36
|
-
const ChainsService_1 =
|
|
36
|
+
const ChainsService_1 = require("./services/ChainsService");
|
|
37
37
|
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(
|
|
42
|
-
super(
|
|
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);
|
|
@@ -270,11 +273,11 @@ class LiFi extends RouteExecutionManager_1.RouteExecutionManager {
|
|
|
270
273
|
const connections = await ApiService_1.default.getAvailableConnections(connectionRequest);
|
|
271
274
|
return connections;
|
|
272
275
|
};
|
|
273
|
-
this.chainsService = ChainsService_1.
|
|
276
|
+
this.chainsService = ChainsService_1.ChainsService.getInstance();
|
|
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,
|
|
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>;
|
package/dist/cjs/connectors.d.ts
CHANGED
|
@@ -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[]>;
|
package/dist/cjs/connectors.js
CHANGED
|
@@ -22,14 +22,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
26
|
exports.getMulticallAddress = exports.getPublicClient = exports.getRpcUrls = exports.getRpcUrl = exports.getChainById = void 0;
|
|
30
27
|
const viem_1 = require("viem");
|
|
31
28
|
const chains = __importStar(require("viem/chains")); // TODO: optimize using BE chains
|
|
32
|
-
const ConfigService_1 =
|
|
29
|
+
const ConfigService_1 = require("./services/ConfigService");
|
|
33
30
|
const errors_1 = require("./utils/errors");
|
|
34
31
|
// cached providers
|
|
35
32
|
const publicClients = {};
|
|
@@ -44,7 +41,7 @@ const getRpcUrl = async (chainId) => {
|
|
|
44
41
|
};
|
|
45
42
|
exports.getRpcUrl = getRpcUrl;
|
|
46
43
|
const getRpcUrls = async (chainId) => {
|
|
47
|
-
const configService = ConfigService_1.
|
|
44
|
+
const configService = ConfigService_1.ConfigService.getInstance();
|
|
48
45
|
const config = await configService.getConfigAsync();
|
|
49
46
|
return config.rpcs[chainId];
|
|
50
47
|
};
|
|
@@ -68,7 +65,7 @@ const getPublicClient = async (chainId) => {
|
|
|
68
65
|
exports.getPublicClient = getPublicClient;
|
|
69
66
|
// Multicall
|
|
70
67
|
const getMulticallAddress = async (chainId) => {
|
|
71
|
-
const configService = ConfigService_1.
|
|
68
|
+
const configService = ConfigService_1.ConfigService.getInstance();
|
|
72
69
|
const config = await configService.getConfigAsync();
|
|
73
70
|
return config.multicallAddresses[chainId];
|
|
74
71
|
};
|
|
@@ -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
|
+
}
|