@vechain/sdk-errors
Advanced tools
Comparing version
@@ -53,2 +53,3 @@ /** | ||
type ObjectErrorData = Record<string, unknown>; | ||
type JSONRpcErrorCode = -32700 | -32600 | -32601 | -32602 | -32603 | -32000; | ||
@@ -131,2 +132,10 @@ /** | ||
} | ||
/** | ||
* Error when calling a read function on a contract. | ||
* | ||
* WHEN TO USE: | ||
* * Error will be thrown when a read (call) operation fails. | ||
*/ | ||
declare class ContractCallError extends VechainSDKError<ObjectErrorData> { | ||
} | ||
@@ -218,2 +227,10 @@ /** | ||
/** | ||
* Provider method error. | ||
* | ||
* WHEN TO USE: | ||
* * This error will be thrown when a provider method has failed. | ||
*/ | ||
declare class ProviderMethodError extends VechainSDKError<ObjectErrorData> { | ||
} | ||
/** | ||
* Provider generic error. | ||
@@ -226,4 +243,4 @@ * | ||
*/ | ||
declare class JSONRPCProviderError<TJSONRpcErrorCode extends -32700 | -32600 | -32601 | -32602 | -32603 | -32000> extends VechainSDKError<{ | ||
code: TJSONRpcErrorCode; | ||
declare class JSONRPCProviderError extends VechainSDKError<{ | ||
code: JSONRpcErrorCode; | ||
message: string; | ||
@@ -234,3 +251,3 @@ data: ObjectErrorData; | ||
readonly innerError?: unknown; | ||
constructor(methodName: string, code: TJSONRpcErrorCode, message: string, data: ObjectErrorData, innerError?: unknown); | ||
constructor(methodName: string, code: JSONRpcErrorCode, message: string, data: ObjectErrorData, innerError?: unknown); | ||
} | ||
@@ -243,3 +260,6 @@ /** | ||
*/ | ||
declare class JSONRPCParseError extends JSONRPCProviderError<-32700> { | ||
declare class JSONRPCParseError extends JSONRPCProviderError { | ||
readonly methodName: string; | ||
readonly innerError?: unknown; | ||
constructor(methodName: string, message: string, data: ObjectErrorData, innerError?: unknown); | ||
} | ||
@@ -252,3 +272,6 @@ /** | ||
*/ | ||
declare class JSONRPCInvalidRequest extends JSONRPCProviderError<-32600> { | ||
declare class JSONRPCInvalidRequest extends JSONRPCProviderError { | ||
readonly methodName: string; | ||
readonly innerError?: unknown; | ||
constructor(methodName: string, message: string, data: ObjectErrorData, innerError?: unknown); | ||
} | ||
@@ -261,3 +284,6 @@ /** | ||
*/ | ||
declare class JSONRPCMethodNotFound extends JSONRPCProviderError<-32601> { | ||
declare class JSONRPCMethodNotFound extends JSONRPCProviderError { | ||
readonly methodName: string; | ||
readonly innerError?: unknown; | ||
constructor(methodName: string, message: string, data: ObjectErrorData, innerError?: unknown); | ||
} | ||
@@ -270,3 +296,6 @@ /** | ||
*/ | ||
declare class JSONRPCInvalidParams extends JSONRPCProviderError<-32602> { | ||
declare class JSONRPCInvalidParams extends JSONRPCProviderError { | ||
readonly methodName: string; | ||
readonly innerError?: unknown; | ||
constructor(methodName: string, message: string, data: ObjectErrorData, innerError?: unknown); | ||
} | ||
@@ -279,3 +308,6 @@ /** | ||
*/ | ||
declare class JSONRPCInternalError extends JSONRPCProviderError<-32603> { | ||
declare class JSONRPCInternalError extends JSONRPCProviderError { | ||
readonly methodName: string; | ||
readonly innerError?: unknown; | ||
constructor(methodName: string, message: string, data: ObjectErrorData, innerError?: unknown); | ||
} | ||
@@ -288,3 +320,6 @@ /** | ||
*/ | ||
declare class JSONRPCServerError extends JSONRPCProviderError<-32000> { | ||
declare class JSONRPCServerError extends JSONRPCProviderError { | ||
readonly methodName: string; | ||
readonly innerError?: unknown; | ||
constructor(methodName: string, message: string, data: ObjectErrorData, innerError?: unknown); | ||
} | ||
@@ -371,2 +406,11 @@ | ||
/** | ||
* Signer method error. | ||
* | ||
* WHEN TO USE: | ||
* * This error will be thrown when a signer method has failed. | ||
*/ | ||
declare class SignerMethodError extends VechainSDKError<ObjectErrorData> { | ||
} | ||
/** | ||
* Unavailable transaction field (field name) error. | ||
@@ -426,2 +470,4 @@ * | ||
declare const errors_CertificateSignatureMismatch: typeof CertificateSignatureMismatch; | ||
type errors_ContractCallError = ContractCallError; | ||
declare const errors_ContractCallError: typeof ContractCallError; | ||
type errors_ContractDeploymentFailed = ContractDeploymentFailed; | ||
@@ -481,6 +527,7 @@ declare const errors_ContractDeploymentFailed: typeof ContractDeploymentFailed; | ||
declare const errors_JSONRPCParseError: typeof JSONRPCParseError; | ||
type errors_JSONRPCProviderError<TJSONRpcErrorCode extends -32700 | -32600 | -32601 | -32602 | -32603 | -32000> = JSONRPCProviderError<TJSONRpcErrorCode>; | ||
type errors_JSONRPCProviderError = JSONRPCProviderError; | ||
declare const errors_JSONRPCProviderError: typeof JSONRPCProviderError; | ||
type errors_JSONRPCServerError = JSONRPCServerError; | ||
declare const errors_JSONRPCServerError: typeof JSONRPCServerError; | ||
type errors_JSONRpcErrorCode = JSONRpcErrorCode; | ||
type errors_NotDelegatedTransaction = NotDelegatedTransaction; | ||
@@ -491,2 +538,6 @@ declare const errors_NotDelegatedTransaction: typeof NotDelegatedTransaction; | ||
declare const errors_PollExecution: typeof PollExecution; | ||
type errors_ProviderMethodError = ProviderMethodError; | ||
declare const errors_ProviderMethodError: typeof ProviderMethodError; | ||
type errors_SignerMethodError = SignerMethodError; | ||
declare const errors_SignerMethodError: typeof SignerMethodError; | ||
type errors_UnavailableTransactionField = UnavailableTransactionField; | ||
@@ -502,5 +553,5 @@ declare const errors_UnavailableTransactionField: typeof UnavailableTransactionField; | ||
declare namespace errors { | ||
export { errors_CannotFindTransaction as CannotFindTransaction, errors_CertificateSignatureMismatch as CertificateSignatureMismatch, errors_ContractDeploymentFailed as ContractDeploymentFailed, errors_InvalidAbiDataToEncodeOrDecode as InvalidAbiDataToEncodeOrDecode, errors_InvalidAbiItem as InvalidAbiItem, errors_InvalidAbiSignatureFormat as InvalidAbiSignatureFormat, errors_InvalidAddress as InvalidAddress, errors_InvalidBloom as InvalidBloom, errors_InvalidBloomParams as InvalidBloomParams, errors_InvalidCommandLineArguments as InvalidCommandLineArguments, errors_InvalidConfigurationFile as InvalidConfigurationFile, errors_InvalidConfigurationFilePath as InvalidConfigurationFilePath, errors_InvalidDataType as InvalidDataType, errors_InvalidHDKey as InvalidHDKey, errors_InvalidHDKeyMnemonic as InvalidHDKeyMnemonic, errors_InvalidHTTPRequest as InvalidHTTPRequest, errors_InvalidKeystore as InvalidKeystore, errors_InvalidKeystoreParams as InvalidKeystoreParams, errors_InvalidOperation as InvalidOperation, 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 { errors_CannotFindTransaction as CannotFindTransaction, errors_CertificateSignatureMismatch as CertificateSignatureMismatch, errors_ContractCallError as ContractCallError, errors_ContractDeploymentFailed as ContractDeploymentFailed, errors_InvalidAbiDataToEncodeOrDecode as InvalidAbiDataToEncodeOrDecode, errors_InvalidAbiItem as InvalidAbiItem, errors_InvalidAbiSignatureFormat as InvalidAbiSignatureFormat, errors_InvalidAddress as InvalidAddress, errors_InvalidBloom as InvalidBloom, errors_InvalidBloomParams as InvalidBloomParams, errors_InvalidCommandLineArguments as InvalidCommandLineArguments, errors_InvalidConfigurationFile as InvalidConfigurationFile, errors_InvalidConfigurationFilePath as InvalidConfigurationFilePath, errors_InvalidDataType as InvalidDataType, errors_InvalidHDKey as InvalidHDKey, errors_InvalidHDKeyMnemonic as InvalidHDKeyMnemonic, errors_InvalidHTTPRequest as InvalidHTTPRequest, errors_InvalidKeystore as InvalidKeystore, errors_InvalidKeystoreParams as InvalidKeystoreParams, errors_InvalidOperation as InvalidOperation, 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, type errors_JSONRpcErrorCode as JSONRpcErrorCode, errors_NotDelegatedTransaction as NotDelegatedTransaction, type errors_ObjectErrorData as ObjectErrorData, errors_PollExecution as PollExecution, errors_ProviderMethodError as ProviderMethodError, errors_SignerMethodError as SignerMethodError, 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 { CannotFindTransaction, CertificateSignatureMismatch, ContractDeploymentFailed, InvalidAbiDataToEncodeOrDecode, InvalidAbiItem, InvalidAbiSignatureFormat, InvalidAddress, InvalidBloom, InvalidBloomParams, InvalidCommandLineArguments, InvalidConfigurationFile, InvalidConfigurationFilePath, InvalidDataType, InvalidHDKey, InvalidHDKeyMnemonic, InvalidHTTPRequest, InvalidKeystore, InvalidKeystoreParams, InvalidOperation, InvalidRLP, InvalidSecp256k1MessageHash, InvalidSecp256k1PrivateKey, InvalidSecp256k1Signature, InvalidTransactionField, JSONRPCInternalError, JSONRPCInvalidParams, JSONRPCInvalidRequest, JSONRPCMethodNotFound, JSONRPCParseError, JSONRPCProviderError, JSONRPCServerError, NotDelegatedTransaction, type ObjectErrorData, PollExecution, UnavailableTransactionField, UnsupportedOperation, VechainSDKError, assertInnerError, createErrorMessage, errors, stringifyData }; | ||
export { CannotFindTransaction, CertificateSignatureMismatch, ContractCallError, ContractDeploymentFailed, InvalidAbiDataToEncodeOrDecode, InvalidAbiItem, InvalidAbiSignatureFormat, InvalidAddress, InvalidBloom, InvalidBloomParams, InvalidCommandLineArguments, InvalidConfigurationFile, InvalidConfigurationFilePath, InvalidDataType, InvalidHDKey, InvalidHDKeyMnemonic, InvalidHTTPRequest, InvalidKeystore, InvalidKeystoreParams, InvalidOperation, InvalidRLP, InvalidSecp256k1MessageHash, InvalidSecp256k1PrivateKey, InvalidSecp256k1Signature, InvalidTransactionField, JSONRPCInternalError, JSONRPCInvalidParams, JSONRPCInvalidRequest, JSONRPCMethodNotFound, JSONRPCParseError, JSONRPCProviderError, JSONRPCServerError, type JSONRpcErrorCode, NotDelegatedTransaction, type ObjectErrorData, PollExecution, ProviderMethodError, SignerMethodError, UnavailableTransactionField, UnsupportedOperation, VechainSDKError, assertInnerError, createErrorMessage, errors, stringifyData }; |
@@ -1,310 +0,53 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
'use strict'; | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
CannotFindTransaction: () => CannotFindTransaction, | ||
CertificateSignatureMismatch: () => CertificateSignatureMismatch, | ||
ContractDeploymentFailed: () => ContractDeploymentFailed, | ||
InvalidAbiDataToEncodeOrDecode: () => InvalidAbiDataToEncodeOrDecode, | ||
InvalidAbiItem: () => InvalidAbiItem, | ||
InvalidAbiSignatureFormat: () => InvalidAbiSignatureFormat, | ||
InvalidAddress: () => InvalidAddress, | ||
InvalidBloom: () => InvalidBloom, | ||
InvalidBloomParams: () => InvalidBloomParams, | ||
InvalidCommandLineArguments: () => InvalidCommandLineArguments, | ||
InvalidConfigurationFile: () => InvalidConfigurationFile, | ||
InvalidConfigurationFilePath: () => InvalidConfigurationFilePath, | ||
InvalidDataType: () => InvalidDataType, | ||
InvalidHDKey: () => InvalidHDKey, | ||
InvalidHDKeyMnemonic: () => InvalidHDKeyMnemonic, | ||
InvalidHTTPRequest: () => InvalidHTTPRequest, | ||
InvalidKeystore: () => InvalidKeystore, | ||
InvalidKeystoreParams: () => InvalidKeystoreParams, | ||
InvalidOperation: () => InvalidOperation, | ||
InvalidRLP: () => InvalidRLP, | ||
InvalidSecp256k1MessageHash: () => InvalidSecp256k1MessageHash, | ||
InvalidSecp256k1PrivateKey: () => InvalidSecp256k1PrivateKey, | ||
InvalidSecp256k1Signature: () => InvalidSecp256k1Signature, | ||
InvalidTransactionField: () => InvalidTransactionField, | ||
JSONRPCInternalError: () => JSONRPCInternalError, | ||
JSONRPCInvalidParams: () => JSONRPCInvalidParams, | ||
JSONRPCInvalidRequest: () => JSONRPCInvalidRequest, | ||
JSONRPCMethodNotFound: () => JSONRPCMethodNotFound, | ||
JSONRPCParseError: () => JSONRPCParseError, | ||
JSONRPCProviderError: () => JSONRPCProviderError, | ||
JSONRPCServerError: () => JSONRPCServerError, | ||
NotDelegatedTransaction: () => NotDelegatedTransaction, | ||
PollExecution: () => PollExecution, | ||
UnavailableTransactionField: () => UnavailableTransactionField, | ||
UnsupportedOperation: () => UnsupportedOperation, | ||
VechainSDKError: () => VechainSDKError, | ||
assertInnerError: () => assertInnerError, | ||
createErrorMessage: () => createErrorMessage, | ||
errors: () => errors_exports, | ||
stringifyData: () => stringifyData | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
// src/errors.ts | ||
var errors_exports = {}; | ||
__export(errors_exports, { | ||
CannotFindTransaction: () => CannotFindTransaction, | ||
CertificateSignatureMismatch: () => CertificateSignatureMismatch, | ||
ContractDeploymentFailed: () => ContractDeploymentFailed, | ||
InvalidAbiDataToEncodeOrDecode: () => InvalidAbiDataToEncodeOrDecode, | ||
InvalidAbiItem: () => InvalidAbiItem, | ||
InvalidAbiSignatureFormat: () => InvalidAbiSignatureFormat, | ||
InvalidAddress: () => InvalidAddress, | ||
InvalidBloom: () => InvalidBloom, | ||
InvalidBloomParams: () => InvalidBloomParams, | ||
InvalidCommandLineArguments: () => InvalidCommandLineArguments, | ||
InvalidConfigurationFile: () => InvalidConfigurationFile, | ||
InvalidConfigurationFilePath: () => InvalidConfigurationFilePath, | ||
InvalidDataType: () => InvalidDataType, | ||
InvalidHDKey: () => InvalidHDKey, | ||
InvalidHDKeyMnemonic: () => InvalidHDKeyMnemonic, | ||
InvalidHTTPRequest: () => InvalidHTTPRequest, | ||
InvalidKeystore: () => InvalidKeystore, | ||
InvalidKeystoreParams: () => InvalidKeystoreParams, | ||
InvalidOperation: () => InvalidOperation, | ||
InvalidRLP: () => InvalidRLP, | ||
InvalidSecp256k1MessageHash: () => InvalidSecp256k1MessageHash, | ||
InvalidSecp256k1PrivateKey: () => InvalidSecp256k1PrivateKey, | ||
InvalidSecp256k1Signature: () => InvalidSecp256k1Signature, | ||
InvalidTransactionField: () => InvalidTransactionField, | ||
JSONRPCInternalError: () => JSONRPCInternalError, | ||
JSONRPCInvalidParams: () => JSONRPCInvalidParams, | ||
JSONRPCInvalidRequest: () => JSONRPCInvalidRequest, | ||
JSONRPCMethodNotFound: () => JSONRPCMethodNotFound, | ||
JSONRPCParseError: () => JSONRPCParseError, | ||
JSONRPCProviderError: () => JSONRPCProviderError, | ||
JSONRPCServerError: () => JSONRPCServerError, | ||
NotDelegatedTransaction: () => NotDelegatedTransaction, | ||
PollExecution: () => PollExecution, | ||
UnavailableTransactionField: () => UnavailableTransactionField, | ||
UnsupportedOperation: () => UnsupportedOperation, | ||
VechainSDKError: () => VechainSDKError, | ||
assertInnerError: () => assertInnerError, | ||
createErrorMessage: () => createErrorMessage, | ||
stringifyData: () => stringifyData | ||
}); | ||
// src/helpers/helpers.ts | ||
var stringifyData = (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(), 2); | ||
}; | ||
function assertInnerError(error) { | ||
if (error instanceof Error) { | ||
return error; | ||
} | ||
return new Error( | ||
`Inner error is not an instance of Error. Object: | ||
${stringifyData(error)}` | ||
); | ||
} | ||
function createErrorMessage(methodName, errorMessage, inputData, innerError) { | ||
return `Method '${methodName}' failed. | ||
-Reason: '${errorMessage}' | ||
var C=Object.defineProperty;var P=(t,a)=>{for(var e in a)C(t,e,{get:a[e],enumerable:!0});};var R={};P(R,{CannotFindTransaction:()=>J,CertificateSignatureMismatch:()=>u,ContractCallError:()=>l,ContractDeploymentFailed:()=>y,InvalidAbiDataToEncodeOrDecode:()=>f,InvalidAbiItem:()=>i,InvalidAbiSignatureFormat:()=>E,InvalidAddress:()=>d,InvalidBloom:()=>D,InvalidBloomParams:()=>g,InvalidCommandLineArguments:()=>X,InvalidConfigurationFile:()=>Z,InvalidConfigurationFilePath:()=>Y,InvalidDataType:()=>j,InvalidHDKey:()=>h,InvalidHDKeyMnemonic:()=>O,InvalidHTTPRequest:()=>w,InvalidKeystore:()=>V,InvalidKeystoreParams:()=>k,InvalidOperation:()=>M,InvalidRLP:()=>T,InvalidSecp256k1MessageHash:()=>A,InvalidSecp256k1PrivateKey:()=>_,InvalidSecp256k1Signature:()=>q,InvalidTransactionField:()=>L,JSONRPCInternalError:()=>G,JSONRPCInvalidParams:()=>W,JSONRPCInvalidRequest:()=>U,JSONRPCMethodNotFound:()=>z,JSONRPCParseError:()=>$,JSONRPCProviderError:()=>p,JSONRPCServerError:()=>Q,NotDelegatedTransaction:()=>N,PollExecution:()=>K,ProviderMethodError:()=>S,SignerMethodError:()=>B,UnavailableTransactionField:()=>H,UnsupportedOperation:()=>b,VechainSDKError:()=>r,assertInnerError:()=>m,createErrorMessage:()=>x,stringifyData:()=>c});var c=t=>JSON.stringify(t,(()=>{let e=new WeakSet;return (s,o)=>{if(typeof o=="object"&&o!==null&&s!==""){if(e.has(o))return;e.add(o);}return o}})(),2);function m(t){return t instanceof Error?t:new Error(`Inner error is not an instance of Error. Object: | ||
${c(t)}`)}function x(t,a,e,s){return `Method '${t}' failed. | ||
-Reason: '${a}' | ||
-Parameters: | ||
${stringifyData(inputData)}${innerError?.message !== void 0 ? ` | ||
${c(e)}${s?.message!==void 0?` | ||
-Internal error: | ||
${innerError.message}` : ""}`; | ||
} | ||
${s.message}`:""}`}var r=class extends Error{constructor(e,s,o,n){super(x(e,s,o,n===void 0?void 0:m(n)));this.methodName=e;this.errorMessage=s;this.data=o;this.innerError=n;}};var f=class extends r{},i=class extends r{},E=class extends r{};var d=class extends r{};var D=class extends r{},g=class extends r{};var u=class extends r{};var y=class extends r{},l=class extends r{};var j=class extends r{},b=class extends r{};var O=class extends r{},h=class extends r{};var w=class extends r{};var V=class extends r{},k=class extends r{};var K=class extends r{};var S=class extends r{},p=class extends r{constructor(e,s,o,n,F){super(e,o,{code:s,message:o,data:n},F);this.methodName=e;this.innerError=F;}},$=class extends p{constructor(e,s,o,n){super(e,-32700,s,o,n);this.methodName=e;this.innerError=n;}},U=class extends p{constructor(e,s,o,n){super(e,-32600,s,o,n);this.methodName=e;this.innerError=n;}},z=class extends p{constructor(e,s,o,n){super(e,-32601,s,o,n);this.methodName=e;this.innerError=n;}},W=class extends p{constructor(e,s,o,n){super(e,-32602,s,o,n);this.methodName=e;this.innerError=n;}},G=class extends p{constructor(e,s,o,n){super(e,-32603,s,o,n);this.methodName=e;this.innerError=n;}},Q=class extends p{constructor(e,s,o,n){super(e,-32e3,s,o,n);this.methodName=e;this.innerError=n;}};var T=class extends r{};var X=class extends r{},Y=class extends r{},Z=class extends r{};var _=class extends r{},A=class extends r{},q=class extends r{};var B=class extends r{};var H=class extends r{},L=class extends r{},N=class extends r{},J=class extends r{};var M=class extends r{}; | ||
// src/available-errors/sdk-error.ts | ||
var VechainSDKError = class extends Error { | ||
constructor(methodName, errorMessage, data, innerError) { | ||
super( | ||
createErrorMessage( | ||
methodName, | ||
errorMessage, | ||
data, | ||
innerError === void 0 ? void 0 : assertInnerError(innerError) | ||
) | ||
); | ||
this.methodName = methodName; | ||
this.errorMessage = errorMessage; | ||
this.data = data; | ||
this.innerError = innerError; | ||
} | ||
}; | ||
// src/available-errors/abi/abi.ts | ||
var InvalidAbiDataToEncodeOrDecode = class extends VechainSDKError { | ||
}; | ||
var InvalidAbiItem = class extends VechainSDKError { | ||
}; | ||
var InvalidAbiSignatureFormat = class extends VechainSDKError { | ||
}; | ||
// src/available-errors/address/address.ts | ||
var InvalidAddress = class extends VechainSDKError { | ||
}; | ||
// src/available-errors/bloom/bloom.ts | ||
var InvalidBloom = class extends VechainSDKError { | ||
}; | ||
var InvalidBloomParams = class extends VechainSDKError { | ||
}; | ||
// src/available-errors/certificate/certificate.ts | ||
var CertificateSignatureMismatch = class extends VechainSDKError { | ||
}; | ||
// 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/hdkey/hdnode.ts | ||
var InvalidHDKeyMnemonic = class extends VechainSDKError { | ||
}; | ||
var InvalidHDKey = class extends VechainSDKError { | ||
}; | ||
// src/available-errors/http/http.ts | ||
var InvalidHTTPRequest = class extends VechainSDKError { | ||
}; | ||
// src/available-errors/keystore/keystore.ts | ||
var InvalidKeystore = class extends VechainSDKError { | ||
}; | ||
var InvalidKeystoreParams = 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 | ||
var InvalidRLP = class extends VechainSDKError { | ||
}; | ||
// src/available-errors/rpc-proxy/rpc-proxy.ts | ||
var InvalidCommandLineArguments = class extends VechainSDKError { | ||
}; | ||
var InvalidConfigurationFilePath = class extends VechainSDKError { | ||
}; | ||
var InvalidConfigurationFile = class extends VechainSDKError { | ||
}; | ||
// src/available-errors/secp256k1/secp256k1.ts | ||
var InvalidSecp256k1PrivateKey = class extends VechainSDKError { | ||
}; | ||
var InvalidSecp256k1MessageHash = class extends VechainSDKError { | ||
}; | ||
var InvalidSecp256k1Signature = class extends VechainSDKError { | ||
}; | ||
// src/available-errors/transaction/transaction.ts | ||
var UnavailableTransactionField = class extends VechainSDKError { | ||
}; | ||
var InvalidTransactionField = class extends VechainSDKError { | ||
}; | ||
var NotDelegatedTransaction = class extends VechainSDKError { | ||
}; | ||
var CannotFindTransaction = class extends VechainSDKError { | ||
}; | ||
// src/available-errors/vcdm/vcdm.ts | ||
var InvalidOperation = class extends VechainSDKError { | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
CannotFindTransaction, | ||
CertificateSignatureMismatch, | ||
ContractDeploymentFailed, | ||
InvalidAbiDataToEncodeOrDecode, | ||
InvalidAbiItem, | ||
InvalidAbiSignatureFormat, | ||
InvalidAddress, | ||
InvalidBloom, | ||
InvalidBloomParams, | ||
InvalidCommandLineArguments, | ||
InvalidConfigurationFile, | ||
InvalidConfigurationFilePath, | ||
InvalidDataType, | ||
InvalidHDKey, | ||
InvalidHDKeyMnemonic, | ||
InvalidHTTPRequest, | ||
InvalidKeystore, | ||
InvalidKeystoreParams, | ||
InvalidOperation, | ||
InvalidRLP, | ||
InvalidSecp256k1MessageHash, | ||
InvalidSecp256k1PrivateKey, | ||
InvalidSecp256k1Signature, | ||
InvalidTransactionField, | ||
JSONRPCInternalError, | ||
JSONRPCInvalidParams, | ||
JSONRPCInvalidRequest, | ||
JSONRPCMethodNotFound, | ||
JSONRPCParseError, | ||
JSONRPCProviderError, | ||
JSONRPCServerError, | ||
NotDelegatedTransaction, | ||
PollExecution, | ||
UnavailableTransactionField, | ||
UnsupportedOperation, | ||
VechainSDKError, | ||
assertInnerError, | ||
createErrorMessage, | ||
errors, | ||
stringifyData | ||
}); | ||
exports.CannotFindTransaction = J; | ||
exports.CertificateSignatureMismatch = u; | ||
exports.ContractCallError = l; | ||
exports.ContractDeploymentFailed = y; | ||
exports.InvalidAbiDataToEncodeOrDecode = f; | ||
exports.InvalidAbiItem = i; | ||
exports.InvalidAbiSignatureFormat = E; | ||
exports.InvalidAddress = d; | ||
exports.InvalidBloom = D; | ||
exports.InvalidBloomParams = g; | ||
exports.InvalidCommandLineArguments = X; | ||
exports.InvalidConfigurationFile = Z; | ||
exports.InvalidConfigurationFilePath = Y; | ||
exports.InvalidDataType = j; | ||
exports.InvalidHDKey = h; | ||
exports.InvalidHDKeyMnemonic = O; | ||
exports.InvalidHTTPRequest = w; | ||
exports.InvalidKeystore = V; | ||
exports.InvalidKeystoreParams = k; | ||
exports.InvalidOperation = M; | ||
exports.InvalidRLP = T; | ||
exports.InvalidSecp256k1MessageHash = A; | ||
exports.InvalidSecp256k1PrivateKey = _; | ||
exports.InvalidSecp256k1Signature = q; | ||
exports.InvalidTransactionField = L; | ||
exports.JSONRPCInternalError = G; | ||
exports.JSONRPCInvalidParams = W; | ||
exports.JSONRPCInvalidRequest = U; | ||
exports.JSONRPCMethodNotFound = z; | ||
exports.JSONRPCParseError = $; | ||
exports.JSONRPCProviderError = p; | ||
exports.JSONRPCServerError = Q; | ||
exports.NotDelegatedTransaction = N; | ||
exports.PollExecution = K; | ||
exports.ProviderMethodError = S; | ||
exports.SignerMethodError = B; | ||
exports.UnavailableTransactionField = H; | ||
exports.UnsupportedOperation = b; | ||
exports.VechainSDKError = r; | ||
exports.assertInnerError = m; | ||
exports.createErrorMessage = x; | ||
exports.errors = R; | ||
exports.stringifyData = c; |
{ | ||
"name": "@vechain/sdk-errors", | ||
"version": "1.0.0-beta.32", | ||
"version": "1.0.0-rc.1", | ||
"description": "This module is dedicated to managing and customizing errors within the VeChain SDK", | ||
@@ -27,7 +27,7 @@ "author": "VeChain Foundation", | ||
"scripts": { | ||
"start-thor-solo": "echo 'Starting thor solo node ...' && docker compose up -d --wait && echo '\nThor solo node started ...'", | ||
"stop-thor-solo": "echo 'Stopping thor solo node ...' && docker compose down && echo 'Thor solo node stopped ...'", | ||
"build": "rm -rf ./dist && tsup-node src/index.ts --format cjs,esm --dts", | ||
"lint": "eslint --ext .ts src --ext .ts tests", | ||
"format": "prettier --write src/**/*.ts tests/**/*.ts", | ||
"start-thor-solo": "echo 'Starting thor solo node ...' && docker compose -f ../../docker-compose.thor.yml up -d --wait && echo '\nThor solo node started ...'", | ||
"stop-thor-solo": "echo 'Stopping thor solo node ...' && docker compose -f ../../docker-compose.thor.yml down && echo 'Thor solo node stopped ...'", | ||
"test:unit": "rm -rf ./coverageUnit && jest --coverage --coverageDirectory=coverageUnit --group=unit", | ||
@@ -34,0 +34,0 @@ "test:integration": "rm -rf ./coverageIntegration && jest --coverage --coverageDirectory=coverageIntegration --group=integration", |
@@ -12,2 +12,10 @@ import { VechainSDKError } from '../sdk-error'; | ||
export { ContractDeploymentFailed }; | ||
/** | ||
* Error when calling a read function on a contract. | ||
* | ||
* WHEN TO USE: | ||
* * Error will be thrown when a read (call) operation fails. | ||
*/ | ||
class ContractCallError extends VechainSDKError<ObjectErrorData> {} | ||
export { ContractCallError, ContractDeploymentFailed }; |
@@ -14,6 +14,7 @@ export * from './abi'; | ||
export * from './rpc-proxy'; | ||
export * from './sdk-error'; | ||
export * from './secp256k1'; | ||
export * from './signer'; | ||
export * from './transaction'; | ||
export type * from './types.d'; | ||
export * from './vcdm'; | ||
export * from './sdk-error'; | ||
export type * from './types.d'; |
import { VechainSDKError } from '../sdk-error'; | ||
import { type ObjectErrorData } from '../types'; | ||
import type { JSONRpcErrorCode, ObjectErrorData } from '../types'; | ||
/** | ||
* Provider method error. | ||
* | ||
* WHEN TO USE: | ||
* * This error will be thrown when a provider method has failed. | ||
*/ | ||
class ProviderMethodError extends VechainSDKError<ObjectErrorData> {} | ||
/** | ||
* Provider generic error. | ||
@@ -12,12 +20,4 @@ * | ||
*/ | ||
class JSONRPCProviderError< | ||
TJSONRpcErrorCode extends | ||
| -32700 | ||
| -32600 | ||
| -32601 | ||
| -32602 | ||
| -32603 | ||
| -32000 | ||
> extends VechainSDKError<{ | ||
code: TJSONRpcErrorCode; | ||
class JSONRPCProviderError extends VechainSDKError<{ | ||
code: JSONRpcErrorCode; | ||
message: string; | ||
@@ -28,3 +28,3 @@ data: ObjectErrorData; | ||
readonly methodName: string, | ||
code: TJSONRpcErrorCode, | ||
code: JSONRpcErrorCode, | ||
message: string, | ||
@@ -44,3 +44,12 @@ data: ObjectErrorData, | ||
*/ | ||
class JSONRPCParseError extends JSONRPCProviderError<-32700> {} | ||
class JSONRPCParseError extends JSONRPCProviderError { | ||
constructor( | ||
readonly methodName: string, | ||
message: string, | ||
data: ObjectErrorData, | ||
readonly innerError?: unknown | ||
) { | ||
super(methodName, -32700, message, data, innerError); | ||
} | ||
} | ||
@@ -53,3 +62,12 @@ /** | ||
*/ | ||
class JSONRPCInvalidRequest extends JSONRPCProviderError<-32600> {} | ||
class JSONRPCInvalidRequest extends JSONRPCProviderError { | ||
constructor( | ||
readonly methodName: string, | ||
message: string, | ||
data: ObjectErrorData, | ||
readonly innerError?: unknown | ||
) { | ||
super(methodName, -32600, message, data, innerError); | ||
} | ||
} | ||
@@ -62,3 +80,12 @@ /** | ||
*/ | ||
class JSONRPCMethodNotFound extends JSONRPCProviderError<-32601> {} | ||
class JSONRPCMethodNotFound extends JSONRPCProviderError { | ||
constructor( | ||
readonly methodName: string, | ||
message: string, | ||
data: ObjectErrorData, | ||
readonly innerError?: unknown | ||
) { | ||
super(methodName, -32601, message, data, innerError); | ||
} | ||
} | ||
@@ -71,3 +98,12 @@ /** | ||
*/ | ||
class JSONRPCInvalidParams extends JSONRPCProviderError<-32602> {} | ||
class JSONRPCInvalidParams extends JSONRPCProviderError { | ||
constructor( | ||
readonly methodName: string, | ||
message: string, | ||
data: ObjectErrorData, | ||
readonly innerError?: unknown | ||
) { | ||
super(methodName, -32602, message, data, innerError); | ||
} | ||
} | ||
@@ -80,3 +116,12 @@ /** | ||
*/ | ||
class JSONRPCInternalError extends JSONRPCProviderError<-32603> {} | ||
class JSONRPCInternalError extends JSONRPCProviderError { | ||
constructor( | ||
readonly methodName: string, | ||
message: string, | ||
data: ObjectErrorData, | ||
readonly innerError?: unknown | ||
) { | ||
super(methodName, -32603, message, data, innerError); | ||
} | ||
} | ||
@@ -89,12 +134,22 @@ /** | ||
*/ | ||
class JSONRPCServerError extends JSONRPCProviderError<-32000> {} | ||
class JSONRPCServerError extends JSONRPCProviderError { | ||
constructor( | ||
readonly methodName: string, | ||
message: string, | ||
data: ObjectErrorData, | ||
readonly innerError?: unknown | ||
) { | ||
super(methodName, -32000, message, data, innerError); | ||
} | ||
} | ||
export { | ||
JSONRPCProviderError, | ||
JSONRPCParseError, | ||
JSONRPCInternalError, | ||
JSONRPCInvalidParams, | ||
JSONRPCInvalidRequest, | ||
JSONRPCMethodNotFound, | ||
JSONRPCInvalidParams, | ||
JSONRPCInternalError, | ||
JSONRPCServerError | ||
JSONRPCParseError, | ||
JSONRPCProviderError, | ||
JSONRPCServerError, | ||
ProviderMethodError | ||
}; |
@@ -5,3 +5,4 @@ /** | ||
type ObjectErrorData = Record<string, unknown>; | ||
type JSONRpcErrorCode = -32700 | -32600 | -32601 | -32602 | -32603 | -32000; | ||
export type { ObjectErrorData }; | ||
export type { ObjectErrorData, JSONRpcErrorCode }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
47
4.44%71452
-3.74%1218
-20.5%1
Infinity%