import { convertLSKToBeddows , signTransaction } from '@liskhq/lisk-transactions' ; import { testing } from 'lisk-framework' ; const schema = { $id : 'lisk/transfer-asset' , title : 'Transfer transaction asset' , type : 'object' , required : [ 'amount' , 'recipientAddress' , 'data' ] , properties : { amount : { dataType : 'uint64' , fieldNumber : 1 , } , recipientAddress : { dataType : 'bytes' , fieldNumber : 2 , minLength : 20 , maxLength : 20 , } , data : { dataType : 'string' , fieldNumber : 3 , minLength : 0 , maxLength : 64 , } , } , } ; export const createTransferTransaction = ( { amount , fee , recipientAddress , nonce , networkIdentifier , } ) => { const genesisAccount = testing . fixtures . defaultFaucetAccount ; const transaction = signTransaction ( schema , { moduleID : 2 , assetID : 0 , nonce : BigInt ( nonce ) , fee : BigInt ( convertLSKToBeddows ( fee ) ) , senderPublicKey : genesisAccount . publicKey , asset : { amount : BigInt ( convertLSKToBeddows ( amount ) ) , recipientAddress : Buffer . from ( recipientAddress , 'hex' ) , data : '' , } , } , networkIdentifier , genesisAccount . passphrase ) as any ; return { ... transaction , id : transaction . id . toString ( 'hex' ) , senderPublicKey : transaction . senderPublicKey . toString ( 'hex' ) , signatures : transaction . signatures . map ( ( s ) => s . toString ( 'hex' ) ) , asset : { ... transaction . asset , amount : transaction . asset . amount . toString ( ) , recipientAddress : transaction . asset . recipientAddress . toString ( 'hex' ) , } , nonce : transaction . nonce . toString ( ) , fee : transaction . fee . toString ( ) , } ; } ;