Socket
Socket
Sign inDemoInstall

web3-errors

Package Overview
Dependencies
0
Maintainers
5
Versions
264
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.5-dev.2c60685.0 to 1.1.5-dev.2f73aa5.0

1

lib/commonjs/error_codes.d.ts

@@ -11,2 +11,3 @@ export declare const ERR_RESPONSE = 100;

export declare const ERR_INVALID_METHOD_PARAMS = 207;
export declare const ERR_MULTIPLE_ERRORS = 208;
export declare const ERR_CONTRACT = 300;

@@ -13,0 +14,0 @@ export declare const ERR_CONTRACT_RESOLVER_MISSING = 301;

7

lib/commonjs/error_codes.js

@@ -19,5 +19,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ERR_TX_RECEIPT_MISSING_OR_BLOCKHASH_NULL = exports.ERR_TX_POLLING_TIMEOUT = exports.ERR_TX_DATA_AND_INPUT = exports.ERR_TX_UNSUPPORTED_TYPE = exports.ERR_TX_UNSUPPORTED_EIP_1559 = exports.ERR_TX_UNABLE_TO_POPULATE_NONCE = exports.ERR_TX_INVALID_NONCE_OR_CHAIN_ID = exports.ERR_TX_INVALID_OBJECT = exports.ERR_TX_INVALID_LEGACY_FEE_MARKET = exports.ERR_TX_INVALID_FEE_MARKET_GAS_PRICE = exports.ERR_TX_INVALID_FEE_MARKET_GAS = exports.ERR_TX_INVALID_LEGACY_GAS = exports.ERR_TX_MISSING_GAS = exports.ERR_TX_MISSING_CHAIN_INFO = exports.ERR_TX_INVALID_CHAIN_INFO = exports.ERR_TX_CHAIN_ID_MISMATCH = exports.ERR_TX_MISSING_CUSTOM_CHAIN_ID = exports.ERR_TX_MISSING_CUSTOM_CHAIN = exports.ERR_TX_INVALID_CALL = exports.ERR_TX_INVALID_SENDER = exports.ERR_RAW_TX_UNDEFINED = exports.ERR_TX_OUT_OF_GAS = exports.ERR_TX_REVERT_WITHOUT_REASON = exports.ERR_TX_CONTRACT_NOT_STORED = exports.ERR_TX_NO_CONTRACT_ADDRESS = exports.ERR_TX_REVERT_TRANSACTION = exports.ERR_TX_REVERT_INSTRUCTION = exports.ERR_TX = exports.ERR_CONTRACT_TX_DATA_AND_INPUT = exports.ERR_CONTRACT_EXECUTION_REVERTED = exports.ERR_CONTRACT_INSTANTIATION = exports.ERR_CONTRACT_MISSING_FROM_ADDRESS = exports.ERR_CONTRACT_MISSING_ADDRESS = exports.ERR_CONTRACT_MISSING_DEPLOY_DATA = exports.ERR_CONTRACT_RESERVED_EVENT = exports.ERR_CONTRACT_EVENT_NOT_EXISTS = exports.ERR_CONTRACT_REQUIRED_CALLBACK = exports.ERR_CONTRACT_ABI_MISSING = exports.ERR_CONTRACT_RESOLVER_MISSING = exports.ERR_CONTRACT = exports.ERR_INVALID_METHOD_PARAMS = exports.ERR_EXISTING_PLUGIN_NAMESPACE = exports.ERR_ABI_ENCODING = exports.ERR_OPERATION_ABORT = exports.ERR_OPERATION_TIMEOUT = exports.ERR_METHOD_NOT_IMPLEMENTED = exports.ERR_FORMATTERS = exports.ERR_PARAM = exports.ERR_INVALID_RESPONSE = exports.ERR_RESPONSE = void 0;
exports.ERR_INVALID_NUMBER = exports.ERR_INVALID_BYTES = exports.ERR_INVALID_STRING = exports.ERR_ENS_NETWORK_NOT_SYNCED = exports.ERR_ENS_UNSUPPORTED_NETWORK = exports.ERR_ENS_CHECK_INTERFACE_SUPPORT = exports.JSONRPC_ERR_CHAIN_DISCONNECTED = exports.JSONRPC_ERR_DISCONNECTED = exports.JSONRPC_ERR_UNSUPPORTED_METHOD = exports.JSONRPC_ERR_UNAUTHORIZED = exports.JSONRPC_ERR_REJECTED_REQUEST = exports.GENESIS_BLOCK_NUMBER = exports.ERR_INVALID_SIGNATURE = exports.ERR_SIGNATURE_FAILED = exports.ERR_PBKDF2_ITERATIONS = exports.ERR_INVALID_KEYSTORE = exports.ERR_IV_LENGTH = exports.ERR_INVALID_PASSWORD = exports.ERR_KEY_VERSION_UNSUPPORTED = exports.ERR_KEY_DERIVATION_FAIL = exports.ERR_UNSUPPORTED_KDF = exports.ERR_INVALID_PRIVATE_KEY = exports.ERR_PRIVATE_KEY_LENGTH = exports.ERR_WS_PROVIDER = exports.ERR_SUBSCRIPTION = exports.ERR_INVALID_CLIENT = exports.ERR_INVALID_PROVIDER = exports.ERR_PROVIDER = exports.ERR_REQ_ALREADY_SENT = exports.ERR_CONN_PENDING_REQUESTS = exports.ERR_CONN_MAX_ATTEMPTS = exports.ERR_CONN_CLOSE = exports.ERR_CONN_NOT_OPEN = exports.ERR_CONN_TIMEOUT = exports.ERR_CONN_INVALID = exports.ERR_CONN = exports.ERR_TX_GAS_MISMATCH_INNER_ERROR = exports.ERR_TX_MISSING_GAS_INNER_ERROR = exports.ERR_TX_INVALID_PROPERTIES_FOR_TYPE = exports.ERR_TX_REVERT_TRANSACTION_CUSTOM_ERROR = exports.ERR_TX_INVALID_RECEIVER = exports.ERR_TX_HARDFORK_MISMATCH = exports.ERR_TX_CHAIN_MISMATCH = exports.ERR_TX_GAS_MISMATCH = exports.ERR_TX_SIGNING = exports.ERR_TX_BLOCK_TIMEOUT = exports.ERR_TX_SEND_TIMEOUT = exports.ERR_TX_NOT_FOUND = exports.ERR_TX_LOCAL_WALLET_NOT_AVAILABLE = exports.ERR_TX_RECEIPT_MISSING_BLOCK_NUMBER = void 0;
exports.ERR_RPC_NOT_SUPPORTED = exports.ERR_RPC_LIMIT_EXCEEDED = exports.ERR_RPC_UNSUPPORTED_METHOD = exports.ERR_RPC_TRANSACTION_REJECTED = exports.ERR_RPC_UNAVAILABLE_RESOURCE = exports.ERR_RPC_MISSING_RESOURCE = exports.ERR_RPC_INVALID_INPUT = exports.ERR_RPC_INTERNAL_ERROR = exports.ERR_RPC_INVALID_PARAMS = exports.ERR_RPC_INVALID_METHOD = exports.ERR_RPC_INVALID_REQUEST = exports.ERR_RPC_INVALID_JSON = exports.ERR_SCHEMA_FORMAT = exports.ERR_CORE_CHAIN_MISMATCH = exports.ERR_CORE_HARDFORK_MISMATCH = exports.ERR_VALIDATION = exports.ERR_INVALID_NIBBLE_WIDTH = exports.ERR_INVALID_TYPE_ABI = exports.ERR_INVALID_BLOCK = exports.ERR_INVALID_LARGE_VALUE = exports.ERR_INVALID_SIZE = exports.ERR_INVALID_UNSIGNED_INTEGER = exports.ERR_INVALID_BOOLEAN = exports.ERR_INVALID_TYPE = exports.ERR_INVALID_HEX = exports.ERR_INVALID_ADDRESS = exports.ERR_INVALID_UNIT = void 0;
exports.ERR_TX_POLLING_TIMEOUT = exports.ERR_TX_DATA_AND_INPUT = exports.ERR_TX_UNSUPPORTED_TYPE = exports.ERR_TX_UNSUPPORTED_EIP_1559 = exports.ERR_TX_UNABLE_TO_POPULATE_NONCE = exports.ERR_TX_INVALID_NONCE_OR_CHAIN_ID = exports.ERR_TX_INVALID_OBJECT = exports.ERR_TX_INVALID_LEGACY_FEE_MARKET = exports.ERR_TX_INVALID_FEE_MARKET_GAS_PRICE = exports.ERR_TX_INVALID_FEE_MARKET_GAS = exports.ERR_TX_INVALID_LEGACY_GAS = exports.ERR_TX_MISSING_GAS = exports.ERR_TX_MISSING_CHAIN_INFO = exports.ERR_TX_INVALID_CHAIN_INFO = exports.ERR_TX_CHAIN_ID_MISMATCH = exports.ERR_TX_MISSING_CUSTOM_CHAIN_ID = exports.ERR_TX_MISSING_CUSTOM_CHAIN = exports.ERR_TX_INVALID_CALL = exports.ERR_TX_INVALID_SENDER = exports.ERR_RAW_TX_UNDEFINED = exports.ERR_TX_OUT_OF_GAS = exports.ERR_TX_REVERT_WITHOUT_REASON = exports.ERR_TX_CONTRACT_NOT_STORED = exports.ERR_TX_NO_CONTRACT_ADDRESS = exports.ERR_TX_REVERT_TRANSACTION = exports.ERR_TX_REVERT_INSTRUCTION = exports.ERR_TX = exports.ERR_CONTRACT_TX_DATA_AND_INPUT = exports.ERR_CONTRACT_EXECUTION_REVERTED = exports.ERR_CONTRACT_INSTANTIATION = exports.ERR_CONTRACT_MISSING_FROM_ADDRESS = exports.ERR_CONTRACT_MISSING_ADDRESS = exports.ERR_CONTRACT_MISSING_DEPLOY_DATA = exports.ERR_CONTRACT_RESERVED_EVENT = exports.ERR_CONTRACT_EVENT_NOT_EXISTS = exports.ERR_CONTRACT_REQUIRED_CALLBACK = exports.ERR_CONTRACT_ABI_MISSING = exports.ERR_CONTRACT_RESOLVER_MISSING = exports.ERR_CONTRACT = exports.ERR_MULTIPLE_ERRORS = exports.ERR_INVALID_METHOD_PARAMS = exports.ERR_EXISTING_PLUGIN_NAMESPACE = exports.ERR_ABI_ENCODING = exports.ERR_OPERATION_ABORT = exports.ERR_OPERATION_TIMEOUT = exports.ERR_METHOD_NOT_IMPLEMENTED = exports.ERR_FORMATTERS = exports.ERR_PARAM = exports.ERR_INVALID_RESPONSE = exports.ERR_RESPONSE = void 0;
exports.ERR_INVALID_BYTES = exports.ERR_INVALID_STRING = exports.ERR_ENS_NETWORK_NOT_SYNCED = exports.ERR_ENS_UNSUPPORTED_NETWORK = exports.ERR_ENS_CHECK_INTERFACE_SUPPORT = exports.JSONRPC_ERR_CHAIN_DISCONNECTED = exports.JSONRPC_ERR_DISCONNECTED = exports.JSONRPC_ERR_UNSUPPORTED_METHOD = exports.JSONRPC_ERR_UNAUTHORIZED = exports.JSONRPC_ERR_REJECTED_REQUEST = exports.GENESIS_BLOCK_NUMBER = exports.ERR_INVALID_SIGNATURE = exports.ERR_SIGNATURE_FAILED = exports.ERR_PBKDF2_ITERATIONS = exports.ERR_INVALID_KEYSTORE = exports.ERR_IV_LENGTH = exports.ERR_INVALID_PASSWORD = exports.ERR_KEY_VERSION_UNSUPPORTED = exports.ERR_KEY_DERIVATION_FAIL = exports.ERR_UNSUPPORTED_KDF = exports.ERR_INVALID_PRIVATE_KEY = exports.ERR_PRIVATE_KEY_LENGTH = exports.ERR_WS_PROVIDER = exports.ERR_SUBSCRIPTION = exports.ERR_INVALID_CLIENT = exports.ERR_INVALID_PROVIDER = exports.ERR_PROVIDER = exports.ERR_REQ_ALREADY_SENT = exports.ERR_CONN_PENDING_REQUESTS = exports.ERR_CONN_MAX_ATTEMPTS = exports.ERR_CONN_CLOSE = exports.ERR_CONN_NOT_OPEN = exports.ERR_CONN_TIMEOUT = exports.ERR_CONN_INVALID = exports.ERR_CONN = exports.ERR_TX_GAS_MISMATCH_INNER_ERROR = exports.ERR_TX_MISSING_GAS_INNER_ERROR = exports.ERR_TX_INVALID_PROPERTIES_FOR_TYPE = exports.ERR_TX_REVERT_TRANSACTION_CUSTOM_ERROR = exports.ERR_TX_INVALID_RECEIVER = exports.ERR_TX_HARDFORK_MISMATCH = exports.ERR_TX_CHAIN_MISMATCH = exports.ERR_TX_GAS_MISMATCH = exports.ERR_TX_SIGNING = exports.ERR_TX_BLOCK_TIMEOUT = exports.ERR_TX_SEND_TIMEOUT = exports.ERR_TX_NOT_FOUND = exports.ERR_TX_LOCAL_WALLET_NOT_AVAILABLE = exports.ERR_TX_RECEIPT_MISSING_BLOCK_NUMBER = exports.ERR_TX_RECEIPT_MISSING_OR_BLOCKHASH_NULL = void 0;
exports.ERR_RPC_NOT_SUPPORTED = exports.ERR_RPC_LIMIT_EXCEEDED = exports.ERR_RPC_UNSUPPORTED_METHOD = exports.ERR_RPC_TRANSACTION_REJECTED = exports.ERR_RPC_UNAVAILABLE_RESOURCE = exports.ERR_RPC_MISSING_RESOURCE = exports.ERR_RPC_INVALID_INPUT = exports.ERR_RPC_INTERNAL_ERROR = exports.ERR_RPC_INVALID_PARAMS = exports.ERR_RPC_INVALID_METHOD = exports.ERR_RPC_INVALID_REQUEST = exports.ERR_RPC_INVALID_JSON = exports.ERR_SCHEMA_FORMAT = exports.ERR_CORE_CHAIN_MISMATCH = exports.ERR_CORE_HARDFORK_MISMATCH = exports.ERR_VALIDATION = exports.ERR_INVALID_NIBBLE_WIDTH = exports.ERR_INVALID_TYPE_ABI = exports.ERR_INVALID_BLOCK = exports.ERR_INVALID_LARGE_VALUE = exports.ERR_INVALID_SIZE = exports.ERR_INVALID_UNSIGNED_INTEGER = exports.ERR_INVALID_BOOLEAN = exports.ERR_INVALID_TYPE = exports.ERR_INVALID_HEX = exports.ERR_INVALID_ADDRESS = exports.ERR_INVALID_UNIT = exports.ERR_INVALID_NUMBER = void 0;
// Response error

@@ -35,2 +35,3 @@ exports.ERR_RESPONSE = 100;

exports.ERR_INVALID_METHOD_PARAMS = 207;
exports.ERR_MULTIPLE_ERRORS = 208;
// Contract error codes

@@ -37,0 +38,0 @@ exports.ERR_CONTRACT = 300;

@@ -14,3 +14,4 @@ import { ConnectionEvent } from 'web3-types';

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -28,3 +29,4 @@ }

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -42,3 +44,4 @@ }

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -45,0 +48,0 @@ }

@@ -18,3 +18,4 @@ import { JsonRpcError, TransactionReceipt, HexString } from 'web3-types';

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -39,3 +40,4 @@ }

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -52,3 +54,4 @@ }

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -79,3 +82,3 @@ }

/**
* This class is expected to be set as an `innerError` inside ContractExecutionError
* This class is expected to be set as an `cause` inside ContractExecutionError
* The properties would be typically decoded from the `data` if it was encoded according to EIP-838

@@ -92,3 +95,3 @@ */

};
innerError: Eip838ExecutionError | undefined;
cause: Eip838ExecutionError | undefined;
constructor(error: JsonRpcError<ProviderErrorData> | Eip838ExecutionError);

@@ -102,3 +105,4 @@ setDecodedProperties(errorName: string, errorSignature?: string, errorArgs?: {

message: string;
innerError: Error | Error[] | undefined;
innerError: Eip838ExecutionError | undefined;
cause: Eip838ExecutionError | undefined;
data: string;

@@ -117,3 +121,3 @@ errorName?: string | undefined;

export declare class ContractExecutionError extends Web3ContractError {
innerError: Eip838ExecutionError;
cause: Eip838ExecutionError;
constructor(rpcError: JsonRpcError);

@@ -120,0 +124,0 @@ }

@@ -107,3 +107,3 @@ "use strict";

/**
* This class is expected to be set as an `innerError` inside ContractExecutionError
* This class is expected to be set as an `cause` inside ContractExecutionError
* The properties would be typically decoded from the `data` if it was encoded according to EIP-838

@@ -131,3 +131,3 @@ */

this.data = originalError.data;
this.innerError = new Eip838ExecutionError(originalError);
this.cause = new Eip838ExecutionError(originalError);
}

@@ -160,3 +160,3 @@ else {

this.code = error_codes_js_1.ERR_CONTRACT_EXECUTION_REVERTED;
this.innerError = new Eip838ExecutionError(rpcError);
this.cause = new Eip838ExecutionError(rpcError);
}

@@ -163,0 +163,0 @@ }

@@ -15,3 +15,4 @@ import { BaseWeb3Error } from '../web3_error_base.js';

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -28,3 +29,4 @@ }

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -31,0 +33,0 @@ }

@@ -14,3 +14,4 @@ import { JsonRpcPayload, JsonRpcResponse } from 'web3-types';

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -17,0 +18,0 @@ }

@@ -50,5 +50,10 @@ "use strict";

else if (response instanceof Array) {
errorOrErrors = response.map(r => r.error);
errorOrErrors = response.filter(r => r.error).map(r => r.error);
}
this.innerError = errorOrErrors;
if (Array.isArray(errorOrErrors) && errorOrErrors.length > 0) {
this.cause = new web3_error_base_js_1.MultipleErrors(errorOrErrors);
}
else {
this.cause = errorOrErrors;
}
}

@@ -71,3 +76,8 @@ toJSON() {

}
this.innerError = errorOrErrors;
if (Array.isArray(errorOrErrors)) {
this.cause = new web3_error_base_js_1.MultipleErrors(errorOrErrors);
}
else {
this.cause = errorOrErrors;
}
}

@@ -74,0 +84,0 @@ }

@@ -16,3 +16,4 @@ import { JsonRpcResponseWithError, JsonRpcId, JsonRpcError } from 'web3-types';

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -19,0 +20,0 @@ }

@@ -11,4 +11,5 @@ import { BaseWeb3Error } from '../web3_error_base.js';

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};
}

@@ -12,3 +12,4 @@ import { Bytes, HexString, Numbers, TransactionReceipt, Web3ValidationErrorObject } from 'web3-types';

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -27,3 +28,4 @@ }

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -46,3 +48,4 @@ }

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -76,3 +79,4 @@ }

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -87,3 +91,4 @@ }

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -90,0 +95,0 @@ }

@@ -211,3 +211,3 @@ "use strict";

this.code = error_codes_js_1.ERR_TX_MISSING_GAS;
this.innerError = new MissingGasInnerError();
this.cause = new MissingGasInnerError();
}

@@ -228,3 +228,3 @@ }

this.code = error_codes_js_1.ERR_TX_GAS_MISMATCH;
this.innerError = new TransactionGasMismatchInnerError();
this.cause = new TransactionGasMismatchInnerError();
}

@@ -231,0 +231,0 @@ }

import { Web3Error } from 'web3-types';
/**
* Base class for Web3 errors.
*/
export declare abstract class BaseWeb3Error extends Error implements Web3Error {

@@ -6,4 +9,12 @@ readonly name: string;

stack: string | undefined;
innerError: Error | Error[] | undefined;
constructor(msg?: string, innerError?: Error | Error[]);
cause: Error | undefined;
/**
* @deprecated Use the `cause` property instead.
*/
get innerError(): Error | Error[] | undefined;
/**
* @deprecated Use the `cause` property instead.
*/
set innerError(cause: Error | Error[] | undefined);
constructor(msg?: string, cause?: Error | Error[]);
static convertToString(value: unknown, unquotValue?: boolean): string;

@@ -14,5 +25,11 @@ toJSON(): {

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};
}
export declare class MultipleErrors extends BaseWeb3Error {
code: number;
errors: Error[];
constructor(errors: Error[]);
}
export declare abstract class InvalidValueError extends BaseWeb3Error {

@@ -19,0 +36,0 @@ readonly name: string;

@@ -19,7 +19,17 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.InvalidValueError = exports.BaseWeb3Error = void 0;
exports.InvalidValueError = exports.MultipleErrors = exports.BaseWeb3Error = void 0;
const error_codes_js_1 = require("./error_codes.js");
/**
* Base class for Web3 errors.
*/
class BaseWeb3Error extends Error {
constructor(msg, innerError) {
constructor(msg, cause) {
super(msg);
this.innerError = innerError;
if (Array.isArray(cause)) {
// eslint-disable-next-line no-use-before-define
this.cause = new MultipleErrors(cause);
}
else {
this.cause = cause;
}
this.name = this.constructor.name;

@@ -33,2 +43,24 @@ if (typeof Error.captureStackTrace === 'function') {

}
/**
* @deprecated Use the `cause` property instead.
*/
get innerError() {
// eslint-disable-next-line no-use-before-define
if (this.cause instanceof MultipleErrors) {
return this.cause.errors;
}
return this.cause;
}
/**
* @deprecated Use the `cause` property instead.
*/
set innerError(cause) {
if (Array.isArray(cause)) {
// eslint-disable-next-line no-use-before-define
this.cause = new MultipleErrors(cause);
}
else {
this.cause = cause;
}
}
static convertToString(value, unquotValue = false) {

@@ -49,3 +81,5 @@ // Using "null" value intentionally for validation

message: this.message,
innerError: this.innerError,
cause: this.cause,
// deprecated
innerError: this.cause,
};

@@ -55,2 +89,10 @@ }

exports.BaseWeb3Error = BaseWeb3Error;
class MultipleErrors extends BaseWeb3Error {
constructor(errors) {
super(`Multiple errors occurred: [${errors.map(e => e.message).join('], [')}]`);
this.code = error_codes_js_1.ERR_MULTIPLE_ERRORS;
this.errors = errors;
}
}
exports.MultipleErrors = MultipleErrors;
class InvalidValueError extends BaseWeb3Error {

@@ -57,0 +99,0 @@ constructor(value, msg) {

@@ -29,2 +29,3 @@ /*

export const ERR_INVALID_METHOD_PARAMS = 207;
export const ERR_MULTIPLE_ERRORS = 208;
// Contract error codes

@@ -31,0 +32,0 @@ export const ERR_CONTRACT = 300;

@@ -94,3 +94,3 @@ /*

/**
* This class is expected to be set as an `innerError` inside ContractExecutionError
* This class is expected to be set as an `cause` inside ContractExecutionError
* The properties would be typically decoded from the `data` if it was encoded according to EIP-838

@@ -118,3 +118,3 @@ */

this.data = originalError.data;
this.innerError = new Eip838ExecutionError(originalError);
this.cause = new Eip838ExecutionError(originalError);
}

@@ -146,3 +146,3 @@ else {

this.code = ERR_CONTRACT_EXECUTION_REVERTED;
this.innerError = new Eip838ExecutionError(rpcError);
this.cause = new Eip838ExecutionError(rpcError);
}

@@ -149,0 +149,0 @@ }

@@ -17,3 +17,3 @@ /*

*/
import { BaseWeb3Error } from '../web3_error_base.js';
import { BaseWeb3Error, MultipleErrors } from '../web3_error_base.js';
import { ERR_INVALID_RESPONSE, ERR_RESPONSE } from '../error_codes.js';

@@ -48,5 +48,10 @@ // To avoid circular package dependency, copied to code here. If you update this please update same function in `json_rpc.ts`

else if (response instanceof Array) {
errorOrErrors = response.map(r => r.error);
errorOrErrors = response.filter(r => r.error).map(r => r.error);
}
this.innerError = errorOrErrors;
if (Array.isArray(errorOrErrors) && errorOrErrors.length > 0) {
this.cause = new MultipleErrors(errorOrErrors);
}
else {
this.cause = errorOrErrors;
}
}

@@ -68,5 +73,10 @@ toJSON() {

}
this.innerError = errorOrErrors;
if (Array.isArray(errorOrErrors)) {
this.cause = new MultipleErrors(errorOrErrors);
}
else {
this.cause = errorOrErrors;
}
}
}
//# sourceMappingURL=response_errors.js.map

@@ -187,3 +187,3 @@ /*

this.code = ERR_TX_MISSING_GAS;
this.innerError = new MissingGasInnerError();
this.cause = new MissingGasInnerError();
}

@@ -202,3 +202,3 @@ }

this.code = ERR_TX_GAS_MISMATCH;
this.innerError = new TransactionGasMismatchInnerError();
this.cause = new TransactionGasMismatchInnerError();
}

@@ -205,0 +205,0 @@ }

@@ -17,6 +17,16 @@ /*

*/
import { ERR_MULTIPLE_ERRORS } from './error_codes.js';
/**
* Base class for Web3 errors.
*/
export class BaseWeb3Error extends Error {
constructor(msg, innerError) {
constructor(msg, cause) {
super(msg);
this.innerError = innerError;
if (Array.isArray(cause)) {
// eslint-disable-next-line no-use-before-define
this.cause = new MultipleErrors(cause);
}
else {
this.cause = cause;
}
this.name = this.constructor.name;

@@ -30,2 +40,24 @@ if (typeof Error.captureStackTrace === 'function') {

}
/**
* @deprecated Use the `cause` property instead.
*/
get innerError() {
// eslint-disable-next-line no-use-before-define
if (this.cause instanceof MultipleErrors) {
return this.cause.errors;
}
return this.cause;
}
/**
* @deprecated Use the `cause` property instead.
*/
set innerError(cause) {
if (Array.isArray(cause)) {
// eslint-disable-next-line no-use-before-define
this.cause = new MultipleErrors(cause);
}
else {
this.cause = cause;
}
}
static convertToString(value, unquotValue = false) {

@@ -46,6 +78,15 @@ // Using "null" value intentionally for validation

message: this.message,
innerError: this.innerError,
cause: this.cause,
// deprecated
innerError: this.cause,
};
}
}
export class MultipleErrors extends BaseWeb3Error {
constructor(errors) {
super(`Multiple errors occurred: [${errors.map(e => e.message).join('], [')}]`);
this.code = ERR_MULTIPLE_ERRORS;
this.errors = errors;
}
}
export class InvalidValueError extends BaseWeb3Error {

@@ -52,0 +93,0 @@ constructor(value, msg) {

@@ -11,2 +11,3 @@ export declare const ERR_RESPONSE = 100;

export declare const ERR_INVALID_METHOD_PARAMS = 207;
export declare const ERR_MULTIPLE_ERRORS = 208;
export declare const ERR_CONTRACT = 300;

@@ -13,0 +14,0 @@ export declare const ERR_CONTRACT_RESOLVER_MISSING = 301;

@@ -14,3 +14,4 @@ import { ConnectionEvent } from 'web3-types';

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -28,3 +29,4 @@ }

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -42,3 +44,4 @@ }

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -45,0 +48,0 @@ }

@@ -18,3 +18,4 @@ import { JsonRpcError, TransactionReceipt, HexString } from 'web3-types';

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -39,3 +40,4 @@ }

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -52,3 +54,4 @@ }

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -79,3 +82,3 @@ }

/**
* This class is expected to be set as an `innerError` inside ContractExecutionError
* This class is expected to be set as an `cause` inside ContractExecutionError
* The properties would be typically decoded from the `data` if it was encoded according to EIP-838

@@ -92,3 +95,3 @@ */

};
innerError: Eip838ExecutionError | undefined;
cause: Eip838ExecutionError | undefined;
constructor(error: JsonRpcError<ProviderErrorData> | Eip838ExecutionError);

@@ -102,3 +105,4 @@ setDecodedProperties(errorName: string, errorSignature?: string, errorArgs?: {

message: string;
innerError: Error | Error[] | undefined;
innerError: Eip838ExecutionError | undefined;
cause: Eip838ExecutionError | undefined;
data: string;

@@ -117,3 +121,3 @@ errorName?: string | undefined;

export declare class ContractExecutionError extends Web3ContractError {
innerError: Eip838ExecutionError;
cause: Eip838ExecutionError;
constructor(rpcError: JsonRpcError);

@@ -120,0 +124,0 @@ }

@@ -15,3 +15,4 @@ import { BaseWeb3Error } from '../web3_error_base.js';

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -28,3 +29,4 @@ }

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -31,0 +33,0 @@ }

@@ -14,3 +14,4 @@ import { JsonRpcPayload, JsonRpcResponse } from 'web3-types';

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -17,0 +18,0 @@ }

@@ -16,3 +16,4 @@ import { JsonRpcResponseWithError, JsonRpcId, JsonRpcError } from 'web3-types';

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -19,0 +20,0 @@ }

@@ -11,5 +11,6 @@ import { BaseWeb3Error } from '../web3_error_base.js';

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};
}
//# sourceMappingURL=schema_errors.d.ts.map

@@ -12,3 +12,4 @@ import { Bytes, HexString, Numbers, TransactionReceipt, Web3ValidationErrorObject } from 'web3-types';

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -27,3 +28,4 @@ }

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -46,3 +48,4 @@ }

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -76,3 +79,4 @@ }

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -87,3 +91,4 @@ }

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};

@@ -90,0 +95,0 @@ }

import { Web3Error } from 'web3-types';
/**
* Base class for Web3 errors.
*/
export declare abstract class BaseWeb3Error extends Error implements Web3Error {

@@ -6,4 +9,12 @@ readonly name: string;

stack: string | undefined;
innerError: Error | Error[] | undefined;
constructor(msg?: string, innerError?: Error | Error[]);
cause: Error | undefined;
/**
* @deprecated Use the `cause` property instead.
*/
get innerError(): Error | Error[] | undefined;
/**
* @deprecated Use the `cause` property instead.
*/
set innerError(cause: Error | Error[] | undefined);
constructor(msg?: string, cause?: Error | Error[]);
static convertToString(value: unknown, unquotValue?: boolean): string;

@@ -14,5 +25,11 @@ toJSON(): {

message: string;
innerError: Error | Error[] | undefined;
cause: Error | undefined;
innerError: Error | undefined;
};
}
export declare class MultipleErrors extends BaseWeb3Error {
code: number;
errors: Error[];
constructor(errors: Error[]);
}
export declare abstract class InvalidValueError extends BaseWeb3Error {

@@ -19,0 +36,0 @@ readonly name: string;

{
"name": "web3-errors",
"version": "1.1.5-dev.2c60685.0+2c60685",
"version": "1.1.5-dev.2f73aa5.0+2f73aa5",
"description": "This package has web3 error classes",

@@ -33,3 +33,3 @@ "main": "./lib/commonjs/index.js",

"build:check": "node -e \"require('./lib')\"",
"lint": "eslint --ext .js,.ts .",
"lint": "eslint --cache --cache-strategy content --ext .ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",

@@ -45,3 +45,3 @@ "format": "prettier --write '**/*'",

"dependencies": {
"web3-types": "1.3.2-dev.2c60685.0+2c60685"
"web3-types": "1.6.1-dev.2f73aa5.0+2f73aa5"
},

@@ -56,9 +56,9 @@ "devDependencies": {

"eslint-plugin-import": "^2.26.0",
"jest": "^28.1.3",
"jest": "^29.7.0",
"jest-extended": "^3.0.1",
"prettier": "^2.7.1",
"ts-jest": "^28.0.7",
"ts-jest": "^29.1.1",
"typescript": "^4.7.4"
},
"gitHead": "2c6068571268a41a5de530f9052f1de1faaafd24"
"gitHead": "2f73aa5c1de205f30a3961388be27c47c7a28dc5"
}

@@ -31,2 +31,3 @@ /*

export const ERR_INVALID_METHOD_PARAMS = 207;
export const ERR_MULTIPLE_ERRORS = 208;

@@ -33,0 +34,0 @@ // Contract error codes

@@ -135,3 +135,3 @@ /*

/**
* This class is expected to be set as an `innerError` inside ContractExecutionError
* This class is expected to be set as an `cause` inside ContractExecutionError
* The properties would be typically decoded from the `data` if it was encoded according to EIP-838

@@ -148,3 +148,3 @@ */

// eslint-disable-next-line no-use-before-define
public innerError: Eip838ExecutionError | undefined;
public cause: Eip838ExecutionError | undefined;

@@ -171,5 +171,3 @@ public constructor(error: JsonRpcError<ProviderErrorData> | Eip838ExecutionError) {

this.data = originalError.data;
this.innerError = new Eip838ExecutionError(
originalError as JsonRpcError<ProviderErrorData>,
);
this.cause = new Eip838ExecutionError(originalError as JsonRpcError<ProviderErrorData>);
} else {

@@ -198,3 +196,4 @@ this.data = error.data;

message: string;
innerError: Error | Error[] | undefined;
innerError: Eip838ExecutionError | undefined;
cause: Eip838ExecutionError | undefined;
data: string;

@@ -223,3 +222,3 @@ errorName?: string;

export class ContractExecutionError extends Web3ContractError {
public innerError: Eip838ExecutionError;
public cause: Eip838ExecutionError;

@@ -229,3 +228,3 @@ public constructor(rpcError: JsonRpcError) {

this.code = ERR_CONTRACT_EXECUTION_REVERTED;
this.innerError = new Eip838ExecutionError(rpcError as JsonRpcError<ProviderErrorData>);
this.cause = new Eip838ExecutionError(rpcError as JsonRpcError<ProviderErrorData>);
}

@@ -232,0 +231,0 @@ }

@@ -25,3 +25,3 @@ /*

} from 'web3-types';
import { BaseWeb3Error } from '../web3_error_base.js';
import { BaseWeb3Error, MultipleErrors } from '../web3_error_base.js';
import { ERR_INVALID_RESPONSE, ERR_RESPONSE } from '../error_codes.js';

@@ -75,6 +75,10 @@

} else if (response instanceof Array) {
errorOrErrors = response.map(r => r.error) as JsonRpcError[];
errorOrErrors = response.filter(r => r.error).map(r => r.error) as JsonRpcError[];
}
this.innerError = errorOrErrors as Error | Error[] | undefined;
if (Array.isArray(errorOrErrors) && errorOrErrors.length > 0) {
this.cause = new MultipleErrors(errorOrErrors as unknown as Error[]);
} else {
this.cause = errorOrErrors as Error | undefined;
}
}

@@ -103,5 +107,8 @@

}
this.innerError = errorOrErrors as Error | Error[] | undefined;
if (Array.isArray(errorOrErrors)) {
this.cause = new MultipleErrors(errorOrErrors as unknown as Error[]);
} else {
this.cause = errorOrErrors as Error | undefined;
}
}
}
}

@@ -344,3 +344,3 @@ /*

);
this.innerError = new MissingGasInnerError();
this.cause = new MissingGasInnerError();
}

@@ -376,3 +376,3 @@ }

);
this.innerError = new TransactionGasMismatchInnerError();
this.cause = new TransactionGasMismatchInnerError();
}

@@ -379,0 +379,0 @@ }

@@ -21,3 +21,7 @@ /*

import { Web3Error } from 'web3-types';
import { ERR_MULTIPLE_ERRORS } from './error_codes.js';
/**
* Base class for Web3 errors.
*/
export abstract class BaseWeb3Error extends Error implements Web3Error {

@@ -27,7 +31,37 @@ public readonly name: string;

public stack: string | undefined;
public innerError: Error | Error[] | undefined;
public constructor(msg?: string, innerError?: Error | Error[]) {
public cause: Error | undefined;
/**
* @deprecated Use the `cause` property instead.
*/
public get innerError(): Error | Error[] | undefined {
// eslint-disable-next-line no-use-before-define
if (this.cause instanceof MultipleErrors) {
return this.cause.errors;
}
return this.cause;
}
/**
* @deprecated Use the `cause` property instead.
*/
public set innerError(cause: Error | Error[] | undefined) {
if (Array.isArray(cause)) {
// eslint-disable-next-line no-use-before-define
this.cause = new MultipleErrors(cause);
} else {
this.cause = cause;
}
}
public constructor(msg?: string, cause?: Error | Error[]) {
super(msg);
this.innerError = innerError;
if (Array.isArray(cause)) {
// eslint-disable-next-line no-use-before-define
this.cause = new MultipleErrors(cause);
} else {
this.cause = cause;
}
this.name = this.constructor.name;

@@ -62,3 +96,5 @@

message: this.message,
innerError: this.innerError,
cause: this.cause,
// deprecated
innerError: this.cause,
};

@@ -68,2 +104,12 @@ }

export class MultipleErrors extends BaseWeb3Error {
public code = ERR_MULTIPLE_ERRORS;
public errors: Error[];
public constructor(errors: Error[]) {
super(`Multiple errors occurred: [${errors.map(e => e.message).join('], [')}]`);
this.errors = errors;
}
}
export abstract class InvalidValueError extends BaseWeb3Error {

@@ -70,0 +116,0 @@ public readonly name: string;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc