fix: allow EthCall.From to be nil (#9556)
This commit is contained in:
parent
b3b9da5bbc
commit
49da019bd0
@ -159,7 +159,7 @@ func NewEthBlock() EthBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type EthCall struct {
|
type EthCall struct {
|
||||||
From EthAddress `json:"from"`
|
From *EthAddress `json:"from"`
|
||||||
To *EthAddress `json:"to"`
|
To *EthAddress `json:"to"`
|
||||||
Gas EthUint64 `json:"gas"`
|
Gas EthUint64 `json:"gas"`
|
||||||
GasPrice EthBigInt `json:"gasPrice"`
|
GasPrice EthBigInt `json:"gasPrice"`
|
||||||
|
@ -505,13 +505,23 @@ func (a *EthModule) EthSendRawTransaction(ctx context.Context, rawTx api.EthByte
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *EthModule) ethCallToFilecoinMessage(ctx context.Context, tx api.EthCall) (*types.Message, error) {
|
func (a *EthModule) ethCallToFilecoinMessage(ctx context.Context, tx api.EthCall) (*types.Message, error) {
|
||||||
// The from address must be translatable to an f4 address.
|
var err error
|
||||||
from, err := tx.From.ToFilecoinAddress()
|
var from address.Address
|
||||||
if err != nil {
|
if tx.From == nil {
|
||||||
return nil, fmt.Errorf("failed to translate sender address (%s): %w", tx.From.String(), err)
|
// Send from the filecoin "system" address.
|
||||||
}
|
from, err = (api.EthAddress{}).ToFilecoinAddress()
|
||||||
if p := from.Protocol(); p != address.Delegated {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("expected a class 4 address, got: %d: %w", p, err)
|
return nil, fmt.Errorf("failed to construct the ethereum system address: %w", err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// The from address must be translatable to an f4 address.
|
||||||
|
from, err = tx.From.ToFilecoinAddress()
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to translate sender address (%s): %w", tx.From.String(), err)
|
||||||
|
}
|
||||||
|
if p := from.Protocol(); p != address.Delegated {
|
||||||
|
return nil, fmt.Errorf("expected a class 4 address, got: %d: %w", p, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var params []byte
|
var params []byte
|
||||||
|
Loading…
Reference in New Issue
Block a user