import { getLogger , remove0x , serializeObject } from '@pigi/core-utils' ; import { SignedTransaction , RollupTransaction , Transfer , RollupBlock , } from '../../types' ; import { abi , signedTransactionAbiTypes , transferAbiTypes } from './common' ; const log = getLogger ( 'abiEncoders' ) ; param abiEncoded returns export const parseSignedTransactionFromABI = ( abiEncoded ) : SignedTransaction => { log . debug ( `ABI decoding SignedTransaction: ${ serializeObject ( abiEncoded ) }` ) ; const [ signature , tx ] = abi . decode ( signedTransactionAbiTypes , abiEncoded ) ; return { signature , transaction : parseTransactionFromABI ( tx ) , } ; } ; param abiEncoded returns export const parseTransactionFromABI = ( abiEncoded ) : RollupTransaction => { return parseTransferFromABI ( abiEncoded ) ; } ; export const abiDecodeRollupBlock = ( abiEncoded ) : RollupBlock => { return { blockNumber : 1 , stateRoot : '' , signedTransactions : [ ] , } ; } ; /*********************
 * PRIVATE FUNCTIONS *
 *********************/ param abiEncoded returns const parseTransferFromABI = ( abiEncoded ) : Transfer => { log . debug ( `ABI decoding Transfer: ${ serializeObject ( abiEncoded ) }` ) ; const [ sender , recipient , tokenType , amount ] = abi . decode ( transferAbiTypes , abiEncoded ) ; return { sender : remove0x ( sender ) , recipient : remove0x ( recipient ) , tokenType , amount , } ; } ; const getSlotIndex = ( slotIndexString ) : string => { return remove0x ( slotIndexString ) ; } ;