Update to go-cosmwasm 0.9.0-beta

This commit is contained in:
Ethan Frey 2020-06-26 11:54:09 +02:00
parent ac3babc8b0
commit 5fd8dc363c
7 changed files with 14 additions and 17 deletions

View File

@ -15,7 +15,7 @@ RUN go mod download
# TODO: how to use this instead of hardcoding GO_COSMWASM
RUN basename $(ls -d /go/pkg/mod/github.com/\!cosm\!wasm/go-cosmwasm@v*)
ENV GO_COSMWASM="v0.9.0-alpha3"
ENV GO_COSMWASM="v0.9.0-beta"
# build go-cosmwasm *.a and install it
WORKDIR /go/pkg/mod/github.com/\!cosm\!wasm/go-cosmwasm@${GO_COSMWASM}

2
go.mod
View File

@ -4,7 +4,7 @@ go 1.13
require (
// Note: update ENV GO_COSMWASM in Dockerfile when updating this
github.com/CosmWasm/go-cosmwasm v0.9.0-alpha3
github.com/CosmWasm/go-cosmwasm v0.9.0-beta
github.com/btcsuite/btcd v0.0.0-20190807005414-4063feeff79a // indirect
github.com/cosmos/cosmos-sdk v0.38.3
github.com/golang/mock v1.4.3 // indirect

4
go.sum
View File

@ -11,6 +11,10 @@ github.com/ChainSafe/go-schnorrkel v0.0.0-20200102211924-4bcbc698314f h1:4O1om+U
github.com/ChainSafe/go-schnorrkel v0.0.0-20200102211924-4bcbc698314f/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4=
github.com/CosmWasm/go-cosmwasm v0.9.0-alpha3 h1:CLa70UA9QGWye4GtIs7H/sRdKtneCAzWGVXzqUEkDeg=
github.com/CosmWasm/go-cosmwasm v0.9.0-alpha3/go.mod h1:gAFCwllx97ejI+m9SqJQrmd2SBW7HA0fOjvWWJjM2uc=
github.com/CosmWasm/go-cosmwasm v0.9.0-beta h1:yV8VRaD7K8bgBhtVeF4J8fIOLQ1sSGrFiDSIp/mVDQw=
github.com/CosmWasm/go-cosmwasm v0.9.0-beta/go.mod h1:gAFCwllx97ejI+m9SqJQrmd2SBW7HA0fOjvWWJjM2uc=
github.com/CosmWasm/go-cosmwasm v0.9.0 h1:756YkHBlv6+IuovwyFkc4dTXau3D5HNSQpSmGlz//7k=
github.com/CosmWasm/go-cosmwasm v0.9.0/go.mod h1:gAFCwllx97ejI+m9SqJQrmd2SBW7HA0fOjvWWJjM2uc=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=

View File

@ -47,7 +47,6 @@ var (
NewEnv = types.NewEnv
NewWasmCoins = types.NewWasmCoins
ParseEvents = types.ParseEvents
ResultFromData = types.ResultFromData
DefaultWasmConfig = types.DefaultWasmConfig
InitGenesis = keeper.InitGenesis
ExportGenesis = keeper.ExportGenesis

View File

@ -209,7 +209,9 @@ func (k Keeper) Execute(ctx sdk.Context, contractAddress sdk.AccAddress, caller
return nil, err
}
return types.ResultFromData(res.Data), nil
return &sdk.Result{
Data: res.Data,
}, nil
}
// Migrate allows to upgrade a contract to a new code with data migration.
@ -260,7 +262,9 @@ func (k Keeper) Migrate(ctx sdk.Context, contractAddress sdk.AccAddress, caller
return nil, sdkerrors.Wrap(err, "dispatch")
}
return types.ResultFromData(res.Data), nil
return &sdk.Result{
Data: res.Data,
}, nil
}
// UpdateContractAdmin sets the admin value on the ContractInfo. It must be a valid address (use ClearContractAdmin to remove it)

View File

@ -2,7 +2,6 @@ package keeper
import (
"bytes"
"encoding/base64"
"encoding/binary"
"encoding/json"
"io/ioutil"
@ -402,8 +401,7 @@ func TestExecuteWithCpuLoop(t *testing.T) {
_, err = keeper.Execute(ctx, addr, fred, []byte(`{"cpu_loop":{}}`), nil)
assert.Error(t, err)
// make sure gas ran out
// TODO: wasmer doesn't return gas used on error. we should consume it (for error on metering failure)
// require.Equal(t, gasLimit, ctx.GasMeter().GasConsumed())
require.Equal(t, gasLimit, ctx.GasMeter().GasConsumed())
}
func TestExecuteWithStorageLoop(t *testing.T) {
@ -629,9 +627,7 @@ func TestMigrateWithDispatchedMessage(t *testing.T) {
ctx = ctx.WithEventManager(sdk.NewEventManager()).WithBlockHeight(ctx.BlockHeight() + 1)
res, err := keeper.Migrate(ctx, contractAddr, fred, burnerContractID, migMsgBz)
require.NoError(t, err)
dataBz, err := base64.StdEncoding.DecodeString(string(res.Data))
require.NoError(t, err)
assert.Equal(t, "burnt 1 keys", string(dataBz))
assert.Equal(t, "burnt 1 keys", string(res.Data))
assert.Equal(t, "", res.Log)
type dict map[string]interface{}
expEvents := []dict{

View File

@ -161,12 +161,6 @@ func ParseEvents(logs []wasmTypes.LogAttribute, contractAddr sdk.AccAddress) sdk
return sdk.Events{sdk.NewEvent(CustomEventType, attrs...)}
}
func ResultFromData(data string) *sdk.Result {
return &sdk.Result{
Data: []byte(data),
}
}
// WasmConfig is the extra config required for wasm
type WasmConfig struct {
SmartQueryGasLimit uint64 `mapstructure:"query_gas_limit"`