From 4eaed376cec3475607f80b93e70da48f9e2ad6f9 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Tue, 21 May 2024 10:10:41 -0400 Subject: [PATCH] Fix usage of deprecated wasm. --- internal/provwasm/message_encoders.go | 8 ++++---- internal/provwasm/query_plugins.go | 11 ++++++----- internal/provwasm/stargate_whitelist.go | 8 ++++---- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/internal/provwasm/message_encoders.go b/internal/provwasm/message_encoders.go index ddcc4214f5..7c8e3dc355 100644 --- a/internal/provwasm/message_encoders.go +++ b/internal/provwasm/message_encoders.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/CosmWasm/wasmd/x/wasm" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" "cosmossdk.io/log" @@ -40,14 +40,14 @@ func (qr *EncoderRegistry) RegisterEncoder(route string, encoder Encoder) { } // MessageEncoders provides provenance message encoding support for smart contracts. -func MessageEncoders(registry *EncoderRegistry, logger log.Logger) *wasm.MessageEncoders { - return &wasm.MessageEncoders{ +func MessageEncoders(registry *EncoderRegistry, logger log.Logger) *wasmkeeper.MessageEncoders { + return &wasmkeeper.MessageEncoders{ Custom: customEncoders(registry, logger), } } // Custom provenance encoders for CosmWasm integration. -func customEncoders(registry *EncoderRegistry, logger log.Logger) wasm.CustomEncoder { +func customEncoders(registry *EncoderRegistry, logger log.Logger) wasmkeeper.CustomEncoder { return func(contract sdk.AccAddress, msg json.RawMessage) ([]sdk.Msg, error) { req := EncodeRequest{} if err := json.Unmarshal(msg, &req); err != nil { diff --git a/internal/provwasm/query_plugins.go b/internal/provwasm/query_plugins.go index c182bb5bee..6a3129b7e0 100644 --- a/internal/provwasm/query_plugins.go +++ b/internal/provwasm/query_plugins.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/CosmWasm/wasmd/x/wasm" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmvmtypes "github.com/CosmWasm/wasmvm/types" abci "github.com/cometbft/cometbft/abci/types" @@ -14,6 +14,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/gogoproto/proto" ) // The maximum querier result size allowed, ~10MB. @@ -43,15 +44,15 @@ func (qr *QuerierRegistry) RegisterQuerier(route string, querier Querier) { } // QueryPlugins provides provenance query support for smart contracts. -func QueryPlugins(registry *QuerierRegistry, queryRouter baseapp.GRPCQueryRouter, codec codec.Codec) *wasm.QueryPlugins { - return &wasm.QueryPlugins{ +func QueryPlugins(registry *QuerierRegistry, queryRouter baseapp.GRPCQueryRouter, codec codec.Codec) *wasmkeeper.QueryPlugins { + return &wasmkeeper.QueryPlugins{ Custom: customPlugins(registry), Stargate: StargateQuerier(queryRouter, codec), } } // Custom provenance queriers for CosmWasm integration. -func customPlugins(registry *QuerierRegistry) wasm.CustomQuerier { +func customPlugins(registry *QuerierRegistry) wasmkeeper.CustomQuerier { return func(ctx sdk.Context, request json.RawMessage) ([]byte, error) { req := QueryRequest{} if err := json.Unmarshal(request, &req); err != nil { @@ -114,7 +115,7 @@ func StargateQuerier(queryRouter baseapp.GRPCQueryRouter, cdc codec.Codec) func( // ConvertProtoToJsonMarshal unmarshals the given bytes into a proto message and then marshals it to json. // This is done so that clients calling stargate queries do not need to define their own proto unmarshalers, // being able to use response directly by json marshaling, which is supported in cosmwasm. -func ConvertProtoToJSONMarshal(protoResponseType codec.ProtoMarshaler, bz []byte, cdc codec.Codec) ([]byte, error) { +func ConvertProtoToJSONMarshal(protoResponseType proto.Message, bz []byte, cdc codec.Codec) ([]byte, error) { // unmarshal binary into stargate response data structure err := cdc.Unmarshal(bz, protoResponseType) if err != nil { diff --git a/internal/provwasm/stargate_whitelist.go b/internal/provwasm/stargate_whitelist.go index a6ba4cd870..5c294bc6d4 100644 --- a/internal/provwasm/stargate_whitelist.go +++ b/internal/provwasm/stargate_whitelist.go @@ -6,13 +6,13 @@ import ( wasmvmtypes "github.com/CosmWasm/wasmvm/types" - "github.com/cosmos/cosmos-sdk/codec" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/cosmos/gogoproto/proto" ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" attributetypes "github.com/provenance-io/provenance/x/attribute/types" @@ -141,19 +141,19 @@ func init() { // GetWhitelistedQuery returns the whitelisted query at the provided path. // If the query does not exist, or it was setup wrong by the chain, this returns an error. -func GetWhitelistedQuery(queryPath string) (codec.ProtoMarshaler, error) { +func GetWhitelistedQuery(queryPath string) (proto.Message, error) { protoResponseAny, isWhitelisted := stargateWhitelist.Load(queryPath) if !isWhitelisted { return nil, wasmvmtypes.UnsupportedRequest{Kind: fmt.Sprintf("'%s' path is not allowed from the contract", queryPath)} } - protoResponseType, ok := protoResponseAny.(codec.ProtoMarshaler) + protoResponseType, ok := protoResponseAny.(proto.Message) if !ok { return nil, wasmvmtypes.Unknown{} } return protoResponseType, nil } -func setWhitelistedQuery(queryPath string, protoType codec.ProtoMarshaler) { +func setWhitelistedQuery(queryPath string, protoType proto.Message) { stargateWhitelist.Store(queryPath, protoType) }