add support for f4 addresses in the Eth JSON-RPC and signature.
This commit is contained in:
@@ -109,6 +109,9 @@ func (tx *EthTxArgs) ToSignedMessage() (*types.SignedMessage, error) {
|
||||
}
|
||||
|
||||
if tx.To == nil {
|
||||
// TODO https://github.com/filecoin-project/ref-fvm/issues/992
|
||||
// TODO unify with applyEvmMsg
|
||||
|
||||
// this is a contract creation
|
||||
to = builtintypes.InitActorAddr
|
||||
|
||||
@@ -263,7 +266,12 @@ func (tx *EthTxArgs) Sender() (address.Address, error) {
|
||||
return address.Undef, err
|
||||
}
|
||||
|
||||
return address.NewSecp256k1Address(pubk)
|
||||
// Calculate the f4 address based on the keccak hash of the pubkey.
|
||||
hasher.Reset()
|
||||
hasher.Write(pubk)
|
||||
addrHash := hasher.Sum(nil)
|
||||
|
||||
return address.NewDelegatedAddress(builtintypes.EthereumAddressManagerActorID, addrHash[len(addrHash)-20:])
|
||||
}
|
||||
|
||||
func parseEip1559Tx(data []byte) (*EthTxArgs, error) {
|
||||
|
||||
+2
-4
@@ -10,6 +10,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/builtin"
|
||||
"github.com/ipfs/go-cid"
|
||||
"github.com/multiformats/go-multihash"
|
||||
"golang.org/x/xerrors"
|
||||
@@ -23,9 +24,6 @@ import (
|
||||
|
||||
type EthUint64 uint64
|
||||
|
||||
// EthAddressManagerActorID is the actor ID of the Ethereum Address Manager singleton.
|
||||
const EthAddressManagerActorID = 10
|
||||
|
||||
func (e EthUint64) MarshalJSON() ([]byte, error) {
|
||||
if e == 0 {
|
||||
return json.Marshal("0x0")
|
||||
@@ -294,7 +292,7 @@ func (ea EthAddress) ToFilecoinAddress() (address.Address, error) {
|
||||
|
||||
// Otherwise, translate the address into an address controlled by the
|
||||
// Ethereum Address Manager.
|
||||
addr, err := address.NewDelegatedAddress(EthAddressManagerActorID, ea[:])
|
||||
addr, err := address.NewDelegatedAddress(builtin.EthereumAddressManagerActorID, ea[:])
|
||||
if err != nil {
|
||||
return address.Undef, fmt.Errorf("failed to translate supplied address (%s) into a "+
|
||||
"Filecoin f4 address: %w", hex.EncodeToString(ea[:]), err)
|
||||
|
||||
Reference in New Issue
Block a user