@taquito/core
Version:
Classes, interfaces, and types shared across Taquito packages
347 lines (343 loc) • 13 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.taquitoCore = {}));
})(this, (function (exports) { 'use strict';
// ==========================================================================================
// parent error classes for Taquito
// ==========================================================================================
/**
* @category Error
* @description Parent error class all taquito errors to extend from
*/
class TaquitoError extends Error {
}
/**
* @category Error
* @description Error that indicates invalid user inputs
*/
class ParameterValidationError extends TaquitoError {
}
/**
* @category Error
* @description Error returned by RPC node
*/
class RpcError extends TaquitoError {
}
/**
* @category Error
* @description Error that indicates TezosToolKit has not been configured appropriately
*/
class TezosToolkitConfigError extends TaquitoError {
}
/**
* @category Error
* @description Error that indicates a requested action is not supported by Taquito
*/
class UnsupportedActionError extends TaquitoError {
}
/**
* @category Error
* @description Error during a network operation
*/
class NetworkError extends TaquitoError {
}
/**
* @category Error
* @description Error that indicates user attempts an action without necessary permissions
*/
class PermissionDeniedError extends TaquitoError {
}
// ==========================================================================================
// common error classes for Taquito
// ==========================================================================================
/**
* @category Error
* @description Error that indicates an invalid originated or implicit address being passed or used
*/
class InvalidAddressError extends ParameterValidationError {
constructor(address, errorDetail) {
super();
this.address = address;
this.errorDetail = errorDetail;
this.name = 'InvalidAddressError';
this.message = `Invalid address "${address}"`;
this.message += errorDetail ? ` ${errorDetail}.` : '.';
}
}
class InvalidStakingAddressError extends ParameterValidationError {
constructor(address, errorDetail) {
super();
this.address = address;
this.errorDetail = errorDetail;
this.name = 'InvalidStakingAddressError';
this.message = `Invalid staking address "${address}", you can only set destination as your own address`;
}
}
class InvalidFinalizeUnstakeAmountError extends ParameterValidationError {
constructor(address, errorDetail) {
super();
this.address = address;
this.errorDetail = errorDetail;
this.name = 'InvalidFinalizeUnstakeAmountError';
this.message = `The amount can only be 0 when finalizing an unstake`;
}
}
/**
* @category Error
* @description Error that indicates an invalid block hash being passed or used
*/
class InvalidBlockHashError extends ParameterValidationError {
constructor(blockHash, errorDetail) {
super();
this.blockHash = blockHash;
this.errorDetail = errorDetail;
this.name = 'InvalidBlockHashError';
this.message = `Invalid block hash "${blockHash}"`;
this.message += errorDetail ? ` ${errorDetail}.` : '.';
}
}
/**
* @category Error
* @description Error that indicates an invalid amount of tez being passed as a parameter
*/
class InvalidAmountError extends ParameterValidationError {
constructor(amount) {
super();
this.amount = amount;
this.name = 'InvalidAmountError';
this.message = `Invalid amount "${amount}"`;
}
}
/**
* @category Error
* @description Error that indicates an invalid derivation path being passed or used
*/
class InvalidDerivationPathError extends ParameterValidationError {
constructor(derivationPath, errorDetail) {
super();
this.derivationPath = derivationPath;
this.errorDetail = errorDetail;
this.name = 'InvalidDerivationPathError';
this.message = `Invalid derivation path "${derivationPath}"`;
this.message += errorDetail ? ` ${errorDetail}.` : '.';
}
}
/**
* @category Error
* @description Error that indicates an invalid hex string have been passed or used
*/
class InvalidHexStringError extends ParameterValidationError {
constructor(hexString, errorDetail) {
super();
this.hexString = hexString;
this.errorDetail = errorDetail;
this.name = 'InvalidHexStringError';
this.message = `Invalid hex string "${hexString}"`;
this.message += errorDetail ? ` ${errorDetail}.` : '.';
}
}
/**
* @category Error
* @description Error that indicates an invalid message being passed or used
*/
class InvalidMessageError extends ParameterValidationError {
constructor(msg, errorDetail) {
super();
this.msg = msg;
this.errorDetail = errorDetail;
this.name = 'InvalidMessageError';
this.message = `Invalid message "${msg}"`;
this.message += errorDetail ? ` ${errorDetail}.` : '.';
}
}
/**
* @category Error
* @description Error that indicates invalid view parameter of a smart contract
*/
class InvalidViewParameterError extends ParameterValidationError {
constructor(viewName, sigs, args, cause) {
super();
this.viewName = viewName;
this.sigs = sigs;
this.args = args;
this.cause = cause;
this.name = 'InvalidViewParameterError';
this.message = `Invalid view arguments ${JSON.stringify(args)} received for name "${viewName}" expecting one of the following signatures ${JSON.stringify(sigs)}.`;
}
}
/**
* @category Error
* @description Error that indicates an invalid private key being passed or used
*/
class InvalidKeyError extends ParameterValidationError {
constructor(errorDetail) {
super();
this.errorDetail = errorDetail;
this.name = 'InvalidKeyError';
this.message = `Invalid private key`;
this.message += errorDetail ? ` ${errorDetail}.` : '.';
}
}
/**
* @category Error
* @description Error that indicates an Invalid Public Key being passed or used
*/
class InvalidPublicKeyError extends ParameterValidationError {
constructor(publicKey, errorDetail) {
super();
this.publicKey = publicKey;
this.errorDetail = errorDetail;
this.name = 'InvalidPublicKeyError';
this.message = `Invalid public key "${publicKey}"`;
this.message += errorDetail ? ` ${errorDetail}.` : '.';
}
}
/**
* @category Error
* @description Error that indicates an invalid signature being passed or used
*/
class InvalidSignatureError extends ParameterValidationError {
constructor(signature, errorDetail) {
super();
this.signature = signature;
this.errorDetail = errorDetail;
this.name = 'InvalidSignatureError';
this.message = `Invalid signature "${signature}"`;
this.message += errorDetail ? ` ${errorDetail}.` : '.';
}
}
/**
* @category Error
* @description Error that indicates an invalid contract address being passed or used
*/
class InvalidContractAddressError extends ParameterValidationError {
constructor(contractAddress, errorDetail) {
super();
this.contractAddress = contractAddress;
this.errorDetail = errorDetail;
this.name = 'InvalidContractAddressError';
this.message = `Invalid contract address "${contractAddress}"`;
this.message += errorDetail ? ` ${errorDetail}.` : '.';
}
}
/**
* @category Error
* @description Error that indicates an invalid chain id being passed or used
*/
class InvalidChainIdError extends ParameterValidationError {
constructor(chainId, errorDetail) {
super();
this.chainId = chainId;
this.errorDetail = errorDetail;
this.name = 'InvalidChainIdError';
this.message = `Invalid chain id "${chainId}"`;
this.message += errorDetail ? ` ${errorDetail}.` : '.';
}
}
/**
* @category Error
* @description Error that indicates an invalid public key hash being passed or used
*/
class InvalidKeyHashError extends ParameterValidationError {
constructor(keyHash, errorDetail) {
super();
this.keyHash = keyHash;
this.errorDetail = errorDetail;
this.name = 'InvalidKeyHashError';
this.message = `Invalid public key hash "${keyHash}"`;
this.message += errorDetail ? ` ${errorDetail}.` : '.';
}
}
/**
* @category Error
* @description Error that indicates an invalid operation hash being passed or used
*/
class InvalidOperationHashError extends ParameterValidationError {
constructor(operationHash, errorDetail) {
super();
this.operationHash = operationHash;
this.errorDetail = errorDetail;
this.name = 'InvalidOperationHashError';
this.message = `Invalid operation hash "${operationHash}"`;
this.message += errorDetail ? ` ${errorDetail}.` : '.';
}
}
/**
* @category Error
* @description Error that indicates an invalid operation kind being passed or used
*/
class InvalidOperationKindError extends ParameterValidationError {
constructor(operationKind, errorDetail) {
super();
this.operationKind = operationKind;
this.errorDetail = errorDetail;
this.name = 'InvalidOperationKindError';
this.message = `Invalid operation kind "${operationKind}"`;
this.message += errorDetail ? ` ${errorDetail}.` : '.';
}
}
/**
* @category Error
* @description General error that indicates something is no longer supported and/or deprecated
*/
class DeprecationError extends UnsupportedActionError {
constructor(message) {
super();
this.message = message;
this.name = 'DeprecationError';
}
}
/**
* @category Error
* @description General error that indicates an action is prohibited or not allowed
*/
class ProhibitedActionError extends UnsupportedActionError {
constructor(message) {
super();
this.message = message;
this.name = 'ProhibitedActionError';
}
}
/**
* @category Error
* @description Error that indicates a failure in grabbing the public key
*/
class PublicKeyNotFoundError extends TaquitoError {
constructor(pkh, cause) {
super();
this.pkh = pkh;
this.cause = cause;
this.name = 'PublicKeyNotFoundError';
this.message = `Public key not found of this address "${pkh}" in either wallet or contract API.`;
}
}
exports.DeprecationError = DeprecationError;
exports.InvalidAddressError = InvalidAddressError;
exports.InvalidAmountError = InvalidAmountError;
exports.InvalidBlockHashError = InvalidBlockHashError;
exports.InvalidChainIdError = InvalidChainIdError;
exports.InvalidContractAddressError = InvalidContractAddressError;
exports.InvalidDerivationPathError = InvalidDerivationPathError;
exports.InvalidFinalizeUnstakeAmountError = InvalidFinalizeUnstakeAmountError;
exports.InvalidHexStringError = InvalidHexStringError;
exports.InvalidKeyError = InvalidKeyError;
exports.InvalidKeyHashError = InvalidKeyHashError;
exports.InvalidMessageError = InvalidMessageError;
exports.InvalidOperationHashError = InvalidOperationHashError;
exports.InvalidOperationKindError = InvalidOperationKindError;
exports.InvalidPublicKeyError = InvalidPublicKeyError;
exports.InvalidSignatureError = InvalidSignatureError;
exports.InvalidStakingAddressError = InvalidStakingAddressError;
exports.InvalidViewParameterError = InvalidViewParameterError;
exports.NetworkError = NetworkError;
exports.ParameterValidationError = ParameterValidationError;
exports.PermissionDeniedError = PermissionDeniedError;
exports.ProhibitedActionError = ProhibitedActionError;
exports.PublicKeyNotFoundError = PublicKeyNotFoundError;
exports.RpcError = RpcError;
exports.TaquitoError = TaquitoError;
exports.TezosToolkitConfigError = TezosToolkitConfigError;
exports.UnsupportedActionError = UnsupportedActionError;
}));
//# sourceMappingURL=taquito-core.umd.js.map