diff --git a/internal/hmyapi/types.go b/internal/hmyapi/types.go index d81b7034b..6b258998a 100644 --- a/internal/hmyapi/types.go +++ b/internal/hmyapi/types.go @@ -23,6 +23,7 @@ type RPCTransaction struct { BlockHash common.Hash `json:"blockHash"` BlockNumber *hexutil.Big `json:"blockNumber"` From string `json:"from"` + Timestamp hexutil.Uint64 `json:"timestamp"` Gas hexutil.Uint64 `json:"gas"` GasPrice *hexutil.Big `json:"gasPrice"` Hash common.Hash `json:"hash"` @@ -43,6 +44,7 @@ type RPCStakingTransaction struct { BlockHash common.Hash `json:"blockHash"` BlockNumber *hexutil.Big `json:"blockNumber"` From string `json:"from"` + Timestamp hexutil.Uint64 `json:"timestamp"` Gas hexutil.Uint64 `json:"gas"` GasPrice *hexutil.Big `json:"gasPrice"` Hash common.Hash `json:"hash"` @@ -192,7 +194,7 @@ func newRPCValidator(validator *types2.Validator) *RPCValidator { // newRPCTransaction returns a transaction that will serialize to the RPC // representation, with the given location metadata set (if available). -func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber uint64, index uint64) *RPCTransaction { +func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber uint64, timestamp uint64, uinindex uint64) *RPCTransaction { var signer types.Signer = types.FrontierSigner{} if tx.Protected() { signer = types.NewEIP155Signer(tx.ChainID()) @@ -208,6 +210,7 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber Value: (*hexutil.Big)(tx.Value()), ShardID: tx.ShardID(), ToShardID: tx.ToShardID(), + Timestamp: hexutil.Uint64(timestamp), V: (*hexutil.Big)(v), R: (*hexutil.Big)(r), S: (*hexutil.Big)(s), @@ -239,7 +242,7 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber // newRPCStakingTransaction returns a transaction that will serialize to the RPC // representation, with the given location metadata set (if available). -func newRPCStakingTransaction(tx *types2.StakingTransaction, blockHash common.Hash, blockNumber uint64, index uint64) *RPCStakingTransaction { +func newRPCStakingTransaction(tx *types2.StakingTransaction, blockHash common.Hash, blockNumber uint64, timestamp uint64, index uint64) *RPCStakingTransaction { from, _ := tx.SenderAddress() v, r, s := tx.RawSignatureValues() @@ -302,15 +305,16 @@ func newRPCStakingTransaction(tx *types2.StakingTransaction, blockHash common.Ha } result := &RPCStakingTransaction{ - Gas: hexutil.Uint64(tx.Gas()), - GasPrice: (*hexutil.Big)(tx.Price()), - Hash: tx.Hash(), - Nonce: hexutil.Uint64(tx.Nonce()), - V: (*hexutil.Big)(v), - R: (*hexutil.Big)(r), - S: (*hexutil.Big)(s), - Type: stakingTxType, - Msg: fields, + Gas: hexutil.Uint64(tx.Gas()), + GasPrice: (*hexutil.Big)(tx.Price()), + Hash: tx.Hash(), + Nonce: hexutil.Uint64(tx.Nonce()), + Timestamp: hexutil.Uint64(timestamp), + V: (*hexutil.Big)(v), + R: (*hexutil.Big)(r), + S: (*hexutil.Big)(s), + Type: stakingTxType, + Msg: fields, } if blockHash != (common.Hash{}) { result.BlockHash = blockHash @@ -448,7 +452,7 @@ func newRPCTransactionFromBlockIndex(b *types.Block, index uint64) *RPCTransacti if index >= uint64(len(txs)) { return nil } - return newRPCTransaction(txs[index], b.Hash(), b.NumberU64(), index) + return newRPCTransaction(txs[index], b.Hash(), b.NumberU64(), b.Time().Uint64(), index) } // newRPCStakingTransactionFromBlockHash returns a transaction that will serialize to the RPC representation. @@ -467,7 +471,7 @@ func newRPCStakingTransactionFromBlockIndex(b *types.Block, index uint64) *RPCSt if index >= uint64(len(txs)) { return nil } - return newRPCStakingTransaction(txs[index], b.Hash(), b.NumberU64(), index) + return newRPCStakingTransaction(txs[index], b.Hash(), b.NumberU64(), b.Time().Uint64(), index) } // CallArgs represents the arguments for a call.