UNPKG

chaingate

Version:

Multi-chain cryptocurrency SDK for TypeScript — unified API for Bitcoin, Ethereum, Litecoin, Dogecoin, Bitcoin Cash, Polygon, Arbitrum, and any EVM-compatible chain. Create wallets, query balances, send transactions, and manage tokens and NFTs across UTXO

121 lines (120 loc) 4.75 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RpcError = exports.InvalidKeystoreError = exports.IncorrectKeystorePasswordError = exports.RateLimitQuotaError = exports.RateLimitError = exports.NotEnoughFundsError = exports.TransactionAlreadySentError = exports.BroadcastError = exports.UnsupportedOperationError = exports.InvalidWalletExportError = exports.InvalidWalletParamsError = exports.UnrecognizedFormatError = exports.InvalidHexError = void 0; /** Thrown when a string is not valid hexadecimal. */ class InvalidHexError extends Error { constructor(message) { super(message); this.name = 'InvalidHexError'; } } exports.InvalidHexError = InvalidHexError; /** Thrown when an input string cannot be recognized as any supported wallet format. */ class UnrecognizedFormatError extends Error { constructor(message) { super(message); this.name = 'UnrecognizedFormatError'; } } exports.UnrecognizedFormatError = UnrecognizedFormatError; /** Thrown when {@link importWallet} receives invalid parameters. */ class InvalidWalletParamsError extends Error { constructor(message) { super(message); this.name = 'InvalidWalletParamsError'; } } exports.InvalidWalletParamsError = InvalidWalletParamsError; /** Thrown when {@link deserializeWallet} receives invalid data. */ class InvalidWalletExportError extends Error { constructor(message) { super(message); this.name = 'InvalidWalletExportError'; } } exports.InvalidWalletExportError = InvalidWalletExportError; /** Thrown when an operation is not supported for the given context (e.g. wrong wallet type, accessing token-only data on a native coin). */ class UnsupportedOperationError extends Error { constructor(message) { super(message); this.name = 'UnsupportedOperationError'; } } exports.UnsupportedOperationError = UnsupportedOperationError; /** Thrown when a transaction fails to broadcast. */ class BroadcastError extends Error { constructor(message) { super(message); this.name = 'BroadcastError'; } } exports.BroadcastError = BroadcastError; /** Thrown when a transaction has already been sent and cannot be modified. */ class TransactionAlreadySentError extends Error { constructor() { super('Transaction has already been sent and cannot be modified.'); this.name = 'TransactionAlreadySentError'; } } exports.TransactionAlreadySentError = TransactionAlreadySentError; /** Thrown when the wallet does not have enough funds to cover the transfer amount plus fees. */ class NotEnoughFundsError extends Error { constructor() { super('Not enough funds to cover the transaction amount and fees.'); this.name = 'NotEnoughFundsError'; } } exports.NotEnoughFundsError = NotEnoughFundsError; /** * Thrown when the keyless rate limit is exhausted (HTTP 429). * * ChainGate works without an API key for light usage. To raise the quota, * grab a free API key at {@link https://api.chaingate.dev} and pass it as * `new ChainGate({ apiKey })`. */ class RateLimitError extends Error { constructor() { super('ChainGate rate limit reached on the keyless tier. Get a free API key at ' + 'https://api.chaingate.dev and pass it as `new ChainGate({ apiKey })` ' + 'to raise your quota.'); this.name = 'RateLimitError'; } } exports.RateLimitError = RateLimitError; /** * Thrown when the API returns 429 Too Many Requests while using an API key. * * Upgrade your plan at {@link https://api.chaingate.dev} for a higher rate limit. */ class RateLimitQuotaError extends Error { constructor() { super('API key rate limit exceeded. Upgrade your plan at https://api.chaingate.dev for a higher quota.'); this.name = 'RateLimitQuotaError'; } } exports.RateLimitQuotaError = RateLimitQuotaError; /** Thrown when a keystore password is incorrect. */ class IncorrectKeystorePasswordError extends Error { constructor() { super('Password provided is not correct'); this.name = 'IncorrectKeystorePasswordError'; } } exports.IncorrectKeystorePasswordError = IncorrectKeystorePasswordError; /** Thrown when a keystore has an invalid or unrecognized format. */ class InvalidKeystoreError extends Error { constructor(message) { super(message); this.name = 'InvalidKeystoreError'; } } exports.InvalidKeystoreError = InvalidKeystoreError; /** Thrown when a JSON-RPC call to an EVM node fails. */ class RpcError extends Error { constructor(message, code) { super(message); this.name = 'RpcError'; this.code = code; } } exports.RpcError = RpcError;