import { IAssetService } from 'core/service/transaction' ; import { TransactionModel } from 'shared/model/transaction' ; import { IAssetSignature , Transaction } from 'shared/model/transaction' ; import { Account } from 'shared/model/account' ; import { ResponseEntity } from 'shared/model/response' ; import config from 'shared/config' ; class TransactionSignatureService implements IAssetService < IAssetSignature > { create ( trs ) { return { publicKey : trs . asset . publicKey , } ; } getBytes ( trs ) { return Buffer . from ( trs . asset . publicKey , 'hex' ) ; } validate ( trs ) { const errors = [ ] ; if ( ! trs . asset ) { errors . push ( 'Missing asset' ) ; return new ResponseEntity < void > ( { errors } ) ; } if ( ! trs . asset . publicKey ) { errors . push ( 'Missing second public key' ) ; } return new ResponseEntity < void > ( { errors } ) ; } verifyUnconfirmed ( trs , sender ) { const errors = [ ] ; if ( sender . secondPublicKey ) { errors . push ( 'User already has second public key' ) ; } return new ResponseEntity < void > ( { errors } ) ; } calculateFee ( trs , sender ) { return config . CONSTANTS . FEES . SECOND_SIGNATURE ; } applyUnconfirmed ( trs , sender ) { sender . secondPublicKey = trs . asset . publicKey ; } undoUnconfirmed ( trs , sender , senderOnly ) { sender . secondPublicKey = null ; } } export default new TransactionSignatureService ( ) ;