diff --git a/venus-devtool/state-type-gen/main.go b/venus-devtool/state-type-gen/main.go index e2444c5286..d1e208f264 100644 --- a/venus-devtool/state-type-gen/main.go +++ b/venus-devtool/state-type-gen/main.go @@ -125,8 +125,9 @@ var stateTypesOpt = option{ // venus-shared/actors/types var sharedTypesOpt = option{ skipStructs: map[string]struct{}{ - "ActorV5": {}, - "TempEthCall": {}, + "ActorV5": {}, + "EthCallDecode": {}, + "EthCallRaw": {}, }, skipAllVar: false, skipVars: []string{"Eip155ChainID"}, diff --git a/venus-shared/actors/types/eth.go b/venus-shared/actors/types/eth.go index c2d4c7f7d0..901be64d0d 100644 --- a/venus-shared/actors/types/eth.go +++ b/venus-shared/actors/types/eth.go @@ -308,13 +308,25 @@ func (c *EthCall) ToFilecoinMessage() (*Message, error) { } func (c *EthCall) UnmarshalJSON(b []byte) error { - type TempEthCall EthCall - var params TempEthCall + type EthCallRaw EthCall // Avoid a recursive call. + type EthCallDecode struct { + // The field should be "input" by spec, but many clients use "data" so we support + // both, but prefer "input". + Input *EthBytes `json:"input"` + EthCallRaw + } + var params EthCallDecode if err := json.Unmarshal(b, ¶ms); err != nil { return err } - *c = EthCall(params) + + // If input is specified, prefer it. + if params.Input != nil { + params.Data = *params.Input + } + + *c = EthCall(params.EthCallRaw) return nil }