import { PaymentsFactory , StandardConnectionManager } from '@bitaccess/coinlib-common' ; import { assertType } from '@faast/ts-common' ; import { RipplePaymentsConfig , HdRipplePaymentsConfig , AccountRipplePaymentsConfig , BaseRipplePaymentsConfig , RippleBalanceMonitorConfig , BaseRippleConfig , RippleServerAPI , } from './types' ; import { PACKAGE_NAME } from './constants' ; import { BaseRipplePayments } from './BaseRipplePayments' ; import { HdRipplePayments } from './HdRipplePayments' ; import { AccountRipplePayments } from './AccountRipplePayments' ; import { RipplePaymentsUtils } from './RipplePaymentsUtils' ; import { RippleBalanceMonitor } from './RippleBalanceMonitor' ; import { RippleConnected } from './RippleConnected' ; export class RipplePaymentsFactory extends PaymentsFactory < BaseRippleConfig , RipplePaymentsUtils , BaseRipplePayments < BaseRippleConfig > , RippleBalanceMonitor > { readonly packageName = PACKAGE_NAME ; newPayments ( config ) ; newPayments ( config ) ; newPayments ( config ) { if ( AccountRipplePaymentsConfig . is ( config ) ) { return new AccountRipplePayments ( config ) ; } if ( HdRipplePaymentsConfig . is ( config ) ) { return new HdRipplePayments ( config ) ; } throw new Error ( `Cannot instantiate ${ this . packageName } for unsupported config` ) ; } newUtils ( config ) { return new RipplePaymentsUtils ( assertType ( BaseRipplePaymentsConfig , config , 'config' ) ) ; } hasBalanceMonitor = true ; newBalanceMonitor ( config ) { return new RippleBalanceMonitor ( assertType ( RippleBalanceMonitorConfig , config , 'config' ) ) ; } connectionManager = new StandardConnectionManager < RippleServerAPI , BaseRippleConfig > ( ) ; } export default RipplePaymentsFactory ;