@injectivelabs/exceptions 1.17.2-alpha.9 → 1.17.2
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/cjs/index.cjs +13 -8
- package/dist/cjs/index.d.cts +2 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +13 -8
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -217,7 +217,9 @@ const ChainExchangeModuleErrorCode = {
|
|
|
217
217
|
ErrInsufficientFunds: 95,
|
|
218
218
|
ErrPostOnlyMode: 96,
|
|
219
219
|
ErrClientOrderIdAlreadyExists: 97,
|
|
220
|
-
ErrInvalidCid: 98
|
|
220
|
+
ErrInvalidCid: 98,
|
|
221
|
+
ErrInvalidClosingDirection: 99,
|
|
222
|
+
ErrInvalidNotional: 100
|
|
221
223
|
};
|
|
222
224
|
const ChainAuctionErrorCodes = {
|
|
223
225
|
ErrBidInvalid: 1,
|
|
@@ -625,16 +627,18 @@ var ConcreteException = class extends Error {
|
|
|
625
627
|
this.originalMessage = error.message;
|
|
626
628
|
}
|
|
627
629
|
parseContext(errorContext) {
|
|
628
|
-
const { contextModule, type, code, context } = errorContext || {
|
|
630
|
+
const { contextModule, type, code, context, contextCode } = errorContext || {
|
|
629
631
|
contextModule: "Unknown",
|
|
630
632
|
context: "Unknown",
|
|
631
633
|
code: UnspecifiedErrorCode,
|
|
632
|
-
type: ErrorType.Unspecified
|
|
634
|
+
type: ErrorType.Unspecified,
|
|
635
|
+
contextCode: void 0
|
|
633
636
|
};
|
|
634
637
|
this.context = context;
|
|
635
638
|
this.contextModule = contextModule;
|
|
636
639
|
this.type = type || ErrorType.Unspecified;
|
|
637
640
|
this.code = code || UnspecifiedErrorCode;
|
|
641
|
+
this.contextCode = contextCode;
|
|
638
642
|
}
|
|
639
643
|
setType(type) {
|
|
640
644
|
this.type = type;
|
|
@@ -888,7 +892,8 @@ const exchangeErrorMap = {
|
|
|
888
892
|
[ChainExchangeModuleErrorCode.ErrInsufficientFunds]: "Insufficient funds",
|
|
889
893
|
[ChainExchangeModuleErrorCode.ErrPostOnlyMode]: "Only post-only actions available for approximately 30 minutes after a chain upgrade.",
|
|
890
894
|
[ChainExchangeModuleErrorCode.ErrClientOrderIdAlreadyExists]: "Client order id already exists",
|
|
891
|
-
[ChainExchangeModuleErrorCode.ErrInvalidCid]: "Client order id is invalid. Max length is 36 chars"
|
|
895
|
+
[ChainExchangeModuleErrorCode.ErrInvalidCid]: "Client order id is invalid. Max length is 36 chars",
|
|
896
|
+
[ChainExchangeModuleErrorCode.ErrInvalidClosingDirection]: "Invalid closing direction"
|
|
892
897
|
};
|
|
893
898
|
const insuranceErrorMap = {
|
|
894
899
|
[ChainInsuranceErrorCodes.ErrInsuranceFundAlreadyExists]: "The insurance fund already exists",
|
|
@@ -2378,7 +2383,7 @@ const mapFailedTransactionMessage = (message, context) => {
|
|
|
2378
2383
|
}
|
|
2379
2384
|
return reason$1;
|
|
2380
2385
|
};
|
|
2381
|
-
const ABCICode = context && context.
|
|
2386
|
+
const ABCICode = context && context.contextCode ? context.contextCode : getABCICode(message);
|
|
2382
2387
|
const contextModule = (context === null || context === void 0 ? void 0 : context.contextModule) || getContextModule(message);
|
|
2383
2388
|
const reason = getReason(message);
|
|
2384
2389
|
if (!ABCICode || !contextModule) {
|
|
@@ -2391,12 +2396,12 @@ const mapFailedTransactionMessage = (message, context) => {
|
|
|
2391
2396
|
}
|
|
2392
2397
|
const codespaceErrorMessages = chainModuleCodeErrorMessagesMap[contextModule];
|
|
2393
2398
|
if (!codespaceErrorMessages) return {
|
|
2394
|
-
message: reason || message,
|
|
2399
|
+
message: reason || parseErrorMessage(message),
|
|
2395
2400
|
code: ABCICode,
|
|
2396
2401
|
contextModule
|
|
2397
2402
|
};
|
|
2398
2403
|
return {
|
|
2399
|
-
message: codespaceErrorMessages[ABCICode] || reason || message,
|
|
2404
|
+
message: codespaceErrorMessages[ABCICode] || reason || parseErrorMessage(message),
|
|
2400
2405
|
code: ABCICode,
|
|
2401
2406
|
contextModule
|
|
2402
2407
|
};
|
|
@@ -2445,7 +2450,7 @@ const isCommonLockedError = (error) => {
|
|
|
2445
2450
|
"Ledger device",
|
|
2446
2451
|
"UNKNOWN_ERROR"
|
|
2447
2452
|
];
|
|
2448
|
-
return commonMessages.some((m) => m.includes(error)) || commonMessages.some((m) => error.toLowerCase().includes(m)) || commonMessages.some((m) => m.toLowerCase().includes(error.toLowerCase()));
|
|
2453
|
+
return commonMessages.some((m) => m.includes(error)) || commonMessages.some((m) => error.toLowerCase().includes(m.toLowerCase())) || commonMessages.some((m) => m.toLowerCase().includes(error.toLowerCase()));
|
|
2449
2454
|
};
|
|
2450
2455
|
|
|
2451
2456
|
//#endregion
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -183,6 +183,8 @@ declare const ChainExchangeModuleErrorCode: {
|
|
|
183
183
|
readonly ErrPostOnlyMode: 96;
|
|
184
184
|
readonly ErrClientOrderIdAlreadyExists: 97;
|
|
185
185
|
readonly ErrInvalidCid: 98;
|
|
186
|
+
readonly ErrInvalidClosingDirection: 99;
|
|
187
|
+
readonly ErrInvalidNotional: 100;
|
|
186
188
|
};
|
|
187
189
|
type ChainExchangeModuleErrorCode = (typeof ChainExchangeModuleErrorCode)[keyof typeof ChainExchangeModuleErrorCode];
|
|
188
190
|
declare const ChainAuctionErrorCodes: {
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -183,6 +183,8 @@ declare const ChainExchangeModuleErrorCode: {
|
|
|
183
183
|
readonly ErrPostOnlyMode: 96;
|
|
184
184
|
readonly ErrClientOrderIdAlreadyExists: 97;
|
|
185
185
|
readonly ErrInvalidCid: 98;
|
|
186
|
+
readonly ErrInvalidClosingDirection: 99;
|
|
187
|
+
readonly ErrInvalidNotional: 100;
|
|
186
188
|
};
|
|
187
189
|
type ChainExchangeModuleErrorCode = (typeof ChainExchangeModuleErrorCode)[keyof typeof ChainExchangeModuleErrorCode];
|
|
188
190
|
declare const ChainAuctionErrorCodes: {
|
package/dist/esm/index.js
CHANGED
|
@@ -216,7 +216,9 @@ const ChainExchangeModuleErrorCode = {
|
|
|
216
216
|
ErrInsufficientFunds: 95,
|
|
217
217
|
ErrPostOnlyMode: 96,
|
|
218
218
|
ErrClientOrderIdAlreadyExists: 97,
|
|
219
|
-
ErrInvalidCid: 98
|
|
219
|
+
ErrInvalidCid: 98,
|
|
220
|
+
ErrInvalidClosingDirection: 99,
|
|
221
|
+
ErrInvalidNotional: 100
|
|
220
222
|
};
|
|
221
223
|
const ChainAuctionErrorCodes = {
|
|
222
224
|
ErrBidInvalid: 1,
|
|
@@ -624,16 +626,18 @@ var ConcreteException = class extends Error {
|
|
|
624
626
|
this.originalMessage = error.message;
|
|
625
627
|
}
|
|
626
628
|
parseContext(errorContext) {
|
|
627
|
-
const { contextModule, type, code, context } = errorContext || {
|
|
629
|
+
const { contextModule, type, code, context, contextCode } = errorContext || {
|
|
628
630
|
contextModule: "Unknown",
|
|
629
631
|
context: "Unknown",
|
|
630
632
|
code: UnspecifiedErrorCode,
|
|
631
|
-
type: ErrorType.Unspecified
|
|
633
|
+
type: ErrorType.Unspecified,
|
|
634
|
+
contextCode: void 0
|
|
632
635
|
};
|
|
633
636
|
this.context = context;
|
|
634
637
|
this.contextModule = contextModule;
|
|
635
638
|
this.type = type || ErrorType.Unspecified;
|
|
636
639
|
this.code = code || UnspecifiedErrorCode;
|
|
640
|
+
this.contextCode = contextCode;
|
|
637
641
|
}
|
|
638
642
|
setType(type) {
|
|
639
643
|
this.type = type;
|
|
@@ -887,7 +891,8 @@ const exchangeErrorMap = {
|
|
|
887
891
|
[ChainExchangeModuleErrorCode.ErrInsufficientFunds]: "Insufficient funds",
|
|
888
892
|
[ChainExchangeModuleErrorCode.ErrPostOnlyMode]: "Only post-only actions available for approximately 30 minutes after a chain upgrade.",
|
|
889
893
|
[ChainExchangeModuleErrorCode.ErrClientOrderIdAlreadyExists]: "Client order id already exists",
|
|
890
|
-
[ChainExchangeModuleErrorCode.ErrInvalidCid]: "Client order id is invalid. Max length is 36 chars"
|
|
894
|
+
[ChainExchangeModuleErrorCode.ErrInvalidCid]: "Client order id is invalid. Max length is 36 chars",
|
|
895
|
+
[ChainExchangeModuleErrorCode.ErrInvalidClosingDirection]: "Invalid closing direction"
|
|
891
896
|
};
|
|
892
897
|
const insuranceErrorMap = {
|
|
893
898
|
[ChainInsuranceErrorCodes.ErrInsuranceFundAlreadyExists]: "The insurance fund already exists",
|
|
@@ -2377,7 +2382,7 @@ const mapFailedTransactionMessage = (message, context) => {
|
|
|
2377
2382
|
}
|
|
2378
2383
|
return reason$1;
|
|
2379
2384
|
};
|
|
2380
|
-
const ABCICode = context && context.
|
|
2385
|
+
const ABCICode = context && context.contextCode ? context.contextCode : getABCICode(message);
|
|
2381
2386
|
const contextModule = (context === null || context === void 0 ? void 0 : context.contextModule) || getContextModule(message);
|
|
2382
2387
|
const reason = getReason(message);
|
|
2383
2388
|
if (!ABCICode || !contextModule) {
|
|
@@ -2390,12 +2395,12 @@ const mapFailedTransactionMessage = (message, context) => {
|
|
|
2390
2395
|
}
|
|
2391
2396
|
const codespaceErrorMessages = chainModuleCodeErrorMessagesMap[contextModule];
|
|
2392
2397
|
if (!codespaceErrorMessages) return {
|
|
2393
|
-
message: reason || message,
|
|
2398
|
+
message: reason || parseErrorMessage(message),
|
|
2394
2399
|
code: ABCICode,
|
|
2395
2400
|
contextModule
|
|
2396
2401
|
};
|
|
2397
2402
|
return {
|
|
2398
|
-
message: codespaceErrorMessages[ABCICode] || reason || message,
|
|
2403
|
+
message: codespaceErrorMessages[ABCICode] || reason || parseErrorMessage(message),
|
|
2399
2404
|
code: ABCICode,
|
|
2400
2405
|
contextModule
|
|
2401
2406
|
};
|
|
@@ -2444,7 +2449,7 @@ const isCommonLockedError = (error) => {
|
|
|
2444
2449
|
"Ledger device",
|
|
2445
2450
|
"UNKNOWN_ERROR"
|
|
2446
2451
|
];
|
|
2447
|
-
return commonMessages.some((m) => m.includes(error)) || commonMessages.some((m) => error.toLowerCase().includes(m)) || commonMessages.some((m) => m.toLowerCase().includes(error.toLowerCase()));
|
|
2452
|
+
return commonMessages.some((m) => m.includes(error)) || commonMessages.some((m) => error.toLowerCase().includes(m.toLowerCase())) || commonMessages.some((m) => m.toLowerCase().includes(error.toLowerCase()));
|
|
2448
2453
|
};
|
|
2449
2454
|
|
|
2450
2455
|
//#endregion
|