You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider making the 08-wasm contract API types exported/public.
Problem Definition
The 08-wasm module defines a number of structs used for encoding the contract payloads to JSON.
It is not necessarily the types themselves but the serialized JSON bytes of these types which define the API, as contracts are not written natively in Go and rather in Rust. Contracts written in Rust will likely define their own types to which they unmarshal to or consume some common library.
We currently need to export these types in export_test.go in order to expose them for testing. Note, that this is the reason the mock wasm engine implementation lives still within the types package. When implementing some test cases I stumbled upon this and would have expected for the mock wasm engine to live within the 08-wasm/testing package.
At the moment I am struggling to see the value in keeping these types unexported / private. If anyone can highlight some good points or concerns about making them exported we should discuss them here. I believe it was also pointed out that this API is final and can only be extended in future, which suggests further than there is little value in maintaining them as private structs.
Proposal
Make the types defined in contract_api.go public / exported symbols. With this we can then move the mock wasm engine implementation to the testing package and remove export_test.go and the overhead associated with this for testing.
For Admin Use
Not duplicate issue
Appropriate labels applied
Appropriate contributors tagged/assigned
The text was updated successfully, but these errors were encountered:
I'd say the main reason I see is not requiring a major/minor bump any time we might make changes to the Go types. We might make some changes to go structs that don't affect contract API but do change 08-wasm's public API if that is exposed (i.e #4909).
I'd be more favorable if we make all their fields private, if possible (and definitely release 08-wasm with a < 1.0.0 version)
Yea, that seems to be the case. It seems you can create a dummy private struct that holds the exported fields and embed that into the struct you want to marshal/unmarshal but that seems like an equally annoying workaround.
Summary
Consider making the
08-wasm
contract API types exported/public.Problem Definition
The
08-wasm
module defines a number of structs used for encoding the contract payloads to JSON.It is not necessarily the types themselves but the serialized JSON bytes of these types which define the API, as contracts are not written natively in Go and rather in Rust. Contracts written in Rust will likely define their own types to which they unmarshal to or consume some common library.
We currently need to export these types in
export_test.go
in order to expose them for testing. Note, that this is the reason the mock wasm engine implementation lives still within thetypes
package. When implementing some test cases I stumbled upon this and would have expected for the mock wasm engine to live within the08-wasm/testing
package.At the moment I am struggling to see the value in keeping these types unexported / private. If anyone can highlight some good points or concerns about making them exported we should discuss them here. I believe it was also pointed out that this API is final and can only be extended in future, which suggests further than there is little value in maintaining them as private structs.
Proposal
Make the types defined in
contract_api.go
public / exported symbols. With this we can then move the mock wasm engine implementation to thetesting
package and removeexport_test.go
and the overhead associated with this for testing.For Admin Use
The text was updated successfully, but these errors were encountered: