export enum ArchWalletErrorType { InvalidFeeRate = 'InvalidFeeRate', InvalidUtxo = 'InvalidUtxo', InvalidPubkey = 'InvalidPubkey', InvalidAddress = 'InvalidAddress', NotEnoughFunds = 'NotEnoughFunds', } interface CommonArchWalletError { type: ArchWalletErrorType; message: string; } export interface InvalidFeeRateError extends CommonArchWalletError { type: ArchWalletErrorType.InvalidFeeRate; minFeeRate: number; } export interface InvalidUtxoError extends CommonArchWalletError { type: ArchWalletErrorType.InvalidUtxo; utxos: string[]; } export interface InvalidPubkeyError extends CommonArchWalletError { type: ArchWalletErrorType.InvalidPubkey; pubkey: string; } export interface InvalidAddressError extends CommonArchWalletError { type: ArchWalletErrorType.InvalidAddress; } export interface NotEnoughFundsError extends CommonArchWalletError { type: ArchWalletErrorType.NotEnoughFunds; maxAmount: string; minAmount: string; token: string; } export type ArchWalletError = | InvalidFeeRateError | InvalidUtxoError | InvalidPubkeyError | InvalidAddressError | NotEnoughFundsError; export class ArchWalletErrorException extends Error { error: ArchWalletError; constructor(error: ArchWalletError) { super(error.message); this.name = 'PoolError'; this.error = error; } getError(): ArchWalletError { return this.error; } }