@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.
Files changed (121) hide show
  1. package/dist/LiFi.d.ts +21 -18
  2. package/dist/LiFi.js +16 -13
  3. package/dist/allowance/setAllowance.d.ts +1 -1
  4. package/dist/cjs/LiFi.d.ts +21 -18
  5. package/dist/cjs/LiFi.js +17 -14
  6. package/dist/cjs/allowance/setAllowance.d.ts +1 -1
  7. package/dist/cjs/connectors.d.ts +1 -1
  8. package/dist/cjs/connectors.js +3 -6
  9. package/dist/cjs/execution/BaseStepExecutor.d.ts +12 -0
  10. package/dist/cjs/execution/BaseStepExecutor.js +27 -0
  11. package/dist/cjs/execution/EVMStepExecutor.d.ts +13 -0
  12. package/dist/cjs/execution/EVMStepExecutor.js +292 -0
  13. package/dist/cjs/execution/RouteExecutionManager.d.ts +9 -8
  14. package/dist/cjs/execution/RouteExecutionManager.js +26 -24
  15. package/dist/cjs/execution/StatusManager.d.ts +8 -7
  16. package/dist/cjs/execution/StatusManager.js +1 -1
  17. package/dist/cjs/execution/StepExecutionManager.d.ts +3 -3
  18. package/dist/cjs/execution/StepExecutionManager.js +8 -8
  19. package/dist/cjs/execution/checkAllowance.d.ts +3 -2
  20. package/dist/cjs/execution/checkBalance.d.ts +2 -2
  21. package/dist/cjs/execution/index.d.ts +1 -0
  22. package/dist/cjs/execution/index.js +1 -0
  23. package/dist/cjs/execution/multisig.d.ts +2 -2
  24. package/dist/cjs/execution/multisig.js +2 -5
  25. package/dist/cjs/execution/prepareRestart.d.ts +2 -3
  26. package/dist/cjs/execution/prepareRestart.js +2 -2
  27. package/dist/cjs/execution/stepComparison.d.ts +4 -3
  28. package/dist/cjs/execution/stepComparison.js +1 -1
  29. package/dist/cjs/execution/switchChain.d.ts +4 -3
  30. package/dist/cjs/execution/switchChain.js +1 -0
  31. package/dist/cjs/{types/internal.types.d.ts → execution/types.d.ts} +33 -96
  32. package/dist/cjs/execution/utils.d.ts +2 -2
  33. package/dist/cjs/execution/waitForReceivingTransaction.d.ts +3 -3
  34. package/dist/cjs/helpers.d.ts +2 -2
  35. package/dist/cjs/index.d.ts +5 -1
  36. package/dist/cjs/index.js +10 -4
  37. package/dist/cjs/providers/EVM.d.ts +10 -0
  38. package/dist/cjs/providers/EVM.js +34 -0
  39. package/dist/cjs/providers/Solana.d.ts +9 -0
  40. package/dist/cjs/providers/Solana.js +38 -0
  41. package/dist/cjs/providers/index.d.ts +1 -0
  42. package/dist/cjs/providers/index.js +17 -0
  43. package/dist/cjs/providers/types.d.ts +12 -0
  44. package/dist/cjs/providers/types.js +8 -0
  45. package/dist/cjs/request.js +12 -9
  46. package/dist/cjs/services/ApiService.d.ts +4 -5
  47. package/dist/cjs/services/ApiService.js +15 -18
  48. package/dist/cjs/services/ChainsService.d.ts +1 -1
  49. package/dist/cjs/services/ChainsService.js +2 -1
  50. package/dist/cjs/services/ConfigService.d.ts +9 -6
  51. package/dist/cjs/services/ConfigService.js +7 -4
  52. package/dist/cjs/typeguards.d.ts +2 -2
  53. package/dist/cjs/types/index.d.ts +1 -3
  54. package/dist/cjs/types/index.js +1 -5
  55. package/dist/cjs/types/internal.d.ts +60 -0
  56. package/dist/cjs/types/internal.js +2 -0
  57. package/dist/cjs/utils/parseError.d.ts +4 -4
  58. package/dist/cjs/utils/parseError.js +3 -6
  59. package/dist/cjs/version.d.ts +1 -1
  60. package/dist/cjs/version.js +1 -1
  61. package/dist/connectors.d.ts +1 -1
  62. package/dist/connectors.js +1 -1
  63. package/dist/execution/BaseStepExecutor.d.ts +12 -0
  64. package/dist/execution/BaseStepExecutor.js +23 -0
  65. package/dist/execution/EVMStepExecutor.d.ts +13 -0
  66. package/dist/execution/EVMStepExecutor.js +285 -0
  67. package/dist/execution/RouteExecutionManager.d.ts +9 -8
  68. package/dist/execution/RouteExecutionManager.js +25 -20
  69. package/dist/execution/StatusManager.d.ts +8 -7
  70. package/dist/execution/StatusManager.js +1 -1
  71. package/dist/execution/StepExecutionManager.d.ts +3 -3
  72. package/dist/execution/StepExecutionManager.js +6 -6
  73. package/dist/execution/checkAllowance.d.ts +3 -2
  74. package/dist/execution/checkBalance.d.ts +2 -2
  75. package/dist/execution/index.d.ts +1 -0
  76. package/dist/execution/index.js +1 -0
  77. package/dist/execution/multisig.d.ts +2 -2
  78. package/dist/execution/multisig.js +1 -1
  79. package/dist/execution/prepareRestart.d.ts +2 -3
  80. package/dist/execution/prepareRestart.js +2 -2
  81. package/dist/execution/stepComparison.d.ts +4 -3
  82. package/dist/execution/stepComparison.js +1 -1
  83. package/dist/execution/switchChain.d.ts +4 -3
  84. package/dist/execution/switchChain.js +1 -0
  85. package/dist/{types/internal.types.d.ts → execution/types.d.ts} +33 -96
  86. package/dist/execution/utils.d.ts +2 -2
  87. package/dist/execution/waitForReceivingTransaction.d.ts +3 -3
  88. package/dist/helpers.d.ts +2 -2
  89. package/dist/index.d.ts +5 -1
  90. package/dist/index.js +5 -2
  91. package/dist/providers/EVM.d.ts +10 -0
  92. package/dist/providers/EVM.js +29 -0
  93. package/dist/providers/Solana.d.ts +9 -0
  94. package/dist/providers/Solana.js +33 -0
  95. package/dist/providers/index.d.ts +1 -0
  96. package/dist/providers/index.js +1 -0
  97. package/dist/providers/types.d.ts +12 -0
  98. package/dist/providers/types.js +5 -0
  99. package/dist/request.js +12 -6
  100. package/dist/services/ApiService.d.ts +4 -5
  101. package/dist/services/ApiService.js +3 -3
  102. package/dist/services/ChainsService.d.ts +1 -1
  103. package/dist/services/ChainsService.js +1 -1
  104. package/dist/services/ConfigService.d.ts +9 -6
  105. package/dist/services/ConfigService.js +6 -5
  106. package/dist/typeguards.d.ts +2 -2
  107. package/dist/types/index.d.ts +1 -3
  108. package/dist/types/index.js +1 -3
  109. package/dist/types/internal.d.ts +60 -0
  110. package/dist/types/internal.js +1 -0
  111. package/dist/utils/parseError.d.ts +4 -4
  112. package/dist/utils/parseError.js +1 -1
  113. package/dist/version.d.ts +1 -1
  114. package/dist/version.js +1 -1
  115. package/package.json +6 -5
  116. package/dist/cjs/execution/StepExecutor.d.ts +0 -15
  117. package/dist/cjs/execution/StepExecutor.js +0 -62
  118. package/dist/execution/StepExecutor.d.ts +0 -15
  119. package/dist/execution/StepExecutor.js +0 -58
  120. /package/dist/cjs/{types/internal.types.js → execution/types.js} +0 -0
  121. /package/dist/{types/internal.types.js → execution/types.js} +0 -0
@@ -1,13 +1,10 @@
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
3
  const request_1 = require("../request");
7
4
  const typeguards_1 = require("../typeguards");
8
5
  const errors_1 = require("../utils/errors");
9
6
  const parseError_1 = require("../utils/parseError");
10
- const ConfigService_1 = __importDefault(require("./ConfigService"));
7
+ const ConfigService_1 = require("./ConfigService");
11
8
  /**
12
9
  * @param requestConfig
13
10
  * @param options
@@ -17,7 +14,7 @@ const getPossibilities = async (requestConfig, options) => {
17
14
  if (!requestConfig) {
18
15
  requestConfig = {};
19
16
  }
20
- const config = ConfigService_1.default.getInstance().getConfig();
17
+ const config = ConfigService_1.ConfigService.getInstance().getConfig();
21
18
  // apply defaults
22
19
  if (requestConfig.bridges || config.defaultRouteOptions.bridges) {
23
20
  requestConfig.bridges =
@@ -50,7 +47,7 @@ const getToken = async (chain, token, options) => {
50
47
  if (!token) {
51
48
  throw new errors_1.ValidationError('Required parameter "token" is missing.');
52
49
  }
53
- const config = ConfigService_1.default.getInstance().getConfig();
50
+ const config = ConfigService_1.ConfigService.getInstance().getConfig();
54
51
  try {
55
52
  const response = await (0, request_1.request)(`${config.apiUrl}/token?${new URLSearchParams({
56
53
  chain,
@@ -65,7 +62,7 @@ const getToken = async (chain, token, options) => {
65
62
  }
66
63
  };
67
64
  const getQuote = async (requestConfig, options) => {
68
- const config = ConfigService_1.default.getInstance().getConfig();
65
+ const config = ConfigService_1.ConfigService.getInstance().getConfig();
69
66
  const requiredParameters = [
70
67
  'fromChain',
71
68
  'fromToken',
@@ -104,7 +101,7 @@ const getQuote = async (requestConfig, options) => {
104
101
  }
105
102
  };
106
103
  const getContractCallQuote = async (requestConfig, options) => {
107
- const config = ConfigService_1.default.getInstance().getConfig();
104
+ const config = ConfigService_1.ConfigService.getInstance().getConfig();
108
105
  // validation
109
106
  const requiredParameters = [
110
107
  'fromChain',
@@ -154,7 +151,7 @@ const getStatus = async (requestConfig, options) => {
154
151
  if (!requestConfig.txHash) {
155
152
  throw new errors_1.ValidationError('Required parameter "txHash" is missing.');
156
153
  }
157
- const config = ConfigService_1.default.getInstance().getConfig();
154
+ const config = ConfigService_1.ConfigService.getInstance().getConfig();
158
155
  const queryParams = new URLSearchParams(requestConfig);
159
156
  try {
160
157
  const response = await (0, request_1.request)(`${config.apiUrl}/status?${queryParams}`, {
@@ -167,7 +164,7 @@ const getStatus = async (requestConfig, options) => {
167
164
  }
168
165
  };
169
166
  const getChains = async (options) => {
170
- const config = ConfigService_1.default.getInstance().getConfig();
167
+ const config = ConfigService_1.ConfigService.getInstance().getConfig();
171
168
  try {
172
169
  const response = await (0, request_1.request)(`${config.apiUrl}/chains`, {
173
170
  signal: options?.signal,
@@ -182,7 +179,7 @@ const getRoutes = async (requestConfig, options) => {
182
179
  if (!(0, typeguards_1.isRoutesRequest)(requestConfig)) {
183
180
  throw new errors_1.ValidationError('Invalid routes request.');
184
181
  }
185
- const config = ConfigService_1.default.getInstance().getConfig();
182
+ const config = ConfigService_1.ConfigService.getInstance().getConfig();
186
183
  // apply defaults
187
184
  requestConfig.options = {
188
185
  ...config.defaultRouteOptions,
@@ -210,7 +207,7 @@ const getStepTransaction = async (step, options) => {
210
207
  // eslint-disable-next-line no-console
211
208
  console.warn('SDK Validation: Invalid Step', step);
212
209
  }
213
- const config = ConfigService_1.default.getInstance().getConfig();
210
+ const config = ConfigService_1.ConfigService.getInstance().getConfig();
214
211
  try {
215
212
  const response = await (0, request_1.request)(`${config.apiUrl}/advanced/stepTransaction`, {
216
213
  method: 'POST',
@@ -227,7 +224,7 @@ const getStepTransaction = async (step, options) => {
227
224
  }
228
225
  };
229
226
  const getTools = async (requestConfig, options) => {
230
- const config = ConfigService_1.default.getInstance().getConfig();
227
+ const config = ConfigService_1.ConfigService.getInstance().getConfig();
231
228
  if (requestConfig) {
232
229
  Object.keys(requestConfig).forEach((key) => !requestConfig[key] &&
233
230
  delete requestConfig[key]);
@@ -238,7 +235,7 @@ const getTools = async (requestConfig, options) => {
238
235
  return response;
239
236
  };
240
237
  const getTokens = async (requestConfig, options) => {
241
- const config = ConfigService_1.default.getInstance().getConfig();
238
+ const config = ConfigService_1.ConfigService.getInstance().getConfig();
242
239
  if (requestConfig) {
243
240
  Object.keys(requestConfig).forEach((key) => !requestConfig[key] &&
244
241
  delete requestConfig[key]);
@@ -249,7 +246,7 @@ const getTokens = async (requestConfig, options) => {
249
246
  return response;
250
247
  };
251
248
  const getGasRecommendation = async ({ chainId, fromChain, fromToken }, options) => {
252
- const config = ConfigService_1.default.getInstance().getConfig();
249
+ const config = ConfigService_1.ConfigService.getInstance().getConfig();
253
250
  if (!chainId) {
254
251
  throw new errors_1.ValidationError('Required parameter "chainId" is missing.');
255
252
  }
@@ -271,7 +268,7 @@ const getGasRecommendation = async ({ chainId, fromChain, fromToken }, options)
271
268
  }
272
269
  };
273
270
  const getAvailableConnections = async (connectionRequest) => {
274
- const config = ConfigService_1.default.getInstance().getConfig();
271
+ const config = ConfigService_1.ConfigService.getInstance().getConfig();
275
272
  const url = new URL(`${config.apiUrl}/connections`);
276
273
  const { fromChain, fromToken, toChain, toToken } = connectionRequest;
277
274
  if (fromChain) {
@@ -281,10 +278,10 @@ const getAvailableConnections = async (connectionRequest) => {
281
278
  url.searchParams.append('fromToken', fromToken);
282
279
  }
283
280
  if (toChain) {
284
- url.searchParams.append('fromToken', toChain);
281
+ url.searchParams.append('toChain', toChain);
285
282
  }
286
283
  if (toToken) {
287
- url.searchParams.append('fromToken', toToken);
284
+ url.searchParams.append('toToken', toToken);
288
285
  }
289
286
  const connectionRequestArrayParams = [
290
287
  'allowBridges',
@@ -1,5 +1,5 @@
1
1
  import type { ChainId, ExtendedChain } from '@lifi/types';
2
- export default class ChainsService {
2
+ export declare class ChainsService {
3
3
  private static instance;
4
4
  private readonly loadingPromise;
5
5
  private chains;
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ChainsService = void 0;
6
7
  const errors_1 = require("../utils/errors");
7
8
  const ApiService_1 = __importDefault(require("./ApiService"));
8
9
  class ChainsService {
@@ -36,4 +37,4 @@ class ChainsService {
36
37
  return this.chains;
37
38
  }
38
39
  }
39
- exports.default = ChainsService;
40
+ exports.ChainsService = ChainsService;
@@ -1,5 +1,6 @@
1
- import type { Chain, Config, ConfigUpdate } from '../types';
2
- export default class ConfigService {
1
+ import type { Chain } from '@lifi/types';
2
+ import type { SDKConfig, SDKOptions } from '../types';
3
+ export declare class ConfigService {
3
4
  private static instance;
4
5
  private readonly config;
5
6
  private readonly setupPromise;
@@ -11,13 +12,15 @@ export default class ConfigService {
11
12
  /**
12
13
  * This call immediately returns the current config. It does not make sure that all chain data is already loaded
13
14
  * Use this if you need access to basic information like API urls or settings
15
+ * @returns SDKConfig
14
16
  */
15
- getConfig: () => Config;
17
+ getConfig: () => SDKConfig;
16
18
  /**
17
19
  * This call waits for all setup promises to be done.
18
20
  * Use this if you need access to chain data (RPCs or multicalls)
21
+ * @returns SDKConfig
19
22
  */
20
- getConfigAsync: () => Promise<Config>;
21
- updateConfig: (configUpdate: Partial<ConfigUpdate>) => Config;
22
- updateChains: (chains: Chain[]) => Config;
23
+ getConfigAsync: () => Promise<SDKConfig>;
24
+ updateConfig: (configUpdate: Partial<SDKOptions>) => SDKConfig;
25
+ updateChains: (chains: Chain[]) => SDKConfig;
23
26
  }
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const types_1 = require("../types");
3
+ exports.ConfigService = void 0;
4
+ const types_1 = require("@lifi/types");
4
5
  const DefaultExecutionSettings = {
5
- /* eslint-disable-next-line @typescript-eslint/no-empty-function */
6
6
  updateRouteHook: () => { },
7
7
  switchChainHook: () => Promise.resolve(undefined),
8
8
  acceptExchangeRateUpdateHook: () => Promise.resolve(undefined),
@@ -15,6 +15,7 @@ class ConfigService {
15
15
  /**
16
16
  * This call immediately returns the current config. It does not make sure that all chain data is already loaded
17
17
  * Use this if you need access to basic information like API urls or settings
18
+ * @returns SDKConfig
18
19
  */
19
20
  this.getConfig = () => {
20
21
  return this.config;
@@ -22,6 +23,7 @@ class ConfigService {
22
23
  /**
23
24
  * This call waits for all setup promises to be done.
24
25
  * Use this if you need access to chain data (RPCs or multicalls)
26
+ * @returns SDKConfig
25
27
  */
26
28
  this.getConfigAsync = async () => {
27
29
  await this.setupPromise;
@@ -38,6 +40,7 @@ class ConfigService {
38
40
  this.config.defaultExecutionSettings = Object.assign(this.config.defaultExecutionSettings, configUpdate.defaultExecutionSettings);
39
41
  // OPTIONS
40
42
  this.config.defaultRouteOptions = Object.assign(this.config.defaultRouteOptions, configUpdate.defaultRouteOptions);
43
+ this.config.apiKey = configUpdate.apiKey || this.config.apiKey;
41
44
  this.config.userId = configUpdate.userId || this.config.userId;
42
45
  this.config.integrator = configUpdate.integrator || this.config.integrator;
43
46
  this.config.defaultRouteOptions.integrator =
@@ -46,7 +49,7 @@ class ConfigService {
46
49
  this.config.integrator;
47
50
  this.config.widgetVersion =
48
51
  configUpdate.widgetVersion || this.config.widgetVersion;
49
- this.config.multisig = configUpdate.multisigConfig || this.config.multisig;
52
+ this.config.multisig = configUpdate.multisig || this.config.multisig;
50
53
  return this.config;
51
54
  };
52
55
  this.updateChains = (chains) => {
@@ -86,6 +89,7 @@ class ConfigService {
86
89
  return this.instance;
87
90
  }
88
91
  }
92
+ exports.ConfigService = ConfigService;
89
93
  ConfigService.getDefaultConfig = () => {
90
94
  return {
91
95
  apiUrl: 'https://li.quest/v1',
@@ -98,4 +102,3 @@ ConfigService.getDefaultConfig = () => {
98
102
  integrator: 'lifi-sdk',
99
103
  };
100
104
  };
101
- exports.default = ConfigService;
@@ -1,4 +1,4 @@
1
- import type { LifiStep, RoutesRequest, StaticToken } from './types';
1
+ import type { LiFiStep, RoutesRequest, StaticToken } from '@lifi/types';
2
2
  export declare const isRoutesRequest: (routesRequest: RoutesRequest) => routesRequest is RoutesRequest;
3
- export declare const isStep: (step: LifiStep) => step is LifiStep;
3
+ export declare const isStep: (step: LiFiStep) => step is LiFiStep;
4
4
  export declare const isToken: (token: StaticToken) => token is StaticToken;
@@ -1,4 +1,2 @@
1
- export * from '@lifi/types';
2
- export { ErrorCode, LiFiError } from '../utils/errors';
3
1
  export * from './abi';
4
- export * from './internal.types';
2
+ export * from './internal';
@@ -14,9 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.LiFiError = void 0;
18
- __exportStar(require("@lifi/types"), exports);
19
- var errors_1 = require("../utils/errors");
20
- Object.defineProperty(exports, "LiFiError", { enumerable: true, get: function () { return errors_1.LiFiError; } });
21
17
  __exportStar(require("./abi"), exports);
22
- __exportStar(require("./internal.types"), exports);
18
+ __exportStar(require("./internal"), exports);
@@ -0,0 +1,60 @@
1
+ import type { ChainId, RouteOptions } from '@lifi/types';
2
+ import type { ExecutionSettings, InternalExecutionSettings, MultisigConfig } from '../execution/types';
3
+ import type { SDKProvider } from '../providers';
4
+ export interface SDKConfig {
5
+ apiUrl: string;
6
+ apiKey?: string;
7
+ rpcs: Record<ChainId, string[]>;
8
+ multicallAddresses: Record<ChainId, string | undefined>;
9
+ defaultExecutionSettings: InternalExecutionSettings;
10
+ defaultRouteOptions: RouteOptions;
11
+ disableVersionCheck?: boolean;
12
+ userId?: string;
13
+ integrator: string;
14
+ widgetVersion?: string;
15
+ multisig?: MultisigConfig;
16
+ providers?: SDKProvider[];
17
+ }
18
+ export interface SDKOptions extends Partial<Omit<SDKConfig, 'defaultExecutionSettings' | 'integrator'>> {
19
+ defaultExecutionSettings?: ExecutionSettings;
20
+ integrator: string;
21
+ }
22
+ export interface TenderlyResponse {
23
+ hash: string;
24
+ block_hash: string;
25
+ block_number: number;
26
+ from: string;
27
+ gas: number;
28
+ gas_price: number;
29
+ gas_fee_cap: number;
30
+ gas_tip_cap: number;
31
+ cumulative_gas_used: number;
32
+ gas_used: number;
33
+ effective_gas_price: number;
34
+ input: string;
35
+ nonce: number;
36
+ to: string;
37
+ index: number;
38
+ value: string;
39
+ access_list: unknown;
40
+ status: boolean;
41
+ addresses: string[];
42
+ contract_ids: string[];
43
+ network_id: string;
44
+ timestamp: string;
45
+ function_selector: string;
46
+ l1_block_number: number;
47
+ l1_timestamp: number;
48
+ deposit_tx: boolean;
49
+ system_tx: boolean;
50
+ mint: number;
51
+ sig: {
52
+ v: string;
53
+ r: string;
54
+ s: string;
55
+ };
56
+ error_message: string;
57
+ method: string;
58
+ decoded_input: unknown;
59
+ call_trace: unknown;
60
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,4 @@
1
- import type { LifiStep, Process } from '@lifi/types';
1
+ import type { LiFiStep, Process } from '@lifi/types';
2
2
  import { LiFiError } from './errors';
3
3
  /**
4
4
  * Available MetaMask error codes:
@@ -31,7 +31,7 @@ import { LiFiError } from './errors';
31
31
  * https://eips.ethereum.org/EIPS/eip-1474#error-codes
32
32
  * https://eips.ethereum.org/EIPS/eip-1193#provider-errors
33
33
  */
34
- export declare const getTransactionNotSentMessage: (step?: LifiStep, process?: Process) => Promise<string>;
35
- export declare const getTransactionFailedMessage: (step: LifiStep, txLink?: string) => Promise<string>;
36
- export declare const parseError: (e: any, step?: LifiStep, process?: Process) => Promise<LiFiError>;
34
+ export declare const getTransactionNotSentMessage: (step?: LiFiStep, process?: Process) => Promise<string>;
35
+ export declare const getTransactionFailedMessage: (step: LiFiStep, txLink?: string) => Promise<string>;
36
+ export declare const parseError: (e: any, step?: LiFiStep, process?: Process) => Promise<LiFiError>;
37
37
  export declare const parseBackendError: (e: any) => Promise<LiFiError>;
@@ -1,13 +1,10 @@
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
3
  exports.parseBackendError = exports.parseError = exports.getTransactionFailedMessage = exports.getTransactionNotSentMessage = void 0;
7
4
  const eth_rpc_errors_1 = require("eth-rpc-errors");
8
5
  const viem_1 = require("viem");
9
6
  const helpers_1 = require("../helpers");
10
- const ChainsService_1 = __importDefault(require("../services/ChainsService"));
7
+ const ChainsService_1 = require("../services/ChainsService");
11
8
  const errors_1 = require("./errors");
12
9
  /**
13
10
  * Available MetaMask error codes:
@@ -44,7 +41,7 @@ const getTransactionNotSentMessage = async (step, process) => {
44
41
  let transactionNotSend = 'Transaction was not sent, your funds are still in your wallet';
45
42
  // add information about funds if available
46
43
  if (step) {
47
- const chainService = ChainsService_1.default.getInstance();
44
+ const chainService = ChainsService_1.ChainsService.getInstance();
48
45
  const chain = await chainService.getChainById(step.action.fromChainId);
49
46
  transactionNotSend += ` (${(0, viem_1.formatUnits)(BigInt(step.action.fromAmount), step.action.fromToken.decimals)} ${step.action.fromToken.symbol} on ${chain.name})`;
50
47
  }
@@ -59,7 +56,7 @@ const getTransactionNotSentMessage = async (step, process) => {
59
56
  };
60
57
  exports.getTransactionNotSentMessage = getTransactionNotSentMessage;
61
58
  const getTransactionFailedMessage = async (step, txLink) => {
62
- const chainsService = ChainsService_1.default.getInstance();
59
+ const chainsService = ChainsService_1.ChainsService.getInstance();
63
60
  const chain = await chainsService.getChainById(step.action.toChainId);
64
61
  const baseString = `It appears that your transaction may not have been successful.
65
62
  However, to confirm this, please check your ${chain.name} wallet for ${step.action.toToken.symbol}.`;
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/sdk";
2
- export declare const version = "3.0.0-alpha.6";
2
+ export declare const version = "3.0.0-alpha.8";
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = exports.name = void 0;
4
4
  exports.name = '@lifi/sdk';
5
- exports.version = '3.0.0-alpha.6';
5
+ exports.version = '3.0.0-alpha.8';
@@ -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[]>;
@@ -1,6 +1,6 @@
1
1
  import { createPublicClient, fallback, http } from 'viem';
2
2
  import * as chains from 'viem/chains'; // TODO: optimize using BE chains
3
- import ConfigService from './services/ConfigService';
3
+ import { ConfigService } from './services/ConfigService';
4
4
  import { ServerError } from './utils/errors';
5
5
  // cached providers
6
6
  const publicClients = {};
@@ -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,23 @@
1
+ // Please be careful when changing the defaults as it may break the behavior (e.g., background execution)
2
+ const defaultInteractionSettings = {
3
+ allowInteraction: true,
4
+ allowUpdates: true,
5
+ allowExecution: true,
6
+ };
7
+ export class BaseStepExecutor {
8
+ constructor(options) {
9
+ this.allowUserInteraction = true;
10
+ this.allowExecution = true;
11
+ this.setInteraction = (settings) => {
12
+ const interactionSettings = {
13
+ ...defaultInteractionSettings,
14
+ ...settings,
15
+ };
16
+ this.allowUserInteraction = interactionSettings.allowInteraction;
17
+ this.statusManager.allowUpdates(interactionSettings.allowUpdates);
18
+ this.allowExecution = interactionSettings.allowExecution;
19
+ };
20
+ this.statusManager = options.statusManager;
21
+ this.settings = options.settings;
22
+ }
23
+ }
@@ -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
+ }