@vechain/sdk-errors
Advanced tools
Comparing version 1.0.0-beta.24 to 1.0.0-beta.25
/** | ||
* @note: REGISTER YOUR NEW FANCY ERRORS BELOW! | ||
*/ | ||
/** | ||
* Default error data type. it accepts any object. | ||
* Function to stringify data correctly. | ||
* Some data types like Error, Map, Set, etc. are not stringified correctly by JSON.stringify. | ||
* This function handles those cases and avoid circular references. | ||
* | ||
* @param ErrorCodeT - The error code type from the error types enum. | ||
* @param data - The data to be stringified. | ||
* @returns The stringified data. | ||
*/ | ||
type DefaultErrorData = Record<string, unknown> | { | ||
innerError: Error; | ||
}; | ||
declare const stringifyData: (data: unknown) => string; | ||
/** | ||
* Error code type. | ||
*/ | ||
type ErrorCode = SECP256K1 | ADDRESS | KEYSTORE | HDNODE | BLOOM | CERTIFICATE | ABI | RLP_ERRORS | DATA | TRANSACTION | HTTP_CLIENT | POLL_ERROR | FUNCTION | EIP1193 | JSONRPC | CONTRACT; | ||
/** | ||
* Conditional type to get the error data type from the error code. | ||
* The type is used to specify the data type of the error builder. | ||
* Asserts that the given error is an instance of the Error class. | ||
* If the error is an instance of Error, it is returned. | ||
* If the error is not an instance of Error, a new Error object is created with a descriptive message. | ||
* | ||
* @param ErrorCodeT - The error code type from the error types enum. | ||
*/ | ||
type DataType<ErrorCodeT extends ErrorCode> = ErrorCodeT extends RLP_ERRORS.INVALID_RLP ? InvalidRLPErrorData : ErrorCodeT extends HTTP_CLIENT.INVALID_HTTP_REQUEST ? HTTPClientErrorData : ErrorCodeT extends POLL_ERROR.POLL_EXECUTION_ERROR ? PollErrorData : ErrorCodeT extends EIP1193.USER_REJECTED_REQUEST ? EIP1193ProviderRpcErrorData : ErrorCodeT extends EIP1193.UNAUTHORIZED ? EIP1193ProviderRpcErrorData : ErrorCodeT extends EIP1193.UNSUPPORTED_METHOD ? EIP1193ProviderRpcErrorData : ErrorCodeT extends EIP1193.DISCONNECTED ? EIP1193ProviderRpcErrorData : ErrorCodeT extends EIP1193.CHAIN_DISCONNECTED ? EIP1193ProviderRpcErrorData : ErrorCodeT extends JSONRPC.INVALID_REQUEST ? JSONRPCErrorData : ErrorCodeT extends JSONRPC.INVALID_PARAMS ? JSONRPCErrorData : ErrorCodeT extends JSONRPC.INTERNAL_ERROR ? JSONRPCErrorData : DefaultErrorData; | ||
/** | ||
* Default error codes. | ||
*/ | ||
declare const ERROR_CODES: { | ||
SECP256K1: typeof SECP256K1; | ||
ADDRESS: typeof ADDRESS; | ||
KEYSTORE: typeof KEYSTORE; | ||
HDNODE: typeof HDNODE; | ||
BLOOM: typeof BLOOM; | ||
CERTIFICATE: typeof CERTIFICATE; | ||
ABI: typeof ABI; | ||
RLP: typeof RLP_ERRORS; | ||
DATA: typeof DATA; | ||
TRANSACTION: typeof TRANSACTION; | ||
HTTP_CLIENT: typeof HTTP_CLIENT; | ||
POLL_ERROR: typeof POLL_ERROR; | ||
FUNCTION: typeof FUNCTION; | ||
EIP1193: typeof EIP1193; | ||
JSONRPC: typeof JSONRPC; | ||
CONTRACT: typeof CONTRACT; | ||
}; | ||
/** | ||
* Conditional type to get the error type from the error code. | ||
* The type is used to specify the return type of the error builder. | ||
* @param {unknown} error - The error to be asserted. | ||
* @return {Error} - The error if it is an instance of Error, or a new Error object if it is not. | ||
* | ||
* @note When adding a new error, add the error code and the error class to the type. | ||
* | ||
* @param ErrorCodeT - The error code type from the error types enum. | ||
* @remarks | ||
* **IMPORTANT: no sensitive data should be passed as any parameter.** | ||
*/ | ||
type ErrorType<ErrorCodeT> = ErrorCodeT extends SECP256K1.INVALID_SECP256k1_PRIVATE_KEY ? InvalidSecp256k1PrivateKeyError : ErrorCodeT extends SECP256K1.INVALID_SECP256k1_MESSAGE_HASH ? InvalidSecp256k1MessageHashError : ErrorCodeT extends SECP256K1.INVALID_SECP256k1_SIGNATURE ? InvalidSecp256k1SignatureError : ErrorCodeT extends SECP256K1.INVALID_SECP256k1_SIGNATURE_RECOVERY ? InvalidSecp256k1SignatureRecoveryError : ErrorCodeT extends ADDRESS.INVALID_ADDRESS ? InvalidAddressError : ErrorCodeT extends KEYSTORE.INVALID_KEYSTORE ? InvalidKeystoreError : ErrorCodeT extends KEYSTORE.INVALID_PASSWORD ? InvalidKeystorePasswordError : ErrorCodeT extends HDNODE.INVALID_HDNODE_CHAIN_CODE ? InvalidHDNodeChaincodeError : ErrorCodeT extends HDNODE.INVALID_HDNODE_MNEMONICS ? InvalidHDNodeMnemonicsError : ErrorCodeT extends HDNODE.INVALID_HDNODE_PRIVATE_KEY ? InvalidHDNodePrivateKeyError : ErrorCodeT extends HDNODE.INVALID_HDNODE_PUBLIC_KEY ? InvalidHDNodePublicKeyError : ErrorCodeT extends HDNODE.INVALID_HDNODE_DERIVATION_PATH ? InvalidHDNodeDerivationPathError : ErrorCodeT extends BLOOM.INVALID_BLOOM ? InvalidBloomError : ErrorCodeT extends BLOOM.INVALID_K ? InvalidKError : ErrorCodeT extends CERTIFICATE.CERTIFICATE_NOT_SIGNED ? CertificateNotSignedError : ErrorCodeT extends CERTIFICATE.CERTIFICATE_INVALID_SIGNATURE_FORMAT ? CertificateInvalidSignatureFormatError : ErrorCodeT extends CERTIFICATE.CERTIFICATE_INVALID_SIGNER ? CertificateInvalidSignerError : ErrorCodeT extends ABI.INVALID_EVENT ? InvalidAbiEventError : ErrorCodeT extends ABI.INVALID_DATA_TO_DECODE ? InvalidAbiDataToDecodeError : ErrorCodeT extends ABI.INVALID_DATA_TO_ENCODE ? InvalidAbiDataToEncodeError : ErrorCodeT extends ABI.INVALID_FORMAT_TYPE ? InvalidAbiFormatTypeError : ErrorCodeT extends ABI.INVALID_FUNCTION ? InvalidAbiFunctionError : ErrorCodeT extends ABI.CONTRACT_INTERFACE_ERROR ? ContractInterfaceError : ErrorCodeT extends RLP_ERRORS.INVALID_RLP ? InvalidRLPError : ErrorCodeT extends DATA.INVALID_DATA_TYPE ? InvalidDataTypeError : ErrorCodeT extends DATA.INVALID_DATA_RETURN_TYPE ? InvalidDataReturnTypeError : ErrorCodeT extends TRANSACTION.ALREADY_SIGNED ? TransactionAlreadySignedError : ErrorCodeT extends TRANSACTION.NOT_SIGNED ? TransactionNotSignedError : ErrorCodeT extends TRANSACTION.INVALID_TRANSACTION_BODY ? TransactionBodyError : ErrorCodeT extends TRANSACTION.INVALID_DELEGATION ? TransactionDelegationError : ErrorCodeT extends TRANSACTION.MISSING_PRIVATE_KEY ? TransactionMissingPrivateKeyError : ErrorCodeT extends HTTP_CLIENT.INVALID_HTTP_REQUEST ? HTTPClientError : ErrorCodeT extends POLL_ERROR.POLL_EXECUTION_ERROR ? PollExecutionError : ErrorCodeT extends EIP1193.USER_REJECTED_REQUEST ? EIP1193UserRejectedRequest : ErrorCodeT extends EIP1193.UNAUTHORIZED ? EIP1193Unauthorized : ErrorCodeT extends EIP1193.UNSUPPORTED_METHOD ? EIP1193UnsupportedMethod : ErrorCodeT extends EIP1193.DISCONNECTED ? EIP1193Disconnected : ErrorCodeT extends EIP1193.CHAIN_DISCONNECTED ? EIP1193ChainDisconnected : ErrorCodeT extends FUNCTION.NOT_IMPLEMENTED ? NotImplementedError : ErrorCodeT extends JSONRPC.INVALID_REQUEST ? JSONRPCInvalidRequest : ErrorCodeT extends JSONRPC.INVALID_PARAMS ? JSONRPCInvalidParams : ErrorCodeT extends JSONRPC.INTERNAL_ERROR ? JSONRPCInternalError : ErrorCodeT extends JSONRPC.DEFAULT ? JSONRPCDefaultError : ErrorCodeT extends CONTRACT.CONTRACT_DEPLOYMENT_FAILED ? ContractDeploymentFailedError : never; | ||
declare function assertInnerError(error: unknown): Error; | ||
/** | ||
* Map to get the error class from the error code. | ||
* The class is used to construct the error object. | ||
* | ||
* @note When adding a new error, add the error code and the error class to the map. | ||
* | ||
* @param ErrorCodeT - The error code type from the error types enum. | ||
*/ | ||
declare const ErrorClassMap: Map<ErrorCode, typeof ErrorBase<ErrorCode, DataType<ErrorCode>>>; | ||
/** | ||
* Base error class to construct all other errors from. | ||
* @param ErrorCodeT - The error code type from the error types enum. | ||
* @param DataTypeT - The error data type. | ||
* @param code - The error code from the error types enum. | ||
* @param message - The error message. | ||
* @param data - The error data. | ||
* @returns The error object. | ||
*/ | ||
declare class ErrorBase<ErrorCodeT extends ErrorCode, DataTypeT> extends Error { | ||
code: ErrorCodeT; | ||
message: string; | ||
data?: DataTypeT; | ||
innerError?: Error; | ||
constructor({ code, message, data, innerError }: { | ||
code: ErrorCodeT; | ||
message: string; | ||
data?: DataTypeT; | ||
innerError?: Error; | ||
}); | ||
} | ||
/** | ||
* Invalid data to decode error to be thrown when an invalid data is detected during decoding. | ||
*/ | ||
declare class InvalidAbiDataToDecodeError extends ErrorBase<ABI.INVALID_DATA_TO_DECODE, DefaultErrorData> { | ||
} | ||
/** | ||
* Invalid data to encode error to be thrown when an invalid data is detected during encoding. | ||
*/ | ||
declare class InvalidAbiDataToEncodeError extends ErrorBase<ABI.INVALID_DATA_TO_ENCODE, DefaultErrorData> { | ||
} | ||
/** | ||
* Invalid event error to be thrown when an invalid event is detected. | ||
*/ | ||
declare class InvalidAbiEventError extends ErrorBase<ABI.INVALID_EVENT, DefaultErrorData> { | ||
} | ||
/** | ||
* Invalid format error to be thrown when an invalid format is provided. | ||
*/ | ||
declare class InvalidAbiFormatTypeError extends ErrorBase<ABI.INVALID_FORMAT_TYPE, DefaultErrorData> { | ||
} | ||
/** | ||
* Invalid function error to be thrown when an invalid function is detected. | ||
*/ | ||
declare class InvalidAbiFunctionError extends ErrorBase<ABI.INVALID_FUNCTION, DefaultErrorData> { | ||
} | ||
/** | ||
* Invalid function error to be thrown when an invalid function is detected. | ||
*/ | ||
declare class ContractInterfaceError extends ErrorBase<ABI.CONTRACT_INTERFACE_ERROR, DefaultErrorData> { | ||
} | ||
/** | ||
* Errors enum. | ||
*/ | ||
declare enum ABI { | ||
INVALID_FUNCTION = "INVALID_FUNCTION", | ||
INVALID_EVENT = "INVALID_EVENT", | ||
INVALID_DATA_TO_DECODE = "INVALID_DATA_TO_DECODE", | ||
INVALID_DATA_TO_ENCODE = "INVALID_DATA_TO_ENCODE", | ||
INVALID_FORMAT_TYPE = "INVALID_FORMAT_TYPE", | ||
CONTRACT_INTERFACE_ERROR = "CONTRACT_INTERFACE_ERROR" | ||
} | ||
/** | ||
* Invalid address error to be thrown when an invalid address is provided. | ||
*/ | ||
declare class InvalidAddressError extends ErrorBase<ADDRESS.INVALID_ADDRESS, DefaultErrorData> { | ||
} | ||
/** | ||
* Errors enum. | ||
*/ | ||
declare enum ADDRESS { | ||
INVALID_ADDRESS = "INVALID_ADDRESS" | ||
} | ||
/** | ||
* Invalid bloom error to be thrown when an invalid bloom is detected. | ||
*/ | ||
declare class InvalidBloomError extends ErrorBase<BLOOM.INVALID_BLOOM, DefaultErrorData> { | ||
} | ||
/** | ||
* Invalid k error to be thrown when an invalid k is detected. | ||
*/ | ||
declare class InvalidKError extends ErrorBase<BLOOM.INVALID_K, DefaultErrorData> { | ||
} | ||
/** | ||
* Errors enum. | ||
*/ | ||
declare enum BLOOM { | ||
INVALID_BLOOM = "INVALID_BLOOM", | ||
INVALID_K = "INVALID_K" | ||
} | ||
/** | ||
* Certificate not signed. | ||
*/ | ||
declare class CertificateNotSignedError extends ErrorBase<CERTIFICATE.CERTIFICATE_NOT_SIGNED, DefaultErrorData> { | ||
} | ||
/** | ||
* Certificate signature format is invalid. | ||
*/ | ||
declare class CertificateInvalidSignatureFormatError extends ErrorBase<CERTIFICATE.CERTIFICATE_INVALID_SIGNATURE_FORMAT, DefaultErrorData> { | ||
} | ||
/** | ||
* Certificate signer is invalid. | ||
*/ | ||
declare class CertificateInvalidSignerError extends ErrorBase<CERTIFICATE.CERTIFICATE_INVALID_SIGNER, DefaultErrorData> { | ||
} | ||
/** | ||
* Errors enum. | ||
*/ | ||
declare enum CERTIFICATE { | ||
CERTIFICATE_NOT_SIGNED = "CERTIFICATE_NOT_SIGNED", | ||
CERTIFICATE_INVALID_SIGNATURE_FORMAT = "CERTIFICATE_INVALID_SIGNATURE_FORMAT", | ||
CERTIFICATE_INVALID_SIGNER = "CERTIFICATE_INVALID_SIGNER" | ||
} | ||
/** | ||
* Error to be thrown when the contract deployment failed. | ||
*/ | ||
declare class ContractDeploymentFailedError extends ErrorBase<CONTRACT.CONTRACT_DEPLOYMENT_FAILED, DefaultErrorData> { | ||
} | ||
/** | ||
* Errors enum. | ||
*/ | ||
declare enum CONTRACT { | ||
CONTRACT_DEPLOYMENT_FAILED = "CONTRACT_DEPLOYMENT_FAILED" | ||
} | ||
/** | ||
* Invalid data error to be thrown when an invalid data is detected. | ||
*/ | ||
declare class InvalidDataTypeError extends ErrorBase<DATA.INVALID_DATA_TYPE, DefaultErrorData> { | ||
} | ||
/** | ||
* Invalid return type given as input. | ||
*/ | ||
declare class InvalidDataReturnTypeError extends ErrorBase<DATA.INVALID_DATA_RETURN_TYPE, DefaultErrorData> { | ||
} | ||
/** | ||
* Errors enum. | ||
*/ | ||
declare enum DATA { | ||
INVALID_DATA_TYPE = "INVALID_DATA_TYPE", | ||
INVALID_DATA_RETURN_TYPE = "INVALID_DATA_RETURN_TYPE" | ||
} | ||
/** | ||
* Invalid chaincode error to be thrown when an invalid chaincode is detected. | ||
*/ | ||
declare class InvalidHDNodeChaincodeError extends ErrorBase<HDNODE.INVALID_HDNODE_CHAIN_CODE, DefaultErrorData> { | ||
} | ||
/** | ||
* Invalid mnemonics error to be thrown when an invalid mnemonic is provided. | ||
*/ | ||
declare class InvalidHDNodeMnemonicsError extends ErrorBase<HDNODE.INVALID_HDNODE_MNEMONICS, DefaultErrorData> { | ||
} | ||
/** | ||
* Invalid private key error to be thrown when an invalid private key is detected. | ||
*/ | ||
declare class InvalidHDNodePrivateKeyError extends ErrorBase<HDNODE.INVALID_HDNODE_PRIVATE_KEY, DefaultErrorData> { | ||
} | ||
/** | ||
* Invalid public key error to be thrown when an invalid public key is detected. | ||
*/ | ||
declare class InvalidHDNodePublicKeyError extends ErrorBase<HDNODE.INVALID_HDNODE_PUBLIC_KEY, DefaultErrorData> { | ||
} | ||
/** | ||
* Invalid derivation path error to be thrown when an invalid derivation path is detected. | ||
*/ | ||
declare class InvalidHDNodeDerivationPathError extends ErrorBase<HDNODE.INVALID_HDNODE_DERIVATION_PATH, DefaultErrorData> { | ||
} | ||
/** | ||
* Errors enum. | ||
*/ | ||
declare enum HDNODE { | ||
INVALID_HDNODE_PUBLIC_KEY = "INVALID_HDNODE_PUBLIC_KEY", | ||
INVALID_HDNODE_PRIVATE_KEY = "INVALID_HDNODE_PRIVATE_KEY", | ||
INVALID_HDNODE_CHAIN_CODE = "INVALID_HDNODE_CHAIN_CODE", | ||
INVALID_HDNODE_MNEMONICS = "INVALID_HDNODE_MNEMONICS", | ||
INVALID_HDNODE_DERIVATION_PATH = "INVALID_HDNODE_DERIVATION_PATH" | ||
} | ||
/** | ||
* Invalid keystore error to be thrown when an invalid keystore is detected. | ||
*/ | ||
declare class InvalidKeystoreError extends ErrorBase<KEYSTORE.INVALID_KEYSTORE, DefaultErrorData> { | ||
} | ||
/** | ||
* Invalid password error to be thrown when an invalid password is provided. | ||
*/ | ||
declare class InvalidKeystorePasswordError extends ErrorBase<KEYSTORE.INVALID_PASSWORD, DefaultErrorData> { | ||
} | ||
/** | ||
* Errors enum. | ||
*/ | ||
declare enum KEYSTORE { | ||
INVALID_KEYSTORE = "INVALID_KEYSTORE", | ||
INVALID_PASSWORD = "INVALID_PASSWORD" | ||
} | ||
/** | ||
* Invalid RLP_ERRORS error data interface. | ||
*/ | ||
interface InvalidRLPErrorData { | ||
context: string; | ||
} | ||
/** | ||
* Invalid RLP_ERRORS error to be thrown when an invalid RLP_ERRORS is detected. | ||
*/ | ||
declare class InvalidRLPError extends ErrorBase<RLP_ERRORS.INVALID_RLP, InvalidRLPErrorData> { | ||
} | ||
/** | ||
* Errors enum. | ||
*/ | ||
declare enum RLP_ERRORS { | ||
INVALID_RLP = "INVALID_RLP" | ||
} | ||
/** | ||
* Error to be thrown when the private key is invalid. | ||
*/ | ||
declare class InvalidSecp256k1PrivateKeyError extends ErrorBase<SECP256K1.INVALID_SECP256k1_PRIVATE_KEY, DefaultErrorData> { | ||
} | ||
/** | ||
* Error to be thrown when the message hash is invalid. | ||
*/ | ||
declare class InvalidSecp256k1MessageHashError extends ErrorBase<SECP256K1.INVALID_SECP256k1_MESSAGE_HASH, DefaultErrorData> { | ||
} | ||
/** | ||
* Error to be thrown when the signature is invalid. | ||
*/ | ||
declare class InvalidSecp256k1SignatureError extends ErrorBase<SECP256K1.INVALID_SECP256k1_SIGNATURE, DefaultErrorData> { | ||
} | ||
/** | ||
* Error to be thrown when the signature recovery is invalid. | ||
*/ | ||
declare class InvalidSecp256k1SignatureRecoveryError extends ErrorBase<SECP256K1.INVALID_SECP256k1_SIGNATURE_RECOVERY, DefaultErrorData> { | ||
} | ||
/** | ||
* Errors enum. | ||
*/ | ||
declare enum SECP256K1 { | ||
INVALID_SECP256k1_PRIVATE_KEY = "INVALID_SECP256k1_PRIVATE_KEY", | ||
INVALID_SECP256k1_MESSAGE_HASH = "INVALID_SECP256k1_MESSAGE_HASH", | ||
INVALID_SECP256k1_SIGNATURE = "INVALID_SECP256k1_SIGNATURE", | ||
INVALID_SECP256k1_SIGNATURE_RECOVERY = "INVALID_SECP256k1_SIGNATURE_RECOVERY" | ||
} | ||
/** | ||
* Invalid Transaction to sign. It is already signed. | ||
*/ | ||
declare class TransactionAlreadySignedError extends ErrorBase<TRANSACTION.ALREADY_SIGNED, DefaultErrorData> { | ||
} | ||
/** | ||
* Transaction not signed. | ||
*/ | ||
declare class TransactionNotSignedError extends ErrorBase<TRANSACTION.NOT_SIGNED, DefaultErrorData> { | ||
} | ||
/** | ||
* Invalid Transaction body. | ||
*/ | ||
declare class TransactionBodyError extends ErrorBase<TRANSACTION.INVALID_TRANSACTION_BODY, DefaultErrorData> { | ||
} | ||
/** | ||
* Invalid Delegation feature. | ||
*/ | ||
declare class TransactionDelegationError extends ErrorBase<TRANSACTION.INVALID_DELEGATION, DefaultErrorData> { | ||
} | ||
/** | ||
* Error to be thrown when the private key is missing. | ||
*/ | ||
declare class TransactionMissingPrivateKeyError extends ErrorBase<TRANSACTION.MISSING_PRIVATE_KEY, DefaultErrorData> { | ||
} | ||
/** | ||
* Errors enum. | ||
*/ | ||
declare enum TRANSACTION { | ||
ALREADY_SIGNED = "ALREADY_SIGNED", | ||
NOT_SIGNED = "NOT_SIGNED", | ||
INVALID_TRANSACTION_BODY = "INVALID_TRANSACTION_BODY", | ||
INVALID_DELEGATION = "INVALID_DELEGATION", | ||
MISSING_PRIVATE_KEY = "MISSING_PRIVATE_KEY" | ||
} | ||
/** | ||
* HTTP Client Error. | ||
*/ | ||
interface HTTPClientErrorData { | ||
status?: number; | ||
method?: string; | ||
url?: string; | ||
text?: string; | ||
message?: string; | ||
} | ||
/** | ||
* Client error to be thrown when a http request fails. | ||
*/ | ||
declare class HTTPClientError extends ErrorBase<HTTP_CLIENT.INVALID_HTTP_REQUEST, HTTPClientErrorData> { | ||
} | ||
/** | ||
* Errors enum. | ||
*/ | ||
declare enum HTTP_CLIENT { | ||
INVALID_HTTP_REQUEST = "INVALID_HTTP_REQUEST" | ||
} | ||
/** | ||
* POLL Error. | ||
*/ | ||
interface PollErrorData { | ||
message?: string; | ||
functionName?: string; | ||
} | ||
/** | ||
* Client error to be thrown when a http request fails. | ||
*/ | ||
declare class PollExecutionError extends ErrorBase<POLL_ERROR.POLL_EXECUTION_ERROR, PollErrorData> { | ||
} | ||
/** | ||
* Errors enum. | ||
*/ | ||
declare enum POLL_ERROR { | ||
POLL_EXECUTION_ERROR = "POLL_EXECUTION_ERROR" | ||
} | ||
/** | ||
* Not implemented function | ||
*/ | ||
declare class NotImplementedError extends ErrorBase<FUNCTION.NOT_IMPLEMENTED, DefaultErrorData> { | ||
} | ||
/** | ||
* Errors enum. | ||
*/ | ||
declare enum FUNCTION { | ||
NOT_IMPLEMENTED = "NOT_IMPLEMENTED" | ||
} | ||
/** | ||
* Errors implementation of EIP-1193 provider standard. | ||
* | ||
* @see https://eips.ethereum.org/EIPS/eip-1193#errors | ||
* @see https://eips.ethereum.org/EIPS/eip-1193#provider-errors | ||
*/ | ||
/** | ||
* HTTP Client Error. | ||
* | ||
* @NOTE: code parameter is required to be fully compatible with EIP-1193. | ||
* When we will throw error, we will use EIP1193.CODE_..., but for syntactic sugar | ||
* we will have code as number into error data. | ||
*/ | ||
interface EIP1193ProviderRpcErrorData { | ||
code: 4001 | 4100 | 4200 | 4900 | 4901; | ||
data?: unknown; | ||
} | ||
/** | ||
* The user rejected the request. | ||
*/ | ||
declare class EIP1193UserRejectedRequest extends ErrorBase<EIP1193.USER_REJECTED_REQUEST, EIP1193ProviderRpcErrorData> { | ||
} | ||
/** | ||
* The requested method and/or account has not been authorized by the user. | ||
*/ | ||
declare class EIP1193Unauthorized extends ErrorBase<EIP1193.UNAUTHORIZED, EIP1193ProviderRpcErrorData> { | ||
} | ||
/** | ||
* The Provider does not support the requested method. | ||
*/ | ||
declare class EIP1193UnsupportedMethod extends ErrorBase<EIP1193.UNSUPPORTED_METHOD, EIP1193ProviderRpcErrorData> { | ||
} | ||
/** | ||
* The Provider is disconnected from all chains. | ||
*/ | ||
declare class EIP1193Disconnected extends ErrorBase<EIP1193.DISCONNECTED, EIP1193ProviderRpcErrorData> { | ||
} | ||
/** | ||
* The Provider is not connected to the requested chain. | ||
* | ||
* @NOTE 4900 is intended to indicate that the Provider is disconnected from all chains, | ||
* while 4901 is intended to indicate that the Provider is disconnected from a specific chain only. | ||
* In other words, 4901 implies that the Provider is connected to other chains, just not the requested one. | ||
*/ | ||
declare class EIP1193ChainDisconnected extends ErrorBase<EIP1193.CHAIN_DISCONNECTED, EIP1193ProviderRpcErrorData> { | ||
} | ||
/** | ||
* Errors enum. | ||
* | ||
* @see https://eips.ethereum.org/EIPS/eip-1193#rpc-errors | ||
*/ | ||
declare enum EIP1193 { | ||
/** | ||
* The user rejected the request. | ||
*/ | ||
USER_REJECTED_REQUEST = "USER_REJECTED_REQUEST", | ||
/** | ||
* The requested method and/or account has not been authorized by the user. | ||
*/ | ||
UNAUTHORIZED = "UNAUTHORIZED", | ||
/** | ||
* The Provider does not support the requested method. | ||
*/ | ||
UNSUPPORTED_METHOD = "UNSUPPORTED METHOD", | ||
/** | ||
* The Provider is disconnected from all chains. | ||
*/ | ||
DISCONNECTED = "DISCONNECTED", | ||
/** | ||
* The Provider is not connected to the requested chain. | ||
* | ||
* @NOTE 4900 is intended to indicate that the Provider is disconnected from all chains, | ||
* while 4901 is intended to indicate that the Provider is disconnected from a specific chain only. | ||
* In other words, 4901 implies that the Provider is connected to other chains, just not the requested one. | ||
*/ | ||
CHAIN_DISCONNECTED = "CHAIN_DISCONNECTED" | ||
} | ||
/** | ||
* Get correct error code by error message enum. | ||
*/ | ||
declare const getEIP1193ErrorCode: (error: EIP1193) => 4001 | 4100 | 4200 | 4900 | 4901; | ||
/** | ||
* Errors implementation of JSON-RPC standard. | ||
* | ||
* @see https://docs.infura.io/networks/ethereum/json-rpc-methods | ||
* @see https://github.com/ethereum/go-ethereum/blob/master/rpc/errors.go | ||
*/ | ||
/** | ||
* HTTP Client Error. | ||
* | ||
* @NOTE: code parameter is required to be fully compatible with EIP-1193. | ||
* When we will throw error, we will use EIP1193.CODE_..., but for syntactic sugar | ||
* we will have code as number into error data. | ||
*/ | ||
interface JSONRPCErrorData { | ||
code: -32700 | -32600 | -32601 | -32602 | -32603 | -32000; | ||
message: string; | ||
} | ||
/** | ||
* JSON is not a valid request object | ||
*/ | ||
declare class JSONRPCInvalidRequest extends ErrorBase<JSONRPC.INVALID_REQUEST, JSONRPCErrorData> { | ||
} | ||
/** | ||
* Invalid method parameters | ||
*/ | ||
declare class JSONRPCInvalidParams extends ErrorBase<JSONRPC.INVALID_PARAMS, JSONRPCErrorData> { | ||
} | ||
/** | ||
* Internal JSON-RPC error | ||
*/ | ||
declare class JSONRPCInternalError extends ErrorBase<JSONRPC.INTERNAL_ERROR, JSONRPCErrorData> { | ||
} | ||
/** | ||
* Default error | ||
* | ||
* @see https://github.com/ethereum/go-ethereum/blob/master/rpc/errors.go | ||
*/ | ||
declare class JSONRPCDefaultError extends ErrorBase<JSONRPC.DEFAULT, JSONRPCErrorData> { | ||
} | ||
/** | ||
* Errors enum. | ||
* | ||
* @see https://eips.ethereum.org/EIPS/eip-1193#rpc-errors | ||
*/ | ||
declare enum JSONRPC { | ||
INVALID_REQUEST = "INVALID_REQUEST", | ||
INVALID_PARAMS = "INVALID_PARAMS", | ||
INTERNAL_ERROR = "INTERNAL_ERROR", | ||
DEFAULT = "DEFAULT" | ||
} | ||
/** | ||
* Get correct error code by error message enum. | ||
*/ | ||
declare const getJSONRPCErrorCode: (error: JSONRPC) => -32600 | -32602 | -32603 | -32000; | ||
/** | ||
* The `ProviderRpcError` error is thrown when the provider returns an error | ||
* | ||
* @link [ProviderRpcError](https://eips.ethereum.org/EIPS/eip-1193#provider-errors) | ||
*/ | ||
declare class ProviderRpcError extends Error { | ||
/** | ||
* The error code as specified in EIP-1193 or EIP-1474 | ||
* | ||
* @link [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474#error-codes) | ||
* @link [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193#provider-errors) | ||
*/ | ||
code: number; | ||
/** | ||
* Contains optional extra information about the error | ||
*/ | ||
data?: unknown; | ||
/** | ||
* | ||
* @param code - The error code as specified in EIP-1193 or EIP-1474 | ||
* @param message - The error message | ||
* @param data - Contains optional extra information about the error | ||
*/ | ||
constructor(code: number, message?: string, data?: unknown); | ||
} | ||
/** | ||
* Function to build the error message. | ||
@@ -668,2 +123,11 @@ * Here, we can customize the error message format. | ||
/** | ||
* Cannot find transaction error. | ||
* | ||
* WHEN TO USE: | ||
* * Error will be thrown when the transaction is not into the blockchain. | ||
*/ | ||
declare class ContractDeploymentFailed extends VechainSDKError<ObjectErrorData> { | ||
} | ||
/** | ||
* Invalid data type error. | ||
@@ -677,4 +141,24 @@ * | ||
} | ||
/** | ||
* Unsupported operation error. | ||
* | ||
* WHEN TO USE: | ||
* * This error will be thrown when an operation is not supported. | ||
* -e.g.- into the ethers adapter, when the runner does not support sending transactions. | ||
*/ | ||
declare class UnsupportedOperation extends VechainSDKError<ObjectErrorData> { | ||
} | ||
/** | ||
* Function not implemented error. | ||
* | ||
* WHEN TO USE: | ||
* * This error will be thrown when a function is not implemented. | ||
*/ | ||
declare class FunctionNotImplemented extends VechainSDKError<{ | ||
functionName: string; | ||
} & ObjectErrorData> { | ||
} | ||
/** | ||
* Invalid HDNode mnemonic error. | ||
@@ -705,2 +189,16 @@ * | ||
/** | ||
* Http invalid request error | ||
* | ||
* WHEN TO USE: | ||
* * Error will be thrown when an invalid HTTP request fails | ||
*/ | ||
declare class InvalidHTTPRequest extends VechainSDKError<{ | ||
method: string; | ||
url: string; | ||
message?: string; | ||
status?: number; | ||
}> { | ||
} | ||
/** | ||
* Invalid keystore error. | ||
@@ -723,2 +221,79 @@ * | ||
/** | ||
* Poll execution error. | ||
* | ||
* WHEN TO USE: | ||
* * Error will be thrown when a poll execution of a function throw error | ||
*/ | ||
declare class PollExecution extends VechainSDKError<{ | ||
functionName: string; | ||
}> { | ||
} | ||
/** | ||
* Provider generic error. | ||
* | ||
* WHEN TO USE: | ||
* * It is a subclass of all provider errors | ||
* | ||
* @see{https://www.jsonrpc.org/specification#error_object} | ||
*/ | ||
declare class JSONRPCProviderError<TJSONRpcErrorCode extends -32700 | -32600 | -32601 | -32602 | -32603 | -32000> extends VechainSDKError<{ | ||
code: TJSONRpcErrorCode; | ||
message: string; | ||
data: ObjectErrorData; | ||
}> { | ||
readonly methodName: string; | ||
readonly innerError?: unknown; | ||
constructor(methodName: string, code: TJSONRpcErrorCode, message: string, data: ObjectErrorData, innerError?: unknown); | ||
} | ||
/** | ||
* Parse error. | ||
* | ||
* WHEN TO USE: | ||
* * Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text. | ||
*/ | ||
declare class JSONRPCParseError extends JSONRPCProviderError<-32700> { | ||
} | ||
/** | ||
* Invalid request. | ||
* | ||
* WHEN TO USE: | ||
* * The JSON sent is not a valid Request object. | ||
*/ | ||
declare class JSONRPCInvalidRequest extends JSONRPCProviderError<-32600> { | ||
} | ||
/** | ||
* Method not found. | ||
* | ||
* WHEN TO USE: | ||
* * The method does not exist / is not available. | ||
*/ | ||
declare class JSONRPCMethodNotFound extends JSONRPCProviderError<-32601> { | ||
} | ||
/** | ||
* Invalid params. | ||
* | ||
* WHEN TO USE: | ||
* * Invalid method parameter(s). | ||
*/ | ||
declare class JSONRPCInvalidParams extends JSONRPCProviderError<-32602> { | ||
} | ||
/** | ||
* Internal JSON-RPC error. | ||
* | ||
* WHEN TO USE: | ||
* * Internal JSON-RPC error. | ||
*/ | ||
declare class JSONRPCInternalError extends JSONRPCProviderError<-32603> { | ||
} | ||
/** | ||
* Server error. | ||
* | ||
* WHEN TO USE: | ||
* * Reserved for implementation-defined server-errors. | ||
*/ | ||
declare class JSONRPCServerError extends JSONRPCProviderError<-32000> { | ||
} | ||
/** | ||
* Invalid RLP error. | ||
@@ -793,160 +368,30 @@ * | ||
*/ | ||
declare class NotDelegatedTransaction extends VechainSDKError<undefined> { | ||
declare class NotDelegatedTransaction extends VechainSDKError<undefined | { | ||
delegatorUrl: string; | ||
}> { | ||
} | ||
/** | ||
* Builds an error object with the error code provided and specified parameters. | ||
* Cannot find transaction error. | ||
* | ||
* @param {string} methodName - The name of the method where the error occurred. | ||
* @param {ErrorCodeT} code - The error code. | ||
* @param {string} message - The error message. | ||
* @param {DataTypeT} [data] - Additional data associated with the error. | ||
* @param {unknown} [innerError] - An inner error associated with the error. | ||
* | ||
* @returns {ErrorType<ErrorCodeT>} - The error object. | ||
* | ||
* @throws {Error} - If the error code is invalid. | ||
* | ||
* @remarks | ||
* **IMPORTANT: no sensitive data should be passed as any parameter.** | ||
* WHEN TO USE: | ||
* * Error will be thrown when the transaction is not into the blockchain. | ||
*/ | ||
declare function buildError<ErrorCodeT extends ErrorCode, DataTypeT extends DataType<ErrorCodeT>>(methodName: string, code: ErrorCodeT, message: string, data?: DataTypeT, innerError?: unknown): ErrorType<ErrorCodeT>; | ||
declare class CannotFindTransaction extends VechainSDKError<{ | ||
transactionHash?: string; | ||
networkUrl?: string; | ||
}> { | ||
} | ||
/** | ||
* Builds a ProviderRpcError object with the given code, message, and data, | ||
* according [Rpc Errors](https://eips.ethereum.org/EIPS/eip-1193#rpc-errors) | ||
* | ||
* @param {EIP1193 | JSONRPC} code - The error code. | ||
* @param {string} message - The error message. | ||
* @param {DataTypeT} [data] - Optional data associated with the error. | ||
* @return {ProviderRpcError} - The constructed ProviderRpcError object. | ||
* | ||
* @remarks | ||
* **IMPORTANT: no sensitive data should be passed as any parameter.** | ||
*/ | ||
declare function buildProviderError<ErrorCodeT extends ErrorCode, DataTypeT extends DataType<ErrorCodeT>>(code: EIP1193 | JSONRPC, message: string, data?: DataTypeT): ProviderRpcError; | ||
/** | ||
* Function to stringify data correctly. | ||
* Some data types like Error, Map, Set, etc. are not stringified correctly by JSON.stringify. | ||
* This function handles those cases and avoid circular references. | ||
* | ||
* @param data - The data to be stringified. | ||
* @returns The stringified data. | ||
*/ | ||
declare const stringifyData: (data: unknown) => string; | ||
/** | ||
* Builds an error message with the specified method name, error message, input data, and optional inner error. | ||
* | ||
* @param {string} methodName - The name of the method that failed. | ||
* @param {string} errorMessage - The specific reason for the failure. | ||
* @param {DataType} inputData - The input data used by the method. | ||
* @param {Error} [innerError] - An optional inner error that caused the failure. | ||
* | ||
* @return {string} - The built error message. | ||
* | ||
* @remarks | ||
* **IMPORTANT: no sensitive data should be passed as any parameter.** | ||
*/ | ||
declare function buildErrorMessage<ErrorCodeT extends ErrorCode, DataTypeT extends DataType<ErrorCodeT>>(methodName: string, errorMessage: string, inputData: DataTypeT, innerError?: Error): string; | ||
/** | ||
* Asserts that a given condition is true. If the condition is false, an error is thrown. | ||
* | ||
* @param {string} methodName - The name of the method or function being asserted. | ||
* @param {boolean} condition - The condition to be asserted. | ||
* @param {ErrorCode} code - The error code to be associated with the error if the condition is false. | ||
* @param {string} message - The error message to be associated with the error if the condition is false. | ||
* @param {DataType} [data] - Additional data to be associated with the error if the condition is false. | ||
* @param {unknown} [innerError] - The inner error to be associated with the error if the condition is false. | ||
* | ||
* @returns {void} | ||
* | ||
* @throws {Error} An error object if the condition is false. | ||
* | ||
* @remarks | ||
* **IMPORTANT: no sensitive data should be passed as any parameter.** | ||
*/ | ||
declare function assert<ErrorCodeT extends ErrorCode, DataTypeT extends DataType<ErrorCodeT>>(methodName: string, condition: boolean, code: ErrorCodeT, message: string, data?: DataTypeT, innerError?: unknown): void; | ||
/** | ||
* Asserts that the given error is an instance of the Error class. | ||
* If the error is an instance of Error, it is returned. | ||
* If the error is not an instance of Error, a new Error object is created with a descriptive message. | ||
* | ||
* @param {unknown} error - The error to be asserted. | ||
* @return {Error} - The error if it is an instance of Error, or a new Error object if it is not. | ||
* | ||
* @remarks | ||
* **IMPORTANT: no sensitive data should be passed as any parameter.** | ||
*/ | ||
declare function assertInnerError(error: unknown): Error; | ||
type errors_ABI = ABI; | ||
declare const errors_ABI: typeof ABI; | ||
type errors_ADDRESS = ADDRESS; | ||
declare const errors_ADDRESS: typeof ADDRESS; | ||
type errors_BLOOM = BLOOM; | ||
declare const errors_BLOOM: typeof BLOOM; | ||
type errors_CERTIFICATE = CERTIFICATE; | ||
declare const errors_CERTIFICATE: typeof CERTIFICATE; | ||
type errors_CONTRACT = CONTRACT; | ||
declare const errors_CONTRACT: typeof CONTRACT; | ||
type errors_CertificateInvalidSignatureFormatError = CertificateInvalidSignatureFormatError; | ||
declare const errors_CertificateInvalidSignatureFormatError: typeof CertificateInvalidSignatureFormatError; | ||
type errors_CertificateInvalidSignerError = CertificateInvalidSignerError; | ||
declare const errors_CertificateInvalidSignerError: typeof CertificateInvalidSignerError; | ||
type errors_CertificateNotSignedError = CertificateNotSignedError; | ||
declare const errors_CertificateNotSignedError: typeof CertificateNotSignedError; | ||
type errors_CannotFindTransaction = CannotFindTransaction; | ||
declare const errors_CannotFindTransaction: typeof CannotFindTransaction; | ||
type errors_CertificateSignature = CertificateSignature; | ||
declare const errors_CertificateSignature: typeof CertificateSignature; | ||
type errors_ContractDeploymentFailedError = ContractDeploymentFailedError; | ||
declare const errors_ContractDeploymentFailedError: typeof ContractDeploymentFailedError; | ||
type errors_ContractInterfaceError = ContractInterfaceError; | ||
declare const errors_ContractInterfaceError: typeof ContractInterfaceError; | ||
type errors_DATA = DATA; | ||
declare const errors_DATA: typeof DATA; | ||
type errors_DataType<ErrorCodeT extends ErrorCode> = DataType<ErrorCodeT>; | ||
type errors_DefaultErrorData = DefaultErrorData; | ||
type errors_EIP1193 = EIP1193; | ||
declare const errors_EIP1193: typeof EIP1193; | ||
type errors_EIP1193ChainDisconnected = EIP1193ChainDisconnected; | ||
declare const errors_EIP1193ChainDisconnected: typeof EIP1193ChainDisconnected; | ||
type errors_EIP1193Disconnected = EIP1193Disconnected; | ||
declare const errors_EIP1193Disconnected: typeof EIP1193Disconnected; | ||
type errors_EIP1193ProviderRpcErrorData = EIP1193ProviderRpcErrorData; | ||
type errors_EIP1193Unauthorized = EIP1193Unauthorized; | ||
declare const errors_EIP1193Unauthorized: typeof EIP1193Unauthorized; | ||
type errors_EIP1193UnsupportedMethod = EIP1193UnsupportedMethod; | ||
declare const errors_EIP1193UnsupportedMethod: typeof EIP1193UnsupportedMethod; | ||
type errors_EIP1193UserRejectedRequest = EIP1193UserRejectedRequest; | ||
declare const errors_EIP1193UserRejectedRequest: typeof EIP1193UserRejectedRequest; | ||
declare const errors_ERROR_CODES: typeof ERROR_CODES; | ||
type errors_ErrorBase<ErrorCodeT extends ErrorCode, DataTypeT> = ErrorBase<ErrorCodeT, DataTypeT>; | ||
declare const errors_ErrorBase: typeof ErrorBase; | ||
declare const errors_ErrorClassMap: typeof ErrorClassMap; | ||
type errors_ErrorCode = ErrorCode; | ||
type errors_ErrorType<ErrorCodeT> = ErrorType<ErrorCodeT>; | ||
type errors_FUNCTION = FUNCTION; | ||
declare const errors_FUNCTION: typeof FUNCTION; | ||
type errors_HDNODE = HDNODE; | ||
declare const errors_HDNODE: typeof HDNODE; | ||
type errors_HTTPClientError = HTTPClientError; | ||
declare const errors_HTTPClientError: typeof HTTPClientError; | ||
type errors_HTTPClientErrorData = HTTPClientErrorData; | ||
type errors_HTTP_CLIENT = HTTP_CLIENT; | ||
declare const errors_HTTP_CLIENT: typeof HTTP_CLIENT; | ||
type errors_InvalidAbiDataToDecodeError = InvalidAbiDataToDecodeError; | ||
declare const errors_InvalidAbiDataToDecodeError: typeof InvalidAbiDataToDecodeError; | ||
type errors_InvalidAbiDataToEncodeError = InvalidAbiDataToEncodeError; | ||
declare const errors_InvalidAbiDataToEncodeError: typeof InvalidAbiDataToEncodeError; | ||
type errors_ContractDeploymentFailed = ContractDeploymentFailed; | ||
declare const errors_ContractDeploymentFailed: typeof ContractDeploymentFailed; | ||
type errors_FunctionNotImplemented = FunctionNotImplemented; | ||
declare const errors_FunctionNotImplemented: typeof FunctionNotImplemented; | ||
type errors_InvalidAbiDataToEncodeOrDecode = InvalidAbiDataToEncodeOrDecode; | ||
declare const errors_InvalidAbiDataToEncodeOrDecode: typeof InvalidAbiDataToEncodeOrDecode; | ||
type errors_InvalidAbiEventError = InvalidAbiEventError; | ||
declare const errors_InvalidAbiEventError: typeof InvalidAbiEventError; | ||
type errors_InvalidAbiFormatTypeError = InvalidAbiFormatTypeError; | ||
declare const errors_InvalidAbiFormatTypeError: typeof InvalidAbiFormatTypeError; | ||
type errors_InvalidAbiFragment = InvalidAbiFragment; | ||
declare const errors_InvalidAbiFragment: typeof InvalidAbiFragment; | ||
type errors_InvalidAbiFunctionError = InvalidAbiFunctionError; | ||
declare const errors_InvalidAbiFunctionError: typeof InvalidAbiFunctionError; | ||
type errors_InvalidAbiSignatureFormat = InvalidAbiSignatureFormat; | ||
@@ -956,66 +401,28 @@ declare const errors_InvalidAbiSignatureFormat: typeof InvalidAbiSignatureFormat; | ||
declare const errors_InvalidAddress: typeof InvalidAddress; | ||
type errors_InvalidAddressError = InvalidAddressError; | ||
declare const errors_InvalidAddressError: typeof InvalidAddressError; | ||
type errors_InvalidBloom = InvalidBloom; | ||
declare const errors_InvalidBloom: typeof InvalidBloom; | ||
type errors_InvalidBloomError = InvalidBloomError; | ||
declare const errors_InvalidBloomError: typeof InvalidBloomError; | ||
type errors_InvalidBloomParams = InvalidBloomParams; | ||
declare const errors_InvalidBloomParams: typeof InvalidBloomParams; | ||
type errors_InvalidDataReturnTypeError = InvalidDataReturnTypeError; | ||
declare const errors_InvalidDataReturnTypeError: typeof InvalidDataReturnTypeError; | ||
type errors_InvalidDataType = InvalidDataType; | ||
declare const errors_InvalidDataType: typeof InvalidDataType; | ||
type errors_InvalidDataTypeError = InvalidDataTypeError; | ||
declare const errors_InvalidDataTypeError: typeof InvalidDataTypeError; | ||
type errors_InvalidHDNode = InvalidHDNode; | ||
declare const errors_InvalidHDNode: typeof InvalidHDNode; | ||
type errors_InvalidHDNodeChaincodeError = InvalidHDNodeChaincodeError; | ||
declare const errors_InvalidHDNodeChaincodeError: typeof InvalidHDNodeChaincodeError; | ||
type errors_InvalidHDNodeDerivationPathError = InvalidHDNodeDerivationPathError; | ||
declare const errors_InvalidHDNodeDerivationPathError: typeof InvalidHDNodeDerivationPathError; | ||
type errors_InvalidHDNodeMnemonic = InvalidHDNodeMnemonic; | ||
declare const errors_InvalidHDNodeMnemonic: typeof InvalidHDNodeMnemonic; | ||
type errors_InvalidHDNodeMnemonicsError = InvalidHDNodeMnemonicsError; | ||
declare const errors_InvalidHDNodeMnemonicsError: typeof InvalidHDNodeMnemonicsError; | ||
type errors_InvalidHDNodePrivateKeyError = InvalidHDNodePrivateKeyError; | ||
declare const errors_InvalidHDNodePrivateKeyError: typeof InvalidHDNodePrivateKeyError; | ||
type errors_InvalidHDNodePublicKeyError = InvalidHDNodePublicKeyError; | ||
declare const errors_InvalidHDNodePublicKeyError: typeof InvalidHDNodePublicKeyError; | ||
type errors_InvalidKError = InvalidKError; | ||
declare const errors_InvalidKError: typeof InvalidKError; | ||
type errors_InvalidHTTPRequest = InvalidHTTPRequest; | ||
declare const errors_InvalidHTTPRequest: typeof InvalidHTTPRequest; | ||
type errors_InvalidKeystore = InvalidKeystore; | ||
declare const errors_InvalidKeystore: typeof InvalidKeystore; | ||
type errors_InvalidKeystoreError = InvalidKeystoreError; | ||
declare const errors_InvalidKeystoreError: typeof InvalidKeystoreError; | ||
type errors_InvalidKeystoreParams = InvalidKeystoreParams; | ||
declare const errors_InvalidKeystoreParams: typeof InvalidKeystoreParams; | ||
type errors_InvalidKeystorePasswordError = InvalidKeystorePasswordError; | ||
declare const errors_InvalidKeystorePasswordError: typeof InvalidKeystorePasswordError; | ||
type errors_InvalidRLP = InvalidRLP; | ||
declare const errors_InvalidRLP: typeof InvalidRLP; | ||
type errors_InvalidRLPError = InvalidRLPError; | ||
declare const errors_InvalidRLPError: typeof InvalidRLPError; | ||
type errors_InvalidRLPErrorData = InvalidRLPErrorData; | ||
type errors_InvalidSecp256k1MessageHash = InvalidSecp256k1MessageHash; | ||
declare const errors_InvalidSecp256k1MessageHash: typeof InvalidSecp256k1MessageHash; | ||
type errors_InvalidSecp256k1MessageHashError = InvalidSecp256k1MessageHashError; | ||
declare const errors_InvalidSecp256k1MessageHashError: typeof InvalidSecp256k1MessageHashError; | ||
type errors_InvalidSecp256k1PrivateKey = InvalidSecp256k1PrivateKey; | ||
declare const errors_InvalidSecp256k1PrivateKey: typeof InvalidSecp256k1PrivateKey; | ||
type errors_InvalidSecp256k1PrivateKeyError = InvalidSecp256k1PrivateKeyError; | ||
declare const errors_InvalidSecp256k1PrivateKeyError: typeof InvalidSecp256k1PrivateKeyError; | ||
type errors_InvalidSecp256k1Signature = InvalidSecp256k1Signature; | ||
declare const errors_InvalidSecp256k1Signature: typeof InvalidSecp256k1Signature; | ||
type errors_InvalidSecp256k1SignatureError = InvalidSecp256k1SignatureError; | ||
declare const errors_InvalidSecp256k1SignatureError: typeof InvalidSecp256k1SignatureError; | ||
type errors_InvalidSecp256k1SignatureRecoveryError = InvalidSecp256k1SignatureRecoveryError; | ||
declare const errors_InvalidSecp256k1SignatureRecoveryError: typeof InvalidSecp256k1SignatureRecoveryError; | ||
type errors_InvalidTransactionField = InvalidTransactionField; | ||
declare const errors_InvalidTransactionField: typeof InvalidTransactionField; | ||
type errors_JSONRPC = JSONRPC; | ||
declare const errors_JSONRPC: typeof JSONRPC; | ||
type errors_JSONRPCDefaultError = JSONRPCDefaultError; | ||
declare const errors_JSONRPCDefaultError: typeof JSONRPCDefaultError; | ||
type errors_JSONRPCErrorData = JSONRPCErrorData; | ||
type errors_JSONRPCInternalError = JSONRPCInternalError; | ||
@@ -1027,49 +434,28 @@ declare const errors_JSONRPCInternalError: typeof JSONRPCInternalError; | ||
declare const errors_JSONRPCInvalidRequest: typeof JSONRPCInvalidRequest; | ||
type errors_KEYSTORE = KEYSTORE; | ||
declare const errors_KEYSTORE: typeof KEYSTORE; | ||
type errors_JSONRPCMethodNotFound = JSONRPCMethodNotFound; | ||
declare const errors_JSONRPCMethodNotFound: typeof JSONRPCMethodNotFound; | ||
type errors_JSONRPCParseError = JSONRPCParseError; | ||
declare const errors_JSONRPCParseError: typeof JSONRPCParseError; | ||
type errors_JSONRPCProviderError<TJSONRpcErrorCode extends -32700 | -32600 | -32601 | -32602 | -32603 | -32000> = JSONRPCProviderError<TJSONRpcErrorCode>; | ||
declare const errors_JSONRPCProviderError: typeof JSONRPCProviderError; | ||
type errors_JSONRPCServerError = JSONRPCServerError; | ||
declare const errors_JSONRPCServerError: typeof JSONRPCServerError; | ||
type errors_NotDelegatedTransaction = NotDelegatedTransaction; | ||
declare const errors_NotDelegatedTransaction: typeof NotDelegatedTransaction; | ||
type errors_NotImplementedError = NotImplementedError; | ||
declare const errors_NotImplementedError: typeof NotImplementedError; | ||
type errors_ObjectErrorData = ObjectErrorData; | ||
type errors_POLL_ERROR = POLL_ERROR; | ||
declare const errors_POLL_ERROR: typeof POLL_ERROR; | ||
type errors_PollErrorData = PollErrorData; | ||
type errors_PollExecutionError = PollExecutionError; | ||
declare const errors_PollExecutionError: typeof PollExecutionError; | ||
type errors_ProviderRpcError = ProviderRpcError; | ||
declare const errors_ProviderRpcError: typeof ProviderRpcError; | ||
type errors_RLP_ERRORS = RLP_ERRORS; | ||
declare const errors_RLP_ERRORS: typeof RLP_ERRORS; | ||
type errors_SECP256K1 = SECP256K1; | ||
declare const errors_SECP256K1: typeof SECP256K1; | ||
type errors_TRANSACTION = TRANSACTION; | ||
declare const errors_TRANSACTION: typeof TRANSACTION; | ||
type errors_TransactionAlreadySignedError = TransactionAlreadySignedError; | ||
declare const errors_TransactionAlreadySignedError: typeof TransactionAlreadySignedError; | ||
type errors_TransactionBodyError = TransactionBodyError; | ||
declare const errors_TransactionBodyError: typeof TransactionBodyError; | ||
type errors_TransactionDelegationError = TransactionDelegationError; | ||
declare const errors_TransactionDelegationError: typeof TransactionDelegationError; | ||
type errors_TransactionMissingPrivateKeyError = TransactionMissingPrivateKeyError; | ||
declare const errors_TransactionMissingPrivateKeyError: typeof TransactionMissingPrivateKeyError; | ||
type errors_TransactionNotSignedError = TransactionNotSignedError; | ||
declare const errors_TransactionNotSignedError: typeof TransactionNotSignedError; | ||
type errors_PollExecution = PollExecution; | ||
declare const errors_PollExecution: typeof PollExecution; | ||
type errors_UnavailableTransactionField = UnavailableTransactionField; | ||
declare const errors_UnavailableTransactionField: typeof UnavailableTransactionField; | ||
type errors_UnsupportedOperation = UnsupportedOperation; | ||
declare const errors_UnsupportedOperation: typeof UnsupportedOperation; | ||
type errors_VechainSDKError<TErrorDataType> = VechainSDKError<TErrorDataType>; | ||
declare const errors_VechainSDKError: typeof VechainSDKError; | ||
declare const errors_assert: typeof assert; | ||
declare const errors_assertInnerError: typeof assertInnerError; | ||
declare const errors_buildError: typeof buildError; | ||
declare const errors_buildErrorMessage: typeof buildErrorMessage; | ||
declare const errors_buildProviderError: typeof buildProviderError; | ||
declare const errors_createErrorMessage: typeof createErrorMessage; | ||
declare const errors_getEIP1193ErrorCode: typeof getEIP1193ErrorCode; | ||
declare const errors_getJSONRPCErrorCode: typeof getJSONRPCErrorCode; | ||
declare const errors_stringifyData: typeof stringifyData; | ||
declare namespace errors { | ||
export { errors_ABI as ABI, errors_ADDRESS as ADDRESS, errors_BLOOM as BLOOM, errors_CERTIFICATE as CERTIFICATE, errors_CONTRACT as CONTRACT, errors_CertificateInvalidSignatureFormatError as CertificateInvalidSignatureFormatError, errors_CertificateInvalidSignerError as CertificateInvalidSignerError, errors_CertificateNotSignedError as CertificateNotSignedError, errors_CertificateSignature as CertificateSignature, errors_ContractDeploymentFailedError as ContractDeploymentFailedError, errors_ContractInterfaceError as ContractInterfaceError, errors_DATA as DATA, type errors_DataType as DataType, type errors_DefaultErrorData as DefaultErrorData, errors_EIP1193 as EIP1193, errors_EIP1193ChainDisconnected as EIP1193ChainDisconnected, errors_EIP1193Disconnected as EIP1193Disconnected, type errors_EIP1193ProviderRpcErrorData as EIP1193ProviderRpcErrorData, errors_EIP1193Unauthorized as EIP1193Unauthorized, errors_EIP1193UnsupportedMethod as EIP1193UnsupportedMethod, errors_EIP1193UserRejectedRequest as EIP1193UserRejectedRequest, errors_ERROR_CODES as ERROR_CODES, errors_ErrorBase as ErrorBase, errors_ErrorClassMap as ErrorClassMap, type errors_ErrorCode as ErrorCode, type errors_ErrorType as ErrorType, errors_FUNCTION as FUNCTION, errors_HDNODE as HDNODE, errors_HTTPClientError as HTTPClientError, type errors_HTTPClientErrorData as HTTPClientErrorData, errors_HTTP_CLIENT as HTTP_CLIENT, errors_InvalidAbiDataToDecodeError as InvalidAbiDataToDecodeError, errors_InvalidAbiDataToEncodeError as InvalidAbiDataToEncodeError, errors_InvalidAbiDataToEncodeOrDecode as InvalidAbiDataToEncodeOrDecode, errors_InvalidAbiEventError as InvalidAbiEventError, errors_InvalidAbiFormatTypeError as InvalidAbiFormatTypeError, errors_InvalidAbiFragment as InvalidAbiFragment, errors_InvalidAbiFunctionError as InvalidAbiFunctionError, errors_InvalidAbiSignatureFormat as InvalidAbiSignatureFormat, errors_InvalidAddress as InvalidAddress, errors_InvalidAddressError as InvalidAddressError, errors_InvalidBloom as InvalidBloom, errors_InvalidBloomError as InvalidBloomError, errors_InvalidBloomParams as InvalidBloomParams, errors_InvalidDataReturnTypeError as InvalidDataReturnTypeError, errors_InvalidDataType as InvalidDataType, errors_InvalidDataTypeError as InvalidDataTypeError, errors_InvalidHDNode as InvalidHDNode, errors_InvalidHDNodeChaincodeError as InvalidHDNodeChaincodeError, errors_InvalidHDNodeDerivationPathError as InvalidHDNodeDerivationPathError, errors_InvalidHDNodeMnemonic as InvalidHDNodeMnemonic, errors_InvalidHDNodeMnemonicsError as InvalidHDNodeMnemonicsError, errors_InvalidHDNodePrivateKeyError as InvalidHDNodePrivateKeyError, errors_InvalidHDNodePublicKeyError as InvalidHDNodePublicKeyError, errors_InvalidKError as InvalidKError, errors_InvalidKeystore as InvalidKeystore, errors_InvalidKeystoreError as InvalidKeystoreError, errors_InvalidKeystoreParams as InvalidKeystoreParams, errors_InvalidKeystorePasswordError as InvalidKeystorePasswordError, errors_InvalidRLP as InvalidRLP, errors_InvalidRLPError as InvalidRLPError, type errors_InvalidRLPErrorData as InvalidRLPErrorData, errors_InvalidSecp256k1MessageHash as InvalidSecp256k1MessageHash, errors_InvalidSecp256k1MessageHashError as InvalidSecp256k1MessageHashError, errors_InvalidSecp256k1PrivateKey as InvalidSecp256k1PrivateKey, errors_InvalidSecp256k1PrivateKeyError as InvalidSecp256k1PrivateKeyError, errors_InvalidSecp256k1Signature as InvalidSecp256k1Signature, errors_InvalidSecp256k1SignatureError as InvalidSecp256k1SignatureError, errors_InvalidSecp256k1SignatureRecoveryError as InvalidSecp256k1SignatureRecoveryError, errors_InvalidTransactionField as InvalidTransactionField, errors_JSONRPC as JSONRPC, errors_JSONRPCDefaultError as JSONRPCDefaultError, type errors_JSONRPCErrorData as JSONRPCErrorData, errors_JSONRPCInternalError as JSONRPCInternalError, errors_JSONRPCInvalidParams as JSONRPCInvalidParams, errors_JSONRPCInvalidRequest as JSONRPCInvalidRequest, errors_KEYSTORE as KEYSTORE, errors_NotDelegatedTransaction as NotDelegatedTransaction, errors_NotImplementedError as NotImplementedError, type errors_ObjectErrorData as ObjectErrorData, errors_POLL_ERROR as POLL_ERROR, type errors_PollErrorData as PollErrorData, errors_PollExecutionError as PollExecutionError, errors_ProviderRpcError as ProviderRpcError, errors_RLP_ERRORS as RLP_ERRORS, errors_SECP256K1 as SECP256K1, errors_TRANSACTION as TRANSACTION, errors_TransactionAlreadySignedError as TransactionAlreadySignedError, errors_TransactionBodyError as TransactionBodyError, errors_TransactionDelegationError as TransactionDelegationError, errors_TransactionMissingPrivateKeyError as TransactionMissingPrivateKeyError, errors_TransactionNotSignedError as TransactionNotSignedError, errors_UnavailableTransactionField as UnavailableTransactionField, errors_VechainSDKError as VechainSDKError, errors_assert as assert, errors_assertInnerError as assertInnerError, errors_buildError as buildError, errors_buildErrorMessage as buildErrorMessage, errors_buildProviderError as buildProviderError, errors_createErrorMessage as createErrorMessage, errors_getEIP1193ErrorCode as getEIP1193ErrorCode, errors_getJSONRPCErrorCode as getJSONRPCErrorCode, errors_stringifyData as stringifyData }; | ||
export { errors_CannotFindTransaction as CannotFindTransaction, errors_CertificateSignature as CertificateSignature, errors_ContractDeploymentFailed as ContractDeploymentFailed, errors_FunctionNotImplemented as FunctionNotImplemented, errors_InvalidAbiDataToEncodeOrDecode as InvalidAbiDataToEncodeOrDecode, errors_InvalidAbiFragment as InvalidAbiFragment, errors_InvalidAbiSignatureFormat as InvalidAbiSignatureFormat, errors_InvalidAddress as InvalidAddress, errors_InvalidBloom as InvalidBloom, errors_InvalidBloomParams as InvalidBloomParams, errors_InvalidDataType as InvalidDataType, errors_InvalidHDNode as InvalidHDNode, errors_InvalidHDNodeMnemonic as InvalidHDNodeMnemonic, errors_InvalidHTTPRequest as InvalidHTTPRequest, errors_InvalidKeystore as InvalidKeystore, errors_InvalidKeystoreParams as InvalidKeystoreParams, errors_InvalidRLP as InvalidRLP, errors_InvalidSecp256k1MessageHash as InvalidSecp256k1MessageHash, errors_InvalidSecp256k1PrivateKey as InvalidSecp256k1PrivateKey, errors_InvalidSecp256k1Signature as InvalidSecp256k1Signature, errors_InvalidTransactionField as InvalidTransactionField, errors_JSONRPCInternalError as JSONRPCInternalError, errors_JSONRPCInvalidParams as JSONRPCInvalidParams, errors_JSONRPCInvalidRequest as JSONRPCInvalidRequest, errors_JSONRPCMethodNotFound as JSONRPCMethodNotFound, errors_JSONRPCParseError as JSONRPCParseError, errors_JSONRPCProviderError as JSONRPCProviderError, errors_JSONRPCServerError as JSONRPCServerError, errors_NotDelegatedTransaction as NotDelegatedTransaction, type errors_ObjectErrorData as ObjectErrorData, errors_PollExecution as PollExecution, errors_UnavailableTransactionField as UnavailableTransactionField, errors_UnsupportedOperation as UnsupportedOperation, errors_VechainSDKError as VechainSDKError, errors_assertInnerError as assertInnerError, errors_createErrorMessage as createErrorMessage, errors_stringifyData as stringifyData }; | ||
} | ||
export { ABI, ADDRESS, BLOOM, CERTIFICATE, CONTRACT, CertificateInvalidSignatureFormatError, CertificateInvalidSignerError, CertificateNotSignedError, CertificateSignature, ContractDeploymentFailedError, ContractInterfaceError, DATA, type DataType, type DefaultErrorData, EIP1193, EIP1193ChainDisconnected, EIP1193Disconnected, type EIP1193ProviderRpcErrorData, EIP1193Unauthorized, EIP1193UnsupportedMethod, EIP1193UserRejectedRequest, ERROR_CODES, ErrorBase, ErrorClassMap, type ErrorCode, type ErrorType, FUNCTION, HDNODE, HTTPClientError, type HTTPClientErrorData, HTTP_CLIENT, InvalidAbiDataToDecodeError, InvalidAbiDataToEncodeError, InvalidAbiDataToEncodeOrDecode, InvalidAbiEventError, InvalidAbiFormatTypeError, InvalidAbiFragment, InvalidAbiFunctionError, InvalidAbiSignatureFormat, InvalidAddress, InvalidAddressError, InvalidBloom, InvalidBloomError, InvalidBloomParams, InvalidDataReturnTypeError, InvalidDataType, InvalidDataTypeError, InvalidHDNode, InvalidHDNodeChaincodeError, InvalidHDNodeDerivationPathError, InvalidHDNodeMnemonic, InvalidHDNodeMnemonicsError, InvalidHDNodePrivateKeyError, InvalidHDNodePublicKeyError, InvalidKError, InvalidKeystore, InvalidKeystoreError, InvalidKeystoreParams, InvalidKeystorePasswordError, InvalidRLP, InvalidRLPError, type InvalidRLPErrorData, InvalidSecp256k1MessageHash, InvalidSecp256k1MessageHashError, InvalidSecp256k1PrivateKey, InvalidSecp256k1PrivateKeyError, InvalidSecp256k1Signature, InvalidSecp256k1SignatureError, InvalidSecp256k1SignatureRecoveryError, InvalidTransactionField, JSONRPC, JSONRPCDefaultError, type JSONRPCErrorData, JSONRPCInternalError, JSONRPCInvalidParams, JSONRPCInvalidRequest, KEYSTORE, NotDelegatedTransaction, NotImplementedError, type ObjectErrorData, POLL_ERROR, type PollErrorData, PollExecutionError, ProviderRpcError, RLP_ERRORS, SECP256K1, TRANSACTION, TransactionAlreadySignedError, TransactionBodyError, TransactionDelegationError, TransactionMissingPrivateKeyError, TransactionNotSignedError, UnavailableTransactionField, VechainSDKError, assert, assertInnerError, buildError, buildErrorMessage, buildProviderError, createErrorMessage, errors, getEIP1193ErrorCode, getJSONRPCErrorCode, stringifyData }; | ||
export { CannotFindTransaction, CertificateSignature, ContractDeploymentFailed, FunctionNotImplemented, InvalidAbiDataToEncodeOrDecode, InvalidAbiFragment, InvalidAbiSignatureFormat, InvalidAddress, InvalidBloom, InvalidBloomParams, InvalidDataType, InvalidHDNode, InvalidHDNodeMnemonic, InvalidHTTPRequest, InvalidKeystore, InvalidKeystoreParams, InvalidRLP, InvalidSecp256k1MessageHash, InvalidSecp256k1PrivateKey, InvalidSecp256k1Signature, InvalidTransactionField, JSONRPCInternalError, JSONRPCInvalidParams, JSONRPCInvalidRequest, JSONRPCMethodNotFound, JSONRPCParseError, JSONRPCProviderError, JSONRPCServerError, NotDelegatedTransaction, type ObjectErrorData, PollExecution, UnavailableTransactionField, UnsupportedOperation, VechainSDKError, assertInnerError, createErrorMessage, errors, stringifyData }; |
@@ -23,96 +23,39 @@ "use strict"; | ||
__export(src_exports, { | ||
ABI: () => ABI, | ||
ADDRESS: () => ADDRESS, | ||
BLOOM: () => BLOOM, | ||
CERTIFICATE: () => CERTIFICATE, | ||
CONTRACT: () => CONTRACT, | ||
CertificateInvalidSignatureFormatError: () => CertificateInvalidSignatureFormatError, | ||
CertificateInvalidSignerError: () => CertificateInvalidSignerError, | ||
CertificateNotSignedError: () => CertificateNotSignedError, | ||
CannotFindTransaction: () => CannotFindTransaction, | ||
CertificateSignature: () => CertificateSignature, | ||
ContractDeploymentFailedError: () => ContractDeploymentFailedError, | ||
ContractInterfaceError: () => ContractInterfaceError, | ||
DATA: () => DATA, | ||
EIP1193: () => EIP1193, | ||
EIP1193ChainDisconnected: () => EIP1193ChainDisconnected, | ||
EIP1193Disconnected: () => EIP1193Disconnected, | ||
EIP1193Unauthorized: () => EIP1193Unauthorized, | ||
EIP1193UnsupportedMethod: () => EIP1193UnsupportedMethod, | ||
EIP1193UserRejectedRequest: () => EIP1193UserRejectedRequest, | ||
ERROR_CODES: () => ERROR_CODES, | ||
ErrorBase: () => ErrorBase, | ||
ErrorClassMap: () => ErrorClassMap, | ||
FUNCTION: () => FUNCTION, | ||
HDNODE: () => HDNODE, | ||
HTTPClientError: () => HTTPClientError, | ||
HTTP_CLIENT: () => HTTP_CLIENT, | ||
InvalidAbiDataToDecodeError: () => InvalidAbiDataToDecodeError, | ||
InvalidAbiDataToEncodeError: () => InvalidAbiDataToEncodeError, | ||
ContractDeploymentFailed: () => ContractDeploymentFailed, | ||
FunctionNotImplemented: () => FunctionNotImplemented, | ||
InvalidAbiDataToEncodeOrDecode: () => InvalidAbiDataToEncodeOrDecode, | ||
InvalidAbiEventError: () => InvalidAbiEventError, | ||
InvalidAbiFormatTypeError: () => InvalidAbiFormatTypeError, | ||
InvalidAbiFragment: () => InvalidAbiFragment, | ||
InvalidAbiFunctionError: () => InvalidAbiFunctionError, | ||
InvalidAbiSignatureFormat: () => InvalidAbiSignatureFormat, | ||
InvalidAddress: () => InvalidAddress, | ||
InvalidAddressError: () => InvalidAddressError, | ||
InvalidBloom: () => InvalidBloom, | ||
InvalidBloomError: () => InvalidBloomError, | ||
InvalidBloomParams: () => InvalidBloomParams, | ||
InvalidDataReturnTypeError: () => InvalidDataReturnTypeError, | ||
InvalidDataType: () => InvalidDataType, | ||
InvalidDataTypeError: () => InvalidDataTypeError, | ||
InvalidHDNode: () => InvalidHDNode, | ||
InvalidHDNodeChaincodeError: () => InvalidHDNodeChaincodeError, | ||
InvalidHDNodeDerivationPathError: () => InvalidHDNodeDerivationPathError, | ||
InvalidHDNodeMnemonic: () => InvalidHDNodeMnemonic, | ||
InvalidHDNodeMnemonicsError: () => InvalidHDNodeMnemonicsError, | ||
InvalidHDNodePrivateKeyError: () => InvalidHDNodePrivateKeyError, | ||
InvalidHDNodePublicKeyError: () => InvalidHDNodePublicKeyError, | ||
InvalidKError: () => InvalidKError, | ||
InvalidHTTPRequest: () => InvalidHTTPRequest, | ||
InvalidKeystore: () => InvalidKeystore, | ||
InvalidKeystoreError: () => InvalidKeystoreError, | ||
InvalidKeystoreParams: () => InvalidKeystoreParams, | ||
InvalidKeystorePasswordError: () => InvalidKeystorePasswordError, | ||
InvalidRLP: () => InvalidRLP, | ||
InvalidRLPError: () => InvalidRLPError, | ||
InvalidSecp256k1MessageHash: () => InvalidSecp256k1MessageHash, | ||
InvalidSecp256k1MessageHashError: () => InvalidSecp256k1MessageHashError, | ||
InvalidSecp256k1PrivateKey: () => InvalidSecp256k1PrivateKey, | ||
InvalidSecp256k1PrivateKeyError: () => InvalidSecp256k1PrivateKeyError, | ||
InvalidSecp256k1Signature: () => InvalidSecp256k1Signature, | ||
InvalidSecp256k1SignatureError: () => InvalidSecp256k1SignatureError, | ||
InvalidSecp256k1SignatureRecoveryError: () => InvalidSecp256k1SignatureRecoveryError, | ||
InvalidTransactionField: () => InvalidTransactionField, | ||
JSONRPC: () => JSONRPC, | ||
JSONRPCDefaultError: () => JSONRPCDefaultError, | ||
JSONRPCInternalError: () => JSONRPCInternalError, | ||
JSONRPCInvalidParams: () => JSONRPCInvalidParams, | ||
JSONRPCInvalidRequest: () => JSONRPCInvalidRequest, | ||
KEYSTORE: () => KEYSTORE, | ||
JSONRPCMethodNotFound: () => JSONRPCMethodNotFound, | ||
JSONRPCParseError: () => JSONRPCParseError, | ||
JSONRPCProviderError: () => JSONRPCProviderError, | ||
JSONRPCServerError: () => JSONRPCServerError, | ||
NotDelegatedTransaction: () => NotDelegatedTransaction, | ||
NotImplementedError: () => NotImplementedError, | ||
POLL_ERROR: () => POLL_ERROR, | ||
PollExecutionError: () => PollExecutionError, | ||
ProviderRpcError: () => ProviderRpcError, | ||
RLP_ERRORS: () => RLP_ERRORS, | ||
SECP256K1: () => SECP256K1, | ||
TRANSACTION: () => TRANSACTION, | ||
TransactionAlreadySignedError: () => TransactionAlreadySignedError, | ||
TransactionBodyError: () => TransactionBodyError, | ||
TransactionDelegationError: () => TransactionDelegationError, | ||
TransactionMissingPrivateKeyError: () => TransactionMissingPrivateKeyError, | ||
TransactionNotSignedError: () => TransactionNotSignedError, | ||
PollExecution: () => PollExecution, | ||
UnavailableTransactionField: () => UnavailableTransactionField, | ||
UnsupportedOperation: () => UnsupportedOperation, | ||
VechainSDKError: () => VechainSDKError, | ||
assert: () => assert, | ||
assertInnerError: () => assertInnerError, | ||
buildError: () => buildError, | ||
buildErrorMessage: () => buildErrorMessage, | ||
buildProviderError: () => buildProviderError, | ||
createErrorMessage: () => createErrorMessage, | ||
errors: () => errors_exports, | ||
getEIP1193ErrorCode: () => getEIP1193ErrorCode, | ||
getJSONRPCErrorCode: () => getJSONRPCErrorCode, | ||
stringifyData: () => stringifyData2 | ||
stringifyData: () => stringifyData | ||
}); | ||
@@ -124,381 +67,40 @@ module.exports = __toCommonJS(src_exports); | ||
__export(errors_exports, { | ||
ABI: () => ABI, | ||
ADDRESS: () => ADDRESS, | ||
BLOOM: () => BLOOM, | ||
CERTIFICATE: () => CERTIFICATE, | ||
CONTRACT: () => CONTRACT, | ||
CertificateInvalidSignatureFormatError: () => CertificateInvalidSignatureFormatError, | ||
CertificateInvalidSignerError: () => CertificateInvalidSignerError, | ||
CertificateNotSignedError: () => CertificateNotSignedError, | ||
CannotFindTransaction: () => CannotFindTransaction, | ||
CertificateSignature: () => CertificateSignature, | ||
ContractDeploymentFailedError: () => ContractDeploymentFailedError, | ||
ContractInterfaceError: () => ContractInterfaceError, | ||
DATA: () => DATA, | ||
EIP1193: () => EIP1193, | ||
EIP1193ChainDisconnected: () => EIP1193ChainDisconnected, | ||
EIP1193Disconnected: () => EIP1193Disconnected, | ||
EIP1193Unauthorized: () => EIP1193Unauthorized, | ||
EIP1193UnsupportedMethod: () => EIP1193UnsupportedMethod, | ||
EIP1193UserRejectedRequest: () => EIP1193UserRejectedRequest, | ||
ERROR_CODES: () => ERROR_CODES, | ||
ErrorBase: () => ErrorBase, | ||
ErrorClassMap: () => ErrorClassMap, | ||
FUNCTION: () => FUNCTION, | ||
HDNODE: () => HDNODE, | ||
HTTPClientError: () => HTTPClientError, | ||
HTTP_CLIENT: () => HTTP_CLIENT, | ||
InvalidAbiDataToDecodeError: () => InvalidAbiDataToDecodeError, | ||
InvalidAbiDataToEncodeError: () => InvalidAbiDataToEncodeError, | ||
ContractDeploymentFailed: () => ContractDeploymentFailed, | ||
FunctionNotImplemented: () => FunctionNotImplemented, | ||
InvalidAbiDataToEncodeOrDecode: () => InvalidAbiDataToEncodeOrDecode, | ||
InvalidAbiEventError: () => InvalidAbiEventError, | ||
InvalidAbiFormatTypeError: () => InvalidAbiFormatTypeError, | ||
InvalidAbiFragment: () => InvalidAbiFragment, | ||
InvalidAbiFunctionError: () => InvalidAbiFunctionError, | ||
InvalidAbiSignatureFormat: () => InvalidAbiSignatureFormat, | ||
InvalidAddress: () => InvalidAddress, | ||
InvalidAddressError: () => InvalidAddressError, | ||
InvalidBloom: () => InvalidBloom, | ||
InvalidBloomError: () => InvalidBloomError, | ||
InvalidBloomParams: () => InvalidBloomParams, | ||
InvalidDataReturnTypeError: () => InvalidDataReturnTypeError, | ||
InvalidDataType: () => InvalidDataType, | ||
InvalidDataTypeError: () => InvalidDataTypeError, | ||
InvalidHDNode: () => InvalidHDNode, | ||
InvalidHDNodeChaincodeError: () => InvalidHDNodeChaincodeError, | ||
InvalidHDNodeDerivationPathError: () => InvalidHDNodeDerivationPathError, | ||
InvalidHDNodeMnemonic: () => InvalidHDNodeMnemonic, | ||
InvalidHDNodeMnemonicsError: () => InvalidHDNodeMnemonicsError, | ||
InvalidHDNodePrivateKeyError: () => InvalidHDNodePrivateKeyError, | ||
InvalidHDNodePublicKeyError: () => InvalidHDNodePublicKeyError, | ||
InvalidKError: () => InvalidKError, | ||
InvalidHTTPRequest: () => InvalidHTTPRequest, | ||
InvalidKeystore: () => InvalidKeystore, | ||
InvalidKeystoreError: () => InvalidKeystoreError, | ||
InvalidKeystoreParams: () => InvalidKeystoreParams, | ||
InvalidKeystorePasswordError: () => InvalidKeystorePasswordError, | ||
InvalidRLP: () => InvalidRLP, | ||
InvalidRLPError: () => InvalidRLPError, | ||
InvalidSecp256k1MessageHash: () => InvalidSecp256k1MessageHash, | ||
InvalidSecp256k1MessageHashError: () => InvalidSecp256k1MessageHashError, | ||
InvalidSecp256k1PrivateKey: () => InvalidSecp256k1PrivateKey, | ||
InvalidSecp256k1PrivateKeyError: () => InvalidSecp256k1PrivateKeyError, | ||
InvalidSecp256k1Signature: () => InvalidSecp256k1Signature, | ||
InvalidSecp256k1SignatureError: () => InvalidSecp256k1SignatureError, | ||
InvalidSecp256k1SignatureRecoveryError: () => InvalidSecp256k1SignatureRecoveryError, | ||
InvalidTransactionField: () => InvalidTransactionField, | ||
JSONRPC: () => JSONRPC, | ||
JSONRPCDefaultError: () => JSONRPCDefaultError, | ||
JSONRPCInternalError: () => JSONRPCInternalError, | ||
JSONRPCInvalidParams: () => JSONRPCInvalidParams, | ||
JSONRPCInvalidRequest: () => JSONRPCInvalidRequest, | ||
KEYSTORE: () => KEYSTORE, | ||
JSONRPCMethodNotFound: () => JSONRPCMethodNotFound, | ||
JSONRPCParseError: () => JSONRPCParseError, | ||
JSONRPCProviderError: () => JSONRPCProviderError, | ||
JSONRPCServerError: () => JSONRPCServerError, | ||
NotDelegatedTransaction: () => NotDelegatedTransaction, | ||
NotImplementedError: () => NotImplementedError, | ||
POLL_ERROR: () => POLL_ERROR, | ||
PollExecutionError: () => PollExecutionError, | ||
ProviderRpcError: () => ProviderRpcError, | ||
RLP_ERRORS: () => RLP_ERRORS, | ||
SECP256K1: () => SECP256K1, | ||
TRANSACTION: () => TRANSACTION, | ||
TransactionAlreadySignedError: () => TransactionAlreadySignedError, | ||
TransactionBodyError: () => TransactionBodyError, | ||
TransactionDelegationError: () => TransactionDelegationError, | ||
TransactionMissingPrivateKeyError: () => TransactionMissingPrivateKeyError, | ||
TransactionNotSignedError: () => TransactionNotSignedError, | ||
PollExecution: () => PollExecution, | ||
UnavailableTransactionField: () => UnavailableTransactionField, | ||
UnsupportedOperation: () => UnsupportedOperation, | ||
VechainSDKError: () => VechainSDKError, | ||
assert: () => assert, | ||
assertInnerError: () => assertInnerError, | ||
buildError: () => buildError, | ||
buildErrorMessage: () => buildErrorMessage, | ||
buildProviderError: () => buildProviderError, | ||
createErrorMessage: () => createErrorMessage, | ||
getEIP1193ErrorCode: () => getEIP1193ErrorCode, | ||
getJSONRPCErrorCode: () => getJSONRPCErrorCode, | ||
stringifyData: () => stringifyData2 | ||
stringifyData: () => stringifyData | ||
}); | ||
// src/model/base.ts | ||
var ErrorBase = class extends Error { | ||
code; | ||
message; | ||
data; | ||
innerError; | ||
constructor({ | ||
code, | ||
message, | ||
data, | ||
innerError | ||
}) { | ||
super(); | ||
this.code = code; | ||
this.message = message; | ||
this.data = data; | ||
this.innerError = innerError; | ||
} | ||
}; | ||
// src/model/core/abi.ts | ||
var InvalidAbiDataToDecodeError = class extends ErrorBase { | ||
}; | ||
var InvalidAbiDataToEncodeError = class extends ErrorBase { | ||
}; | ||
var InvalidAbiEventError = class extends ErrorBase { | ||
}; | ||
var InvalidAbiFormatTypeError = class extends ErrorBase { | ||
}; | ||
var InvalidAbiFunctionError = class extends ErrorBase { | ||
}; | ||
var ContractInterfaceError = class extends ErrorBase { | ||
}; | ||
var ABI = /* @__PURE__ */ ((ABI2) => { | ||
ABI2["INVALID_FUNCTION"] = "INVALID_FUNCTION"; | ||
ABI2["INVALID_EVENT"] = "INVALID_EVENT"; | ||
ABI2["INVALID_DATA_TO_DECODE"] = "INVALID_DATA_TO_DECODE"; | ||
ABI2["INVALID_DATA_TO_ENCODE"] = "INVALID_DATA_TO_ENCODE"; | ||
ABI2["INVALID_FORMAT_TYPE"] = "INVALID_FORMAT_TYPE"; | ||
ABI2["CONTRACT_INTERFACE_ERROR"] = "CONTRACT_INTERFACE_ERROR"; | ||
return ABI2; | ||
})(ABI || {}); | ||
// src/model/core/address.ts | ||
var InvalidAddressError = class extends ErrorBase { | ||
}; | ||
var ADDRESS = /* @__PURE__ */ ((ADDRESS2) => { | ||
ADDRESS2["INVALID_ADDRESS"] = "INVALID_ADDRESS"; | ||
return ADDRESS2; | ||
})(ADDRESS || {}); | ||
// src/model/core/bloom.ts | ||
var InvalidBloomError = class extends ErrorBase { | ||
}; | ||
var InvalidKError = class extends ErrorBase { | ||
}; | ||
var BLOOM = /* @__PURE__ */ ((BLOOM2) => { | ||
BLOOM2["INVALID_BLOOM"] = "INVALID_BLOOM"; | ||
BLOOM2["INVALID_K"] = "INVALID_K"; | ||
return BLOOM2; | ||
})(BLOOM || {}); | ||
// src/model/core/certificate.ts | ||
var CertificateNotSignedError = class extends ErrorBase { | ||
}; | ||
var CertificateInvalidSignatureFormatError = class extends ErrorBase { | ||
}; | ||
var CertificateInvalidSignerError = class extends ErrorBase { | ||
}; | ||
var CERTIFICATE = /* @__PURE__ */ ((CERTIFICATE2) => { | ||
CERTIFICATE2["CERTIFICATE_NOT_SIGNED"] = "CERTIFICATE_NOT_SIGNED"; | ||
CERTIFICATE2["CERTIFICATE_INVALID_SIGNATURE_FORMAT"] = "CERTIFICATE_INVALID_SIGNATURE_FORMAT"; | ||
CERTIFICATE2["CERTIFICATE_INVALID_SIGNER"] = "CERTIFICATE_INVALID_SIGNER"; | ||
return CERTIFICATE2; | ||
})(CERTIFICATE || {}); | ||
// src/model/core/contract.ts | ||
var ContractDeploymentFailedError = class extends ErrorBase { | ||
}; | ||
var CONTRACT = /* @__PURE__ */ ((CONTRACT2) => { | ||
CONTRACT2["CONTRACT_DEPLOYMENT_FAILED"] = "CONTRACT_DEPLOYMENT_FAILED"; | ||
return CONTRACT2; | ||
})(CONTRACT || {}); | ||
// src/model/core/data.ts | ||
var InvalidDataTypeError = class extends ErrorBase { | ||
}; | ||
var InvalidDataReturnTypeError = class extends ErrorBase { | ||
}; | ||
var DATA = /* @__PURE__ */ ((DATA2) => { | ||
DATA2["INVALID_DATA_TYPE"] = "INVALID_DATA_TYPE"; | ||
DATA2["INVALID_DATA_RETURN_TYPE"] = "INVALID_DATA_RETURN_TYPE"; | ||
return DATA2; | ||
})(DATA || {}); | ||
// src/model/core/hdnode.ts | ||
var InvalidHDNodeChaincodeError = class extends ErrorBase { | ||
}; | ||
var InvalidHDNodeMnemonicsError = class extends ErrorBase { | ||
}; | ||
var InvalidHDNodePrivateKeyError = class extends ErrorBase { | ||
}; | ||
var InvalidHDNodePublicKeyError = class extends ErrorBase { | ||
}; | ||
var InvalidHDNodeDerivationPathError = class extends ErrorBase { | ||
}; | ||
var HDNODE = /* @__PURE__ */ ((HDNODE2) => { | ||
HDNODE2["INVALID_HDNODE_PUBLIC_KEY"] = "INVALID_HDNODE_PUBLIC_KEY"; | ||
HDNODE2["INVALID_HDNODE_PRIVATE_KEY"] = "INVALID_HDNODE_PRIVATE_KEY"; | ||
HDNODE2["INVALID_HDNODE_CHAIN_CODE"] = "INVALID_HDNODE_CHAIN_CODE"; | ||
HDNODE2["INVALID_HDNODE_MNEMONICS"] = "INVALID_HDNODE_MNEMONICS"; | ||
HDNODE2["INVALID_HDNODE_DERIVATION_PATH"] = "INVALID_HDNODE_DERIVATION_PATH"; | ||
return HDNODE2; | ||
})(HDNODE || {}); | ||
// src/model/core/keystore.ts | ||
var InvalidKeystoreError = class extends ErrorBase { | ||
}; | ||
var InvalidKeystorePasswordError = class extends ErrorBase { | ||
}; | ||
var KEYSTORE = /* @__PURE__ */ ((KEYSTORE2) => { | ||
KEYSTORE2["INVALID_KEYSTORE"] = "INVALID_KEYSTORE"; | ||
KEYSTORE2["INVALID_PASSWORD"] = "INVALID_PASSWORD"; | ||
return KEYSTORE2; | ||
})(KEYSTORE || {}); | ||
// src/model/core/rlp.ts | ||
var InvalidRLPError = class extends ErrorBase { | ||
}; | ||
var RLP_ERRORS = /* @__PURE__ */ ((RLP_ERRORS2) => { | ||
RLP_ERRORS2["INVALID_RLP"] = "INVALID_RLP"; | ||
return RLP_ERRORS2; | ||
})(RLP_ERRORS || {}); | ||
// src/model/core/secp256k1.ts | ||
var InvalidSecp256k1PrivateKeyError = class extends ErrorBase { | ||
}; | ||
var InvalidSecp256k1MessageHashError = class extends ErrorBase { | ||
}; | ||
var InvalidSecp256k1SignatureError = class extends ErrorBase { | ||
}; | ||
var InvalidSecp256k1SignatureRecoveryError = class extends ErrorBase { | ||
}; | ||
var SECP256K1 = /* @__PURE__ */ ((SECP256K12) => { | ||
SECP256K12["INVALID_SECP256k1_PRIVATE_KEY"] = "INVALID_SECP256k1_PRIVATE_KEY"; | ||
SECP256K12["INVALID_SECP256k1_MESSAGE_HASH"] = "INVALID_SECP256k1_MESSAGE_HASH"; | ||
SECP256K12["INVALID_SECP256k1_SIGNATURE"] = "INVALID_SECP256k1_SIGNATURE"; | ||
SECP256K12["INVALID_SECP256k1_SIGNATURE_RECOVERY"] = "INVALID_SECP256k1_SIGNATURE_RECOVERY"; | ||
return SECP256K12; | ||
})(SECP256K1 || {}); | ||
// src/model/core/transaction.ts | ||
var TransactionAlreadySignedError = class extends ErrorBase { | ||
}; | ||
var TransactionNotSignedError = class extends ErrorBase { | ||
}; | ||
var TransactionBodyError = class extends ErrorBase { | ||
}; | ||
var TransactionDelegationError = class extends ErrorBase { | ||
}; | ||
var TransactionMissingPrivateKeyError = class extends ErrorBase { | ||
}; | ||
var TRANSACTION = /* @__PURE__ */ ((TRANSACTION2) => { | ||
TRANSACTION2["ALREADY_SIGNED"] = "ALREADY_SIGNED"; | ||
TRANSACTION2["NOT_SIGNED"] = "NOT_SIGNED"; | ||
TRANSACTION2["INVALID_TRANSACTION_BODY"] = "INVALID_TRANSACTION_BODY"; | ||
TRANSACTION2["INVALID_DELEGATION"] = "INVALID_DELEGATION"; | ||
TRANSACTION2["MISSING_PRIVATE_KEY"] = "MISSING_PRIVATE_KEY"; | ||
return TRANSACTION2; | ||
})(TRANSACTION || {}); | ||
// src/model/network/http-client.ts | ||
var HTTPClientError = class extends ErrorBase { | ||
}; | ||
var HTTP_CLIENT = /* @__PURE__ */ ((HTTP_CLIENT2) => { | ||
HTTP_CLIENT2["INVALID_HTTP_REQUEST"] = "INVALID_HTTP_REQUEST"; | ||
return HTTP_CLIENT2; | ||
})(HTTP_CLIENT || {}); | ||
// src/model/network/poll.ts | ||
var PollExecutionError = class extends ErrorBase { | ||
}; | ||
var POLL_ERROR = /* @__PURE__ */ ((POLL_ERROR2) => { | ||
POLL_ERROR2["POLL_EXECUTION_ERROR"] = "POLL_EXECUTION_ERROR"; | ||
return POLL_ERROR2; | ||
})(POLL_ERROR || {}); | ||
// src/model/generic/function.ts | ||
var NotImplementedError = class extends ErrorBase { | ||
}; | ||
var FUNCTION = /* @__PURE__ */ ((FUNCTION2) => { | ||
FUNCTION2["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED"; | ||
return FUNCTION2; | ||
})(FUNCTION || {}); | ||
// src/model/eip1193/eip1193.ts | ||
var EIP1193UserRejectedRequest = class extends ErrorBase { | ||
}; | ||
var EIP1193Unauthorized = class extends ErrorBase { | ||
}; | ||
var EIP1193UnsupportedMethod = class extends ErrorBase { | ||
}; | ||
var EIP1193Disconnected = class extends ErrorBase { | ||
}; | ||
var EIP1193ChainDisconnected = class extends ErrorBase { | ||
}; | ||
var EIP1193 = /* @__PURE__ */ ((EIP11932) => { | ||
EIP11932["USER_REJECTED_REQUEST"] = "USER_REJECTED_REQUEST"; | ||
EIP11932["UNAUTHORIZED"] = "UNAUTHORIZED"; | ||
EIP11932["UNSUPPORTED_METHOD"] = "UNSUPPORTED METHOD"; | ||
EIP11932["DISCONNECTED"] = "DISCONNECTED"; | ||
EIP11932["CHAIN_DISCONNECTED"] = "CHAIN_DISCONNECTED"; | ||
return EIP11932; | ||
})(EIP1193 || {}); | ||
var getEIP1193ErrorCode = (error) => { | ||
switch (error) { | ||
case "USER_REJECTED_REQUEST" /* USER_REJECTED_REQUEST */: | ||
return 4001; | ||
case "UNAUTHORIZED" /* UNAUTHORIZED */: | ||
return 4100; | ||
case "UNSUPPORTED METHOD" /* UNSUPPORTED_METHOD */: | ||
return 4200; | ||
case "DISCONNECTED" /* DISCONNECTED */: | ||
return 4900; | ||
case "CHAIN_DISCONNECTED" /* CHAIN_DISCONNECTED */: | ||
return 4901; | ||
} | ||
}; | ||
// src/model/json-rpc/json-rpc.ts | ||
var JSONRPCInvalidRequest = class extends ErrorBase { | ||
}; | ||
var JSONRPCInvalidParams = class extends ErrorBase { | ||
}; | ||
var JSONRPCInternalError = class extends ErrorBase { | ||
}; | ||
var JSONRPCDefaultError = class extends ErrorBase { | ||
}; | ||
var JSONRPC = /* @__PURE__ */ ((JSONRPC2) => { | ||
JSONRPC2["INVALID_REQUEST"] = "INVALID_REQUEST"; | ||
JSONRPC2["INVALID_PARAMS"] = "INVALID_PARAMS"; | ||
JSONRPC2["INTERNAL_ERROR"] = "INTERNAL_ERROR"; | ||
JSONRPC2["DEFAULT"] = "DEFAULT"; | ||
return JSONRPC2; | ||
})(JSONRPC || {}); | ||
var getJSONRPCErrorCode = (error) => { | ||
switch (error) { | ||
case "INVALID_REQUEST" /* INVALID_REQUEST */: | ||
return -32600; | ||
case "INVALID_PARAMS" /* INVALID_PARAMS */: | ||
return -32602; | ||
case "INTERNAL_ERROR" /* INTERNAL_ERROR */: | ||
return -32603; | ||
case "DEFAULT" /* DEFAULT */: | ||
return -32e3; | ||
} | ||
}; | ||
// src/model/provider-rpc.ts | ||
var ProviderRpcError = class extends Error { | ||
/** | ||
* The error code as specified in EIP-1193 or EIP-1474 | ||
* | ||
* @link [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474#error-codes) | ||
* @link [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193#provider-errors) | ||
*/ | ||
code; | ||
/** | ||
* Contains optional extra information about the error | ||
*/ | ||
data; | ||
/** | ||
* | ||
* @param code - The error code as specified in EIP-1193 or EIP-1474 | ||
* @param message - The error message | ||
* @param data - Contains optional extra information about the error | ||
*/ | ||
constructor(code, message, data) { | ||
super(message); | ||
this.code = code; | ||
this.data = data; | ||
} | ||
}; | ||
// src/helpers/helpers.ts | ||
@@ -520,137 +122,2 @@ var stringifyData = (data) => { | ||
}; | ||
function createErrorMessage(methodName, errorMessage, inputData, innerError) { | ||
return `Method '${methodName}' failed. | ||
-Reason: '${errorMessage}' | ||
-Parameters: | ||
${stringifyData(inputData)} | ||
-Internal error: | ||
${innerError?.message !== void 0 ? innerError.message : "No internal error given"}`; | ||
} | ||
// src/types/errorTypes.ts | ||
var ERROR_CODES = { | ||
SECP256K1, | ||
ADDRESS, | ||
KEYSTORE, | ||
HDNODE, | ||
BLOOM, | ||
CERTIFICATE, | ||
ABI, | ||
RLP: RLP_ERRORS, | ||
DATA, | ||
TRANSACTION, | ||
HTTP_CLIENT, | ||
POLL_ERROR, | ||
FUNCTION, | ||
EIP1193, | ||
JSONRPC, | ||
CONTRACT | ||
}; | ||
var ErrorClassMap = /* @__PURE__ */ new Map([ | ||
// ADDRESS | ||
["INVALID_ADDRESS" /* INVALID_ADDRESS */, InvalidAddressError], | ||
// SECP256K1 | ||
["INVALID_SECP256k1_PRIVATE_KEY" /* INVALID_SECP256k1_PRIVATE_KEY */, InvalidSecp256k1PrivateKeyError], | ||
[ | ||
"INVALID_SECP256k1_MESSAGE_HASH" /* INVALID_SECP256k1_MESSAGE_HASH */, | ||
InvalidSecp256k1MessageHashError | ||
], | ||
["INVALID_SECP256k1_SIGNATURE" /* INVALID_SECP256k1_SIGNATURE */, InvalidSecp256k1SignatureError], | ||
[ | ||
"INVALID_SECP256k1_SIGNATURE_RECOVERY" /* INVALID_SECP256k1_SIGNATURE_RECOVERY */, | ||
InvalidSecp256k1SignatureRecoveryError | ||
], | ||
// KEYSTORE | ||
["INVALID_KEYSTORE" /* INVALID_KEYSTORE */, InvalidKeystoreError], | ||
["INVALID_PASSWORD" /* INVALID_PASSWORD */, InvalidKeystorePasswordError], | ||
// HDNODE | ||
["INVALID_HDNODE_CHAIN_CODE" /* INVALID_HDNODE_CHAIN_CODE */, InvalidHDNodeChaincodeError], | ||
["INVALID_HDNODE_MNEMONICS" /* INVALID_HDNODE_MNEMONICS */, InvalidHDNodeMnemonicsError], | ||
["INVALID_HDNODE_PRIVATE_KEY" /* INVALID_HDNODE_PRIVATE_KEY */, InvalidHDNodePrivateKeyError], | ||
["INVALID_HDNODE_PUBLIC_KEY" /* INVALID_HDNODE_PUBLIC_KEY */, InvalidHDNodePublicKeyError], | ||
["INVALID_HDNODE_DERIVATION_PATH" /* INVALID_HDNODE_DERIVATION_PATH */, InvalidHDNodeDerivationPathError], | ||
["INVALID_BLOOM" /* INVALID_BLOOM */, InvalidBloomError], | ||
["INVALID_K" /* INVALID_K */, InvalidKError], | ||
// CERTIFICATE | ||
["CERTIFICATE_NOT_SIGNED" /* CERTIFICATE_NOT_SIGNED */, CertificateNotSignedError], | ||
[ | ||
"CERTIFICATE_INVALID_SIGNATURE_FORMAT" /* CERTIFICATE_INVALID_SIGNATURE_FORMAT */, | ||
CertificateInvalidSignatureFormatError | ||
], | ||
["CERTIFICATE_INVALID_SIGNER" /* CERTIFICATE_INVALID_SIGNER */, CertificateInvalidSignerError], | ||
// ABI | ||
["INVALID_EVENT" /* INVALID_EVENT */, InvalidAbiEventError], | ||
["INVALID_DATA_TO_DECODE" /* INVALID_DATA_TO_DECODE */, InvalidAbiDataToDecodeError], | ||
["INVALID_DATA_TO_ENCODE" /* INVALID_DATA_TO_ENCODE */, InvalidAbiDataToEncodeError], | ||
["INVALID_FORMAT_TYPE" /* INVALID_FORMAT_TYPE */, InvalidAbiFormatTypeError], | ||
["INVALID_FUNCTION" /* INVALID_FUNCTION */, InvalidAbiFunctionError], | ||
["CONTRACT_INTERFACE_ERROR" /* CONTRACT_INTERFACE_ERROR */, ContractInterfaceError], | ||
// RLP_ERRORS | ||
["INVALID_RLP" /* INVALID_RLP */, InvalidRLPError], | ||
// DATA | ||
["INVALID_DATA_TYPE" /* INVALID_DATA_TYPE */, InvalidDataTypeError], | ||
["INVALID_DATA_RETURN_TYPE" /* INVALID_DATA_RETURN_TYPE */, InvalidDataReturnTypeError], | ||
// TRANSACTION | ||
["ALREADY_SIGNED" /* ALREADY_SIGNED */, TransactionAlreadySignedError], | ||
["NOT_SIGNED" /* NOT_SIGNED */, TransactionNotSignedError], | ||
["INVALID_TRANSACTION_BODY" /* INVALID_TRANSACTION_BODY */, TransactionBodyError], | ||
["INVALID_DELEGATION" /* INVALID_DELEGATION */, TransactionDelegationError], | ||
["MISSING_PRIVATE_KEY" /* MISSING_PRIVATE_KEY */, TransactionMissingPrivateKeyError], | ||
// HTTP_CLIENT | ||
["INVALID_HTTP_REQUEST" /* INVALID_HTTP_REQUEST */, HTTPClientError], | ||
// POLL_ERROR | ||
["POLL_EXECUTION_ERROR" /* POLL_EXECUTION_ERROR */, PollExecutionError], | ||
// FUNCTION | ||
["NOT_IMPLEMENTED" /* NOT_IMPLEMENTED */, NotImplementedError], | ||
// EIP1193 | ||
["USER_REJECTED_REQUEST" /* USER_REJECTED_REQUEST */, EIP1193UserRejectedRequest], | ||
["UNAUTHORIZED" /* UNAUTHORIZED */, EIP1193Unauthorized], | ||
["UNSUPPORTED METHOD" /* UNSUPPORTED_METHOD */, EIP1193UnsupportedMethod], | ||
["DISCONNECTED" /* DISCONNECTED */, EIP1193Disconnected], | ||
["CHAIN_DISCONNECTED" /* CHAIN_DISCONNECTED */, EIP1193ChainDisconnected], | ||
// JSONRPC | ||
["INVALID_REQUEST" /* INVALID_REQUEST */, JSONRPCInvalidRequest], | ||
["INVALID_PARAMS" /* INVALID_PARAMS */, JSONRPCInvalidParams], | ||
["INTERNAL_ERROR" /* INTERNAL_ERROR */, JSONRPCInternalError], | ||
["DEFAULT" /* DEFAULT */, JSONRPCDefaultError], | ||
// CONTRACT | ||
["CONTRACT_DEPLOYMENT_FAILED" /* CONTRACT_DEPLOYMENT_FAILED */, ContractDeploymentFailedError] | ||
]); | ||
// src/utils/error-message-builder/error-message-builder.ts | ||
var stringifyData2 = (data) => { | ||
const getCircularReplacer = () => { | ||
const seen = /* @__PURE__ */ new WeakSet(); | ||
return (_key, value) => { | ||
if (typeof value === "object" && value !== null && _key !== "") { | ||
if (seen.has(value)) { | ||
return; | ||
} | ||
seen.add(value); | ||
} | ||
return value; | ||
}; | ||
}; | ||
return JSON.stringify(data, getCircularReplacer()); | ||
}; | ||
function buildErrorMessage(methodName, errorMessage, inputData, innerError) { | ||
return `Method '${methodName}' failed. | ||
-Reason: '${errorMessage}' | ||
-Parameters: | ||
${stringifyData2(inputData)} | ||
-Internal error: | ||
${innerError?.message !== void 0 ? innerError.message : "No internal error given"}`; | ||
} | ||
// src/utils/assert/assert.ts | ||
function assert(methodName, condition, code, message, data, innerError) { | ||
const error = buildError( | ||
`Assertion on ${methodName}`, | ||
code, | ||
message, | ||
data, | ||
innerError | ||
); | ||
if (!condition && typeof error === "object") throw error; | ||
} | ||
function assertInnerError(error) { | ||
@@ -662,40 +129,14 @@ if (error instanceof Error) { | ||
`Inner error is not an instance of Error. Object: | ||
${stringifyData2(error)}` | ||
${stringifyData(error)}` | ||
); | ||
} | ||
// src/utils/error-builder/error-builder.ts | ||
function buildError(methodName, code, message, data, innerError) { | ||
const ErrorClass = ErrorClassMap.get(code); | ||
if (ErrorClass === void 0 || ErrorClass === null) { | ||
throw new Error("Invalid error code"); | ||
} | ||
const errorMessage = buildErrorMessage( | ||
methodName, | ||
message, | ||
data, | ||
innerError === void 0 ? void 0 : assertInnerError(innerError) | ||
); | ||
const error = new ErrorClass({ | ||
code, | ||
message: errorMessage, | ||
data, | ||
innerError: innerError === void 0 ? void 0 : assertInnerError(innerError) | ||
}); | ||
return error; | ||
function createErrorMessage(methodName, errorMessage, inputData, innerError) { | ||
return `Method '${methodName}' failed. | ||
-Reason: '${errorMessage}' | ||
-Parameters: | ||
${stringifyData(inputData)} | ||
-Internal error: | ||
${innerError?.message !== void 0 ? innerError.message : "No internal error given"}`; | ||
} | ||
// src/utils/error-builder/provider-error-builder.ts | ||
function buildProviderError(code, message, data) { | ||
const ErrorClass = ErrorClassMap.get(code); | ||
const _code = isEIP1193Code(code) ? getEIP1193ErrorCode(code) : getJSONRPCErrorCode(code); | ||
if (ErrorClass === void 0 || ErrorClass === null) { | ||
throw new Error("Invalid error code"); | ||
} | ||
return new ProviderRpcError(_code, message, data); | ||
} | ||
function isEIP1193Code(code) { | ||
return Object.values(EIP1193).includes(code); | ||
} | ||
// src/available-errors/sdk-error.ts | ||
@@ -741,6 +182,16 @@ var VechainSDKError = class extends Error { | ||
// src/available-errors/contract/contract.ts | ||
var ContractDeploymentFailed = class extends VechainSDKError { | ||
}; | ||
// src/available-errors/data/data.ts | ||
var InvalidDataType = class extends VechainSDKError { | ||
}; | ||
var UnsupportedOperation = class extends VechainSDKError { | ||
}; | ||
// src/available-errors/function/function.ts | ||
var FunctionNotImplemented = class extends VechainSDKError { | ||
}; | ||
// src/available-errors/hdnode/hdnode.ts | ||
@@ -752,2 +203,6 @@ var InvalidHDNodeMnemonic = class extends VechainSDKError { | ||
// src/available-errors/http/http.ts | ||
var InvalidHTTPRequest = class extends VechainSDKError { | ||
}; | ||
// src/available-errors/keystore/keystore.ts | ||
@@ -759,2 +214,27 @@ var InvalidKeystore = class extends VechainSDKError { | ||
// src/available-errors/poll/poll.ts | ||
var PollExecution = class extends VechainSDKError { | ||
}; | ||
// src/available-errors/provider/provider.ts | ||
var JSONRPCProviderError = class extends VechainSDKError { | ||
constructor(methodName, code, message, data, innerError) { | ||
super(methodName, message, { code, message, data }, innerError); | ||
this.methodName = methodName; | ||
this.innerError = innerError; | ||
} | ||
}; | ||
var JSONRPCParseError = class extends JSONRPCProviderError { | ||
}; | ||
var JSONRPCInvalidRequest = class extends JSONRPCProviderError { | ||
}; | ||
var JSONRPCMethodNotFound = class extends JSONRPCProviderError { | ||
}; | ||
var JSONRPCInvalidParams = class extends JSONRPCProviderError { | ||
}; | ||
var JSONRPCInternalError = class extends JSONRPCProviderError { | ||
}; | ||
var JSONRPCServerError = class extends JSONRPCProviderError { | ||
}; | ||
// src/available-errors/rlp/rlp.ts | ||
@@ -779,98 +259,43 @@ var InvalidRLP = class extends VechainSDKError { | ||
}; | ||
var CannotFindTransaction = class extends VechainSDKError { | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
ABI, | ||
ADDRESS, | ||
BLOOM, | ||
CERTIFICATE, | ||
CONTRACT, | ||
CertificateInvalidSignatureFormatError, | ||
CertificateInvalidSignerError, | ||
CertificateNotSignedError, | ||
CannotFindTransaction, | ||
CertificateSignature, | ||
ContractDeploymentFailedError, | ||
ContractInterfaceError, | ||
DATA, | ||
EIP1193, | ||
EIP1193ChainDisconnected, | ||
EIP1193Disconnected, | ||
EIP1193Unauthorized, | ||
EIP1193UnsupportedMethod, | ||
EIP1193UserRejectedRequest, | ||
ERROR_CODES, | ||
ErrorBase, | ||
ErrorClassMap, | ||
FUNCTION, | ||
HDNODE, | ||
HTTPClientError, | ||
HTTP_CLIENT, | ||
InvalidAbiDataToDecodeError, | ||
InvalidAbiDataToEncodeError, | ||
ContractDeploymentFailed, | ||
FunctionNotImplemented, | ||
InvalidAbiDataToEncodeOrDecode, | ||
InvalidAbiEventError, | ||
InvalidAbiFormatTypeError, | ||
InvalidAbiFragment, | ||
InvalidAbiFunctionError, | ||
InvalidAbiSignatureFormat, | ||
InvalidAddress, | ||
InvalidAddressError, | ||
InvalidBloom, | ||
InvalidBloomError, | ||
InvalidBloomParams, | ||
InvalidDataReturnTypeError, | ||
InvalidDataType, | ||
InvalidDataTypeError, | ||
InvalidHDNode, | ||
InvalidHDNodeChaincodeError, | ||
InvalidHDNodeDerivationPathError, | ||
InvalidHDNodeMnemonic, | ||
InvalidHDNodeMnemonicsError, | ||
InvalidHDNodePrivateKeyError, | ||
InvalidHDNodePublicKeyError, | ||
InvalidKError, | ||
InvalidHTTPRequest, | ||
InvalidKeystore, | ||
InvalidKeystoreError, | ||
InvalidKeystoreParams, | ||
InvalidKeystorePasswordError, | ||
InvalidRLP, | ||
InvalidRLPError, | ||
InvalidSecp256k1MessageHash, | ||
InvalidSecp256k1MessageHashError, | ||
InvalidSecp256k1PrivateKey, | ||
InvalidSecp256k1PrivateKeyError, | ||
InvalidSecp256k1Signature, | ||
InvalidSecp256k1SignatureError, | ||
InvalidSecp256k1SignatureRecoveryError, | ||
InvalidTransactionField, | ||
JSONRPC, | ||
JSONRPCDefaultError, | ||
JSONRPCInternalError, | ||
JSONRPCInvalidParams, | ||
JSONRPCInvalidRequest, | ||
KEYSTORE, | ||
JSONRPCMethodNotFound, | ||
JSONRPCParseError, | ||
JSONRPCProviderError, | ||
JSONRPCServerError, | ||
NotDelegatedTransaction, | ||
NotImplementedError, | ||
POLL_ERROR, | ||
PollExecutionError, | ||
ProviderRpcError, | ||
RLP_ERRORS, | ||
SECP256K1, | ||
TRANSACTION, | ||
TransactionAlreadySignedError, | ||
TransactionBodyError, | ||
TransactionDelegationError, | ||
TransactionMissingPrivateKeyError, | ||
TransactionNotSignedError, | ||
PollExecution, | ||
UnavailableTransactionField, | ||
UnsupportedOperation, | ||
VechainSDKError, | ||
assert, | ||
assertInnerError, | ||
buildError, | ||
buildErrorMessage, | ||
buildProviderError, | ||
createErrorMessage, | ||
errors, | ||
getEIP1193ErrorCode, | ||
getJSONRPCErrorCode, | ||
stringifyData | ||
}); |
{ | ||
"name": "@vechain/sdk-errors", | ||
"version": "1.0.0-beta.24", | ||
"version": "1.0.0-beta.25", | ||
"description": "This module is dedicated to managing and customizing errors within the SDK", | ||
@@ -5,0 +5,0 @@ "author": "vechain Foundation", |
@@ -13,2 +13,11 @@ import { VechainSDKError } from '../sdk-error'; | ||
export { InvalidDataType }; | ||
/** | ||
* Unsupported operation error. | ||
* | ||
* WHEN TO USE: | ||
* * This error will be thrown when an operation is not supported. | ||
* -e.g.- into the ethers adapter, when the runner does not support sending transactions. | ||
*/ | ||
class UnsupportedOperation extends VechainSDKError<ObjectErrorData> {} | ||
export { InvalidDataType, UnsupportedOperation }; |
@@ -5,5 +5,10 @@ export * from './abi'; | ||
export * from './certificate'; | ||
export * from './contract'; | ||
export * from './data'; | ||
export * from './function'; | ||
export * from './hdnode'; | ||
export * from './http'; | ||
export * from './keystore'; | ||
export * from './poll'; | ||
export * from './provider'; | ||
export * from './rlp'; | ||
@@ -10,0 +15,0 @@ export * from './secp256k1'; |
@@ -1,3 +0,2 @@ | ||
import { assertInnerError } from '../utils'; | ||
import { createErrorMessage } from '../helpers'; | ||
import { assertInnerError, createErrorMessage } from '../helpers'; | ||
@@ -4,0 +3,0 @@ /** |
@@ -32,8 +32,22 @@ import { VechainSDKError } from '../sdk-error'; | ||
*/ | ||
class NotDelegatedTransaction extends VechainSDKError<undefined> {} | ||
class NotDelegatedTransaction extends VechainSDKError< | ||
undefined | { delegatorUrl: string } | ||
> {} | ||
/** | ||
* Cannot find transaction error. | ||
* | ||
* WHEN TO USE: | ||
* * Error will be thrown when the transaction is not into the blockchain. | ||
*/ | ||
class CannotFindTransaction extends VechainSDKError<{ | ||
transactionHash?: string; | ||
networkUrl?: string; | ||
}> {} | ||
export { | ||
UnavailableTransactionField, | ||
InvalidTransactionField, | ||
NotDelegatedTransaction | ||
NotDelegatedTransaction, | ||
CannotFindTransaction | ||
}; |
@@ -1,5 +0,2 @@ | ||
export * from './model'; | ||
export * from './helpers'; | ||
export * from './available-errors'; | ||
export * from './types'; | ||
export * from './utils'; |
@@ -34,2 +34,23 @@ /** | ||
/** | ||
* Asserts that the given error is an instance of the Error class. | ||
* If the error is an instance of Error, it is returned. | ||
* If the error is not an instance of Error, a new Error object is created with a descriptive message. | ||
* | ||
* @param {unknown} error - The error to be asserted. | ||
* @return {Error} - The error if it is an instance of Error, or a new Error object if it is not. | ||
* | ||
* @remarks | ||
* **IMPORTANT: no sensitive data should be passed as any parameter.** | ||
*/ | ||
function assertInnerError(error: unknown): Error { | ||
if (error instanceof Error) { | ||
return error; | ||
} | ||
return new Error( | ||
`Inner error is not an instance of Error. Object:\n\t${stringifyData(error)}` | ||
); | ||
} | ||
/** | ||
* Function to build the error message. | ||
@@ -58,2 +79,2 @@ * Here, we can customize the error message format. | ||
export { createErrorMessage }; | ||
export { stringifyData, assertInnerError, createErrorMessage }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69547
43
1436
1