@injectivelabs/exceptions 1.16.38 → 1.17.2-alpha.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.
Files changed (133) hide show
  1. package/dist/cjs/index.cjs +2759 -0
  2. package/dist/cjs/index.d.cts +826 -0
  3. package/dist/cjs/package.json +2 -2
  4. package/dist/esm/index.d.ts +826 -3
  5. package/dist/esm/index.js +2712 -2
  6. package/dist/esm/package.json +2 -2
  7. package/package.json +37 -38
  8. package/dist/cjs/exceptions/base.d.ts +0 -81
  9. package/dist/cjs/exceptions/base.js +0 -179
  10. package/dist/cjs/exceptions/exceptions/BitGetException.d.ts +0 -7
  11. package/dist/cjs/exceptions/exceptions/BitGetException.js +0 -31
  12. package/dist/cjs/exceptions/exceptions/CosmosWalletException.d.ts +0 -7
  13. package/dist/cjs/exceptions/exceptions/CosmosWalletException.js +0 -16
  14. package/dist/cjs/exceptions/exceptions/GeneralException.d.ts +0 -5
  15. package/dist/cjs/exceptions/exceptions/GeneralException.js +0 -11
  16. package/dist/cjs/exceptions/exceptions/GrpcUnaryRequestException.d.ts +0 -7
  17. package/dist/cjs/exceptions/exceptions/GrpcUnaryRequestException.js +0 -21
  18. package/dist/cjs/exceptions/exceptions/HttpRequestException.d.ts +0 -11
  19. package/dist/cjs/exceptions/exceptions/HttpRequestException.js +0 -21
  20. package/dist/cjs/exceptions/exceptions/LedgerCosmosException.d.ts +0 -7
  21. package/dist/cjs/exceptions/exceptions/LedgerCosmosException.js +0 -40
  22. package/dist/cjs/exceptions/exceptions/LedgerException.d.ts +0 -7
  23. package/dist/cjs/exceptions/exceptions/LedgerException.js +0 -40
  24. package/dist/cjs/exceptions/exceptions/MetamaskException.d.ts +0 -7
  25. package/dist/cjs/exceptions/exceptions/MetamaskException.js +0 -31
  26. package/dist/cjs/exceptions/exceptions/OkxWalletException.d.ts +0 -7
  27. package/dist/cjs/exceptions/exceptions/OkxWalletException.js +0 -31
  28. package/dist/cjs/exceptions/exceptions/RabbyWalletException.d.ts +0 -7
  29. package/dist/cjs/exceptions/exceptions/RabbyWalletException.js +0 -33
  30. package/dist/cjs/exceptions/exceptions/RainbowWalletException.d.ts +0 -7
  31. package/dist/cjs/exceptions/exceptions/RainbowWalletException.js +0 -31
  32. package/dist/cjs/exceptions/exceptions/TransactionException.d.ts +0 -7
  33. package/dist/cjs/exceptions/exceptions/TransactionException.js +0 -34
  34. package/dist/cjs/exceptions/exceptions/TrezorException.d.ts +0 -7
  35. package/dist/cjs/exceptions/exceptions/TrezorException.js +0 -16
  36. package/dist/cjs/exceptions/exceptions/TrustWalletException.d.ts +0 -7
  37. package/dist/cjs/exceptions/exceptions/TrustWalletException.js +0 -33
  38. package/dist/cjs/exceptions/exceptions/TurnkeyWalletSessionException.d.ts +0 -5
  39. package/dist/cjs/exceptions/exceptions/TurnkeyWalletSessionException.js +0 -11
  40. package/dist/cjs/exceptions/exceptions/WalletConnectException.d.ts +0 -7
  41. package/dist/cjs/exceptions/exceptions/WalletConnectException.js +0 -31
  42. package/dist/cjs/exceptions/exceptions/WalletException.d.ts +0 -5
  43. package/dist/cjs/exceptions/exceptions/WalletException.js +0 -11
  44. package/dist/cjs/exceptions/exceptions/Web3Exception.d.ts +0 -7
  45. package/dist/cjs/exceptions/exceptions/Web3Exception.js +0 -16
  46. package/dist/cjs/exceptions/exceptions/index.d.ts +0 -18
  47. package/dist/cjs/exceptions/exceptions/index.js +0 -37
  48. package/dist/cjs/exceptions/index.d.ts +0 -2
  49. package/dist/cjs/exceptions/index.js +0 -18
  50. package/dist/cjs/exceptions/messages.d.ts +0 -13
  51. package/dist/cjs/exceptions/messages.js +0 -1600
  52. package/dist/cjs/exceptions/types/codes.d.ts +0 -441
  53. package/dist/cjs/exceptions/types/codes.js +0 -774
  54. package/dist/cjs/exceptions/types/context.d.ts +0 -93
  55. package/dist/cjs/exceptions/types/context.js +0 -21
  56. package/dist/cjs/exceptions/types/index.d.ts +0 -3
  57. package/dist/cjs/exceptions/types/index.js +0 -19
  58. package/dist/cjs/exceptions/types/modules.d.ts +0 -67
  59. package/dist/cjs/exceptions/types/modules.js +0 -66
  60. package/dist/cjs/exceptions/utils/grpc.d.ts +0 -3
  61. package/dist/cjs/exceptions/utils/grpc.js +0 -43
  62. package/dist/cjs/exceptions/utils/helpers.d.ts +0 -1
  63. package/dist/cjs/exceptions/utils/helpers.js +0 -24
  64. package/dist/cjs/exceptions/utils/maps.d.ts +0 -13
  65. package/dist/cjs/exceptions/utils/maps.js +0 -127
  66. package/dist/cjs/index.d.ts +0 -3
  67. package/dist/cjs/index.js +0 -18
  68. package/dist/cjs/types.d.ts +0 -2
  69. package/dist/cjs/types.js +0 -2
  70. package/dist/cjs/utils.d.ts +0 -8
  71. package/dist/cjs/utils.js +0 -49
  72. package/dist/esm/exceptions/base.d.ts +0 -81
  73. package/dist/esm/exceptions/base.js +0 -175
  74. package/dist/esm/exceptions/exceptions/BitGetException.d.ts +0 -7
  75. package/dist/esm/exceptions/exceptions/BitGetException.js +0 -27
  76. package/dist/esm/exceptions/exceptions/CosmosWalletException.d.ts +0 -7
  77. package/dist/esm/exceptions/exceptions/CosmosWalletException.js +0 -12
  78. package/dist/esm/exceptions/exceptions/GeneralException.d.ts +0 -5
  79. package/dist/esm/exceptions/exceptions/GeneralException.js +0 -7
  80. package/dist/esm/exceptions/exceptions/GrpcUnaryRequestException.d.ts +0 -7
  81. package/dist/esm/exceptions/exceptions/GrpcUnaryRequestException.js +0 -17
  82. package/dist/esm/exceptions/exceptions/HttpRequestException.d.ts +0 -11
  83. package/dist/esm/exceptions/exceptions/HttpRequestException.js +0 -17
  84. package/dist/esm/exceptions/exceptions/LedgerCosmosException.d.ts +0 -7
  85. package/dist/esm/exceptions/exceptions/LedgerCosmosException.js +0 -36
  86. package/dist/esm/exceptions/exceptions/LedgerException.d.ts +0 -7
  87. package/dist/esm/exceptions/exceptions/LedgerException.js +0 -36
  88. package/dist/esm/exceptions/exceptions/MetamaskException.d.ts +0 -7
  89. package/dist/esm/exceptions/exceptions/MetamaskException.js +0 -27
  90. package/dist/esm/exceptions/exceptions/OkxWalletException.d.ts +0 -7
  91. package/dist/esm/exceptions/exceptions/OkxWalletException.js +0 -27
  92. package/dist/esm/exceptions/exceptions/RabbyWalletException.d.ts +0 -7
  93. package/dist/esm/exceptions/exceptions/RabbyWalletException.js +0 -29
  94. package/dist/esm/exceptions/exceptions/RainbowWalletException.d.ts +0 -7
  95. package/dist/esm/exceptions/exceptions/RainbowWalletException.js +0 -27
  96. package/dist/esm/exceptions/exceptions/TransactionException.d.ts +0 -7
  97. package/dist/esm/exceptions/exceptions/TransactionException.js +0 -30
  98. package/dist/esm/exceptions/exceptions/TrezorException.d.ts +0 -7
  99. package/dist/esm/exceptions/exceptions/TrezorException.js +0 -12
  100. package/dist/esm/exceptions/exceptions/TrustWalletException.d.ts +0 -7
  101. package/dist/esm/exceptions/exceptions/TrustWalletException.js +0 -29
  102. package/dist/esm/exceptions/exceptions/TurnkeyWalletSessionException.d.ts +0 -5
  103. package/dist/esm/exceptions/exceptions/TurnkeyWalletSessionException.js +0 -7
  104. package/dist/esm/exceptions/exceptions/WalletConnectException.d.ts +0 -7
  105. package/dist/esm/exceptions/exceptions/WalletConnectException.js +0 -27
  106. package/dist/esm/exceptions/exceptions/WalletException.d.ts +0 -5
  107. package/dist/esm/exceptions/exceptions/WalletException.js +0 -7
  108. package/dist/esm/exceptions/exceptions/Web3Exception.d.ts +0 -7
  109. package/dist/esm/exceptions/exceptions/Web3Exception.js +0 -12
  110. package/dist/esm/exceptions/exceptions/index.d.ts +0 -18
  111. package/dist/esm/exceptions/exceptions/index.js +0 -18
  112. package/dist/esm/exceptions/index.d.ts +0 -2
  113. package/dist/esm/exceptions/index.js +0 -2
  114. package/dist/esm/exceptions/messages.d.ts +0 -13
  115. package/dist/esm/exceptions/messages.js +0 -1597
  116. package/dist/esm/exceptions/types/codes.d.ts +0 -441
  117. package/dist/esm/exceptions/types/codes.js +0 -770
  118. package/dist/esm/exceptions/types/context.d.ts +0 -93
  119. package/dist/esm/exceptions/types/context.js +0 -18
  120. package/dist/esm/exceptions/types/index.d.ts +0 -3
  121. package/dist/esm/exceptions/types/index.js +0 -3
  122. package/dist/esm/exceptions/types/modules.d.ts +0 -67
  123. package/dist/esm/exceptions/types/modules.js +0 -63
  124. package/dist/esm/exceptions/utils/grpc.d.ts +0 -3
  125. package/dist/esm/exceptions/utils/grpc.js +0 -6
  126. package/dist/esm/exceptions/utils/helpers.d.ts +0 -1
  127. package/dist/esm/exceptions/utils/helpers.js +0 -20
  128. package/dist/esm/exceptions/utils/maps.d.ts +0 -13
  129. package/dist/esm/exceptions/utils/maps.js +0 -120
  130. package/dist/esm/types.d.ts +0 -2
  131. package/dist/esm/types.js +0 -1
  132. package/dist/esm/utils.d.ts +0 -8
  133. package/dist/esm/utils.js +0 -44
@@ -1,93 +0,0 @@
1
- import type { ErrorCode, ErrorContextCode } from './codes.js';
2
- export declare const HttpRequestMethod: {
3
- readonly Get: "GET";
4
- readonly Post: "POST";
5
- readonly Options: "OPTIONS";
6
- };
7
- export type HttpRequestMethod = (typeof HttpRequestMethod)[keyof typeof HttpRequestMethod];
8
- export declare const ErrorType: {
9
- readonly Unspecified: "unspecified";
10
- readonly ChainError: "chain-error";
11
- readonly ExecutionError: "execution-error";
12
- readonly NotFoundError: "not-found-error";
13
- readonly ValidationError: "validation-error";
14
- readonly WalletError: "wallet-error";
15
- readonly WalletNotInstalledError: "wallet-not-installed-error";
16
- readonly GrpcUnaryRequest: "grpc-unary-request";
17
- readonly HttpRequest: "http-request";
18
- readonly Web3: "web3";
19
- readonly Web3Gateway: "web3-gateway";
20
- };
21
- export type ErrorType = (typeof ErrorType)[keyof typeof ErrorType];
22
- export interface ErrorContext {
23
- code?: ErrorCode;
24
- type?: ErrorType;
25
- /**
26
- * Additional context needed for the exception
27
- */
28
- context?: string;
29
- /**
30
- * Where is the exception thrown
31
- */
32
- contextModule?: string;
33
- /**
34
- * Needed when we get a code error from a Http/Grpc Request
35
- * and we need to specify the error code for the particular message
36
- * for example why the transaction has failed
37
- * */
38
- contextCode?: ErrorContextCode;
39
- /**
40
- * If true, skip parsing the error message and use the raw message
41
- * Useful when you want to preserve the original error message without
42
- * any transformation or mapping
43
- */
44
- skipParsing?: boolean;
45
- }
46
- export interface Exception {
47
- /**
48
- * The type of the Error
49
- */
50
- type: ErrorType;
51
- /**
52
- * Error specific code (HttpStatus, GrpcStatus, etc)
53
- */
54
- code: ErrorCode;
55
- /**
56
- * The name of the error (the name of the instance of the Exception)
57
- */
58
- name: string;
59
- /**
60
- * Providing more context as to where the exception was thrown
61
- * (ex: on-chain module, etc)
62
- */
63
- contextModule?: string;
64
- /**
65
- * Providing more context as to why the exception was thrown
66
- * (ex: on-chain error code, etc)
67
- */
68
- contextCode?: ErrorContextCode;
69
- /**
70
- * Parsed message of the exception
71
- */
72
- message: string;
73
- /**
74
- * The original stack of the error
75
- */
76
- stack?: string;
77
- /**
78
- * The original message of the error
79
- */
80
- originalMessage: string;
81
- parse?(): void;
82
- parseError(error: Error): void;
83
- parseContext(context?: ErrorContext): void;
84
- setType(type: ErrorType): void;
85
- setCode(code: ErrorCode): void;
86
- setStack(stack: string): void;
87
- setName(name: string): void;
88
- setMessage(message: string): void;
89
- setContextModule(contextModule: string): void;
90
- toOriginalError(): Error;
91
- toError(): Error;
92
- toString(): string;
93
- }
@@ -1,18 +0,0 @@
1
- export const HttpRequestMethod = {
2
- Get: 'GET',
3
- Post: 'POST',
4
- Options: 'OPTIONS',
5
- };
6
- export const ErrorType = {
7
- Unspecified: 'unspecified',
8
- ChainError: 'chain-error',
9
- ExecutionError: 'execution-error',
10
- NotFoundError: 'not-found-error',
11
- ValidationError: 'validation-error',
12
- WalletError: 'wallet-error',
13
- WalletNotInstalledError: 'wallet-not-installed-error',
14
- GrpcUnaryRequest: 'grpc-unary-request',
15
- HttpRequest: 'http-request',
16
- Web3: 'web3',
17
- Web3Gateway: 'web3-gateway',
18
- };
@@ -1,3 +0,0 @@
1
- export * from './modules.js';
2
- export * from './codes.js';
3
- export * from './context.js';
@@ -1,3 +0,0 @@
1
- export * from './modules.js';
2
- export * from './codes.js';
3
- export * from './context.js';
@@ -1,67 +0,0 @@
1
- export declare const ContractErrorModule: {
2
- readonly Peggy: "peggy-contract";
3
- readonly PeggyOld: "peggy-old-contract";
4
- readonly Erc20Contract: "erc20-contract";
5
- };
6
- export type ContractErrorModule = (typeof ContractErrorModule)[keyof typeof ContractErrorModule];
7
- export declare const ChainErrorModule: {
8
- readonly Gov: "chain-gov";
9
- readonly Ibc: "chain-ibc";
10
- readonly Evm: "chain-evm";
11
- readonly Auth: "chain-auth";
12
- readonly Bank: "chain-bank";
13
- readonly Mint: "chain-mint";
14
- readonly Wasm: "chain-wasm";
15
- readonly Authz: "chain-authz";
16
- readonly Peggy: "chain-peggy";
17
- readonly WasmX: "chain-wasmx";
18
- readonly Erc20: "chain-erc20";
19
- readonly Oracle: "chain-oracle";
20
- readonly TxFees: "chain-tx-fees";
21
- readonly Auction: "chain-auction";
22
- readonly Staking: "chain-staking";
23
- readonly Exchange: "chain-exchange";
24
- readonly Tendermint: "chain-tendermint";
25
- readonly InsuranceFund: "chain-insurance";
26
- readonly Permissions: "chain-permissions";
27
- readonly Distribution: "chain-distribution";
28
- };
29
- export type ChainErrorModule = (typeof ChainErrorModule)[keyof typeof ChainErrorModule];
30
- export declare const IndexerErrorModule: {
31
- readonly Dmm: "dmm";
32
- readonly OLP: "olp";
33
- readonly Abacus: "abacus";
34
- readonly Meta: "indexer-meta";
35
- readonly Mito: "indexer-mito";
36
- readonly Referral: "referral";
37
- readonly Spot: "indexer-spot";
38
- readonly Web3Gw: "web3-gateway";
39
- readonly Oracle: "indexer-oracle";
40
- readonly Account: "indexer-account";
41
- readonly Auction: "indexer-auction";
42
- readonly Trading: "indexer-trading";
43
- readonly Archiver: "indexer-archiver";
44
- readonly Explorer: "indexer-explorer";
45
- readonly Campaign: "indexer-campaign";
46
- readonly Portfolio: "indexer-portfolio";
47
- readonly MegaVault: "indexer-mega-vault";
48
- readonly Derivatives: "indexer-derivatives";
49
- readonly Transaction: "indexer-transaction";
50
- readonly ChronosSpot: "indexer-chronos-spot";
51
- readonly InsuranceFund: "indexer-insurance-fund";
52
- readonly ChronosMarkets: "indexer-chronos-markets";
53
- readonly ChronosDerivative: "indexer-chronos-derivative";
54
- };
55
- export type IndexerErrorModule = (typeof IndexerErrorModule)[keyof typeof IndexerErrorModule];
56
- export declare const WalletErrorActionModule: {
57
- readonly GetChainId: "get-chain-id";
58
- readonly GetAccounts: "get-accounts";
59
- readonly GetNetworkId: "get-network-id";
60
- readonly SignArbitrary: "sign-arbitrary";
61
- readonly SignTransaction: "sign-transaction";
62
- readonly SendTransaction: "send-transaction";
63
- readonly SendEvmTransaction: "send-evm-transaction";
64
- readonly SignEvmTransaction: "sign-evm-transaction";
65
- readonly GetEvmTransactionReceipt: "get-evm-transaction-receipt";
66
- };
67
- export type WalletErrorActionModule = (typeof WalletErrorActionModule)[keyof typeof WalletErrorActionModule];
@@ -1,63 +0,0 @@
1
- export const ContractErrorModule = {
2
- Peggy: 'peggy-contract',
3
- PeggyOld: 'peggy-old-contract',
4
- Erc20Contract: 'erc20-contract',
5
- };
6
- export const ChainErrorModule = {
7
- Gov: 'chain-gov',
8
- Ibc: 'chain-ibc',
9
- Evm: 'chain-evm',
10
- Auth: 'chain-auth',
11
- Bank: 'chain-bank',
12
- Mint: 'chain-mint',
13
- Wasm: 'chain-wasm',
14
- Authz: 'chain-authz',
15
- Peggy: 'chain-peggy',
16
- WasmX: 'chain-wasmx',
17
- Erc20: 'chain-erc20',
18
- Oracle: 'chain-oracle',
19
- TxFees: 'chain-tx-fees',
20
- Auction: 'chain-auction',
21
- Staking: 'chain-staking',
22
- Exchange: 'chain-exchange',
23
- Tendermint: 'chain-tendermint',
24
- InsuranceFund: 'chain-insurance',
25
- Permissions: 'chain-permissions',
26
- Distribution: 'chain-distribution',
27
- };
28
- export const IndexerErrorModule = {
29
- Dmm: 'dmm',
30
- OLP: 'olp',
31
- Abacus: 'abacus',
32
- Meta: 'indexer-meta',
33
- Mito: 'indexer-mito',
34
- Referral: 'referral',
35
- Spot: 'indexer-spot',
36
- Web3Gw: 'web3-gateway',
37
- Oracle: 'indexer-oracle',
38
- Account: 'indexer-account',
39
- Auction: 'indexer-auction',
40
- Trading: 'indexer-trading',
41
- Archiver: 'indexer-archiver',
42
- Explorer: 'indexer-explorer',
43
- Campaign: 'indexer-campaign',
44
- Portfolio: 'indexer-portfolio',
45
- MegaVault: 'indexer-mega-vault',
46
- Derivatives: 'indexer-derivatives',
47
- Transaction: 'indexer-transaction',
48
- ChronosSpot: 'indexer-chronos-spot',
49
- InsuranceFund: 'indexer-insurance-fund',
50
- ChronosMarkets: 'indexer-chronos-markets',
51
- ChronosDerivative: 'indexer-chronos-derivative',
52
- };
53
- export const WalletErrorActionModule = {
54
- GetChainId: 'get-chain-id',
55
- GetAccounts: 'get-accounts',
56
- GetNetworkId: 'get-network-id',
57
- SignArbitrary: 'sign-arbitrary',
58
- SignTransaction: 'sign-transaction',
59
- SendTransaction: 'send-transaction',
60
- SendEvmTransaction: 'send-evm-transaction',
61
- SignEvmTransaction: 'sign-evm-transaction',
62
- GetEvmTransactionReceipt: 'get-evm-transaction-receipt',
63
- };
@@ -1,3 +0,0 @@
1
- import * as grpcPkg from '@injectivelabs/grpc-web';
2
- declare const grpc: typeof grpcPkg.grpc;
3
- export { grpc, grpcPkg };
@@ -1,6 +0,0 @@
1
- import * as grpcPkg from '@injectivelabs/grpc-web';
2
- const grpc = grpcPkg.grpc ??
3
- grpcPkg.default
4
- .grpc ??
5
- grpcPkg;
6
- export { grpc, grpcPkg };
@@ -1 +0,0 @@
1
- export declare const isCommonLockedError: (error: string) => boolean;
@@ -1,20 +0,0 @@
1
- export const isCommonLockedError = (error) => {
2
- const commonMessages = [
3
- 'Ledger device: Incorrect length',
4
- 'Ledger device: INS_NOT_SUPPORTED',
5
- 'Ledger device: CLA_NOT_SUPPORTED',
6
- 'Unknown',
7
- 'Ledger device',
8
- 'CLA_NOT_SUPPORTED',
9
- 'CLA',
10
- 'Locked',
11
- 'Failed to open the device',
12
- 'Failed to open the device',
13
- 'Ledger Device is busy',
14
- 'Ledger device',
15
- 'UNKNOWN_ERROR',
16
- ];
17
- return (commonMessages.some((m) => m.includes(error)) ||
18
- commonMessages.some((m) => error.toLowerCase().includes(m)) ||
19
- commonMessages.some((m) => m.toLowerCase().includes(error.toLowerCase())));
20
- };
@@ -1,13 +0,0 @@
1
- import type { ErrorContext, ErrorContextCode, TransactionChainErrorModule } from '../types/index.js';
2
- export declare const parseErrorMessage: (message: string) => string;
3
- export declare const mapFailedTransactionMessageFromString: (message: string) => {
4
- message: string;
5
- code: ErrorContextCode;
6
- module?: TransactionChainErrorModule;
7
- };
8
- export declare const mapFailedTransactionMessage: (message: string, context?: ErrorContext) => {
9
- message: string;
10
- code: ErrorContextCode;
11
- contextModule?: string;
12
- };
13
- export declare const mapErrorMessage: (message: string) => string;
@@ -1,120 +0,0 @@
1
- import { UnspecifiedErrorCode } from '../types/index.js';
2
- import { chainErrorMessagesMap, chainModuleCodeErrorMessagesMap, } from '../messages.js';
3
- export const parseErrorMessage = (message) => {
4
- const firstParse = message.split('message index: 0:');
5
- if (firstParse.length === 1) {
6
- const [firstParseString] = firstParse;
7
- const secondParse = firstParseString.split(': invalid request');
8
- const [secondParseString] = secondParse;
9
- return secondParseString.trim().trimEnd();
10
- }
11
- const [, firstParseString] = firstParse;
12
- const [actualMessage] = firstParseString.split(': invalid request');
13
- return actualMessage.trim().trimEnd();
14
- };
15
- export const mapFailedTransactionMessageFromString = (message) => {
16
- const parsedMessage = parseErrorMessage(message);
17
- const messageInMapKey = Object.keys(chainErrorMessagesMap).find((key) => parsedMessage.toLowerCase().includes(key.toLowerCase()));
18
- if (!messageInMapKey) {
19
- return {
20
- message: parsedMessage,
21
- code: UnspecifiedErrorCode,
22
- module: undefined,
23
- };
24
- }
25
- return chainErrorMessagesMap[messageInMapKey];
26
- };
27
- export const mapFailedTransactionMessage = (message, context) => {
28
- const getWasmErrorFromMessage = (message) => {
29
- if (!message.includes('execute wasm contract failed')) {
30
- return;
31
- }
32
- const ReasonPattern = /(.*?)execute wasm contract failed(.*?)/g;
33
- const reason = ReasonPattern.exec(message);
34
- if (!reason) {
35
- return;
36
- }
37
- if (reason.length < 2) {
38
- return;
39
- }
40
- return reason[1].replace('failed to execute message; message index: 0: ', '');
41
- };
42
- const getABCICode = (message) => {
43
- const ABCICodePattern = /{key:"ABCICode"[ \t]+value:"(.*?)"}/g;
44
- const ABCICode = ABCICodePattern.exec(message);
45
- if (!ABCICode || ABCICode.length < 2) {
46
- return;
47
- }
48
- return Number(ABCICode[1]);
49
- };
50
- const getContextModule = (message) => {
51
- const codespacePattern = /{key:"Codespace"[ \t]+value:"(.*?)"}/g;
52
- const codespace = codespacePattern.exec(message);
53
- if (!codespace || codespace.length < 2) {
54
- return;
55
- }
56
- return codespace[1];
57
- };
58
- const getReason = (message) => {
59
- const ReasonPattern = /\[reason:"(.*?)"/g;
60
- const codespace = ReasonPattern.exec(message);
61
- if (!codespace || codespace.length < 2) {
62
- if (message.includes('execute wasm contract failed')) {
63
- return getWasmErrorFromMessage(message);
64
- }
65
- return;
66
- }
67
- const reason = codespace[1];
68
- if (reason === 'execute wasm contract failed') {
69
- const SubReasonPattern = /(.*?)Generic error:(.*?): execute wasm/g;
70
- const subReason = SubReasonPattern.exec(message);
71
- if (!subReason) {
72
- return reason;
73
- }
74
- return subReason[2] || reason;
75
- }
76
- return reason;
77
- };
78
- const ABCICode = context && context.code ? context.code : getABCICode(message);
79
- const contextModule = context?.contextModule || getContextModule(message);
80
- const reason = getReason(message);
81
- if (!ABCICode || !contextModule) {
82
- const failedTxMap = mapFailedTransactionMessageFromString(message);
83
- return {
84
- ...failedTxMap,
85
- contextModule: failedTxMap.module || contextModule,
86
- message: reason || failedTxMap.message,
87
- };
88
- }
89
- const codespaceErrorMessages = chainModuleCodeErrorMessagesMap[contextModule];
90
- if (!codespaceErrorMessages) {
91
- return {
92
- message: reason || message,
93
- code: ABCICode,
94
- contextModule,
95
- };
96
- }
97
- return {
98
- message: codespaceErrorMessages[ABCICode] || reason || message,
99
- code: ABCICode,
100
- contextModule,
101
- };
102
- };
103
- export const mapErrorMessage = (message) => {
104
- const parsedMessage = message.trim().toLowerCase();
105
- if (parsedMessage.includes('User denied message signature'.toLowerCase())) {
106
- return 'The request has been rejected';
107
- }
108
- if (parsedMessage.toLowerCase().includes('user denied'.toLowerCase())) {
109
- return 'The request has been rejected';
110
- }
111
- if (parsedMessage.toLowerCase().includes('provided chain'.toLowerCase())) {
112
- return 'Your selected network is incorrect';
113
- }
114
- if (parsedMessage
115
- .toLowerCase()
116
- .includes('Keyring Controller signTypedMessage'.toLowerCase())) {
117
- return 'Please ensure your Ledger is connected, unlocked and your Ethereum app is open.';
118
- }
119
- return message.replaceAll('Keyring Controller signTypedMessage:', '');
120
- };
@@ -1,2 +0,0 @@
1
- import type { Web3Exception, WalletException, TrezorException, BitGetException, LedgerException, GeneralException, MetamaskException, OkxWalletException, HttpRequestException, TrustWalletException, TransactionException, LedgerCosmosException, CosmosWalletException, GrpcUnaryRequestException } from './exceptions/exceptions/index.js';
2
- export type ThrownException = Web3Exception | LedgerException | TrezorException | WalletException | BitGetException | GeneralException | MetamaskException | OkxWalletException | HttpRequestException | TrustWalletException | TransactionException | CosmosWalletException | LedgerCosmosException | GrpcUnaryRequestException;
package/dist/esm/types.js DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- import type { ThrownException } from './types.js';
2
- import type { Exception } from './exceptions/types/index.js';
3
- export declare const THROWN_EXCEPTIONS: string[];
4
- export declare const isThrownException: (exception: Error | Exception | ThrownException) => boolean;
5
- export declare const formatNotificationDescription: (description: string) => {
6
- description: string;
7
- tooltip: string;
8
- };
package/dist/esm/utils.js DELETED
@@ -1,44 +0,0 @@
1
- export const THROWN_EXCEPTIONS = [
2
- 'Web3Exception',
3
- 'LedgerException',
4
- 'TrezorException',
5
- 'WalletException',
6
- 'BitGetException',
7
- 'GeneralException',
8
- 'MetamaskException',
9
- 'OkxWalletException',
10
- 'HttpRequestException',
11
- 'TransactionException',
12
- 'TrustWalletException',
13
- 'LedgerCosmosException',
14
- 'CosmosWalletException',
15
- 'WalletConnectException',
16
- 'GrpcUnaryRequestException',
17
- 'TurnkeyWalletSessionException',
18
- ];
19
- export const isThrownException = (exception) => {
20
- if (THROWN_EXCEPTIONS.includes(exception.constructor.name)) {
21
- return true;
22
- }
23
- if (THROWN_EXCEPTIONS.includes(exception.name)) {
24
- return true;
25
- }
26
- if ('errorClass' in exception &&
27
- THROWN_EXCEPTIONS.includes(exception.errorClass)) {
28
- return true;
29
- }
30
- return false;
31
- };
32
- export const formatNotificationDescription = (description) => {
33
- const DESCRIPTION_CHARACTER_LIMIT = 50;
34
- if (description.length <= DESCRIPTION_CHARACTER_LIMIT) {
35
- return {
36
- description,
37
- tooltip: '',
38
- };
39
- }
40
- return {
41
- description: description.slice(0, DESCRIPTION_CHARACTER_LIMIT) + ' ...',
42
- tooltip: description,
43
- };
44
- };