@injectivelabs/exceptions 1.0.47 → 1.0.49

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.
@@ -1,59 +1,67 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mapMetamaskMessage = exports.mapFailedTransactionMessage = exports.parseMessage = void 0;
3
+ exports.mapMetamaskMessage = exports.mapFailedTransactionMessage = exports.mapFailedTransactionMessageFromString = void 0;
4
4
  const messages_1 = require("../messages");
5
5
  const types_1 = require("../types");
6
- /* todo: remove this with the next chain upgrade */
7
- const parseMessage = (message) => {
8
- const firstParse = message.split('message index: 0:');
9
- if (firstParse.length === 1) {
10
- const [firstParseString] = firstParse;
11
- const secondParse = firstParseString.split(': invalid request');
12
- const [secondParseString] = secondParse;
13
- return secondParseString.trim().trimEnd();
14
- }
15
- const [, firstParseString] = firstParse;
16
- const [actualMessage] = firstParseString.split(': invalid request');
17
- return actualMessage.trim().trimEnd();
18
- };
19
- exports.parseMessage = parseMessage;
20
- /* todo: remove this with the next chain upgrade */
21
- const mapMessageByContent = (message) => {
22
- const parsedMessage = (0, exports.parseMessage)(message);
6
+ const mapFailedTransactionMessageFromString = (message) => {
7
+ const parseMessage = (message) => {
8
+ const firstParse = message.split('message index: 0:');
9
+ if (firstParse.length === 1) {
10
+ const [firstParseString] = firstParse;
11
+ const secondParse = firstParseString.split(': invalid request');
12
+ const [secondParseString] = secondParse;
13
+ return secondParseString.trim().trimEnd();
14
+ }
15
+ const [, firstParseString] = firstParse;
16
+ const [actualMessage] = firstParseString.split(': invalid request');
17
+ return actualMessage.trim().trimEnd();
18
+ };
19
+ const parsedMessage = parseMessage(message);
23
20
  const messageInMapKey = Object.keys(messages_1.chainErrorMessagesMap).find((key) => parsedMessage.toLowerCase().includes(key.toLowerCase()));
24
21
  if (!messageInMapKey) {
25
- return { message: parsedMessage, code: types_1.UnspecifiedErrorCode };
22
+ return {
23
+ message: parsedMessage,
24
+ code: types_1.UnspecifiedErrorCode,
25
+ module: undefined,
26
+ };
26
27
  }
27
28
  return messages_1.chainErrorMessagesMap[messageInMapKey];
28
29
  };
29
- const getABCICode = (message) => {
30
- const chainCodePattern = /{key:"ABCICode" (.*?)}/g;
31
- const numericPattern = /\d+/g;
32
- const chainCodeMsg = message.match(chainCodePattern);
33
- if (!chainCodeMsg || chainCodeMsg.length === 0) {
34
- return;
35
- }
36
- const chainCode = chainCodeMsg[0].match(numericPattern);
37
- if (!chainCode || chainCode.length === 0) {
38
- return;
39
- }
40
- return Number(chainCode[0]);
41
- };
42
- const mapFailedTransactionMessage = (message) => {
43
- const ABCICode = getABCICode(message);
44
- if (!ABCICode) {
45
- return mapMessageByContent(message);
30
+ exports.mapFailedTransactionMessageFromString = mapFailedTransactionMessageFromString;
31
+ const mapFailedTransactionMessage = (message, context) => {
32
+ const getABCICode = (message) => {
33
+ const chainCodePattern = /{key:"ABCICode" value:"(.*?)"}/g;
34
+ const chainCode = chainCodePattern.exec(message);
35
+ if (!chainCode || chainCode.length < 2) {
36
+ return;
37
+ }
38
+ return Number(chainCode[1]);
39
+ };
40
+ const getContextModule = (message) => {
41
+ const chainModulePattern = /{key:"Codespace" value:"(.*?)"}/g;
42
+ const chainCode = chainModulePattern.exec(message);
43
+ if (!chainCode || chainCode.length < 2) {
44
+ return;
45
+ }
46
+ return chainCode[1];
47
+ };
48
+ const ABCICode = context && context.code ? context.code : getABCICode(message);
49
+ const contextModule = context && context.contextModule
50
+ ? context.contextModule
51
+ : getContextModule(message);
52
+ if (!ABCICode ||
53
+ !contextModule ||
54
+ !messages_1.chainModuleCodeErrorMessagesMap[contextModule]) {
55
+ return (0, exports.mapFailedTransactionMessageFromString)(message);
46
56
  }
47
- const chainCodeErrorMessage = messages_1.chainCodeErrorMessagesMap[ABCICode];
57
+ const chainCodeErrorMessage = messages_1.chainModuleCodeErrorMessagesMap[contextModule][ABCICode];
48
58
  if (!chainCodeErrorMessage) {
49
- return {
50
- message: messages_1.chainCodeErrorMessagesMap[types_1.ChainCosmosErrorCode.ErrUnknownRequest],
51
- code: types_1.ChainCosmosErrorCode.ErrUnknownRequest,
52
- };
59
+ return (0, exports.mapFailedTransactionMessageFromString)(message);
53
60
  }
54
61
  return {
55
62
  message: chainCodeErrorMessage,
56
63
  code: ABCICode,
64
+ contextModule,
57
65
  };
58
66
  };
59
67
  exports.mapFailedTransactionMessage = mapFailedTransactionMessage;
@@ -1 +1 @@
1
- {"version":3,"file":"maps.js","sourceRoot":"","sources":["../../src/utils/maps.ts"],"names":[],"mappings":";;;AAAA,0CAA8E;AAC9E,oCAIiB;AAEjB,mDAAmD;AAC5C,MAAM,YAAY,GAAG,CAAC,OAAe,EAAE,EAAE;IAC9C,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;IAErD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;QAC3B,MAAM,CAAC,gBAAgB,CAAC,GAAG,UAAU,CAAA;QACrC,MAAM,WAAW,GAAG,gBAAgB,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;QAC/D,MAAM,CAAC,iBAAiB,CAAC,GAAG,WAAW,CAAA;QAEvC,OAAO,iBAAiB,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;KAC1C;IAED,MAAM,CAAC,EAAE,gBAAgB,CAAC,GAAG,UAAU,CAAA;IACvC,MAAM,CAAC,aAAa,CAAC,GAAG,gBAAgB,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;IAEnE,OAAO,aAAa,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;AACvC,CAAC,CAAA;AAfY,QAAA,YAAY,gBAexB;AAED,mDAAmD;AACnD,MAAM,mBAAmB,GAAG,CAC1B,OAAe,EAC8B,EAAE;IAC/C,MAAM,aAAa,GAAG,IAAA,oBAAY,EAAC,OAAO,CAAC,CAAA;IAE3C,MAAM,eAAe,GACnB,MAAM,CAAC,IAAI,C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CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;IAC9E,MAAM,aAAa,GACjB,OAAO,IAAI,OAAO,CAAC,aAAa;QAC9B,CAAC,CAAC,OAAO,CAAC,aAAa;QACvB,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAE/B,IACE,CAAC,QAAQ;QACT,CAAC,aAAa;QACd,CAAC,0CAA+B,CAAC,aAAa,CAAC,EAC/C;QACA,OAAO,IAAA,6CAAqC,EAAC,OAAO,CAAC,CAAA;KACtD;IAED,MAAM,qBAAqB,GACzB,0CAA+B,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,CAAA;IAE1D,IAAI,CAAC,qBAAqB,EAAE;QAC1B,OAAO,IAAA,6CAAqC,EAAC,OAAO,CAAC,CAAA;KACtD;IAED,OAAO;QACL,OAAO,EAAE,qBAAqB;QAC9B,IAAI,EAAE,QAAQ;QACd,aAAa;KACd,CAAA;AACH,CAAC,CAAA;AAtDY,QAAA,2BAA2B,+BAsDvC;AAEM,MAAM,kBAAkB,GAAG,CAAC,OAAe,EAAU,EAAE;IAC5D,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;IAElD,IAAI,aAAa,CAAC,QAAQ,CAAC,+BAA+B,CAAC,WAAW,EAAE,CAAC,EAAE;QACzE,OAAO,+BAA+B,CAAA;KACvC;IAED,OAAO,aAAa,CAAA;AACtB,CAAC,CAAA;AARY,QAAA,kBAAkB,sBAQ9B"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@injectivelabs/exceptions",
3
3
  "description": "List of exceptions that can be reused throughout Injective's projects.",
4
- "version": "1.0.47",
4
+ "version": "1.0.49",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -37,5 +37,5 @@
37
37
  "link-module-alias": "^1.2.0",
38
38
  "shx": "^0.3.2"
39
39
  },
40
- "gitHead": "3947185308da9ed553ad6686b281d87fcbeec889"
40
+ "gitHead": "75422f594113fc8c6a711211ec8f5abbb3929344"
41
41
  }
@@ -1,4 +0,0 @@
1
- import { TransactionException } from './TransactionException';
2
- export declare class Web3GatewayTransactionException extends TransactionException {
3
- }
4
- //# sourceMappingURL=Web3GatewayTransactionException.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Web3GatewayTransactionException.d.ts","sourceRoot":"","sources":["../../src/exceptions/Web3GatewayTransactionException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAE7D,qBAAa,+BAAgC,SAAQ,oBAAoB;CAExE"}
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Web3GatewayTransactionException = void 0;
4
- const TransactionException_1 = require("./TransactionException");
5
- class Web3GatewayTransactionException extends TransactionException_1.TransactionException {
6
- }
7
- exports.Web3GatewayTransactionException = Web3GatewayTransactionException;
8
- //# sourceMappingURL=Web3GatewayTransactionException.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Web3GatewayTransactionException.js","sourceRoot":"","sources":["../../src/exceptions/Web3GatewayTransactionException.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAE7D,MAAa,+BAAgC,SAAQ,2CAAoB;CAExE;AAFD,0EAEC"}