keep-network / keep-common

Common libraries and tools used across Keep repositories
MIT License
5 stars 14 forks source link

Contract binding generator: Wrong handling of multiple return values #111

Open lukasz-zimnoch opened 1 year ago

lukasz-zimnoch commented 1 year ago

During the work on https://github.com/keep-network/keep-core/pull/3427, we noticed a problem with a generated contract binding that maps the WalletRegistry contract. That contract defines the following function:

function isDkgResultValid(DKG.Result calldata result) external view returns (bool, string memory)

which is covered by the WalletRegistry.go binding as:

func (wr *WalletRegistry) IsDkgResultValid(
    arg_result abi.EcdsaDkgResult,
) (isDkgResultValid, error) {
    ...
}

type isDkgResultValid struct {
    bool
    string
}

The isDkgResultValid is package-private and contains anonymous fields that can't be accessed outside. The only possible workaround is by using Go's reflection. This should be improved by making the returned values accessible.