@faast/tron-payments
Version:
Library to assist in processing tron payments, such as deriving addresses and sweeping funds
27 lines • 1.12 kB
JavaScript
import { PaymentsFactory } from '@faast/payments-common';
import { assertType } from '@faast/ts-common';
import { HdTronPaymentsConfig, KeyPairTronPaymentsConfig, BaseTronPaymentsConfig } from './types';
import { PACKAGE_NAME } from './constants';
import { HdTronPayments } from './HdTronPayments';
import { KeyPairTronPayments } from './KeyPairTronPayments';
import { TronPaymentsUtils } from './TronPaymentsUtils';
export class TronPaymentsFactory extends PaymentsFactory {
constructor() {
super(...arguments);
this.packageName = PACKAGE_NAME;
}
newPayments(config) {
if (HdTronPaymentsConfig.is(config)) {
return new HdTronPayments(config);
}
if (KeyPairTronPaymentsConfig.is(config)) {
return new KeyPairTronPayments(config);
}
throw new Error(`Cannot instantiate ${this.packageName} for unsupported config`);
}
newUtils(config) {
return new TronPaymentsUtils(assertType(BaseTronPaymentsConfig, config, 'config'));
}
}
export default TronPaymentsFactory;
//# sourceMappingURL=TronPaymentsFactory.js.map