import { TransactionId } from 'ddk.registry/dist/model/common/type' ; import { Transaction } from 'shared/model/transaction' ; import TransactionRepository from 'core/repository/transaction' ; import TransactionPGRepository from 'core/repository/transaction/pg' ; import { ConfirmedTransactionRepository } from 'core/repository/transaction/confirmed' ; class TransactionStorageService { add ( transaction ) { TransactionRepository . add ( transaction ) ; ConfirmedTransactionRepository . add ( transaction . id ) ; } delete ( id ) { TransactionRepository . delete ( id ) ; ConfirmedTransactionRepository . delete ( id ) ; } has ( id ) { return ConfirmedTransactionRepository . has ( id ) ; } get size ( ) : number { return ConfirmedTransactionRepository . size ; } async getById ( id ) { if ( ! ConfirmedTransactionRepository . has ( id ) ) { return null ; } const transaction = TransactionRepository . getById ( id ) ; if ( transaction ) { return transaction ; } return TransactionPGRepository . getById ( id ) ; } } export default new TransactionStorageService ( ) ;