UNPKG

raiden-ts

Version:

Raiden Light Client Typescript/Javascript SDK

160 lines (159 loc) 6.19 kB
import * as t from 'io-ts'; export declare const ErrorCodes: { PFS_EMPTY_URL: string; PFS_INVALID_URL: string; PFS_INVALID_INFO: string; PFS_TOO_EXPENSIVE: string; PFS_NO_ROUTES_FOUND: string; PFS_ERROR_RESPONSE: string; PFS_DISABLED: string; PFS_UNKNOWN_TOKEN_NETWORK: string; PFS_TARGET_OFFLINE: string; PFS_TARGET_NO_RECEIVE: string; PFS_LAST_IOU_REQUEST_FAILED: string; PFS_IOU_SIGNATURE_MISMATCH: string; PFS_NO_ROUTES_BETWEEN_NODES: string; CNL_INVALID_STATE: string; CNL_NO_OPEN_CHANNEL_FOUND: string; CNL_NO_OPEN_OR_CLOSING_CHANNEL_FOUND: string; CNL_NO_SETTLEABLE_OR_SETTLING_CHANNEL_FOUND: string; CNL_OPENCHANNEL_FAILED: string; CNL_SETTOTALDEPOSIT_FAILED: string; CNL_CLOSECHANNEL_FAILED: string; CNL_SETTLE_INVALID_BALANCEHASH: string; CNL_SETTLE_FAILED: string; CNL_COOP_SETTLE_FAILED: string; CNL_SETTLE_AUTO_ENABLED: string; CNL_UPDATE_NONCLOSING_BP_FAILED: string; CNL_ONCHAIN_UNLOCK_FAILED: string; CNL_WITHDRAW_PENDING: string; CNL_WITHDRAW_RETRY_CONFIRMATION: string; CNL_WITHDRAW_TRANSACTION_FAILED: string; CNL_WITHDRAW_EXPIRES_SOON: string; CNL_WITHDRAW_EXPIRED: string; CNL_WITHDRAW_AMOUNT_TOO_LOW: string; CNL_WITHDRAW_AMOUNT_TOO_HIGH: string; CNL_COOP_SETTLE_NOT_POSSIBLE: string; XFER_EXPIRED: string; XFER_CHANNEL_CLOSED_PREMATURELY: string; XFER_REFUNDED: string; XFER_INVALID_SECRETREQUEST: string; XFER_ALREADY_COMPLETED: string; XFER_REGISTERSECRET_TX_FAILED: string; TRNS_NO_MATRIX_SERVERS: string; TRNS_NO_VALID_USER: string; TRNS_NO_SERVERNAME: string; TRNS_MESSAGE_SIGNATURE_MISMATCH: string; RDN_GENERAL_ERROR: string; RDN_ASSERT_ERROR: string; RDN_MINT_FAILED: string; RDN_MINT_MAINNET: string; RDN_REGISTER_TOKEN_FAILED: string; RDN_REGISTER_TOKEN_MAINNET: string; RDN_REGISTER_TOKEN_REGISTERED: string; RDN_TRANSACTION_FAILED: string; RDN_APPROVE_TRANSACTION_FAILED: string; RDN_DEPOSIT_TRANSACTION_FAILED: string; RDN_TRANSFER_ONCHAIN_BALANCE_FAILED: string; RDN_TRANSFER_ONCHAIN_TOKENS_FAILED: string; RDN_UNRECOGNIZED_NETWORK: string; RDN_SIGNER_NOT_CONNECTED: string; RDN_ACCOUNT_NOT_FOUND: string; RDN_STRING_ACCOUNT_INVALID: string; RDN_TRANSACTION_REORG: string; RDN_STATE_MIGRATION: string; RDN_INSUFFICIENT_BALANCE: string; RDN_INSUFFICIENT_ALLOWANCE: string; RDN_NOT_A_TOKEN: string; RDN_STATE_ADDRESS_MISMATCH: string; RDN_STATE_NETWORK_MISMATCH: string; RDN_ALREADY_STARTED: string; RDN_UNKNOWN_TOKEN_NETWORK: string; RDN_INVALID_SECRET: string; RDN_INVALID_SECRETHASH: string; RDN_SECRET_SECRETHASH_MISMATCH: string; RDN_UNKNOWN_TRANSFER: string; RDN_DATABASE_DELETED: string; DTA_NEGATIVE_NUMBER: string; DTA_NUMBER_TOO_LARGE: string; DTA_ARRAY_LENGTH_DIFFERENCE: string; DTA_UNENCODABLE_DATA: string; DTA_NON_POSITIVE_NUMBER: string; DTA_INVALID_ADDRESS: string; DTA_INVALID_DEPOSIT: string; DTA_INVALID_TIMEOUT: string; DTA_INVALID_AMOUNT: string; DTA_INVALID_PAYMENT_ID: string; DTA_INVALID_PATH: string; DTA_INVALID_PFS: string; UDC_DEPOSIT_OUTDATED: string; UDC_PLAN_WITHDRAW_FAILED: string; UDC_PLAN_WITHDRAW_GT_ZERO: string; UDC_PLAN_WITHDRAW_EXCEEDS_AVAILABLE: string; UDC_WITHDRAW_NO_BALANCE: string; UDC_WITHDRAW_FAILED: string; UDC_WITHDRAW_AUTO_ENABLED: string; UDC_WITHDRAW_NO_PLAN: string; UDC_WITHDRAW_TOO_LARGE: string; }; export declare type ErrorCodes = keyof typeof ErrorCodes; export declare type ErrorMatch = string | number | { [k: string]: string | number; }; export declare type ErrorMatches = readonly ErrorMatch[]; declare type PredicateFunc = (err: any, count: number) => boolean | undefined; declare type LogFunc = (...args: any[]) => void; export declare function matchError(match: ErrorMatch | ErrorMatches): (error: any) => boolean; export declare function matchError(match: ErrorMatch | ErrorMatches, error: any): boolean; /** * Creates a function to decide if a given error should be retried or not * * @param opts - Options object * @param opts.maxRetries - maximum number of retries before rejecting * @param opts.onErrors - retry only on these errors * @param opts.neverOnErrors - Never retry on these errors * @param opts.predicate - Retry if this predicate matches * @param opts.stopPredicate - Don't retry if this predicate match * @param opts.log - Log using this function * @returns Function to test if errors should be retried or not */ export declare function shouldRetryError(opts: { readonly maxRetries?: number; readonly onErrors?: ErrorMatches; readonly neverOnErrors?: ErrorMatches; readonly predicate?: PredicateFunc; readonly stopPredicate?: PredicateFunc; readonly log?: LogFunc; }): (error: any) => boolean; export declare const networkErrors: ErrorMatches; export declare const commonTxErrors: ErrorMatches; export declare const commonAndFailTxErrors: ErrorMatches; export declare class RaidenError extends Error { details?: unknown; name: string; constructor(message?: string, details?: unknown); get code(): ErrorCodes; } /** * Type-safe assertion function (TS3.7) * * @param condition - Condition to validate as truthy * @param error - Message, Error, error factory or tuple of RaidenError constructor parameters * to throw if condition is falsy * @param log - Logger to log error to */ export declare function assert<E extends Error = RaidenError>(condition: any, error?: string | E | ((condition?: any) => E | never) | ConstructorParameters<typeof RaidenError>, log?: (...args: any[]) => void): asserts condition; /** * Simple Error codec * * This codec doesn't decode to an instance of the exact same error class object, but instead to * a generic Error, but assigning 'name', 'stack' & 'message' properties, more as an informative * object. */ export declare const ErrorCodec: t.Type<Error, { name: string; message?: string | undefined; stack?: string | undefined; details?: unknown; }, unknown>; export {};