@lifi/sdk 1.2.2 → 1.4.0
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/CHANGELOG.md +27 -0
- package/dist/cjs/execution/bridges/bridge.execute.js +5 -4
- package/dist/cjs/execution/exchanges/swap.execute.js +5 -3
- package/dist/cjs/services/ApiService.js +6 -6
- package/dist/cjs/services/ConfigService.js +6 -4
- package/dist/cjs/utils/errors.d.ts +5 -4
- package/dist/cjs/utils/errors.js +4 -3
- package/dist/cjs/utils/parseError.js +10 -7
- package/dist/cjs/utils/preRestart.js +4 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/execution/bridges/bridge.execute.js +5 -4
- package/dist/execution/exchanges/swap.execute.js +5 -3
- package/dist/services/ApiService.js +6 -6
- package/dist/services/ConfigService.js +6 -4
- package/dist/utils/errors.d.ts +5 -4
- package/dist/utils/errors.js +4 -3
- package/dist/utils/parseError.js +11 -8
- package/dist/utils/preRestart.js +4 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.4.0](https://github.com/lifinance/sdk/compare/v1.3.1...v1.4.0) (2022-09-05)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* skip step tx generation if tx data already provided ([#100](https://github.com/lifinance/sdk/issues/100)) ([280de4a](https://github.com/lifinance/sdk/commit/280de4a3d96b8077893e0bc1e0ed944f4772c5fb))
|
|
11
|
+
|
|
12
|
+
### [1.3.1](https://github.com/lifinance/sdk/compare/v1.3.0...v1.3.1) (2022-09-05)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* pass default options right for quote requests ([#109](https://github.com/lifinance/sdk/issues/109)) ([776c5a3](https://github.com/lifinance/sdk/commit/776c5a33f0ac7e6525659878cf7323244f055e77))
|
|
18
|
+
|
|
19
|
+
## [1.3.0](https://github.com/lifinance/sdk/compare/v1.2.2...v1.3.0) (2022-09-05)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* add TransactionRejected error ([#104](https://github.com/lifinance/sdk/issues/104)) ([2c180fd](https://github.com/lifinance/sdk/commit/2c180fd0cedbdf3acbf77326d69eb2a328c59170))
|
|
25
|
+
* **config:** set default integrator string ([#107](https://github.com/lifinance/sdk/issues/107)) ([f8ef3bf](https://github.com/lifinance/sdk/commit/f8ef3bfeff8bf0e6d5d9eec172bb7d7d86ec123f))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* duplicates for LifiErrorCodes ([#106](https://github.com/lifinance/sdk/issues/106)) ([d63a80b](https://github.com/lifinance/sdk/commit/d63a80b2106d7f18d51e9f30b49dc896f5a30019))
|
|
31
|
+
|
|
5
32
|
### [1.2.2](https://github.com/lifinance/sdk/compare/v1.2.1...v1.2.2) (2022-08-24)
|
|
6
33
|
|
|
7
34
|
### [1.2.1](https://github.com/lifinance/sdk/compare/v1.2.0...v1.2.1) (2022-08-22)
|
|
@@ -58,10 +58,11 @@ class BridgeExecutionManager {
|
|
|
58
58
|
else {
|
|
59
59
|
// check balance
|
|
60
60
|
yield (0, balanceCheck_execute_1.balanceCheck)(signer, step);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
if (!step.transactionRequest) {
|
|
62
|
+
const personalizedStep = yield (0, utils_1.personalizeStep)(signer, step);
|
|
63
|
+
const updatedStep = yield ApiService_1.default.getStepTransaction(personalizedStep);
|
|
64
|
+
step = Object.assign(Object.assign({}, (yield (0, stepComparison_1.stepComparison)(statusManager, personalizedStep, updatedStep, settings.acceptSlippageUpdateHook, this.shouldContinue))), { execution: step.execution });
|
|
65
|
+
}
|
|
65
66
|
const { transactionRequest } = step;
|
|
66
67
|
if (!transactionRequest) {
|
|
67
68
|
throw new errors_1.TransactionError(errors_1.LifiErrorCode.TransactionUnprepared, 'Unable to prepare transaction.');
|
|
@@ -56,9 +56,11 @@ class SwapExecutionManager {
|
|
|
56
56
|
// -> check balance
|
|
57
57
|
yield (0, balanceCheck_execute_1.balanceCheck)(signer, step);
|
|
58
58
|
// -> get tx from backend
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
if (!step.transactionRequest) {
|
|
60
|
+
const personalizedStep = yield (0, utils_1.personalizeStep)(signer, step);
|
|
61
|
+
const updatedStep = yield ApiService_1.default.getStepTransaction(personalizedStep);
|
|
62
|
+
step = Object.assign(Object.assign({}, (yield (0, stepComparison_1.stepComparison)(statusManager, personalizedStep, updatedStep, settings.acceptSlippageUpdateHook, this.shouldContinue))), { execution: step.execution });
|
|
63
|
+
}
|
|
62
64
|
const { transactionRequest } = step;
|
|
63
65
|
if (!transactionRequest) {
|
|
64
66
|
throw new errors_1.TransactionError(errors_1.LifiErrorCode.TransactionUnprepared, 'Unable to prepare transaction.');
|
|
@@ -92,11 +92,11 @@ const getQuote = (request, options) => __awaiter(void 0, void 0, void 0, functio
|
|
|
92
92
|
request.preferBridges =
|
|
93
93
|
request.preferBridges || ((_c = config.defaultRouteOptions.bridges) === null || _c === void 0 ? void 0 : _c.prefer);
|
|
94
94
|
request.allowExchanges =
|
|
95
|
-
request.allowExchanges || ((_d = config.defaultRouteOptions.
|
|
95
|
+
request.allowExchanges || ((_d = config.defaultRouteOptions.exchanges) === null || _d === void 0 ? void 0 : _d.allow);
|
|
96
96
|
request.denyExchanges =
|
|
97
|
-
request.denyExchanges || ((_e = config.defaultRouteOptions.
|
|
97
|
+
request.denyExchanges || ((_e = config.defaultRouteOptions.exchanges) === null || _e === void 0 ? void 0 : _e.deny);
|
|
98
98
|
request.preferExchanges =
|
|
99
|
-
request.preferExchanges || ((_f = config.defaultRouteOptions.
|
|
99
|
+
request.preferExchanges || ((_f = config.defaultRouteOptions.exchanges) === null || _f === void 0 ? void 0 : _f.prefer);
|
|
100
100
|
try {
|
|
101
101
|
const result = yield axios_1.default.get(config.apiUrl + 'quote', {
|
|
102
102
|
params: request,
|
|
@@ -143,11 +143,11 @@ const getContractCallQuote = (request, options) => __awaiter(void 0, void 0, voi
|
|
|
143
143
|
request.preferBridges =
|
|
144
144
|
request.preferBridges || ((_j = config.defaultRouteOptions.bridges) === null || _j === void 0 ? void 0 : _j.prefer);
|
|
145
145
|
request.allowExchanges =
|
|
146
|
-
request.allowExchanges || ((_k = config.defaultRouteOptions.
|
|
146
|
+
request.allowExchanges || ((_k = config.defaultRouteOptions.exchanges) === null || _k === void 0 ? void 0 : _k.allow);
|
|
147
147
|
request.denyExchanges =
|
|
148
|
-
request.denyExchanges || ((_l = config.defaultRouteOptions.
|
|
148
|
+
request.denyExchanges || ((_l = config.defaultRouteOptions.exchanges) === null || _l === void 0 ? void 0 : _l.deny);
|
|
149
149
|
request.preferExchanges =
|
|
150
|
-
request.preferExchanges || ((_m = config.defaultRouteOptions.
|
|
150
|
+
request.preferExchanges || ((_m = config.defaultRouteOptions.exchanges) === null || _m === void 0 ? void 0 : _m.prefer);
|
|
151
151
|
// send request
|
|
152
152
|
try {
|
|
153
153
|
const result = yield axios_1.default.post(config.apiUrl + 'quote/contractCall', request, {
|
|
@@ -49,11 +49,11 @@ class ConfigService {
|
|
|
49
49
|
return this.config;
|
|
50
50
|
};
|
|
51
51
|
this.updateChains = (chains) => {
|
|
52
|
-
var _a;
|
|
52
|
+
var _a, _b;
|
|
53
53
|
for (const chain of chains) {
|
|
54
54
|
const chainId = chain.id;
|
|
55
55
|
// set RPCs if they were not configured by the user before
|
|
56
|
-
if (!this.config.rpcs[chainId].length) {
|
|
56
|
+
if (!((_a = this.config.rpcs[chainId]) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
57
57
|
this.config.rpcs[chainId] = chain.metamask.rpcUrls;
|
|
58
58
|
}
|
|
59
59
|
// set multicall addresses if they exist and were not configured by the user before
|
|
@@ -61,7 +61,7 @@ class ConfigService {
|
|
|
61
61
|
this.config.multicallAddresses[chainId] = chain.multicallAddress;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
(
|
|
64
|
+
(_b = this.resolveSetupPromise) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
65
65
|
return this.config;
|
|
66
66
|
};
|
|
67
67
|
this.config = ConfigService.getDefaultConfig();
|
|
@@ -93,6 +93,8 @@ ConfigService.getDefaultConfig = () => {
|
|
|
93
93
|
rpcs: ConfigService.chainIdToObject([]),
|
|
94
94
|
multicallAddresses: ConfigService.chainIdToObject(undefined),
|
|
95
95
|
defaultExecutionSettings: DefaultExecutionSettings,
|
|
96
|
-
defaultRouteOptions: {
|
|
96
|
+
defaultRouteOptions: {
|
|
97
|
+
integrator: 'lifi-sdk',
|
|
98
|
+
},
|
|
97
99
|
};
|
|
98
100
|
};
|
|
@@ -13,14 +13,15 @@ export declare enum LifiErrorCode {
|
|
|
13
13
|
ValidationError = 1001,
|
|
14
14
|
TransactionUnderpriced = 1002,
|
|
15
15
|
TransactionFailed = 1003,
|
|
16
|
-
TransactionUnprepared = 1008,
|
|
17
16
|
Timeout = 1004,
|
|
18
17
|
ProviderUnavailable = 1005,
|
|
19
18
|
NotFound = 1006,
|
|
20
19
|
ChainSwitchError = 1007,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
TransactionUnprepared = 1008,
|
|
21
|
+
GasLimitError = 1009,
|
|
22
|
+
SlippageNotMet = 1010,
|
|
23
|
+
SlippageError = 1011,
|
|
24
|
+
TransactionRejected = 1012
|
|
24
25
|
}
|
|
25
26
|
export declare enum MetaMaskRPCErrorCode {
|
|
26
27
|
invalidInput = -32000,
|
package/dist/cjs/utils/errors.js
CHANGED
|
@@ -18,14 +18,15 @@ var LifiErrorCode;
|
|
|
18
18
|
LifiErrorCode[LifiErrorCode["ValidationError"] = 1001] = "ValidationError";
|
|
19
19
|
LifiErrorCode[LifiErrorCode["TransactionUnderpriced"] = 1002] = "TransactionUnderpriced";
|
|
20
20
|
LifiErrorCode[LifiErrorCode["TransactionFailed"] = 1003] = "TransactionFailed";
|
|
21
|
-
LifiErrorCode[LifiErrorCode["TransactionUnprepared"] = 1008] = "TransactionUnprepared";
|
|
22
21
|
LifiErrorCode[LifiErrorCode["Timeout"] = 1004] = "Timeout";
|
|
23
22
|
LifiErrorCode[LifiErrorCode["ProviderUnavailable"] = 1005] = "ProviderUnavailable";
|
|
24
23
|
LifiErrorCode[LifiErrorCode["NotFound"] = 1006] = "NotFound";
|
|
25
24
|
LifiErrorCode[LifiErrorCode["ChainSwitchError"] = 1007] = "ChainSwitchError";
|
|
26
|
-
LifiErrorCode[LifiErrorCode["
|
|
27
|
-
LifiErrorCode[LifiErrorCode["SlippageError"] = 1008] = "SlippageError";
|
|
25
|
+
LifiErrorCode[LifiErrorCode["TransactionUnprepared"] = 1008] = "TransactionUnprepared";
|
|
28
26
|
LifiErrorCode[LifiErrorCode["GasLimitError"] = 1009] = "GasLimitError";
|
|
27
|
+
LifiErrorCode[LifiErrorCode["SlippageNotMet"] = 1010] = "SlippageNotMet";
|
|
28
|
+
LifiErrorCode[LifiErrorCode["SlippageError"] = 1011] = "SlippageError";
|
|
29
|
+
LifiErrorCode[LifiErrorCode["TransactionRejected"] = 1012] = "TransactionRejected";
|
|
29
30
|
})(LifiErrorCode = exports.LifiErrorCode || (exports.LifiErrorCode = {}));
|
|
30
31
|
var MetaMaskRPCErrorCode;
|
|
31
32
|
(function (MetaMaskRPCErrorCode) {
|
|
@@ -103,17 +103,20 @@ const parseError = (e, step, process) => __awaiter(void 0, void 0, void 0, funct
|
|
|
103
103
|
return new errors_1.ProviderError(e.code, (0, eth_rpc_errors_1.getMessageFromCode)(e.code), yield (0, exports.getTransactionNotSentMessage)(step, process), e.stack);
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
|
|
106
|
+
}
|
|
107
|
+
switch (e.code) {
|
|
108
|
+
case 'CALL_EXCEPTION':
|
|
107
109
|
return new errors_1.ProviderError(errors_1.LifiErrorCode.TransactionFailed, e.reason, yield (0, exports.getTransactionNotSentMessage)(step, process), e.stack);
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
case 'ACTION_REJECTED':
|
|
111
|
+
case errors_1.MetaMaskProviderErrorCode.userRejectedRequest:
|
|
112
|
+
return new errors_1.TransactionError(errors_1.LifiErrorCode.TransactionRejected, e.message, yield (0, exports.getTransactionNotSentMessage)(step, process), e.stack);
|
|
113
|
+
case errors_1.LifiErrorCode.TransactionUnprepared:
|
|
110
114
|
return new errors_1.TransactionError(errors_1.LifiErrorCode.TransactionUnprepared, e.message, yield (0, exports.getTransactionNotSentMessage)(step, process), e.stack);
|
|
111
|
-
|
|
112
|
-
if (e.code === errors_1.LifiErrorCode.ValidationError) {
|
|
115
|
+
case errors_1.LifiErrorCode.ValidationError:
|
|
113
116
|
return new errors_1.TransactionError(errors_1.LifiErrorCode.ValidationError, e.message, e.htmlMessage);
|
|
114
|
-
|
|
117
|
+
default:
|
|
118
|
+
return new errors_1.UnknownError(errors_1.LifiErrorCode.InternalError, e.message || 'Unknown error occurred.', undefined, e.stack);
|
|
115
119
|
}
|
|
116
|
-
return new errors_1.UnknownError(errors_1.LifiErrorCode.InternalError, e.message || 'Unknown error occurred.', undefined, e.stack);
|
|
117
120
|
});
|
|
118
121
|
exports.parseError = parseError;
|
|
119
122
|
const parseBackendError = (e) => {
|
|
@@ -9,6 +9,7 @@ const handlePreRestart = (route) => {
|
|
|
9
9
|
if (stepHasFailed) {
|
|
10
10
|
handleErrorType(route, index);
|
|
11
11
|
deleteFailedProcesses(route, index);
|
|
12
|
+
deleteTransactionData(route, index);
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
};
|
|
@@ -29,3 +30,6 @@ const deleteFailedProcesses = (route, index) => {
|
|
|
29
30
|
route.steps[index].execution.process = route.steps[index].execution.process.filter((process) => process.status !== 'FAILED');
|
|
30
31
|
}
|
|
31
32
|
};
|
|
33
|
+
const deleteTransactionData = (route, index) => {
|
|
34
|
+
route.steps[index].transactionRequest = undefined;
|
|
35
|
+
};
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/sdk";
|
|
2
|
-
export declare const version = "1.
|
|
2
|
+
export declare const version = "1.4.0";
|
package/dist/cjs/version.js
CHANGED
|
@@ -52,10 +52,11 @@ export class BridgeExecutionManager {
|
|
|
52
52
|
else {
|
|
53
53
|
// check balance
|
|
54
54
|
yield balanceCheck(signer, step);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
if (!step.transactionRequest) {
|
|
56
|
+
const personalizedStep = yield personalizeStep(signer, step);
|
|
57
|
+
const updatedStep = yield ApiService.getStepTransaction(personalizedStep);
|
|
58
|
+
step = Object.assign(Object.assign({}, (yield stepComparison(statusManager, personalizedStep, updatedStep, settings.acceptSlippageUpdateHook, this.shouldContinue))), { execution: step.execution });
|
|
59
|
+
}
|
|
59
60
|
const { transactionRequest } = step;
|
|
60
61
|
if (!transactionRequest) {
|
|
61
62
|
throw new TransactionError(LifiErrorCode.TransactionUnprepared, 'Unable to prepare transaction.');
|
|
@@ -50,9 +50,11 @@ export class SwapExecutionManager {
|
|
|
50
50
|
// -> check balance
|
|
51
51
|
yield balanceCheck(signer, step);
|
|
52
52
|
// -> get tx from backend
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
if (!step.transactionRequest) {
|
|
54
|
+
const personalizedStep = yield personalizeStep(signer, step);
|
|
55
|
+
const updatedStep = yield ApiService.getStepTransaction(personalizedStep);
|
|
56
|
+
step = Object.assign(Object.assign({}, (yield stepComparison(statusManager, personalizedStep, updatedStep, settings.acceptSlippageUpdateHook, this.shouldContinue))), { execution: step.execution });
|
|
57
|
+
}
|
|
56
58
|
const { transactionRequest } = step;
|
|
57
59
|
if (!transactionRequest) {
|
|
58
60
|
throw new TransactionError(LifiErrorCode.TransactionUnprepared, 'Unable to prepare transaction.');
|
|
@@ -87,11 +87,11 @@ const getQuote = (request, options) => __awaiter(void 0, void 0, void 0, functio
|
|
|
87
87
|
request.preferBridges =
|
|
88
88
|
request.preferBridges || ((_c = config.defaultRouteOptions.bridges) === null || _c === void 0 ? void 0 : _c.prefer);
|
|
89
89
|
request.allowExchanges =
|
|
90
|
-
request.allowExchanges || ((_d = config.defaultRouteOptions.
|
|
90
|
+
request.allowExchanges || ((_d = config.defaultRouteOptions.exchanges) === null || _d === void 0 ? void 0 : _d.allow);
|
|
91
91
|
request.denyExchanges =
|
|
92
|
-
request.denyExchanges || ((_e = config.defaultRouteOptions.
|
|
92
|
+
request.denyExchanges || ((_e = config.defaultRouteOptions.exchanges) === null || _e === void 0 ? void 0 : _e.deny);
|
|
93
93
|
request.preferExchanges =
|
|
94
|
-
request.preferExchanges || ((_f = config.defaultRouteOptions.
|
|
94
|
+
request.preferExchanges || ((_f = config.defaultRouteOptions.exchanges) === null || _f === void 0 ? void 0 : _f.prefer);
|
|
95
95
|
try {
|
|
96
96
|
const result = yield axios.get(config.apiUrl + 'quote', {
|
|
97
97
|
params: request,
|
|
@@ -138,11 +138,11 @@ const getContractCallQuote = (request, options) => __awaiter(void 0, void 0, voi
|
|
|
138
138
|
request.preferBridges =
|
|
139
139
|
request.preferBridges || ((_j = config.defaultRouteOptions.bridges) === null || _j === void 0 ? void 0 : _j.prefer);
|
|
140
140
|
request.allowExchanges =
|
|
141
|
-
request.allowExchanges || ((_k = config.defaultRouteOptions.
|
|
141
|
+
request.allowExchanges || ((_k = config.defaultRouteOptions.exchanges) === null || _k === void 0 ? void 0 : _k.allow);
|
|
142
142
|
request.denyExchanges =
|
|
143
|
-
request.denyExchanges || ((_l = config.defaultRouteOptions.
|
|
143
|
+
request.denyExchanges || ((_l = config.defaultRouteOptions.exchanges) === null || _l === void 0 ? void 0 : _l.deny);
|
|
144
144
|
request.preferExchanges =
|
|
145
|
-
request.preferExchanges || ((_m = config.defaultRouteOptions.
|
|
145
|
+
request.preferExchanges || ((_m = config.defaultRouteOptions.exchanges) === null || _m === void 0 ? void 0 : _m.prefer);
|
|
146
146
|
// send request
|
|
147
147
|
try {
|
|
148
148
|
const result = yield axios.post(config.apiUrl + 'quote/contractCall', request, {
|
|
@@ -47,11 +47,11 @@ export default class ConfigService {
|
|
|
47
47
|
return this.config;
|
|
48
48
|
};
|
|
49
49
|
this.updateChains = (chains) => {
|
|
50
|
-
var _a;
|
|
50
|
+
var _a, _b;
|
|
51
51
|
for (const chain of chains) {
|
|
52
52
|
const chainId = chain.id;
|
|
53
53
|
// set RPCs if they were not configured by the user before
|
|
54
|
-
if (!this.config.rpcs[chainId].length) {
|
|
54
|
+
if (!((_a = this.config.rpcs[chainId]) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
55
55
|
this.config.rpcs[chainId] = chain.metamask.rpcUrls;
|
|
56
56
|
}
|
|
57
57
|
// set multicall addresses if they exist and were not configured by the user before
|
|
@@ -59,7 +59,7 @@ export default class ConfigService {
|
|
|
59
59
|
this.config.multicallAddresses[chainId] = chain.multicallAddress;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
(
|
|
62
|
+
(_b = this.resolveSetupPromise) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
63
63
|
return this.config;
|
|
64
64
|
};
|
|
65
65
|
this.config = ConfigService.getDefaultConfig();
|
|
@@ -90,6 +90,8 @@ ConfigService.getDefaultConfig = () => {
|
|
|
90
90
|
rpcs: ConfigService.chainIdToObject([]),
|
|
91
91
|
multicallAddresses: ConfigService.chainIdToObject(undefined),
|
|
92
92
|
defaultExecutionSettings: DefaultExecutionSettings,
|
|
93
|
-
defaultRouteOptions: {
|
|
93
|
+
defaultRouteOptions: {
|
|
94
|
+
integrator: 'lifi-sdk',
|
|
95
|
+
},
|
|
94
96
|
};
|
|
95
97
|
};
|
package/dist/utils/errors.d.ts
CHANGED
|
@@ -13,14 +13,15 @@ export declare enum LifiErrorCode {
|
|
|
13
13
|
ValidationError = 1001,
|
|
14
14
|
TransactionUnderpriced = 1002,
|
|
15
15
|
TransactionFailed = 1003,
|
|
16
|
-
TransactionUnprepared = 1008,
|
|
17
16
|
Timeout = 1004,
|
|
18
17
|
ProviderUnavailable = 1005,
|
|
19
18
|
NotFound = 1006,
|
|
20
19
|
ChainSwitchError = 1007,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
TransactionUnprepared = 1008,
|
|
21
|
+
GasLimitError = 1009,
|
|
22
|
+
SlippageNotMet = 1010,
|
|
23
|
+
SlippageError = 1011,
|
|
24
|
+
TransactionRejected = 1012
|
|
24
25
|
}
|
|
25
26
|
export declare enum MetaMaskRPCErrorCode {
|
|
26
27
|
invalidInput = -32000,
|
package/dist/utils/errors.js
CHANGED
|
@@ -15,14 +15,15 @@ export var LifiErrorCode;
|
|
|
15
15
|
LifiErrorCode[LifiErrorCode["ValidationError"] = 1001] = "ValidationError";
|
|
16
16
|
LifiErrorCode[LifiErrorCode["TransactionUnderpriced"] = 1002] = "TransactionUnderpriced";
|
|
17
17
|
LifiErrorCode[LifiErrorCode["TransactionFailed"] = 1003] = "TransactionFailed";
|
|
18
|
-
LifiErrorCode[LifiErrorCode["TransactionUnprepared"] = 1008] = "TransactionUnprepared";
|
|
19
18
|
LifiErrorCode[LifiErrorCode["Timeout"] = 1004] = "Timeout";
|
|
20
19
|
LifiErrorCode[LifiErrorCode["ProviderUnavailable"] = 1005] = "ProviderUnavailable";
|
|
21
20
|
LifiErrorCode[LifiErrorCode["NotFound"] = 1006] = "NotFound";
|
|
22
21
|
LifiErrorCode[LifiErrorCode["ChainSwitchError"] = 1007] = "ChainSwitchError";
|
|
23
|
-
LifiErrorCode[LifiErrorCode["
|
|
24
|
-
LifiErrorCode[LifiErrorCode["SlippageError"] = 1008] = "SlippageError";
|
|
22
|
+
LifiErrorCode[LifiErrorCode["TransactionUnprepared"] = 1008] = "TransactionUnprepared";
|
|
25
23
|
LifiErrorCode[LifiErrorCode["GasLimitError"] = 1009] = "GasLimitError";
|
|
24
|
+
LifiErrorCode[LifiErrorCode["SlippageNotMet"] = 1010] = "SlippageNotMet";
|
|
25
|
+
LifiErrorCode[LifiErrorCode["SlippageError"] = 1011] = "SlippageError";
|
|
26
|
+
LifiErrorCode[LifiErrorCode["TransactionRejected"] = 1012] = "TransactionRejected";
|
|
26
27
|
})(LifiErrorCode || (LifiErrorCode = {}));
|
|
27
28
|
export var MetaMaskRPCErrorCode;
|
|
28
29
|
(function (MetaMaskRPCErrorCode) {
|
package/dist/utils/parseError.js
CHANGED
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { getChainById } from '@lifi/types';
|
|
11
11
|
import { errorCodes as MetaMaskErrorCodes, getMessageFromCode, } from 'eth-rpc-errors';
|
|
12
12
|
import ChainsService from '../services/ChainsService';
|
|
13
|
-
import { LifiError, LifiErrorCode, NotFoundError, ProviderError, RPCError, ServerError, SlippageError, TransactionError, UnknownError, ValidationError, } from './errors';
|
|
13
|
+
import { LifiError, LifiErrorCode, MetaMaskProviderErrorCode, NotFoundError, ProviderError, RPCError, ServerError, SlippageError, TransactionError, UnknownError, ValidationError, } from './errors';
|
|
14
14
|
import { formatTokenAmountOnly } from './utils';
|
|
15
15
|
/**
|
|
16
16
|
* Available MetaMask error codes:
|
|
@@ -95,17 +95,20 @@ export const parseError = (e, step, process) => __awaiter(void 0, void 0, void 0
|
|
|
95
95
|
return new ProviderError(e.code, getMessageFromCode(e.code), yield getTransactionNotSentMessage(step, process), e.stack);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
|
|
98
|
+
}
|
|
99
|
+
switch (e.code) {
|
|
100
|
+
case 'CALL_EXCEPTION':
|
|
99
101
|
return new ProviderError(LifiErrorCode.TransactionFailed, e.reason, yield getTransactionNotSentMessage(step, process), e.stack);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
case 'ACTION_REJECTED':
|
|
103
|
+
case MetaMaskProviderErrorCode.userRejectedRequest:
|
|
104
|
+
return new TransactionError(LifiErrorCode.TransactionRejected, e.message, yield getTransactionNotSentMessage(step, process), e.stack);
|
|
105
|
+
case LifiErrorCode.TransactionUnprepared:
|
|
102
106
|
return new TransactionError(LifiErrorCode.TransactionUnprepared, e.message, yield getTransactionNotSentMessage(step, process), e.stack);
|
|
103
|
-
|
|
104
|
-
if (e.code === LifiErrorCode.ValidationError) {
|
|
107
|
+
case LifiErrorCode.ValidationError:
|
|
105
108
|
return new TransactionError(LifiErrorCode.ValidationError, e.message, e.htmlMessage);
|
|
106
|
-
|
|
109
|
+
default:
|
|
110
|
+
return new UnknownError(LifiErrorCode.InternalError, e.message || 'Unknown error occurred.', undefined, e.stack);
|
|
107
111
|
}
|
|
108
|
-
return new UnknownError(LifiErrorCode.InternalError, e.message || 'Unknown error occurred.', undefined, e.stack);
|
|
109
112
|
});
|
|
110
113
|
export const parseBackendError = (e) => {
|
|
111
114
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
package/dist/utils/preRestart.js
CHANGED
|
@@ -6,6 +6,7 @@ export const handlePreRestart = (route) => {
|
|
|
6
6
|
if (stepHasFailed) {
|
|
7
7
|
handleErrorType(route, index);
|
|
8
8
|
deleteFailedProcesses(route, index);
|
|
9
|
+
deleteTransactionData(route, index);
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
};
|
|
@@ -25,3 +26,6 @@ const deleteFailedProcesses = (route, index) => {
|
|
|
25
26
|
route.steps[index].execution.process = route.steps[index].execution.process.filter((process) => process.status !== 'FAILED');
|
|
26
27
|
}
|
|
27
28
|
};
|
|
29
|
+
const deleteTransactionData = (route, index) => {
|
|
30
|
+
route.steps[index].transactionRequest = undefined;
|
|
31
|
+
};
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/sdk";
|
|
2
|
-
export declare const version = "1.
|
|
2
|
+
export declare const version = "1.4.0";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/sdk';
|
|
2
|
-
export const version = '1.
|
|
2
|
+
export const version = '1.4.0';
|