Javascript SDK of WoopChain protocol
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sdk/packages/harmony-transaction/src/factory.ts

35 lines
926 B

import { getContractAddress } from '@harmony-js/crypto';
import { Messenger } from '@harmony-js/network';
import { Transaction } from './transaction';
import { TxParams, TxStatus } from './types';
class TransactionFactory {
static getContractAddress(tx: Transaction) {
const { from, nonce } = tx.txParams;
return getContractAddress(from, Number.parseInt(`${nonce}`, 10));
}
messenger: Messenger;
constructor(messenger: Messenger) {
this.messenger = messenger;
}
setMessenger(messenger: Messenger) {
this.messenger = messenger;
}
newTx(txParams?: TxParams | any): Transaction {
return new Transaction(txParams, this.messenger, TxStatus.INTIALIZED);
}
recover(txHash: string): Transaction {
const newTxn = new Transaction(
undefined,
this.messenger,
TxStatus.INTIALIZED,
);
newTxn.recover(txHash);
return newTxn;
}
}
export { TransactionFactory };