Skip to content

Commit

Permalink
Merge branch 'main' into fix/cli_warning
Browse files Browse the repository at this point in the history
  • Loading branch information
zemyblue authored Mar 28, 2023
2 parents 4d86ed3 + 962f37d commit 7cab94a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* [\#10](https://github.com/line/wasmd/pull/10) update wasmvm version

### Bug Fixes
* [\#12](https://github.com/line/wasmd/pull/12) fix not to register wrong codec in `x/wasmplus`
* [\#14](https://github.com/line/wasmd/pull/14) fix the cmd error that does not recognize wasmvm library version

### Breaking Changes
Expand Down
2 changes: 1 addition & 1 deletion x/wasmplus/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

// RegisterLegacyAminoCodec registers the account types and interface
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { //nolint:staticcheck
legacy.RegisterAminoMsg(cdc, &MsgStoreCodeAndInstantiateContract{}, "wasm/StoreCodeAndInstantiateContract")
legacy.RegisterAminoMsg(cdc, &MsgStoreCodeAndInstantiateContract{}, "wasm/MsgStoreCodeAndInstantiateContract")

cdc.RegisterConcrete(&DeactivateContractProposal{}, "wasm/DeactivateContractProposal", nil)
cdc.RegisterConcrete(&ActivateContractProposal{}, "wasm/ActivateContractProposal", nil)
Expand Down
6 changes: 2 additions & 4 deletions x/wasmplus/types/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ package types
import (
sdk "github.com/line/lbm-sdk/types"
sdkerrors "github.com/line/lbm-sdk/types/errors"

wasmtypes "github.com/line/wasmd/x/wasm/types"
)

func (msg MsgStoreCodeAndInstantiateContract) Route() string {
return wasmtypes.RouterKey
return RouterKey
}

func (msg MsgStoreCodeAndInstantiateContract) Type() string {
Expand Down Expand Up @@ -51,7 +49,7 @@ func (msg MsgStoreCodeAndInstantiateContract) ValidateBasic() error {
}

func (msg MsgStoreCodeAndInstantiateContract) GetSignBytes() []byte {
return sdk.MustSortJSON(wasmtypes.ModuleCdc.MustMarshalJSON(&msg))
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
}

func (msg MsgStoreCodeAndInstantiateContract) GetSigners() []sdk.AccAddress {
Expand Down
35 changes: 35 additions & 0 deletions x/wasmplus/types/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/stretchr/testify/require"

sdk "github.com/line/lbm-sdk/types"
"github.com/line/lbm-sdk/x/auth/legacy/legacytx"

wasmTypes "github.com/line/wasmd/x/wasm/types"
)
Expand Down Expand Up @@ -135,3 +136,37 @@ func TestNewMsgStoreCodeAndInstantiateContractGetSigners(t *testing.T) {
bytes := sdk.MustAccAddressFromBech32(res[0].String())
require.Equal(t, "696e707574313131313131313131313131313131", fmt.Sprintf("%v", hex.EncodeToString(bytes)))
}

func TestMsgJsonSignBytes(t *testing.T) {
const myInnerMsg = `{"foo":"bar"}`
specs := map[string]struct {
src legacytx.LegacyMsg
exp string
}{
"MsgInstantiateContract with every field": {
src: &MsgStoreCodeAndInstantiateContract{Sender: "sender1", WASMByteCode: []byte{89, 69, 76, 76, 79, 87, 32, 83, 85, 66, 77, 65, 82, 73, 78, 69},
InstantiatePermission: &wasmTypes.AccessConfig{Permission: wasmTypes.AccessTypeAnyOfAddresses, Addresses: []string{"address1", "address2"}},
Admin: "admin1", Label: "My", Msg: wasmTypes.RawContractMessage(myInnerMsg), Funds: sdk.Coins{{Denom: "denom1", Amount: sdk.NewInt(1)}}},
exp: `
{
"type":"wasm/MsgStoreCodeAndInstantiateContract",
"value": {"admin":"admin1","funds":[{"amount":"1","denom":"denom1"}],"instantiate_permission":{"addresses":["address1","address2"],
"permission":"AnyOfAddresses"},"label":"My","msg":{"foo":"bar"},"sender":"sender1","wasm_byte_code":"WUVMTE9XIFNVQk1BUklORQ=="}
}`,
},
"MsgInstantiateContract with minimum field": {
src: &MsgStoreCodeAndInstantiateContract{},
exp: `
{
"type":"wasm/MsgStoreCodeAndInstantiateContract",
"value": {"funds":[]}
}`,
},
}
for name, spec := range specs {
t.Run(name, func(t *testing.T) {
bz := spec.src.GetSignBytes()
assert.JSONEq(t, spec.exp, string(bz), "raw: %s", string(bz))
})
}
}

0 comments on commit 7cab94a

Please sign in to comment.