Extend ContractInfo for custom data (#492)

* Extend ContractInfo with custom data

* Review comments
This commit is contained in:
Alexander Peters 2021-04-16 13:38:21 +02:00 committed by GitHub
parent 4b8d0247cc
commit d90bf6ec3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 750 additions and 252 deletions

View File

@ -7,6 +7,7 @@ import (
"path/filepath"
"github.com/CosmWasm/wasmd/x/wasm"
clientcodec "github.com/CosmWasm/wasmd/x/wasm/client/codec"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
vestingcli "github.com/cosmos/cosmos-sdk/x/auth/vesting/client/cli"
bankcmd "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
@ -48,7 +49,7 @@ func NewRootCmd() (*cobra.Command, app.EncodingConfig) {
config.Seal()
initClientCtx := client.Context{}.
WithJSONMarshaler(encodingConfig.Marshaler).
WithJSONMarshaler(clientcodec.NewProtoCodec(encodingConfig.Marshaler, encodingConfig.InterfaceRegistry)).
WithInterfaceRegistry(encodingConfig.InterfaceRegistry).
WithTxConfig(encodingConfig.TxConfig).
WithLegacyAmino(encodingConfig.Amino).

View File

@ -185,6 +185,7 @@ ContractInfo stores a WASM contract instance
| `label` | [string](#string) | | Label is optional metadata to be stored with a contract instance. |
| `created` | [AbsoluteTxPosition](#cosmwasm.wasm.v1beta1.AbsoluteTxPosition) | | Created Tx position when the contract was instantiated. This data should kept internal and not be exposed via query results. Just use for sorting |
| `ibc_port_id` | [string](#string) | | |
| `extension` | [google.protobuf.Any](#google.protobuf.Any) | | Extension is an extension point to store custom metadata within the persistence model. |

1
go.mod
View File

@ -14,6 +14,7 @@ require (
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/pkg/errors v0.9.1
github.com/rakyll/statik v0.1.7
github.com/regen-network/cosmos-proto v0.3.1 // indirect
github.com/rs/zerolog v1.21.0
github.com/snikch/goodman v0.0.0-20171125024755-10e37e294daa
github.com/spf13/cast v1.3.1

View File

@ -67,8 +67,11 @@ message QueryContractInfoResponse {
// address is the address of the contract
string address = 1;
ContractInfo contract_info = 2
[ (gogoproto.embed) = true, (gogoproto.jsontag) = "" ];
ContractInfo contract_info = 2 [
(gogoproto.embed) = true,
(gogoproto.nullable) = false,
(gogoproto.jsontag) = ""
];
}
// QueryContractHistoryRequest is the request type for the Query/ContractHistory
@ -103,8 +106,11 @@ message ContractInfoWithAddress {
option (gogoproto.equal) = true;
string address = 1;
ContractInfo contract_info = 2
[ (gogoproto.embed) = true, (gogoproto.jsontag) = "" ];
ContractInfo contract_info = 2 [
(gogoproto.embed) = true,
(gogoproto.nullable) = false,
(gogoproto.jsontag) = ""
];
}
// QueryContractsByCodeResponse is the response type for the
// Query/ContractsByCode RPC method

View File

@ -1,7 +1,9 @@
syntax = "proto3";
package cosmwasm.wasm.v1beta1;
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
option go_package = "github.com/CosmWasm/wasmd/x/wasm/types";
option (gogoproto.goproto_getters_all) = false;
@ -83,6 +85,11 @@ message ContractInfo {
// use for sorting
AbsoluteTxPosition created = 5;
string ibc_port_id = 6 [ (gogoproto.customname) = "IBCPortID" ];
// Extension is an extension point to store custom metadata within the
// persistence model.
google.protobuf.Any extension = 7
[ (cosmos_proto.accepts_interface) = "ContractInfoExtension" ];
}
// ContractCodeHistoryOperationType actions that caused a code change

View File

@ -32,7 +32,7 @@ type GenesisReader interface {
// GenesisMutator extension point to modify the wasm module genesis state.
// This gives flexibility to customize the data structure in the genesis file a bit.
type GenesisMutator interface {
// AlterModuleState loads the genesis from the default or set home dir,
// AlterWasmModuleState loads the genesis from the default or set home dir,
// unmarshalls the wasm module section into the object representation
// calls the callback function to modify it
// and marshals the modified state back into the genesis file
@ -147,7 +147,7 @@ func GenesisInstantiateContractCmd(defaultNodeHome string, genesisMutator Genesi
return cmd
}
// GenesisInstantiateContractCmd cli command to add a `MsgExecuteContract` to the wasm section of the genesis
// GenesisExecuteContractCmd cli command to add a `MsgExecuteContract` to the wasm section of the genesis
// that is executed on block 0.
func GenesisExecuteContractCmd(defaultNodeHome string, genesisMutator GenesisMutator) *cobra.Command {
cmd := &cobra.Command{
@ -420,7 +420,7 @@ func NewDefaultGenesisIO() *DefaultGenesisIO {
return &DefaultGenesisIO{DefaultGenesisReader: DefaultGenesisReader{}}
}
// AlterModuleState loads the genesis from the default or set home dir,
// AlterWasmModuleState loads the genesis from the default or set home dir,
// unmarshalls the wasm module section into the object representation
// calls the callback function to modify it
// and marshals the modified state back into the genesis file

View File

@ -13,9 +13,7 @@ import (
"github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/gogo/protobuf/proto"
"github.com/spf13/cobra"
flag "github.com/spf13/pflag"
)
@ -66,7 +64,7 @@ func GetCmdListCode() *cobra.Command {
if err != nil {
return err
}
return clientCtx.WithJSONMarshaler(&VanillaStdJsonMarshaller{}).PrintProto(res)
return clientCtx.PrintProto(res)
},
}
flags.AddQueryFlagsToCmd(cmd)
@ -107,7 +105,7 @@ func GetCmdListContractByCode() *cobra.Command {
if err != nil {
return err
}
return clientCtx.WithJSONMarshaler(&VanillaStdJsonMarshaller{}).PrintProto(res)
return clientCtx.PrintProto(res)
},
}
flags.AddQueryFlagsToCmd(cmd)
@ -183,7 +181,7 @@ func GetCmdGetContractInfo() *cobra.Command {
if err != nil {
return err
}
return clientCtx.WithJSONMarshaler(&VanillaStdJsonMarshaller{}).PrintProto(res)
return clientCtx.PrintProto(res)
},
}
flags.AddQueryFlagsToCmd(cmd)
@ -240,7 +238,7 @@ func GetCmdGetContractStateAll() *cobra.Command {
if err != nil {
return err
}
return clientCtx.WithJSONMarshaler(&VanillaStdJsonMarshaller{}).PrintProto(res)
return clientCtx.PrintProto(res)
},
}
flags.AddQueryFlagsToCmd(cmd)
@ -281,7 +279,7 @@ func GetCmdGetContractStateRaw() *cobra.Command {
if err != nil {
return err
}
return clientCtx.WithJSONMarshaler(&VanillaStdJsonMarshaller{}).PrintProto(res)
return clientCtx.PrintProto(res)
},
}
decoder.RegisterFlags(cmd.PersistentFlags(), "key argument")
@ -329,7 +327,7 @@ func GetCmdGetContractStateSmart() *cobra.Command {
if err != nil {
return err
}
return clientCtx.WithJSONMarshaler(&VanillaStdJsonMarshaller{}).PrintProto(res)
return clientCtx.PrintProto(res)
},
}
decoder.RegisterFlags(cmd.PersistentFlags(), "query argument")
@ -371,7 +369,7 @@ func GetCmdGetContractHistory() *cobra.Command {
return err
}
return clientCtx.WithJSONMarshaler(&VanillaStdJsonMarshaller{}).PrintProto(res)
return clientCtx.PrintProto(res)
},
}
@ -423,41 +421,6 @@ func asciiDecodeString(s string) ([]byte, error) {
return []byte(s), nil
}
type VanillaStdJsonMarshaller struct {
}
func (x VanillaStdJsonMarshaller) MarshalInterfaceJSON(i proto.Message) ([]byte, error) {
any, err := codectypes.NewAnyWithValue(i)
if err != nil {
return nil, err
}
return x.MarshalJSON(any)
}
func (x VanillaStdJsonMarshaller) MarshalJSON(o proto.Message) ([]byte, error) {
return json.MarshalIndent(o, "", " ")
}
func (x VanillaStdJsonMarshaller) MustMarshalJSON(o proto.Message) []byte {
b, err := x.MarshalJSON(o)
if err != nil {
panic(err)
}
return b
}
func (x VanillaStdJsonMarshaller) UnmarshalInterfaceJSON(bz []byte, ptr interface{}) error {
panic("not supported")
}
func (x VanillaStdJsonMarshaller) UnmarshalJSON(bz []byte, ptr proto.Message) error {
panic("not supported")
}
func (x VanillaStdJsonMarshaller) MustUnmarshalJSON(bz []byte, ptr proto.Message) {
panic("not supported")
}
// sdk ReadPageRequest expects binary but we encoded to base64 in our marshaller
func withPageKeyDecoded(flagSet *flag.FlagSet) *flag.FlagSet {
encoded, err := flagSet.GetString(flags.FlagPageKey)

View File

@ -0,0 +1,78 @@
package codec
import (
"bytes"
"fmt"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/gogo/protobuf/jsonpb"
"github.com/gogo/protobuf/proto"
)
var _ codec.Marshaler = (*ProtoCodec)(nil)
// ProtoCodec that omits empty values.
// This Marshaler can be used globally when setting up the client context or individually
// for each command via `clientCtx.WithJSONMarshaler(myMarshaler)`.
type ProtoCodec struct {
codec.Marshaler
interfaceRegistry types.InterfaceRegistry
}
func NewProtoCodec(marshaler codec.Marshaler, registry types.InterfaceRegistry) *ProtoCodec {
return &ProtoCodec{Marshaler: marshaler, interfaceRegistry: registry}
}
// MarshalJSON implements JSONMarshaler.MarshalJSON method,
// it marshals to JSON using proto codec.
func (pc *ProtoCodec) MarshalJSON(o proto.Message) ([]byte, error) {
m, ok := o.(codec.ProtoMarshaler)
if !ok {
return nil, fmt.Errorf("cannot protobuf JSON encode unsupported type: %T", o)
}
return ProtoMarshalJSON(m, pc.interfaceRegistry)
}
// MustMarshalJSON implements JSONMarshaler.MustMarshalJSON method,
// it executes MarshalJSON except it panics upon failure.
func (pc *ProtoCodec) MustMarshalJSON(o proto.Message) []byte {
bz, err := pc.MarshalJSON(o)
if err != nil {
panic(err)
}
return bz
}
// MarshalInterfaceJSON is a convenience function for proto marshalling interfaces. It
// packs the provided value in an Any and then marshals it to bytes.
// NOTE: to marshal a concrete type, you should use MarshalJSON instead
func (pc *ProtoCodec) MarshalInterfaceJSON(x proto.Message) ([]byte, error) {
any, err := types.NewAnyWithValue(x)
if err != nil {
return nil, err
}
return pc.MarshalJSON(any)
}
// ProtoMarshalJSON provides an auxiliary function to return Proto3 JSON encoded
// bytes of a message.
func ProtoMarshalJSON(msg proto.Message, resolver jsonpb.AnyResolver) ([]byte, error) {
// method copied from sdk codec/json.go with EmitDefaults set to `false`
// so that empty fields are not rendered
// We use the OrigName because camel casing fields just doesn't make sense.
// EmitDefaults is also often the more expected behavior for CLI users
jm := &jsonpb.Marshaler{OrigName: true, EmitDefaults: false, AnyResolver: resolver}
err := types.UnpackInterfaces(msg, types.ProtoJSONPacker{JSONPBMarshaler: jm})
if err != nil {
return nil, err
}
buf := new(bytes.Buffer)
if err := jm.Marshal(buf, msg); err != nil {
return nil, err
}
return buf.Bytes(), nil
}

View File

@ -16,6 +16,7 @@ type decoratedKeeper interface {
pinCode(ctx sdk.Context, codeID uint64) error
unpinCode(ctx sdk.Context, codeID uint64) error
execute(ctx sdk.Context, contractAddress sdk.AccAddress, caller sdk.AccAddress, msg []byte, coins sdk.Coins) (*sdk.Result, error)
setContractInfoExtension(ctx sdk.Context, contract sdk.AccAddress, extra types.ContractInfoExtension) error
}
type PermissionedKeeper struct {
@ -66,3 +67,8 @@ func (p PermissionedKeeper) PinCode(ctx sdk.Context, codeID uint64) error {
func (p PermissionedKeeper) UnpinCode(ctx sdk.Context, codeID uint64) error {
return p.nested.unpinCode(ctx, codeID)
}
// SetExtraContractAttributes updates the extra attributes that can be stored with the contract info
func (p PermissionedKeeper) SetContractInfoExtension(ctx sdk.Context, contract sdk.AccAddress, extra types.ContractInfoExtension) error {
return p.nested.setContractInfoExtension(ctx, contract, extra)
}

View File

@ -4,9 +4,9 @@ import (
"bytes"
"crypto/sha256"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"io/ioutil"
"math/rand"
"os"
@ -48,17 +48,20 @@ func TestGenesisExportImport(t *testing.T) {
for i := 0; i < 25; i++ {
var (
codeInfo types.CodeInfo
contract types.ContractInfo
stateModels []types.Model
history []types.ContractCodeHistoryEntry
pinned bool
codeInfo types.CodeInfo
contract types.ContractInfo
stateModels []types.Model
history []types.ContractCodeHistoryEntry
pinned bool
contractExtension bool
)
f.Fuzz(&codeInfo)
f.Fuzz(&contract)
f.Fuzz(&stateModels)
f.NilChance(0).Fuzz(&history)
f.Fuzz(&pinned)
f.Fuzz(&contractExtension)
creatorAddr, err := sdk.AccAddressFromBech32(codeInfo.Creator)
require.NoError(t, err)
codeID, err := contractKeeper.Create(srcCtx, creatorAddr, wasmCode, codeInfo.Source, codeInfo.Builder, &codeInfo.InstantiateConfig)
@ -66,6 +69,14 @@ func TestGenesisExportImport(t *testing.T) {
if pinned {
contractKeeper.PinCode(srcCtx, codeID)
}
if contractExtension {
anyTime := time.Now().UTC()
var nestedType govtypes.TextProposal
f.NilChance(0).Fuzz(&nestedType)
myExtension, err := govtypes.NewProposal(&nestedType, 1, anyTime, anyTime)
require.NoError(t, err)
contract.SetExtension(&myExtension)
}
contract.CodeID = codeID
contractAddr := wasmKeeper.generateContractAddress(srcCtx, codeID)
@ -89,7 +100,7 @@ func TestGenesisExportImport(t *testing.T) {
rand.Shuffle(len(exportedState.Sequences), func(i, j int) {
exportedState.Sequences[i], exportedState.Sequences[j] = exportedState.Sequences[j], exportedState.Sequences[i]
})
exportedGenesis, err := json.Marshal(exportedState)
exportedGenesis, err := wasmKeeper.cdc.MarshalJSON(exportedState)
require.NoError(t, err)
// reset ContractInfo in source DB for comparison with dest DB
@ -104,7 +115,7 @@ func TestGenesisExportImport(t *testing.T) {
dstKeeper, dstCtx, dstStoreKeys := setupKeeper(t)
var importState wasmTypes.GenesisState
err = json.Unmarshal(exportedGenesis, &importState)
err = wasmKeeper.cdc.UnmarshalJSON(exportedGenesis, &importState)
require.NoError(t, err)
InitGenesis(dstCtx, dstKeeper, importState, &StakingKeeperMock{}, TestHandler(contractKeeper))
@ -642,6 +653,14 @@ func setupKeeper(t *testing.T) (*Keeper, sdk.Context, []sdk.StoreKey) {
}, false, log.NewNopLogger())
encodingConfig := MakeEncodingConfig(t)
// register an example extension. must be protobuf
encodingConfig.InterfaceRegistry.RegisterImplementations(
(*types.ContractInfoExtension)(nil),
&govtypes.Proposal{},
)
// also registering gov interfaces for nested Any type
govtypes.RegisterInterfaces(encodingConfig.InterfaceRegistry)
wasmConfig := wasmTypes.DefaultWasmConfig()
pk := paramskeeper.NewKeeper(encodingConfig.Marshaler, encodingConfig.Amino, keyParams, tkeyParams)

View File

@ -756,6 +756,19 @@ func (k Keeper) InitializePinnedCodes(ctx sdk.Context) error {
return nil
}
// setContractInfoExtension updates the extension point data that is stored with the contract info
func (k Keeper) setContractInfoExtension(ctx sdk.Context, contractAddr sdk.AccAddress, ext types.ContractInfoExtension) error {
info := k.GetContractInfo(ctx, contractAddr)
if info == nil {
return sdkerrors.Wrap(types.ErrNotFound, "contract info")
}
if err := info.SetExtension(ext); err != nil {
return err
}
k.storeContractInfo(ctx, contractAddr, info)
return nil
}
func (k Keeper) dispatchAll(ctx sdk.Context, contractAddr sdk.AccAddress, ibcPort string, subMsgs []wasmvmtypes.SubMsg, msgs []wasmvmtypes.CosmosMsg) error {
// first dispatch all submessages (and the replies).
err := k.dispatchSubmessages(ctx, contractAddr, ibcPort, subMsgs)

View File

@ -152,7 +152,7 @@ func queryContractListByCode(ctx sdk.Context, codeID uint64, keeper types.ViewKe
// and add the address
infoWithAddress := types.ContractInfoWithAddress{
Address: addr.String(),
ContractInfo: &info,
ContractInfo: info,
}
contracts = append(contracts, infoWithAddress)
}

View File

@ -103,7 +103,7 @@ func (q grpcQuerier) ContractsByCode(c context.Context, req *types.QueryContract
if accumulate {
r = append(r, types.ContractInfoWithAddress{
Address: contractAddr.String(),
ContractInfo: c,
ContractInfo: *c,
})
}
return true, nil
@ -267,7 +267,7 @@ func queryContractInfo(ctx sdk.Context, addr sdk.AccAddress, keeper types.ViewKe
info.Created = nil
return &types.ContractInfoWithAddress{
Address: addr.String(),
ContractInfo: info,
ContractInfo: *info,
}, nil
}

View File

@ -5,18 +5,19 @@ import (
"encoding/json"
"fmt"
"github.com/CosmWasm/wasmd/x/wasm/keeper/wasmtesting"
"io/ioutil"
"testing"
"github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/CosmWasm/wasmvm"
wasmvmtypes "github.com/CosmWasm/wasmvm/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkErrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/query"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/log"
"io/ioutil"
"testing"
"time"
)
func TestQueryAllContractState(t *testing.T) {
@ -523,6 +524,77 @@ func TestQueryCodeList(t *testing.T) {
}
}
func TestQueryContractInfo(t *testing.T) {
var (
contractAddr = RandomAccountAddress(t)
anyDate = time.Now().UTC()
)
ctx, keepers := CreateTestInput(t, false, SupportedFeatures)
// register an example extension. must be protobuf
keepers.EncodingConfig.InterfaceRegistry.RegisterImplementations(
(*types.ContractInfoExtension)(nil),
&govtypes.Proposal{},
)
govtypes.RegisterInterfaces(keepers.EncodingConfig.InterfaceRegistry)
k := keepers.WasmKeeper
querier := NewGrpcQuerier(k.cdc, k.storeKey, k, k.queryGasLimit)
myExtension := func(info *types.ContractInfo) {
// abuse gov proposal as a random protobuf extension with an Any type
myExt, err := govtypes.NewProposal(&govtypes.TextProposal{Title: "foo", Description: "bar"}, 1, anyDate, anyDate)
require.NoError(t, err)
myExt.TotalDeposit = nil
info.SetExtension(&myExt)
}
specs := map[string]struct {
src *types.QueryContractInfoRequest
stored types.ContractInfo
expRsp *types.QueryContractInfoResponse
expErr bool
}{
"found": {
src: &types.QueryContractInfoRequest{Address: contractAddr.String()},
stored: types.ContractInfoFixture(),
expRsp: &types.QueryContractInfoResponse{
Address: contractAddr.String(),
ContractInfo: types.ContractInfoFixture(func(info *types.ContractInfo) {
info.Created = nil // not returned on queries
}),
},
},
"with extension": {
src: &types.QueryContractInfoRequest{Address: contractAddr.String()},
stored: types.ContractInfoFixture(myExtension),
expRsp: &types.QueryContractInfoResponse{
Address: contractAddr.String(),
ContractInfo: types.ContractInfoFixture(myExtension, func(info *types.ContractInfo) {
info.Created = nil // not returned on queries
}),
},
},
"not found": {
src: &types.QueryContractInfoRequest{Address: RandomBech32AccountAddress(t)},
stored: types.ContractInfoFixture(),
expErr: true,
},
}
for name, spec := range specs {
t.Run(name, func(t *testing.T) {
xCtx, _ := ctx.CacheContext()
k.storeContractInfo(xCtx, contractAddr, &spec.stored)
// when
gotRsp, gotErr := querier.ContractInfo(sdk.WrapSDKContext(xCtx), spec.src)
if spec.expErr {
require.Error(t, gotErr)
return
}
require.NoError(t, gotErr)
assert.Equal(t, spec.expRsp, gotRsp)
})
}
}
func fromBase64(s string) []byte {
r, err := base64.StdEncoding.DecodeString(s)
if err != nil {

View File

@ -136,6 +136,7 @@ type TestKeepers struct {
WasmKeeper *Keeper
IBCKeeper *ibckeeper.Keeper
Router *baseapp.Router
EncodingConfig params2.EncodingConfig
}
// CreateDefaultTestInput common settings for CreateTestInput
@ -334,6 +335,7 @@ func createTestInput(
GovKeeper: govKeeper,
IBCKeeper: ibcKeeper,
Router: router,
EncodingConfig: encodingConfig,
}
return ctx, keepers
}

View File

@ -50,6 +50,8 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
&UnpinCodesProposal{},
)
registry.RegisterInterface("ContractInfoExtension", (*ContractInfoExtension)(nil))
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}

View File

@ -47,6 +47,9 @@ type ContractOpsKeeper interface {
// UnpinCode removes the wasm contract from wasmvm cache
UnpinCode(ctx sdk.Context, codeID uint64) error
// SetContractInfoExtension updates the extension point data that is stored with the contract info
SetContractInfoExtension(ctx sdk.Context, contract sdk.AccAddress, extra ContractInfoExtension) error
}
// IBCContractKeeper IBC lifecycle event handler

View File

@ -77,8 +77,8 @@ var xxx_messageInfo_QueryContractInfoRequest proto.InternalMessageInfo
// method
type QueryContractInfoResponse struct {
// address is the address of the contract
Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
*ContractInfo `protobuf:"bytes,2,opt,name=contract_info,json=contractInfo,proto3,embedded=contract_info" json:""`
Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
ContractInfo `protobuf:"bytes,2,opt,name=contract_info,json=contractInfo,proto3,embedded=contract_info" json:""`
}
func (m *QueryContractInfoResponse) Reset() { *m = QueryContractInfoResponse{} }
@ -241,8 +241,8 @@ var xxx_messageInfo_QueryContractsByCodeRequest proto.InternalMessageInfo
// ContractInfoWithAddress adds the address (key) to the ContractInfo
// representation
type ContractInfoWithAddress struct {
Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
*ContractInfo `protobuf:"bytes,2,opt,name=contract_info,json=contractInfo,proto3,embedded=contract_info" json:""`
Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
ContractInfo `protobuf:"bytes,2,opt,name=contract_info,json=contractInfo,proto3,embedded=contract_info" json:""`
}
func (m *ContractInfoWithAddress) Reset() { *m = ContractInfoWithAddress{} }
@ -787,77 +787,77 @@ func init() {
func init() { proto.RegisterFile("cosmwasm/wasm/v1beta1/query.proto", fileDescriptor_e8595715dfdf95d1) }
var fileDescriptor_e8595715dfdf95d1 = []byte{
// 1105 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x97, 0xcf, 0x6f, 0x1b, 0x45,
0x14, 0xc7, 0x3d, 0xa9, 0xe3, 0xc4, 0xd3, 0x14, 0xcc, 0xa8, 0x50, 0x63, 0xdc, 0x75, 0x58, 0x50,
0xea, 0x16, 0x69, 0x37, 0x89, 0x53, 0x04, 0xe5, 0x54, 0xa7, 0x40, 0x2a, 0x51, 0x7e, 0x6c, 0x84,
0x22, 0xe8, 0x21, 0x1a, 0xef, 0x4e, 0xed, 0x45, 0xf6, 0x8e, 0xbb, 0x33, 0x26, 0xb1, 0xa2, 0x50,
0xc4, 0x85, 0x13, 0x02, 0x89, 0x23, 0x17, 0x0e, 0x1c, 0x50, 0x81, 0x7b, 0x8f, 0x1c, 0x38, 0xe4,
0x18, 0x89, 0x0b, 0x27, 0x0b, 0x1c, 0x84, 0x50, 0xfe, 0x84, 0x9e, 0xd0, 0xce, 0xce, 0x3a, 0xbb,
0x8e, 0xd7, 0xeb, 0x20, 0x0b, 0x2e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67, 0x45, 0x6b, 0x45, 0x89, 0x81, 0x83, 0xde, 0x5e, 0xb8,
0x3a, 0x81, 0xa5, 0x64, 0x28, 0x08, 0x86, 0x8b, 0x08, 0x9d, 0x66, 0xa8, 0x6e, 0x1c, 0xfc, 0xa1,
0xa4, 0xbe, 0xef, 0x2b, 0xa9, 0x83, 0xbe, 0x02, 0x0e, 0xfb, 0x0a, 0xf8, 0xbd, 0xaf, 0x80, 0xaf,
0x8e, 0x94, 0xd4, 0xe1, 0x91, 0x92, 0xfa, 0xed, 0x48, 0x49, 0x7d, 0xb8, 0x14, 0x9a, 0xad, 0xeb,
0x94, 0xb5, 0xb6, 0x82, 0x3f, 0xad, 0x96, 0xbe, 0xeb, 0x07, 0x14, 0x7f, 0x5a, 0x6b, 0x19, 0xf1,
0x5f, 0xb3, 0xf2, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6e, 0x56, 0xdc, 0x6b, 0x2a, 0x0f, 0x00,
0x00,
// 1111 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x97, 0xcd, 0x6f, 0x1b, 0xc5,
0x1b, 0xc7, 0x3d, 0xa9, 0xf3, 0xe2, 0x69, 0xfa, 0xfb, 0x85, 0x51, 0xa1, 0xc6, 0xb8, 0xbb, 0x61,
0x41, 0xa9, 0x5b, 0xa4, 0xdd, 0x24, 0x4e, 0x11, 0x94, 0x53, 0x9d, 0x02, 0xa9, 0x44, 0x79, 0xd9,
0x08, 0x22, 0xe8, 0x21, 0x1a, 0xef, 0x4e, 0xed, 0x45, 0xf6, 0x8e, 0xbb, 0x33, 0x26, 0xb1, 0xa2,
0x50, 0xc4, 0x85, 0x2b, 0xa8, 0x47, 0x2e, 0x1c, 0x38, 0xa0, 0x02, 0xf7, 0x1e, 0x39, 0x70, 0xc8,
0x31, 0x12, 0x17, 0x4e, 0x16, 0x38, 0x08, 0xa1, 0xfc, 0x09, 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x14, 0x5c, 0x0a, 0x2a, 0x8e, 0x3a, 0xb8, 0x68, 0x17, 0x4e, 0x8b, 0xd6,
0x8a, 0x52, 0x03, 0x87, 0xbd, 0xbd, 0x70, 0x75, 0x0c, 0x4b, 0xc9, 0x50, 0x10, 0x0c, 0x17, 0x11,
0x3a, 0xcd, 0x50, 0xd9, 0x38, 0xf8, 0x5d, 0xc9, 0x7c, 0xd7, 0x53, 0x32, 0x07, 0x3d, 0x05, 0x1c,
0xf6, 0x14, 0xf0, 0x5b, 0x4f, 0x01, 0x5f, 0x1e, 0x29, 0x99, 0xc3, 0x23, 0x25, 0xf3, 0xeb, 0x91,
0x92, 0xf9, 0x68, 0x29, 0x32, 0x5b, 0xd7, 0x29, 0x6b, 0x6e, 0x85, 0x1f, 0xaf, 0xb6, 0xb1, 0x1b,
0x04, 0x14, 0x1f, 0xaf, 0xd5, 0x19, 0xf1, 0xcd, 0x59, 0xfe, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x99,
0xbc, 0xec, 0x7a, 0x32, 0x0f, 0x00, 0x00,
}
func (this *QueryContractInfoResponse) Equal(that interface{}) bool {
@ -882,7 +882,7 @@ func (this *QueryContractInfoResponse) Equal(that interface{}) bool {
if this.Address != that1.Address {
return false
}
if !this.ContractInfo.Equal(that1.ContractInfo) {
if !this.ContractInfo.Equal(&that1.ContractInfo) {
return false
}
return true
@ -909,7 +909,7 @@ func (this *ContractInfoWithAddress) Equal(that interface{}) bool {
if this.Address != that1.Address {
return false
}
if !this.ContractInfo.Equal(that1.ContractInfo) {
if !this.ContractInfo.Equal(&that1.ContractInfo) {
return false
}
return true
@ -1376,18 +1376,16 @@ func (m *QueryContractInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, erro
_ = i
var l int
_ = l
if m.ContractInfo != nil {
{
size, err := m.ContractInfo.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintQuery(dAtA, i, uint64(size))
{
size, err := m.ContractInfo.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i--
dAtA[i] = 0x12
i -= size
i = encodeVarintQuery(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x12
if len(m.Address) > 0 {
i -= len(m.Address)
copy(dAtA[i:], m.Address)
@ -1549,18 +1547,16 @@ func (m *ContractInfoWithAddress) MarshalToSizedBuffer(dAtA []byte) (int, error)
_ = i
var l int
_ = l
if m.ContractInfo != nil {
{
size, err := m.ContractInfo.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintQuery(dAtA, i, uint64(size))
{
size, err := m.ContractInfo.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i--
dAtA[i] = 0x12
i -= size
i = encodeVarintQuery(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x12
if len(m.Address) > 0 {
i -= len(m.Address)
copy(dAtA[i:], m.Address)
@ -2089,10 +2085,8 @@ func (m *QueryContractInfoResponse) Size() (n int) {
if l > 0 {
n += 1 + l + sovQuery(uint64(l))
}
if m.ContractInfo != nil {
l = m.ContractInfo.Size()
n += 1 + l + sovQuery(uint64(l))
}
l = m.ContractInfo.Size()
n += 1 + l + sovQuery(uint64(l))
return n
}
@ -2158,10 +2152,8 @@ func (m *ContractInfoWithAddress) Size() (n int) {
if l > 0 {
n += 1 + l + sovQuery(uint64(l))
}
if m.ContractInfo != nil {
l = m.ContractInfo.Size()
n += 1 + l + sovQuery(uint64(l))
}
l = m.ContractInfo.Size()
n += 1 + l + sovQuery(uint64(l))
return n
}
@ -2547,9 +2539,6 @@ func (m *QueryContractInfoResponse) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.ContractInfo == nil {
m.ContractInfo = &ContractInfo{}
}
if err := m.ContractInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
@ -3008,9 +2997,6 @@ func (m *ContractInfoWithAddress) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.ContractInfo == nil {
m.ContractInfo = &ContractInfo{}
}
if err := m.ContractInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}

View File

@ -2,10 +2,12 @@ package types
import (
"fmt"
wasmvmtypes "github.com/CosmWasm/wasmvm/types"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/gogo/protobuf/proto"
"reflect"
)
const (
@ -68,6 +70,14 @@ func NewContractInfo(codeID uint64, creator, admin sdk.AccAddress, label string,
}
}
// validatable is an optional interface that can be implemented by an ContractInfoExtension to enable validation
type validatable interface {
ValidateBasic() error
}
// ValidateBasic does syntax checks on the data. If an extension is set and has the `ValidateBasic() error` method, then
// the method is called as well. It is recommend to implement `ValidateBasic` so that the data is verified in the setter
// but also in the genesis import process.
func (c *ContractInfo) ValidateBasic() error {
if c.CodeID == 0 {
return sdkerrors.Wrap(ErrEmpty, "code id")
@ -83,6 +93,62 @@ func (c *ContractInfo) ValidateBasic() error {
if err := validateLabel(c.Label); err != nil {
return sdkerrors.Wrap(err, "label")
}
if c.Extension == nil {
return nil
}
e, ok := c.Extension.GetCachedValue().(validatable)
if !ok {
return nil
}
if err := e.ValidateBasic(); err != nil {
return sdkerrors.Wrap(err, "extension")
}
return nil
}
// SetExtension set new extension data. Calls `ValidateBasic() error` on non nil values when method is implemented by
// the extension.
func (c *ContractInfo) SetExtension(ext ContractInfoExtension) error {
if ext == nil {
c.Extension = nil
return nil
}
if e, ok := ext.(validatable); ok {
if err := e.ValidateBasic(); err != nil {
return err
}
}
any, err := codectypes.NewAnyWithValue(ext)
if err != nil {
return sdkerrors.Wrap(sdkerrors.ErrPackAny, err.Error())
}
c.Extension = any
return nil
}
// ReadExtension copies the extension value to the pointer passed as argument so that there is no need to cast
// For example with a custom extension of type `MyContractDetails` it will look as following:
// var d MyContractDetails
// if err := info.ReadExtension(&d); err != nil {
// return nil, sdkerrors.Wrap(err, "extension")
// }
func (c *ContractInfo) ReadExtension(e ContractInfoExtension) error {
rv := reflect.ValueOf(e)
if rv.Kind() != reflect.Ptr || rv.IsNil() {
return sdkerrors.Wrap(sdkerrors.ErrInvalidType, "not a pointer")
}
if c.Extension == nil {
return nil
}
cached := c.Extension.GetCachedValue()
elem := reflect.ValueOf(cached).Elem()
if !elem.Type().AssignableTo(rv.Elem().Type()) {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "extension is of type %s but argument of %s", elem.Type(), rv.Elem().Type())
}
rv.Elem().Set(elem)
return nil
}
@ -128,6 +194,23 @@ func (c *ContractInfo) AdminAddr() sdk.AccAddress {
return admin
}
// ContractInfoExtension defines the extension point for custom data to be stored with a contract info
type ContractInfoExtension interface {
proto.Message
String() string
}
var _ codectypes.UnpackInterfacesMessage = &ContractInfo{}
// UnpackInterfaces implements codectypes.UnpackInterfaces
func (m *ContractInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
var details ContractInfoExtension
if err := unpacker.UnpackAny(m.Extension, &details); err != nil {
return err
}
return codectypes.UnpackInterfaces(details, unpacker)
}
// NewAbsoluteTxPosition gets a block position from the context
func NewAbsoluteTxPosition(ctx sdk.Context) *AbsoluteTxPosition {
// we must safely handle nil gas meters

View File

@ -7,8 +7,10 @@ import (
bytes "bytes"
encoding_json "encoding/json"
fmt "fmt"
types "github.com/cosmos/cosmos-sdk/codec/types"
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/gogo/protobuf/proto"
_ "github.com/regen-network/cosmos-proto"
github_com_tendermint_tendermint_libs_bytes "github.com/tendermint/tendermint/libs/bytes"
io "io"
math "math"
@ -273,6 +275,9 @@ type ContractInfo struct {
// use for sorting
Created *AbsoluteTxPosition `protobuf:"bytes,5,opt,name=created,proto3" json:"created,omitempty"`
IBCPortID string `protobuf:"bytes,6,opt,name=ibc_port_id,json=ibcPortId,proto3" json:"ibc_port_id,omitempty"`
// Extension is an extension point to store custom metadata within the
// persistence model.
Extension *types.Any `protobuf:"bytes,7,opt,name=extension,proto3" json:"extension,omitempty"`
}
func (m *ContractInfo) Reset() { *m = ContractInfo{} }
@ -451,78 +456,82 @@ func init() {
func init() { proto.RegisterFile("cosmwasm/wasm/v1beta1/types.proto", fileDescriptor_2548aa229a1f29bc) }
var fileDescriptor_2548aa229a1f29bc = []byte{
// 1123 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x56, 0xcd, 0x6f, 0x1b, 0x45,
0x14, 0xf7, 0xda, 0xce, 0xd7, 0x34, 0xb4, 0xee, 0xd0, 0x50, 0xd7, 0x14, 0xdb, 0xd9, 0xf2, 0x91,
0x7e, 0x60, 0xd3, 0x82, 0x28, 0xea, 0xcd, 0x5e, 0x2f, 0xcd, 0x56, 0xc4, 0xb6, 0xc6, 0x0e, 0x6d,
0x90, 0xd0, 0x6a, 0x76, 0x77, 0xe2, 0x0c, 0xdd, 0xdd, 0xb1, 0x76, 0xc6, 0xad, 0xdd, 0xbf, 0x00,
0x85, 0x0b, 0xe2, 0xc4, 0x81, 0x48, 0x48, 0x20, 0xd4, 0x3f, 0xa5, 0x17, 0xa4, 0x1e, 0x39, 0x59,
0x90, 0x0a, 0x09, 0xae, 0xe1, 0xd6, 0x13, 0xda, 0x19, 0x5b, 0x5e, 0xd1, 0x36, 0x31, 0x97, 0xd5,
0xbc, 0x37, 0xef, 0xf7, 0x7b, 0xef, 0xf7, 0x66, 0xde, 0x6a, 0xc0, 0xba, 0xcb, 0x78, 0xf0, 0x10,
0xf3, 0xa0, 0x2a, 0x3f, 0x0f, 0xae, 0x3b, 0x44, 0xe0, 0xeb, 0x55, 0x31, 0xea, 0x13, 0x5e, 0xe9,
0x47, 0x4c, 0x30, 0xb8, 0x36, 0x0d, 0xa9, 0xc8, 0xcf, 0x24, 0xa4, 0x70, 0xae, 0xc7, 0x7a, 0x4c,
0x46, 0x54,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x16, 0xb5, 0xdf, 0x0f, 0x8b, 0xda,
0xb7, 0xcf, 0x8a, 0xa9, 0xa7, 0xcf, 0x8a, 0xa9, 0xdf, 0x9e, 0x15, 0x53, 0x5f, 0xbc, 0x9b, 0x98,
0x03, 0x83, 0xf1, 0xe0, 0xee, 0xf4, 0x3d, 0xe4, 0x55, 0x87, 0xea, 0x5d, 0x24, 0xdf, 0x43, 0xce,
0xa2, 0x7c, 0xe3, 0x7c, 0xf8, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd8, 0xd8, 0x83, 0x31, 0x35,
0x09, 0x00, 0x00,
// 1190 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x56, 0x5d, 0x6f, 0x1b, 0x45,
0x17, 0xf6, 0xda, 0xce, 0x87, 0xa7, 0x79, 0x5b, 0x77, 0xde, 0x84, 0x3a, 0xa6, 0xd8, 0xce, 0x96,
0x8f, 0xf4, 0xcb, 0xa6, 0x05, 0x51, 0xd4, 0x3b, 0x7b, 0xbd, 0x34, 0x5b, 0x11, 0xdb, 0x1a, 0x3b,
0xb4, 0x41, 0x42, 0xab, 0xd9, 0xdd, 0x89, 0x33, 0x74, 0xbd, 0x63, 0xed, 0x8c, 0x5b, 0xbb, 0xbf,
0x00, 0x85, 0x1b, 0xc4, 0x15, 0x17, 0x44, 0x42, 0x02, 0xa1, 0xfe, 0x00, 0x7e, 0x01, 0x57, 0x15,
0x12, 0x52, 0x2f, 0xb9, 0xb2, 0x20, 0x15, 0x12, 0xdc, 0xe6, 0xb2, 0x57, 0x68, 0x67, 0x6c, 0x79,
0x45, 0x3f, 0x62, 0x6e, 0xac, 0x39, 0x67, 0xce, 0xf3, 0x9c, 0x79, 0xce, 0x99, 0x33, 0x5e, 0xb0,
0xe1, 0x32, 0xde, 0x7b, 0x80, 0x79, 0xaf, 0x22, 0x7f, 0xee, 0x5f, 0x73, 0x88, 0xc0,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 0x4f, 0xe2, 0x8e, 0x17, 0xec, 0x0e, 0xb8, 0x38, 0x57, 0x1a, 0xab, 0x61,
0x75, 0xb2, 0x5a, 0x7e, 0xf3, 0xe0, 0xb0, 0xf4, 0xe6, 0x49, 0xfc, 0x56, 0x40, 0x05, 0xfc, 0x0c,
0x5c, 0x99, 0x8b, 0x78, 0xdb, 0xba, 0x85, 0xaa, 0x1d, 0x33, 0x9b, 0xcc, 0x5f, 0x3e, 0x38, 0x2c,
0xbd, 0x73, 0x12, 0xf7, 0x36, 0xed, 0x86, 0x58, 0x90, 0xb9, 0xe9, 0x6f, 0x99, 0x0d, 0xb3, 0x6d,
0xb5, 0xb3, 0xa9, 0xf9, 0xe8, 0x6f, 0x91, 0x80, 0x70, 0xca, 0xf3, 0xe9, 0xa8, 0x59, 0xb5, 0xad,
0xc7, 0x7f, 0x14, 0x12, 0x8f, 0x8e, 0x0a, 0xda, 0xe3, 0xa3, 0x82, 0xf6, 0xe4, 0xa8, 0xa0, 0xfd,
0x7e, 0x54, 0xd0, 0xbe, 0x7a, 0x5a, 0x48, 0x3c, 0x79, 0x5a, 0x48, 0xfc, 0xf6, 0xb4, 0x90, 0xf8,
0xf4, 0xed, 0xd8, 0x1c, 0x18, 0x8c, 0xf7, 0xee, 0x4c, 0x3f, 0xca, 0xbc, 0xca, 0x50, 0x7d, 0x9c,
0xc9, 0x8f, 0x32, 0x67, 0x51, 0xbe, 0x72, 0xef, 0xfd, 0x13, 0x00, 0x00, 0xff, 0xff, 0xf0, 0xea,
0x50, 0x19, 0xba, 0x09, 0x00, 0x00,
}
func (this *AccessTypeParam) Equal(that interface{}) bool {
@ -679,6 +688,9 @@ func (this *ContractInfo) Equal(that interface{}) bool {
if this.IBCPortID != that1.IBCPortID {
return false
}
if !this.Extension.Equal(that1.Extension) {
return false
}
return true
}
func (this *ContractCodeHistoryEntry) Equal(that interface{}) bool {
@ -955,6 +967,18 @@ func (m *ContractInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if m.Extension != nil {
{
size, err := m.Extension.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintTypes(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x3a
}
if len(m.IBCPortID) > 0 {
i -= len(m.IBCPortID)
copy(dAtA[i:], m.IBCPortID)
@ -1237,6 +1261,10 @@ func (m *ContractInfo) Size() (n int) {
if l > 0 {
n += 1 + l + sovTypes(uint64(l))
}
if m.Extension != nil {
l = m.Extension.Size()
n += 1 + l + sovTypes(uint64(l))
}
return n
}
@ -2017,6 +2045,42 @@ func (m *ContractInfo) Unmarshal(dAtA []byte) error {
}
m.IBCPortID = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 7:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Extension", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTypes
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthTypes
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthTypes
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Extension == nil {
m.Extension = &types.Any{}
}
if err := m.Extension.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipTypes(dAtA[iNdEx:])

View File

@ -1,10 +1,17 @@
package types
import (
"github.com/cosmos/cosmos-sdk/codec"
"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"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/rand"
"strings"
"testing"
"github.com/stretchr/testify/require"
"time"
)
func TestContractInfoValidateBasic(t *testing.T) {
@ -41,6 +48,23 @@ func TestContractInfoValidateBasic(t *testing.T) {
srcMutator: func(c *ContractInfo) { c.Label = strings.Repeat("a", MaxLabelSize+1) },
expError: true,
},
"invalid extension": {
srcMutator: func(c *ContractInfo) {
// any protobuf type with ValidateBasic method
any, err := codectypes.NewAnyWithValue(&govtypes.TextProposal{})
require.NoError(t, err)
c.Extension = any
},
expError: true,
},
"not validatable extension": {
srcMutator: func(c *ContractInfo) {
// any protobuf type with ValidateBasic method
any, err := codectypes.NewAnyWithValue(&govtypes.Proposal{})
require.NoError(t, err)
c.Extension = any
},
},
}
for msg, spec := range specs {
t.Run(msg, func(t *testing.T) {
@ -117,3 +141,170 @@ func TestCodeInfoValidateBasic(t *testing.T) {
})
}
}
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)
require.NoError(t, err)
myExtension.TotalDeposit = nil
return &myExtension
}
specs := map[string]struct {
src ContractInfoExtension
expErr bool
expNil bool
}{
"all good with any proto extension": {
src: aNestedProtobufExt(),
},
"nil allowed": {
src: nil,
expNil: true,
},
"validated and accepted": {
src: &govtypes.TextProposal{Title: "bar", Description: "set"},
},
"validated and rejected": {
src: &govtypes.TextProposal{Title: "bar"},
expErr: true,
},
}
for name, spec := range specs {
t.Run(name, func(t *testing.T) {
var c ContractInfo
gotErr := c.SetExtension(spec.src)
if spec.expErr {
require.Error(t, gotErr)
return
}
require.NoError(t, gotErr)
if spec.expNil {
return
}
require.NotNil(t, c.Extension)
assert.NotNil(t, c.Extension.GetCachedValue())
})
}
}
func TestContractInfoMarshalUnmarshal(t *testing.T) {
var myAddr sdk.AccAddress = rand.Bytes(sdk.AddrLen)
var myOtherAddr sdk.AccAddress = rand.Bytes(sdk.AddrLen)
var anyPos = AbsoluteTxPosition{BlockHeight: 1, TxIndex: 2}
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)
require.NoError(t, err)
myExtension.TotalDeposit = nil
src := NewContractInfo(1, myAddr, myOtherAddr, "bar", &anyPos)
err = src.SetExtension(&myExtension)
require.NoError(t, err)
interfaceRegistry := types.NewInterfaceRegistry()
marshaler := codec.NewProtoCodec(interfaceRegistry)
RegisterInterfaces(interfaceRegistry)
// register proposal as extension type
interfaceRegistry.RegisterImplementations(
(*ContractInfoExtension)(nil),
&govtypes.Proposal{},
)
// register gov types for nested Anys
govtypes.RegisterInterfaces(interfaceRegistry)
// when encode
bz, err := marshaler.MarshalBinaryBare(&src)
require.NoError(t, err)
// and decode
var dest ContractInfo
err = marshaler.UnmarshalBinaryBare(bz, &dest)
// then
require.NoError(t, err)
assert.Equal(t, src, dest)
// and sanity check nested any
var destExt govtypes.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)
require.NoError(t, err)
type TestExtensionAsStruct struct {
ContractInfoExtension
}
specs := map[string]struct {
setup func(*ContractInfo)
param func() ContractInfoExtension
expVal ContractInfoExtension
expErr bool
}{
"all good": {
setup: func(i *ContractInfo) {
i.SetExtension(&myExtension)
},
param: func() ContractInfoExtension {
return &govtypes.Proposal{}
},
expVal: &myExtension,
},
"no extension set": {
setup: func(i *ContractInfo) {
},
param: func() ContractInfoExtension {
return &govtypes.Proposal{}
},
expVal: &govtypes.Proposal{},
},
"nil argument value": {
setup: func(i *ContractInfo) {
i.SetExtension(&myExtension)
},
param: func() ContractInfoExtension {
return nil
},
expErr: true,
},
"non matching types": {
setup: func(i *ContractInfo) {
i.SetExtension(&myExtension)
},
param: func() ContractInfoExtension {
return &govtypes.TextProposal{}
},
expErr: true,
},
"not a pointer argument": {
setup: func(i *ContractInfo) {
},
param: func() ContractInfoExtension {
return TestExtensionAsStruct{}
},
expErr: true,
},
}
for name, spec := range specs {
t.Run(name, func(t *testing.T) {
var c ContractInfo
spec.setup(&c)
// when
gotValue := spec.param()
gotErr := c.ReadExtension(gotValue)
// then
if spec.expErr {
require.Error(t, gotErr)
return
}
require.NoError(t, gotErr)
assert.Equal(t, spec.expVal, gotValue)
})
}
}