import * as StellarSdk from 'stellar-sdk' ; const typeTx = StellarSdk . xdr . EnvelopeType . envelopeTypeTx ( ) . toXDR ( ) ; function transactionHash ( tx , networkId ) { return StellarSdk . hash ( Buffer . concat ( [ networkId , typeTx , tx . tx . toXDR ( ) ] ) ) ; } export function sign ( tx , keypair , networkId ) { const hash = transactionHash ( tx , networkId ) ; const sig = keypair . signDecorated ( hash ) ; tx . signatures . push ( sig ) ; }