feat: Port x/wasm module #92
@ -16,7 +16,7 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/version"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/client/cli"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
flag "github.com/spf13/pflag"
|
||||
@ -68,7 +68,7 @@ func ProposalStoreCodeCmd() *cobra.Command {
|
||||
CodeHash: codeHash,
|
||||
}
|
||||
|
||||
msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress())
|
||||
msg, err := govv1beta1.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -172,7 +172,7 @@ func ProposalInstantiateContractCmd() *cobra.Command {
|
||||
Funds: src.Funds,
|
||||
}
|
||||
|
||||
msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress())
|
||||
msg, err := govv1beta1.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -234,7 +234,7 @@ func ProposalInstantiateContract2Cmd() *cobra.Command {
|
||||
|
||||
content := types.NewInstantiateContract2Proposal(proposalTitle, proposalDescr, runAs, src.Admin, src.CodeID, src.Label, src.Msg, src.Funds, salt, fixMsg)
|
||||
|
||||
msg, err := govtypes.NewMsgSubmitProposal(content, deposit, clientCtx.GetFromAddress())
|
||||
msg, err := govv1beta1.NewMsgSubmitProposal(content, deposit, clientCtx.GetFromAddress())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -357,7 +357,7 @@ func ProposalStoreAndInstantiateContractCmd() *cobra.Command {
|
||||
Funds: amount,
|
||||
}
|
||||
|
||||
msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress())
|
||||
msg, err := govv1beta1.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -411,7 +411,7 @@ func ProposalMigrateContractCmd() *cobra.Command {
|
||||
Msg: src.Msg,
|
||||
}
|
||||
|
||||
msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress())
|
||||
msg, err := govv1beta1.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -470,7 +470,7 @@ func ProposalExecuteContractCmd() *cobra.Command {
|
||||
Funds: funds,
|
||||
}
|
||||
|
||||
msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress())
|
||||
msg, err := govv1beta1.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -513,7 +513,7 @@ func ProposalSudoContractCmd() *cobra.Command {
|
||||
Msg: sudoMsg,
|
||||
}
|
||||
|
||||
msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress())
|
||||
msg, err := govv1beta1.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -556,7 +556,7 @@ func ProposalUpdateContractAdminCmd() *cobra.Command {
|
||||
NewAdmin: src.NewAdmin,
|
||||
}
|
||||
|
||||
msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress())
|
||||
msg, err := govv1beta1.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -592,7 +592,7 @@ func ProposalClearContractAdminCmd() *cobra.Command {
|
||||
Contract: args[0],
|
||||
}
|
||||
|
||||
msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress())
|
||||
msg, err := govv1beta1.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -633,7 +633,7 @@ func ProposalPinCodesCmd() *cobra.Command {
|
||||
CodeIDs: codeIds,
|
||||
}
|
||||
|
||||
msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress())
|
||||
msg, err := govv1beta1.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -686,7 +686,7 @@ func ProposalUnpinCodesCmd() *cobra.Command {
|
||||
CodeIDs: codeIds,
|
||||
}
|
||||
|
||||
msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress())
|
||||
msg, err := govv1beta1.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -785,7 +785,7 @@ $ %s tx gov submit-proposal update-instantiate-config 1:nobody 2:everybody 3:%s1
|
||||
Description: proposalDescr,
|
||||
AccessConfigUpdates: updates,
|
||||
}
|
||||
msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress())
|
||||
msg, err := govv1beta1.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/msgservice"
|
||||
"github.com/cosmos/cosmos-sdk/x/authz"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
|
||||
)
|
||||
|
||||
// RegisterLegacyAminoCodec registers the account types and interface
|
||||
@ -65,7 +65,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
|
||||
&MsgUpdateInstantiateConfig{},
|
||||
)
|
||||
registry.RegisterImplementations(
|
||||
(*govtypes.Content)(nil),
|
||||
(*govv1beta1.Content)(nil),
|
||||
&StoreCodeProposal{},
|
||||
&InstantiateContractProposal{},
|
||||
&InstantiateContract2Proposal{},
|
||||
|
@ -8,9 +8,9 @@ import (
|
||||
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
connectiontypes "github.com/cosmos/ibc-go/v4/modules/core/03-connection/types"
|
||||
channeltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
|
||||
ibcexported "github.com/cosmos/ibc-go/v4/modules/core/exported"
|
||||
connectiontypes "github.com/cosmos/ibc-go/v5/modules/core/03-connection/types"
|
||||
channeltypes "github.com/cosmos/ibc-go/v5/modules/core/04-channel/types"
|
||||
ibcexported "github.com/cosmos/ibc-go/v5/modules/core/exported"
|
||||
)
|
||||
|
||||
// BankViewKeeper defines a subset of methods implemented by the cosmos-sdk bank keeper
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/tendermint/tendermint/libs/rand"
|
||||
|
||||
@ -168,7 +168,7 @@ func TestGenesisContractInfoMarshalUnmarshal(t *testing.T) {
|
||||
|
||||
anyTime := time.Now().UTC()
|
||||
// using gov proposal here as a random protobuf types as it contains an Any type inside for nested unpacking
|
||||
myExtension, err := govtypes.NewProposal(&govtypes.TextProposal{Title: "bar"}, 1, anyTime, anyTime)
|
||||
myExtension, err := govv1beta1.NewProposal(&govv1beta1.TextProposal{Title: "bar"}, 1, anyTime, anyTime)
|
||||
require.NoError(t, err)
|
||||
myExtension.TotalDeposit = nil
|
||||
|
||||
@ -182,10 +182,10 @@ func TestGenesisContractInfoMarshalUnmarshal(t *testing.T) {
|
||||
// register proposal as extension type
|
||||
interfaceRegistry.RegisterImplementations(
|
||||
(*ContractInfoExtension)(nil),
|
||||
&govtypes.Proposal{},
|
||||
&govv1beta1.Proposal{},
|
||||
)
|
||||
// register gov types for nested Anys
|
||||
govtypes.RegisterInterfaces(interfaceRegistry)
|
||||
govv1beta1.RegisterInterfaces(interfaceRegistry)
|
||||
|
||||
// when encode
|
||||
gs := GenesisState{
|
||||
@ -205,7 +205,7 @@ func TestGenesisContractInfoMarshalUnmarshal(t *testing.T) {
|
||||
dest := destGs.Contracts[0].ContractInfo
|
||||
assert.Equal(t, src, dest)
|
||||
// and sanity check nested any
|
||||
var destExt govtypes.Proposal
|
||||
var destExt govv1beta1.Proposal
|
||||
require.NoError(t, dest.ReadExtension(&destExt))
|
||||
assert.Equal(t, destExt.GetTitle(), "bar")
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
|
||||
)
|
||||
|
||||
type ProposalType string
|
||||
@ -66,30 +67,18 @@ func ConvertToProposals(keys []string) ([]ProposalType, error) {
|
||||
}
|
||||
|
||||
func init() { // register new content types with the sdk
|
||||
govtypes.RegisterProposalType(string(ProposalTypeStoreCode))
|
||||
govtypes.RegisterProposalType(string(ProposalTypeInstantiateContract))
|
||||
govtypes.RegisterProposalType(string(ProposalTypeInstantiateContract2))
|
||||
govtypes.RegisterProposalType(string(ProposalTypeMigrateContract))
|
||||
govtypes.RegisterProposalType(string(ProposalTypeSudoContract))
|
||||
govtypes.RegisterProposalType(string(ProposalTypeExecuteContract))
|
||||
govtypes.RegisterProposalType(string(ProposalTypeUpdateAdmin))
|
||||
govtypes.RegisterProposalType(string(ProposalTypeClearAdmin))
|
||||
govtypes.RegisterProposalType(string(ProposalTypePinCodes))
|
||||
govtypes.RegisterProposalType(string(ProposalTypeUnpinCodes))
|
||||
govtypes.RegisterProposalType(string(ProposalTypeUpdateInstantiateConfig))
|
||||
govtypes.RegisterProposalType(string(ProposalTypeStoreAndInstantiateContractProposal))
|
||||
govtypes.RegisterProposalTypeCodec(&StoreCodeProposal{}, "wasm/StoreCodeProposal")
|
||||
govtypes.RegisterProposalTypeCodec(&InstantiateContractProposal{}, "wasm/InstantiateContractProposal")
|
||||
govtypes.RegisterProposalTypeCodec(&InstantiateContract2Proposal{}, "wasm/InstantiateContract2Proposal")
|
||||
govtypes.RegisterProposalTypeCodec(&MigrateContractProposal{}, "wasm/MigrateContractProposal")
|
||||
govtypes.RegisterProposalTypeCodec(&SudoContractProposal{}, "wasm/SudoContractProposal")
|
||||
govtypes.RegisterProposalTypeCodec(&ExecuteContractProposal{}, "wasm/ExecuteContractProposal")
|
||||
govtypes.RegisterProposalTypeCodec(&UpdateAdminProposal{}, "wasm/UpdateAdminProposal")
|
||||
govtypes.RegisterProposalTypeCodec(&ClearAdminProposal{}, "wasm/ClearAdminProposal")
|
||||
govtypes.RegisterProposalTypeCodec(&PinCodesProposal{}, "wasm/PinCodesProposal")
|
||||
govtypes.RegisterProposalTypeCodec(&UnpinCodesProposal{}, "wasm/UnpinCodesProposal")
|
||||
govtypes.RegisterProposalTypeCodec(&UpdateInstantiateConfigProposal{}, "wasm/UpdateInstantiateConfigProposal")
|
||||
govtypes.RegisterProposalTypeCodec(&StoreAndInstantiateContractProposal{}, "wasm/StoreAndInstantiateContractProposal")
|
||||
govv1beta1.RegisterProposalType(string(ProposalTypeStoreCode))
|
||||
govv1beta1.RegisterProposalType(string(ProposalTypeInstantiateContract))
|
||||
govv1beta1.RegisterProposalType(string(ProposalTypeInstantiateContract2))
|
||||
govv1beta1.RegisterProposalType(string(ProposalTypeMigrateContract))
|
||||
govv1beta1.RegisterProposalType(string(ProposalTypeSudoContract))
|
||||
govv1beta1.RegisterProposalType(string(ProposalTypeExecuteContract))
|
||||
govv1beta1.RegisterProposalType(string(ProposalTypeUpdateAdmin))
|
||||
govv1beta1.RegisterProposalType(string(ProposalTypeClearAdmin))
|
||||
govv1beta1.RegisterProposalType(string(ProposalTypePinCodes))
|
||||
govv1beta1.RegisterProposalType(string(ProposalTypeUnpinCodes))
|
||||
govv1beta1.RegisterProposalType(string(ProposalTypeUpdateInstantiateConfig))
|
||||
govv1beta1.RegisterProposalType(string(ProposalTypeStoreAndInstantiateContractProposal))
|
||||
}
|
||||
|
||||
func NewStoreCodeProposal(
|
||||
@ -915,8 +904,8 @@ func validateProposalCommons(title, description string) error {
|
||||
if len(title) == 0 {
|
||||
return sdkerrors.Wrap(govtypes.ErrInvalidProposalContent, "proposal title cannot be blank")
|
||||
}
|
||||
if len(title) > govtypes.MaxTitleLength {
|
||||
return sdkerrors.Wrapf(govtypes.ErrInvalidProposalContent, "proposal title is longer than max length of %d", govtypes.MaxTitleLength)
|
||||
if len(title) > govv1beta1.MaxTitleLength {
|
||||
return sdkerrors.Wrapf(govtypes.ErrInvalidProposalContent, "proposal title is longer than max length of %d", govv1beta1.MaxTitleLength)
|
||||
}
|
||||
if strings.TrimSpace(description) != description {
|
||||
return sdkerrors.Wrap(govtypes.ErrInvalidProposalContent, "proposal description must not start/end with white spaces")
|
||||
@ -924,8 +913,8 @@ func validateProposalCommons(title, description string) error {
|
||||
if len(description) == 0 {
|
||||
return sdkerrors.Wrap(govtypes.ErrInvalidProposalContent, "proposal description cannot be blank")
|
||||
}
|
||||
if len(description) > govtypes.MaxDescriptionLength {
|
||||
return sdkerrors.Wrapf(govtypes.ErrInvalidProposalContent, "proposal description is longer than max length of %d", govtypes.MaxDescriptionLength)
|
||||
if len(description) > govv1beta1.MaxDescriptionLength {
|
||||
return sdkerrors.Wrapf(govtypes.ErrInvalidProposalContent, "proposal description is longer than max length of %d", govv1beta1.MaxDescriptionLength)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"testing"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"gopkg.in/yaml.v2"
|
||||
@ -48,7 +48,7 @@ func TestValidateProposalCommons(t *testing.T) {
|
||||
},
|
||||
"prevent title exceeds max length ": {
|
||||
src: commonProposal{
|
||||
Title: strings.Repeat("a", govtypes.MaxTitleLength+1),
|
||||
Title: strings.Repeat("a", govv1beta1.MaxTitleLength+1),
|
||||
Description: "Bar",
|
||||
},
|
||||
expErr: true,
|
||||
@ -76,7 +76,7 @@ func TestValidateProposalCommons(t *testing.T) {
|
||||
"prevent descr exceeds max length ": {
|
||||
src: commonProposal{
|
||||
Title: "Foo",
|
||||
Description: strings.Repeat("a", govtypes.MaxDescriptionLength+1),
|
||||
Description: strings.Repeat("a", govv1beta1.MaxDescriptionLength+1),
|
||||
},
|
||||
expErr: true,
|
||||
},
|
||||
@ -784,7 +784,7 @@ func TestValidateClearAdminProposal(t *testing.T) {
|
||||
|
||||
func TestProposalStrings(t *testing.T) {
|
||||
specs := map[string]struct {
|
||||
src govtypes.Content
|
||||
src govv1beta1.Content
|
||||
exp string
|
||||
}{
|
||||
"store code": {
|
||||
@ -903,7 +903,7 @@ func TestProposalStrings(t *testing.T) {
|
||||
|
||||
func TestProposalYaml(t *testing.T) {
|
||||
specs := map[string]struct {
|
||||
src govtypes.Content
|
||||
src govv1beta1.Content
|
||||
exp string
|
||||
}{
|
||||
"store code": {
|
||||
@ -1051,8 +1051,8 @@ func TestConvertToProposals(t *testing.T) {
|
||||
func TestUnmarshalContentFromJson(t *testing.T) {
|
||||
specs := map[string]struct {
|
||||
src string
|
||||
got govtypes.Content
|
||||
exp govtypes.Content
|
||||
got govv1beta1.Content
|
||||
exp govv1beta1.Content
|
||||
}{
|
||||
"instantiate ": {
|
||||
src: `
|
||||
@ -1109,7 +1109,7 @@ func TestUnmarshalContentFromJson(t *testing.T) {
|
||||
func TestProposalJsonSignBytes(t *testing.T) {
|
||||
const myInnerMsg = `{"foo":"bar"}`
|
||||
specs := map[string]struct {
|
||||
src govtypes.Content
|
||||
src govv1beta1.Content
|
||||
exp string
|
||||
}{
|
||||
"instantiate contract": {
|
||||
@ -1131,7 +1131,7 @@ func TestProposalJsonSignBytes(t *testing.T) {
|
||||
}
|
||||
for name, spec := range specs {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
msg, err := govtypes.NewMsgSubmitProposal(spec.src, sdk.NewCoins(), []byte{})
|
||||
msg, err := govv1beta1.NewMsgSubmitProposal(spec.src, sdk.NewCoins(), []byte{})
|
||||
require.NoError(t, err)
|
||||
|
||||
bz := msg.GetSignBytes()
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@ -15,7 +15,7 @@ import (
|
||||
const firstCodeID = 1
|
||||
|
||||
func TestStoreCodeValidation(t *testing.T) {
|
||||
bad, err := sdk.AccAddressFromHex("012345")
|
||||
bad, err := sdk.AccAddressFromHexUnsafe("012345")
|
||||
require.NoError(t, err)
|
||||
badAddress := bad.String()
|
||||
// proper address size
|
||||
@ -79,7 +79,7 @@ func TestStoreCodeValidation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInstantiateContractValidation(t *testing.T) {
|
||||
bad, err := sdk.AccAddressFromHex("012345")
|
||||
bad, err := sdk.AccAddressFromHexUnsafe("012345")
|
||||
require.NoError(t, err)
|
||||
badAddress := bad.String()
|
||||
// proper address size
|
||||
@ -187,7 +187,7 @@ func TestInstantiateContractValidation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInstantiateContract2Validation(t *testing.T) {
|
||||
bad, err := sdk.AccAddressFromHex("012345")
|
||||
bad, err := sdk.AccAddressFromHexUnsafe("012345")
|
||||
require.NoError(t, err)
|
||||
badAddress := bad.String()
|
||||
// proper address size
|
||||
@ -323,7 +323,7 @@ func TestInstantiateContract2Validation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExecuteContractValidation(t *testing.T) {
|
||||
bad, err := sdk.AccAddressFromHex("012345")
|
||||
bad, err := sdk.AccAddressFromHexUnsafe("012345")
|
||||
require.NoError(t, err)
|
||||
badAddress := bad.String()
|
||||
// proper address size
|
||||
@ -432,7 +432,7 @@ func TestExecuteContractValidation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMsgUpdateAdministrator(t *testing.T) {
|
||||
bad, err := sdk.AccAddressFromHex("012345")
|
||||
bad, err := sdk.AccAddressFromHexUnsafe("012345")
|
||||
require.NoError(t, err)
|
||||
badAddress := bad.String()
|
||||
// proper address size
|
||||
@ -504,7 +504,7 @@ func TestMsgUpdateAdministrator(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMsgClearAdministrator(t *testing.T) {
|
||||
bad, err := sdk.AccAddressFromHex("012345")
|
||||
bad, err := sdk.AccAddressFromHexUnsafe("012345")
|
||||
require.NoError(t, err)
|
||||
badAddress := bad.String()
|
||||
// proper address size
|
||||
@ -555,7 +555,7 @@ func TestMsgClearAdministrator(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMsgMigrateContract(t *testing.T) {
|
||||
bad, err := sdk.AccAddressFromHex("012345")
|
||||
bad, err := sdk.AccAddressFromHexUnsafe("012345")
|
||||
require.NoError(t, err)
|
||||
badAddress := bad.String()
|
||||
// proper address size
|
||||
@ -681,7 +681,7 @@ func TestMsgJsonSignBytes(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMsgUpdateInstantiateConfig(t *testing.T) {
|
||||
bad, err := sdk.AccAddressFromHex("012345")
|
||||
bad, err := sdk.AccAddressFromHexUnsafe("012345")
|
||||
require.NoError(t, err)
|
||||
badAddress := bad.String()
|
||||
// proper address size
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/tendermint/tendermint/libs/rand"
|
||||
@ -55,7 +55,7 @@ func TestContractInfoValidateBasic(t *testing.T) {
|
||||
"invalid extension": {
|
||||
srcMutator: func(c *ContractInfo) {
|
||||
// any protobuf type with ValidateBasic method
|
||||
any, err := codectypes.NewAnyWithValue(&govtypes.TextProposal{})
|
||||
any, err := codectypes.NewAnyWithValue(&govv1beta1.TextProposal{})
|
||||
require.NoError(t, err)
|
||||
c.Extension = any
|
||||
},
|
||||
@ -64,7 +64,7 @@ func TestContractInfoValidateBasic(t *testing.T) {
|
||||
"not validatable extension": {
|
||||
srcMutator: func(c *ContractInfo) {
|
||||
// any protobuf type with ValidateBasic method
|
||||
any, err := codectypes.NewAnyWithValue(&govtypes.Proposal{})
|
||||
any, err := codectypes.NewAnyWithValue(&govv1beta1.Proposal{})
|
||||
require.NoError(t, err)
|
||||
c.Extension = any
|
||||
},
|
||||
@ -127,7 +127,7 @@ func TestContractInfoSetExtension(t *testing.T) {
|
||||
anyTime := time.Now().UTC()
|
||||
aNestedProtobufExt := func() ContractInfoExtension {
|
||||
// using gov proposal here as a random protobuf types as it contains an Any type inside for nested unpacking
|
||||
myExtension, err := govtypes.NewProposal(&govtypes.TextProposal{Title: "bar"}, 1, anyTime, anyTime)
|
||||
myExtension, err := govv1beta1.NewProposal(&govv1beta1.TextProposal{Title: "bar"}, 1, anyTime, anyTime)
|
||||
require.NoError(t, err)
|
||||
myExtension.TotalDeposit = nil
|
||||
return &myExtension
|
||||
@ -146,10 +146,10 @@ func TestContractInfoSetExtension(t *testing.T) {
|
||||
expNil: true,
|
||||
},
|
||||
"validated and accepted": {
|
||||
src: &govtypes.TextProposal{Title: "bar", Description: "set"},
|
||||
src: &govv1beta1.TextProposal{Title: "bar", Description: "set"},
|
||||
},
|
||||
"validated and rejected": {
|
||||
src: &govtypes.TextProposal{Title: "bar"},
|
||||
src: &govv1beta1.TextProposal{Title: "bar"},
|
||||
expErr: true,
|
||||
},
|
||||
}
|
||||
@ -178,7 +178,7 @@ func TestContractInfoMarshalUnmarshal(t *testing.T) {
|
||||
|
||||
anyTime := time.Now().UTC()
|
||||
// using gov proposal here as a random protobuf types as it contains an Any type inside for nested unpacking
|
||||
myExtension, err := govtypes.NewProposal(&govtypes.TextProposal{Title: "bar"}, 1, anyTime, anyTime)
|
||||
myExtension, err := govv1beta1.NewProposal(&govv1beta1.TextProposal{Title: "bar"}, 1, anyTime, anyTime)
|
||||
require.NoError(t, err)
|
||||
myExtension.TotalDeposit = nil
|
||||
|
||||
@ -192,10 +192,10 @@ func TestContractInfoMarshalUnmarshal(t *testing.T) {
|
||||
// register proposal as extension type
|
||||
interfaceRegistry.RegisterImplementations(
|
||||
(*ContractInfoExtension)(nil),
|
||||
&govtypes.Proposal{},
|
||||
&govv1beta1.Proposal{},
|
||||
)
|
||||
// register gov types for nested Anys
|
||||
govtypes.RegisterInterfaces(interfaceRegistry)
|
||||
govv1beta1.RegisterInterfaces(interfaceRegistry)
|
||||
|
||||
// when encode
|
||||
bz, err := marshaler.Marshal(&src)
|
||||
@ -207,14 +207,14 @@ func TestContractInfoMarshalUnmarshal(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, src, dest)
|
||||
// and sanity check nested any
|
||||
var destExt govtypes.Proposal
|
||||
var destExt govv1beta1.Proposal
|
||||
require.NoError(t, dest.ReadExtension(&destExt))
|
||||
assert.Equal(t, destExt.GetTitle(), "bar")
|
||||
}
|
||||
|
||||
func TestContractInfoReadExtension(t *testing.T) {
|
||||
anyTime := time.Now().UTC()
|
||||
myExtension, err := govtypes.NewProposal(&govtypes.TextProposal{Title: "foo"}, 1, anyTime, anyTime)
|
||||
myExtension, err := govv1beta1.NewProposal(&govv1beta1.TextProposal{Title: "foo"}, 1, anyTime, anyTime)
|
||||
require.NoError(t, err)
|
||||
type TestExtensionAsStruct struct {
|
||||
ContractInfoExtension
|
||||
@ -231,7 +231,7 @@ func TestContractInfoReadExtension(t *testing.T) {
|
||||
i.SetExtension(&myExtension)
|
||||
},
|
||||
param: func() ContractInfoExtension {
|
||||
return &govtypes.Proposal{}
|
||||
return &govv1beta1.Proposal{}
|
||||
},
|
||||
expVal: &myExtension,
|
||||
},
|
||||
@ -239,9 +239,9 @@ func TestContractInfoReadExtension(t *testing.T) {
|
||||
setup: func(i *ContractInfo) {
|
||||
},
|
||||
param: func() ContractInfoExtension {
|
||||
return &govtypes.Proposal{}
|
||||
return &govv1beta1.Proposal{}
|
||||
},
|
||||
expVal: &govtypes.Proposal{},
|
||||
expVal: &govv1beta1.Proposal{},
|
||||
},
|
||||
"nil argument value": {
|
||||
setup: func(i *ContractInfo) {
|
||||
@ -257,7 +257,7 @@ func TestContractInfoReadExtension(t *testing.T) {
|
||||
i.SetExtension(&myExtension)
|
||||
},
|
||||
param: func() ContractInfoExtension {
|
||||
return &govtypes.TextProposal{}
|
||||
return &govv1beta1.TextProposal{}
|
||||
},
|
||||
expErr: true,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user