Skip to content

Commit

Permalink
Update to go-cosmwasm 0.9.0-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanfrey committed Jun 26, 2020
1 parent ac3babc commit 5fd8dc3
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
1 change: 0 additions & 1 deletion x/wasm/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions x/wasm/internal/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 2 additions & 6 deletions x/wasm/internal/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package keeper

import (
"bytes"
"encoding/base64"
"encoding/binary"
"encoding/json"
"io/ioutil"
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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{
Expand Down
6 changes: 0 additions & 6 deletions x/wasm/internal/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit 5fd8dc3

Please sign in to comment.