CosmWasm / wasmvm

Go bindings to the running cosmwasm contracts with wasmer
Apache License 2.0
173 stars 99 forks source link

Decouple cgo dependencies #373

Closed alpe closed 1 year ago

alpe commented 1 year ago

When wasmd is used as a library, the project won't compile without cgo enabled:

../../../go/pkg/mod/github.com/!cosm!wasm/wasmvm@v1.1.1/internal/api/mocks.go:195:2: undefined: GasMeter
../../../go/pkg/mod/github.com/!cosm!wasm/wasmvm@v1.1.1/internal/api/mocks.go:196:20: undefined: Gas
../../../go/pkg/mod/github.com/!cosm!wasm/wasmvm@v1.1.1/internal/api/mocks.go:200:11: undefined: Gas
../../../go/pkg/mod/github.com/!cosm!wasm/wasmvm@v1.1.1/internal/api/mocks.go:201:11: undefined: Gas
../../../go/pkg/mod/github.com/!cosm!wasm/wasmvm@v1.1.1/internal/api/mocks.go:205:28: undefined: Gas
../../../go/pkg/mod/github.com/!cosm!wasm/wasmvm@v1.1.1/internal/api/mocks.go:212:38: undefined: Gas
../../../go/pkg/mod/github.com/!cosm!wasm/wasmvm@v1.1.1/internal/api/mocks.go:216:32: undefined: Gas
../../../go/pkg/mod/github.com/!cosm!wasm/wasmvm@v1.1.1/internal/api/mocks.go:230:42: undefined: Gas
../../../go/pkg/mod/github.com/!cosm!wasm/wasmvm@v1.1.1/internal/api/mocks.go:329:7: undefined: KVStore
../../../go/pkg/mod/github.com/!cosm!wasm/wasmvm@v1.1.1/internal/api/mock_failure.go:15:27: undefined: GoAPI
../../../go/pkg/mod/github.com/!cosm!wasm/wasmvm@v1.1.1/internal/api/mocks.go:329:7: too many errors

With this PR, I added build flags and decoupled the types to make the compiler happy.

webmaster128 commented 1 year ago

Implemented as part of #377. Thanks for bringing this up.