Closed
Description
System information
Geth version: geth version 1.9.25
, abigen version 1.9.25-stable
OS & Version: OSX
Commit hash : e7872729012a4871397307b12cc3f4772ffcbec6
Expected behaviour
After generating contract bindings using abigen version 1.9.25-stable
, I tried calling a view function getOrderRelevantStates
(see below)
// GetOrderRelevantStates is a free data retrieval call binding the contract method 0xe25cabf7.
//
// Solidity: function getOrderRelevantStates((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[] orders, bytes[] signatures) view returns((uint8,bytes32,uint256,bytes32,uint8,bytes32,uint256)[] ordersInfo, uint256[] fillableTakerAssetAmounts, bool[] isValidSignature)
func (f *FuturesCaller) GetOrderRelevantStates(opts *bind.CallOpts, orders []Order, signatures [][]byte) (struct {
OrdersInfo []DerivativeOrderInfo
FillableTakerAssetAmounts []*big.Int
IsValidSignature []bool
}, error) {
var out []interface{}
err := f.contract.Call(opts, &out, "getOrderRelevantStates", orders, signatures)
outstruct := new(struct {
OrdersInfo []DerivativeOrderInfo
FillableTakerAssetAmounts []*big.Int
IsValidSignature []bool
})
outstruct.OrdersInfo = out[0].([]DerivativeOrderInfo)
outstruct.FillableTakerAssetAmounts = out[1].([]*big.Int)
outstruct.IsValidSignature = out[2].([]bool)
return *outstruct, err
}
where the DerivativeOrderInfo
struct is defined as
// DerivativeOrderInfo is an auto generated low-level Go binding around an user-defined struct.
type DerivativeOrderInfo struct {
OrderStatus uint8
OrderHash [32]byte
OrderTakerAssetFilledAmount *big.Int
SubAccountID [32]byte
Direction uint8
MarketID [32]byte
EntryPrice *big.Int
}
It's expected this call should work successfully without any panics.
Actual behaviour
However, this results in the following panic
panic: interface conversion: interface {} is []struct { OrderStatus uint8 "json:\"orderStatus\""; OrderHash [32]uint8 "json:\"orderHash\""; OrderTakerAssetFilledAmount *big.Int "json:\"orderTakerAssetFilledAmount\""; SubAccountID [32]uint8 "json:\"subAccountID\""; Direction uint8 "json:\"direction\""; MarketID [32]uint8 "json:\"marketID\""; EntryPrice *big.Int "json:\"entryPrice\"" }, not []wrappers.DerivativeOrderInfo
The OrderHash
, SubAccountID
, and MarketID
fields are attempting to be converted as [32]uint8
instead of [32]byte
as expected.
We manually fixed this in our contract binding wrapper here but this should be fixed on the abigen level obviously.