Skip to content

Commit f1db38a

Browse files
authored
Merge pull request #6506 from filecoin-project/fix/ethcall-unmarshal
fix: EthCall UnmarshalJSON compatible Input field
2 parents 3c781e0 + dc96b00 commit f1db38a

File tree

2 files changed

+18
-5
lines changed
  • venus-devtool/state-type-gen
  • venus-shared/actors/types

2 files changed

+18
-5
lines changed

venus-devtool/state-type-gen/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,9 @@ var stateTypesOpt = option{
125125
// venus-shared/actors/types
126126
var sharedTypesOpt = option{
127127
skipStructs: map[string]struct{}{
128-
"ActorV5": {},
129-
"TempEthCall": {},
128+
"ActorV5": {},
129+
"EthCallDecode": {},
130+
"EthCallRaw": {},
130131
},
131132
skipAllVar: false,
132133
skipVars: []string{"Eip155ChainID"},

venus-shared/actors/types/eth.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,13 +308,25 @@ func (c *EthCall) ToFilecoinMessage() (*Message, error) {
308308
}
309309

310310
func (c *EthCall) UnmarshalJSON(b []byte) error {
311-
type TempEthCall EthCall
312-
var params TempEthCall
311+
type EthCallRaw EthCall // Avoid a recursive call.
312+
type EthCallDecode struct {
313+
// The field should be "input" by spec, but many clients use "data" so we support
314+
// both, but prefer "input".
315+
Input *EthBytes `json:"input"`
316+
EthCallRaw
317+
}
313318

319+
var params EthCallDecode
314320
if err := json.Unmarshal(b, &params); err != nil {
315321
return err
316322
}
317-
*c = EthCall(params)
323+
324+
// If input is specified, prefer it.
325+
if params.Input != nil {
326+
params.Data = *params.Input
327+
}
328+
329+
*c = EthCall(params.EthCallRaw)
318330
return nil
319331
}
320332

0 commit comments

Comments
 (0)