Move assigning from address to the API level

This commit is contained in:
Maciej Witowski 2023-01-31 18:18:54 +01:00
parent 070aca2b65
commit 5f2ef98de6
2 changed files with 7 additions and 6 deletions

View File

@ -77,16 +77,10 @@ func EthTxFromSignedEthMessage(smsg *types.SignedMessage) (EthTx, error) {
return EthTx{}, xerrors.Errorf("failed to recover signature: %w", err)
}
fromAddr, err := EthAddressFromFilecoinAddress(smsg.Message.From)
if err != nil {
return EthTx{}, xerrors.Errorf("failed to get from: %w", err)
}
return EthTx{
Nonce: EthUint64(txArgs.Nonce),
ChainID: EthUint64(txArgs.ChainID),
To: txArgs.To,
From: fromAddr,
Value: EthBigInt(txArgs.Value),
Type: Eip1559TxType,
Gas: EthUint64(txArgs.GasLimit),

View File

@ -1571,6 +1571,13 @@ func newEthTxFromSignedMessage(ctx context.Context, smsg *types.SignedMessage, s
if err != nil {
return ethtypes.EthTx{}, err
}
fromAddr, err := lookupEthAddress(ctx, smsg.Message.From, sa)
if err != nil {
return ethtypes.EthTx{}, xerrors.Errorf("failed to resolve Ethereum address: %w", err)
}
tx.From = fromAddr
} else if smsg.Signature.Type == crypto.SigTypeSecp256k1 { // Secp Filecoin Message
tx = ethTxFromNativeMessage(ctx, smsg.VMMessage(), sa)
tx.Hash, err = ethtypes.EthHashFromCid(smsg.Cid())