diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 69e7481dc..9177bc9fa 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -596,6 +596,7 @@ func NewAppKeepers( appKeepers.ClockKeeper = clockkeeper.NewKeeper( appKeepers.keys[clocktypes.StoreKey], appCodec, + appKeepers.WasmKeeper, appKeepers.ContractKeeper, govModAddress, ) diff --git a/interchaintest/contracts/clock_example_high_gas.wasm b/interchaintest/contracts/clock_example_high_gas.wasm new file mode 100644 index 000000000..c82f98f20 Binary files /dev/null and b/interchaintest/contracts/clock_example_high_gas.wasm differ diff --git a/interchaintest/contracts/clock_example_migrate.wasm b/interchaintest/contracts/clock_example_migrate.wasm new file mode 100644 index 000000000..5c339341d Binary files /dev/null and b/interchaintest/contracts/clock_example_migrate.wasm differ diff --git a/interchaintest/contracts/clock_example_no_sudo.wasm b/interchaintest/contracts/clock_example_no_sudo.wasm new file mode 100644 index 000000000..d2ad6ec8c Binary files /dev/null and b/interchaintest/contracts/clock_example_no_sudo.wasm differ diff --git a/interchaintest/helpers/clock.go b/interchaintest/helpers/clock.go new file mode 100644 index 000000000..784f0bcb9 --- /dev/null +++ b/interchaintest/helpers/clock.go @@ -0,0 +1,120 @@ +package helpers + +import ( + "context" + "encoding/json" + "fmt" + "testing" + + "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/strangelove-ventures/interchaintest/v7/chain/cosmos" + "github.com/strangelove-ventures/interchaintest/v7/ibc" + "github.com/strangelove-ventures/interchaintest/v7/testutil" + "github.com/stretchr/testify/require" +) + +// Register the clock contract +func RegisterClockContract(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, contract string) { + cmd := []string{ + "junod", "tx", "clock", "register", contract, + "--node", chain.GetRPCAddress(), + "--home", chain.HomeDir(), + "--chain-id", chain.Config().ChainID, + "--fees", "500ujuno", + "--from", user.KeyName(), + "--keyring-dir", chain.HomeDir(), + "--keyring-backend", keyring.BackendTest, + "-y", + } + stdout, _, err := chain.Exec(ctx, cmd, nil) + require.NoError(t, err) + + debugOutput(t, string(stdout)) + + err = testutil.WaitForBlocks(ctx, 2, chain) + require.NoError(t, err) +} + +// Unregister the clock contract +func UnregisterClockContract(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, contract string) { + cmd := []string{ + "junod", "tx", "clock", "unregister", contract, + "--node", chain.GetRPCAddress(), + "--home", chain.HomeDir(), + "--chain-id", chain.Config().ChainID, + "--fees", "500ujuno", + "--from", user.KeyName(), + "--keyring-dir", chain.HomeDir(), + "--keyring-backend", keyring.BackendTest, + "-y", + } + stdout, _, err := chain.Exec(ctx, cmd, nil) + require.NoError(t, err) + + debugOutput(t, string(stdout)) + + err = testutil.WaitForBlocks(ctx, 2, chain) + require.NoError(t, err) +} + +// Unjail the clock contract +func UnjailClockContract(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, contract string) { + cmd := []string{ + "junod", "tx", "clock", "unjail", contract, + "--node", chain.GetRPCAddress(), + "--home", chain.HomeDir(), + "--chain-id", chain.Config().ChainID, + "--fees", "500ujuno", + "--from", user.KeyName(), + "--keyring-dir", chain.HomeDir(), + "--keyring-backend", keyring.BackendTest, + "-y", + } + stdout, _, err := chain.Exec(ctx, cmd, nil) + require.NoError(t, err) + + debugOutput(t, string(stdout)) + + err = testutil.WaitForBlocks(ctx, 2, chain) + require.NoError(t, err) +} + +type ClockContract struct { + ClockContract struct { + ContractAddress string `json:"contract_address"` + IsJailed bool `json:"is_jailed"` + } `json:"clock_contract"` +} + +// Get the clock contract +func GetClockContract(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, contract string) ClockContract { + var res ClockContract + + cmd := getClockQueryCommand(chain, contract) + stdout, _, err := chain.Exec(ctx, cmd, nil) + require.NoError(t, err) + + fmt.Println(string(stdout)) + + if err := json.Unmarshal(stdout, &res); err != nil { + t.Fatal(err) + } + + return res +} + +// Validate a contract is not registered with the clock module +func ValidateNoClockContract(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, contract string) { + cmd := getClockQueryCommand(chain, contract) + _, _, err := chain.Exec(ctx, cmd, nil) + require.Error(t, err) +} + +// Get the clock query command +func getClockQueryCommand(chain *cosmos.CosmosChain, contract string) []string { + return []string{"junod", "query", "clock", "contract", contract, + "--node", chain.GetRPCAddress(), + "--chain-id", chain.Config().ChainID, + "--output", "json", + } +} diff --git a/interchaintest/helpers/cosmwasm.go b/interchaintest/helpers/cosmwasm.go index 1df24584f..27c98cd73 100644 --- a/interchaintest/helpers/cosmwasm.go +++ b/interchaintest/helpers/cosmwasm.go @@ -24,17 +24,61 @@ func SmartQueryString(t *testing.T, ctx context.Context, chain *cosmos.CosmosCha return err } -func SetupContract(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, keyname string, fileLoc string, message string) (codeId, contract string) { +func StoreContract(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, keyname string, fileLoc string) (codeId string) { codeId, err := chain.StoreContract(ctx, keyname, fileLoc) if err != nil { t.Fatal(err) } + return codeId +} + +func SetupContract(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, keyname string, fileLoc string, message string, extraFlags ...string) (codeId, contract string) { + codeId = StoreContract(t, ctx, chain, keyname, fileLoc) + + needsNoAdminFlag := true + // if extraFlags contains "--admin", switch to false + for _, flag := range extraFlags { + if flag == "--admin" { + needsNoAdminFlag = false + } + } + + contractAddr, err := chain.InstantiateContract(ctx, keyname, codeId, message, needsNoAdminFlag, extraFlags...) + if err != nil { + t.Fatal(err) + } - contractAddr, err := chain.InstantiateContract(ctx, keyname, codeId, message, true) + return codeId, contractAddr +} + +func MigrateContract(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, keyname string, contractAddr string, fileLoc string, message string) (codeId, contract string) { + codeId, err := chain.StoreContract(ctx, keyname, fileLoc) if err != nil { t.Fatal(err) } + // Execute migrate tx + cmd := []string{ + "junod", "tx", "wasm", "migrate", contractAddr, codeId, message, + "--node", chain.GetRPCAddress(), + "--home", chain.HomeDir(), + "--chain-id", chain.Config().ChainID, + "--from", keyname, + "--gas", "500000", + "--keyring-dir", chain.HomeDir(), + "--keyring-backend", keyring.BackendTest, + "-y", + } + + stdout, _, err := chain.Exec(ctx, cmd, nil) + require.NoError(t, err) + + debugOutput(t, string(stdout)) + + if err := testutil.WaitForBlocks(ctx, 2, chain); err != nil { + t.Fatal(err) + } + return codeId, contractAddr } diff --git a/interchaintest/module_clock_test.go b/interchaintest/module_clock_test.go index 046828253..5c49be4a7 100644 --- a/interchaintest/module_clock_test.go +++ b/interchaintest/module_clock_test.go @@ -10,7 +10,6 @@ import ( "github.com/strangelove-ventures/interchaintest/v7" "github.com/strangelove-ventures/interchaintest/v7/chain/cosmos" "github.com/strangelove-ventures/interchaintest/v7/ibc" - "github.com/strangelove-ventures/interchaintest/v7/testutil" "github.com/stretchr/testify/require" helpers "github.com/CosmosContracts/juno/tests/interchaintest/helpers" @@ -33,7 +32,13 @@ func TestJunoClock(t *testing.T) { users := interchaintest.GetAndFundTestUsers(t, ctx, "default", int64(10_000_000_000), juno, juno) user := users[0] - // Upload & init contract payment to another address + // + // -- REGULAR GAS CONTRACT -- + // Ensure logic works as expected for a contract that uses less than the gas limit + // and has a valid sudo message entry point. + // + + // Setup contract _, contractAddr := helpers.SetupContract(t, ctx, juno, user.KeyName(), "contracts/clock_example.wasm", `{}`) // Ensure config is 0 @@ -41,32 +46,105 @@ func TestJunoClock(t *testing.T) { fmt.Printf("- res: %v\n", res.Data.Val) require.Equal(t, uint32(0), res.Data.Val) - // Submit the proposal to add it to the allowed contracts list - SubmitParamChangeProp(t, ctx, juno, user, []string{contractAddr}) + // Register the contract + helpers.RegisterClockContract(t, ctx, juno, user, contractAddr) - // Wait 1 block - _ = testutil.WaitForBlocks(ctx, 1, juno) + // Validate contract is not jailed + contract := helpers.GetClockContract(t, ctx, juno, contractAddr) + require.False(t, contract.ClockContract.IsJailed) // Validate the contract is now auto incrementing from the end blocker res = helpers.GetClockContractValue(t, ctx, juno, contractAddr) fmt.Printf("- res: %v\n", res.Data.Val) require.GreaterOrEqual(t, res.Data.Val, uint32(1)) + // Unregister the contract & ensure it is removed from the store + helpers.UnregisterClockContract(t, ctx, juno, user, contractAddr) + helpers.ValidateNoClockContract(t, ctx, juno, contractAddr) + + // + // -- HIGH GAS CONTRACT -- + // Ensure contracts that exceed the gas limit are jailed. + // + + // Setup contract + _, contractAddr = helpers.SetupContract(t, ctx, juno, user.KeyName(), "contracts/clock_example_high_gas.wasm", `{}`, "--admin", user.FormattedAddress()) + + // Ensure config is 0 + res = helpers.GetClockContractValue(t, ctx, juno, contractAddr) + fmt.Printf("- res: %v\n", res.Data.Val) + require.Equal(t, uint32(0), res.Data.Val) + + // Register the contract + helpers.RegisterClockContract(t, ctx, juno, user, contractAddr) + + // Validate contract is jailed + contract = helpers.GetClockContract(t, ctx, juno, contractAddr) + require.True(t, contract.ClockContract.IsJailed) + + // + // -- MIGRATE CONTRACT -- + // Ensure migrations can patch contracts that error or exceed gas limit + // so they can be unjailed. + // + + // Migrate the high gas contract to a contract with lower gas usage + helpers.MigrateContract(t, ctx, juno, user.KeyName(), contractAddr, "contracts/clock_example_migrate.wasm", `{}`) + + // Unjail the contract + helpers.UnjailClockContract(t, ctx, juno, user, contractAddr) + + // Validate contract is not jailed + contract = helpers.GetClockContract(t, ctx, juno, contractAddr) + require.False(t, contract.ClockContract.IsJailed) + + // Validate the contract is now auto incrementing from the end blocker + res = helpers.GetClockContractValue(t, ctx, juno, contractAddr) + fmt.Printf("- res: %v\n", res.Data.Val) + require.GreaterOrEqual(t, res.Data.Val, uint32(1)) + + // + // -- NO SUDO CONTRACT -- + // Ensure contracts that do not have a sudo message entry point are jailed. + // + + // Setup contract + _, contractAddr = helpers.SetupContract(t, ctx, juno, user.KeyName(), "contracts/clock_example_no_sudo.wasm", `{}`) + + // Ensure config is 0 + res = helpers.GetClockContractValue(t, ctx, juno, contractAddr) + fmt.Printf("- res: %v\n", res.Data.Val) + require.Equal(t, uint32(0), res.Data.Val) + + // Register the contract + helpers.RegisterClockContract(t, ctx, juno, user, contractAddr) + + // Validate contract is jailed + contract = helpers.GetClockContract(t, ctx, juno, contractAddr) + require.True(t, contract.ClockContract.IsJailed) + + // Validate contract is not auto incrementing + res = helpers.GetClockContractValue(t, ctx, juno, contractAddr) + fmt.Printf("- res: %v\n", res.Data.Val) + require.Equal(t, uint32(0), res.Data.Val) + t.Cleanup(func() { _ = ic.Close() }) } -func SubmitParamChangeProp(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, contracts []string) string { +func SubmitParamChangeProp(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, gasLimit uint64) string { govAcc := "juno10d07y265gmmuvt4z0w9aw880jnsr700jvss730" updateParams := []cosmosproto.Message{ &clocktypes.MsgUpdateParams{ Authority: govAcc, - Params: clocktypes.NewParams(contracts, 1_000_000_000), + Params: clocktypes.Params{ + ContractGasLimit: gasLimit, + }, }, } - proposal, err := chain.BuildProposal(updateParams, "Params Add Contract", "params", "ipfs://CID", fmt.Sprintf(`500000000%s`, chain.Config().Denom)) + proposal, err := chain.BuildProposal(updateParams, "Params Update Gas Limit", "params", "ipfs://CID", fmt.Sprintf(`500000000%s`, chain.Config().Denom)) require.NoError(t, err, "error building proposal") txProp, err := chain.SubmitProposal(ctx, user.KeyName(), proposal) diff --git a/proto/juno/clock/v1/clock.proto b/proto/juno/clock/v1/clock.proto new file mode 100644 index 000000000..a80197d3a --- /dev/null +++ b/proto/juno/clock/v1/clock.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +package juno.clock.v1; + +option go_package = "github.com/CosmosContracts/juno/x/clock/types"; + +// This object is used to store the contract address and the +// jail status of the contract. +message ClockContract { + // The address of the contract. + string contract_address = 1; + // The jail status of the contract. + bool is_jailed = 2; +} \ No newline at end of file diff --git a/proto/juno/clock/v1/genesis.proto b/proto/juno/clock/v1/genesis.proto index 2d202e140..66c1d821e 100644 --- a/proto/juno/clock/v1/genesis.proto +++ b/proto/juno/clock/v1/genesis.proto @@ -3,6 +3,7 @@ package juno.clock.v1; import "gogoproto/gogo.proto"; import "cosmos/base/v1beta1/coin.proto"; +import "juno/clock/v1/clock.proto"; option go_package = "github.com/CosmosContracts/juno/x/clock/types"; @@ -17,13 +18,8 @@ message GenesisState { // Params defines the set of module parameters. message Params { - // contract_addresses stores the list of executable contracts to be ticked on every block. - repeated string contract_addresses = 1 [ - (gogoproto.jsontag) = "contract_addresses,omitempty", - (gogoproto.moretags) = "yaml:\"contract_addresses\"" - ]; - - uint64 contract_gas_limit = 2 [ + // contract_gas_limit defines the maximum amount of gas that can be used by a contract. + uint64 contract_gas_limit = 1 [ (gogoproto.jsontag) = "contract_gas_limit,omitempty", (gogoproto.moretags) = "yaml:\"contract_gas_limit\"" ]; diff --git a/proto/juno/clock/v1/query.proto b/proto/juno/clock/v1/query.proto index 23f5214d5..b392978b2 100644 --- a/proto/juno/clock/v1/query.proto +++ b/proto/juno/clock/v1/query.proto @@ -1,10 +1,12 @@ syntax = "proto3"; package juno.clock.v1; +import "cosmos/base/query/v1beta1/pagination.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "cosmos/base/v1beta1/coin.proto"; import "juno/clock/v1/genesis.proto"; +import "juno/clock/v1/clock.proto"; option go_package = "github.com/CosmosContracts/juno/x/clock/types"; @@ -16,6 +18,12 @@ service Query { option (google.api.http).get = "/juno/clock/v1/contracts"; } + // ClockContract + rpc ClockContract(QueryClockContract) + returns (QueryClockContractResponse) { + option (google.api.http).get = + "/juno/clock/v1/contracts/{contract_address}"; + } // Params rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/juno/clock/v1/params"; @@ -23,14 +31,29 @@ service Query { } // QueryClockContracts is the request type to get all contracts. -message QueryClockContracts {} +message QueryClockContracts { + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} // QueryClockContractsResponse is the response type for the Query/ClockContracts RPC method. message QueryClockContractsResponse { - repeated string contract_addresses = 1 [ - (gogoproto.jsontag) = "contract_addresses,omitempty", - (gogoproto.moretags) = "yaml:\"contract_addresses\"" - ]; + // clock_contracts are the clock contracts. + repeated ClockContract clock_contracts = 1 [ (gogoproto.nullable) = false ]; + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryClockContract is the request type to get a single contract. +message QueryClockContract { + // contract_address is the address of the contract to query. + string contract_address = 1; +} + +// QueryClockContractResponse is the response type for the Query/ClockContract RPC method. +message QueryClockContractResponse { + // contract is the clock contract. + ClockContract clock_contract = 1 [(gogoproto.nullable) = false]; } // QueryParams is the request type to get all module params. diff --git a/proto/juno/clock/v1/tx.proto b/proto/juno/clock/v1/tx.proto index 55db3fff2..8604aec37 100644 --- a/proto/juno/clock/v1/tx.proto +++ b/proto/juno/clock/v1/tx.proto @@ -3,6 +3,7 @@ package juno.clock.v1; option go_package = "github.com/CosmosContracts/juno/x/clock/types"; +import "google/api/annotations.proto"; import "cosmos/msg/v1/msg.proto"; import "juno/clock/v1/genesis.proto"; import "gogoproto/gogo.proto"; @@ -11,6 +12,28 @@ import "amino/amino.proto"; // Msg defines the Msg service. service Msg { + + // RegisterClockContract defines the endpoint for + // registering a new clock contract. + rpc RegisterClockContract(MsgRegisterClockContract) + returns (MsgRegisterClockContractResponse) { + option (google.api.http).post = "/juno/clock/v1/tx/register"; + }; + + // UnregisterClockContract defines the endpoint for + // unregistering a clock contract. + rpc UnregisterClockContract(MsgUnregisterClockContract) + returns (MsgUnregisterClockContractResponse) { + option (google.api.http).post = "/juno/clock/v1/tx/unregister"; + }; + + // UnjailClockContract defines the endpoint for + // unjailing a clock contract. + rpc UnjailClockContract(MsgUnjailClockContract) + returns (MsgUnjailClockContractResponse) { + option (google.api.http).post = "/juno/clock/v1/tx/unjail"; + }; + // UpdateParams defines a governance operation for updating the x/clock module // parameters. The authority is hard-coded to the x/gov module account. // @@ -18,6 +41,42 @@ service Msg { rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); } +// MsgRegisterClockContract is the Msg/RegisterClockContract request type. +message MsgRegisterClockContract { + // The address of the sender. + string sender_address = 1; + // The address of the contract to register. + string contract_address = 2; +} + +// MsgRegisterClockContractResponse defines the response structure for executing a +// MsgRegisterClockContract message. +message MsgRegisterClockContractResponse {} + +// MsgUnregisterClockContract is the Msg/UnregisterClockContract request type. +message MsgUnregisterClockContract { + // The address of the sender. + string sender_address = 1; + // The address of the contract to unregister. + string contract_address = 2; +} + +// MsgUnregisterClockContractResponse defines the response structure for executing a +// MsgUnregisterClockContract message. +message MsgUnregisterClockContractResponse {} + +// MsgUnjailClockContract is the Msg/UnjailClockContract request type. +message MsgUnjailClockContract { + // The address of the sender. + string sender_address = 1; + // The address of the contract to unjail. + string contract_address = 2; +} + +// MsgUnjailClockContractResponse defines the response structure for executing a +// MsgUnjailClockContract message. +message MsgUnjailClockContractResponse {} + // MsgUpdateParams is the Msg/UpdateParams request type. // // Since: cosmos-sdk 0.47 diff --git a/x/clock/abci.go b/x/clock/abci.go index 6274863e0..6679b5e5a 100644 --- a/x/clock/abci.go +++ b/x/clock/abci.go @@ -1,9 +1,11 @@ package clock import ( - "log" "time" + "github.com/cometbft/cometbft/libs/log" + + storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" @@ -11,32 +13,110 @@ import ( "github.com/CosmosContracts/juno/v19/x/clock/types" ) +var endBlockSudoMessage = []byte(types.EndBlockSudoMessage) + // EndBlocker executes on contracts at the end of the block. func EndBlocker(ctx sdk.Context, k keeper.Keeper) { defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker) - message := []byte(types.EndBlockSudoMessage) - + logger := k.Logger(ctx) p := k.GetParams(ctx) - errorExecs := make([]string, len(p.ContractAddresses)) + // Get all contracts + contracts, err := k.GetAllContracts(ctx) + if err != nil { + logger.Error("Failed to get contracts", "error", err) + return + } - for idx, addr := range p.ContractAddresses { - contract, err := sdk.AccAddressFromBech32(addr) - if err != nil { - errorExecs[idx] = addr + // Track errors + errorExecs := make([]string, len(contracts)) + errorExists := false + + // Execute all contracts that are not jailed + for idx, contract := range contracts { + + // Skip jailed contracts + if contract.IsJailed { continue } + // Get sdk.AccAddress from contract address + contractAddr := sdk.MustAccAddressFromBech32(contract.ContractAddress) + if handleError(ctx, k, logger, errorExecs, &errorExists, err, idx, contract.ContractAddress) { + continue + } + + // Create context with gas limit childCtx := ctx.WithGasMeter(sdk.NewGasMeter(p.ContractGasLimit)) - _, err = k.GetContractKeeper().Sudo(childCtx, contract, message) - if err != nil { - errorExecs[idx] = addr + + // Execute contract + executeContract(k, childCtx, contractAddr, &err) + if handleError(ctx, k, logger, errorExecs, &errorExists, err, idx, contract.ContractAddress) { continue } } - if len(errorExecs) > 0 { - log.Printf("[x/clock] Execute Errors: %v", errorExecs) + // Log errors if present + if errorExists { + logger.Error("Failed to execute contracts", "contracts", errorExecs) + } +} + +// Function to handle contract execution errors. Returns true if error is present, false otherwise. +func handleError( + ctx sdk.Context, + k keeper.Keeper, + logger log.Logger, + errorExecs []string, + errorExists *bool, + err error, + idx int, + contractAddress string, +) bool { + // Check if error is present + if err != nil { + + // Flag error + *errorExists = true + errorExecs[idx] = contractAddress + + // Attempt to jail contract, log error if present + err := k.SetJailStatus(ctx, contractAddress, true) + if err != nil { + logger.Error("Failed to jail contract", "contract", contractAddress, "error", err) + } + } + + return err != nil +} + +// Execute contract, recover from panic +func executeContract(k keeper.Keeper, childCtx sdk.Context, contractAddr sdk.AccAddress, err *error) { + // Recover from panic, return error + defer func() { + if recoveryError := recover(); recoveryError != nil { + // Determine error associated with panic + if isOutofGas, msg := isOutOfGasError(recoveryError); isOutofGas { + *err = types.ErrOutOfGas.Wrapf("%s", msg) + } else { + *err = types.ErrContractExecutionPanic.Wrapf("%s", recoveryError) + } + } + }() + + // Execute contract with sudo + _, *err = k.GetContractKeeper().Sudo(childCtx, contractAddr, endBlockSudoMessage) +} + +// Check if error is out of gas error +func isOutOfGasError(err any) (bool, string) { + switch e := err.(type) { + case storetypes.ErrorOutOfGas: + return true, e.Descriptor + case storetypes.ErrorGasOverflow: + return true, e.Descriptor + default: + return false, "" } } diff --git a/x/clock/abci_test.go b/x/clock/abci_test.go new file mode 100644 index 000000000..a4751d853 --- /dev/null +++ b/x/clock/abci_test.go @@ -0,0 +1,267 @@ +package clock_test + +import ( + "crypto/sha256" + "encoding/json" + "testing" + "time" + + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + "github.com/stretchr/testify/suite" + + _ "embed" + + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + + "github.com/cosmos/cosmos-sdk/testutil/testdata" + sdk "github.com/cosmos/cosmos-sdk/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + + "github.com/CosmosContracts/juno/v19/app" + clock "github.com/CosmosContracts/juno/v19/x/clock" + "github.com/CosmosContracts/juno/v19/x/clock/types" +) + +type EndBlockerTestSuite struct { + suite.Suite + + ctx sdk.Context + + app *app.App +} + +func TestEndBlockerTestSuite(t *testing.T) { + suite.Run(t, new(EndBlockerTestSuite)) +} + +func (s *EndBlockerTestSuite) SetupTest() { + app := app.Setup(s.T()) + ctx := app.BaseApp.NewContext(false, tmproto.Header{ + ChainID: "testing", + Height: 10, + Time: time.Now(), + }) + + s.app = app + s.ctx = ctx +} + +//go:embed keeper/testdata/clock_example.wasm +var clockContract []byte + +//go:embed keeper/testdata/cw_testburn.wasm +var burnContract []byte + +func (s *EndBlockerTestSuite) StoreCode(wasmContract []byte) { + _, _, sender := testdata.KeyTestPubAddr() + msg := wasmtypes.MsgStoreCodeFixture(func(m *wasmtypes.MsgStoreCode) { + m.WASMByteCode = wasmContract + m.Sender = sender.String() + }) + rsp, err := s.app.MsgServiceRouter().Handler(msg)(s.ctx, msg) + s.Require().NoError(err) + var result wasmtypes.MsgStoreCodeResponse + s.Require().NoError(s.app.AppCodec().Unmarshal(rsp.Data, &result)) + s.Require().Equal(uint64(1), result.CodeID) + expHash := sha256.Sum256(wasmContract) + s.Require().Equal(expHash[:], result.Checksum) + // and + info := s.app.AppKeepers.WasmKeeper.GetCodeInfo(s.ctx, 1) + s.Require().NotNil(info) + s.Require().Equal(expHash[:], info.CodeHash) + s.Require().Equal(sender.String(), info.Creator) + s.Require().Equal(wasmtypes.DefaultParams().InstantiateDefaultPermission.With(sender), info.InstantiateConfig) +} + +func (s *EndBlockerTestSuite) InstantiateContract(sender string, admin string) string { + msgStoreCode := wasmtypes.MsgStoreCodeFixture(func(m *wasmtypes.MsgStoreCode) { + m.WASMByteCode = clockContract + m.Sender = sender + }) + _, err := s.app.MsgServiceRouter().Handler(msgStoreCode)(s.ctx, msgStoreCode) + s.Require().NoError(err) + + msgInstantiate := wasmtypes.MsgInstantiateContractFixture(func(m *wasmtypes.MsgInstantiateContract) { + m.Sender = sender + m.Admin = admin + m.Msg = []byte(`{}`) + }) + resp, err := s.app.MsgServiceRouter().Handler(msgInstantiate)(s.ctx, msgInstantiate) + s.Require().NoError(err) + var result wasmtypes.MsgInstantiateContractResponse + s.Require().NoError(s.app.AppCodec().Unmarshal(resp.Data, &result)) + contractInfo := s.app.AppKeepers.WasmKeeper.GetContractInfo(s.ctx, sdk.MustAccAddressFromBech32(result.Address)) + s.Require().Equal(contractInfo.CodeID, uint64(1)) + s.Require().Equal(contractInfo.Admin, admin) + s.Require().Equal(contractInfo.Creator, sender) + + return result.Address +} + +func (s *EndBlockerTestSuite) FundAccount(ctx sdk.Context, addr sdk.AccAddress, amounts sdk.Coins) error { + if err := s.app.AppKeepers.BankKeeper.MintCoins(ctx, minttypes.ModuleName, amounts); err != nil { + return err + } + + return s.app.AppKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr, amounts) +} + +// Register a contract. You must store the contract code before registering. +func (s *EndBlockerTestSuite) registerContract() string { + // Create & fund accounts + _, _, sender := testdata.KeyTestPubAddr() + _, _, admin := testdata.KeyTestPubAddr() + _ = s.FundAccount(s.ctx, sender, sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1_000_000)))) + _ = s.FundAccount(s.ctx, admin, sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1_000_000)))) + + // Instantiate contract + contractAddress := s.InstantiateContract(sender.String(), admin.String()) + + // Register contract + clockKeeper := s.app.AppKeepers.ClockKeeper + err := clockKeeper.RegisterContract(s.ctx, admin.String(), contractAddress) + s.Require().NoError(err) + + // Assert contract is registered + contract, err := clockKeeper.GetClockContract(s.ctx, contractAddress) + s.Require().NoError(err) + s.Require().Equal(contractAddress, contract.ContractAddress) + + // Increment block height + s.ctx = s.ctx.WithBlockHeight(11) + + return contract.ContractAddress +} + +// Test the end blocker. This test registers a contract, executes it with enough gas, +// too little gas, and also ensures the unjailing process functions. +func (s *EndBlockerTestSuite) TestEndBlocker() { + // Setup test + clockKeeper := s.app.AppKeepers.ClockKeeper + s.StoreCode(clockContract) + contractAddress := s.registerContract() + + // Query contract + val := s.queryContract(contractAddress) + s.Require().Equal(int64(0), val) + + // Call end blocker + s.callEndBlocker() + + // Query contract + val = s.queryContract(contractAddress) + s.Require().Equal(int64(1), val) + + // Update params with 10 gas limit + s.updateGasLimit(65_000) + + // Call end blocker + s.callEndBlocker() + + // Ensure contract is now jailed + contract, err := clockKeeper.GetClockContract(s.ctx, contractAddress) + s.Require().NoError(err) + s.Require().True(contract.IsJailed) + + // Update params to regular + s.updateGasLimit(types.DefaultParams().ContractGasLimit) + + // Call end blocker + s.callEndBlocker() + + // Unjail contract + err = clockKeeper.SetJailStatus(s.ctx, contractAddress, false) + s.Require().NoError(err) + + // Ensure contract is no longer jailed + contract, err = clockKeeper.GetClockContract(s.ctx, contractAddress) + s.Require().NoError(err) + s.Require().False(contract.IsJailed) + + // Call end blocker + s.callEndBlocker() + + // Query contract + val = s.queryContract(contractAddress) + s.Require().Equal(int64(2), val) +} + +// Test a contract which does not handle the sudo EndBlock msg. +func (s *EndBlockerTestSuite) TestInvalidContract() { + // Setup test + clockKeeper := s.app.AppKeepers.ClockKeeper + s.StoreCode(burnContract) + contractAddress := s.registerContract() + + // Run the end blocker + s.callEndBlocker() + + // Ensure contract is now jailed + contract, err := clockKeeper.GetClockContract(s.ctx, contractAddress) + s.Require().NoError(err) + s.Require().True(contract.IsJailed) +} + +// Test the endblocker with numerous contracts that all panic +func (s *EndBlockerTestSuite) TestPerformance() { + s.StoreCode(burnContract) + + numContracts := 1000 + + // Register numerous contracts + for x := 0; x < numContracts; x++ { + // Register contract + _ = s.registerContract() + } + + // Ensure contracts exist + clockKeeper := s.app.AppKeepers.ClockKeeper + contracts, err := clockKeeper.GetAllContracts(s.ctx) + s.Require().NoError(err) + s.Require().Len(contracts, numContracts) + + // Call end blocker + s.callEndBlocker() + + // Ensure contracts are jailed + contracts, err = clockKeeper.GetAllContracts(s.ctx) + s.Require().NoError(err) + for _, contract := range contracts { + s.Require().True(contract.IsJailed) + } +} + +// Update the gas limit +func (s *EndBlockerTestSuite) updateGasLimit(gasLimit uint64) { + params := types.DefaultParams() + params.ContractGasLimit = gasLimit + k := s.app.AppKeepers.ClockKeeper + + store := s.ctx.KVStore(k.GetStore()) + bz := k.GetCdc().MustMarshal(¶ms) + store.Set(types.ParamsKey, bz) + + s.ctx = s.ctx.WithBlockHeight(s.ctx.BlockHeight() + 1) +} + +// Call the end blocker, incrementing the block height +func (s *EndBlockerTestSuite) callEndBlocker() { + clock.EndBlocker(s.ctx, s.app.AppKeepers.ClockKeeper) + s.ctx = s.ctx.WithBlockHeight(s.ctx.BlockHeight() + 1) +} + +// Query the clock contract +func (s *EndBlockerTestSuite) queryContract(contractAddress string) int64 { + query := `{"get_config":{}}` + output, err := s.app.AppKeepers.WasmKeeper.QuerySmart(s.ctx, sdk.MustAccAddressFromBech32(contractAddress), []byte(query)) + s.Require().NoError(err) + + var val struct { + Val int64 `json:"val"` + } + + err = json.Unmarshal(output, &val) + s.Require().NoError(err) + + return val.Val +} diff --git a/x/clock/client/cli/query.go b/x/clock/client/cli/query.go index 92eb03285..92c39a73f 100644 --- a/x/clock/client/cli/query.go +++ b/x/clock/client/cli/query.go @@ -19,6 +19,7 @@ func GetQueryCmd() *cobra.Command { } queryCmd.AddCommand( GetCmdShowContracts(), + GetCmdShowContract(), GetCmdParams(), ) return queryCmd @@ -27,8 +28,40 @@ func GetQueryCmd() *cobra.Command { func GetCmdShowContracts() *cobra.Command { cmd := &cobra.Command{ Use: "contracts", - Short: "Show addresses of all current contract modules", + Short: "Show addresses of all current clock contracts", Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + res, err := queryClient.ClockContracts(cmd.Context(), &types.QueryClockContracts{ + Pagination: pageReq, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "contracts") + return cmd +} + +func GetCmdShowContract() *cobra.Command { + cmd := &cobra.Command{ + Use: "contract [contract_address]", + Short: "Get contract by address", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { @@ -36,7 +69,12 @@ func GetCmdShowContracts() *cobra.Command { } queryClient := types.NewQueryClient(clientCtx) - res, err := queryClient.ClockContracts(cmd.Context(), &types.QueryClockContracts{}) + + req := &types.QueryClockContract{ + ContractAddress: args[0], + } + + res, err := queryClient.ClockContract(cmd.Context(), req) if err != nil { return err } diff --git a/x/clock/client/cli/tx.go b/x/clock/client/cli/tx.go new file mode 100644 index 000000000..10a6afff5 --- /dev/null +++ b/x/clock/client/cli/tx.go @@ -0,0 +1,132 @@ +package cli + +import ( + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + + "github.com/CosmosContracts/juno/v19/x/clock/types" +) + +// NewTxCmd returns a root CLI command handler for certain modules/Clock +// transaction commands. +func NewTxCmd() *cobra.Command { + txCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Clock subcommands.", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + txCmd.AddCommand( + NewRegisterClockContract(), + NewUnregisterClockContract(), + NewUnjailClockContract(), + ) + return txCmd +} + +// NewRegisterClockContract returns a CLI command handler for registering a +// contract for the clock module. +func NewRegisterClockContract() *cobra.Command { + cmd := &cobra.Command{ + Use: "register [contract_bech32]", + Short: "Register a clock contract.", + Long: "Register a clock contract. Sender must be admin of the contract.", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + cliCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + senderAddress := cliCtx.GetFromAddress() + contractAddress := args[0] + + msg := &types.MsgRegisterClockContract{ + SenderAddress: senderAddress.String(), + ContractAddress: contractAddress, + } + + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(cliCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} + +// NewUnregisterClockContract returns a CLI command handler for unregistering a +// contract for the clock module. +func NewUnregisterClockContract() *cobra.Command { + cmd := &cobra.Command{ + Use: "unregister [contract_bech32]", + Short: "Unregister a clock contract.", + Long: "Unregister a clock contract. Sender must be admin of the contract.", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + cliCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + senderAddress := cliCtx.GetFromAddress() + contractAddress := args[0] + + msg := &types.MsgUnregisterClockContract{ + SenderAddress: senderAddress.String(), + ContractAddress: contractAddress, + } + + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(cliCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} + +// NewUnjailClockContract returns a CLI command handler for unjailing a +// contract for the clock module. +func NewUnjailClockContract() *cobra.Command { + cmd := &cobra.Command{ + Use: "unjail [contract_bech32]", + Short: "Unjail a clock contract.", + Long: "Unjail a clock contract. Sender must be admin of the contract.", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + cliCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + senderAddress := cliCtx.GetFromAddress() + contractAddress := args[0] + + msg := &types.MsgUnjailClockContract{ + SenderAddress: senderAddress.String(), + ContractAddress: contractAddress, + } + + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(cliCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} diff --git a/x/clock/genesis.go b/x/clock/genesis.go index a8c1d3509..1a840181a 100644 --- a/x/clock/genesis.go +++ b/x/clock/genesis.go @@ -35,7 +35,12 @@ func GetGenesisStateFromAppState(cdc codec.Codec, appState map[string]json.RawMe } func ValidateGenesis(data types.GenesisState) error { - return data.Params.Validate() + err := data.Params.Validate() + if err != nil { + return err + } + + return nil } // InitGenesis import module genesis @@ -44,10 +49,12 @@ func InitGenesis( k keeper.Keeper, data types.GenesisState, ) { + // Validate init contents if err := ValidateGenesis(data); err != nil { panic(err) } + // Set params if err := k.SetParams(ctx, data.Params); err != nil { panic(err) } @@ -55,7 +62,9 @@ func InitGenesis( // ExportGenesis export module state func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + params := k.GetParams(ctx) + return &types.GenesisState{ - Params: k.GetParams(ctx), + Params: params, } } diff --git a/x/clock/genesis_test.go b/x/clock/genesis_test.go index e56da5664..f89aadcb5 100644 --- a/x/clock/genesis_test.go +++ b/x/clock/genesis_test.go @@ -8,7 +8,6 @@ import ( tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/CosmosContracts/juno/v19/app" @@ -39,47 +38,30 @@ func (suite *GenesisTestSuite) SetupTest() { } func (suite *GenesisTestSuite) TestClockInitGenesis() { - _, _, addr := testdata.KeyTestPubAddr() - _, _, addr2 := testdata.KeyTestPubAddr() - - defaultParams := types.DefaultParams() - testCases := []struct { - name string - genesis types.GenesisState - expPanic bool + name string + genesis types.GenesisState + success bool }{ { - "default genesis", + "Success - Default Genesis", *clock.DefaultGenesisState(), - false, - }, - { - "custom genesis - none", - types.GenesisState{ - Params: types.Params{ - ContractAddresses: []string(nil), - ContractGasLimit: defaultParams.ContractGasLimit, - }, - }, - false, + true, }, { - "custom genesis - incorrect addr", + "Success - Custom Genesis", types.GenesisState{ Params: types.Params{ - ContractAddresses: []string{"incorrectaddr"}, - ContractGasLimit: defaultParams.ContractGasLimit, + ContractGasLimit: 500_000, }, }, true, }, { - "custom genesis - only one addr allowed", + "Fail - Invalid Gas Amount", types.GenesisState{ Params: types.Params{ - ContractAddresses: []string{addr.String(), addr2.String()}, - ContractGasLimit: defaultParams.ContractGasLimit, + ContractGasLimit: 1, }, }, false, @@ -90,17 +72,17 @@ func (suite *GenesisTestSuite) TestClockInitGenesis() { suite.Run(fmt.Sprintf("Case %s", tc.name), func() { suite.SetupTest() // reset - if tc.expPanic { - suite.Require().Panics(func() { - clock.InitGenesis(suite.ctx, suite.app.AppKeepers.ClockKeeper, tc.genesis) - }) - } else { + if tc.success { suite.Require().NotPanics(func() { clock.InitGenesis(suite.ctx, suite.app.AppKeepers.ClockKeeper, tc.genesis) }) params := suite.app.AppKeepers.ClockKeeper.GetParams(suite.ctx) suite.Require().Equal(tc.genesis.Params, params) + } else { + suite.Require().Panics(func() { + clock.InitGenesis(suite.ctx, suite.app.AppKeepers.ClockKeeper, tc.genesis) + }) } }) } diff --git a/x/clock/keeper/clock.go b/x/clock/keeper/clock.go new file mode 100644 index 000000000..0519ad08d --- /dev/null +++ b/x/clock/keeper/clock.go @@ -0,0 +1,230 @@ +package keeper + +import ( + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + + "github.com/CosmosContracts/juno/v19/x/clock/types" +) + +// Store Keys for clock contracts (both jailed and unjailed) +var ( + StoreKeyContracts = []byte("contracts") +) + +// Get the store for the clock contracts. +func (k Keeper) getStore(ctx sdk.Context) prefix.Store { + return prefix.NewStore(ctx.KVStore(k.storeKey), StoreKeyContracts) +} + +// Set a clock contract address in the KV store. +func (k Keeper) SetClockContract(ctx sdk.Context, contract types.ClockContract) error { + // Get store, marshal content + store := k.getStore(ctx) + bz, err := k.cdc.Marshal(&contract) + if err != nil { + return err + } + + // Set the contract + store.Set([]byte(contract.ContractAddress), bz) + return nil +} + +// Check if a clock contract address is in the KV store. +func (k Keeper) IsClockContract(ctx sdk.Context, contractAddress string) bool { + store := k.getStore(ctx) + return store.Has([]byte(contractAddress)) +} + +// Get a clock contract address from the KV store. +func (k Keeper) GetClockContract(ctx sdk.Context, contractAddress string) (*types.ClockContract, error) { + // Check if the contract is registered + if !k.IsClockContract(ctx, contractAddress) { + return nil, types.ErrContractNotRegistered + } + + // Get the KV store + store := k.getStore(ctx) + bz := store.Get([]byte(contractAddress)) + + // Unmarshal the contract + var contract types.ClockContract + err := k.cdc.Unmarshal(bz, &contract) + if err != nil { + return nil, err + } + + // Return the contract + return &contract, nil +} + +// Get all clock contract addresses from the KV store. +func (k Keeper) GetAllContracts(ctx sdk.Context) ([]types.ClockContract, error) { + // Get the KV store + store := k.getStore(ctx) + + // Create iterator for contracts + iterator := sdk.KVStorePrefixIterator(store, []byte(nil)) + defer iterator.Close() + + // Iterate over all contracts + contracts := []types.ClockContract{} + for ; iterator.Valid(); iterator.Next() { + + // Unmarshal iterator + var contract types.ClockContract + err := k.cdc.Unmarshal(iterator.Value(), &contract) + if err != nil { + return nil, err + } + + contracts = append(contracts, contract) + } + + // Return array of contracts + return contracts, nil +} + +// Get all registered fee pay contracts +func (k Keeper) GetPaginatedContracts(ctx sdk.Context, pag *query.PageRequest) (*types.QueryClockContractsResponse, error) { + store := k.getStore(ctx) + + // Filter and paginate all contracts + results, pageRes, err := query.GenericFilteredPaginate( + k.cdc, + store, + pag, + func(key []byte, value *types.ClockContract) (*types.ClockContract, error) { + return value, nil + }, + func() *types.ClockContract { + return &types.ClockContract{} + }, + ) + if err != nil { + return nil, err + } + + // Dereference pointer array of contracts + var contracts []types.ClockContract + for _, contract := range results { + contracts = append(contracts, *contract) + } + + // Return paginated contracts + return &types.QueryClockContractsResponse{ + ClockContracts: contracts, + Pagination: pageRes, + }, nil +} + +// Remove a clock contract address from the KV store. +func (k Keeper) RemoveContract(ctx sdk.Context, contractAddress string) { + store := k.getStore(ctx) + key := []byte(contractAddress) + + if store.Has(key) { + store.Delete(key) + } +} + +// Register a clock contract address in the KV store. +func (k Keeper) RegisterContract(ctx sdk.Context, senderAddress string, contractAddress string) error { + // Check if the contract is already registered + if k.IsClockContract(ctx, contractAddress) { + return types.ErrContractAlreadyRegistered + } + + // Ensure the sender is the contract admin or creator + if ok, err := k.IsContractManager(ctx, senderAddress, contractAddress); !ok { + return err + } + + // Register contract + return k.SetClockContract(ctx, types.ClockContract{ + ContractAddress: contractAddress, + IsJailed: false, + }) +} + +// Unregister a clock contract from either the jailed or unjailed KV store. +func (k Keeper) UnregisterContract(ctx sdk.Context, senderAddress string, contractAddress string) error { + // Check if the contract is registered in either store + if !k.IsClockContract(ctx, contractAddress) { + return types.ErrContractNotRegistered + } + + // Ensure the sender is the contract admin or creator + if ok, err := k.IsContractManager(ctx, senderAddress, contractAddress); !ok { + return err + } + + // Remove contract from both stores + k.RemoveContract(ctx, contractAddress) + return nil +} + +// Set the jail status of a clock contract in the KV store. +func (k Keeper) SetJailStatus(ctx sdk.Context, contractAddress string, isJailed bool) error { + // Get the contract + contract, err := k.GetClockContract(ctx, contractAddress) + if err != nil { + return err + } + + // Check if the contract is already jailed or unjailed + if contract.IsJailed == isJailed { + if isJailed { + return types.ErrContractAlreadyJailed + } + + return types.ErrContractNotJailed + } + + // Set the jail status + contract.IsJailed = isJailed + + // Set the contract + return k.SetClockContract(ctx, *contract) +} + +// Set the jail status of a clock contract by the sender address. +func (k Keeper) SetJailStatusBySender(ctx sdk.Context, senderAddress string, contractAddress string, jailStatus bool) error { + // Ensure the sender is the contract admin or creator + if ok, err := k.IsContractManager(ctx, senderAddress, contractAddress); !ok { + return err + } + + return k.SetJailStatus(ctx, contractAddress, jailStatus) +} + +// Check if the sender is the designated contract manager for the FeePay contract. If +// an admin is present, they are considered the manager. If there is no admin, the +// contract creator is considered the manager. +func (k Keeper) IsContractManager(ctx sdk.Context, senderAddress string, contractAddress string) (bool, error) { + contractAddr := sdk.MustAccAddressFromBech32(contractAddress) + + // Ensure the contract is a cosm wasm contract + if ok := k.wasmKeeper.HasContractInfo(ctx, contractAddr); !ok { + return false, types.ErrInvalidCWContract + } + + // Get the contract info + contractInfo := k.wasmKeeper.GetContractInfo(ctx, contractAddr) + + // Flags for admin existence & sender being admin/creator + adminExists := len(contractInfo.Admin) > 0 + isSenderAdmin := contractInfo.Admin == senderAddress + isSenderCreator := contractInfo.Creator == senderAddress + + // Check if the sender is the admin or creator + if adminExists && !isSenderAdmin { + return false, types.ErrContractNotAdmin + } else if !adminExists && !isSenderCreator { + return false, types.ErrContractNotCreator + } + + return true, nil +} diff --git a/x/clock/keeper/keeper.go b/x/clock/keeper/keeper.go index 4f52c5533..641fa109a 100644 --- a/x/clock/keeper/keeper.go +++ b/x/clock/keeper/keeper.go @@ -1,8 +1,11 @@ package keeper import ( + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + "github.com/cometbft/cometbft/libs/log" + "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -15,6 +18,7 @@ type Keeper struct { storeKey storetypes.StoreKey cdc codec.BinaryCodec + wasmKeeper wasmkeeper.Keeper contractKeeper wasmtypes.ContractOpsKeeper authority string @@ -23,17 +27,24 @@ type Keeper struct { func NewKeeper( key storetypes.StoreKey, cdc codec.BinaryCodec, + wasmKeeper wasmkeeper.Keeper, contractKeeper wasmtypes.ContractOpsKeeper, authority string, ) Keeper { return Keeper{ cdc: cdc, storeKey: key, + wasmKeeper: wasmKeeper, contractKeeper: contractKeeper, authority: authority, } } +// Logger returns a module-specific logger. +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", "x/"+types.ModuleName) +} + // GetAuthority returns the x/clock module's authority. func (k Keeper) GetAuthority() string { return k.authority @@ -68,3 +79,13 @@ func (k Keeper) GetParams(ctx sdk.Context) (p types.Params) { func (k Keeper) GetContractKeeper() wasmtypes.ContractOpsKeeper { return k.contractKeeper } + +// GetCdc returns the x/clock module's codec. +func (k Keeper) GetCdc() codec.BinaryCodec { + return k.cdc +} + +// GetStore returns the x/clock module's store key. +func (k Keeper) GetStore() storetypes.StoreKey { + return k.storeKey +} diff --git a/x/clock/keeper/keeper_test.go b/x/clock/keeper/keeper_test.go index c0fcc6330..77b45d11a 100644 --- a/x/clock/keeper/keeper_test.go +++ b/x/clock/keeper/keeper_test.go @@ -1,14 +1,19 @@ package keeper_test import ( + "crypto/sha256" "testing" "time" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" "github.com/stretchr/testify/suite" + _ "embed" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" @@ -57,3 +62,76 @@ func (s *IntegrationTestSuite) FundAccount(ctx sdk.Context, addr sdk.AccAddress, func TestKeeperTestSuite(t *testing.T) { suite.Run(t, new(IntegrationTestSuite)) } + +//go:embed testdata/clock_example.wasm +var wasmContract []byte + +func (s *IntegrationTestSuite) StoreCode() { + _, _, sender := testdata.KeyTestPubAddr() + msg := wasmtypes.MsgStoreCodeFixture(func(m *wasmtypes.MsgStoreCode) { + m.WASMByteCode = wasmContract + m.Sender = sender.String() + }) + rsp, err := s.app.MsgServiceRouter().Handler(msg)(s.ctx, msg) + s.Require().NoError(err) + var result wasmtypes.MsgStoreCodeResponse + s.Require().NoError(s.app.AppCodec().Unmarshal(rsp.Data, &result)) + s.Require().Equal(uint64(1), result.CodeID) + expHash := sha256.Sum256(wasmContract) + s.Require().Equal(expHash[:], result.Checksum) + // and + info := s.app.AppKeepers.WasmKeeper.GetCodeInfo(s.ctx, 1) + s.Require().NotNil(info) + s.Require().Equal(expHash[:], info.CodeHash) + s.Require().Equal(sender.String(), info.Creator) + s.Require().Equal(wasmtypes.DefaultParams().InstantiateDefaultPermission.With(sender), info.InstantiateConfig) +} + +func (s *IntegrationTestSuite) InstantiateContract(sender string, admin string) string { + msgStoreCode := wasmtypes.MsgStoreCodeFixture(func(m *wasmtypes.MsgStoreCode) { + m.WASMByteCode = wasmContract + m.Sender = sender + }) + _, err := s.app.MsgServiceRouter().Handler(msgStoreCode)(s.ctx, msgStoreCode) + s.Require().NoError(err) + + msgInstantiate := wasmtypes.MsgInstantiateContractFixture(func(m *wasmtypes.MsgInstantiateContract) { + m.Sender = sender + m.Admin = admin + m.Msg = []byte(`{}`) + }) + resp, err := s.app.MsgServiceRouter().Handler(msgInstantiate)(s.ctx, msgInstantiate) + s.Require().NoError(err) + var result wasmtypes.MsgInstantiateContractResponse + s.Require().NoError(s.app.AppCodec().Unmarshal(resp.Data, &result)) + contractInfo := s.app.AppKeepers.WasmKeeper.GetContractInfo(s.ctx, sdk.MustAccAddressFromBech32(result.Address)) + s.Require().Equal(contractInfo.CodeID, uint64(1)) + s.Require().Equal(contractInfo.Admin, admin) + s.Require().Equal(contractInfo.Creator, sender) + + return result.Address +} + +// Helper method for quickly registering a clock contract +func (s *IntegrationTestSuite) RegisterClockContract(senderAddress string, contractAddress string) { + err := s.app.AppKeepers.ClockKeeper.RegisterContract(s.ctx, senderAddress, contractAddress) + s.Require().NoError(err) +} + +// Helper method for quickly unregistering a clock contract +func (s *IntegrationTestSuite) UnregisterClockContract(senderAddress string, contractAddress string) { + err := s.app.AppKeepers.ClockKeeper.UnregisterContract(s.ctx, senderAddress, contractAddress) + s.Require().NoError(err) +} + +// Helper method for quickly jailing a clock contract +func (s *IntegrationTestSuite) JailClockContract(contractAddress string) { + err := s.app.AppKeepers.ClockKeeper.SetJailStatus(s.ctx, contractAddress, true) + s.Require().NoError(err) +} + +// Helper method for quickly unjailing a clock contract +func (s *IntegrationTestSuite) UnjailClockContract(senderAddress string, contractAddress string) { + err := s.app.AppKeepers.ClockKeeper.SetJailStatusBySender(s.ctx, senderAddress, contractAddress, false) + s.Require().NoError(err) +} diff --git a/x/clock/keeper/msg_server.go b/x/clock/keeper/msg_server.go index 222eb04cc..634cb1cbd 100644 --- a/x/clock/keeper/msg_server.go +++ b/x/clock/keeper/msg_server.go @@ -25,6 +25,42 @@ func NewMsgServerImpl(k Keeper) types.MsgServer { } } +// RegisterClockContract handles incoming transactions to register clock contracts. +func (k msgServer) RegisterClockContract(goCtx context.Context, req *types.MsgRegisterClockContract) (*types.MsgRegisterClockContractResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // Validate request + if err := req.ValidateBasic(); err != nil { + return nil, err + } + + return &types.MsgRegisterClockContractResponse{}, k.RegisterContract(ctx, req.SenderAddress, req.ContractAddress) +} + +// UnregisterClockContract handles incoming transactions to unregister clock contracts. +func (k msgServer) UnregisterClockContract(goCtx context.Context, req *types.MsgUnregisterClockContract) (*types.MsgUnregisterClockContractResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // Validate request + if err := req.ValidateBasic(); err != nil { + return nil, err + } + + return &types.MsgUnregisterClockContractResponse{}, k.UnregisterContract(ctx, req.SenderAddress, req.ContractAddress) +} + +// UnjailClockContract handles incoming transactions to unjail clock contracts. +func (k msgServer) UnjailClockContract(goCtx context.Context, req *types.MsgUnjailClockContract) (*types.MsgUnjailClockContractResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // Validate request + if err := req.ValidateBasic(); err != nil { + return nil, err + } + + return &types.MsgUnjailClockContractResponse{}, k.SetJailStatusBySender(ctx, req.SenderAddress, req.ContractAddress, false) +} + func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { if k.authority != req.Authority { return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, req.Authority) diff --git a/x/clock/keeper/msg_server_test.go b/x/clock/keeper/msg_server_test.go index 9f13cfd36..fa02dc5f3 100644 --- a/x/clock/keeper/msg_server_test.go +++ b/x/clock/keeper/msg_server_test.go @@ -4,69 +4,320 @@ import ( _ "embed" "github.com/cosmos/cosmos-sdk/testutil/testdata" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/CosmosContracts/juno/v19/x/clock/types" ) -func (s *IntegrationTestSuite) TestUpdateClockParams() { +// Test register clock contract. +func (s *IntegrationTestSuite) TestRegisterClockContract() { _, _, addr := testdata.KeyTestPubAddr() _, _, addr2 := testdata.KeyTestPubAddr() + _ = s.FundAccount(s.ctx, addr, sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1_000_000)))) + + // Store code + s.StoreCode() + contractAddress := s.InstantiateContract(addr.String(), "") + contractAddressWithAdmin := s.InstantiateContract(addr.String(), addr2.String()) for _, tc := range []struct { - desc string - isEnabled bool - ContractAddresses []string - success bool + desc string + sender string + contract string + isJailed bool + success bool }{ { - desc: "Success - Valid on", - isEnabled: true, - ContractAddresses: []string{}, - success: true, + desc: "Success - Register Contract", + sender: addr.String(), + contract: contractAddress, + success: true, + }, + { + desc: "Success - Register Contract With Admin", + sender: addr2.String(), + contract: contractAddressWithAdmin, + success: true, }, { - desc: "Success - Valid off", - isEnabled: false, - ContractAddresses: []string{}, - success: true, + desc: "Fail - Register Contract With Admin, But With Creator Addr", + sender: addr.String(), + contract: contractAddressWithAdmin, + success: false, }, { - desc: "Success - On and 1 allowed address", - isEnabled: true, - ContractAddresses: []string{addr.String()}, - success: true, + desc: "Error - Invalid Sender", + sender: addr2.String(), + contract: contractAddress, + success: false, }, { - desc: "Fail - On and 2 duplicate addresses", - isEnabled: true, - ContractAddresses: []string{addr.String(), addr.String()}, - success: false, + desc: "Fail - Invalid Contract Address", + sender: addr.String(), + contract: "Invalid", + success: false, }, { - desc: "Success - On and 2 unique", - isEnabled: true, - ContractAddresses: []string{addr.String(), addr2.String()}, - success: true, + desc: "Fail - Invalid Sender Address", + sender: "Invalid", + contract: contractAddress, + success: false, }, { - desc: "Success - On and 2 duplicate 1 unique", - isEnabled: true, - ContractAddresses: []string{addr.String(), addr2.String(), addr.String()}, - success: false, + desc: "Fail - Contract Already Jailed", + sender: addr.String(), + contract: contractAddress, + isJailed: true, + success: false, }, } { tc := tc s.Run(tc.desc, func() { + // Set params params := types.DefaultParams() - params.ContractAddresses = tc.ContractAddresses + err := s.app.AppKeepers.ClockKeeper.SetParams(s.ctx, params) + s.Require().NoError(err) + + // Jail contract if needed + if tc.isJailed { + s.RegisterClockContract(tc.sender, tc.contract) + err := s.app.AppKeepers.ClockKeeper.SetJailStatus(s.ctx, tc.contract, true) + s.Require().NoError(err) + } + + // Try to register contract + res, err := s.clockMsgServer.RegisterClockContract(s.ctx, &types.MsgRegisterClockContract{ + SenderAddress: tc.sender, + ContractAddress: tc.contract, + }) + + if !tc.success { + s.Require().Error(err) + } else { + s.Require().NoError(err) + s.Require().Equal(res, &types.MsgRegisterClockContractResponse{}) + } + + // Ensure contract is unregistered + s.app.AppKeepers.ClockKeeper.RemoveContract(s.ctx, contractAddress) + s.app.AppKeepers.ClockKeeper.RemoveContract(s.ctx, contractAddressWithAdmin) + }) + } +} + +// Test standard unregistration of clock contracts. +func (s *IntegrationTestSuite) TestUnregisterClockContract() { + _, _, addr := testdata.KeyTestPubAddr() + _, _, addr2 := testdata.KeyTestPubAddr() + _ = s.FundAccount(s.ctx, addr, sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1_000_000)))) + + s.StoreCode() + contractAddress := s.InstantiateContract(addr.String(), "") + contractAddressWithAdmin := s.InstantiateContract(addr.String(), addr2.String()) + + for _, tc := range []struct { + desc string + sender string + contract string + success bool + }{ + { + desc: "Success - Unregister Contract", + sender: addr.String(), + contract: contractAddress, + success: true, + }, + { + desc: "Success - Unregister Contract With Admin", + sender: addr2.String(), + contract: contractAddressWithAdmin, + success: true, + }, + { + desc: "Fail - Unregister Contract With Admin, But With Creator Addr", + sender: addr.String(), + contract: contractAddressWithAdmin, + success: false, + }, + { + desc: "Error - Invalid Sender", + sender: addr2.String(), + contract: contractAddress, + success: false, + }, + { + desc: "Fail - Invalid Contract Address", + sender: addr.String(), + contract: "Invalid", + success: false, + }, + { + desc: "Fail - Invalid Sender Address", + sender: "Invalid", + contract: contractAddress, + success: false, + }, + } { + tc := tc + s.Run(tc.desc, func() { + s.RegisterClockContract(addr.String(), contractAddress) + s.RegisterClockContract(addr2.String(), contractAddressWithAdmin) + // Set params + params := types.DefaultParams() err := s.app.AppKeepers.ClockKeeper.SetParams(s.ctx, params) + s.Require().NoError(err) + + // Try to register all contracts + res, err := s.clockMsgServer.UnregisterClockContract(s.ctx, &types.MsgUnregisterClockContract{ + SenderAddress: tc.sender, + ContractAddress: tc.contract, + }) if !tc.success { s.Require().Error(err) } else { s.Require().NoError(err) + s.Require().Equal(res, &types.MsgUnregisterClockContractResponse{}) } + + // Ensure contract is unregistered + s.app.AppKeepers.ClockKeeper.RemoveContract(s.ctx, contractAddress) + s.app.AppKeepers.ClockKeeper.RemoveContract(s.ctx, contractAddressWithAdmin) + }) + } +} + +// Test duplicate register/unregister clock contracts. +func (s *IntegrationTestSuite) TestDuplicateRegistrationChecks() { + _, _, addr := testdata.KeyTestPubAddr() + _ = s.FundAccount(s.ctx, addr, sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1_000_000)))) + + s.StoreCode() + contractAddress := s.InstantiateContract(addr.String(), "") + + // Test double register, first succeed, second fail + _, err := s.clockMsgServer.RegisterClockContract(s.ctx, &types.MsgRegisterClockContract{ + SenderAddress: addr.String(), + ContractAddress: contractAddress, + }) + s.Require().NoError(err) + + _, err = s.clockMsgServer.RegisterClockContract(s.ctx, &types.MsgRegisterClockContract{ + SenderAddress: addr.String(), + ContractAddress: contractAddress, + }) + s.Require().Error(err) + + // Test double unregister, first succeed, second fail + _, err = s.clockMsgServer.UnregisterClockContract(s.ctx, &types.MsgUnregisterClockContract{ + SenderAddress: addr.String(), + ContractAddress: contractAddress, + }) + s.Require().NoError(err) + + _, err = s.clockMsgServer.UnregisterClockContract(s.ctx, &types.MsgUnregisterClockContract{ + SenderAddress: addr.String(), + ContractAddress: contractAddress, + }) + s.Require().Error(err) +} + +// Test unjailing clock contracts. +func (s *IntegrationTestSuite) TestUnjailClockContract() { + _, _, addr := testdata.KeyTestPubAddr() + _, _, addr2 := testdata.KeyTestPubAddr() + _ = s.FundAccount(s.ctx, addr, sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1_000_000)))) + + s.StoreCode() + contractAddress := s.InstantiateContract(addr.String(), "") + contractAddressWithAdmin := s.InstantiateContract(addr.String(), addr2.String()) + + for _, tc := range []struct { + desc string + sender string + contract string + unjail bool + success bool + }{ + { + desc: "Success - Unjail Contract", + sender: addr.String(), + contract: contractAddress, + success: true, + }, + { + desc: "Success - Unjail Contract With Admin", + sender: addr2.String(), + contract: contractAddressWithAdmin, + success: true, + }, + { + desc: "Fail - Unjail Contract With Admin, But With Creator Addr", + sender: addr.String(), + contract: contractAddressWithAdmin, + success: false, + }, + { + desc: "Error - Invalid Sender", + sender: addr2.String(), + contract: contractAddress, + success: false, + }, + { + desc: "Fail - Invalid Contract Address", + sender: addr.String(), + contract: "Invalid", + success: false, + }, + { + desc: "Fail - Invalid Sender Address", + sender: "Invalid", + contract: contractAddress, + success: false, + }, + { + desc: "Fail - Contract Not Jailed", + sender: addr.String(), + contract: contractAddress, + unjail: true, + success: false, + }, + } { + tc := tc + s.Run(tc.desc, func() { + s.RegisterClockContract(addr.String(), contractAddress) + s.JailClockContract(contractAddress) + s.RegisterClockContract(addr2.String(), contractAddressWithAdmin) + s.JailClockContract(contractAddressWithAdmin) + + // Unjail contract if needed + if tc.unjail { + s.UnjailClockContract(addr.String(), contractAddress) + s.UnjailClockContract(addr2.String(), contractAddressWithAdmin) + } + + // Set params + params := types.DefaultParams() + err := s.app.AppKeepers.ClockKeeper.SetParams(s.ctx, params) + s.Require().NoError(err) + + // Try to register all contracts + res, err := s.clockMsgServer.UnjailClockContract(s.ctx, &types.MsgUnjailClockContract{ + SenderAddress: tc.sender, + ContractAddress: tc.contract, + }) + + if !tc.success { + s.Require().Error(err) + } else { + s.Require().NoError(err) + s.Require().Equal(res, &types.MsgUnjailClockContractResponse{}) + } + + // Ensure contract is unregistered + s.app.AppKeepers.ClockKeeper.RemoveContract(s.ctx, contractAddress) + s.app.AppKeepers.ClockKeeper.RemoveContract(s.ctx, contractAddressWithAdmin) }) } } diff --git a/x/clock/keeper/querier.go b/x/clock/keeper/querier.go index 38975e78a..48b4bc642 100644 --- a/x/clock/keeper/querier.go +++ b/x/clock/keeper/querier.go @@ -21,13 +21,33 @@ func NewQuerier(k Keeper) Querier { } // ContractModules returns contract addresses which are using the clock -func (q Querier) ClockContracts(stdCtx context.Context, _ *types.QueryClockContracts) (*types.QueryClockContractsResponse, error) { +func (q Querier) ClockContracts(stdCtx context.Context, req *types.QueryClockContracts) (*types.QueryClockContractsResponse, error) { ctx := sdk.UnwrapSDKContext(stdCtx) - p := q.keeper.GetParams(ctx) + contracts, err := q.keeper.GetPaginatedContracts(ctx, req.Pagination) + if err != nil { + return nil, err + } + + return contracts, nil +} + +// ClockContract returns the clock contract information +func (q Querier) ClockContract(stdCtx context.Context, req *types.QueryClockContract) (*types.QueryClockContractResponse, error) { + ctx := sdk.UnwrapSDKContext(stdCtx) + + // Ensure the contract address is valid + if _, err := sdk.AccAddressFromBech32(req.ContractAddress); err != nil { + return nil, types.ErrInvalidAddress + } + + contract, err := q.keeper.GetClockContract(ctx, req.ContractAddress) + if err != nil { + return nil, err + } - return &types.QueryClockContractsResponse{ - ContractAddresses: p.ContractAddresses, + return &types.QueryClockContractResponse{ + ClockContract: *contract, }, nil } diff --git a/x/clock/keeper/querier_test.go b/x/clock/keeper/querier_test.go index 11d937225..7a34355ed 100644 --- a/x/clock/keeper/querier_test.go +++ b/x/clock/keeper/querier_test.go @@ -7,54 +7,228 @@ import ( "github.com/CosmosContracts/juno/v19/x/clock/types" ) -func (s *IntegrationTestSuite) TestClockQueryParams() { +// Query Clock Params +func (s *IntegrationTestSuite) TestQueryClockParams() { + for _, tc := range []struct { + desc string + params types.Params + }{ + { + desc: "On default", + params: types.DefaultParams(), + }, + { + desc: "On 500_000", + params: types.Params{ + ContractGasLimit: 500_000, + }, + }, + { + desc: "On 1_000_000", + params: types.Params{ + ContractGasLimit: 1_000_000, + }, + }, + } { + tc := tc + s.Run(tc.desc, func() { + // Set params + err := s.app.AppKeepers.ClockKeeper.SetParams(s.ctx, tc.params) + s.Require().NoError(err) + + // Query params + goCtx := sdk.WrapSDKContext(s.ctx) + resp, err := s.queryClient.Params(goCtx, &types.QueryParamsRequest{}) + + // Response check + s.Require().NoError(err) + s.Require().NotNil(resp) + s.Require().Equal(tc.params, *resp.Params) + }) + } +} + +// Query Clock Contracts +func (s *IntegrationTestSuite) TestQueryClockContracts() { _, _, addr := testdata.KeyTestPubAddr() - _, _, addr2 := testdata.KeyTestPubAddr() + _ = s.FundAccount(s.ctx, addr, sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1_000_000)))) - defaultParams := types.DefaultParams() + s.StoreCode() for _, tc := range []struct { - desc string - Expected types.Params + desc string + contracts []string }{ { - desc: "On empty", - Expected: types.Params{ - ContractAddresses: []string(nil), - ContractGasLimit: defaultParams.ContractGasLimit, - }, + desc: "On empty", + contracts: []string(nil), }, { - desc: "On 1 address", - Expected: types.Params{ - ContractAddresses: []string{addr.String()}, - ContractGasLimit: defaultParams.ContractGasLimit, + desc: "On Single", + contracts: []string{ + s.InstantiateContract(addr.String(), ""), }, }, { - desc: "On 2 Unique", - Expected: types.Params{ - ContractAddresses: []string{addr.String(), addr2.String()}, - ContractGasLimit: defaultParams.ContractGasLimit, + desc: "On Multiple", + contracts: []string{ + s.InstantiateContract(addr.String(), ""), + s.InstantiateContract(addr.String(), ""), + s.InstantiateContract(addr.String(), ""), }, }, } { tc := tc s.Run(tc.desc, func() { - // Set the params to what is expected, then query and ensure the query is the same - err := s.app.AppKeepers.ClockKeeper.SetParams(s.ctx, tc.Expected) - s.Require().NoError(err) + // Loop through contracts & register + for _, contract := range tc.contracts { + s.RegisterClockContract(addr.String(), contract) + } // Contracts check goCtx := sdk.WrapSDKContext(s.ctx) resp, err := s.queryClient.ClockContracts(goCtx, &types.QueryClockContracts{}) + + // Response check s.Require().NoError(err) - s.Require().Equal(tc.Expected.ContractAddresses, resp.ContractAddresses) + s.Require().NotNil(resp) + for _, contract := range resp.ClockContracts { + s.Require().Contains(tc.contracts, contract.ContractAddress) + s.Require().False(contract.IsJailed) + } + + // Remove all contracts + for _, contract := range tc.contracts { + s.app.AppKeepers.ClockKeeper.RemoveContract(s.ctx, contract) + } + }) + } +} + +// Query Jailed Clock Contracts +func (s *IntegrationTestSuite) TestQueryJailedClockContracts() { + _, _, addr := testdata.KeyTestPubAddr() + _ = s.FundAccount(s.ctx, addr, sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1_000_000)))) + + s.StoreCode() + + for _, tc := range []struct { + desc string + contracts []string + }{ + { + desc: "On empty", + contracts: []string(nil), + }, + { + desc: "On Single", + contracts: []string{ + s.InstantiateContract(addr.String(), ""), + }, + }, + { + desc: "On Multiple", + contracts: []string{ + s.InstantiateContract(addr.String(), ""), + s.InstantiateContract(addr.String(), ""), + s.InstantiateContract(addr.String(), ""), + }, + }, + } { + tc := tc + s.Run(tc.desc, func() { + // Loop through contracts & register + for _, contract := range tc.contracts { + s.RegisterClockContract(addr.String(), contract) + s.JailClockContract(contract) + } - // All Params Check - resp2, err := s.queryClient.Params(goCtx, &types.QueryParamsRequest{}) + // Contracts check + goCtx := sdk.WrapSDKContext(s.ctx) + resp, err := s.queryClient.ClockContracts(goCtx, &types.QueryClockContracts{}) + + // Response check s.Require().NoError(err) - s.Require().Equal(tc.Expected, *resp2.Params) + s.Require().NotNil(resp) + for _, contract := range resp.ClockContracts { + s.Require().Contains(tc.contracts, contract.ContractAddress) + s.Require().True(contract.IsJailed) + } + + // Remove all contracts + for _, contract := range tc.contracts { + s.app.AppKeepers.ClockKeeper.RemoveContract(s.ctx, contract) + } + }) + } +} + +// Query Clock Contract +func (s *IntegrationTestSuite) TestQueryClockContract() { + _, _, addr := testdata.KeyTestPubAddr() + _ = s.FundAccount(s.ctx, addr, sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1_000_000)))) + _, _, invalidAddr := testdata.KeyTestPubAddr() + + s.StoreCode() + + unjailedContract := s.InstantiateContract(addr.String(), "") + _ = s.app.AppKeepers.ClockKeeper.SetClockContract(s.ctx, types.ClockContract{ + ContractAddress: unjailedContract, + IsJailed: false, + }) + + jailedContract := s.InstantiateContract(addr.String(), "") + _ = s.app.AppKeepers.ClockKeeper.SetClockContract(s.ctx, types.ClockContract{ + ContractAddress: jailedContract, + IsJailed: true, + }) + + for _, tc := range []struct { + desc string + contract string + isJailed bool + success bool + }{ + { + desc: "On Unjailed", + contract: unjailedContract, + isJailed: false, + success: true, + }, + { + desc: "On Jailed", + contract: jailedContract, + isJailed: true, + success: true, + }, + { + desc: "Invalid Contract - Unjailed", + contract: invalidAddr.String(), + isJailed: false, + success: false, + }, + { + desc: "Invalid Contract - Jailed", + contract: invalidAddr.String(), + isJailed: true, + success: false, + }, + } { + tc := tc + s.Run(tc.desc, func() { + // Query contract + resp, err := s.queryClient.ClockContract(s.ctx, &types.QueryClockContract{ + ContractAddress: tc.contract, + }) + + // Validate responses + if tc.success { + s.Require().NoError(err) + s.Require().Equal(resp.ClockContract.ContractAddress, tc.contract) + s.Require().Equal(resp.ClockContract.IsJailed, tc.isJailed) + } else { + s.Require().Error(err) + } }) } } diff --git a/x/clock/keeper/testdata/clock_example.wasm b/x/clock/keeper/testdata/clock_example.wasm new file mode 100644 index 000000000..e2d99f71c Binary files /dev/null and b/x/clock/keeper/testdata/clock_example.wasm differ diff --git a/x/clock/keeper/testdata/cw_testburn.wasm b/x/clock/keeper/testdata/cw_testburn.wasm new file mode 100644 index 000000000..4b47f3623 Binary files /dev/null and b/x/clock/keeper/testdata/cw_testburn.wasm differ diff --git a/x/clock/module.go b/x/clock/module.go index 909971fd1..cfac70574 100644 --- a/x/clock/module.go +++ b/x/clock/module.go @@ -75,7 +75,7 @@ func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux } func (a AppModuleBasic) GetTxCmd() *cobra.Command { - return nil + return cli.NewTxCmd() } func (a AppModuleBasic) GetQueryCmd() *cobra.Command { @@ -115,8 +115,7 @@ func (a AppModule) InitGenesis(ctx sdk.Context, marshaler codec.JSONCodec, messa } func (a AppModule) ExportGenesis(ctx sdk.Context, marshaler codec.JSONCodec) json.RawMessage { - params := a.keeper.GetParams(ctx) - genState := NewGenesisState(params) + genState := ExportGenesis(ctx, a.keeper) return marshaler.MustMarshalJSON(genState) } diff --git a/x/clock/spec/01_authorization.md b/x/clock/spec/01_authorization.md deleted file mode 100644 index 9115e17a2..000000000 --- a/x/clock/spec/01_authorization.md +++ /dev/null @@ -1,39 +0,0 @@ -# Authorization - -For security purposes, only the governance module can add new contracts to the EndBlocker executes. - -## Query contracts - -You can query the list of contracts that are 'ticked' every block with the following command: - -```bash - junod q clock contracts --output json - # {"contract_addresses":[]} -``` - -## Governance proposal - -To update the authorized address is possible to create an onchain new proposal. You can use the following example `proposal.json` file - -```json -{ - "messages": [ - { - "@type": "/juno.clock.v1.MsgUpdateParams", - "authority": "juno10d07y265gmmuvt4z0w9aw880jnsr700jvss730", - "params": { - "contract_addresses": [ - "juno14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9skjuwg8" - ], - "contract_gas_limit": "1000000" - } - } - ], - "metadata": "{\"title\": \"Allow a new contract to use the x/clock module for our features\", \"authors\": [\"Reece\"], \"summary\": \"If this proposal passes juno14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9skjuwg8 will be added to the authorized addresses of the clock module\", \"details\": \"If this proposal passes juno14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9skjuwg8 will be added to the authorized addresses of the clock module\", \"proposal_forum_url\": \"https://commonwealth.im/juno/discussion/9697-juno-protocol-level-defi-incentives\", \"vote_option_context\": \"yes\"}", - "deposit": "1000000ujuno", - "title": "Allow a new contract to use the x/clock module for our features", - "summary": "If this proposal passes juno14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9skjuwg8 will be allowed to use the x/clock module to perform XYZ actions" -} -``` - -It can be submitted with the standard `junod tx gov submit-proposal proposal.json --from=YOURKEY` command. diff --git a/x/clock/spec/01_concepts.md b/x/clock/spec/01_concepts.md new file mode 100644 index 000000000..8a9ada6f3 --- /dev/null +++ b/x/clock/spec/01_concepts.md @@ -0,0 +1,45 @@ + + +# Concepts + +## Clock + +The Clock module allows registered contracts to be executed at the end of every block. This allows the smart contract to perform regular and routine actions without the need for external bots. Developers can setup their contract with x/Clock by registering their contract with the module. Once registered, the contract will be executed at the end of every block. If the contract throws an error during execution or exceeds the gas limit defined in the module's parameters, the contract will be jailed and no longer executed. The contract can be unjailed by the contract admin. + +## Registering a Contract + +Register a contract with x/Clock by executing the following transaction: + +```bash +junod tx clock register [contract_address] +``` + +> Note: the sender of this transaction must be the contract admin, if exists, or else the contract creator. + +The `contract_address` is the bech32 address of the contract to be executed at the end of every block. Once registered, the contract will be executed at the end of every block. Please ensure that your contract follows the guidelines outlined in [Integration](03_integration.md). + +## Unjailing a Contract + +A contract can be unjailed by executing the following transaction: + +```bash +junod tx clock unjail [contract_address] +``` + +> Note: the sender of this transaction must be the contract admin, if exists, or else the contract creator. + +The `contract_address` is the bech32 address of the contract to be unjailed. Unjailing a contract will allow it to be executed at the end of every block. If your contract becomes jailed, please see [Integration](03_integration.md) to ensure the contract is setup with a Sudo message. + +## Unregistering a Contract + +A contract can be unregistered by executing the following transaction: + +```bash +junod tx clock unregister [contract_address] +``` + +> Note: the sender of this transaction must be the contract admin, if exists, or else the contract creator. + +The `contract_address` is the bech32 address of the contract to be unregistered. Unregistering a contract will remove it from the Clock module. This means that the contract will no longer be executed at the end of every block. \ No newline at end of file diff --git a/x/clock/spec/02_integration.md b/x/clock/spec/02_integration.md deleted file mode 100644 index fa7646339..000000000 --- a/x/clock/spec/02_integration.md +++ /dev/null @@ -1,56 +0,0 @@ -# CosmWasm Integration - -This module does not require any custom bindings. Rather, you must just add the following Sudo message to your contract. If your contract is not whitelisted, you can still upload it to the chain. However, to get it to execute, you must submit a proposal to add your contract to the whitelist. - -You can find a basic [cw-clock contract here](https://github.com/Reecepbcups/cw-clock-example) - -## Implementation - -Add the following to your Rust Contract: - -```rust -// msg.rs -#[cw_serde] -pub enum SudoMsg { - ClockEndBlock { }, -} - -// contract.rs -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn sudo(deps: DepsMut, _env: Env, msg: SudoMsg) -> Result { - match msg { - SudoMsg::ClockEndBlock { } => { - let mut config = CONFIG.load(deps.storage)?; - config.val += 1; - CONFIG.save(deps.storage, &config)?; - - Ok(Response::new()) - } - } -} -``` - -Using the above example, for every block the module will increase the `val` Config variable by 1. This is a simple example, but you can use this to perform any action you want (ex: cleanup, auto compounding, etc). - -If you wish not to have your action performed every block, you can use the `env` variable in the Sudo message to check the block height and only perform an action every X blocks. - -```rust -// contract.rs -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn sudo(deps: DepsMut, env: Env, msg: SudoMsg) -> Result { - match msg { - SudoMsg::ClockEndBlock { } => { - // If the block is not divisible by ten, do nothing. - if env.block.height % 10 != 0 { - return Ok(Response::new()); - } - - let mut config = CONFIG.load(deps.storage)?; - config.val += 1; - CONFIG.save(deps.storage, &config)?; - - Ok(Response::new()) - } - } -} -``` diff --git a/x/clock/spec/02_state.md b/x/clock/spec/02_state.md new file mode 100644 index 000000000..11da3d5a1 --- /dev/null +++ b/x/clock/spec/02_state.md @@ -0,0 +1,53 @@ + + +# State + +## State Objects + +The `x/clock` module only manages the following object in state: ClockContract. This object is used to store the address of the contract and its jail status. The jail status is used to determine if the contract should be executed at the end of every block. If the contract is jailed, it will not be executed. + +```go +// This object is used to store the contract address and the +// jail status of the contract. +message ClockContract { + // The address of the contract. + string contract_address = 1; + // The jail status of the contract. + bool is_jailed = 2; +} +``` + +## Genesis & Params + +The `x/clock` module's `GenesisState` defines the state necessary for initializing the chain from a previously exported height. It simply contains the gas limit parameter which is used to determine the maximum amount of gas that can be used by a contract. This value can be modified with a governance proposal. + +```go +// GenesisState - initial state of module +message GenesisState { + // Params of this module + Params params = 1 [ + (gogoproto.nullable) = false, + (gogoproto.jsontag) = "params,omitempty" + ]; +} + +// Params defines the set of module parameters. +message Params { + // contract_gas_limit defines the maximum amount of gas that can be used by a contract. + uint64 contract_gas_limit = 1 [ + (gogoproto.jsontag) = "contract_gas_limit,omitempty", + (gogoproto.moretags) = "yaml:\"contract_gas_limit\"" + ]; +} +``` + +## State Transitions + +The following state transitions are possible: + +- Register a contract creates a new ClockContract object in state. +- Jailing a contract updates the is_jailed field of a ClockContract object in state. +- Unjailing a contract updates the is_jailed field of a ClockContract object in state. +- Unregister a contract deletes a ClockContract object from state. \ No newline at end of file diff --git a/x/clock/spec/03_integration.md b/x/clock/spec/03_integration.md new file mode 100644 index 000000000..a7031d534 --- /dev/null +++ b/x/clock/spec/03_integration.md @@ -0,0 +1,91 @@ + + +# CosmWasm Integration + +This `x/clock` module does not require any custom bindings. Rather, you must add a Sudo message to your contract. If your contract does not implement this Sudo message, it will be jailed. Please review the following sections below for more information. + +> Note: you can find a basic [cw-clock contract here](https://github.com/Reecepbcups/cw-clock-example). + +## Implementation + +To satisfy the module's requirements, add the following message and entry point to your contract: + +```rust +// msg.rs +#[cw_serde] +pub enum SudoMsg { + ClockEndBlock { }, +} + +// contract.rs +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn sudo(deps: DepsMut, _env: Env, msg: SudoMsg) -> Result { + match msg { + SudoMsg::ClockEndBlock { } => { + + // TODO: PERFORM LOGIC HERE + + Ok(Response::new()) + } + } +} +``` + +At the end of every block, registered contracts will execute the `ClockEndBlock` Sudo message. This is where all of the contract's custom end block logic can be performed. Please keep in mind that contracts which exceed the gas limit specified in the params will be jailed. + +## Examples + +In the example below, at the end of every block the `val` Config variable will increase by 1. This is a simple example, but one can extrapolate upon this idea and perform actions such as cleanup, auto compounding, etc. + +```rust +// msg.rs +#[cw_serde] +pub enum SudoMsg { + ClockEndBlock { }, +} + +// contract.rs +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn sudo(deps: DepsMut, _env: Env, msg: SudoMsg) -> Result { + match msg { + SudoMsg::ClockEndBlock { } => { + let mut config = CONFIG.load(deps.storage)?; + config.val += 1; + CONFIG.save(deps.storage, &config)?; + + Ok(Response::new()) + } + } +} +``` + +To perform an action occasionally rather than every block, use the `env` variable in the Sudo message to check the block height and then perform logic accordingly. The contract below will only increase the `val` Config variable by 1 if the block height is divisible by 10. + +```rust +// msg.rs +#[cw_serde] +pub enum SudoMsg { + ClockEndBlock { }, +} + +// contract.rs +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn sudo(deps: DepsMut, env: Env, msg: SudoMsg) -> Result { + match msg { + SudoMsg::ClockEndBlock { } => { + // If the block is not divisible by ten, do nothing. + if env.block.height % 10 != 0 { + return Ok(Response::new()); + } + + let mut config = CONFIG.load(deps.storage)?; + config.val += 1; + CONFIG.save(deps.storage, &config)?; + + Ok(Response::new()) + } + } +} +``` diff --git a/x/clock/spec/04_clients.md b/x/clock/spec/04_clients.md new file mode 100644 index 000000000..58ec871d4 --- /dev/null +++ b/x/clock/spec/04_clients.md @@ -0,0 +1,25 @@ + + +# Clients + +## Command Line Interface (CLI) + +The CLI has been updated with new queries and transactions for the `x/clock` module. View the entire list below. + +### Queries + +| Command | Subcommand | Arguments | Description | +| :------------------ | :---------- | :----------------- | :---------------------- | +| `junod query clock` | `params` | | Get Clock params | +| `junod query clock` | `contract` | [contract_address] | Get a Clock contract | +| `junod query clock` | `contracts` | | Get all Clock contracts | + +### Transactions + +| Command | Subcommand | Arguments | Description | +| :--------------- | :----------- | :----------------- | :-------------------------- | +| `junod tx clock` | `register` | [contract_address] | Register a Clock contract | +| `junod tx clock` | `unjail` | [contract_address] | Unjail a Clock contract | +| `junod tx clock` | `unregister` | [contract_address] | Unregister a Clock contract | \ No newline at end of file diff --git a/x/clock/spec/README.md b/x/clock/spec/README.md index 982d7ec3e..735d8ae0a 100644 --- a/x/clock/spec/README.md +++ b/x/clock/spec/README.md @@ -4,11 +4,13 @@ This document specifies the internal `x/clock` module of Juno Network. -The `x/clock` module allows specific contracts to be executed at the end of every block. This allows the smart contract to perform actions that may need to happen every block, or at set block intervals. +The `x/clock` module allows specific contracts to be executed at the end of every block. This allows the smart contract to perform actions that may need to happen every block or at set block intervals. By using this module, your application can remove the headache of external whitelisted bots and instead depend on the chain itself for constant executions. ## Contents -1. **[Authorization](01_authorization.md)** -2. **[Contract Integration](02_integration.md)** +1. **[Concepts](01_concepts.md)** +2. **[State](02_state.md)** +3. **[Contract Integration](03_integration.md)** +4. **[Clients](04_clients.md)** diff --git a/x/clock/types/clock.pb.go b/x/clock/types/clock.pb.go new file mode 100644 index 000000000..4dc2be186 --- /dev/null +++ b/x/clock/types/clock.pb.go @@ -0,0 +1,361 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: juno/clock/v1/clock.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// This object is used to store the contract address and the +// jail status of the contract. +type ClockContract struct { + // The address of the contract. + ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` + // The jail status of the contract. + IsJailed bool `protobuf:"varint,2,opt,name=is_jailed,json=isJailed,proto3" json:"is_jailed,omitempty"` +} + +func (m *ClockContract) Reset() { *m = ClockContract{} } +func (m *ClockContract) String() string { return proto.CompactTextString(m) } +func (*ClockContract) ProtoMessage() {} +func (*ClockContract) Descriptor() ([]byte, []int) { + return fileDescriptor_ae7dc6f78089f30c, []int{0} +} +func (m *ClockContract) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ClockContract) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ClockContract.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 *ClockContract) XXX_Merge(src proto.Message) { + xxx_messageInfo_ClockContract.Merge(m, src) +} +func (m *ClockContract) XXX_Size() int { + return m.Size() +} +func (m *ClockContract) XXX_DiscardUnknown() { + xxx_messageInfo_ClockContract.DiscardUnknown(m) +} + +var xxx_messageInfo_ClockContract proto.InternalMessageInfo + +func (m *ClockContract) GetContractAddress() string { + if m != nil { + return m.ContractAddress + } + return "" +} + +func (m *ClockContract) GetIsJailed() bool { + if m != nil { + return m.IsJailed + } + return false +} + +func init() { + proto.RegisterType((*ClockContract)(nil), "juno.clock.v1.ClockContract") +} + +func init() { proto.RegisterFile("juno/clock/v1/clock.proto", fileDescriptor_ae7dc6f78089f30c) } + +var fileDescriptor_ae7dc6f78089f30c = []byte{ + // 190 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcc, 0x2a, 0xcd, 0xcb, + 0xd7, 0x4f, 0xce, 0xc9, 0x4f, 0xce, 0xd6, 0x2f, 0x33, 0x84, 0x30, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, + 0xf2, 0x85, 0x78, 0x41, 0x52, 0x7a, 0x10, 0x91, 0x32, 0x43, 0xa5, 0x70, 0x2e, 0x5e, 0x67, 0x10, + 0xdb, 0x39, 0x3f, 0xaf, 0xa4, 0x28, 0x31, 0xb9, 0x44, 0x48, 0x93, 0x4b, 0x20, 0x19, 0xca, 0x8e, + 0x4f, 0x4c, 0x49, 0x29, 0x4a, 0x2d, 0x2e, 0x96, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0xe2, 0x87, + 0x89, 0x3b, 0x42, 0x84, 0x85, 0xa4, 0xb9, 0x38, 0x33, 0x8b, 0xe3, 0xb3, 0x12, 0x33, 0x73, 0x52, + 0x53, 0x24, 0x98, 0x14, 0x18, 0x35, 0x38, 0x82, 0x38, 0x32, 0x8b, 0xbd, 0xc0, 0x7c, 0x27, 0xf7, + 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, + 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0xd2, 0x4d, 0xcf, 0x2c, 0xc9, 0x28, + 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x77, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0x86, 0x59, 0x5e, 0xac, + 0x0f, 0x76, 0x77, 0x05, 0xd4, 0xe5, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x77, 0x1b, + 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x0e, 0xd7, 0x4c, 0x19, 0xd4, 0x00, 0x00, 0x00, +} + +func (m *ClockContract) 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 *ClockContract) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ClockContract) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.IsJailed { + i-- + if m.IsJailed { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if len(m.ContractAddress) > 0 { + i -= len(m.ContractAddress) + copy(dAtA[i:], m.ContractAddress) + i = encodeVarintClock(dAtA, i, uint64(len(m.ContractAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintClock(dAtA []byte, offset int, v uint64) int { + offset -= sovClock(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ClockContract) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ContractAddress) + if l > 0 { + n += 1 + l + sovClock(uint64(l)) + } + if m.IsJailed { + n += 2 + } + return n +} + +func sovClock(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozClock(x uint64) (n int) { + return sovClock(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ClockContract) 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 ErrIntOverflowClock + } + 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: ClockContract: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ClockContract: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowClock + } + 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 ErrInvalidLengthClock + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthClock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ContractAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsJailed", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowClock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsJailed = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipClock(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthClock + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipClock(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowClock + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowClock + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowClock + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthClock + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupClock + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthClock + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthClock = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowClock = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupClock = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/clock/types/codec.go b/x/clock/types/codec.go index 88c0a05f8..bad84425f 100644 --- a/x/clock/types/codec.go +++ b/x/clock/types/codec.go @@ -2,7 +2,6 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -30,13 +29,18 @@ func init() { // RegisterLegacyAminoCodec registers concrete types on the LegacyAmino codec func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(Params{}, "juno/x/clock/Params", nil) - legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "juno/x/clock/MsgUpdateParams") + cdc.RegisterConcrete(&MsgRegisterClockContract{}, "clock/MsgRegisterClockContract", nil) + cdc.RegisterConcrete(&MsgUnregisterClockContract{}, "clock/MsgUnregisterClockContract", nil) + cdc.RegisterConcrete(&MsgUnjailClockContract{}, "clock/MsgUnjailClockContract", nil) + cdc.RegisterConcrete(&MsgUpdateParams{}, "clock/MsgUpdateParams", nil) } func RegisterInterfaces(registry types.InterfaceRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), + &MsgRegisterClockContract{}, + &MsgUnregisterClockContract{}, + &MsgUnjailClockContract{}, &MsgUpdateParams{}, ) diff --git a/x/clock/types/codec_test.go b/x/clock/types/codec_test.go index a794ac4ce..120d534da 100644 --- a/x/clock/types/codec_test.go +++ b/x/clock/types/codec_test.go @@ -23,8 +23,11 @@ func (suite *CodecTestSuite) TestRegisterInterfaces() { RegisterInterfaces(registry) impls := registry.ListImplementations(sdk.MsgInterfaceProtoName) - suite.Require().Equal(1, len(impls)) + suite.Require().Equal(4, len(impls)) suite.Require().ElementsMatch([]string{ "/juno.clock.v1.MsgUpdateParams", + "/juno.clock.v1.MsgRegisterClockContract", + "/juno.clock.v1.MsgUnregisterClockContract", + "/juno.clock.v1.MsgUnjailClockContract", }, impls) } diff --git a/x/clock/types/errors.go b/x/clock/types/errors.go new file mode 100644 index 000000000..ea3adc307 --- /dev/null +++ b/x/clock/types/errors.go @@ -0,0 +1,22 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +var ( + ErrInvalidAddress = sdkerrors.ErrInvalidAddress + ErrContractNotRegistered = errorsmod.Register(ModuleName, 1, "contract not registered") + ErrContractAlreadyRegistered = errorsmod.Register(ModuleName, 2, "contract already registered") + ErrContractRegisterNotAdmin = errorsmod.Register(ModuleName, 3, "this address is not the contract admin, cannot register") + ErrContractNotAdmin = errorsmod.Register(ModuleName, 4, "sender is not the contract admin") + ErrContractNotCreator = errorsmod.Register(ModuleName, 5, "sender is not the contract creator") + ErrContractJailed = errorsmod.Register(ModuleName, 6, "contract is jailed") + ErrContractNotJailed = errorsmod.Register(ModuleName, 7, "contract is not jailed") + ErrContractAlreadyJailed = errorsmod.Register(ModuleName, 8, "contract is already jailed") + ErrInvalidCWContract = errorsmod.Register(ModuleName, 9, "invalid CosmWasm contract") + ErrOutOfGas = errorsmod.Register(ModuleName, 10, "contract execution ran out of gas") + ErrContractExecutionPanic = errorsmod.Register(ModuleName, 11, "contract execution panicked") +) diff --git a/x/clock/types/genesis.pb.go b/x/clock/types/genesis.pb.go index 4d8ecce3b..ecc8feeb2 100644 --- a/x/clock/types/genesis.pb.go +++ b/x/clock/types/genesis.pb.go @@ -72,9 +72,8 @@ func (m *GenesisState) GetParams() Params { // Params defines the set of module parameters. type Params struct { - // contract_addresses stores the list of executable contracts to be ticked on every block. - ContractAddresses []string `protobuf:"bytes,1,rep,name=contract_addresses,json=contractAddresses,proto3" json:"contract_addresses,omitempty" yaml:"contract_addresses"` - ContractGasLimit uint64 `protobuf:"varint,2,opt,name=contract_gas_limit,json=contractGasLimit,proto3" json:"contract_gas_limit,omitempty" yaml:"contract_gas_limit"` + // contract_gas_limit defines the maximum amount of gas that can be used by a contract. + ContractGasLimit uint64 `protobuf:"varint,1,opt,name=contract_gas_limit,json=contractGasLimit,proto3" json:"contract_gas_limit,omitempty" yaml:"contract_gas_limit"` } func (m *Params) Reset() { *m = Params{} } @@ -110,13 +109,6 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo -func (m *Params) GetContractAddresses() []string { - if m != nil { - return m.ContractAddresses - } - return nil -} - func (m *Params) GetContractGasLimit() uint64 { if m != nil { return m.ContractGasLimit @@ -132,28 +124,26 @@ func init() { func init() { proto.RegisterFile("juno/clock/v1/genesis.proto", fileDescriptor_c31a7855fe794abe) } var fileDescriptor_c31a7855fe794abe = []byte{ - // 329 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0x3f, 0x4b, 0xc3, 0x40, - 0x18, 0xc6, 0x73, 0x2a, 0x05, 0xa3, 0x42, 0x0d, 0x0a, 0xb5, 0xca, 0xa5, 0x64, 0xea, 0xa0, 0x39, - 0xa2, 0x9b, 0xe0, 0x60, 0x3b, 0x64, 0x71, 0x90, 0x3a, 0x08, 0x2e, 0xe5, 0x72, 0x3d, 0x62, 0x6c, - 0x2e, 0x17, 0xf2, 0x5e, 0x8b, 0xfd, 0x16, 0x7e, 0xac, 0x8e, 0x1d, 0x9d, 0x82, 0x34, 0x5b, 0x47, - 0x3f, 0x81, 0xe4, 0xd2, 0xd6, 0x3f, 0x05, 0xb7, 0x97, 0xe7, 0xf7, 0xbc, 0xcf, 0x33, 0x3c, 0xe6, - 0xe9, 0xcb, 0x28, 0x91, 0x84, 0xc5, 0x92, 0x0d, 0xc9, 0xd8, 0x23, 0x21, 0x4f, 0x38, 0x44, 0xe0, - 0xa6, 0x99, 0x54, 0xd2, 0x3a, 0x28, 0xa1, 0xab, 0xa1, 0x3b, 0xf6, 0x9a, 0x47, 0xa1, 0x0c, 0xa5, - 0x26, 0xa4, 0xbc, 0x2a, 0x53, 0x13, 0x33, 0x09, 0x42, 0x02, 0x09, 0x28, 0x70, 0x32, 0xf6, 0x02, - 0xae, 0xa8, 0x47, 0x98, 0x8c, 0x92, 0x8a, 0x3b, 0x8f, 0xe6, 0xbe, 0x5f, 0xa5, 0x3e, 0x28, 0xaa, - 0xb8, 0xe5, 0x9b, 0xb5, 0x94, 0x66, 0x54, 0x40, 0x03, 0xb5, 0x50, 0x7b, 0xef, 0xf2, 0xd8, 0xfd, - 0xd5, 0xe2, 0xde, 0x6b, 0xd8, 0x69, 0x4c, 0x73, 0xdb, 0x58, 0xe4, 0x76, 0xbd, 0x32, 0x9f, 0x4b, - 0x11, 0x29, 0x2e, 0x52, 0x35, 0xe9, 0x2d, 0xdf, 0x9d, 0x02, 0x99, 0xb5, 0xca, 0x6c, 0xc5, 0xa6, - 0xc5, 0x64, 0xa2, 0x32, 0xca, 0x54, 0x9f, 0x0e, 0x06, 0x19, 0x07, 0xe0, 0x65, 0xfe, 0x76, 0x7b, - 0xb7, 0x73, 0xb3, 0xc8, 0xed, 0xb3, 0x4d, 0xfa, 0x1d, 0xf8, 0x99, 0xdb, 0x27, 0x13, 0x2a, 0xe2, - 0x6b, 0x67, 0xd3, 0xe5, 0xf4, 0x0e, 0x57, 0xe2, 0xed, 0x4a, 0xb3, 0x86, 0x3f, 0xda, 0x42, 0x0a, - 0xfd, 0x38, 0x12, 0x91, 0x6a, 0x6c, 0xb5, 0x50, 0x7b, 0xe7, 0x4f, 0xdb, 0x9a, 0xfe, 0xdb, 0xb6, - 0x76, 0x39, 0xbd, 0xfa, 0x4a, 0xf4, 0x29, 0xdc, 0x95, 0x52, 0xc7, 0x9f, 0xce, 0x31, 0x9a, 0xcd, - 0x31, 0xfa, 0x98, 0x63, 0xf4, 0x56, 0x60, 0x63, 0x56, 0x60, 0xe3, 0xbd, 0xc0, 0xc6, 0xd3, 0x45, - 0x18, 0xa9, 0xe7, 0x51, 0xe0, 0x32, 0x29, 0x48, 0x57, 0x6f, 0xd0, 0x5d, 0x3e, 0x03, 0xd1, 0xab, - 0xbe, 0x2e, 0x77, 0x55, 0x93, 0x94, 0x43, 0x50, 0xd3, 0x73, 0x5c, 0x7d, 0x05, 0x00, 0x00, 0xff, - 0xff, 0xe7, 0x62, 0x4a, 0xd0, 0xf2, 0x01, 0x00, 0x00, + // 301 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x90, 0x31, 0x4b, 0xf3, 0x40, + 0x18, 0xc7, 0x13, 0x78, 0xe9, 0x90, 0x57, 0xa1, 0x04, 0x85, 0xb6, 0xca, 0x45, 0x32, 0x39, 0xe8, + 0x1d, 0xd1, 0x4d, 0x70, 0x69, 0x87, 0x2c, 0x0e, 0x52, 0x07, 0xc1, 0xa5, 0x5c, 0x8e, 0x23, 0x9e, + 0xcd, 0xe5, 0x09, 0xb9, 0x4b, 0x30, 0xdf, 0xc2, 0x8f, 0xd5, 0xb1, 0xa3, 0x53, 0x90, 0x64, 0xeb, + 0xe8, 0x27, 0x90, 0x5c, 0x22, 0x52, 0xba, 0x1d, 0xcf, 0xef, 0xff, 0xfc, 0x9f, 0xe3, 0xe7, 0x9c, + 0xbd, 0x15, 0x29, 0x10, 0x96, 0x00, 0x5b, 0x93, 0x32, 0x20, 0x31, 0x4f, 0xb9, 0x12, 0x0a, 0x67, + 0x39, 0x68, 0x70, 0x8f, 0x3b, 0x88, 0x0d, 0xc4, 0x65, 0x30, 0x3b, 0x89, 0x21, 0x06, 0x43, 0x48, + 0xf7, 0xea, 0x43, 0x33, 0xc4, 0x40, 0x49, 0x50, 0x24, 0xa2, 0x8a, 0x93, 0x32, 0x88, 0xb8, 0xa6, + 0x01, 0x61, 0x20, 0xd2, 0x81, 0x4f, 0xf7, 0x2f, 0xf4, 0x6d, 0x06, 0xf9, 0xcf, 0xce, 0x51, 0xd8, + 0x1f, 0x7c, 0xd2, 0x54, 0x73, 0x37, 0x74, 0x46, 0x19, 0xcd, 0xa9, 0x54, 0x13, 0xfb, 0xc2, 0xbe, + 0xfc, 0x7f, 0x73, 0x8a, 0xf7, 0x3e, 0x80, 0x1f, 0x0d, 0x9c, 0x4f, 0x36, 0xb5, 0x67, 0xed, 0x6a, + 0x6f, 0xdc, 0x87, 0xaf, 0x40, 0x0a, 0xcd, 0x65, 0xa6, 0xab, 0xe5, 0xb0, 0xee, 0x17, 0xce, 0xa8, + 0xcf, 0xba, 0x6b, 0xc7, 0x65, 0x90, 0xea, 0x9c, 0x32, 0xbd, 0x8a, 0xa9, 0x5a, 0x25, 0x42, 0x0a, + 0x6d, 0xea, 0xff, 0xcd, 0xef, 0x77, 0xb5, 0x77, 0x7e, 0x48, 0xff, 0xfa, 0xbe, 0x6b, 0x6f, 0x5a, + 0x51, 0x99, 0xdc, 0xf9, 0x87, 0x29, 0x7f, 0x39, 0xfe, 0x1d, 0x86, 0x54, 0x3d, 0x74, 0xa3, 0x79, + 0xb8, 0x69, 0x90, 0xbd, 0x6d, 0x90, 0xfd, 0xd5, 0x20, 0xfb, 0xa3, 0x45, 0xd6, 0xb6, 0x45, 0xd6, + 0x67, 0x8b, 0xac, 0x97, 0xeb, 0x58, 0xe8, 0xd7, 0x22, 0xc2, 0x0c, 0x24, 0x59, 0x18, 0x5f, 0x8b, + 0x61, 0x59, 0x11, 0xe3, 0xe7, 0x7d, 0x30, 0xa4, 0xab, 0x8c, 0xab, 0x68, 0x64, 0xfc, 0xdc, 0xfe, + 0x04, 0x00, 0x00, 0xff, 0xff, 0x3c, 0x09, 0x34, 0x28, 0x9e, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -212,16 +202,7 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.ContractGasLimit != 0 { i = encodeVarintGenesis(dAtA, i, uint64(m.ContractGasLimit)) i-- - dAtA[i] = 0x10 - } - if len(m.ContractAddresses) > 0 { - for iNdEx := len(m.ContractAddresses) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.ContractAddresses[iNdEx]) - copy(dAtA[i:], m.ContractAddresses[iNdEx]) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.ContractAddresses[iNdEx]))) - i-- - dAtA[i] = 0xa - } + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -254,12 +235,6 @@ func (m *Params) Size() (n int) { } var l int _ = l - if len(m.ContractAddresses) > 0 { - for _, s := range m.ContractAddresses { - l = len(s) - n += 1 + l + sovGenesis(uint64(l)) - } - } if m.ContractGasLimit != 0 { n += 1 + sovGenesis(uint64(m.ContractGasLimit)) } @@ -385,38 +360,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ContractAddresses", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - 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 ErrInvalidLengthGenesis - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ContractAddresses = append(m.ContractAddresses, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 2: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ContractGasLimit", wireType) } diff --git a/x/clock/types/keys.go b/x/clock/types/keys.go index 3b97c283b..88dc89ab2 100644 --- a/x/clock/types/keys.go +++ b/x/clock/types/keys.go @@ -5,6 +5,8 @@ var ParamsKey = []byte{0x00} const ( ModuleName = "clock" + RouterKey = ModuleName + StoreKey = ModuleName QuerierRoute = ModuleName diff --git a/x/clock/types/msgs.go b/x/clock/types/msgs.go index 8d6c5768f..b94c60a44 100644 --- a/x/clock/types/msgs.go +++ b/x/clock/types/msgs.go @@ -4,8 +4,6 @@ import ( "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/CosmosContracts/juno/v19/x/drip/types" ) const ( @@ -14,23 +12,99 @@ const ( ) // == MsgUpdateParams == -const TypeMsgUpdateParams = "update_clock_params" +const ( + TypeMsgRegisterFeePayContract = "register_clock_contract" + TypeMsgUnregisterFeePayContract = "unregister_clock_contract" + TypeMsgUnjailFeePayContract = "unjail_clock_contract" + TypeMsgUpdateParams = "update_clock_params" +) + +var ( + _ sdk.Msg = &MsgRegisterClockContract{} + _ sdk.Msg = &MsgUnregisterClockContract{} + _ sdk.Msg = &MsgUnjailClockContract{} + _ sdk.Msg = &MsgUpdateParams{} +) + +// Route returns the name of the module +func (msg MsgRegisterClockContract) Route() string { return RouterKey } + +// Type returns the the action +func (msg MsgRegisterClockContract) Type() string { return TypeMsgRegisterFeePayContract } + +// ValidateBasic runs stateless checks on the message +func (msg MsgRegisterClockContract) ValidateBasic() error { + return validateAddresses(msg.SenderAddress, msg.ContractAddress) +} + +// GetSignBytes encodes the message for signing +func (msg *MsgRegisterClockContract) GetSignBytes() []byte { + return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(msg)) +} + +// GetSigners defines whose signature is required +func (msg MsgRegisterClockContract) GetSigners() []sdk.AccAddress { + from, _ := sdk.AccAddressFromBech32(msg.SenderAddress) + return []sdk.AccAddress{from} +} + +// Route returns the name of the module +func (msg MsgUnregisterClockContract) Route() string { return RouterKey } + +// Type returns the the action +func (msg MsgUnregisterClockContract) Type() string { return TypeMsgRegisterFeePayContract } -var _ sdk.Msg = &MsgUpdateParams{} +// ValidateBasic runs stateless checks on the message +func (msg MsgUnregisterClockContract) ValidateBasic() error { + return validateAddresses(msg.SenderAddress, msg.ContractAddress) +} + +// GetSignBytes encodes the message for signing +func (msg *MsgUnregisterClockContract) GetSignBytes() []byte { + return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(msg)) +} + +// GetSigners defines whose signature is required +func (msg MsgUnregisterClockContract) GetSigners() []sdk.AccAddress { + from, _ := sdk.AccAddressFromBech32(msg.SenderAddress) + return []sdk.AccAddress{from} +} + +// Route returns the name of the module +func (msg MsgUnjailClockContract) Route() string { return RouterKey } + +// Type returns the the action +func (msg MsgUnjailClockContract) Type() string { return TypeMsgRegisterFeePayContract } + +// ValidateBasic runs stateless checks on the message +func (msg MsgUnjailClockContract) ValidateBasic() error { + return validateAddresses(msg.SenderAddress, msg.ContractAddress) +} + +// GetSignBytes encodes the message for signing +func (msg *MsgUnjailClockContract) GetSignBytes() []byte { + return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(msg)) +} + +// GetSigners defines whose signature is required +func (msg MsgUnjailClockContract) GetSigners() []sdk.AccAddress { + from, _ := sdk.AccAddressFromBech32(msg.SenderAddress) + return []sdk.AccAddress{from} +} // NewMsgUpdateParams creates new instance of MsgUpdateParams func NewMsgUpdateParams( sender sdk.Address, - contracts []string, + contractGasLimit uint64, ) *MsgUpdateParams { return &MsgUpdateParams{ Authority: sender.String(), - Params: Params{ContractAddresses: contracts}, + Params: NewParams(contractGasLimit), } } // Route returns the name of the module -func (msg MsgUpdateParams) Route() string { return types.RouterKey } +func (msg MsgUpdateParams) Route() string { return RouterKey } // Type returns the the action func (msg MsgUpdateParams) Type() string { return TypeMsgUpdateParams } @@ -54,3 +128,14 @@ func (msg *MsgUpdateParams) ValidateBasic() error { return msg.Params.Validate() } + +// ValidateAddresses validates the provided addresses +func validateAddresses(addresses ...string) error { + for _, address := range addresses { + if _, err := sdk.AccAddressFromBech32(address); err != nil { + return errors.Wrapf(ErrInvalidAddress, "invalid address: %s", address) + } + } + + return nil +} diff --git a/x/clock/types/msgs_test.go b/x/clock/types/msgs_test.go index 1ea9fda06..4cc090750 100644 --- a/x/clock/types/msgs_test.go +++ b/x/clock/types/msgs_test.go @@ -6,8 +6,6 @@ import ( "github.com/stretchr/testify/suite" sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/CosmosContracts/juno/v19/x/drip/types" ) type MsgsTestSuite struct { @@ -24,18 +22,20 @@ func (suite *MsgsTestSuite) SetupTest() { } func (suite *MsgsTestSuite) TestMsgUpdateParams() { + var limit uint64 = 100_000 + p := MsgUpdateParams{ Authority: suite.govModule, Params: Params{ - ContractAddresses: []string{}, + ContractGasLimit: limit, }, } acc, _ := sdk.AccAddressFromBech32(p.Authority) - msg := NewMsgUpdateParams(acc, []string(nil)) + msg := NewMsgUpdateParams(acc, limit) - suite.Require().Equal(types.RouterKey, msg.Route()) + suite.Require().Equal(RouterKey, msg.Route()) suite.Require().Equal(TypeMsgUpdateParams, msg.Type()) suite.Require().NotNil(msg.GetSigners()) } diff --git a/x/clock/types/params.go b/x/clock/types/params.go index 46b5dfb72..9a8a356e9 100644 --- a/x/clock/types/params.go +++ b/x/clock/types/params.go @@ -3,26 +3,22 @@ package types import ( errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) // DefaultParams returns default parameters func DefaultParams() Params { return Params{ - ContractAddresses: []string(nil), - ContractGasLimit: 1_000_000_000, // 1 billion + ContractGasLimit: 100_000, } } // NewParams creates a new Params object func NewParams( - contracts []string, contractGasLimit uint64, ) Params { return Params{ - ContractAddresses: contracts, - ContractGasLimit: contractGasLimit, + ContractGasLimit: contractGasLimit, } } @@ -36,30 +32,5 @@ func (p Params) Validate() error { ) } - for _, addr := range p.ContractAddresses { - // Valid address check - if _, err := sdk.AccAddressFromBech32(addr); err != nil { - return errorsmod.Wrapf( - sdkerrors.ErrInvalidAddress, - "invalid contract address: %s", err.Error(), - ) - } - - // duplicate address check - count := 0 - for _, addr2 := range p.ContractAddresses { - if addr == addr2 { - count++ - } - - if count > 1 { - return errorsmod.Wrapf( - sdkerrors.ErrInvalidAddress, - "duplicate contract address: %s", addr, - ) - } - } - } - return nil } diff --git a/x/clock/types/params_test.go b/x/clock/types/params_test.go index eab7d55a2..f544e07f9 100644 --- a/x/clock/types/params_test.go +++ b/x/clock/types/params_test.go @@ -10,35 +10,54 @@ import ( func TestParamsValidate(t *testing.T) { testCases := []struct { - name string - params types.Params - expError bool + name string + params types.Params + success bool }{ - {"default", types.DefaultParams(), false}, { - "valid: no contracts, enough gas", - types.NewParams([]string(nil), 100_000), - false, + "Success - Default", + types.DefaultParams(), + true, }, { - "invalid: address malformed", - types.NewParams([]string{"invalid address"}, 100_000), + "Success - Meets min Gas", + types.NewParams(100_000), true, }, { - "invalid: not enough gas", - types.NewParams([]string(nil), 1), + "Success - Meets min Gas", + types.NewParams(500_000), true, }, + { + "Fail - Not Enough Gas", + types.NewParams(1), + false, + }, + { + "Fail - Not Enough Gas", + types.NewParams(100), + false, + }, + { + "Fail - Not Enough Gas", + types.NewParams(1_000), + false, + }, + { + "Fail - Not Enough Gas", + types.NewParams(10_000), + false, + }, } for _, tc := range testCases { err := tc.params.Validate() - if tc.expError { - require.Error(t, err, tc.name) - } else { + if tc.success { require.NoError(t, err, tc.name) + } else { + require.Error(t, err, tc.name) } } } diff --git a/x/clock/types/query.pb.go b/x/clock/types/query.pb.go index 82f6c847b..cebef7850 100644 --- a/x/clock/types/query.pb.go +++ b/x/clock/types/query.pb.go @@ -7,6 +7,7 @@ import ( context "context" fmt "fmt" _ "github.com/cosmos/cosmos-sdk/types" + query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" @@ -32,6 +33,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // QueryClockContracts is the request type to get all contracts. type QueryClockContracts struct { + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` } func (m *QueryClockContracts) Reset() { *m = QueryClockContracts{} } @@ -67,9 +70,19 @@ func (m *QueryClockContracts) XXX_DiscardUnknown() { var xxx_messageInfo_QueryClockContracts proto.InternalMessageInfo +func (m *QueryClockContracts) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + // QueryClockContractsResponse is the response type for the Query/ClockContracts RPC method. type QueryClockContractsResponse struct { - ContractAddresses []string `protobuf:"bytes,1,rep,name=contract_addresses,json=contractAddresses,proto3" json:"contract_addresses,omitempty" yaml:"contract_addresses"` + // clock_contracts are the clock contracts. + ClockContracts []ClockContract `protobuf:"bytes,1,rep,name=clock_contracts,json=clockContracts,proto3" json:"clock_contracts"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } func (m *QueryClockContractsResponse) Reset() { *m = QueryClockContractsResponse{} } @@ -105,13 +118,112 @@ func (m *QueryClockContractsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryClockContractsResponse proto.InternalMessageInfo -func (m *QueryClockContractsResponse) GetContractAddresses() []string { +func (m *QueryClockContractsResponse) GetClockContracts() []ClockContract { if m != nil { - return m.ContractAddresses + return m.ClockContracts } return nil } +func (m *QueryClockContractsResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryClockContract is the request type to get a single contract. +type QueryClockContract struct { + // contract_address is the address of the contract to query. + ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` +} + +func (m *QueryClockContract) Reset() { *m = QueryClockContract{} } +func (m *QueryClockContract) String() string { return proto.CompactTextString(m) } +func (*QueryClockContract) ProtoMessage() {} +func (*QueryClockContract) Descriptor() ([]byte, []int) { + return fileDescriptor_7da208f579d775c8, []int{2} +} +func (m *QueryClockContract) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryClockContract) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryClockContract.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 *QueryClockContract) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryClockContract.Merge(m, src) +} +func (m *QueryClockContract) XXX_Size() int { + return m.Size() +} +func (m *QueryClockContract) XXX_DiscardUnknown() { + xxx_messageInfo_QueryClockContract.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryClockContract proto.InternalMessageInfo + +func (m *QueryClockContract) GetContractAddress() string { + if m != nil { + return m.ContractAddress + } + return "" +} + +// QueryClockContractResponse is the response type for the Query/ClockContract RPC method. +type QueryClockContractResponse struct { + // contract is the clock contract. + ClockContract ClockContract `protobuf:"bytes,1,opt,name=clock_contract,json=clockContract,proto3" json:"clock_contract"` +} + +func (m *QueryClockContractResponse) Reset() { *m = QueryClockContractResponse{} } +func (m *QueryClockContractResponse) String() string { return proto.CompactTextString(m) } +func (*QueryClockContractResponse) ProtoMessage() {} +func (*QueryClockContractResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_7da208f579d775c8, []int{3} +} +func (m *QueryClockContractResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryClockContractResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryClockContractResponse.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 *QueryClockContractResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryClockContractResponse.Merge(m, src) +} +func (m *QueryClockContractResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryClockContractResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryClockContractResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryClockContractResponse proto.InternalMessageInfo + +func (m *QueryClockContractResponse) GetClockContract() ClockContract { + if m != nil { + return m.ClockContract + } + return ClockContract{} +} + // QueryParams is the request type to get all module params. type QueryParamsRequest struct { } @@ -120,7 +232,7 @@ func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } func (*QueryParamsRequest) ProtoMessage() {} func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_7da208f579d775c8, []int{2} + return fileDescriptor_7da208f579d775c8, []int{4} } func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -158,7 +270,7 @@ func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } func (*QueryParamsResponse) ProtoMessage() {} func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_7da208f579d775c8, []int{3} + return fileDescriptor_7da208f579d775c8, []int{5} } func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -197,6 +309,8 @@ func (m *QueryParamsResponse) GetParams() *Params { func init() { proto.RegisterType((*QueryClockContracts)(nil), "juno.clock.v1.QueryClockContracts") proto.RegisterType((*QueryClockContractsResponse)(nil), "juno.clock.v1.QueryClockContractsResponse") + proto.RegisterType((*QueryClockContract)(nil), "juno.clock.v1.QueryClockContract") + proto.RegisterType((*QueryClockContractResponse)(nil), "juno.clock.v1.QueryClockContractResponse") proto.RegisterType((*QueryParamsRequest)(nil), "juno.clock.v1.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "juno.clock.v1.QueryParamsResponse") } @@ -204,34 +318,41 @@ func init() { func init() { proto.RegisterFile("juno/clock/v1/query.proto", fileDescriptor_7da208f579d775c8) } var fileDescriptor_7da208f579d775c8 = []byte{ - // 423 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xb1, 0x8f, 0xd3, 0x30, - 0x18, 0xc5, 0x6b, 0x10, 0x95, 0x30, 0x3a, 0x24, 0xcc, 0x55, 0xf4, 0xd2, 0x23, 0x2d, 0x9e, 0x4e, - 0x08, 0x62, 0xe5, 0xd8, 0x90, 0x18, 0x68, 0x07, 0x24, 0x26, 0xc8, 0xc8, 0x82, 0x1c, 0x9f, 0x15, - 0x02, 0x89, 0xbf, 0x5c, 0xec, 0x54, 0x64, 0xbd, 0x95, 0x05, 0x89, 0x7f, 0x8a, 0xf1, 0x24, 0x16, - 0xa6, 0x08, 0xb5, 0x4c, 0x37, 0xde, 0xcc, 0x80, 0xe2, 0xb8, 0x95, 0x72, 0x57, 0xc1, 0x96, 0xbc, - 0xdf, 0xcb, 0xf7, 0x9e, 0xbf, 0x18, 0x1f, 0x7c, 0xac, 0x14, 0x30, 0x91, 0x81, 0xf8, 0xc4, 0x96, - 0x21, 0x3b, 0xad, 0x64, 0x59, 0x07, 0x45, 0x09, 0x06, 0xc8, 0x5e, 0x8b, 0x02, 0x8b, 0x82, 0x65, - 0xe8, 0xed, 0x27, 0x90, 0x80, 0x25, 0xac, 0x7d, 0xea, 0x4c, 0xde, 0x61, 0x02, 0x90, 0x64, 0x92, - 0xf1, 0x22, 0x65, 0x5c, 0x29, 0x30, 0xdc, 0xa4, 0xa0, 0xb4, 0xa3, 0xbe, 0x00, 0x9d, 0x83, 0x66, - 0x31, 0xd7, 0x92, 0x2d, 0xc3, 0x58, 0x1a, 0x1e, 0x32, 0x01, 0xa9, 0x72, 0x7c, 0xd2, 0x4f, 0x4f, - 0xa4, 0x92, 0x3a, 0x75, 0x1f, 0xd3, 0x11, 0xbe, 0xff, 0xb6, 0xad, 0xb3, 0x68, 0xf1, 0x02, 0x94, - 0x29, 0xb9, 0x30, 0x9a, 0x7e, 0x41, 0x78, 0xb2, 0x43, 0x8f, 0xa4, 0x2e, 0x40, 0x69, 0x49, 0x32, - 0x4c, 0x84, 0x13, 0xdf, 0xf3, 0x93, 0x93, 0x52, 0x6a, 0x2d, 0xf5, 0x18, 0xcd, 0x6e, 0x1e, 0xdd, - 0x9e, 0xbf, 0xb8, 0x68, 0xa6, 0x87, 0xd7, 0xe9, 0x13, 0xc8, 0x53, 0x23, 0xf3, 0xc2, 0xd4, 0x97, - 0xcd, 0xf4, 0xa0, 0xe6, 0x79, 0xf6, 0x9c, 0x5e, 0x77, 0xd1, 0xe8, 0xde, 0x46, 0x7c, 0xb9, 0xd5, - 0xf6, 0x31, 0xb1, 0x65, 0xde, 0xf0, 0x92, 0xe7, 0x3a, 0x92, 0xa7, 0x95, 0xd4, 0x86, 0x72, 0x57, - 0x7d, 0xa3, 0xba, 0x6a, 0xaf, 0xf1, 0xb0, 0xb0, 0xca, 0x18, 0xcd, 0xd0, 0xd1, 0x9d, 0xe3, 0x51, - 0xd0, 0x5b, 0x71, 0xd0, 0xd9, 0xe7, 0x93, 0x8b, 0x66, 0xea, 0x8c, 0x97, 0xcd, 0x74, 0xaf, 0xeb, - 0xd3, 0xbd, 0xd3, 0xc8, 0x81, 0xe3, 0x3f, 0x08, 0xdf, 0xb2, 0x19, 0xe4, 0x0c, 0xe1, 0xbb, 0xfd, - 0x5d, 0x10, 0x7a, 0x65, 0xf0, 0x8e, 0x7d, 0x79, 0x8f, 0xff, 0xef, 0xd9, 0x14, 0xa7, 0xb3, 0xb3, - 0x1f, 0xbf, 0xbf, 0xdd, 0xf0, 0xc8, 0x98, 0xf5, 0x7f, 0x98, 0xd8, 0x26, 0x2a, 0x3c, 0xec, 0xda, - 0x93, 0x47, 0xbb, 0xe6, 0xf6, 0xd6, 0xe3, 0xd1, 0x7f, 0x59, 0x5c, 0xe4, 0x43, 0x1b, 0xf9, 0x80, - 0x8c, 0xae, 0x44, 0x76, 0xc7, 0x9f, 0xbf, 0xfa, 0xbe, 0xf2, 0xd1, 0xf9, 0xca, 0x47, 0xbf, 0x56, - 0x3e, 0xfa, 0xba, 0xf6, 0x07, 0xe7, 0x6b, 0x7f, 0xf0, 0x73, 0xed, 0x0f, 0xde, 0x3d, 0x4d, 0x52, - 0xf3, 0xa1, 0x8a, 0x03, 0x01, 0x39, 0x5b, 0xd8, 0xeb, 0xb7, 0x3d, 0x4f, 0x37, 0xea, 0xb3, 0x1b, - 0x66, 0xea, 0x42, 0xea, 0x78, 0x68, 0x2f, 0xdb, 0xb3, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xdb, - 0x57, 0xe2, 0x8b, 0x09, 0x03, 0x00, 0x00, + // 542 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0x4d, 0x6f, 0xd3, 0x30, + 0x18, 0xc7, 0x9b, 0x0d, 0x2a, 0xe1, 0xa9, 0x1d, 0x32, 0x9b, 0x28, 0xe9, 0x48, 0x8b, 0x0f, 0xb0, + 0x0d, 0xcd, 0x56, 0xbb, 0x1b, 0x17, 0x44, 0x2b, 0x31, 0x01, 0x97, 0x91, 0x23, 0x12, 0x9a, 0xdc, + 0xcc, 0x0a, 0x81, 0x36, 0xce, 0x62, 0xb7, 0xa2, 0x42, 0x5c, 0xf6, 0x09, 0x78, 0xf9, 0x28, 0x7c, + 0x89, 0x1d, 0x27, 0x71, 0xe1, 0x54, 0xa1, 0x96, 0x13, 0x47, 0x3e, 0x01, 0x8a, 0xed, 0x94, 0x39, + 0x2b, 0x94, 0x9b, 0xfb, 0xbc, 0xfc, 0x9f, 0xdf, 0xf3, 0xd2, 0x80, 0x5b, 0xaf, 0x87, 0x31, 0x27, + 0x41, 0x9f, 0x07, 0x6f, 0xc8, 0xa8, 0x45, 0x4e, 0x86, 0x2c, 0x1d, 0xe3, 0x24, 0xe5, 0x92, 0xc3, + 0x4a, 0xe6, 0xc2, 0xca, 0x85, 0x47, 0x2d, 0x77, 0x37, 0xe0, 0x62, 0xc0, 0x05, 0xe9, 0x51, 0xc1, + 0x74, 0x1c, 0x19, 0xb5, 0x7a, 0x4c, 0xd2, 0x16, 0x49, 0x68, 0x18, 0xc5, 0x54, 0x46, 0x3c, 0xd6, + 0xa9, 0xee, 0x46, 0xc8, 0x43, 0xae, 0x9e, 0x24, 0x7b, 0x19, 0xeb, 0x56, 0xc8, 0x79, 0xd8, 0x67, + 0x84, 0x26, 0x11, 0xa1, 0x71, 0xcc, 0xa5, 0x4a, 0x11, 0xc6, 0xeb, 0x5d, 0xd4, 0xcf, 0x95, 0x03, + 0x1e, 0xe5, 0x9a, 0x75, 0x9b, 0x34, 0x64, 0x31, 0x13, 0x51, 0x9e, 0x5c, 0x68, 0x43, 0x43, 0x2b, + 0x17, 0x7a, 0x09, 0x6e, 0x3c, 0xcf, 0x68, 0xbb, 0x99, 0xad, 0xcb, 0x63, 0x99, 0xd2, 0x40, 0x0a, + 0xf8, 0x18, 0x80, 0x3f, 0xd8, 0x35, 0xa7, 0xe9, 0x6c, 0xaf, 0xb5, 0xef, 0x62, 0xcd, 0x80, 0x33, + 0x06, 0xac, 0x67, 0x61, 0x48, 0xf0, 0x21, 0x0d, 0x99, 0xcf, 0x4e, 0x86, 0x4c, 0x48, 0xff, 0x42, + 0x26, 0xfa, 0xe2, 0x80, 0xfa, 0x02, 0x7d, 0x9f, 0x89, 0x84, 0xc7, 0x82, 0xc1, 0x67, 0x60, 0x5d, + 0xd1, 0x1c, 0x05, 0xb9, 0xab, 0xe6, 0x34, 0x57, 0xb7, 0xd7, 0xda, 0x5b, 0xd8, 0x9a, 0x2f, 0xb6, + 0xf2, 0x3b, 0x57, 0xce, 0x26, 0x8d, 0x92, 0x5f, 0x0d, 0x6c, 0xe8, 0x03, 0x0b, 0x7a, 0x45, 0x41, + 0xdf, 0x5b, 0x0a, 0xad, 0x49, 0x2c, 0xea, 0x87, 0x00, 0x5e, 0x86, 0x86, 0x3b, 0xe0, 0x7a, 0x4e, + 0x79, 0x44, 0x8f, 0x8f, 0x53, 0x26, 0x84, 0x9a, 0xcc, 0x35, 0x7f, 0x3d, 0xb7, 0x3f, 0xd2, 0x66, + 0x14, 0x02, 0xf7, 0xb2, 0xc0, 0xbc, 0xe9, 0x27, 0xa0, 0x6a, 0x37, 0x6d, 0x06, 0xfc, 0x3f, 0x3d, + 0x57, 0xac, 0x9e, 0xd1, 0x86, 0x21, 0x3d, 0xa4, 0x29, 0x1d, 0x08, 0xb3, 0x01, 0x44, 0xcd, 0x52, + 0x73, 0xab, 0xa9, 0xfb, 0x14, 0x94, 0x13, 0x65, 0x31, 0xf5, 0x36, 0x0b, 0xf5, 0x74, 0x78, 0xa7, + 0xfe, 0x73, 0xd2, 0x30, 0x81, 0xbf, 0x26, 0x8d, 0xca, 0x98, 0x0e, 0xfa, 0x0f, 0x90, 0xfe, 0x8d, + 0x7c, 0xe3, 0x68, 0x7f, 0x5c, 0x05, 0x57, 0x55, 0x0d, 0x78, 0xea, 0x80, 0x6a, 0xe1, 0x7a, 0x50, + 0x41, 0x78, 0xc1, 0x05, 0xb8, 0xbb, 0xcb, 0x63, 0x72, 0x70, 0xd4, 0x3c, 0xfd, 0xfa, 0xe3, 0xf3, + 0x8a, 0x0b, 0x6b, 0xa4, 0x70, 0xc8, 0xf3, 0x8a, 0x9f, 0x1c, 0x50, 0xb1, 0xb7, 0x75, 0x67, 0xa9, + 0xbe, 0xbb, 0xb3, 0x34, 0x64, 0x4e, 0xb0, 0xaf, 0x08, 0xf6, 0xe0, 0xfd, 0xbf, 0x11, 0x90, 0x77, + 0xc5, 0xdb, 0x78, 0x0f, 0x63, 0x50, 0xd6, 0x23, 0x5d, 0x0c, 0x63, 0xed, 0xcc, 0x45, 0xff, 0x0a, + 0x31, 0x14, 0xb7, 0x15, 0xc5, 0x4d, 0xb8, 0x59, 0xa0, 0xd0, 0x3b, 0xe9, 0x1c, 0x9c, 0x4d, 0x3d, + 0xe7, 0x7c, 0xea, 0x39, 0xdf, 0xa7, 0x9e, 0xf3, 0x61, 0xe6, 0x95, 0xce, 0x67, 0x5e, 0xe9, 0xdb, + 0xcc, 0x2b, 0xbd, 0xd8, 0x0b, 0x23, 0xf9, 0x6a, 0xd8, 0xc3, 0x01, 0x1f, 0x90, 0xae, 0xfa, 0x3f, + 0xcc, 0x87, 0xac, 0xa5, 0xde, 0x1a, 0x31, 0x39, 0x4e, 0x98, 0xe8, 0x95, 0xd5, 0xb7, 0x61, 0xff, + 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1a, 0x8e, 0x06, 0x27, 0xff, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -248,6 +369,8 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // ClockContracts ClockContracts(ctx context.Context, in *QueryClockContracts, opts ...grpc.CallOption) (*QueryClockContractsResponse, error) + // ClockContract + ClockContract(ctx context.Context, in *QueryClockContract, opts ...grpc.CallOption) (*QueryClockContractResponse, error) // Params Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) } @@ -269,6 +392,15 @@ func (c *queryClient) ClockContracts(ctx context.Context, in *QueryClockContract return out, nil } +func (c *queryClient) ClockContract(ctx context.Context, in *QueryClockContract, opts ...grpc.CallOption) (*QueryClockContractResponse, error) { + out := new(QueryClockContractResponse) + err := c.cc.Invoke(ctx, "/juno.clock.v1.Query/ClockContract", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { out := new(QueryParamsResponse) err := c.cc.Invoke(ctx, "/juno.clock.v1.Query/Params", in, out, opts...) @@ -282,6 +414,8 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . type QueryServer interface { // ClockContracts ClockContracts(context.Context, *QueryClockContracts) (*QueryClockContractsResponse, error) + // ClockContract + ClockContract(context.Context, *QueryClockContract) (*QueryClockContractResponse, error) // Params Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) } @@ -293,6 +427,9 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) ClockContracts(ctx context.Context, req *QueryClockContracts) (*QueryClockContractsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ClockContracts not implemented") } +func (*UnimplementedQueryServer) ClockContract(ctx context.Context, req *QueryClockContract) (*QueryClockContractResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ClockContract not implemented") +} func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } @@ -319,6 +456,24 @@ func _Query_ClockContracts_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } +func _Query_ClockContract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryClockContract) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ClockContract(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/juno.clock.v1.Query/ClockContract", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ClockContract(ctx, req.(*QueryClockContract)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryParamsRequest) if err := dec(in); err != nil { @@ -345,6 +500,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "ClockContracts", Handler: _Query_ClockContracts_Handler, }, + { + MethodName: "ClockContract", + Handler: _Query_ClockContract_Handler, + }, { MethodName: "Params", Handler: _Query_Params_Handler, @@ -374,6 +533,18 @@ func (m *QueryClockContracts) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } return len(dAtA) - i, nil } @@ -397,11 +568,28 @@ func (m *QueryClockContractsResponse) MarshalToSizedBuffer(dAtA []byte) (int, er _ = i var l int _ = l - if len(m.ContractAddresses) > 0 { - for iNdEx := len(m.ContractAddresses) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.ContractAddresses[iNdEx]) - copy(dAtA[i:], m.ContractAddresses[iNdEx]) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ContractAddresses[iNdEx]))) + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.ClockContracts) > 0 { + for iNdEx := len(m.ClockContracts) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ClockContracts[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } i-- dAtA[i] = 0xa } @@ -409,6 +597,69 @@ func (m *QueryClockContractsResponse) MarshalToSizedBuffer(dAtA []byte) (int, er return len(dAtA) - i, nil } +func (m *QueryClockContract) 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 *QueryClockContract) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryClockContract) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ContractAddress) > 0 { + i -= len(m.ContractAddress) + copy(dAtA[i:], m.ContractAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ContractAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryClockContractResponse) 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 *QueryClockContractResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryClockContractResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.ClockContract.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -484,6 +735,10 @@ func (m *QueryClockContracts) Size() (n int) { } var l int _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } return n } @@ -493,12 +748,40 @@ func (m *QueryClockContractsResponse) Size() (n int) { } var l int _ = l - if len(m.ContractAddresses) > 0 { - for _, s := range m.ContractAddresses { - l = len(s) + if len(m.ClockContracts) > 0 { + for _, e := range m.ClockContracts { + l = e.Size() n += 1 + l + sovQuery(uint64(l)) } } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryClockContract) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ContractAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryClockContractResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.ClockContract.Size() + n += 1 + l + sovQuery(uint64(l)) return n } @@ -559,6 +842,42 @@ func (m *QueryClockContracts) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: QueryClockContracts: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -611,7 +930,127 @@ func (m *QueryClockContractsResponse) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ContractAddresses", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ClockContracts", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClockContracts = append(m.ClockContracts, ClockContract{}) + if err := m.ClockContracts[len(m.ClockContracts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + 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 *QueryClockContract) 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: QueryClockContract: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryClockContract: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -639,7 +1078,90 @@ func (m *QueryClockContractsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ContractAddresses = append(m.ContractAddresses, string(dAtA[iNdEx:postIndex])) + m.ContractAddress = 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 *QueryClockContractResponse) 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: QueryClockContractResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryClockContractResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClockContract", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ClockContract.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/clock/types/query.pb.gw.go b/x/clock/types/query.pb.gw.go index 790415fcf..cddeb5969 100644 --- a/x/clock/types/query.pb.gw.go +++ b/x/clock/types/query.pb.gw.go @@ -33,10 +33,21 @@ var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage var _ = metadata.Join +var ( + filter_Query_ClockContracts_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + func request_Query_ClockContracts_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryClockContracts var metadata runtime.ServerMetadata + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ClockContracts_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.ClockContracts(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err @@ -46,11 +57,72 @@ func local_request_Query_ClockContracts_0(ctx context.Context, marshaler runtime var protoReq QueryClockContracts var metadata runtime.ServerMetadata + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ClockContracts_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.ClockContracts(ctx, &protoReq) return msg, metadata, err } +func request_Query_ClockContract_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryClockContract + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["contract_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "contract_address") + } + + protoReq.ContractAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "contract_address", err) + } + + msg, err := client.ClockContract(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ClockContract_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryClockContract + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["contract_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "contract_address") + } + + protoReq.ContractAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "contract_address", err) + } + + msg, err := server.ClockContract(ctx, &protoReq) + return msg, metadata, err + +} + func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryParamsRequest var metadata runtime.ServerMetadata @@ -98,6 +170,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_ClockContract_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_ClockContract_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_ClockContract_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -182,6 +277,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_ClockContract_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_ClockContract_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_ClockContract_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -208,11 +323,15 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie var ( pattern_Query_ClockContracts_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"juno", "clock", "v1", "contracts"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_ClockContract_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"juno", "clock", "v1", "contracts", "contract_address"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"juno", "clock", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( forward_Query_ClockContracts_0 = runtime.ForwardResponseMessage + forward_Query_ClockContract_0 = runtime.ForwardResponseMessage + forward_Query_Params_0 = runtime.ForwardResponseMessage ) diff --git a/x/clock/types/tx.pb.go b/x/clock/types/tx.pb.go index 9374c2eae..22725c909 100644 --- a/x/clock/types/tx.pb.go +++ b/x/clock/types/tx.pb.go @@ -12,6 +12,7 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -31,6 +32,285 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// MsgRegisterClockContract is the Msg/RegisterClockContract request type. +type MsgRegisterClockContract struct { + // The address of the sender. + SenderAddress string `protobuf:"bytes,1,opt,name=sender_address,json=senderAddress,proto3" json:"sender_address,omitempty"` + // The address of the contract to register. + ContractAddress string `protobuf:"bytes,2,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` +} + +func (m *MsgRegisterClockContract) Reset() { *m = MsgRegisterClockContract{} } +func (m *MsgRegisterClockContract) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterClockContract) ProtoMessage() {} +func (*MsgRegisterClockContract) Descriptor() ([]byte, []int) { + return fileDescriptor_76642a1e9a85f94b, []int{0} +} +func (m *MsgRegisterClockContract) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterClockContract) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterClockContract.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 *MsgRegisterClockContract) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterClockContract.Merge(m, src) +} +func (m *MsgRegisterClockContract) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterClockContract) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterClockContract.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterClockContract proto.InternalMessageInfo + +func (m *MsgRegisterClockContract) GetSenderAddress() string { + if m != nil { + return m.SenderAddress + } + return "" +} + +func (m *MsgRegisterClockContract) GetContractAddress() string { + if m != nil { + return m.ContractAddress + } + return "" +} + +// MsgRegisterClockContractResponse defines the response structure for executing a +// MsgRegisterClockContract message. +type MsgRegisterClockContractResponse struct { +} + +func (m *MsgRegisterClockContractResponse) Reset() { *m = MsgRegisterClockContractResponse{} } +func (m *MsgRegisterClockContractResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterClockContractResponse) ProtoMessage() {} +func (*MsgRegisterClockContractResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_76642a1e9a85f94b, []int{1} +} +func (m *MsgRegisterClockContractResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterClockContractResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterClockContractResponse.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 *MsgRegisterClockContractResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterClockContractResponse.Merge(m, src) +} +func (m *MsgRegisterClockContractResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterClockContractResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterClockContractResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterClockContractResponse proto.InternalMessageInfo + +// MsgUnregisterClockContract is the Msg/UnregisterClockContract request type. +type MsgUnregisterClockContract struct { + // The address of the sender. + SenderAddress string `protobuf:"bytes,1,opt,name=sender_address,json=senderAddress,proto3" json:"sender_address,omitempty"` + // The address of the contract to unregister. + ContractAddress string `protobuf:"bytes,2,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` +} + +func (m *MsgUnregisterClockContract) Reset() { *m = MsgUnregisterClockContract{} } +func (m *MsgUnregisterClockContract) String() string { return proto.CompactTextString(m) } +func (*MsgUnregisterClockContract) ProtoMessage() {} +func (*MsgUnregisterClockContract) Descriptor() ([]byte, []int) { + return fileDescriptor_76642a1e9a85f94b, []int{2} +} +func (m *MsgUnregisterClockContract) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUnregisterClockContract) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUnregisterClockContract.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 *MsgUnregisterClockContract) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUnregisterClockContract.Merge(m, src) +} +func (m *MsgUnregisterClockContract) XXX_Size() int { + return m.Size() +} +func (m *MsgUnregisterClockContract) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUnregisterClockContract.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUnregisterClockContract proto.InternalMessageInfo + +func (m *MsgUnregisterClockContract) GetSenderAddress() string { + if m != nil { + return m.SenderAddress + } + return "" +} + +func (m *MsgUnregisterClockContract) GetContractAddress() string { + if m != nil { + return m.ContractAddress + } + return "" +} + +// MsgUnregisterClockContractResponse defines the response structure for executing a +// MsgUnregisterClockContract message. +type MsgUnregisterClockContractResponse struct { +} + +func (m *MsgUnregisterClockContractResponse) Reset() { *m = MsgUnregisterClockContractResponse{} } +func (m *MsgUnregisterClockContractResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUnregisterClockContractResponse) ProtoMessage() {} +func (*MsgUnregisterClockContractResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_76642a1e9a85f94b, []int{3} +} +func (m *MsgUnregisterClockContractResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUnregisterClockContractResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUnregisterClockContractResponse.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 *MsgUnregisterClockContractResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUnregisterClockContractResponse.Merge(m, src) +} +func (m *MsgUnregisterClockContractResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUnregisterClockContractResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUnregisterClockContractResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUnregisterClockContractResponse proto.InternalMessageInfo + +// MsgUnjailClockContract is the Msg/UnjailClockContract request type. +type MsgUnjailClockContract struct { + // The address of the sender. + SenderAddress string `protobuf:"bytes,1,opt,name=sender_address,json=senderAddress,proto3" json:"sender_address,omitempty"` + // The address of the contract to unjail. + ContractAddress string `protobuf:"bytes,2,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` +} + +func (m *MsgUnjailClockContract) Reset() { *m = MsgUnjailClockContract{} } +func (m *MsgUnjailClockContract) String() string { return proto.CompactTextString(m) } +func (*MsgUnjailClockContract) ProtoMessage() {} +func (*MsgUnjailClockContract) Descriptor() ([]byte, []int) { + return fileDescriptor_76642a1e9a85f94b, []int{4} +} +func (m *MsgUnjailClockContract) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUnjailClockContract) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUnjailClockContract.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 *MsgUnjailClockContract) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUnjailClockContract.Merge(m, src) +} +func (m *MsgUnjailClockContract) XXX_Size() int { + return m.Size() +} +func (m *MsgUnjailClockContract) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUnjailClockContract.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUnjailClockContract proto.InternalMessageInfo + +func (m *MsgUnjailClockContract) GetSenderAddress() string { + if m != nil { + return m.SenderAddress + } + return "" +} + +func (m *MsgUnjailClockContract) GetContractAddress() string { + if m != nil { + return m.ContractAddress + } + return "" +} + +// MsgUnjailClockContractResponse defines the response structure for executing a +// MsgUnjailClockContract message. +type MsgUnjailClockContractResponse struct { +} + +func (m *MsgUnjailClockContractResponse) Reset() { *m = MsgUnjailClockContractResponse{} } +func (m *MsgUnjailClockContractResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUnjailClockContractResponse) ProtoMessage() {} +func (*MsgUnjailClockContractResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_76642a1e9a85f94b, []int{5} +} +func (m *MsgUnjailClockContractResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUnjailClockContractResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUnjailClockContractResponse.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 *MsgUnjailClockContractResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUnjailClockContractResponse.Merge(m, src) +} +func (m *MsgUnjailClockContractResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUnjailClockContractResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUnjailClockContractResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUnjailClockContractResponse proto.InternalMessageInfo + // MsgUpdateParams is the Msg/UpdateParams request type. // // Since: cosmos-sdk 0.47 @@ -47,7 +327,7 @@ func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParams) ProtoMessage() {} func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_76642a1e9a85f94b, []int{0} + return fileDescriptor_76642a1e9a85f94b, []int{6} } func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -101,7 +381,7 @@ func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParamsResponse) ProtoMessage() {} func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_76642a1e9a85f94b, []int{1} + return fileDescriptor_76642a1e9a85f94b, []int{7} } func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -131,6 +411,12 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo func init() { + proto.RegisterType((*MsgRegisterClockContract)(nil), "juno.clock.v1.MsgRegisterClockContract") + proto.RegisterType((*MsgRegisterClockContractResponse)(nil), "juno.clock.v1.MsgRegisterClockContractResponse") + proto.RegisterType((*MsgUnregisterClockContract)(nil), "juno.clock.v1.MsgUnregisterClockContract") + proto.RegisterType((*MsgUnregisterClockContractResponse)(nil), "juno.clock.v1.MsgUnregisterClockContractResponse") + proto.RegisterType((*MsgUnjailClockContract)(nil), "juno.clock.v1.MsgUnjailClockContract") + proto.RegisterType((*MsgUnjailClockContractResponse)(nil), "juno.clock.v1.MsgUnjailClockContractResponse") proto.RegisterType((*MsgUpdateParams)(nil), "juno.clock.v1.MsgUpdateParams") proto.RegisterType((*MsgUpdateParamsResponse)(nil), "juno.clock.v1.MsgUpdateParamsResponse") } @@ -138,28 +424,41 @@ func init() { func init() { proto.RegisterFile("juno/clock/v1/tx.proto", fileDescriptor_76642a1e9a85f94b) } var fileDescriptor_76642a1e9a85f94b = []byte{ - // 333 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcb, 0x2a, 0xcd, 0xcb, - 0xd7, 0x4f, 0xce, 0xc9, 0x4f, 0xce, 0xd6, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, - 0x2f, 0xc9, 0x17, 0xe2, 0x05, 0x89, 0xeb, 0x81, 0xc5, 0xf5, 0xca, 0x0c, 0xa5, 0xc4, 0x93, 0xf3, - 0x8b, 0x73, 0xf3, 0x8b, 0xf5, 0x73, 0x8b, 0xd3, 0x41, 0xca, 0x72, 0x8b, 0xd3, 0x21, 0xea, 0xa4, - 0xa4, 0x51, 0xf5, 0xa7, 0xa7, 0xe6, 0xa5, 0x16, 0x67, 0x16, 0x43, 0x25, 0x45, 0xd2, 0xf3, 0xd3, - 0xf3, 0xc1, 0x4c, 0x7d, 0x10, 0x0b, 0x2a, 0x2a, 0x09, 0x31, 0x2b, 0x1e, 0x22, 0x01, 0xe1, 0x40, - 0xa5, 0x04, 0x13, 0x73, 0x33, 0xf3, 0xf2, 0xf5, 0xc1, 0x24, 0x44, 0x48, 0xa9, 0x8f, 0x91, 0x8b, - 0xdf, 0xb7, 0x38, 0x3d, 0xb4, 0x20, 0x25, 0xb1, 0x24, 0x35, 0x20, 0xb1, 0x28, 0x31, 0xb7, 0x58, - 0xc8, 0x8c, 0x8b, 0x33, 0xb1, 0xb4, 0x24, 0x23, 0xbf, 0x28, 0xb3, 0xa4, 0x52, 0x82, 0x51, 0x81, - 0x51, 0x83, 0xd3, 0x49, 0xe2, 0xd2, 0x16, 0x5d, 0x11, 0xa8, 0x59, 0x8e, 0x29, 0x29, 0x45, 0xa9, - 0xc5, 0xc5, 0xc1, 0x25, 0x45, 0x99, 0x79, 0xe9, 0x41, 0x08, 0xa5, 0x42, 0xc6, 0x5c, 0x6c, 0x05, - 0x60, 0x13, 0x24, 0x98, 0x14, 0x18, 0x35, 0xb8, 0x8d, 0x44, 0xf5, 0x50, 0x7c, 0xa9, 0x07, 0x31, - 0xde, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0xa8, 0x52, 0x2b, 0xbe, 0xa6, 0xe7, 0x1b, 0xb4, - 0x10, 0x86, 0x28, 0x49, 0x72, 0x89, 0xa3, 0xb9, 0x27, 0x28, 0xb5, 0xb8, 0x20, 0x3f, 0xaf, 0x38, - 0xd5, 0x28, 0x96, 0x8b, 0xd9, 0xb7, 0x38, 0x5d, 0x28, 0x8c, 0x8b, 0x07, 0xc5, 0xb9, 0x72, 0x68, - 0xd6, 0xa0, 0x69, 0x97, 0x52, 0xc3, 0x2f, 0x0f, 0x33, 0xde, 0xc9, 0xfd, 0xc4, 0x23, 0x39, 0xc6, - 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, - 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x74, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, - 0x73, 0xf5, 0x9d, 0xc1, 0x81, 0xe0, 0x9c, 0x9f, 0x57, 0x52, 0x94, 0x98, 0x5c, 0x52, 0xac, 0x0f, - 0x8e, 0xa0, 0x0a, 0x68, 0x14, 0x95, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x83, 0xd6, 0x18, - 0x10, 0x00, 0x00, 0xff, 0xff, 0xda, 0x7a, 0xd4, 0x12, 0xfd, 0x01, 0x00, 0x00, + // 542 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x94, 0x3f, 0x6f, 0xd3, 0x40, + 0x18, 0xc6, 0xe3, 0x52, 0x55, 0xea, 0x41, 0x5b, 0x30, 0x6d, 0x93, 0x9a, 0xc8, 0x44, 0xa7, 0xf2, + 0xa7, 0x48, 0xf1, 0x29, 0xad, 0xc4, 0xc0, 0x46, 0x32, 0x30, 0x45, 0x42, 0x46, 0x30, 0xb0, 0x54, + 0x57, 0xe7, 0x74, 0x75, 0x88, 0xef, 0x2c, 0xdf, 0xa5, 0x6a, 0xd7, 0xee, 0x20, 0x24, 0xc4, 0xc8, + 0xc8, 0xce, 0xc0, 0x87, 0xe8, 0x58, 0xc1, 0xc2, 0x84, 0x50, 0x82, 0xc4, 0xd7, 0x40, 0xbe, 0x3b, + 0x3b, 0x24, 0xb1, 0x51, 0x16, 0x58, 0xac, 0xf3, 0xfb, 0x3e, 0xef, 0xfb, 0xfc, 0x64, 0x3f, 0x36, + 0xd8, 0xee, 0x0f, 0x19, 0x47, 0xc1, 0x80, 0x07, 0xaf, 0xd0, 0x49, 0x0b, 0xc9, 0x53, 0x2f, 0x4e, + 0xb8, 0xe4, 0xf6, 0x5a, 0x5a, 0xf7, 0x54, 0xdd, 0x3b, 0x69, 0x39, 0x75, 0xca, 0x39, 0x1d, 0x10, + 0x84, 0xe3, 0x10, 0x61, 0xc6, 0xb8, 0xc4, 0x32, 0xe4, 0x4c, 0x68, 0xb1, 0x53, 0x0d, 0xb8, 0x88, + 0xb8, 0x40, 0x91, 0xa0, 0xe9, 0x92, 0x48, 0x50, 0xd3, 0xb8, 0x35, 0xbd, 0x9d, 0x12, 0x46, 0x44, + 0x98, 0x4d, 0x6d, 0x52, 0x4e, 0xb9, 0x3a, 0xa2, 0xf4, 0x64, 0xaa, 0x3b, 0x7a, 0xd7, 0xa1, 0x6e, + 0xe8, 0x1b, 0xd3, 0xba, 0x81, 0xa3, 0x90, 0x71, 0xa4, 0xae, 0xba, 0x04, 0x07, 0xa0, 0xd6, 0x15, + 0xd4, 0x27, 0x34, 0x14, 0x92, 0x24, 0x9d, 0xd4, 0xa8, 0xc3, 0x99, 0x4c, 0x70, 0x20, 0xed, 0x3b, + 0x60, 0x5d, 0x10, 0xd6, 0x23, 0xc9, 0x21, 0xee, 0xf5, 0x12, 0x22, 0x44, 0xcd, 0x6a, 0x58, 0xf7, + 0x57, 0xfd, 0x35, 0x5d, 0x7d, 0xac, 0x8b, 0xf6, 0x1e, 0xb8, 0x1e, 0x98, 0x91, 0x5c, 0xb8, 0xa4, + 0x84, 0x1b, 0x59, 0xdd, 0x48, 0x21, 0x04, 0x8d, 0x32, 0x37, 0x9f, 0x88, 0x98, 0x33, 0x41, 0x20, + 0x03, 0x4e, 0x57, 0xd0, 0xe7, 0x2c, 0xf9, 0x4f, 0x4c, 0xbb, 0x00, 0x96, 0xfb, 0xe5, 0x54, 0x7d, + 0xb0, 0xad, 0x54, 0x7d, 0x1c, 0x0e, 0xfe, 0x35, 0x51, 0x03, 0xb8, 0xc5, 0x5e, 0x39, 0xcd, 0x1b, + 0x0b, 0x6c, 0xa4, 0x92, 0xb8, 0x87, 0x25, 0x79, 0x8a, 0x13, 0x1c, 0x09, 0xfb, 0x21, 0x58, 0xc5, + 0x43, 0x79, 0xcc, 0x93, 0x50, 0x9e, 0x69, 0x84, 0x76, 0xed, 0xcb, 0xe7, 0xe6, 0xa6, 0x49, 0x80, + 0x59, 0xfe, 0x4c, 0x26, 0x21, 0xa3, 0xfe, 0x44, 0x6a, 0x1f, 0x80, 0x95, 0x58, 0x6d, 0x50, 0x38, + 0x57, 0xf7, 0xb7, 0xbc, 0xa9, 0xe4, 0x7a, 0x7a, 0x7d, 0x7b, 0xf9, 0xe2, 0xfb, 0xed, 0x8a, 0x6f, + 0xa4, 0x8f, 0xd6, 0xcf, 0x7f, 0x7d, 0x7a, 0x30, 0x59, 0x02, 0x77, 0x40, 0x75, 0x86, 0x27, 0x63, + 0xdd, 0xff, 0xb8, 0x0c, 0xae, 0x74, 0x05, 0xb5, 0xdf, 0x5b, 0x60, 0xab, 0x38, 0x67, 0xf7, 0x66, + 0x1c, 0xcb, 0x22, 0xe2, 0xa0, 0x05, 0x85, 0xf9, 0x73, 0x82, 0xe7, 0x5f, 0x7f, 0xbe, 0x5b, 0xaa, + 0x43, 0x07, 0xcd, 0x7e, 0xa5, 0x28, 0x7b, 0xdd, 0xf6, 0x07, 0x0b, 0x54, 0xcb, 0xd2, 0xb6, 0x37, + 0x6f, 0x58, 0x22, 0x75, 0x5a, 0x0b, 0x4b, 0x73, 0xba, 0x5d, 0x45, 0xe7, 0xc2, 0xfa, 0x3c, 0xdd, + 0x30, 0x1f, 0xb5, 0x5f, 0x5b, 0xe0, 0x66, 0x61, 0xee, 0x8a, 0x0c, 0xe7, 0x64, 0x4e, 0x73, 0x21, + 0x59, 0xce, 0xd4, 0x50, 0x4c, 0x0e, 0xac, 0x15, 0x31, 0xa5, 0x63, 0xf6, 0x0b, 0x70, 0x6d, 0x2a, + 0x77, 0x6e, 0x81, 0xc1, 0x1f, 0x7d, 0xe7, 0xee, 0xdf, 0xfb, 0x99, 0x73, 0xfb, 0xc9, 0xc5, 0xc8, + 0xb5, 0x2e, 0x47, 0xae, 0xf5, 0x63, 0xe4, 0x5a, 0x6f, 0xc7, 0x6e, 0xe5, 0x72, 0xec, 0x56, 0xbe, + 0x8d, 0xdd, 0xca, 0xcb, 0x26, 0x0d, 0xe5, 0xf1, 0xf0, 0xc8, 0x0b, 0x78, 0x84, 0x3a, 0x2a, 0xcd, + 0x19, 0xb6, 0xd0, 0x94, 0xa7, 0x86, 0x53, 0x9e, 0xc5, 0x44, 0x1c, 0xad, 0xa8, 0x3f, 0xdb, 0xc1, + 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xcf, 0x84, 0xfe, 0x6c, 0x9a, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -174,6 +473,15 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { + // RegisterClockContract defines the endpoint for + // registering a new clock contract. + RegisterClockContract(ctx context.Context, in *MsgRegisterClockContract, opts ...grpc.CallOption) (*MsgRegisterClockContractResponse, error) + // UnregisterClockContract defines the endpoint for + // unregistering a clock contract. + UnregisterClockContract(ctx context.Context, in *MsgUnregisterClockContract, opts ...grpc.CallOption) (*MsgUnregisterClockContractResponse, error) + // UnjailClockContract defines the endpoint for + // unjailing a clock contract. + UnjailClockContract(ctx context.Context, in *MsgUnjailClockContract, opts ...grpc.CallOption) (*MsgUnjailClockContractResponse, error) // UpdateParams defines a governance operation for updating the x/clock module // parameters. The authority is hard-coded to the x/gov module account. // @@ -189,6 +497,33 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } +func (c *msgClient) RegisterClockContract(ctx context.Context, in *MsgRegisterClockContract, opts ...grpc.CallOption) (*MsgRegisterClockContractResponse, error) { + out := new(MsgRegisterClockContractResponse) + err := c.cc.Invoke(ctx, "/juno.clock.v1.Msg/RegisterClockContract", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UnregisterClockContract(ctx context.Context, in *MsgUnregisterClockContract, opts ...grpc.CallOption) (*MsgUnregisterClockContractResponse, error) { + out := new(MsgUnregisterClockContractResponse) + err := c.cc.Invoke(ctx, "/juno.clock.v1.Msg/UnregisterClockContract", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UnjailClockContract(ctx context.Context, in *MsgUnjailClockContract, opts ...grpc.CallOption) (*MsgUnjailClockContractResponse, error) { + out := new(MsgUnjailClockContractResponse) + err := c.cc.Invoke(ctx, "/juno.clock.v1.Msg/UnjailClockContract", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { out := new(MsgUpdateParamsResponse) err := c.cc.Invoke(ctx, "/juno.clock.v1.Msg/UpdateParams", in, out, opts...) @@ -200,6 +535,15 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts // MsgServer is the server API for Msg service. type MsgServer interface { + // RegisterClockContract defines the endpoint for + // registering a new clock contract. + RegisterClockContract(context.Context, *MsgRegisterClockContract) (*MsgRegisterClockContractResponse, error) + // UnregisterClockContract defines the endpoint for + // unregistering a clock contract. + UnregisterClockContract(context.Context, *MsgUnregisterClockContract) (*MsgUnregisterClockContractResponse, error) + // UnjailClockContract defines the endpoint for + // unjailing a clock contract. + UnjailClockContract(context.Context, *MsgUnjailClockContract) (*MsgUnjailClockContractResponse, error) // UpdateParams defines a governance operation for updating the x/clock module // parameters. The authority is hard-coded to the x/gov module account. // @@ -211,6 +555,15 @@ type MsgServer interface { type UnimplementedMsgServer struct { } +func (*UnimplementedMsgServer) RegisterClockContract(ctx context.Context, req *MsgRegisterClockContract) (*MsgRegisterClockContractResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisterClockContract not implemented") +} +func (*UnimplementedMsgServer) UnregisterClockContract(ctx context.Context, req *MsgUnregisterClockContract) (*MsgUnregisterClockContractResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UnregisterClockContract not implemented") +} +func (*UnimplementedMsgServer) UnjailClockContract(ctx context.Context, req *MsgUnjailClockContract) (*MsgUnjailClockContractResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UnjailClockContract not implemented") +} func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") } @@ -219,6 +572,60 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } +func _Msg_RegisterClockContract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRegisterClockContract) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RegisterClockContract(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/juno.clock.v1.Msg/RegisterClockContract", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RegisterClockContract(ctx, req.(*MsgRegisterClockContract)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UnregisterClockContract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUnregisterClockContract) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UnregisterClockContract(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/juno.clock.v1.Msg/UnregisterClockContract", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UnregisterClockContract(ctx, req.(*MsgUnregisterClockContract)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UnjailClockContract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUnjailClockContract) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UnjailClockContract(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/juno.clock.v1.Msg/UnjailClockContract", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UnjailClockContract(ctx, req.(*MsgUnjailClockContract)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgUpdateParams) if err := dec(in); err != nil { @@ -241,6 +648,18 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "juno.clock.v1.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ + { + MethodName: "RegisterClockContract", + Handler: _Msg_RegisterClockContract_Handler, + }, + { + MethodName: "UnregisterClockContract", + Handler: _Msg_UnregisterClockContract_Handler, + }, + { + MethodName: "UnjailClockContract", + Handler: _Msg_UnjailClockContract_Handler, + }, { MethodName: "UpdateParams", Handler: _Msg_UpdateParams_Handler, @@ -250,7 +669,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Metadata: "juno/clock/v1/tx.proto", } -func (m *MsgUpdateParams) Marshal() (dAtA []byte, err error) { +func (m *MsgRegisterClockContract) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -260,37 +679,34 @@ func (m *MsgUpdateParams) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgRegisterClockContract) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgRegisterClockContract) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + if len(m.ContractAddress) > 0 { + i -= len(m.ContractAddress) + copy(dAtA[i:], m.ContractAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.ContractAddress))) + i-- + dAtA[i] = 0x12 } - i-- - dAtA[i] = 0x12 - if len(m.Authority) > 0 { - i -= len(m.Authority) - copy(dAtA[i:], m.Authority) - i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + if len(m.SenderAddress) > 0 { + i -= len(m.SenderAddress) + copy(dAtA[i:], m.SenderAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.SenderAddress))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *MsgUpdateParamsResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgRegisterClockContractResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -300,12 +716,12 @@ func (m *MsgUpdateParamsResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgRegisterClockContractResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgRegisterClockContractResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -313,17 +729,278 @@ func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func encodeVarintTx(dAtA []byte, offset int, v uint64) int { - offset -= sovTx(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base +func (m *MsgUnregisterClockContract) 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 *MsgUnregisterClockContract) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUnregisterClockContract) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ContractAddress) > 0 { + i -= len(m.ContractAddress) + copy(dAtA[i:], m.ContractAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.ContractAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.SenderAddress) > 0 { + i -= len(m.SenderAddress) + copy(dAtA[i:], m.SenderAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.SenderAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUnregisterClockContractResponse) 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 *MsgUnregisterClockContractResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUnregisterClockContractResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUnjailClockContract) 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 *MsgUnjailClockContract) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUnjailClockContract) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ContractAddress) > 0 { + i -= len(m.ContractAddress) + copy(dAtA[i:], m.ContractAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.ContractAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.SenderAddress) > 0 { + i -= len(m.SenderAddress) + copy(dAtA[i:], m.SenderAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.SenderAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUnjailClockContractResponse) 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 *MsgUnjailClockContractResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUnjailClockContractResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParams) 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 *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } + +func (m *MsgUpdateParamsResponse) 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 *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgRegisterClockContract) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SenderAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ContractAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRegisterClockContractResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUnregisterClockContract) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SenderAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ContractAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUnregisterClockContractResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUnjailClockContract) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SenderAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ContractAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUnjailClockContractResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *MsgUpdateParams) Size() (n int) { if m == nil { return 0 @@ -354,6 +1031,498 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *MsgRegisterClockContract) 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: MsgRegisterClockContract: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterClockContract: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SenderAddress", 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.SenderAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", 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.ContractAddress = 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 *MsgRegisterClockContractResponse) 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: MsgRegisterClockContractResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterClockContractResponse: 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 *MsgUnregisterClockContract) 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: MsgUnregisterClockContract: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUnregisterClockContract: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SenderAddress", 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.SenderAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", 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.ContractAddress = 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 *MsgUnregisterClockContractResponse) 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: MsgUnregisterClockContractResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUnregisterClockContractResponse: 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 *MsgUnjailClockContract) 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: MsgUnjailClockContract: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUnjailClockContract: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SenderAddress", 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.SenderAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", 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.ContractAddress = 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 *MsgUnjailClockContractResponse) 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: MsgUnjailClockContractResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUnjailClockContractResponse: 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 *MsgUpdateParams) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/clock/types/tx.pb.gw.go b/x/clock/types/tx.pb.gw.go new file mode 100644 index 000000000..13af0301c --- /dev/null +++ b/x/clock/types/tx.pb.gw.go @@ -0,0 +1,337 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: juno/clock/v1/tx.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +var ( + filter_Msg_RegisterClockContract_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Msg_RegisterClockContract_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MsgRegisterClockContract + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_RegisterClockContract_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.RegisterClockContract(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Msg_RegisterClockContract_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MsgRegisterClockContract + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_RegisterClockContract_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.RegisterClockContract(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Msg_UnregisterClockContract_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Msg_UnregisterClockContract_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MsgUnregisterClockContract + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_UnregisterClockContract_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.UnregisterClockContract(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Msg_UnregisterClockContract_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MsgUnregisterClockContract + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_UnregisterClockContract_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.UnregisterClockContract(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Msg_UnjailClockContract_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Msg_UnjailClockContract_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MsgUnjailClockContract + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_UnjailClockContract_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.UnjailClockContract(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Msg_UnjailClockContract_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MsgUnjailClockContract + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_UnjailClockContract_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.UnjailClockContract(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". +// UnaryRPC :call MsgServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead. +func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error { + + mux.Handle("POST", pattern_Msg_RegisterClockContract_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_Msg_RegisterClockContract_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_Msg_RegisterClockContract_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Msg_UnregisterClockContract_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_Msg_UnregisterClockContract_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_Msg_UnregisterClockContract_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Msg_UnjailClockContract_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_Msg_UnjailClockContract_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_Msg_UnjailClockContract_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterMsgHandler(ctx, mux, conn) +} + +// RegisterMsgHandler registers the http handlers for service Msg to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn)) +} + +// RegisterMsgHandlerClient registers the http handlers for service Msg +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "MsgClient" to call the correct interceptors. +func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error { + + mux.Handle("POST", pattern_Msg_RegisterClockContract_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_Msg_RegisterClockContract_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Msg_RegisterClockContract_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Msg_UnregisterClockContract_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_Msg_UnregisterClockContract_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Msg_UnregisterClockContract_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Msg_UnjailClockContract_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_Msg_UnjailClockContract_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Msg_UnjailClockContract_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Msg_RegisterClockContract_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"juno", "clock", "v1", "tx", "register"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Msg_UnregisterClockContract_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"juno", "clock", "v1", "tx", "unregister"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Msg_UnjailClockContract_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"juno", "clock", "v1", "tx", "unjail"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Msg_RegisterClockContract_0 = runtime.ForwardResponseMessage + + forward_Msg_UnregisterClockContract_0 = runtime.ForwardResponseMessage + + forward_Msg_UnjailClockContract_0 = runtime.ForwardResponseMessage +) diff --git a/x/feepay/types/tx.pb.go b/x/feepay/types/tx.pb.go index 55faee6c0..e90b07837 100644 --- a/x/feepay/types/tx.pb.go +++ b/x/feepay/types/tx.pb.go @@ -539,56 +539,56 @@ func init() { func init() { proto.RegisterFile("juno/feepay/v1/tx.proto", fileDescriptor_d739bd30c8846fd5) } var fileDescriptor_d739bd30c8846fd5 = []byte{ - // 769 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x95, 0x4f, 0x4f, 0x1b, 0x47, - 0x18, 0xc6, 0x3d, 0x18, 0x59, 0x62, 0xa0, 0x86, 0xae, 0x28, 0xd8, 0xa6, 0x5d, 0x9b, 0x45, 0x08, - 0x63, 0xea, 0x5d, 0xd9, 0xa0, 0x1e, 0x7c, 0xab, 0x91, 0x10, 0x87, 0x5a, 0x42, 0x5b, 0x55, 0xad, - 0x7a, 0xb1, 0xc6, 0xf6, 0x78, 0xd9, 0xd6, 0x3b, 0xb3, 0xda, 0x19, 0x03, 0xbe, 0xf2, 0x05, 0x5a, - 0xb5, 0xa7, 0xf6, 0x92, 0x1c, 0xf3, 0xe7, 0x42, 0xa4, 0x7c, 0x08, 0x2e, 0x91, 0x50, 0x72, 0xc9, - 0x29, 0x89, 0x20, 0x12, 0x51, 0x3e, 0x45, 0xb4, 0xbb, 0xb3, 0x4b, 0x6c, 0x76, 0x31, 0x28, 0xe2, - 0x62, 0x7b, 0xe6, 0x79, 0x66, 0xde, 0xdf, 0xfb, 0xce, 0xbc, 0x63, 0xb8, 0xf8, 0x47, 0x9f, 0x50, - 0xad, 0x8b, 0xb1, 0x8d, 0x06, 0xda, 0x41, 0x45, 0xe3, 0x47, 0xaa, 0xed, 0x50, 0x4e, 0xa5, 0xb4, - 0x2b, 0xa8, 0xbe, 0xa0, 0x1e, 0x54, 0x72, 0xf3, 0x06, 0x35, 0xa8, 0x27, 0x69, 0xee, 0x2f, 0xdf, - 0x95, 0xfb, 0xd6, 0xa0, 0xd4, 0xe8, 0x61, 0x0d, 0xd9, 0xa6, 0x86, 0x08, 0xa1, 0x1c, 0x71, 0x93, - 0x12, 0x26, 0xd4, 0xaf, 0x91, 0x65, 0x12, 0xaa, 0x79, 0x9f, 0x62, 0x6a, 0xb1, 0x4d, 0x99, 0x45, - 0x99, 0x66, 0x31, 0xc3, 0x0d, 0x67, 0x31, 0x43, 0x08, 0xb2, 0x10, 0x5a, 0x88, 0x61, 0xed, 0xa0, - 0xd2, 0xc2, 0x1c, 0x55, 0xb4, 0x36, 0x35, 0x89, 0xd0, 0xb3, 0xbe, 0xde, 0xf4, 0x11, 0xfc, 0x41, - 0x00, 0x31, 0x92, 0x83, 0x81, 0x09, 0x66, 0x66, 0xa0, 0x2e, 0x8d, 0xa8, 0x22, 0x25, 0x4f, 0x54, - 0xfe, 0x01, 0x30, 0xdb, 0x60, 0x86, 0x8e, 0x0d, 0x93, 0x71, 0xec, 0xec, 0x60, 0xbc, 0x87, 0x06, - 0xdb, 0x94, 0x70, 0x07, 0xb5, 0xb9, 0xb4, 0x0a, 0xd3, 0x0c, 0x93, 0x0e, 0x76, 0x9a, 0xa8, 0xd3, - 0x71, 0x30, 0x63, 0x19, 0x50, 0x00, 0xc5, 0x29, 0xfd, 0x2b, 0x7f, 0xf6, 0x47, 0x7f, 0x52, 0xda, - 0x85, 0x73, 0x5d, 0x8c, 0x9b, 0x36, 0x1a, 0x34, 0xdb, 0x62, 0x69, 0x66, 0xa2, 0x00, 0x8a, 0xd3, - 0x55, 0x59, 0x1d, 0xae, 0xa2, 0x3a, 0x1c, 0x40, 0x4f, 0x77, 0x87, 0xc6, 0xb5, 0xc9, 0x0f, 0x0f, - 0xf3, 0x09, 0x65, 0x05, 0x2e, 0xc7, 0x32, 0xe9, 0x98, 0xd9, 0x94, 0x30, 0xac, 0xf4, 0xe1, 0x52, - 0x83, 0x19, 0xbf, 0x10, 0xe7, 0x8b, 0xd0, 0xd7, 0xe1, 0x5c, 0x80, 0x1c, 0x1a, 0x27, 0x3c, 0xe3, - 0x6c, 0x30, 0x2f, 0xac, 0x82, 0x6d, 0x15, 0xae, 0xdc, 0x10, 0x36, 0xa4, 0xfb, 0x08, 0xe0, 0x37, - 0x0d, 0x66, 0xec, 0xf4, 0x49, 0xe7, 0xbe, 0xc1, 0xa4, 0x01, 0x4c, 0x21, 0x8b, 0xf6, 0x09, 0xcf, - 0x24, 0x0b, 0xc9, 0xe2, 0x74, 0x35, 0xab, 0x8a, 0xdb, 0xe1, 0x5e, 0x25, 0x55, 0x5c, 0x25, 0x75, - 0x9b, 0x9a, 0xa4, 0xbe, 0x73, 0xfa, 0x26, 0x9f, 0x78, 0xf2, 0x36, 0x5f, 0x34, 0x4c, 0xbe, 0xdf, - 0x6f, 0xa9, 0x6d, 0x6a, 0x89, 0xab, 0x24, 0xbe, 0xca, 0xac, 0xf3, 0xa7, 0xc6, 0x07, 0x36, 0x66, - 0xde, 0x02, 0xf6, 0xff, 0xe5, 0x49, 0x69, 0xa6, 0x87, 0x0d, 0xd4, 0x76, 0xcf, 0xd6, 0x24, 0xec, - 0xd1, 0xe5, 0x49, 0x09, 0xe8, 0x22, 0xa0, 0xa8, 0x49, 0x1e, 0x7e, 0x17, 0x99, 0x6b, 0x58, 0x8d, - 0x07, 0x00, 0x2a, 0x6e, 0xd5, 0xec, 0x0e, 0xe2, 0x78, 0xd8, 0xf3, 0x2b, 0xea, 0xf5, 0x30, 0xff, - 0xc9, 0xb4, 0xcc, 0xfb, 0x28, 0xcd, 0x32, 0x9c, 0x39, 0xf4, 0x02, 0x34, 0x7b, 0x6e, 0x84, 0x4c, - 0xb2, 0x00, 0x8a, 0x93, 0xfa, 0xf4, 0xe1, 0x55, 0x50, 0x91, 0xc2, 0xf7, 0xb0, 0x34, 0x1e, 0x30, - 0xcc, 0xe7, 0x2f, 0x00, 0x67, 0x43, 0xfb, 0x1e, 0x72, 0x90, 0xc5, 0xa4, 0x1f, 0xe0, 0x14, 0xea, - 0xf3, 0x7d, 0xea, 0x98, 0x7c, 0xe0, 0x73, 0xd7, 0x33, 0x2f, 0x9f, 0x97, 0xe7, 0xc5, 0x59, 0x08, - 0xa2, 0x9f, 0xb9, 0x63, 0x12, 0x43, 0xbf, 0xb2, 0x4a, 0x5b, 0x30, 0x65, 0x7b, 0x3b, 0x88, 0x96, - 0x59, 0x18, 0x6d, 0x19, 0x7f, 0xff, 0xfa, 0xa4, 0x7b, 0x74, 0xba, 0xf0, 0xd6, 0xd2, 0xc7, 0x97, - 0x27, 0xa5, 0xab, 0x5d, 0x94, 0x2c, 0x5c, 0x1c, 0x01, 0x0a, 0x60, 0xab, 0x4f, 0x53, 0x30, 0xd9, - 0x60, 0x86, 0xf4, 0x18, 0xc0, 0x85, 0x98, 0x3e, 0x5f, 0x1f, 0x8d, 0x19, 0xdb, 0x7e, 0xb9, 0xca, - 0xad, 0xad, 0x61, 0xb5, 0x2a, 0xc7, 0xaf, 0xde, 0xff, 0x3b, 0xb1, 0xa1, 0xac, 0x6b, 0xd7, 0xde, - 0x5a, 0x2d, 0xa6, 0x7b, 0x9f, 0x01, 0x98, 0x89, 0x6d, 0xed, 0x8d, 0x08, 0x84, 0x38, 0x73, 0x6e, - 0xf3, 0x0e, 0xe6, 0x90, 0x78, 0xd3, 0x23, 0x2e, 0x2b, 0x1b, 0x11, 0xc4, 0xfd, 0x38, 0xac, 0xff, - 0x00, 0x94, 0xa2, 0xfa, 0x3d, 0x02, 0xe0, 0xba, 0x2d, 0x57, 0xbe, 0x95, 0x2d, 0x24, 0x2c, 0x7b, - 0x84, 0x6b, 0xca, 0x6a, 0x04, 0x61, 0xf7, 0x3a, 0xc4, 0x0b, 0x00, 0xf3, 0xe3, 0xba, 0xaf, 0x1a, - 0x55, 0xa9, 0x9b, 0xd7, 0xe4, 0x6a, 0x77, 0x5f, 0x13, 0xa6, 0x50, 0xf3, 0x52, 0xd8, 0x52, 0xaa, - 0x51, 0x45, 0x1e, 0xc3, 0xfa, 0x1b, 0x9c, 0x19, 0x6a, 0xbe, 0x7c, 0x2c, 0x87, 0x6f, 0xc8, 0xad, - 0x8d, 0x31, 0x04, 0x54, 0xf5, 0xdd, 0xd3, 0x73, 0x19, 0x9c, 0x9d, 0xcb, 0xe0, 0xdd, 0xb9, 0x0c, - 0xfe, 0xbe, 0x90, 0x13, 0x67, 0x17, 0x72, 0xe2, 0xf5, 0x85, 0x9c, 0xf8, 0x5d, 0xfd, 0xec, 0xcd, - 0xdc, 0xf6, 0x9a, 0x3a, 0x20, 0x63, 0x7e, 0x06, 0x47, 0x41, 0x0e, 0xde, 0xfb, 0xd9, 0x4a, 0x79, - 0xff, 0xb0, 0x9b, 0x9f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x2c, 0x2b, 0xd3, 0x5b, 0x62, 0x08, 0x00, - 0x00, + // 776 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x95, 0xcd, 0x4f, 0xdb, 0x48, + 0x18, 0xc6, 0x33, 0x84, 0x45, 0x62, 0x60, 0x03, 0x6b, 0xb1, 0xe4, 0x83, 0xc5, 0x0e, 0x46, 0xec, + 0x86, 0xec, 0x62, 0x2b, 0x61, 0xb5, 0x07, 0x6e, 0x1b, 0x24, 0xc4, 0x61, 0x23, 0x21, 0xaf, 0x56, + 0xbb, 0xda, 0x4b, 0x34, 0x49, 0x26, 0xc6, 0xbb, 0xf1, 0x8c, 0xe5, 0x19, 0x03, 0xb9, 0x72, 0xed, + 0xa1, 0x55, 0x7b, 0x6b, 0x0f, 0xad, 0xd4, 0x4b, 0xd5, 0x13, 0x87, 0xfe, 0x03, 0xbd, 0x71, 0x44, + 0xed, 0xa5, 0xa7, 0xb6, 0x82, 0x4a, 0x54, 0xbd, 0xf7, 0x5e, 0xd9, 0x1e, 0x1b, 0x12, 0x1c, 0x3e, + 0x54, 0x71, 0x49, 0xe2, 0x79, 0x9f, 0x99, 0xe7, 0x37, 0xaf, 0xe7, 0x99, 0xc0, 0xec, 0x7f, 0x1e, + 0xa1, 0x7a, 0x07, 0x63, 0x07, 0xf5, 0xf4, 0x9d, 0x8a, 0xce, 0xf7, 0x34, 0xc7, 0xa5, 0x9c, 0x4a, + 0x19, 0xbf, 0xa0, 0x85, 0x05, 0x6d, 0xa7, 0x52, 0x98, 0x31, 0xa9, 0x49, 0x83, 0x92, 0xee, 0xff, + 0x0a, 0x55, 0x85, 0x1f, 0x4c, 0x4a, 0xcd, 0x2e, 0xd6, 0x91, 0x63, 0xe9, 0x88, 0x10, 0xca, 0x11, + 0xb7, 0x28, 0x61, 0xa2, 0xfa, 0x1d, 0xb2, 0x2d, 0x42, 0xf5, 0xe0, 0x53, 0x0c, 0x65, 0x5b, 0x94, + 0xd9, 0x94, 0xe9, 0x36, 0x33, 0x7d, 0x3b, 0x9b, 0x99, 0xa2, 0x20, 0x8b, 0x42, 0x13, 0x31, 0xac, + 0xef, 0x54, 0x9a, 0x98, 0xa3, 0x8a, 0xde, 0xa2, 0x16, 0x11, 0xf5, 0x7c, 0x58, 0x6f, 0x84, 0x08, + 0xe1, 0x43, 0x04, 0x31, 0xb0, 0x07, 0x13, 0x13, 0xcc, 0xac, 0xa8, 0x3a, 0x37, 0x50, 0x15, 0x5b, + 0x0a, 0x8a, 0xea, 0x7d, 0x00, 0xf3, 0x75, 0x66, 0x1a, 0xd8, 0xb4, 0x18, 0xc7, 0xee, 0x06, 0xc6, + 0x5b, 0xa8, 0xb7, 0x4e, 0x09, 0x77, 0x51, 0x8b, 0x4b, 0x4b, 0x30, 0xc3, 0x30, 0x69, 0x63, 0xb7, + 0x81, 0xda, 0x6d, 0x17, 0x33, 0x96, 0x03, 0x45, 0x50, 0x1a, 0x37, 0xbe, 0x0d, 0x47, 0x7f, 0x0f, + 0x07, 0xa5, 0x4d, 0x38, 0xdd, 0xc1, 0xb8, 0xe1, 0xa0, 0x5e, 0xa3, 0x25, 0xa6, 0xe6, 0x46, 0x8a, + 0xa0, 0x34, 0x51, 0x95, 0xb5, 0xfe, 0x2e, 0x6a, 0xfd, 0x06, 0x46, 0xa6, 0xd3, 0xf7, 0xbc, 0x36, + 0xfa, 0xf1, 0x89, 0x92, 0x52, 0x17, 0xe1, 0xc2, 0x50, 0x26, 0x03, 0x33, 0x87, 0x12, 0x86, 0x55, + 0x0f, 0xce, 0xd5, 0x99, 0xf9, 0x17, 0x71, 0xbf, 0x0a, 0x7d, 0x19, 0x4e, 0x47, 0xc8, 0xb1, 0x70, + 0x24, 0x10, 0x4e, 0x45, 0xe3, 0x42, 0x2a, 0xd8, 0x96, 0xe0, 0xe2, 0x25, 0xb6, 0x31, 0xdd, 0x27, + 0x00, 0xbf, 0xaf, 0x33, 0x73, 0xc3, 0x23, 0xed, 0xdb, 0x06, 0x93, 0x7a, 0x70, 0x0c, 0xd9, 0xd4, + 0x23, 0x3c, 0x97, 0x2e, 0xa6, 0x4b, 0x13, 0xd5, 0xbc, 0x26, 0x4e, 0x87, 0x7f, 0x94, 0x34, 0x71, + 0x94, 0xb4, 0x75, 0x6a, 0x91, 0xda, 0xc6, 0xe1, 0x5b, 0x25, 0xf5, 0xfc, 0x9d, 0x52, 0x32, 0x2d, + 0xbe, 0xed, 0x35, 0xb5, 0x16, 0xb5, 0xc5, 0x51, 0x12, 0x5f, 0x2b, 0xac, 0xfd, 0xbf, 0xce, 0x7b, + 0x0e, 0x66, 0xc1, 0x04, 0xf6, 0xf0, 0xf4, 0xa0, 0x3c, 0xd9, 0xc5, 0x26, 0x6a, 0xf9, 0xef, 0xd6, + 0x22, 0xec, 0xd9, 0xe9, 0x41, 0x19, 0x18, 0xc2, 0x50, 0xf4, 0x44, 0x81, 0xf3, 0x89, 0x7b, 0x8d, + 0xbb, 0xf1, 0x18, 0x40, 0xd5, 0xef, 0x9a, 0xd3, 0x46, 0x1c, 0xf7, 0x6b, 0xfe, 0x46, 0xdd, 0x2e, + 0xe6, 0x7f, 0x58, 0xb6, 0x75, 0x1b, 0xad, 0x59, 0x80, 0x93, 0xbb, 0x81, 0x41, 0xa3, 0xeb, 0x3b, + 0xe4, 0xd2, 0x45, 0x50, 0x1a, 0x35, 0x26, 0x76, 0xcf, 0x4c, 0xc5, 0x16, 0x7e, 0x81, 0xe5, 0xab, + 0x01, 0xe3, 0xfd, 0xdc, 0x05, 0x70, 0x2a, 0x96, 0x6f, 0x21, 0x17, 0xd9, 0x4c, 0xfa, 0x0d, 0x8e, + 0x23, 0x8f, 0x6f, 0x53, 0xd7, 0xe2, 0xbd, 0x90, 0xbb, 0x96, 0x7b, 0xf5, 0x62, 0x65, 0x46, 0xbc, + 0x0b, 0x41, 0xf4, 0x27, 0x77, 0x2d, 0x62, 0x1a, 0x67, 0x52, 0xe9, 0x57, 0x38, 0xe6, 0x04, 0x2b, + 0x88, 0xc8, 0xcc, 0x0e, 0x46, 0x26, 0x5c, 0xbf, 0x36, 0xea, 0xbf, 0x3a, 0x43, 0x68, 0xd7, 0x32, + 0xfb, 0xa7, 0x07, 0xe5, 0xb3, 0x55, 0xd4, 0x3c, 0xcc, 0x0e, 0x00, 0x45, 0xb0, 0xd5, 0xcf, 0xdf, + 0xc0, 0x74, 0x9d, 0x99, 0xd2, 0x23, 0x00, 0x67, 0x87, 0xe4, 0x7c, 0x79, 0xd0, 0x73, 0x68, 0xfc, + 0x0a, 0x95, 0x6b, 0x4b, 0xe3, 0x6e, 0x2d, 0xee, 0xbf, 0xfe, 0xf0, 0x60, 0x64, 0x5e, 0x9d, 0xd3, + 0x2f, 0xdc, 0xb5, 0x7a, 0x14, 0x23, 0xe9, 0x29, 0x80, 0xb9, 0xa1, 0x61, 0xfe, 0x39, 0xc1, 0x74, + 0x98, 0xb8, 0xb0, 0x7a, 0x03, 0x71, 0xcc, 0xb8, 0x14, 0x30, 0x2a, 0xea, 0x7c, 0x02, 0xa3, 0x17, + 0x4f, 0x96, 0xee, 0x00, 0x28, 0x25, 0x65, 0x3a, 0xc1, 0xf2, 0xa2, 0xac, 0xb0, 0x72, 0x2d, 0x59, + 0xcc, 0xa4, 0x04, 0x4c, 0x79, 0x35, 0x9b, 0xc0, 0xd4, 0xf1, 0x48, 0x5b, 0x7a, 0x09, 0xa0, 0x72, + 0x55, 0xa6, 0xaa, 0x49, 0xdd, 0xb8, 0x7c, 0x4e, 0x61, 0xed, 0xe6, 0x73, 0x62, 0x68, 0x2d, 0x80, + 0x2e, 0xa9, 0x3f, 0x26, 0x35, 0x32, 0x58, 0xa3, 0x71, 0x3e, 0x91, 0xd2, 0x3f, 0x70, 0xb2, 0x2f, + 0x46, 0xca, 0x50, 0xef, 0x50, 0x50, 0xf8, 0xe9, 0x0a, 0x41, 0x44, 0x52, 0xdb, 0x3c, 0x3c, 0x96, + 0xc1, 0xd1, 0xb1, 0x0c, 0xde, 0x1f, 0xcb, 0xe0, 0xde, 0x89, 0x9c, 0x3a, 0x3a, 0x91, 0x53, 0x6f, + 0x4e, 0xe4, 0xd4, 0xbf, 0xda, 0xb9, 0xdb, 0x6f, 0x3d, 0x88, 0x67, 0xb4, 0x23, 0x16, 0x52, 0xef, + 0x45, 0xdc, 0xc1, 0x4d, 0xd8, 0x1c, 0x0b, 0xfe, 0x2b, 0x57, 0xbf, 0x04, 0x00, 0x00, 0xff, 0xff, + 0x49, 0x6c, 0x87, 0x59, 0x2c, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/feepay/types/tx.pb.gw.go b/x/feepay/types/tx.pb.gw.go index 2eef89984..1a1d8d9bf 100644 --- a/x/feepay/types/tx.pb.gw.go +++ b/x/feepay/types/tx.pb.gw.go @@ -400,13 +400,13 @@ func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client } var ( - pattern_Msg_RegisterFeePayContract_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"juno", "feepay", "v1", "tx", "registerFeePayContract"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Msg_RegisterFeePayContract_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"juno", "feepay", "v1", "tx", "register"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Msg_UnregisterFeePayContract_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"juno", "feepay", "v1", "tx", "unregisterFeePayContract"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Msg_UnregisterFeePayContract_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"juno", "feepay", "v1", "tx", "unregister"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Msg_FundFeePayContract_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"juno", "feepay", "v1", "tx", "fundFeePayContract"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Msg_FundFeePayContract_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"juno", "feepay", "v1", "tx", "fund"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Msg_UpdateFeePayContractWalletLimit_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"juno", "feepay", "v1", "tx", "updateFeePayContractWalletLimit"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Msg_UpdateFeePayContractWalletLimit_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"juno", "feepay", "v1", "tx", "update_wallet_limit"}, "", runtime.AssumeColonVerbOpt(false))) ) var (