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