packageDocumentation module import { getContractAddress , getAddress } from '@harmony-js/crypto' ; import { Messenger } from '@harmony-js/network' ; import { Transaction } from './transaction' ; import { ShardingTransaction } from './shardingTransaction' ; import { TxParams , TxStatus } from './types' ; export class TransactionFactory { static getContractAddress ( tx ) { const { from , nonce } = tx . txParams ; return getAddress ( getContractAddress ( getAddress ( from ) . checksum , Number . parseInt ( `${ nonce }` , 10 ) ) ) . checksum ; } messenger : Messenger ; constructor ( messenger ) { this . messenger = messenger ; } setMessenger ( messenger ) { this . messenger = messenger ; } params example newTx ( txParams ? , sharding = false ) { if ( ! sharding ) { return new Transaction ( txParams , this . messenger , TxStatus . INTIALIZED ) ; } return new ShardingTransaction ( txParams , this . messenger , TxStatus . INTIALIZED ) ; } param transaction example clone ( transaction ) { return new Transaction ( transaction . txParams , this . messenger , TxStatus . INTIALIZED ) ; } example recover ( txHash ) { const newTxn = new Transaction ( { } , this . messenger , TxStatus . INTIALIZED ) ; newTxn . recover ( txHash ) ; return newTxn ; } }