diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index cbd5b6742c6..9479f8874e2 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -33,6 +33,9 @@ import ( "github.com/cosmos/cosmos-sdk/x/upgrade" upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + icq "github.com/strangelove-ventures/async-icq/v4" + icqtypes "github.com/strangelove-ventures/async-icq/v4/types" + downtimedetector "github.com/osmosis-labs/osmosis/v14/x/downtime-detector" downtimetypes "github.com/osmosis-labs/osmosis/v14/x/downtime-detector/types" "github.com/osmosis-labs/osmosis/v14/x/gamm" @@ -44,8 +47,6 @@ import ( ibchooks "github.com/osmosis-labs/osmosis/x/ibc-hooks" ibchookskeeper "github.com/osmosis-labs/osmosis/x/ibc-hooks/keeper" ibchookstypes "github.com/osmosis-labs/osmosis/x/ibc-hooks/types" - icq "github.com/strangelove-ventures/async-icq/v4" - icqtypes "github.com/strangelove-ventures/async-icq/v4/types" icahost "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host" icahostkeeper "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/keeper" @@ -643,6 +644,12 @@ func (appKeepers *AppKeepers) SetupHooks() { // e.g. *app.StakingKeeper doesn't appear // Recall that SetHooks is a mutative call. + appKeepers.BankKeeper.SetHooks( + banktypes.NewMultiBankHooks( + appKeepers.TokenFactoryKeeper.Hooks(*appKeepers.WasmKeeper), + ), + ) + appKeepers.StakingKeeper.SetHooks( stakingtypes.NewMultiStakingHooks( appKeepers.DistrKeeper.Hooks(), diff --git a/proto/osmosis/tokenfactory/v1beta1/query.proto b/proto/osmosis/tokenfactory/v1beta1/query.proto index d10121ae44d..5f453b44719 100644 --- a/proto/osmosis/tokenfactory/v1beta1/query.proto +++ b/proto/osmosis/tokenfactory/v1beta1/query.proto @@ -32,6 +32,14 @@ service Query { option (google.api.http).get = "/osmosis/tokenfactory/v1beta1/denoms_from_creator/{creator}"; } + + // BeforeSendHookAddress defines a gRPC query method for + // getting the address registered for the before send hook. + rpc BeforeSendHookAddress(QueryBeforeSendHookAddressRequest) + returns (QueryBeforeSendHookAddressResponse) { + option (google.api.http).get = + "/osmosis/tokenfactory/v1beta1/denoms/{denom}/before_send_hook"; + } } // QueryParamsRequest is the request type for the Query/Params RPC method. @@ -69,3 +77,14 @@ message QueryDenomsFromCreatorRequest { message QueryDenomsFromCreatorResponse { repeated string denoms = 1 [ (gogoproto.moretags) = "yaml:\"denoms\"" ]; } + +message QueryBeforeSendHookAddressRequest { + string denom = 1 [ (gogoproto.moretags) = "yaml:\"denom\"" ]; +} + +// QueryBeforeSendHookAddressResponse defines the response structure for the +// DenomBeforeSendHook gRPC query. +message QueryBeforeSendHookAddressResponse { + string cosmwasm_address = 1 + [ (gogoproto.moretags) = "yaml:\"cosmwasm_address\"" ]; +} \ No newline at end of file diff --git a/proto/osmosis/tokenfactory/v1beta1/tx.proto b/proto/osmosis/tokenfactory/v1beta1/tx.proto index 472fa4434bd..36e75aa103b 100644 --- a/proto/osmosis/tokenfactory/v1beta1/tx.proto +++ b/proto/osmosis/tokenfactory/v1beta1/tx.proto @@ -15,7 +15,8 @@ service Msg { rpc ChangeAdmin(MsgChangeAdmin) returns (MsgChangeAdminResponse); rpc SetDenomMetadata(MsgSetDenomMetadata) returns (MsgSetDenomMetadataResponse); - + rpc SetBeforeSendHook(MsgSetBeforeSendHook) + returns (MsgSetBeforeSendHookResponse); // ForceTransfer is deactivated for now because we need to think through edge // cases rpc ForceTransfer(MsgForceTransfer) returns // (MsgForceTransferResponse); @@ -79,19 +80,18 @@ message MsgChangeAdmin { // MsgChangeAdmin message. message MsgChangeAdminResponse {} -// message MsgForceTransfer { -// string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; -// cosmos.base.v1beta1.Coin amount = 2 [ -// (gogoproto.moretags) = "yaml:\"amount\"", -// (gogoproto.nullable) = false -// ]; -// string transferFromAddress = 3 -// [ (gogoproto.moretags) = "yaml:\"transfer_from_address\"" ]; -// string transferToAddress = 4 -// [ (gogoproto.moretags) = "yaml:\"transfer_to_address\"" ]; -// } +// MsgSetBeforeSendHook is the sdk.Msg type for allowing an admin account to +// assign a CosmWasm contract to call with a BeforeSend hook +message MsgSetBeforeSendHook { + string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; + string denom = 2 [ (gogoproto.moretags) = "yaml:\"denom\"" ]; + string cosmwasm_address = 3 + [ (gogoproto.moretags) = "yaml:\"cosmwasm_address\"" ]; +} -// message MsgForceTransferResponse {} +// MsgSetBeforeSendHookResponse defines the response structure for an executed +// MsgSetBeforeSendHook message. +message MsgSetBeforeSendHookResponse {} // MsgSetDenomMetadata is the sdk.Msg type for allowing an admin account to set // the denom's bank metadata @@ -105,4 +105,4 @@ message MsgSetDenomMetadata { // MsgSetDenomMetadataResponse defines the response structure for an executed // MsgSetDenomMetadata message. -message MsgSetDenomMetadataResponse {} \ No newline at end of file +message MsgSetDenomMetadataResponse {} diff --git a/x/tokenfactory/client/cli/query.go b/x/tokenfactory/client/cli/query.go index 31281564849..20046a425e8 100644 --- a/x/tokenfactory/client/cli/query.go +++ b/x/tokenfactory/client/cli/query.go @@ -4,6 +4,8 @@ import ( // "strings" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/spf13/cobra" // "github.com/cosmos/cosmos-sdk/client/flags" @@ -45,3 +47,32 @@ func GetCmdDenomsFromCreator() (*osmocli.QueryDescriptor, *types.QueryDenomsFrom {{.CommandPrefix}}
`, }, &types.QueryDenomsFromCreatorRequest{} } + +// GetCmdDenomAuthorityMetadata returns the authority metadata for a queried denom +func GetCmdDenomBeforeSendHook() *cobra.Command { + cmd := &cobra.Command{ + Use: "denom-before-send-hook [denom] [flags]", + Short: "Get the BeforeSend hook for a specific denom", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.BeforeSendHookAddress(cmd.Context(), &types.QueryBeforeSendHookAddressRequest{ + Denom: args[0], + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/tokenfactory/client/cli/tx.go b/x/tokenfactory/client/cli/tx.go index 169a02d20a1..b88f689748a 100644 --- a/x/tokenfactory/client/cli/tx.go +++ b/x/tokenfactory/client/cli/tx.go @@ -1,6 +1,9 @@ package cli import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" "github.com/spf13/cobra" // "github.com/cosmos/cosmos-sdk/client/flags" @@ -17,6 +20,7 @@ func GetTxCmd() *cobra.Command { NewBurnCmd(), // NewForceTransferCmd(), NewChangeAdminCmd(), + NewSetBeforeSendHookCmd(), ) return cmd @@ -49,3 +53,31 @@ func NewChangeAdminCmd() *cobra.Command { Short: "Changes the admin address for a factory-created denom. Must have admin authority to do so.", }) } + +// NewChangeAdminCmd broadcast MsgChangeAdmin +func NewSetBeforeSendHookCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "set-beforesend-hook [denom] [cosmwasm-address] [flags]", + Short: "Set a cosmwasm contract to be the beforesend hook for a factory-created denom. Must have admin authority to do so.", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) + + msg := types.NewMsgSetBeforeSendHook( + clientCtx.GetFromAddress().String(), + args[0], + args[1], + ) + + return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} diff --git a/x/tokenfactory/keeper/before_send.go b/x/tokenfactory/keeper/before_send.go new file mode 100644 index 00000000000..bb957dbdcd7 --- /dev/null +++ b/x/tokenfactory/keeper/before_send.go @@ -0,0 +1,115 @@ +package keeper + +import ( + "encoding/json" + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/v14/x/tokenfactory/types" + + wasmKeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + wasmvmtypes "github.com/CosmWasm/wasmvm/types" +) + +func (k Keeper) setBeforeSendHook(ctx sdk.Context, denom string, cosmwasmAddress string) error { + // verify that denom is an x/tokenfactory denom + _, _, err := types.DeconstructDenom(denom) + if err != nil { + return err + } + + store := k.GetDenomPrefixStore(ctx, denom) + + // delete the store for denom prefix store when cosmwasm address is nil + if cosmwasmAddress == "" { + store.Delete([]byte(types.BeforeSendHookAddressPrefixKey)) + return nil + } + + _, err = sdk.AccAddressFromBech32(cosmwasmAddress) + if err != nil { + return err + } + + store.Set([]byte(types.BeforeSendHookAddressPrefixKey), []byte(cosmwasmAddress)) + + return nil +} + +func (k Keeper) GetBeforeSendHook(ctx sdk.Context, denom string) string { + store := k.GetDenomPrefixStore(ctx, denom) + + bz := store.Get([]byte(types.BeforeSendHookAddressPrefixKey)) + if bz == nil { + return "" + } + + return string(bz) +} + +func CWCoinsFromSDKCoins(in sdk.Coins) wasmvmtypes.Coins { + var cwCoins wasmvmtypes.Coins + for _, coin := range in { + cwCoins = append(cwCoins, CWCoinFromSDKCoin(coin)) + } + return cwCoins +} + +func CWCoinFromSDKCoin(in sdk.Coin) wasmvmtypes.Coin { + return wasmvmtypes.Coin{ + Denom: in.GetDenom(), + Amount: in.Amount.String(), + } +} + +// Hooks wrapper struct for bank keeper +type Hooks struct { + k Keeper + wasmkeeper wasmKeeper.Keeper +} + +var _ types.BankHooks = Hooks{} + +// Return the wrapper struct +func (k Keeper) Hooks(wasmkeeper wasmKeeper.Keeper) Hooks { + return Hooks{k, wasmkeeper} +} + +// implements BeforeSend hook in the Bank module. +// Calls the stored before send hook for the denom specificed. +func (h Hooks) BeforeSend(ctx sdk.Context, from, to sdk.AccAddress, amount sdk.Coins) error { + cwCoins := CWCoinsFromSDKCoins(amount) + + for _, coin := range amount { + cosmwasmAddress := h.k.GetBeforeSendHook(ctx, coin.Denom) + if cosmwasmAddress != "" { + cwAddr, err := sdk.AccAddressFromBech32(cosmwasmAddress) + if err != nil { + return err + } + + msg := types.SudoMsg{ + BeforeSend: types.BeforeSendMsg{ + From: from.String(), + To: to.String(), + Amount: cwCoins, + }, + } + + msgBz, err := json.Marshal(msg) + if err != nil { + return err + } + + em := sdk.NewEventManager() + + _, err = h.wasmkeeper.Sudo(ctx.WithEventManager(em), cwAddr, msgBz) + fmt.Println(err) + if err != nil { + return err + } + } + } + return nil +} diff --git a/x/tokenfactory/keeper/before_send_test.go b/x/tokenfactory/keeper/before_send_test.go new file mode 100644 index 00000000000..55570a48663 --- /dev/null +++ b/x/tokenfactory/keeper/before_send_test.go @@ -0,0 +1,100 @@ +package keeper_test + +import ( + "fmt" + "io/ioutil" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/v14/x/tokenfactory/types" + + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" +) + +type SendMsgTestCase struct { + desc string + msg func(denom string) *banktypes.MsgSend + expectPass bool +} + +func (suite *KeeperTestSuite) TestBeforeSendHook() { + for _, tc := range []struct { + desc string + wasmFile string + sendMsgs []SendMsgTestCase + }{ + { + desc: "should not allow sending 100 amount of *any* denom", + wasmFile: "./testdata/no100.wasm", + sendMsgs: []SendMsgTestCase{ + { + desc: "sending 100 of factorydenom should not work", + msg: func(factorydenom string) *banktypes.MsgSend { + return banktypes.NewMsgSend( + suite.TestAccs[0], + suite.TestAccs[1], + sdk.NewCoins(sdk.NewInt64Coin(factorydenom, 1)), + ) + }, + expectPass: true, + }, + { + desc: "sending 100 of factorydenom should not work", + msg: func(factorydenom string) *banktypes.MsgSend { + return banktypes.NewMsgSend( + suite.TestAccs[0], + suite.TestAccs[1], + sdk.NewCoins(sdk.NewInt64Coin(factorydenom, 100)), + ) + }, + expectPass: false, + }, + { + desc: "sending 100 of a non-factorydenom should not work", + msg: func(factorydenom string) *banktypes.MsgSend { + return banktypes.NewMsgSend( + suite.TestAccs[0], + suite.TestAccs[1], + sdk.NewCoins(sdk.NewInt64Coin(factorydenom, 1), sdk.NewInt64Coin("uosmo", 100)), + ) + }, + expectPass: false, + }, + }, + }, + } { + suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { + // setup test + suite.SetupTest() + + // upload and instantiate wasm code + wasmCode, err := ioutil.ReadFile(tc.wasmFile) + suite.Require().NoError(err, "test: %v", tc.desc) + codeID, _, err := suite.contractKeeper.Create(suite.Ctx, suite.TestAccs[0], wasmCode, nil) + suite.Require().NoError(err, "test: %v", tc.desc) + cosmwasmAddress, _, err := suite.contractKeeper.Instantiate(suite.Ctx, codeID, suite.TestAccs[0], suite.TestAccs[0], []byte("{}"), "", sdk.NewCoins()) + suite.Require().NoError(err, "test: %v", tc.desc) + + // create new denom + res, err := suite.msgServer.CreateDenom(sdk.WrapSDKContext(suite.Ctx), types.NewMsgCreateDenom(suite.TestAccs[0].String(), "bitcoin")) + suite.Require().NoError(err, "test: %v", tc.desc) + denom := res.GetNewTokenDenom() + + // mint enough coins to the creator + suite.msgServer.Mint(sdk.WrapSDKContext(suite.Ctx), types.NewMsgMint(suite.TestAccs[0].String(), sdk.NewInt64Coin(denom, 1000000000))) + + // set beforesend hook to the new denom + _, err = suite.msgServer.SetBeforeSendHook(sdk.WrapSDKContext(suite.Ctx), types.NewMsgSetBeforeSendHook(suite.TestAccs[0].String(), denom, cosmwasmAddress.String())) + suite.Require().NoError(err, "test: %v", tc.desc) + + for _, sendTc := range tc.sendMsgs { + _, err := suite.bankMsgServer.Send(sdk.WrapSDKContext(suite.Ctx), sendTc.msg(denom)) + if sendTc.expectPass { + suite.Require().NoError(err, "test: %v", sendTc.desc) + } else { + suite.Require().Error(err, "test: %v", sendTc.desc) + } + } + }) + } +} diff --git a/x/tokenfactory/keeper/grpc_query.go b/x/tokenfactory/keeper/grpc_query.go index 544f32335c6..9d2c190e454 100644 --- a/x/tokenfactory/keeper/grpc_query.go +++ b/x/tokenfactory/keeper/grpc_query.go @@ -33,3 +33,11 @@ func (k Keeper) DenomsFromCreator(ctx context.Context, req *types.QueryDenomsFro denoms := k.getDenomsFromCreator(sdkCtx, req.GetCreator()) return &types.QueryDenomsFromCreatorResponse{Denoms: denoms}, nil } + +func (k Keeper) BeforeSendHookAddress(ctx context.Context, req *types.QueryBeforeSendHookAddressRequest) (*types.QueryBeforeSendHookAddressResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + + cosmwasmAddress := k.GetBeforeSendHook(sdkCtx, req.GetDenom()) + + return &types.QueryBeforeSendHookAddressResponse{CosmwasmAddress: cosmwasmAddress}, nil +} diff --git a/x/tokenfactory/keeper/keeper_test.go b/x/tokenfactory/keeper/keeper_test.go index 20c6a2e7127..cc02fd98997 100644 --- a/x/tokenfactory/keeper/keeper_test.go +++ b/x/tokenfactory/keeper/keeper_test.go @@ -7,6 +7,12 @@ import ( "github.com/stretchr/testify/suite" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/osmosis-labs/osmosis/v14/app/apptesting" "github.com/osmosis-labs/osmosis/v14/x/tokenfactory/keeper" "github.com/osmosis-labs/osmosis/v14/x/tokenfactory/types" @@ -15,8 +21,11 @@ import ( type KeeperTestSuite struct { apptesting.KeeperTestHelper - queryClient types.QueryClient - msgServer types.MsgServer + queryClient types.QueryClient + msgServer types.MsgServer + contractKeeper wasmtypes.ContractOpsKeeper + bankMsgServer banktypes.MsgServer + // defaultDenom is on the suite, as it depends on the creator test address. defaultDenom string } @@ -25,6 +34,24 @@ func TestKeeperTestSuite(t *testing.T) { suite.Run(t, new(KeeperTestSuite)) } +type SudoAuthorizationPolicy struct{} + +func (p SudoAuthorizationPolicy) CanCreateCode(chainAccesscoConfig wasmkeeper.ChainAccessConfigs, actor sdk.AccAddress, config wasmtypes.AccessConfig) bool { + return true +} + +func (p SudoAuthorizationPolicy) CanInstantiateContract(config wasmtypes.AccessConfig, actor sdk.AccAddress) bool { + return true +} + +func (p SudoAuthorizationPolicy) CanModifyContract(admin, actor sdk.AccAddress) bool { + return true +} + +func (p SudoAuthorizationPolicy) CanModifyCodeAccessConfig(creator, actor sdk.AccAddress, isSubset bool) bool { + return true +} + func (suite *KeeperTestSuite) SetupTest() { suite.Setup() // Fund every TestAcc with two denoms, one of which is the denom creation fee @@ -32,9 +59,10 @@ func (suite *KeeperTestSuite) SetupTest() { for _, acc := range suite.TestAccs { suite.FundAcc(acc, fundAccsAmount) } - + suite.contractKeeper = wasmkeeper.NewGovPermissionKeeper(suite.App.WasmKeeper) suite.queryClient = types.NewQueryClient(suite.QueryHelper) suite.msgServer = keeper.NewMsgServerImpl(*suite.App.TokenFactoryKeeper) + suite.bankMsgServer = bankkeeper.NewMsgServerImpl(suite.App.BankKeeper) } func (suite *KeeperTestSuite) CreateDefaultDenom() { diff --git a/x/tokenfactory/keeper/msg_server.go b/x/tokenfactory/keeper/msg_server.go index 55af0af6df1..27884ff3abd 100644 --- a/x/tokenfactory/keeper/msg_server.go +++ b/x/tokenfactory/keeper/msg_server.go @@ -189,3 +189,31 @@ func (server msgServer) SetDenomMetadata(goCtx context.Context, msg *types.MsgSe return &types.MsgSetDenomMetadataResponse{}, nil } + +func (server msgServer) SetBeforeSendHook(goCtx context.Context, msg *types.MsgSetBeforeSendHook) (*types.MsgSetBeforeSendHookResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + authorityMetadata, err := server.Keeper.GetAuthorityMetadata(ctx, msg.Denom) + if err != nil { + return nil, err + } + + if msg.Sender != authorityMetadata.GetAdmin() { + return nil, types.ErrUnauthorized + } + + err = server.Keeper.setBeforeSendHook(ctx, msg.Denom, msg.CosmwasmAddress) + if err != nil { + return nil, err + } + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.TypeMsgSetBeforeSendHook, + sdk.NewAttribute(types.AttributeDenom, msg.GetDenom()), + sdk.NewAttribute(types.AttributeBeforeSendHookAddress, msg.GetCosmwasmAddress()), + ), + }) + + return &types.MsgSetBeforeSendHookResponse{}, nil +} diff --git a/x/tokenfactory/keeper/testdata/no100.wasm b/x/tokenfactory/keeper/testdata/no100.wasm new file mode 100644 index 00000000000..b72f0dfddba Binary files /dev/null and b/x/tokenfactory/keeper/testdata/no100.wasm differ diff --git a/x/tokenfactory/types/beforeSend.go b/x/tokenfactory/types/beforeSend.go new file mode 100644 index 00000000000..149713c9866 --- /dev/null +++ b/x/tokenfactory/types/beforeSend.go @@ -0,0 +1,15 @@ +package types + +import ( + wasmvmtypes "github.com/CosmWasm/wasmvm/types" +) + +type SudoMsg struct { + BeforeSend BeforeSendMsg `json:"before_send"` +} + +type BeforeSendMsg struct { + From string `json:"from"` + To string `json:"to"` + Amount wasmvmtypes.Coins `json:"amount"` +} diff --git a/x/tokenfactory/types/codec.go b/x/tokenfactory/types/codec.go index b086a51e17f..07eab220f32 100644 --- a/x/tokenfactory/types/codec.go +++ b/x/tokenfactory/types/codec.go @@ -16,6 +16,7 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgBurn{}, "osmosis/tokenfactory/burn", nil) // cdc.RegisterConcrete(&MsgForceTransfer{}, "osmosis/tokenfactory/force-transfer", nil) cdc.RegisterConcrete(&MsgChangeAdmin{}, "osmosis/tokenfactory/change-admin", nil) + cdc.RegisterConcrete(&MsgSetBeforeSendHook{}, "osmosis/tokenfactory/set-beforesend-hook", nil) } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { @@ -26,6 +27,7 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { &MsgBurn{}, // &MsgForceTransfer{}, &MsgChangeAdmin{}, + &MsgSetBeforeSendHook{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/x/tokenfactory/types/events.go b/x/tokenfactory/types/events.go index 94196fd034d..0ccec062fda 100644 --- a/x/tokenfactory/types/events.go +++ b/x/tokenfactory/types/events.go @@ -2,15 +2,16 @@ package types // event types const ( - AttributeAmount = "amount" - AttributeCreator = "creator" - AttributeSubdenom = "subdenom" - AttributeNewTokenDenom = "new_token_denom" - AttributeMintToAddress = "mint_to_address" - AttributeBurnFromAddress = "burn_from_address" - AttributeTransferFromAddress = "transfer_from_address" - AttributeTransferToAddress = "transfer_to_address" - AttributeDenom = "denom" - AttributeNewAdmin = "new_admin" - AttributeDenomMetadata = "denom_metadata" + AttributeAmount = "amount" + AttributeCreator = "creator" + AttributeSubdenom = "subdenom" + AttributeNewTokenDenom = "new_token_denom" + AttributeMintToAddress = "mint_to_address" + AttributeBurnFromAddress = "burn_from_address" + AttributeTransferFromAddress = "transfer_from_address" + AttributeTransferToAddress = "transfer_to_address" + AttributeDenom = "denom" + AttributeNewAdmin = "new_admin" + AttributeDenomMetadata = "denom_metadata" + AttributeBeforeSendHookAddress = "before_send_hook_address" ) diff --git a/x/tokenfactory/types/expected_keepers.go b/x/tokenfactory/types/expected_keepers.go index 4dfa4edc765..ff064367210 100644 --- a/x/tokenfactory/types/expected_keepers.go +++ b/x/tokenfactory/types/expected_keepers.go @@ -26,6 +26,11 @@ type AccountKeeper interface { SetModuleAccount(ctx sdk.Context, macc authtypes.ModuleAccountI) } +// BankHooks event hooks +type BankHooks interface { + BeforeSend(ctx sdk.Context, from, to sdk.AccAddress, amount sdk.Coins) error // Must be called when a bank transfer happens +} + // CommunityPoolKeeper defines the contract needed to be fulfilled for community pool interactions. type CommunityPoolKeeper interface { FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error diff --git a/x/tokenfactory/types/keys.go b/x/tokenfactory/types/keys.go index fac4a6e39c4..dd2ed9fe475 100644 --- a/x/tokenfactory/types/keys.go +++ b/x/tokenfactory/types/keys.go @@ -25,10 +25,11 @@ const ( const KeySeparator = "|" var ( - DenomAuthorityMetadataKey = "authoritymetadata" - DenomsPrefixKey = "denoms" - CreatorPrefixKey = "creator" - AdminPrefixKey = "admin" + DenomAuthorityMetadataKey = "authoritymetadata" + DenomsPrefixKey = "denoms" + CreatorPrefixKey = "creator" + AdminPrefixKey = "admin" + BeforeSendHookAddressPrefixKey = "beforesendhook" ) // GetDenomPrefixStore returns the store prefix where all the data associated with a specific denom diff --git a/x/tokenfactory/types/msgs.go b/x/tokenfactory/types/msgs.go index 9c78328e13f..0443ef8638e 100644 --- a/x/tokenfactory/types/msgs.go +++ b/x/tokenfactory/types/msgs.go @@ -8,12 +8,13 @@ import ( // constants const ( - TypeMsgCreateDenom = "create_denom" - TypeMsgMint = "tf_mint" - TypeMsgBurn = "tf_burn" - TypeMsgForceTransfer = "force_transfer" - TypeMsgChangeAdmin = "change_admin" - TypeMsgSetDenomMetadata = "set_denom_metadata" + TypeMsgCreateDenom = "create_denom" + TypeMsgMint = "tf_mint" + TypeMsgBurn = "tf_burn" + TypeMsgForceTransfer = "force_transfer" + TypeMsgChangeAdmin = "change_admin" + TypeMsgSetDenomMetadata = "set_denom_metadata" + TypeMsgSetBeforeSendHook = "set_before_send_hook" ) var _ sdk.Msg = &MsgCreateDenom{} @@ -244,3 +245,46 @@ func (m MsgSetDenomMetadata) GetSigners() []sdk.AccAddress { sender, _ := sdk.AccAddressFromBech32(m.Sender) return []sdk.AccAddress{sender} } + +var _ sdk.Msg = &MsgSetBeforeSendHook{} + +// NewMsgSetBeforeSendHook creates a message to set a new before send hook +func NewMsgSetBeforeSendHook(sender string, denom string, cosmwasmAddress string) *MsgSetBeforeSendHook { + return &MsgSetBeforeSendHook{ + Sender: sender, + Denom: denom, + CosmwasmAddress: cosmwasmAddress, + } +} + +func (m MsgSetBeforeSendHook) Route() string { return RouterKey } +func (m MsgSetBeforeSendHook) Type() string { return TypeMsgBurn } +func (m MsgSetBeforeSendHook) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) + } + + if m.CosmwasmAddress != "" { + _, err = sdk.AccAddressFromBech32(m.CosmwasmAddress) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid cosmwasm contract address (%s)", err) + } + } + + _, _, err = DeconstructDenom(m.Denom) + if err != nil { + return ErrInvalidDenom + } + + return nil +} + +func (m MsgSetBeforeSendHook) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +func (m MsgSetBeforeSendHook) GetSigners() []sdk.AccAddress { + sender, _ := sdk.AccAddressFromBech32(m.Sender) + return []sdk.AccAddress{sender} +} diff --git a/x/tokenfactory/types/query.pb.go b/x/tokenfactory/types/query.pb.go index 941c5197f1c..ae49f17f0f1 100644 --- a/x/tokenfactory/types/query.pb.go +++ b/x/tokenfactory/types/query.pb.go @@ -297,6 +297,96 @@ func (m *QueryDenomsFromCreatorResponse) GetDenoms() []string { return nil } +type QueryBeforeSendHookAddressRequest struct { + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"` +} + +func (m *QueryBeforeSendHookAddressRequest) Reset() { *m = QueryBeforeSendHookAddressRequest{} } +func (m *QueryBeforeSendHookAddressRequest) String() string { return proto.CompactTextString(m) } +func (*QueryBeforeSendHookAddressRequest) ProtoMessage() {} +func (*QueryBeforeSendHookAddressRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_6f22013ad0f72e3f, []int{6} +} +func (m *QueryBeforeSendHookAddressRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryBeforeSendHookAddressRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryBeforeSendHookAddressRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryBeforeSendHookAddressRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBeforeSendHookAddressRequest.Merge(m, src) +} +func (m *QueryBeforeSendHookAddressRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryBeforeSendHookAddressRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBeforeSendHookAddressRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryBeforeSendHookAddressRequest proto.InternalMessageInfo + +func (m *QueryBeforeSendHookAddressRequest) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +// QueryBeforeSendHookAddressResponse defines the response structure for the +// DenomBeforeSendHook gRPC query. +type QueryBeforeSendHookAddressResponse struct { + CosmwasmAddress string `protobuf:"bytes,1,opt,name=cosmwasm_address,json=cosmwasmAddress,proto3" json:"cosmwasm_address,omitempty" yaml:"cosmwasm_address"` +} + +func (m *QueryBeforeSendHookAddressResponse) Reset() { *m = QueryBeforeSendHookAddressResponse{} } +func (m *QueryBeforeSendHookAddressResponse) String() string { return proto.CompactTextString(m) } +func (*QueryBeforeSendHookAddressResponse) ProtoMessage() {} +func (*QueryBeforeSendHookAddressResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_6f22013ad0f72e3f, []int{7} +} +func (m *QueryBeforeSendHookAddressResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryBeforeSendHookAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryBeforeSendHookAddressResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryBeforeSendHookAddressResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBeforeSendHookAddressResponse.Merge(m, src) +} +func (m *QueryBeforeSendHookAddressResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryBeforeSendHookAddressResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBeforeSendHookAddressResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryBeforeSendHookAddressResponse proto.InternalMessageInfo + +func (m *QueryBeforeSendHookAddressResponse) GetCosmwasmAddress() string { + if m != nil { + return m.CosmwasmAddress + } + return "" +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "osmosis.tokenfactory.v1beta1.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "osmosis.tokenfactory.v1beta1.QueryParamsResponse") @@ -304,6 +394,8 @@ func init() { proto.RegisterType((*QueryDenomAuthorityMetadataResponse)(nil), "osmosis.tokenfactory.v1beta1.QueryDenomAuthorityMetadataResponse") proto.RegisterType((*QueryDenomsFromCreatorRequest)(nil), "osmosis.tokenfactory.v1beta1.QueryDenomsFromCreatorRequest") proto.RegisterType((*QueryDenomsFromCreatorResponse)(nil), "osmosis.tokenfactory.v1beta1.QueryDenomsFromCreatorResponse") + proto.RegisterType((*QueryBeforeSendHookAddressRequest)(nil), "osmosis.tokenfactory.v1beta1.QueryBeforeSendHookAddressRequest") + proto.RegisterType((*QueryBeforeSendHookAddressResponse)(nil), "osmosis.tokenfactory.v1beta1.QueryBeforeSendHookAddressResponse") } func init() { @@ -311,43 +403,49 @@ func init() { } var fileDescriptor_6f22013ad0f72e3f = []byte{ - // 574 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xcb, 0x6e, 0xd3, 0x4c, - 0x14, 0xce, 0xfc, 0x7f, 0x1b, 0xd4, 0xe1, 0x22, 0x32, 0x54, 0x08, 0xa2, 0xe2, 0xc0, 0x50, 0x55, - 0x29, 0x2a, 0x1e, 0x52, 0xb2, 0x40, 0x14, 0x04, 0x71, 0x11, 0x2c, 0xa0, 0x12, 0x78, 0x07, 0x9b, - 0x68, 0x92, 0x4e, 0x5d, 0x8b, 0xd8, 0xe3, 0x7a, 0x26, 0x15, 0x51, 0xd5, 0x0d, 0x0b, 0xd6, 0x48, - 0x2c, 0x79, 0x07, 0x9e, 0xa3, 0xcb, 0x4a, 0xdd, 0xb0, 0xb2, 0x50, 0x52, 0xf1, 0x00, 0x79, 0x02, - 0xe4, 0x99, 0x49, 0x68, 0x71, 0xb0, 0x02, 0xac, 0x62, 0xcd, 0xf9, 0xce, 0x77, 0x39, 0xe7, 0x28, - 0xb0, 0xca, 0x45, 0xc0, 0x85, 0x2f, 0x88, 0xe4, 0x6f, 0x59, 0xb8, 0x45, 0xdb, 0x92, 0xc7, 0x3d, - 0xb2, 0x5b, 0x6b, 0x31, 0x49, 0x6b, 0x64, 0xa7, 0xcb, 0xe2, 0x9e, 0x1d, 0xc5, 0x5c, 0x72, 0xb4, - 0x60, 0x90, 0xf6, 0x49, 0xa4, 0x6d, 0x90, 0xe5, 0x79, 0x8f, 0x7b, 0x5c, 0x01, 0x49, 0xfa, 0xa5, - 0x7b, 0xca, 0x0b, 0x1e, 0xe7, 0x5e, 0x87, 0x11, 0x1a, 0xf9, 0x84, 0x86, 0x21, 0x97, 0x54, 0xfa, - 0x3c, 0x14, 0xa6, 0x7a, 0xab, 0xad, 0x28, 0x49, 0x8b, 0x0a, 0xa6, 0xa5, 0xc6, 0xc2, 0x11, 0xf5, - 0xfc, 0x50, 0x81, 0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xd5, - 0x76, 0x6b, 0x75, 0xf2, 0xee, 0xb4, 0xa6, 0xec, 0x45, 0x4c, 0xb4, 0x8a, 0xea, 0xdf, 0xec, 0xee, - 0x8f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3b, 0x70, 0x16, 0x26, 0xd8, 0x05, 0x00, 0x00, + // 672 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x4f, 0x4f, 0x13, 0x41, + 0x14, 0xef, 0xaa, 0xd4, 0x30, 0xfe, 0x83, 0x11, 0xff, 0x55, 0xdc, 0xca, 0x48, 0x08, 0x18, 0xec, + 0x5a, 0xe4, 0x60, 0x44, 0x02, 0x5d, 0x14, 0x4d, 0x90, 0x44, 0xd7, 0x93, 0x5e, 0x9a, 0x69, 0x3b, + 0x94, 0x86, 0xee, 0xbe, 0xb2, 0x33, 0x45, 0x1b, 0xc2, 0xc5, 0x83, 0x67, 0x13, 0x8f, 0x7e, 0x07, + 0x3f, 0x07, 0x47, 0x12, 0x2e, 0x9e, 0x1a, 0x05, 0xe3, 0x07, 0xe8, 0x27, 0x30, 0x9d, 0x79, 0x45, + 0xa0, 0x65, 0xd3, 0xe2, 0xa9, 0x9b, 0xf7, 0x7e, 0xef, 0xf7, 0x7e, 0xbf, 0x79, 0xef, 0xa5, 0x64, + 0x1c, 0xa4, 0x0f, 0xb2, 0x24, 0x1d, 0x05, 0x6b, 0x22, 0x58, 0xe1, 0x79, 0x05, 0x61, 0xcd, 0xd9, + 0x48, 0xe7, 0x84, 0xe2, 0x69, 0x67, 0xbd, 0x2a, 0xc2, 0x5a, 0xaa, 0x12, 0x82, 0x02, 0x3a, 0x8c, + 0xc8, 0xd4, 0x61, 0x64, 0x0a, 0x91, 0x89, 0xa1, 0x22, 0x14, 0x41, 0x03, 0x9d, 0xe6, 0x97, 0xa9, + 0x49, 0x0c, 0x17, 0x01, 0x8a, 0x65, 0xe1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0xb4, 0x1b, 0xb3, 0x30, 0xce, 0xa6, 0xfe, 0xdd, 0x72, 0xda, 0x77, 0x9f, 0xee, 0x5a, 0x64, + 0xb0, 0x6d, 0x29, 0xe9, 0x4c, 0xb7, 0x0a, 0x3b, 0x5c, 0x46, 0xe2, 0xe9, 0xe9, 0x8a, 0xd1, 0xd9, + 0x82, 0x76, 0x36, 0x4b, 0x67, 0xba, 0x71, 0x96, 0x5d, 0x09, 0xc1, 0xcf, 0xe2, 0x91, 0x39, 0x9b, + 0xf8, 0xb1, 0x45, 0x7f, 0x59, 0xe4, 0x5a, 0xc7, 0x85, 0xa6, 0x73, 0x5d, 0x88, 0x8b, 0xba, 0xab, + 0xc4, 0xfc, 0xe9, 0x09, 0xd0, 0xe1, 0x73, 0xed, 0x70, 0x8e, 0xce, 0xf6, 0x34, 0xbb, 0x9c, 0xe6, + 0xcc, 0x4a, 0x11, 0x14, 0xb2, 0xab, 0x00, 0x6b, 0xae, 0xb7, 0xbd, 0x67, 0x5b, 0x3b, 0x7b, 0xb6, + 0xf5, 0x73, 0xcf, 0xb6, 0xbe, 0xec, 0xdb, 0xb1, 0x9d, 0x7d, 0x3b, 0xf6, 0x63, 0xdf, 0x8e, 0xbd, + 0x7f, 0x5c, 0x2c, 0xa9, 0xd5, 0x6a, 0x2e, 0x95, 0x07, 0xbf, 0xd5, 0xe2, 0x41, 0x99, 0xe7, 0xe4, + 0x41, 0xbf, 0x8d, 0xf4, 0xb4, 0xf3, 0xf1, 0x68, 0x57, 0x55, 0xab, 0x08, 0x99, 0x8b, 0xeb, 0x3f, + 0x9b, 0x47, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x20, 0x07, 0x7f, 0x6e, 0x77, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -371,6 +469,9 @@ type QueryClient interface { // DenomsFromCreator defines a gRPC query method for fetching all // denominations created by a specific admin/creator. DenomsFromCreator(ctx context.Context, in *QueryDenomsFromCreatorRequest, opts ...grpc.CallOption) (*QueryDenomsFromCreatorResponse, error) + // BeforeSendHookAddress defines a gRPC query method for + // getting the address registered for the before send hook. + BeforeSendHookAddress(ctx context.Context, in *QueryBeforeSendHookAddressRequest, opts ...grpc.CallOption) (*QueryBeforeSendHookAddressResponse, error) } type queryClient struct { @@ -408,6 +509,15 @@ func (c *queryClient) DenomsFromCreator(ctx context.Context, in *QueryDenomsFrom return out, nil } +func (c *queryClient) BeforeSendHookAddress(ctx context.Context, in *QueryBeforeSendHookAddressRequest, opts ...grpc.CallOption) (*QueryBeforeSendHookAddressResponse, error) { + out := new(QueryBeforeSendHookAddressResponse) + err := c.cc.Invoke(ctx, "/osmosis.tokenfactory.v1beta1.Query/BeforeSendHookAddress", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Params defines a gRPC query method that returns the tokenfactory module's @@ -419,6 +529,9 @@ type QueryServer interface { // DenomsFromCreator defines a gRPC query method for fetching all // denominations created by a specific admin/creator. DenomsFromCreator(context.Context, *QueryDenomsFromCreatorRequest) (*QueryDenomsFromCreatorResponse, error) + // BeforeSendHookAddress defines a gRPC query method for + // getting the address registered for the before send hook. + BeforeSendHookAddress(context.Context, *QueryBeforeSendHookAddressRequest) (*QueryBeforeSendHookAddressResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -434,6 +547,9 @@ func (*UnimplementedQueryServer) DenomAuthorityMetadata(ctx context.Context, req func (*UnimplementedQueryServer) DenomsFromCreator(ctx context.Context, req *QueryDenomsFromCreatorRequest) (*QueryDenomsFromCreatorResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method DenomsFromCreator not implemented") } +func (*UnimplementedQueryServer) BeforeSendHookAddress(ctx context.Context, req *QueryBeforeSendHookAddressRequest) (*QueryBeforeSendHookAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method BeforeSendHookAddress not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -493,6 +609,24 @@ func _Query_DenomsFromCreator_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Query_BeforeSendHookAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryBeforeSendHookAddressRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).BeforeSendHookAddress(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.tokenfactory.v1beta1.Query/BeforeSendHookAddress", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).BeforeSendHookAddress(ctx, req.(*QueryBeforeSendHookAddressRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "osmosis.tokenfactory.v1beta1.Query", HandlerType: (*QueryServer)(nil), @@ -509,6 +643,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "DenomsFromCreator", Handler: _Query_DenomsFromCreator_Handler, }, + { + MethodName: "BeforeSendHookAddress", + Handler: _Query_BeforeSendHookAddress_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "osmosis/tokenfactory/v1beta1/query.proto", @@ -695,6 +833,66 @@ func (m *QueryDenomsFromCreatorResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *QueryBeforeSendHookAddressRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryBeforeSendHookAddressRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryBeforeSendHookAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryBeforeSendHookAddressResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryBeforeSendHookAddressResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryBeforeSendHookAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CosmwasmAddress) > 0 { + i -= len(m.CosmwasmAddress) + copy(dAtA[i:], m.CosmwasmAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.CosmwasmAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -778,6 +976,32 @@ func (m *QueryDenomsFromCreatorResponse) Size() (n int) { return n } +func (m *QueryBeforeSendHookAddressRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryBeforeSendHookAddressResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.CosmwasmAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1246,6 +1470,170 @@ func (m *QueryDenomsFromCreatorResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryBeforeSendHookAddressRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryBeforeSendHookAddressRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryBeforeSendHookAddressRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryBeforeSendHookAddressResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryBeforeSendHookAddressResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryBeforeSendHookAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CosmwasmAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CosmwasmAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/tokenfactory/types/query.pb.gw.go b/x/tokenfactory/types/query.pb.gw.go index 0b895e7062b..5d75e90baf7 100644 --- a/x/tokenfactory/types/query.pb.gw.go +++ b/x/tokenfactory/types/query.pb.gw.go @@ -159,6 +159,60 @@ func local_request_Query_DenomsFromCreator_0(ctx context.Context, marshaler runt } +func request_Query_BeforeSendHookAddress_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryBeforeSendHookAddressRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["denom"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") + } + + protoReq.Denom, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) + } + + msg, err := client.BeforeSendHookAddress(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_BeforeSendHookAddress_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryBeforeSendHookAddressRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["denom"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") + } + + protoReq.Denom, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) + } + + msg, err := server.BeforeSendHookAddress(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -234,6 +288,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_BeforeSendHookAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_BeforeSendHookAddress_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_BeforeSendHookAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -335,6 +412,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_BeforeSendHookAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_BeforeSendHookAddress_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_BeforeSendHookAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -344,6 +441,8 @@ var ( pattern_Query_DenomAuthorityMetadata_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"osmosis", "tokenfactory", "v1beta1", "denoms", "denom", "authority_metadata"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_DenomsFromCreator_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"osmosis", "tokenfactory", "v1beta1", "denoms_from_creator", "creator"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_BeforeSendHookAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"osmosis", "tokenfactory", "v1beta1", "denoms", "denom", "before_send_hook"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -352,4 +451,6 @@ var ( forward_Query_DenomAuthorityMetadata_0 = runtime.ForwardResponseMessage forward_Query_DenomsFromCreator_0 = runtime.ForwardResponseMessage + + forward_Query_BeforeSendHookAddress_0 = runtime.ForwardResponseMessage ) diff --git a/x/tokenfactory/types/tx.pb.go b/x/tokenfactory/types/tx.pb.go index 60a81042fbb..dd7aa6d04d7 100644 --- a/x/tokenfactory/types/tx.pb.go +++ b/x/tokenfactory/types/tx.pb.go @@ -418,6 +418,106 @@ func (m *MsgChangeAdminResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgChangeAdminResponse proto.InternalMessageInfo +// MsgSetBeforeSendHook is the sdk.Msg type for allowing an admin account to +// assign a CosmWasm contract to call with a BeforeSend hook +type MsgSetBeforeSendHook struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"` + CosmwasmAddress string `protobuf:"bytes,3,opt,name=cosmwasm_address,json=cosmwasmAddress,proto3" json:"cosmwasm_address,omitempty" yaml:"cosmwasm_address"` +} + +func (m *MsgSetBeforeSendHook) Reset() { *m = MsgSetBeforeSendHook{} } +func (m *MsgSetBeforeSendHook) String() string { return proto.CompactTextString(m) } +func (*MsgSetBeforeSendHook) ProtoMessage() {} +func (*MsgSetBeforeSendHook) Descriptor() ([]byte, []int) { + return fileDescriptor_283b6c9a90a846b4, []int{8} +} +func (m *MsgSetBeforeSendHook) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetBeforeSendHook) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetBeforeSendHook.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSetBeforeSendHook) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetBeforeSendHook.Merge(m, src) +} +func (m *MsgSetBeforeSendHook) XXX_Size() int { + return m.Size() +} +func (m *MsgSetBeforeSendHook) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetBeforeSendHook.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetBeforeSendHook proto.InternalMessageInfo + +func (m *MsgSetBeforeSendHook) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgSetBeforeSendHook) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +func (m *MsgSetBeforeSendHook) GetCosmwasmAddress() string { + if m != nil { + return m.CosmwasmAddress + } + return "" +} + +// MsgSetBeforeSendHookResponse defines the response structure for an executed +// MsgSetBeforeSendHook message. +type MsgSetBeforeSendHookResponse struct { +} + +func (m *MsgSetBeforeSendHookResponse) Reset() { *m = MsgSetBeforeSendHookResponse{} } +func (m *MsgSetBeforeSendHookResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSetBeforeSendHookResponse) ProtoMessage() {} +func (*MsgSetBeforeSendHookResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_283b6c9a90a846b4, []int{9} +} +func (m *MsgSetBeforeSendHookResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetBeforeSendHookResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetBeforeSendHookResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSetBeforeSendHookResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetBeforeSendHookResponse.Merge(m, src) +} +func (m *MsgSetBeforeSendHookResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSetBeforeSendHookResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetBeforeSendHookResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetBeforeSendHookResponse proto.InternalMessageInfo + // MsgSetDenomMetadata is the sdk.Msg type for allowing an admin account to set // the denom's bank metadata type MsgSetDenomMetadata struct { @@ -429,7 +529,7 @@ func (m *MsgSetDenomMetadata) Reset() { *m = MsgSetDenomMetadata{} } func (m *MsgSetDenomMetadata) String() string { return proto.CompactTextString(m) } func (*MsgSetDenomMetadata) ProtoMessage() {} func (*MsgSetDenomMetadata) Descriptor() ([]byte, []int) { - return fileDescriptor_283b6c9a90a846b4, []int{8} + return fileDescriptor_283b6c9a90a846b4, []int{10} } func (m *MsgSetDenomMetadata) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -481,7 +581,7 @@ func (m *MsgSetDenomMetadataResponse) Reset() { *m = MsgSetDenomMetadata func (m *MsgSetDenomMetadataResponse) String() string { return proto.CompactTextString(m) } func (*MsgSetDenomMetadataResponse) ProtoMessage() {} func (*MsgSetDenomMetadataResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_283b6c9a90a846b4, []int{9} + return fileDescriptor_283b6c9a90a846b4, []int{11} } func (m *MsgSetDenomMetadataResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -519,6 +619,8 @@ func init() { proto.RegisterType((*MsgBurnResponse)(nil), "osmosis.tokenfactory.v1beta1.MsgBurnResponse") proto.RegisterType((*MsgChangeAdmin)(nil), "osmosis.tokenfactory.v1beta1.MsgChangeAdmin") proto.RegisterType((*MsgChangeAdminResponse)(nil), "osmosis.tokenfactory.v1beta1.MsgChangeAdminResponse") + proto.RegisterType((*MsgSetBeforeSendHook)(nil), "osmosis.tokenfactory.v1beta1.MsgSetBeforeSendHook") + proto.RegisterType((*MsgSetBeforeSendHookResponse)(nil), "osmosis.tokenfactory.v1beta1.MsgSetBeforeSendHookResponse") proto.RegisterType((*MsgSetDenomMetadata)(nil), "osmosis.tokenfactory.v1beta1.MsgSetDenomMetadata") proto.RegisterType((*MsgSetDenomMetadataResponse)(nil), "osmosis.tokenfactory.v1beta1.MsgSetDenomMetadataResponse") } @@ -528,45 +630,49 @@ func init() { } var fileDescriptor_283b6c9a90a846b4 = []byte{ - // 594 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x55, 0xc1, 0x6e, 0xd3, 0x4a, - 0x14, 0x8d, 0x5f, 0xfb, 0x42, 0x3a, 0xa5, 0x24, 0x75, 0x4b, 0x09, 0x86, 0xda, 0x68, 0xa4, 0x22, - 0x90, 0xa8, 0xad, 0x94, 0x2e, 0x80, 0x1d, 0x2e, 0x0b, 0x36, 0xde, 0x18, 0x56, 0xa8, 0x52, 0x35, - 0x4e, 0x06, 0xd7, 0x4a, 0x3c, 0x13, 0x32, 0x93, 0xa6, 0xd9, 0x20, 0x3e, 0x81, 0x05, 0xe2, 0x23, - 0xf8, 0x92, 0x2e, 0xbb, 0x64, 0x65, 0xa1, 0xe4, 0x0f, 0xf2, 0x05, 0xc8, 0x33, 0x63, 0xc7, 0x69, - 0x10, 0x49, 0x56, 0xec, 0x62, 0xdf, 0x73, 0xce, 0x9c, 0x39, 0xf7, 0xde, 0x18, 0x1c, 0x50, 0x16, - 0x53, 0x16, 0x31, 0x87, 0xd3, 0x36, 0x26, 0x1f, 0x51, 0x93, 0xd3, 0xde, 0xd0, 0xb9, 0x68, 0x04, - 0x98, 0xa3, 0x86, 0xc3, 0x2f, 0xed, 0x6e, 0x8f, 0x72, 0xaa, 0x3f, 0x54, 0x30, 0xbb, 0x08, 0xb3, - 0x15, 0xcc, 0xd8, 0x0d, 0x69, 0x48, 0x05, 0xd0, 0x49, 0x7f, 0x49, 0x8e, 0x61, 0x36, 0x05, 0xc9, - 0x09, 0x10, 0xc3, 0xb9, 0x62, 0x93, 0x46, 0x64, 0xae, 0x4e, 0xda, 0x79, 0x3d, 0x7d, 0x90, 0x75, - 0xd8, 0x01, 0x77, 0x3c, 0x16, 0x9e, 0xf4, 0x30, 0xe2, 0xf8, 0x0d, 0x26, 0x34, 0xd6, 0x9f, 0x82, - 0x32, 0xc3, 0xa4, 0x85, 0x7b, 0x75, 0xed, 0x91, 0xf6, 0x64, 0xc3, 0xdd, 0x9e, 0x24, 0xd6, 0xd6, - 0x10, 0xc5, 0x9d, 0x57, 0x50, 0xbe, 0x87, 0xbe, 0x02, 0xe8, 0x0e, 0xa8, 0xb0, 0x7e, 0xd0, 0x4a, - 0x69, 0xf5, 0xff, 0x04, 0x78, 0x67, 0x92, 0x58, 0x55, 0x05, 0x56, 0x15, 0xe8, 0xe7, 0x20, 0x78, - 0x0a, 0xf6, 0x66, 0x4f, 0xf3, 0x31, 0xeb, 0x52, 0xc2, 0xb0, 0xee, 0x82, 0x2a, 0xc1, 0x83, 0x33, - 0x71, 0xf3, 0x33, 0xa9, 0x28, 0x8f, 0x37, 0x26, 0x89, 0xb5, 0x27, 0x15, 0x6f, 0x00, 0xa0, 0xbf, - 0x45, 0xf0, 0xe0, 0x7d, 0xfa, 0x42, 0x68, 0xc1, 0xcf, 0xe0, 0x96, 0xc7, 0x42, 0x2f, 0x22, 0x7c, - 0x95, 0x4b, 0xbc, 0x05, 0x65, 0x14, 0xd3, 0x3e, 0xe1, 0xe2, 0x0a, 0x9b, 0x47, 0xf7, 0x6d, 0x19, - 0x99, 0x9d, 0x46, 0x9a, 0xa5, 0x6f, 0x9f, 0xd0, 0x88, 0xb8, 0x77, 0xaf, 0x12, 0xab, 0x34, 0x55, - 0x92, 0x34, 0xe8, 0x2b, 0x3e, 0xdc, 0x06, 0x55, 0x75, 0x7e, 0x76, 0x2d, 0x65, 0xc9, 0xed, 0xf7, -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xcb, 0xc4, 0x35, 0x3f, 0x5f, 0xfa, 0x17, 0x0d, 0xd4, 0xe6, 0x86, 0xab, - 0xb1, 0x50, 0xea, 0x26, 0xc5, 0x78, 0xb9, 0x32, 0x25, 0xb3, 0xe0, 0xfa, 0x57, 0x23, 0x53, 0xbb, - 0x1e, 0x99, 0xda, 0xaf, 0x91, 0xa9, 0x7d, 0x1d, 0x9b, 0xa5, 0xeb, 0xb1, 0x59, 0xfa, 0x39, 0x36, - 0x4b, 0x1f, 0x5e, 0x84, 0x11, 0x3f, 0xef, 0x07, 0x76, 0x93, 0xc6, 0x8e, 0x92, 0x3f, 0xec, 0xa0, - 0x80, 0x65, 0x0f, 0xce, 0x45, 0xe3, 0xd8, 0xb9, 0x9c, 0xfd, 0xb4, 0xf0, 0x61, 0x17, 0xb3, 0xa0, - 0x2c, 0xfe, 0xe2, 0x9f, 0xff, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xc7, 0x2a, 0x0e, 0x94, 0x7f, 0x06, - 0x00, 0x00, + // 669 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x55, 0xcf, 0x4e, 0x13, 0x41, + 0x1c, 0xee, 0x8a, 0x20, 0x0c, 0x62, 0xcb, 0x82, 0x50, 0x17, 0xd8, 0x35, 0x93, 0x60, 0x34, 0x91, + 0xdd, 0x14, 0x39, 0x28, 0x37, 0x16, 0x63, 0xb8, 0xf4, 0xb2, 0x78, 0x32, 0x24, 0x64, 0xda, 0x1d, + 0x96, 0xa6, 0xec, 0x0c, 0xee, 0x4c, 0x29, 0x5c, 0x8c, 0x89, 0x2f, 0xe0, 0xc1, 0xf8, 0x1c, 0xfa, + 0x16, 0x1c, 0x39, 0x7a, 0xda, 0x18, 0x78, 0x83, 0x3e, 0x81, 0xd9, 0x99, 0xd9, 0xed, 0x96, 0x12, + 0xdb, 0x3d, 0x18, 0x6f, 0xed, 0xfc, 0xbe, 0xef, 0x9b, 0xef, 0xf7, 0x6f, 0x16, 0xac, 0x53, 0x16, + 0x52, 0xd6, 0x62, 0x0e, 0xa7, 0x6d, 0x4c, 0x8e, 0x50, 0x93, 0xd3, 0xe8, 0xc2, 0x39, 0xab, 0x35, + 0x30, 0x47, 0x35, 0x87, 0x9f, 0xdb, 0xa7, 0x11, 0xe5, 0x54, 0x5f, 0x55, 0x30, 0x3b, 0x0f, 0xb3, + 0x15, 0xcc, 0x58, 0x0c, 0x68, 0x40, 0x05, 0xd0, 0x49, 0x7e, 0x49, 0x8e, 0x61, 0x36, 0x05, 0xc9, + 0x69, 0x20, 0x86, 0x33, 0xc5, 0x26, 0x6d, 0x91, 0xa1, 0x38, 0x69, 0x67, 0xf1, 0xe4, 0x8f, 0x8c, + 0xc3, 0x13, 0xf0, 0xa8, 0xce, 0x82, 0xdd, 0x08, 0x23, 0x8e, 0xdf, 0x62, 0x42, 0x43, 0xfd, 0x05, + 0x98, 0x62, 0x98, 0xf8, 0x38, 0xaa, 0x6a, 0x4f, 0xb5, 0xe7, 0x33, 0xee, 0x7c, 0x2f, 0xb6, 0xe6, + 0x2e, 0x50, 0x78, 0xb2, 0x0d, 0xe5, 0x39, 0xf4, 0x14, 0x40, 0x77, 0xc0, 0x34, 0xeb, 0x34, 0xfc, + 0x84, 0x56, 0xbd, 0x27, 0xc0, 0x0b, 0xbd, 0xd8, 0x2a, 0x2b, 0xb0, 0x8a, 0x40, 0x2f, 0x03, 0xc1, + 0x03, 0xb0, 0x34, 0x78, 0x9b, 0x87, 0xd9, 0x29, 0x25, 0x0c, 0xeb, 0x2e, 0x28, 0x13, 0xdc, 0x3d, + 0x14, 0x99, 0x1f, 0x4a, 0x45, 0x79, 0xbd, 0xd1, 0x8b, 0xad, 0x25, 0xa9, 0x78, 0x0b, 0x00, 0xbd, + 0x39, 0x82, 0xbb, 0xef, 0x93, 0x03, 0xa1, 0x05, 0x3f, 0x81, 0x07, 0x75, 0x16, 0xd4, 0x5b, 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d4, 0x60, 0xe9, 0x1f, 0xe7, 0xac, + 0xb6, 0xe5, 0x9c, 0x0f, 0x7e, 0xb4, 0xf9, 0xc5, 0x29, 0x66, 0x8d, 0x29, 0xf1, 0xf1, 0x7c, 0xf5, + 0x27, 0x00, 0x00, 0xff, 0xff, 0xf3, 0x4e, 0xdd, 0x2d, 0xd9, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -586,6 +692,7 @@ type MsgClient interface { Burn(ctx context.Context, in *MsgBurn, opts ...grpc.CallOption) (*MsgBurnResponse, error) ChangeAdmin(ctx context.Context, in *MsgChangeAdmin, opts ...grpc.CallOption) (*MsgChangeAdminResponse, error) SetDenomMetadata(ctx context.Context, in *MsgSetDenomMetadata, opts ...grpc.CallOption) (*MsgSetDenomMetadataResponse, error) + SetBeforeSendHook(ctx context.Context, in *MsgSetBeforeSendHook, opts ...grpc.CallOption) (*MsgSetBeforeSendHookResponse, error) } type msgClient struct { @@ -641,6 +748,15 @@ func (c *msgClient) SetDenomMetadata(ctx context.Context, in *MsgSetDenomMetadat return out, nil } +func (c *msgClient) SetBeforeSendHook(ctx context.Context, in *MsgSetBeforeSendHook, opts ...grpc.CallOption) (*MsgSetBeforeSendHookResponse, error) { + out := new(MsgSetBeforeSendHookResponse) + err := c.cc.Invoke(ctx, "/osmosis.tokenfactory.v1beta1.Msg/SetBeforeSendHook", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { CreateDenom(context.Context, *MsgCreateDenom) (*MsgCreateDenomResponse, error) @@ -648,6 +764,7 @@ type MsgServer interface { Burn(context.Context, *MsgBurn) (*MsgBurnResponse, error) ChangeAdmin(context.Context, *MsgChangeAdmin) (*MsgChangeAdminResponse, error) SetDenomMetadata(context.Context, *MsgSetDenomMetadata) (*MsgSetDenomMetadataResponse, error) + SetBeforeSendHook(context.Context, *MsgSetBeforeSendHook) (*MsgSetBeforeSendHookResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -669,6 +786,9 @@ func (*UnimplementedMsgServer) ChangeAdmin(ctx context.Context, req *MsgChangeAd func (*UnimplementedMsgServer) SetDenomMetadata(ctx context.Context, req *MsgSetDenomMetadata) (*MsgSetDenomMetadataResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SetDenomMetadata not implemented") } +func (*UnimplementedMsgServer) SetBeforeSendHook(ctx context.Context, req *MsgSetBeforeSendHook) (*MsgSetBeforeSendHookResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetBeforeSendHook not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -764,6 +884,24 @@ func _Msg_SetDenomMetadata_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } +func _Msg_SetBeforeSendHook_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSetBeforeSendHook) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SetBeforeSendHook(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.tokenfactory.v1beta1.Msg/SetBeforeSendHook", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SetBeforeSendHook(ctx, req.(*MsgSetBeforeSendHook)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "osmosis.tokenfactory.v1beta1.Msg", HandlerType: (*MsgServer)(nil), @@ -788,6 +926,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "SetDenomMetadata", Handler: _Msg_SetDenomMetadata_Handler, }, + { + MethodName: "SetBeforeSendHook", + Handler: _Msg_SetBeforeSendHook_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "osmosis/tokenfactory/v1beta1/tx.proto", @@ -1053,6 +1195,73 @@ func (m *MsgChangeAdminResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *MsgSetBeforeSendHook) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSetBeforeSendHook) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetBeforeSendHook) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CosmwasmAddress) > 0 { + i -= len(m.CosmwasmAddress) + copy(dAtA[i:], m.CosmwasmAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.CosmwasmAddress))) + i-- + dAtA[i] = 0x1a + } + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintTx(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSetBeforeSendHookResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSetBeforeSendHookResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetBeforeSendHookResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func (m *MsgSetDenomMetadata) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1235,6 +1444,36 @@ func (m *MsgChangeAdminResponse) Size() (n int) { return n } +func (m *MsgSetBeforeSendHook) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.CosmwasmAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgSetBeforeSendHookResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *MsgSetDenomMetadata) Size() (n int) { if m == nil { return 0 @@ -1987,6 +2226,202 @@ func (m *MsgChangeAdminResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgSetBeforeSendHook) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSetBeforeSendHook: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetBeforeSendHook: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CosmwasmAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CosmwasmAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSetBeforeSendHookResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSetBeforeSendHookResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetBeforeSendHookResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgSetDenomMetadata) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0