Skip to content

Commit

Permalink
Bugfix: Support Address type in ABI encode
Browse files Browse the repository at this point in the history
  • Loading branch information
jdowning100 committed Feb 14, 2025
1 parent dc6df58 commit 6ec9744
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions quai/abi/pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ func packElement(t Type, reflectValue reflect.Value) ([]byte, error) {
if reflectValue.Kind() == reflect.Array {
reflectValue = mustArrayToByteSlice(reflectValue)
}
if reflectValue.Kind() == reflect.Struct {
// Convert the reflect.Value to an Address struct and call Bytes()
address, ok := reflectValue.Interface().(common.Address)
if !ok {
return []byte{}, errors.New("expected Address type but got something else")
}
return common.LeftPadBytes(address.Bytes(), 32), nil
}

return common.LeftPadBytes(reflectValue.Bytes(), 32), nil
case BoolTy:
Expand Down

0 comments on commit 6ec9744

Please sign in to comment.