@lifi/sdk 2.0.0-beta.11 → 2.0.0-beta.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/LiFi.d.ts CHANGED
@@ -6,7 +6,7 @@ import { RouteExecutionManager } from './execution/RouteExecutionManager';
6
6
  import { Config, ConfigUpdate, RevokeTokenData } from './types';
7
7
  export declare class LiFi extends RouteExecutionManager {
8
8
  private chainsService;
9
- constructor(configUpdate?: ConfigUpdate);
9
+ constructor(configUpdate: ConfigUpdate);
10
10
  /**
11
11
  * Get the current configuration of the SDK
12
12
  * @return {Config} - The config object
@@ -18,7 +18,7 @@ export declare class LiFi extends RouteExecutionManager {
18
18
  */
19
19
  getConfigAsync: () => Promise<Config>;
20
20
  /**
21
- * Get an instance of a provider for a specific cahin
21
+ * Get an instance of a provider for a specific chain
22
22
  * @param {number} chainId - Id of the chain the provider is for
23
23
  * @param {boolean} archive - Whether to use an archive provider that is based on a default rpc or not. defaults to false
24
24
  * @return {FallbackProvider} The provider for the given chain
@@ -29,7 +29,7 @@ export declare class LiFi extends RouteExecutionManager {
29
29
  * @param {ConfigUpdate} configUpdate - An object containing the configuration fields that should be updated.
30
30
  * @return {Config} The renewed config object
31
31
  */
32
- setConfig: (configUpdate: ConfigUpdate) => Config;
32
+ setConfig: (configUpdate: Partial<ConfigUpdate>) => Config;
33
33
  /**
34
34
  * Get a set of current possibilities based on a request that specifies which chains, exchanges and bridges are preferred or unwanted.
35
35
  * @param {PossibilitiesRequest} request - Object defining preferences regarding chain, exchanges and bridges
@@ -154,10 +154,10 @@ export declare class LiFi extends RouteExecutionManager {
154
154
  * @param { RevokeApprovalRequest } request - The revoke request
155
155
  */
156
156
  revokeTokenApproval: (request: RevokeApprovalRequest) => Promise<void>;
157
+ /**
158
+ * Get all the available connections for swap/bridging tokens
159
+ * @param connectionRequest ConnectionsRequest
160
+ * @returns ConnectionsResponse
161
+ */
162
+ getConnections: (connectionRequest: ConnectionsRequest) => Promise<ConnectionsResponse>;
157
163
  }
158
- /**
159
- * Get all the available connections for swap/bridging tokens
160
- * @param connectionRequest ConnectionsRequest
161
- * @returns ConnectionsResponse
162
- */
163
- export declare const getConnections: (connectionRequest: ConnectionsRequest) => Promise<ConnectionsResponse>;
package/dist/LiFi.js CHANGED
@@ -26,7 +26,7 @@ export class LiFi extends RouteExecutionManager {
26
26
  return this.configService.getConfigAsync();
27
27
  };
28
28
  /**
29
- * Get an instance of a provider for a specific cahin
29
+ * Get an instance of a provider for a specific chain
30
30
  * @param {number} chainId - Id of the chain the provider is for
31
31
  * @param {boolean} archive - Whether to use an archive provider that is based on a default rpc or not. defaults to false
32
32
  * @return {FallbackProvider} The provider for the given chain
@@ -216,19 +216,19 @@ export class LiFi extends RouteExecutionManager {
216
216
  this.revokeTokenApproval = (request) => {
217
217
  return revokeTokenApproval(request);
218
218
  };
219
+ /**
220
+ * Get all the available connections for swap/bridging tokens
221
+ * @param connectionRequest ConnectionsRequest
222
+ * @returns ConnectionsResponse
223
+ */
224
+ this.getConnections = async (connectionRequest) => {
225
+ const connections = await ApiService.getAvailableConnections(connectionRequest);
226
+ return connections;
227
+ };
219
228
  this.chainsService = ChainsService.getInstance();
220
229
  this.chainsService.getChains().then((chains) => {
221
230
  this.configService.updateChains(chains);
222
231
  });
223
- checkPackageUpdates(name, version, configUpdate?.disableVersionCheck);
232
+ checkPackageUpdates(name, version, configUpdate.disableVersionCheck);
224
233
  }
225
234
  }
226
- /**
227
- * Get all the available connections for swap/bridging tokens
228
- * @param connectionRequest ConnectionsRequest
229
- * @returns ConnectionsResponse
230
- */
231
- export const getConnections = async (connectionRequest) => {
232
- const connections = await ApiService.getAvailableConnections(connectionRequest);
233
- return connections;
234
- };
@@ -20,10 +20,12 @@ export const checkAllowance = async (signer, step, statusManager, settings, chai
20
20
  from: step.action.fromToken.address,
21
21
  to: step.estimate.approvalAddress,
22
22
  };
23
- if (settings.updateTransactionRequest) {
24
- const config = await settings.updateTransactionRequest(approvalRequest);
23
+ if (settings.updateTransactionRequestHook) {
24
+ const config = await settings.updateTransactionRequestHook(approvalRequest);
25
25
  approvalRequest.gasLimit = config.gasLimit;
26
26
  approvalRequest.gasPrice = config.gasPrice;
27
+ approvalRequest.maxFeePerGas = config.maxFeePerGas;
28
+ approvalRequest.maxPriorityFeePerGas = config.maxPriorityFeePerGas;
27
29
  }
28
30
  if (!approvalRequest.from) {
29
31
  throw new Error('Missing Signer address');
@@ -6,7 +6,7 @@ import { RouteExecutionManager } from './execution/RouteExecutionManager';
6
6
  import { Config, ConfigUpdate, RevokeTokenData } from './types';
7
7
  export declare class LiFi extends RouteExecutionManager {
8
8
  private chainsService;
9
- constructor(configUpdate?: ConfigUpdate);
9
+ constructor(configUpdate: ConfigUpdate);
10
10
  /**
11
11
  * Get the current configuration of the SDK
12
12
  * @return {Config} - The config object
@@ -18,7 +18,7 @@ export declare class LiFi extends RouteExecutionManager {
18
18
  */
19
19
  getConfigAsync: () => Promise<Config>;
20
20
  /**
21
- * Get an instance of a provider for a specific cahin
21
+ * Get an instance of a provider for a specific chain
22
22
  * @param {number} chainId - Id of the chain the provider is for
23
23
  * @param {boolean} archive - Whether to use an archive provider that is based on a default rpc or not. defaults to false
24
24
  * @return {FallbackProvider} The provider for the given chain
@@ -29,7 +29,7 @@ export declare class LiFi extends RouteExecutionManager {
29
29
  * @param {ConfigUpdate} configUpdate - An object containing the configuration fields that should be updated.
30
30
  * @return {Config} The renewed config object
31
31
  */
32
- setConfig: (configUpdate: ConfigUpdate) => Config;
32
+ setConfig: (configUpdate: Partial<ConfigUpdate>) => Config;
33
33
  /**
34
34
  * Get a set of current possibilities based on a request that specifies which chains, exchanges and bridges are preferred or unwanted.
35
35
  * @param {PossibilitiesRequest} request - Object defining preferences regarding chain, exchanges and bridges
@@ -154,10 +154,10 @@ export declare class LiFi extends RouteExecutionManager {
154
154
  * @param { RevokeApprovalRequest } request - The revoke request
155
155
  */
156
156
  revokeTokenApproval: (request: RevokeApprovalRequest) => Promise<void>;
157
+ /**
158
+ * Get all the available connections for swap/bridging tokens
159
+ * @param connectionRequest ConnectionsRequest
160
+ * @returns ConnectionsResponse
161
+ */
162
+ getConnections: (connectionRequest: ConnectionsRequest) => Promise<ConnectionsResponse>;
157
163
  }
158
- /**
159
- * Get all the available connections for swap/bridging tokens
160
- * @param connectionRequest ConnectionsRequest
161
- * @returns ConnectionsResponse
162
- */
163
- export declare const getConnections: (connectionRequest: ConnectionsRequest) => Promise<ConnectionsResponse>;
package/dist/cjs/LiFi.js CHANGED
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.getConnections = exports.LiFi = void 0;
29
+ exports.LiFi = void 0;
30
30
  const allowance_1 = require("./allowance");
31
31
  const balance = __importStar(require("./balance"));
32
32
  const connectors_1 = require("./connectors");
@@ -55,7 +55,7 @@ class LiFi extends RouteExecutionManager_1.RouteExecutionManager {
55
55
  return this.configService.getConfigAsync();
56
56
  };
57
57
  /**
58
- * Get an instance of a provider for a specific cahin
58
+ * Get an instance of a provider for a specific chain
59
59
  * @param {number} chainId - Id of the chain the provider is for
60
60
  * @param {boolean} archive - Whether to use an archive provider that is based on a default rpc or not. defaults to false
61
61
  * @return {FallbackProvider} The provider for the given chain
@@ -245,21 +245,20 @@ class LiFi extends RouteExecutionManager_1.RouteExecutionManager {
245
245
  this.revokeTokenApproval = (request) => {
246
246
  return (0, allowance_1.revokeTokenApproval)(request);
247
247
  };
248
+ /**
249
+ * Get all the available connections for swap/bridging tokens
250
+ * @param connectionRequest ConnectionsRequest
251
+ * @returns ConnectionsResponse
252
+ */
253
+ this.getConnections = async (connectionRequest) => {
254
+ const connections = await ApiService_1.default.getAvailableConnections(connectionRequest);
255
+ return connections;
256
+ };
248
257
  this.chainsService = ChainsService_1.default.getInstance();
249
258
  this.chainsService.getChains().then((chains) => {
250
259
  this.configService.updateChains(chains);
251
260
  });
252
- (0, helpers_1.checkPackageUpdates)(version_1.name, version_1.version, configUpdate?.disableVersionCheck);
261
+ (0, helpers_1.checkPackageUpdates)(version_1.name, version_1.version, configUpdate.disableVersionCheck);
253
262
  }
254
263
  }
255
264
  exports.LiFi = LiFi;
256
- /**
257
- * Get all the available connections for swap/bridging tokens
258
- * @param connectionRequest ConnectionsRequest
259
- * @returns ConnectionsResponse
260
- */
261
- const getConnections = async (connectionRequest) => {
262
- const connections = await ApiService_1.default.getAvailableConnections(connectionRequest);
263
- return connections;
264
- };
265
- exports.getConnections = getConnections;
@@ -26,10 +26,12 @@ const checkAllowance = async (signer, step, statusManager, settings, chain, allo
26
26
  from: step.action.fromToken.address,
27
27
  to: step.estimate.approvalAddress,
28
28
  };
29
- if (settings.updateTransactionRequest) {
30
- const config = await settings.updateTransactionRequest(approvalRequest);
29
+ if (settings.updateTransactionRequestHook) {
30
+ const config = await settings.updateTransactionRequestHook(approvalRequest);
31
31
  approvalRequest.gasLimit = config.gasLimit;
32
32
  approvalRequest.gasPrice = config.gasPrice;
33
+ approvalRequest.maxFeePerGas = config.maxFeePerGas;
34
+ approvalRequest.maxPriorityFeePerGas = config.maxPriorityFeePerGas;
33
35
  }
34
36
  if (!approvalRequest.from) {
35
37
  throw new Error('Missing Signer address');
@@ -6,7 +6,7 @@ export declare class RouteExecutionManager {
6
6
  private executionDictionary;
7
7
  private executionPromiseDictionary;
8
8
  protected configService: ConfigService;
9
- constructor(configUpdate?: ConfigUpdate);
9
+ constructor(configUpdate: ConfigUpdate);
10
10
  /**
11
11
  * Execute a route.
12
12
  * @param {Signer} signer - The signer required to send the transactions.
@@ -136,7 +136,7 @@ class StatusManager {
136
136
  throw new Error("Couldn't find a step to update.");
137
137
  }
138
138
  this.route.steps[stepIndex] = Object.assign(this.route.steps[stepIndex], step);
139
- this.settings.updateCallback(this.route);
139
+ this.settings.updateRouteHook(this.route);
140
140
  this.internalUpdateRouteCallback(this.route);
141
141
  return this.route.steps[stepIndex];
142
142
  };
@@ -81,8 +81,8 @@ class StepExecutionManager {
81
81
  if (!this.allowUserInteraction) {
82
82
  return step.execution;
83
83
  }
84
- if (settings.updateTransactionRequest) {
85
- const customConfig = await settings.updateTransactionRequest(transactionRequest);
84
+ if (settings.updateTransactionRequestHook) {
85
+ const customConfig = await settings.updateTransactionRequestHook(transactionRequest);
86
86
  transactionRequest.gasLimit = customConfig.gasLimit;
87
87
  transactionRequest.gasPrice = customConfig.gasPrice;
88
88
  transactionRequest.maxPriorityFeePerGas =
@@ -18,6 +18,6 @@ export default class ConfigService {
18
18
  * Use this if you need access to chain data (RPCs or multicalls)
19
19
  */
20
20
  getConfigAsync: () => Promise<Config>;
21
- updateConfig: (configUpdate: ConfigUpdate) => Config;
21
+ updateConfig: (configUpdate: Partial<ConfigUpdate>) => Config;
22
22
  updateChains: (chains: Chain[]) => Config;
23
23
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const types_1 = require("../types");
4
4
  const DefaultExecutionSettings = {
5
5
  /* eslint-disable-next-line @typescript-eslint/no-empty-function */
6
- updateCallback: () => { },
6
+ updateRouteHook: () => { },
7
7
  switchChainHook: () => Promise.resolve(undefined),
8
8
  acceptExchangeRateUpdateHook: () => Promise.resolve(undefined),
9
9
  infiniteApproval: false,
@@ -1,4 +1,4 @@
1
- import { LifiStep, RoutesRequest, Token } from './types';
1
+ import { LifiStep, RoutesRequest, StaticToken } from './types';
2
2
  export declare const isRoutesRequest: (routesRequest: RoutesRequest) => routesRequest is RoutesRequest;
3
3
  export declare const isStep: (step: LifiStep) => step is LifiStep;
4
- export declare const isToken: (token: Token) => token is Token;
4
+ export declare const isToken: (token: StaticToken) => token is StaticToken;
@@ -23,8 +23,8 @@ export interface ExecutionParams {
23
23
  statusManager: StatusManager;
24
24
  settings: InternalExecutionSettings;
25
25
  }
26
- export type CallbackFunction = (updatedRoute: Route) => void;
27
- export type TxRequestCallbackFunction = (updatedTxRequest: TransactionRequest) => Promise<TransactionRequest>;
26
+ export type UpdateRouteHook = (updatedRoute: Route) => void;
27
+ export type TransactionRequestUpdateHook = (updatedTxRequest: TransactionRequest) => Promise<TransactionRequest>;
28
28
  export type Config = {
29
29
  apiUrl: string;
30
30
  rpcs: Record<ChainId, string[]>;
@@ -69,16 +69,13 @@ export interface RouteExecutionData {
69
69
  }
70
70
  export type ExecutionSettings = Partial<InternalExecutionSettings>;
71
71
  export interface InternalExecutionSettings {
72
- updateCallback: CallbackFunction;
73
- switchChainHook: SwitchChainHook;
74
72
  acceptExchangeRateUpdateHook: AcceptExchangeRateUpdateHook;
75
- infiniteApproval: boolean;
73
+ switchChainHook: SwitchChainHook;
74
+ updateRouteHook: UpdateRouteHook;
75
+ updateTransactionRequestHook?: TransactionRequestUpdateHook;
76
76
  executeInBackground: boolean;
77
- updateTransactionRequest?: TxRequestCallbackFunction;
77
+ infiniteApproval: boolean;
78
78
  }
79
- export type EnforcedObjectProperties<T> = T & {
80
- [P in keyof T]-?: T[P];
81
- };
82
79
  export type RouteExecutionDictionary = Partial<Record<string, RouteExecutionData>>;
83
80
  export type RouteExecutionPromiseDictionary = Partial<Record<string, Promise<Route>>>;
84
81
  export type RevokeTokenData = {
@@ -23,11 +23,13 @@ export declare enum LifiErrorCode {
23
23
  SlippageError = 1011,
24
24
  TransactionRejected = 1012,
25
25
  BalanceError = 1013,
26
- AllowanceRequired = 1014
26
+ AllowanceRequired = 1014,
27
+ InsufficientFunds = 1015
27
28
  }
28
29
  export declare enum EthersErrorType {
30
+ ActionRejected = "ACTION_REJECTED",
29
31
  CallExecption = "CALL_EXCEPTION",
30
- ActionRejected = "ACTION_REJECTED"
32
+ InsufficientFunds = "INSUFFICIENT_FUNDS"
31
33
  }
32
34
  export declare enum EthersErrorMessage {
33
35
  ERC20Allowance = "ERC20: transfer amount exceeds allowance",
@@ -29,11 +29,13 @@ var LifiErrorCode;
29
29
  LifiErrorCode[LifiErrorCode["TransactionRejected"] = 1012] = "TransactionRejected";
30
30
  LifiErrorCode[LifiErrorCode["BalanceError"] = 1013] = "BalanceError";
31
31
  LifiErrorCode[LifiErrorCode["AllowanceRequired"] = 1014] = "AllowanceRequired";
32
+ LifiErrorCode[LifiErrorCode["InsufficientFunds"] = 1015] = "InsufficientFunds";
32
33
  })(LifiErrorCode = exports.LifiErrorCode || (exports.LifiErrorCode = {}));
33
34
  var EthersErrorType;
34
35
  (function (EthersErrorType) {
35
- EthersErrorType["CallExecption"] = "CALL_EXCEPTION";
36
36
  EthersErrorType["ActionRejected"] = "ACTION_REJECTED";
37
+ EthersErrorType["CallExecption"] = "CALL_EXCEPTION";
38
+ EthersErrorType["InsufficientFunds"] = "INSUFFICIENT_FUNDS";
37
39
  })(EthersErrorType = exports.EthersErrorType || (exports.EthersErrorType = {}));
38
40
  var EthersErrorMessage;
39
41
  (function (EthersErrorMessage) {
@@ -5,10 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.parseBackendError = exports.parseError = exports.getTransactionFailedMessage = exports.getTransactionNotSentMessage = void 0;
7
7
  const eth_rpc_errors_1 = require("eth-rpc-errors");
8
+ const helpers_1 = require("../helpers");
8
9
  const ChainsService_1 = __importDefault(require("../services/ChainsService"));
9
10
  const errors_1 = require("./errors");
10
11
  const utils_1 = require("./utils");
11
- const helpers_1 = require("../helpers");
12
12
  /**
13
13
  * Available MetaMask error codes:
14
14
  *
@@ -115,6 +115,8 @@ const parseError = async (e, step, process) => {
115
115
  catch (error) {
116
116
  return new errors_1.ProviderError(errors_1.LifiErrorCode.TransactionFailed, e.reason, defaultErrorMessage, e.stack);
117
117
  }
118
+ case errors_1.EthersErrorType.InsufficientFunds:
119
+ return new errors_1.TransactionError(errors_1.LifiErrorCode.InsufficientFunds, e.message, await (0, exports.getTransactionNotSentMessage)(step, process), e.stack);
118
120
  case errors_1.EthersErrorType.ActionRejected:
119
121
  case errors_1.MetaMaskProviderErrorCode.userRejectedRequest:
120
122
  return new errors_1.TransactionError(errors_1.LifiErrorCode.TransactionRejected, e.message, await (0, exports.getTransactionNotSentMessage)(step, process), e.stack);
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/sdk";
2
- export declare const version = "2.0.0-beta.11";
2
+ export declare const version = "2.0.0-beta.13";
@@ -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 = '2.0.0-beta.11';
5
+ exports.version = '2.0.0-beta.13';
@@ -6,7 +6,7 @@ export declare class RouteExecutionManager {
6
6
  private executionDictionary;
7
7
  private executionPromiseDictionary;
8
8
  protected configService: ConfigService;
9
- constructor(configUpdate?: ConfigUpdate);
9
+ constructor(configUpdate: ConfigUpdate);
10
10
  /**
11
11
  * Execute a route.
12
12
  * @param {Signer} signer - The signer required to send the transactions.
@@ -133,7 +133,7 @@ export class StatusManager {
133
133
  throw new Error("Couldn't find a step to update.");
134
134
  }
135
135
  this.route.steps[stepIndex] = Object.assign(this.route.steps[stepIndex], step);
136
- this.settings.updateCallback(this.route);
136
+ this.settings.updateRouteHook(this.route);
137
137
  this.internalUpdateRouteCallback(this.route);
138
138
  return this.route.steps[stepIndex];
139
139
  };
@@ -75,8 +75,8 @@ export class StepExecutionManager {
75
75
  if (!this.allowUserInteraction) {
76
76
  return step.execution;
77
77
  }
78
- if (settings.updateTransactionRequest) {
79
- const customConfig = await settings.updateTransactionRequest(transactionRequest);
78
+ if (settings.updateTransactionRequestHook) {
79
+ const customConfig = await settings.updateTransactionRequestHook(transactionRequest);
80
80
  transactionRequest.gasLimit = customConfig.gasLimit;
81
81
  transactionRequest.gasPrice = customConfig.gasPrice;
82
82
  transactionRequest.maxPriorityFeePerGas =
@@ -18,6 +18,6 @@ export default class ConfigService {
18
18
  * Use this if you need access to chain data (RPCs or multicalls)
19
19
  */
20
20
  getConfigAsync: () => Promise<Config>;
21
- updateConfig: (configUpdate: ConfigUpdate) => Config;
21
+ updateConfig: (configUpdate: Partial<ConfigUpdate>) => Config;
22
22
  updateChains: (chains: Chain[]) => Config;
23
23
  }
@@ -1,7 +1,7 @@
1
1
  import { ChainId, } from '../types';
2
2
  const DefaultExecutionSettings = {
3
3
  /* eslint-disable-next-line @typescript-eslint/no-empty-function */
4
- updateCallback: () => { },
4
+ updateRouteHook: () => { },
5
5
  switchChainHook: () => Promise.resolve(undefined),
6
6
  acceptExchangeRateUpdateHook: () => Promise.resolve(undefined),
7
7
  infiniteApproval: false,
@@ -1,4 +1,4 @@
1
- import { LifiStep, RoutesRequest, Token } from './types';
1
+ import { LifiStep, RoutesRequest, StaticToken } from './types';
2
2
  export declare const isRoutesRequest: (routesRequest: RoutesRequest) => routesRequest is RoutesRequest;
3
3
  export declare const isStep: (step: LifiStep) => step is LifiStep;
4
- export declare const isToken: (token: Token) => token is Token;
4
+ export declare const isToken: (token: StaticToken) => token is StaticToken;
@@ -23,8 +23,8 @@ export interface ExecutionParams {
23
23
  statusManager: StatusManager;
24
24
  settings: InternalExecutionSettings;
25
25
  }
26
- export type CallbackFunction = (updatedRoute: Route) => void;
27
- export type TxRequestCallbackFunction = (updatedTxRequest: TransactionRequest) => Promise<TransactionRequest>;
26
+ export type UpdateRouteHook = (updatedRoute: Route) => void;
27
+ export type TransactionRequestUpdateHook = (updatedTxRequest: TransactionRequest) => Promise<TransactionRequest>;
28
28
  export type Config = {
29
29
  apiUrl: string;
30
30
  rpcs: Record<ChainId, string[]>;
@@ -69,16 +69,13 @@ export interface RouteExecutionData {
69
69
  }
70
70
  export type ExecutionSettings = Partial<InternalExecutionSettings>;
71
71
  export interface InternalExecutionSettings {
72
- updateCallback: CallbackFunction;
73
- switchChainHook: SwitchChainHook;
74
72
  acceptExchangeRateUpdateHook: AcceptExchangeRateUpdateHook;
75
- infiniteApproval: boolean;
73
+ switchChainHook: SwitchChainHook;
74
+ updateRouteHook: UpdateRouteHook;
75
+ updateTransactionRequestHook?: TransactionRequestUpdateHook;
76
76
  executeInBackground: boolean;
77
- updateTransactionRequest?: TxRequestCallbackFunction;
77
+ infiniteApproval: boolean;
78
78
  }
79
- export type EnforcedObjectProperties<T> = T & {
80
- [P in keyof T]-?: T[P];
81
- };
82
79
  export type RouteExecutionDictionary = Partial<Record<string, RouteExecutionData>>;
83
80
  export type RouteExecutionPromiseDictionary = Partial<Record<string, Promise<Route>>>;
84
81
  export type RevokeTokenData = {
@@ -23,11 +23,13 @@ export declare enum LifiErrorCode {
23
23
  SlippageError = 1011,
24
24
  TransactionRejected = 1012,
25
25
  BalanceError = 1013,
26
- AllowanceRequired = 1014
26
+ AllowanceRequired = 1014,
27
+ InsufficientFunds = 1015
27
28
  }
28
29
  export declare enum EthersErrorType {
30
+ ActionRejected = "ACTION_REJECTED",
29
31
  CallExecption = "CALL_EXCEPTION",
30
- ActionRejected = "ACTION_REJECTED"
32
+ InsufficientFunds = "INSUFFICIENT_FUNDS"
31
33
  }
32
34
  export declare enum EthersErrorMessage {
33
35
  ERC20Allowance = "ERC20: transfer amount exceeds allowance",
@@ -26,11 +26,13 @@ export var LifiErrorCode;
26
26
  LifiErrorCode[LifiErrorCode["TransactionRejected"] = 1012] = "TransactionRejected";
27
27
  LifiErrorCode[LifiErrorCode["BalanceError"] = 1013] = "BalanceError";
28
28
  LifiErrorCode[LifiErrorCode["AllowanceRequired"] = 1014] = "AllowanceRequired";
29
+ LifiErrorCode[LifiErrorCode["InsufficientFunds"] = 1015] = "InsufficientFunds";
29
30
  })(LifiErrorCode || (LifiErrorCode = {}));
30
31
  export var EthersErrorType;
31
32
  (function (EthersErrorType) {
32
- EthersErrorType["CallExecption"] = "CALL_EXCEPTION";
33
33
  EthersErrorType["ActionRejected"] = "ACTION_REJECTED";
34
+ EthersErrorType["CallExecption"] = "CALL_EXCEPTION";
35
+ EthersErrorType["InsufficientFunds"] = "INSUFFICIENT_FUNDS";
34
36
  })(EthersErrorType || (EthersErrorType = {}));
35
37
  export var EthersErrorMessage;
36
38
  (function (EthersErrorMessage) {
@@ -1,8 +1,8 @@
1
1
  import { errorCodes as MetaMaskErrorCodes, getMessageFromCode, } from 'eth-rpc-errors';
2
+ import { fetchTxErrorDetails } from '../helpers';
2
3
  import ChainsService from '../services/ChainsService';
3
- import { ErrorMessage, EthersErrorType, EthersErrorMessage, LifiError, LifiErrorCode, MetaMaskProviderErrorCode, NotFoundError, ProviderError, RPCError, ServerError, SlippageError, TransactionError, UnknownError, ValidationError, } from './errors';
4
+ import { ErrorMessage, EthersErrorMessage, EthersErrorType, LifiError, LifiErrorCode, MetaMaskProviderErrorCode, NotFoundError, ProviderError, RPCError, ServerError, SlippageError, TransactionError, UnknownError, ValidationError, } from './errors';
4
5
  import { formatTokenAmountOnly } from './utils';
5
- import { fetchTxErrorDetails } from '../helpers';
6
6
  /**
7
7
  * Available MetaMask error codes:
8
8
  *
@@ -107,6 +107,8 @@ export const parseError = async (e, step, process) => {
107
107
  catch (error) {
108
108
  return new ProviderError(LifiErrorCode.TransactionFailed, e.reason, defaultErrorMessage, e.stack);
109
109
  }
110
+ case EthersErrorType.InsufficientFunds:
111
+ return new TransactionError(LifiErrorCode.InsufficientFunds, e.message, await getTransactionNotSentMessage(step, process), e.stack);
110
112
  case EthersErrorType.ActionRejected:
111
113
  case MetaMaskProviderErrorCode.userRejectedRequest:
112
114
  return new TransactionError(LifiErrorCode.TransactionRejected, e.message, await getTransactionNotSentMessage(step, process), e.stack);
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/sdk";
2
- export declare const version = "2.0.0-beta.11";
2
+ export declare const version = "2.0.0-beta.13";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/sdk';
2
- export const version = '2.0.0-beta.11';
2
+ export const version = '2.0.0-beta.13';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/sdk",
3
- "version": "2.0.0-beta.11",
3
+ "version": "2.0.0-beta.13",
4
4
  "description": "LI.FI Any-to-Any Cross-Chain-Swap SDK",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/index.js",
@@ -76,20 +76,20 @@
76
76
  "dependencies": {
77
77
  "@ethersproject/abi": "^5.7.0",
78
78
  "@ethersproject/contracts": "^5.7.0",
79
- "@lifi/types": "^5.0.0",
79
+ "@lifi/types": "^6.0.0",
80
80
  "bignumber.js": "^9.1.1",
81
81
  "eth-rpc-errors": "^4.0.3",
82
82
  "ethers": "^5.7.2"
83
83
  },
84
84
  "devDependencies": {
85
- "@commitlint/cli": "^17.6.1",
86
- "@commitlint/config-conventional": "^17.6.1",
87
- "@mswjs/interceptors": "^0.22.12",
88
- "@typescript-eslint/eslint-plugin": "^5.59.1",
89
- "@typescript-eslint/parser": "^5.59.1",
90
- "@vitest/coverage-c8": "^0.30.1",
85
+ "@commitlint/cli": "^17.6.3",
86
+ "@commitlint/config-conventional": "^17.6.3",
87
+ "@mswjs/interceptors": "^0.22.14",
88
+ "@typescript-eslint/eslint-plugin": "^5.59.5",
89
+ "@typescript-eslint/parser": "^5.59.5",
90
+ "@vitest/coverage-c8": "^0.31.0",
91
91
  "cross-fetch": "^3.1.5",
92
- "eslint": "^8.39.0",
92
+ "eslint": "^8.40.0",
93
93
  "eslint-config-prettier": "^8.8.0",
94
94
  "eslint-plugin-prettier": "^4.2.1",
95
95
  "husky": "^8.0.3",
@@ -100,10 +100,10 @@
100
100
  "prettier": "^2.8.8",
101
101
  "standard-version": "^9.5.0",
102
102
  "typescript": "^5.0.4",
103
- "vitest": "^0.30.1"
103
+ "vitest": "^0.31.0"
104
104
  },
105
105
  "directories": {
106
106
  "test": "test"
107
107
  },
108
- "packageManager": "yarn@3.5.0"
108
+ "packageManager": "yarn@3.5.1"
109
109
  }