@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
  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
  }
@@ -1,3 +1,2 @@
1
- import { type WalletClient } from 'viem';
2
- import type { Route } from '../types';
3
- export declare const prepareRestart: (route: Route, walletClient: WalletClient) => Promise<void>;
1
+ import type { Route } from '@lifi/types';
2
+ export declare const prepareRestart: (route: Route) => Promise<void>;
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.prepareRestart = void 0;
4
4
  const viem_1 = require("viem");
5
5
  const errors_1 = require("../utils/errors");
6
- const prepareRestart = async (route, walletClient) => {
6
+ const prepareRestart = async (route) => {
7
7
  for (let index = 0; index < route.steps.length; index++) {
8
8
  const step = route.steps[index];
9
9
  const stepHasFailed = step.execution?.status === 'FAILED';
10
10
  if (stepHasFailed) {
11
- await handleErrorType(walletClient, step);
11
+ // await handleErrorType(walletClient, step)
12
12
  deleteFailedProcesses(step);
13
13
  deleteTransactionData(step);
14
14
  }
@@ -1,5 +1,6 @@
1
- import type { InternalExecutionSettings, LifiStep } from '../types';
1
+ import type { LiFiStep } from '@lifi/types';
2
2
  import type { StatusManager } from './StatusManager';
3
+ import type { InternalExecutionSettings } from './types';
3
4
  /**
4
5
  * This method checks whether the new and updated Step meets the required exchange rate conditions.
5
6
  * If yes it returns the updated Step.
@@ -9,6 +10,6 @@ import type { StatusManager } from './StatusManager';
9
10
  * @param newStep
10
11
  * @param settings
11
12
  * @param allowUserInteraction
12
- * @returns Return LifiStep
13
+ * @returns Return LiFiStep
13
14
  */
14
- export declare const stepComparison: (statusManager: StatusManager, oldStep: LifiStep, newStep: LifiStep, settings: InternalExecutionSettings, allowUserInteraction: boolean) => Promise<LifiStep>;
15
+ export declare const stepComparison: (statusManager: StatusManager, oldStep: LiFiStep, newStep: LiFiStep, settings: InternalExecutionSettings, allowUserInteraction: boolean) => Promise<LiFiStep>;
@@ -12,7 +12,7 @@ const utils_1 = require("./utils");
12
12
  * @param newStep
13
13
  * @param settings
14
14
  * @param allowUserInteraction
15
- * @returns Return LifiStep
15
+ * @returns Return LiFiStep
16
16
  */
17
17
  const stepComparison = async (statusManager, oldStep, newStep, settings, allowUserInteraction) => {
18
18
  // Check if changed exchange rate is in the range of slippage threshold
@@ -1,7 +1,7 @@
1
- import type { LifiStep } from '@lifi/types';
1
+ import type { LiFiStep } from '@lifi/types';
2
2
  import type { WalletClient } from 'viem';
3
- import type { SwitchChainHook } from '../types';
4
3
  import type { StatusManager } from './StatusManager';
4
+ import type { SwitchChainHook } from './types';
5
5
  /**
6
6
  * This method checks whether the wallet client is configured for the correct chain.
7
7
  * If yes it returns the wallet clien.
@@ -17,5 +17,6 @@ import type { StatusManager } from './StatusManager';
17
17
  * @param step
18
18
  * @param switchChainHook
19
19
  * @param allowUserInteraction
20
+ * @returns New WalletClient
20
21
  */
21
- export declare const switchChain: (walletClient: WalletClient, statusManager: StatusManager, step: LifiStep, switchChainHook: SwitchChainHook, allowUserInteraction: boolean) => Promise<WalletClient | undefined>;
22
+ export declare const switchChain: (walletClient: WalletClient, statusManager: StatusManager, step: LiFiStep, switchChainHook: SwitchChainHook, allowUserInteraction: boolean) => Promise<WalletClient | undefined>;
@@ -17,6 +17,7 @@ const errors_1 = require("../utils/errors");
17
17
  * @param step
18
18
  * @param switchChainHook
19
19
  * @param allowUserInteraction
20
+ * @returns New WalletClient
20
21
  */
21
22
  const switchChain = async (walletClient, statusManager, step, switchChainHook, allowUserInteraction) => {
22
23
  // if we are already on the correct chain we can proceed directly
@@ -1,7 +1,18 @@
1
- import type { ChainId, LifiStep, Route, RouteOptions, Token } from '@lifi/types';
1
+ import type { LiFiStep, Route, Token } from '@lifi/types';
2
2
  import type { Hash, Hex, WalletClient } from 'viem';
3
- import type { StatusManager } from '../execution/StatusManager';
4
- import type { StepExecutor } from '../execution/StepExecutor';
3
+ import type { BaseStepExecutor } from './BaseStepExecutor';
4
+ import type { StatusManager } from './StatusManager';
5
+ export interface StepExecutorOptions {
6
+ statusManager: StatusManager;
7
+ settings: InternalExecutionSettings;
8
+ }
9
+ export interface RouteExecutionData {
10
+ route: Route;
11
+ executors: BaseStepExecutor[];
12
+ settings: InternalExecutionSettings;
13
+ }
14
+ export type RouteExecutionDictionary = Partial<Record<string, RouteExecutionData>>;
15
+ export type RouteExecutionPromiseDictionary = Partial<Record<string, Promise<Route>>>;
5
16
  export type TransactionParameters = {
6
17
  chainId?: number;
7
18
  to?: string;
@@ -14,59 +25,11 @@ export type TransactionParameters = {
14
25
  maxFeePerGas?: bigint;
15
26
  maxPriorityFeePerGas?: bigint;
16
27
  };
17
- export interface ExecutionParams {
18
- walletClient: WalletClient;
19
- step: LifiStep;
20
- statusManager: StatusManager;
21
- settings: InternalExecutionSettings;
22
- }
23
28
  export type UpdateRouteHook = (updatedRoute: Route) => void;
24
29
  export interface TransactionRequestParameters extends TransactionParameters {
25
30
  requestType: 'approve' | 'transaction';
26
31
  }
27
32
  export type TransactionRequestUpdateHook = (updatedTxRequest: TransactionRequestParameters) => Promise<TransactionParameters>;
28
- export type Config = {
29
- apiUrl: string;
30
- rpcs: Record<ChainId, string[]>;
31
- multicallAddresses: Record<ChainId, string | undefined>;
32
- defaultExecutionSettings: InternalExecutionSettings;
33
- defaultRouteOptions: RouteOptions;
34
- disableVersionCheck?: boolean;
35
- userId?: string;
36
- integrator: string;
37
- widgetVersion?: string;
38
- multisig?: MultisigConfig;
39
- };
40
- export interface MultisigTxDetails {
41
- status: 'DONE' | 'FAILED' | 'PENDING' | 'CANCELLED';
42
- txHash?: Hash;
43
- }
44
- export interface MultisigTransactionResponse {
45
- hash: string;
46
- }
47
- export interface BaseTransaction {
48
- to: string;
49
- value?: bigint;
50
- data: string;
51
- }
52
- export interface MultisigConfig {
53
- isMultisigWalletClient: boolean;
54
- getMultisigTransactionDetails: (txHash: Hash, fromChainId: number, updateIntermediateStatus?: () => void) => Promise<MultisigTxDetails>;
55
- sendBatchTransaction?: (batchTransactions: BaseTransaction[]) => Promise<Hash>;
56
- shouldBatchTransactions?: boolean;
57
- }
58
- export type ConfigUpdate = {
59
- apiUrl?: string;
60
- rpcs?: Record<number, string[]>;
61
- multicallAddresses?: Record<number, string | undefined>;
62
- defaultExecutionSettings?: ExecutionSettings;
63
- defaultRouteOptions?: RouteOptions;
64
- disableVersionCheck?: boolean;
65
- userId?: string;
66
- integrator: string;
67
- widgetVersion?: string;
68
- multisigConfig?: MultisigConfig;
69
- };
70
33
  export type SwitchChainHook = (requiredChainId: number) => Promise<WalletClient | undefined>;
71
34
  export interface AcceptSlippageUpdateHookParams {
72
35
  toToken: Token;
@@ -82,11 +45,6 @@ export interface ExchangeRateUpdateParams {
82
45
  newToAmount: string;
83
46
  }
84
47
  export type AcceptExchangeRateUpdateHook = (params: ExchangeRateUpdateParams) => Promise<boolean | undefined>;
85
- export interface RouteExecutionData {
86
- route: Route;
87
- executors: StepExecutor[];
88
- settings: InternalExecutionSettings;
89
- }
90
48
  export type ExecutionSettings = Partial<InternalExecutionSettings>;
91
49
  export interface InternalExecutionSettings {
92
50
  acceptExchangeRateUpdateHook: AcceptExchangeRateUpdateHook;
@@ -96,50 +54,29 @@ export interface InternalExecutionSettings {
96
54
  executeInBackground: boolean;
97
55
  infiniteApproval: boolean;
98
56
  }
99
- export type RouteExecutionDictionary = Partial<Record<string, RouteExecutionData>>;
100
- export type RouteExecutionPromiseDictionary = Partial<Record<string, Promise<Route>>>;
57
+ export interface ExecutionParams {
58
+ walletClient: WalletClient;
59
+ step: LiFiStep;
60
+ statusManager: StatusManager;
61
+ settings: InternalExecutionSettings;
62
+ }
101
63
  export interface InteractionSettings {
102
64
  allowInteraction?: boolean;
103
65
  allowUpdates?: boolean;
104
- stopExecution?: boolean;
66
+ allowExecution?: boolean;
105
67
  }
106
- export interface TenderlyResponse {
107
- hash: string;
108
- block_hash: string;
109
- block_number: number;
110
- from: string;
111
- gas: number;
112
- gas_price: number;
113
- gas_fee_cap: number;
114
- gas_tip_cap: number;
115
- cumulative_gas_used: number;
116
- gas_used: number;
117
- effective_gas_price: number;
118
- input: string;
119
- nonce: number;
68
+ export interface MultisigTxDetails {
69
+ status: 'DONE' | 'FAILED' | 'PENDING' | 'CANCELLED';
70
+ txHash?: Hash;
71
+ }
72
+ export interface BaseTransaction {
120
73
  to: string;
121
- index: number;
122
- value: string;
123
- access_list: any;
124
- status: boolean;
125
- addresses: string[];
126
- contract_ids: string[];
127
- network_id: string;
128
- timestamp: string;
129
- function_selector: string;
130
- l1_block_number: number;
131
- l1_timestamp: number;
132
- deposit_tx: boolean;
133
- system_tx: boolean;
134
- mint: number;
135
- sig: Signature;
136
- error_message: string;
137
- method: string;
138
- decoded_input: any;
139
- call_trace: any;
74
+ value?: bigint;
75
+ data: string;
140
76
  }
141
- export interface Signature {
142
- v: string;
143
- r: string;
144
- s: string;
77
+ export interface MultisigConfig {
78
+ isMultisigWalletClient: boolean;
79
+ getMultisigTransactionDetails: (txHash: Hash, fromChainId: number, updateIntermediateStatus?: () => void) => Promise<MultisigTxDetails>;
80
+ sendBatchTransaction?: (batchTransactions: BaseTransaction[]) => Promise<Hash>;
81
+ shouldBatchTransactions?: boolean;
145
82
  }
@@ -1,4 +1,4 @@
1
- import type { LifiStep, ProcessType, Status, StatusMessage, Substatus } from '@lifi/types';
1
+ import type { LiFiStep, ProcessType, Status, StatusMessage, Substatus } from '@lifi/types';
2
2
  export declare function getProcessMessage(type: ProcessType, status: Status): string | undefined;
3
3
  export declare function getSubstatusMessage(status: StatusMessage, substatus?: Substatus): string | undefined;
4
4
  /**
@@ -9,4 +9,4 @@ export declare function getSubstatusMessage(status: StatusMessage, substatus?: S
9
9
  * @param newStep
10
10
  * @returns Boolean
11
11
  */
12
- export declare function checkStepSlippageThreshold(oldStep: LifiStep, newStep: LifiStep): boolean;
12
+ export declare function checkStepSlippageThreshold(oldStep: LiFiStep, newStep: LiFiStep): boolean;
@@ -1,3 +1,3 @@
1
- import type { LifiStep, ProcessType, StatusResponse } from '@lifi/types';
2
- import type { StatusManager } from '..';
3
- export declare function waitForReceivingTransaction(txHash: string, statusManager: StatusManager, processType: ProcessType, step: LifiStep): Promise<StatusResponse>;
1
+ import type { LiFiStep, ProcessType, StatusResponse } from '@lifi/types';
2
+ import type { StatusManager } from './StatusManager';
3
+ export declare function waitForReceivingTransaction(txHash: string, statusManager: StatusManager, processType: ProcessType, step: LiFiStep): Promise<StatusResponse>;
@@ -1,4 +1,4 @@
1
- import type { LifiStep, Route } from '@lifi/types';
1
+ import type { LiFiStep, Route } from '@lifi/types';
2
2
  import type { TenderlyResponse } from './types';
3
3
  /**
4
4
  * Returns a random number between min (inclusive) and max (inclusive)
@@ -14,5 +14,5 @@ export declare const checkPackageUpdates: (packageName?: string, packageVersion?
14
14
  * @returns - The route to be executed.
15
15
  * @throws {ValidationError} Throws a ValidationError if the step has missing values.
16
16
  */
17
- export declare const convertQuoteToRoute: (step: LifiStep) => Route;
17
+ export declare const convertQuoteToRoute: (step: LiFiStep) => Route;
18
18
  export declare const fetchTxErrorDetails: (txHash: string, chainId: number) => Promise<TenderlyResponse>;
@@ -1,5 +1,9 @@
1
+ export * from '@lifi/types';
2
+ export { LiFi } from './LiFi';
1
3
  export * from './execution';
2
4
  export * from './helpers';
3
- export { LiFi } from './LiFi';
5
+ export { EVM, type EVMProviderOptions } from './providers/EVM';
6
+ export { Solana, type SolanaProviderOptions } from './providers/Solana';
4
7
  export * from './types';
5
8
  export * from './utils/errors';
9
+ export { ErrorCode, LiFiError } from './utils/errors';
package/dist/cjs/index.js CHANGED
@@ -14,11 +14,17 @@ 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.LiFi = void 0;
18
- // expose types and helpers
19
- __exportStar(require("./execution"), exports);
20
- __exportStar(require("./helpers"), exports);
17
+ exports.LiFiError = exports.Solana = exports.EVM = exports.LiFi = void 0;
18
+ __exportStar(require("@lifi/types"), exports);
21
19
  var LiFi_1 = require("./LiFi");
22
20
  Object.defineProperty(exports, "LiFi", { enumerable: true, get: function () { return LiFi_1.LiFi; } });
21
+ __exportStar(require("./execution"), exports);
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; } });
23
27
  __exportStar(require("./types"), exports);
24
28
  __exportStar(require("./utils/errors"), exports);
29
+ var errors_1 = require("./utils/errors");
30
+ Object.defineProperty(exports, "LiFiError", { enumerable: true, get: function () { return errors_1.LiFiError; } });
@@ -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
+ }
@@ -0,0 +1,8 @@
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,32 +11,38 @@ exports.requestSettings = {
14
11
  const request = async (url, options = {
15
12
  retries: exports.requestSettings.retries,
16
13
  }) => {
17
- const { userId, integrator, widgetVersion } = 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) {
18
+ if (apiKey) {
19
+ options.headers = {
20
+ ...options?.headers,
21
+ 'x-lifi-api-key': apiKey,
22
+ };
23
+ }
21
24
  if (userId) {
22
25
  options.headers = {
23
26
  ...options?.headers,
24
- 'X-LIFI-UserId': userId,
27
+ 'x-lifi-userid': userId,
25
28
  };
26
29
  }
27
30
  if (widgetVersion) {
28
31
  options.headers = {
29
32
  ...options?.headers,
30
- 'X-LIFI-Widget': widgetVersion,
33
+ 'x-lifi-widget': widgetVersion,
31
34
  };
32
35
  }
33
36
  if (version_1.version) {
34
37
  options.headers = {
35
38
  ...options?.headers,
36
- 'X-LIFI-SDK': version_1.version,
39
+ 'x-lifi-sdk': version_1.version,
37
40
  };
38
41
  }
39
42
  // integrator is mandatory during SDK initialization
40
43
  options.headers = {
41
44
  ...options?.headers,
42
- 'X-LIFI-Integrator': integrator,
45
+ 'x-lifi-integrator': integrator,
43
46
  };
44
47
  }
45
48
  const response = await fetch(url, options);
@@ -1,14 +1,13 @@
1
- import type { ConnectionsRequest, ConnectionsResponse, ContractCallQuoteRequest, GasRecommendationRequest, GasRecommendationResponse, GetStatusRequest, LifiStep, QuoteRequest, RequestOptions, TokensRequest, TokensResponse } from '@lifi/types';
2
- import type { ChainId, ChainKey, ExtendedChain, PossibilitiesRequest, PossibilitiesResponse, RoutesRequest, RoutesResponse, StatusResponse, Token, ToolsRequest, ToolsResponse } from '../types';
1
+ import type { ChainId, ChainKey, ConnectionsRequest, ConnectionsResponse, ContractCallQuoteRequest, ExtendedChain, GasRecommendationRequest, GasRecommendationResponse, GetStatusRequest, LiFiStep, PossibilitiesRequest, PossibilitiesResponse, QuoteRequest, RequestOptions, RoutesRequest, RoutesResponse, StatusResponse, Token, TokensRequest, TokensResponse, ToolsRequest, ToolsResponse } from '@lifi/types';
3
2
  declare const _default: {
4
3
  getChains: (options?: RequestOptions | undefined) => Promise<ExtendedChain[]>;
5
- getContractCallQuote: (requestConfig: ContractCallQuoteRequest, options?: RequestOptions | undefined) => Promise<LifiStep>;
4
+ getContractCallQuote: (requestConfig: ContractCallQuoteRequest, options?: RequestOptions | undefined) => Promise<LiFiStep>;
6
5
  getGasRecommendation: ({ chainId, fromChain, fromToken }: GasRecommendationRequest, options?: RequestOptions | undefined) => Promise<GasRecommendationResponse>;
7
6
  getPossibilities: (requestConfig?: PossibilitiesRequest | undefined, options?: RequestOptions | undefined) => Promise<PossibilitiesResponse>;
8
- getQuote: (requestConfig: QuoteRequest, options?: RequestOptions | undefined) => Promise<LifiStep>;
7
+ getQuote: (requestConfig: QuoteRequest, options?: RequestOptions | undefined) => Promise<LiFiStep>;
9
8
  getRoutes: (requestConfig: RoutesRequest, options?: RequestOptions | undefined) => Promise<RoutesResponse>;
10
9
  getStatus: (requestConfig: GetStatusRequest, options?: RequestOptions | undefined) => Promise<StatusResponse>;
11
- getStepTransaction: (step: LifiStep, options?: RequestOptions | undefined) => Promise<LifiStep>;
10
+ getStepTransaction: (step: LiFiStep, options?: RequestOptions | undefined) => Promise<LiFiStep>;
12
11
  getToken: (chain: ChainId | ChainKey, token: string, options?: RequestOptions | undefined) => Promise<Token>;
13
12
  getTokens: (requestConfig?: TokensRequest | undefined, options?: RequestOptions | undefined) => Promise<TokensResponse>;
14
13
  getTools: (requestConfig?: ToolsRequest | undefined, options?: RequestOptions | undefined) => Promise<ToolsResponse>;