There are quite a few functions in our Solidity contracts that accept bytes20 or bytes32 as a parameter. One of many examples are requestHeartbeat(bytes20 walletPubKeyHash, bytes calldata message) from the WalletCoordinator contract and getWallet(bytes32 walletID) from the WalletRegistry contract. Given there was no parsing function defined in our Ethereum contract parsing logic, all functions accepting bytes32 and bytes20 were skipped during the code generation:
WARNING: Unsupported param type for method getWallet:
ABI Type: bytes32
Go Type: [32]byte
the method won't be callable with 'ethereum' command
This changeset adds two parsing functions: one for bytes20 and another for bytes32 Solidity type. In theory, we could have other variations of bytesN but this is not the case for our codebase, and defining a generic function is more complicated given we do not deal with slices but fixed-size arrays. Even though the proposed solution does not work for all bytesN types, it is enough for now.
Testing
Testing this change is easy.
First, see how it works without this change. Go to your keep-network/keep-core repository copy and execute make all. You will see a bunch of warnings like this:
WARNING: Unsupported param type for method getWallet:
ABI Type: bytes32
Go Type: [32]byte
the method won't be callable with 'ethereum' command
WARNING: Unsupported param type for method isWalletRegistered:
ABI Type: bytes32
Go Type: [32]byte
the method won't be callable with 'ethereum' command
WARNING: Unsupported param type for method isWalletMember:
ABI Type: bytes32
Go Type: [32]byte
the method won't be callable with 'ethereum' command
Check out this branch locally, go to keep-network/keep-core repository, and add replace directive in go.mod to point to the checked-out code. In my case, it is github.com/keep-network/keep-common => /Users/piotr/git/keep-network/keep-common. Then run make all again.
All warnings should be gone and you should see the code generated for the previously skipped functions.
I did this testing locally and I was able to call some functions with the generated code. Example:
There are quite a few functions in our Solidity contracts that accept
bytes20
orbytes32
as a parameter. One of many examples arerequestHeartbeat(bytes20 walletPubKeyHash, bytes calldata message)
from theWalletCoordinator
contract andgetWallet(bytes32 walletID)
from theWalletRegistry
contract. Given there was no parsing function defined in our Ethereum contract parsing logic, all functions acceptingbytes32
andbytes20
were skipped during the code generation:This changeset adds two parsing functions: one for
bytes20
and another forbytes32
Solidity type. In theory, we could have other variations ofbytesN
but this is not the case for our codebase, and defining a generic function is more complicated given we do not deal with slices but fixed-size arrays. Even though the proposed solution does not work for allbytesN
types, it is enough for now.Testing
Testing this change is easy.
First, see how it works without this change. Go to your
keep-network/keep-core
repository copy and executemake all
. You will see a bunch of warnings like this:Check out this branch locally, go to
keep-network/keep-core
repository, and add replace directive ingo.mod
to point to the checked-out code. In my case, it isgithub.com/keep-network/keep-common => /Users/piotr/git/keep-network/keep-common
. Then runmake all
again.All warnings should be gone and you should see the code generated for the previously skipped functions.
I did this testing locally and I was able to call some functions with the generated code. Example: