Skip to content

Commit

Permalink
Eth JSON-RPC: from in eth_getTransactionByHash is not correctly popul…
Browse files Browse the repository at this point in the history
…ated #1614
  • Loading branch information
maciejwitowski committed Jan 31, 2023
1 parent dc5f865 commit d00665e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion api/api_full.go
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,7 @@ type EthTxReceipt struct {
TransactionIndex ethtypes.EthUint64 `json:"transactionIndex"`
BlockHash ethtypes.EthHash `json:"blockHash"`
BlockNumber ethtypes.EthUint64 `json:"blockNumber"`
From ethtypes.EthAddress `json:"from"`
From *ethtypes.EthAddress `json:"from"`
To *ethtypes.EthAddress `json:"to"`
StateRoot ethtypes.EthHash `json:"root"`
Status ethtypes.EthUint64 `json:"status"`
Expand Down
12 changes: 11 additions & 1 deletion chain/types/ethtypes/eth_transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type EthTx struct {
BlockHash *EthHash `json:"blockHash"`
BlockNumber *EthUint64 `json:"blockNumber"`
TransactionIndex *EthUint64 `json:"transactionIndex"`
From EthAddress `json:"from"`
From *EthAddress `json:"from"`
To *EthAddress `json:"to"`
Value EthBigInt `json:"value"`
Type EthUint64 `json:"type"`
Expand All @@ -46,6 +46,7 @@ type EthTxArgs struct {
ChainID int `json:"chainId"`
Nonce int `json:"nonce"`
To *EthAddress `json:"to"`
From *EthAddress `json:"from"`
Value big.Int `json:"value"`
MaxFeePerGas big.Int `json:"maxFeePerGas"`
MaxPriorityFeePerGas big.Int `json:"maxPriorityFeePerGas"`
Expand Down Expand Up @@ -81,6 +82,7 @@ func EthTxFromSignedEthMessage(smsg *types.SignedMessage) (EthTx, error) {
Nonce: EthUint64(txArgs.Nonce),
ChainID: EthUint64(txArgs.ChainID),
To: txArgs.To,
From: txArgs.From,
Value: EthBigInt(txArgs.Value),
Type: Eip1559TxType,
Gas: EthUint64(txArgs.GasLimit),
Expand All @@ -96,6 +98,7 @@ func EthTxFromSignedEthMessage(smsg *types.SignedMessage) (EthTx, error) {
func EthTxArgsFromUnsignedEthMessage(msg *types.Message) (EthTxArgs, error) {
var (
to *EthAddress
from *EthAddress
params []byte
paramsReader = bytes.NewReader(msg.Params)
err error
Expand All @@ -122,6 +125,12 @@ func EthTxArgsFromUnsignedEthMessage(msg *types.Message) (EthTxArgs, error) {
}
to = &addr

fromAddr, err := EthAddressFromFilecoinAddress(msg.From)
if err != nil {
return EthTxArgs{}, err
}
from = &fromAddr

if len(msg.Params) == 0 {
if msg.Method != builtintypes.MethodSend {
return EthTxArgs{}, xerrors.Errorf("cannot invoke method %d on non-EAM actor without params", msg.Method)
Expand Down Expand Up @@ -154,6 +163,7 @@ func EthTxArgsFromUnsignedEthMessage(msg *types.Message) (EthTxArgs, error) {
ChainID: build.Eip155ChainId,
Nonce: int(msg.Nonce),
To: to,
From: from,
Value: msg.Value,
Input: params,
MaxFeePerGas: msg.GasFeeCap,
Expand Down
2 changes: 1 addition & 1 deletion node/impl/full/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -1599,7 +1599,7 @@ func ethTxFromNativeMessage(ctx context.Context, msg *types.Message, sa StateAPI
to, _ := lookupEthAddress(ctx, msg.To, sa)
return ethtypes.EthTx{
To: &to,
From: from,
From: &from,
Nonce: ethtypes.EthUint64(msg.Nonce),
ChainID: ethtypes.EthUint64(build.Eip155ChainId),
Value: ethtypes.EthBigInt(msg.Value),
Expand Down

0 comments on commit d00665e

Please sign in to comment.