@lifi/sdk 3.0.0-alpha.7 → 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 (67) hide show
  1. package/dist/LiFi.js +1 -1
  2. package/dist/cjs/LiFi.js +2 -2
  3. package/dist/cjs/connectors.js +3 -6
  4. package/dist/cjs/execution/EVMStepExecutor.js +4 -4
  5. package/dist/cjs/execution/RouteExecutionManager.d.ts +4 -2
  6. package/dist/cjs/execution/RouteExecutionManager.js +10 -8
  7. package/dist/cjs/execution/StepExecutionManager.js +4 -4
  8. package/dist/cjs/execution/multisig.js +2 -5
  9. package/dist/cjs/index.d.ts +2 -0
  10. package/dist/cjs/index.js +5 -2
  11. package/dist/cjs/providers/EVM.d.ts +10 -0
  12. package/dist/cjs/providers/EVM.js +34 -0
  13. package/dist/cjs/providers/Solana.d.ts +9 -0
  14. package/dist/cjs/providers/Solana.js +38 -0
  15. package/dist/cjs/providers/index.d.ts +1 -0
  16. package/dist/cjs/providers/index.js +17 -0
  17. package/dist/cjs/providers/types.d.ts +12 -0
  18. package/dist/cjs/providers/types.js +7 -0
  19. package/dist/cjs/request.js +2 -5
  20. package/dist/cjs/services/ApiService.js +13 -16
  21. package/dist/cjs/services/ChainsService.d.ts +1 -1
  22. package/dist/cjs/services/ChainsService.js +2 -1
  23. package/dist/cjs/services/ConfigService.d.ts +3 -1
  24. package/dist/cjs/services/ConfigService.js +4 -1
  25. package/dist/cjs/types/internal.d.ts +2 -2
  26. package/dist/cjs/utils/parseError.js +3 -6
  27. package/dist/cjs/version.d.ts +1 -1
  28. package/dist/cjs/version.js +1 -1
  29. package/dist/connectors.js +1 -1
  30. package/dist/execution/EVMStepExecutor.js +2 -2
  31. package/dist/execution/RouteExecutionManager.d.ts +4 -2
  32. package/dist/execution/RouteExecutionManager.js +9 -4
  33. package/dist/execution/StepExecutionManager.js +2 -2
  34. package/dist/execution/multisig.js +1 -1
  35. package/dist/index.d.ts +2 -0
  36. package/dist/index.js +2 -1
  37. package/dist/providers/EVM.d.ts +10 -0
  38. package/dist/providers/EVM.js +29 -0
  39. package/dist/providers/Solana.d.ts +9 -0
  40. package/dist/providers/Solana.js +33 -0
  41. package/dist/providers/index.d.ts +1 -0
  42. package/dist/providers/index.js +1 -0
  43. package/dist/providers/types.d.ts +12 -0
  44. package/dist/providers/types.js +5 -1
  45. package/dist/request.js +1 -1
  46. package/dist/services/ApiService.js +1 -1
  47. package/dist/services/ChainsService.d.ts +1 -1
  48. package/dist/services/ChainsService.js +1 -1
  49. package/dist/services/ConfigService.d.ts +3 -1
  50. package/dist/services/ConfigService.js +3 -2
  51. package/dist/types/internal.d.ts +2 -2
  52. package/dist/utils/parseError.js +1 -1
  53. package/dist/version.d.ts +1 -1
  54. package/dist/version.js +1 -1
  55. package/package.json +1 -1
  56. package/dist/cjs/providers/BaseProvider.d.ts +0 -7
  57. package/dist/cjs/providers/BaseProvider.js +0 -6
  58. package/dist/cjs/providers/EVMProvider.d.ts +0 -16
  59. package/dist/cjs/providers/EVMProvider.js +0 -28
  60. package/dist/cjs/providers/SolanaProvider.d.ts +0 -15
  61. package/dist/cjs/providers/SolanaProvider.js +0 -32
  62. package/dist/providers/BaseProvider.d.ts +0 -7
  63. package/dist/providers/BaseProvider.js +0 -2
  64. package/dist/providers/EVMProvider.d.ts +0 -16
  65. package/dist/providers/EVMProvider.js +0 -24
  66. package/dist/providers/SolanaProvider.d.ts +0 -15
  67. package/dist/providers/SolanaProvider.js +0 -28
package/dist/LiFi.js CHANGED
@@ -4,7 +4,7 @@ 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';
package/dist/cjs/LiFi.js CHANGED
@@ -33,7 +33,7 @@ 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 = __importDefault(require("./services/ChainsService"));
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");
@@ -273,7 +273,7 @@ class LiFi extends RouteExecutionManager_1.RouteExecutionManager {
273
273
  const connections = await ApiService_1.default.getAvailableConnections(connectionRequest);
274
274
  return connections;
275
275
  };
276
- this.chainsService = ChainsService_1.default.getInstance();
276
+ this.chainsService = ChainsService_1.ChainsService.getInstance();
277
277
  this.chainsService.getChains().then((chains) => {
278
278
  this.configService.updateChains(chains);
279
279
  });
@@ -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 = __importDefault(require("./services/ConfigService"));
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.default.getInstance();
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.default.getInstance();
68
+ const configService = ConfigService_1.ConfigService.getInstance();
72
69
  const config = await configService.getConfigAsync();
73
70
  return config.multicallAddresses[chainId];
74
71
  };
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.EVMStepExecutor = void 0;
7
7
  const viem_1 = require("viem");
8
8
  const ApiService_1 = __importDefault(require("../services/ApiService"));
9
- const ChainsService_1 = __importDefault(require("../services/ChainsService"));
10
- const ConfigService_1 = __importDefault(require("../services/ConfigService"));
9
+ const ChainsService_1 = require("../services/ChainsService");
10
+ const ConfigService_1 = require("../services/ConfigService");
11
11
  const utils_1 = require("../utils");
12
12
  const errors_1 = require("../utils/errors");
13
13
  const parseError_1 = require("../utils/parseError");
@@ -46,13 +46,13 @@ class EVMStepExecutor extends BaseStepExecutor_1.BaseStepExecutor {
46
46
  this.walletClient = updatedWalletClient;
47
47
  }
48
48
  const client = this.walletClient.extend(viem_1.publicActions);
49
- const config = ConfigService_1.default.getInstance().getConfig();
49
+ const config = ConfigService_1.ConfigService.getInstance().getConfig();
50
50
  const isMultisigWalletClient = !!config.multisig?.isMultisigWalletClient;
51
51
  const multisigBatchTransactions = [];
52
52
  const shouldBatchTransactions = config.multisig?.shouldBatchTransactions &&
53
53
  !!config.multisig.sendBatchTransaction;
54
54
  step.execution = this.statusManager.initExecutionObject(step);
55
- const chainsService = ChainsService_1.default.getInstance();
55
+ const chainsService = ChainsService_1.ChainsService.getInstance();
56
56
  const fromChain = await chainsService.getChainById(step.action.fromChainId);
57
57
  const toChain = await chainsService.getChainById(step.action.toChainId);
58
58
  const isBridgeExecution = fromChain.id !== toChain.id;
@@ -1,12 +1,13 @@
1
1
  import type { Route } from '@lifi/types';
2
- import ConfigService from '../services/ConfigService';
2
+ import type { ProviderType, SDKProvider } from '../providers';
3
+ import { ConfigService } from '../services/ConfigService';
3
4
  import type { SDKOptions } from '../types';
4
5
  import type { ExecutionSettings } from './types';
5
6
  export declare class RouteExecutionManager {
6
7
  private executionDictionary;
7
8
  private executionPromiseDictionary;
8
9
  protected configService: ConfigService;
9
- private providers;
10
+ private providers?;
10
11
  constructor(options: SDKOptions);
11
12
  /**
12
13
  * Execute a route.
@@ -55,4 +56,5 @@ export declare class RouteExecutionManager {
55
56
  * @returns The updated route.
56
57
  */
57
58
  getActiveRoute: (route: Route) => Route | undefined;
59
+ getProvider: (type: ProviderType) => SDKProvider | undefined;
58
60
  }
@@ -1,11 +1,7 @@
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.RouteExecutionManager = void 0;
7
- const EVMProvider_1 = require("../providers/EVMProvider");
8
- const ConfigService_1 = __importDefault(require("../services/ConfigService"));
4
+ const ConfigService_1 = require("../services/ConfigService");
9
5
  const errors_1 = require("../utils/errors");
10
6
  const StatusManager_1 = require("./StatusManager");
11
7
  const prepareRestart_1 = require("./prepareRestart");
@@ -91,7 +87,10 @@ class RouteExecutionManager {
91
87
  step.action.fromAmount = previousStep.execution.toAmount;
92
88
  }
93
89
  try {
94
- const provider = this.providers.find((provider) => provider.isProviderStep(step));
90
+ const provider = this.providers?.find((provider) => provider.isProviderStep(step));
91
+ if (!provider) {
92
+ throw new Error('SDK Execution Provider not found.');
93
+ }
95
94
  const stepExecutor = await provider.getStepExecutor({
96
95
  statusManager,
97
96
  settings: execution.settings,
@@ -194,9 +193,12 @@ class RouteExecutionManager {
194
193
  this.getActiveRoute = (route) => {
195
194
  return this.executionDictionary[route.id]?.route;
196
195
  };
197
- this.configService = ConfigService_1.default.getInstance();
196
+ this.getProvider = (type) => {
197
+ return this.providers?.find((provider) => provider.type === type);
198
+ };
199
+ this.configService = ConfigService_1.ConfigService.getInstance();
198
200
  this.configService.updateConfig(options);
199
- this.providers = options.providers ?? [new EVMProvider_1.EVMProvider()];
201
+ this.providers = options.providers;
200
202
  }
201
203
  }
202
204
  exports.RouteExecutionManager = RouteExecutionManager;
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.StepExecutionManager = void 0;
7
7
  const viem_1 = require("viem");
8
8
  const ApiService_1 = __importDefault(require("../services/ApiService"));
9
- const ChainsService_1 = __importDefault(require("../services/ChainsService"));
10
- const ConfigService_1 = __importDefault(require("../services/ConfigService"));
9
+ const ChainsService_1 = require("../services/ChainsService");
10
+ const ConfigService_1 = require("../services/ConfigService");
11
11
  const utils_1 = require("../utils");
12
12
  const errors_1 = require("../utils/errors");
13
13
  const parseError_1 = require("../utils/parseError");
@@ -27,13 +27,13 @@ class StepExecutionManager {
27
27
  };
28
28
  this.execute = async ({ walletClient, step, statusManager, settings, }) => {
29
29
  const client = walletClient.extend(viem_1.publicActions);
30
- const config = ConfigService_1.default.getInstance().getConfig();
30
+ const config = ConfigService_1.ConfigService.getInstance().getConfig();
31
31
  const isMultisigWalletClient = !!config.multisig?.isMultisigWalletClient;
32
32
  const multisigBatchTransactions = [];
33
33
  const shouldBatchTransactions = config.multisig?.shouldBatchTransactions &&
34
34
  !!config.multisig.sendBatchTransaction;
35
35
  step.execution = statusManager.initExecutionObject(step);
36
- const chainsService = ChainsService_1.default.getInstance();
36
+ const chainsService = ChainsService_1.ChainsService.getInstance();
37
37
  const fromChain = await chainsService.getChainById(step.action.fromChainId);
38
38
  const toChain = await chainsService.getChainById(step.action.toChainId);
39
39
  const isBridgeExecution = fromChain.id !== toChain.id;
@@ -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.updateMultisigRouteProcess = void 0;
7
- const ConfigService_1 = __importDefault(require("../services/ConfigService"));
4
+ const ConfigService_1 = require("../services/ConfigService");
8
5
  const errors_1 = require("../utils/errors");
9
6
  const updateMultisigRouteProcess = async (internalTxHash, step, statusManager, processType, fromChain) => {
10
- const config = ConfigService_1.default.getInstance().getConfig();
7
+ const config = ConfigService_1.ConfigService.getInstance().getConfig();
11
8
  if (!config.multisig?.getMultisigTransactionDetails) {
12
9
  throw new Error('getMultisigTransactionDetails is missing in multisig config.');
13
10
  }
@@ -2,6 +2,8 @@ export * from '@lifi/types';
2
2
  export { LiFi } from './LiFi';
3
3
  export * from './execution';
4
4
  export * from './helpers';
5
+ export { EVM, type EVMProviderOptions } from './providers/EVM';
6
+ export { Solana, type SolanaProviderOptions } from './providers/Solana';
5
7
  export * from './types';
6
8
  export * from './utils/errors';
7
9
  export { ErrorCode, LiFiError } from './utils/errors';
package/dist/cjs/index.js CHANGED
@@ -14,13 +14,16 @@ 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 = exports.LiFi = void 0;
18
- // expose types and helpers
17
+ exports.LiFiError = exports.Solana = exports.EVM = exports.LiFi = void 0;
19
18
  __exportStar(require("@lifi/types"), exports);
20
19
  var LiFi_1 = require("./LiFi");
21
20
  Object.defineProperty(exports, "LiFi", { enumerable: true, get: function () { return LiFi_1.LiFi; } });
22
21
  __exportStar(require("./execution"), exports);
23
22
  __exportStar(require("./helpers"), exports);
23
+ var EVM_1 = require("./providers/EVM");
24
+ Object.defineProperty(exports, "EVM", { enumerable: true, get: function () { return EVM_1.EVM; } });
25
+ var Solana_1 = require("./providers/Solana");
26
+ Object.defineProperty(exports, "Solana", { enumerable: true, get: function () { return Solana_1.Solana; } });
24
27
  __exportStar(require("./types"), exports);
25
28
  __exportStar(require("./utils/errors"), exports);
26
29
  var errors_1 = require("./utils/errors");
@@ -0,0 +1,10 @@
1
+ import { type WalletClient } from 'viem';
2
+ import type { SDKProvider } from './types';
3
+ export interface EVMProviderOptions {
4
+ getWalletClient: () => Promise<WalletClient>;
5
+ }
6
+ export interface EVMProvider extends SDKProvider {
7
+ setOptions(options: EVMProviderOptions): void;
8
+ }
9
+ export declare function EVM(options?: EVMProviderOptions): EVMProvider;
10
+ export declare function isEVM(provider: SDKProvider): provider is EVMProvider;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isEVM = exports.EVM = void 0;
4
+ const viem_1 = require("viem");
5
+ const EVMStepExecutor_1 = require("../execution/EVMStepExecutor");
6
+ const types_1 = require("./types");
7
+ function EVM(options) {
8
+ let getWalletClient = options?.getWalletClient;
9
+ return {
10
+ get type() {
11
+ return types_1.ProviderType.EVM;
12
+ },
13
+ isProviderStep(step) {
14
+ const isProviderStep = (0, viem_1.isAddress)(step.action.fromAddress);
15
+ return isProviderStep;
16
+ },
17
+ async getStepExecutor(options) {
18
+ if (!getWalletClient) {
19
+ throw new Error(`getWalletClient is not provided.`);
20
+ }
21
+ const walletClient = await getWalletClient();
22
+ const executor = new EVMStepExecutor_1.EVMStepExecutor({ walletClient, ...options });
23
+ return executor;
24
+ },
25
+ setOptions(options) {
26
+ getWalletClient = options.getWalletClient;
27
+ },
28
+ };
29
+ }
30
+ exports.EVM = EVM;
31
+ function isEVM(provider) {
32
+ return provider.type === types_1.ProviderType.EVM;
33
+ }
34
+ exports.isEVM = isEVM;
@@ -0,0 +1,9 @@
1
+ import type { SDKProvider } from './types';
2
+ export interface SolanaProviderOptions {
3
+ getWalletClient: () => Promise<unknown>;
4
+ }
5
+ export interface SolanaProvider extends SDKProvider {
6
+ setOptions(options: SolanaProviderOptions): void;
7
+ }
8
+ export declare function Solana(options?: SolanaProviderOptions): SolanaProvider;
9
+ export declare function isEVM(provider: SDKProvider): provider is SolanaProvider;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isEVM = exports.Solana = void 0;
4
+ const web3_js_1 = require("@solana/web3.js");
5
+ const types_1 = require("./types");
6
+ function Solana(options) {
7
+ let getWalletClient = options?.getWalletClient;
8
+ return {
9
+ get type() {
10
+ return types_1.ProviderType.Solana;
11
+ },
12
+ isProviderStep(step) {
13
+ try {
14
+ const publickKey = new web3_js_1.PublicKey(step.action.fromAddress);
15
+ const isProviderStep = web3_js_1.PublicKey.isOnCurve(publickKey);
16
+ return isProviderStep;
17
+ }
18
+ catch (error) {
19
+ return false;
20
+ }
21
+ },
22
+ async getStepExecutor(options) {
23
+ if (!getWalletClient) {
24
+ throw new Error(`getWalletClient is not provided.`);
25
+ }
26
+ const walletClient = await getWalletClient();
27
+ return null;
28
+ },
29
+ setOptions(options) {
30
+ getWalletClient = options.getWalletClient;
31
+ },
32
+ };
33
+ }
34
+ exports.Solana = Solana;
35
+ function isEVM(provider) {
36
+ return provider.type === types_1.ProviderType.Solana;
37
+ }
38
+ exports.isEVM = isEVM;
@@ -0,0 +1 @@
1
+ export * from './types';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,12 @@
1
+ import type { LiFiStep } from '@lifi/types';
2
+ import type { BaseStepExecutor } from '../execution/BaseStepExecutor';
3
+ import type { StepExecutorOptions } from '../execution/types';
4
+ export interface SDKProvider {
5
+ readonly type: ProviderType;
6
+ isProviderStep(step: LiFiStep): boolean;
7
+ getStepExecutor(options: StepExecutorOptions): Promise<BaseStepExecutor>;
8
+ }
9
+ export declare enum ProviderType {
10
+ EVM = "EVM",
11
+ Solana = "Solana"
12
+ }
@@ -1 +1,8 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProviderType = void 0;
4
+ var ProviderType;
5
+ (function (ProviderType) {
6
+ ProviderType["EVM"] = "EVM";
7
+ ProviderType["Solana"] = "Solana";
8
+ })(ProviderType || (exports.ProviderType = ProviderType = {}));
@@ -1,10 +1,7 @@
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.request = exports.requestSettings = void 0;
7
- const ConfigService_1 = __importDefault(require("./services/ConfigService"));
4
+ const ConfigService_1 = require("./services/ConfigService");
8
5
  const errors_1 = require("./utils/errors");
9
6
  const utils_1 = require("./utils/utils");
10
7
  const version_1 = require("./version");
@@ -14,7 +11,7 @@ exports.requestSettings = {
14
11
  const request = async (url, options = {
15
12
  retries: exports.requestSettings.retries,
16
13
  }) => {
17
- const { userId, integrator, widgetVersion, apiKey } = ConfigService_1.default.getInstance().getConfig();
14
+ const { userId, integrator, widgetVersion, apiKey } = ConfigService_1.ConfigService.getInstance().getConfig();
18
15
  options.retries = options.retries ?? exports.requestSettings.retries;
19
16
  try {
20
17
  if (!options.skipTrackingHeaders) {
@@ -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) {
@@ -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,6 +1,6 @@
1
1
  import type { Chain } from '@lifi/types';
2
2
  import type { SDKConfig, SDKOptions } from '../types';
3
- export default class ConfigService {
3
+ export declare class ConfigService {
4
4
  private static instance;
5
5
  private readonly config;
6
6
  private readonly setupPromise;
@@ -12,11 +12,13 @@ export default class ConfigService {
12
12
  /**
13
13
  * This call immediately returns the current config. It does not make sure that all chain data is already loaded
14
14
  * Use this if you need access to basic information like API urls or settings
15
+ * @returns SDKConfig
15
16
  */
16
17
  getConfig: () => SDKConfig;
17
18
  /**
18
19
  * This call waits for all setup promises to be done.
19
20
  * Use this if you need access to chain data (RPCs or multicalls)
21
+ * @returns SDKConfig
20
22
  */
21
23
  getConfigAsync: () => Promise<SDKConfig>;
22
24
  updateConfig: (configUpdate: Partial<SDKOptions>) => SDKConfig;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConfigService = void 0;
3
4
  const types_1 = require("@lifi/types");
4
5
  const DefaultExecutionSettings = {
5
6
  updateRouteHook: () => { },
@@ -14,6 +15,7 @@ class ConfigService {
14
15
  /**
15
16
  * This call immediately returns the current config. It does not make sure that all chain data is already loaded
16
17
  * Use this if you need access to basic information like API urls or settings
18
+ * @returns SDKConfig
17
19
  */
18
20
  this.getConfig = () => {
19
21
  return this.config;
@@ -21,6 +23,7 @@ class ConfigService {
21
23
  /**
22
24
  * This call waits for all setup promises to be done.
23
25
  * Use this if you need access to chain data (RPCs or multicalls)
26
+ * @returns SDKConfig
24
27
  */
25
28
  this.getConfigAsync = async () => {
26
29
  await this.setupPromise;
@@ -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,6 +1,6 @@
1
1
  import type { ChainId, RouteOptions } from '@lifi/types';
2
2
  import type { ExecutionSettings, InternalExecutionSettings, MultisigConfig } from '../execution/types';
3
- import type { BaseProvider } from '../providers/BaseProvider';
3
+ import type { SDKProvider } from '../providers';
4
4
  export interface SDKConfig {
5
5
  apiUrl: string;
6
6
  apiKey?: string;
@@ -13,7 +13,7 @@ export interface SDKConfig {
13
13
  integrator: string;
14
14
  widgetVersion?: string;
15
15
  multisig?: MultisigConfig;
16
- providers?: BaseProvider[];
16
+ providers?: SDKProvider[];
17
17
  }
18
18
  export interface SDKOptions extends Partial<Omit<SDKConfig, 'defaultExecutionSettings' | 'integrator'>> {
19
19
  defaultExecutionSettings?: ExecutionSettings;
@@ -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.7";
2
+ export declare const version = "3.0.0-alpha.8";