Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions packages/harmony-staking/src/stakingTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { Messenger, RPCMethod } from '@harmony-js/network';
import { defaultMessenger, TransactionBase, TxStatus } from '@harmony-js/transaction';
import { numberToHex, Unit } from '@harmony-js/utils';
import { TextEncoder } from 'text-encoding';
import { StakingTxParams } from './types';

/** @hidden */
export class StakingSettings {
Expand Down Expand Up @@ -77,6 +78,30 @@ export class StakingTransaction extends TransactionBase {
this.from = '0x';
}

/**
* get staking transaction params
*
* @example
* ```
* const txParams = txn.txParams;
* console.log(txParams)
* ```
*/
get txParams(): StakingTxParams {
return {
directive: this.directive,
stakeMsg: this.stakeMsg,
nonce: this.nonce || 0,
gasPrice: this.gasPrice || new Unit(0).asWei().toWei(),
gasLimit: this.gasLimit || new Unit(0).asWei().toWei(),
chainId: this.chainId || 0,
rawTransaction: this.rawTransaction || '0x',
unsignedRawTransaction: this.unsignedRawTransaction || '0x',
signature: this.signature || '0x',
from: this.from || '',
};
}

encode(): [string, any[]] {
const raw: Array<string | Uint8Array | Array<string | Uint8Array>> = [];
// TODO: temporary hack for converting 0x00 to 0x
Expand Down
22 changes: 22 additions & 0 deletions packages/harmony-staking/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { BN, Signature } from '@harmony-js/crypto';
import {
Directive,
CreateValidator,
EditValidator,
Delegate,
Undelegate,
CollectRewards,
} from '@harmony-js/staking';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

within package you can refer locally. also will fix the build error.


export interface StakingTxParams {
directive: Directive;
stakeMsg: CreateValidator | EditValidator | Delegate | Undelegate | CollectRewards;
nonce: number | string;
gasLimit: number | string | BN;
gasPrice: number | string | BN;
chainId: number;
rawTransaction: string;
unsignedRawTransaction: string;
signature: Signature;
from: string;
}