chore(transaction):add abstractTransaction

staking
neeboo 5 years ago
parent ced30c1f26
commit db5ed5ed84
  1. 27
      packages/harmony-transaction/src/abstractTransaction.ts
  2. 39
      packages/harmony-transaction/src/base.ts
  3. 1
      packages/harmony-transaction/src/index.ts
  4. 6
      packages/harmony-transaction/src/transaction.ts

@ -0,0 +1,27 @@
import { Messenger } from '@harmony-js/network';
import { TxStatus } from './types';
export abstract class AbstractTransaction {
abstract setMessenger(messenger: Messenger): void;
abstract setTxStatus(txStatus: TxStatus): void;
abstract getTxStatus(): TxStatus;
abstract isInitialized(): boolean;
abstract isSigned(): boolean;
abstract isPending(): boolean;
abstract isRejected(): boolean;
abstract isConfirmed(): boolean;
abstract async trackTx(txHash: string, shardID: number | string): Promise<boolean>;
abstract async txConfirm(
txHash: string,
maxAttempts: number | undefined,
interval: number | undefined,
shardID: string | number,
): Promise<any>;
abstract async socketConfirm(
txHash: string,
maxAttempts: number,
shardID: number | string,
): Promise<any>;
abstract async getBlockNumber(shardID: number | string): Promise<any>;
abstract async getBlockByNumber(blockNumber: string): Promise<any>;
}

@ -1,36 +1,11 @@
import {
BN,
encode,
arrayify,
hexlify,
stripZeros,
Signature,
splitSignature,
getAddress,
HarmonyAddress,
} from '@harmony-js/crypto';
import { add0xToString, numberToHex, ChainType, Unit, hexToNumber } from '@harmony-js/utils';
import {
Messenger,
RPCMethod,
Emitter,
HttpProvider,
// WSProvider,
// SubscribeReturns,
NewHeaders,
} from '@harmony-js/network';
import { TxParams, TxStatus, TransasctionReceipt } from './types';
import {
recover,
transactionFields,
sleep,
TransactionEvents,
defaultMessenger,
transactionFieldsETH,
recoverETH,
} from './utils';
import { BN, getAddress, HarmonyAddress } from '@harmony-js/crypto';
import { hexToNumber } from '@harmony-js/utils';
import { Messenger, RPCMethod, Emitter, HttpProvider, NewHeaders } from '@harmony-js/network';
import { TxStatus, TransasctionReceipt } from './types';
import { sleep, TransactionEvents } from './utils';
import { AbstractTransaction } from './abstractTransaction';
export class TransactionBase {
export class TransactionBase implements AbstractTransaction {
static normalizeAddress(address: string) {
if (address === '0x') {
return '0x';

@ -3,3 +3,4 @@ export * from './transaction';
export * from './shardingTransaction';
export * from './types';
export * from './utils';
export * from './base';

@ -6,10 +6,8 @@ import {
stripZeros,
Signature,
splitSignature,
getAddress,
HarmonyAddress,
} from '@harmony-js/crypto';
import { add0xToString, numberToHex, ChainType, Unit, hexToNumber } from '@harmony-js/utils';
import { add0xToString, numberToHex, ChainType, Unit } from '@harmony-js/utils';
import { Messenger, RPCMethod } from '@harmony-js/network';
import { TxParams, TxStatus } from './types';
import {
@ -26,7 +24,7 @@ class Transaction extends TransactionBase {
private from: string;
private nonce: number | string;
private to: string;
//private shardID: number | string;
// private shardID: number | string;
private toShardID: number | string;
private gasLimit: BN;
private gasPrice: BN;

Loading…
Cancel
Save