diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dcee358d..1a4264663 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * [#1705](https://github.com/NibiruChain/nibiru/pull/1705) - feat(perp): Add oracle pair to market object * [#1718](https://github.com/NibiruChain/nibiru/pull/1718) - fix: fees does not require additional funds * [#1734](https://github.com/NibiruChain/nibiru/pull/1734) - feat(perp): MsgDonateToPerpFund sudo call as part of #1642 +* [#1752](https://github.com/NibiruChain/nibiru/pull/1752) - feat(oracle): MsgEditOracleParams sudo tx msg as part of #1642 * [#1755](https://github.com/NibiruChain/nibiru/pull/1755) - feat(oracle): Add more events on validator's performance * [#1749](https://github.com/NibiruChain/nibiru/pull/1749) - feat(perp): move close market from Wasm Binding to MsgCloseMarket diff --git a/app/keepers.go b/app/keepers.go index b623ebbbb..efefdc215 100644 --- a/app/keepers.go +++ b/app/keepers.go @@ -357,18 +357,20 @@ func (app *NibiruApp) InitKeepers( appCodec, keys[spottypes.StoreKey], app.GetSubspace(spottypes.ModuleName), app.AccountKeeper, app.BankKeeper, app.DistrKeeper) + app.SudoKeeper = keeper.NewKeeper( + appCodec, keys[sudotypes.StoreKey], + ) + app.OracleKeeper = oraclekeeper.NewKeeper(appCodec, keys[oracletypes.StoreKey], - app.AccountKeeper, app.BankKeeper, app.DistrKeeper, app.stakingKeeper, distrtypes.ModuleName, + app.AccountKeeper, app.BankKeeper, app.DistrKeeper, app.stakingKeeper, + app.SudoKeeper, + distrtypes.ModuleName, ) app.EpochsKeeper = epochskeeper.NewKeeper( appCodec, keys[epochstypes.StoreKey], ) - app.SudoKeeper = keeper.NewKeeper( - appCodec, keys[sudotypes.StoreKey], - ) - app.PerpKeeperV2 = perpkeeper.NewKeeper( appCodec, keys[perptypes.StoreKey], app.AccountKeeper, app.BankKeeper, app.OracleKeeper, app.EpochsKeeper, diff --git a/proto/nibiru/oracle/v1/oracle.proto b/proto/nibiru/oracle/v1/oracle.proto index d9969b32e..0e12baad2 100644 --- a/proto/nibiru/oracle/v1/oracle.proto +++ b/proto/nibiru/oracle/v1/oracle.proto @@ -60,7 +60,8 @@ message Params { (gogoproto.nullable) = false ]; - // Amount of time to look back for TWAP calculations + // Amount of time to look back for TWAP calculations. + // Ex: "900.000000069s" corresponds to 900 seconds and 69 nanoseconds in JSON. google.protobuf.Duration twap_lookback_window = 8 [ (gogoproto.nullable) = false, (gogoproto.stdduration) = true, @@ -79,9 +80,8 @@ message Params { (gogoproto.nullable) = false ]; - uint64 expiration_blocks = 11 [ - (gogoproto.moretags) = "yaml:\"expiration_blocks\"" - ]; + uint64 expiration_blocks = 11 + [ (gogoproto.moretags) = "yaml:\"expiration_blocks\"" ]; } // Struct for aggregate prevoting on the ExchangeRateVote. @@ -154,4 +154,4 @@ message Rewards { uint64 vote_periods = 2; // Coins defines the amount of coins to distribute in a single vote period. repeated cosmos.base.v1beta1.Coin coins = 3 [ (gogoproto.nullable) = false ]; -} \ No newline at end of file +} diff --git a/proto/nibiru/oracle/v1/tx.proto b/proto/nibiru/oracle/v1/tx.proto index 19fd2f833..299023008 100644 --- a/proto/nibiru/oracle/v1/tx.proto +++ b/proto/nibiru/oracle/v1/tx.proto @@ -3,6 +3,7 @@ package nibiru.oracle.v1; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; +import "nibiru/oracle/v1/oracle.proto"; option go_package = "github.com/NibiruChain/nibiru/x/oracle/types"; @@ -29,6 +30,11 @@ service Msg { returns (MsgDelegateFeedConsentResponse) { option (google.api.http).post = "/nibiru/oracle/feeder-delegate"; } + + rpc EditOracleParams(MsgEditOracleParams) + returns (MsgEditOracleParamsResponse) { + option (google.api.http).post = "/nibiru/oracle/edit-oracle-params"; + } } // MsgAggregateExchangeRatePrevote represents a message to submit @@ -84,3 +90,65 @@ message MsgDelegateFeedConsent { // MsgDelegateFeedConsentResponse defines the Msg/DelegateFeedConsent response // type. message MsgDelegateFeedConsentResponse {} + +// MsgEditOracleParams: gRPC tx message for updating the x/oracle module params +// [SUDO] Only callable by sudoers. +message MsgEditOracleParams { + string sender = 1; + + string vote_period = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = true + ]; + + // vote_threshold: [cosmossdk.io/math.LegacyDec] TODO: + string vote_threshold = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = true + ]; + + // reward_band: [cosmossdk.io/math.LegacyDec] TODO: + string reward_band = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = true + ]; + + repeated string whitelist = 5 [ (gogoproto.nullable) = true ]; + + // slash_fraction: [cosmossdk.io/math.LegacyDec] TODO: + string slash_fraction = 6 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = true + ]; + + string slash_window = 7 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = true + ]; + + // min_valid_per_window: [cosmossdk.io/math.LegacyDec] TODO: + string min_valid_per_window = 8 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = true + ]; + + string twap_lookback_window = 9 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = true + ]; + + string min_voters = 10 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = true + ]; + + // VoteThreshold: [cosmossdk.io/math.LegacyDec] TODO: + string validator_fee_ratio = 11 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = true + ]; +} + +// MsgEditOracleParamsResponse defines the Msg/EditOracleParams response +// type. +message MsgEditOracleParamsResponse { nibiru.oracle.v1.Params new_params = 1; } diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index c8031720e..48f520dbd 100644 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -27,9 +27,11 @@ type Keeper struct { bankKeeper types.BankKeeper distrKeeper types.DistributionKeeper StakingKeeper types.StakingKeeper + SudoKeeper types.SudoKeeper distrModuleName string + // Module parameters Params collections.Item[types.Params] ExchangeRates collections.Map[asset.Pair, types.DatedPrice] FeederDelegations collections.Map[sdk.ValAddress, sdk.AccAddress] @@ -38,30 +40,40 @@ type Keeper struct { Votes collections.Map[sdk.ValAddress, types.AggregateExchangeRateVote] // PriceSnapshots maps types.PriceSnapshot to the asset.Pair of the snapshot and the creation timestamp as keys.Uint64Key. - PriceSnapshots collections.Map[collections.Pair[asset.Pair, time.Time], types.PriceSnapshot] + PriceSnapshots collections.Map[ + collections.Pair[asset.Pair, time.Time], + types.PriceSnapshot] WhitelistedPairs collections.KeySet[asset.Pair] Rewards collections.Map[uint64, types.Rewards] RewardsID collections.Sequence } // NewKeeper constructs a new keeper for oracle -func NewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey, +func NewKeeper( + cdc codec.BinaryCodec, + storeKey storetypes.StoreKey, + accountKeeper types.AccountKeeper, - bankKeeper types.BankKeeper, distrKeeper types.DistributionKeeper, - stakingKeeper types.StakingKeeper, distrName string, + bankKeeper types.BankKeeper, + distrKeeper types.DistributionKeeper, + stakingKeeper types.StakingKeeper, + sudoKeeper types.SudoKeeper, + + distrName string, ) Keeper { // ensure oracle module account is set if addr := accountKeeper.GetModuleAddress(types.ModuleName); addr == nil { panic(fmt.Sprintf("%s module account has not been set", types.ModuleName)) } - return Keeper{ + k := Keeper{ cdc: cdc, storeKey: storeKey, AccountKeeper: accountKeeper, bankKeeper: bankKeeper, distrKeeper: distrKeeper, StakingKeeper: stakingKeeper, + SudoKeeper: sudoKeeper, distrModuleName: distrName, Params: collections.NewItem(storeKey, 11, collections.ProtoValueEncoder[types.Params](cdc)), ExchangeRates: collections.NewMap(storeKey, 1, asset.PairKeyEncoder, collections.ProtoValueEncoder[types.DatedPrice](cdc)), @@ -76,6 +88,7 @@ func NewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey, collections.Uint64KeyEncoder, collections.ProtoValueEncoder[types.Rewards](cdc)), RewardsID: collections.NewSequence(storeKey, 9), } + return k } // Logger returns a module-specific logger. diff --git a/x/oracle/keeper/msg_server.go b/x/oracle/keeper/msg_server.go index 7bed77107..c21a8dcd5 100644 --- a/x/oracle/keeper/msg_server.go +++ b/x/oracle/keeper/msg_server.go @@ -113,7 +113,7 @@ func (ms msgServer) AggregateExchangeRateVote( hash := types.GetAggregateVoteHash(msg.Salt, msg.ExchangeRates, valAddr) if aggregatePrevote.Hash != hash.String() { return nil, sdkerrors.Wrapf( - types.ErrVerificationFailed, "must be given %s not %s", aggregatePrevote.Hash, hash, + types.ErrHashVerificationFailed, "must be given %s not %s", aggregatePrevote.Hash, hash, ) } @@ -167,3 +167,21 @@ func (ms msgServer) DelegateFeedConsent( return &types.MsgDelegateFeedConsentResponse{}, err } + +// EditOracleParams: gRPC tx msg for editing the oracle module params. +// [SUDO] Only callable by sudoers. +func (ms msgServer) EditOracleParams( + goCtx context.Context, msg *types.MsgEditOracleParams, +) (resp *types.MsgEditOracleParamsResponse, err error) { + ctx := sdk.UnwrapSDKContext(goCtx) + // Stateless field validation is already performed in msg.ValidateBasic() + // before the current scope is reached. + sender, _ := sdk.AccAddressFromBech32(msg.Sender) + newParams, err := ms.Sudo().EditOracleParams( + ctx, *msg, sender, + ) + resp = &types.MsgEditOracleParamsResponse{ + NewParams: &newParams, + } + return resp, err +} diff --git a/x/oracle/keeper/sudo.go b/x/oracle/keeper/sudo.go new file mode 100644 index 000000000..05e38973f --- /dev/null +++ b/x/oracle/keeper/sudo.go @@ -0,0 +1,100 @@ +package keeper + +import ( + "fmt" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/NibiruChain/nibiru/x/common/asset" + oracletypes "github.com/NibiruChain/nibiru/x/oracle/types" +) + +// Sudo extends the Keeper with sudo functions. See sudo.go. Sudo is syntactic +// sugar to separate admin calls off from the other Keeper methods. +// +// These Sudo functions should: +// 1. Not be called in other methods in the x/perp module. +// 2. Only be callable by the x/sudo root or sudo contracts. +// +// The intention behind "Keeper.Sudo()" is to make it more obvious to the +// developer that an unsafe function is being used when it's called. +func (k Keeper) Sudo() sudoExtension { return sudoExtension{k} } + +type sudoExtension struct{ Keeper } + +// ------------------------------------------------------------------ +// Admin.EditOracleParams + +func (k sudoExtension) EditOracleParams( + ctx sdk.Context, newParams oracletypes.MsgEditOracleParams, + sender sdk.AccAddress, +) (paramsAfter oracletypes.Params, err error) { + if err := k.SudoKeeper.CheckPermissions(sender, ctx); err != nil { + return paramsAfter, err + } + + params, err := k.Params.Get(ctx) + if err != nil { + return paramsAfter, fmt.Errorf("%w: failed to read oracle params", err) + } + + paramsAfter = MergeOracleParams(newParams, params) + k.UpdateParams(ctx, paramsAfter) + return paramsAfter, paramsAfter.Validate() +} + +// MergeOracleParams: Takes the given oracle params and merges them into the +// existing partial params, keeping any existing values that are not set in the +// partial. +func MergeOracleParams( + partial oracletypes.MsgEditOracleParams, + oracleParams oracletypes.Params, +) oracletypes.Params { + if partial.VotePeriod != nil { + oracleParams.VotePeriod = partial.VotePeriod.Uint64() + } + + if partial.VoteThreshold != nil { + oracleParams.VoteThreshold = *partial.VoteThreshold + } + + if partial.RewardBand != nil { + oracleParams.RewardBand = *partial.RewardBand + } + + if partial.Whitelist != nil { + whitelist := make([]asset.Pair, len(partial.Whitelist)) + for i, pair := range partial.Whitelist { + whitelist[i] = asset.MustNewPair(pair) + } + + oracleParams.Whitelist = whitelist + } + + if partial.SlashFraction != nil { + oracleParams.SlashFraction = *partial.SlashFraction + } + + if partial.SlashWindow != nil { + oracleParams.SlashWindow = partial.SlashWindow.Uint64() + } + + if partial.MinValidPerWindow != nil { + oracleParams.MinValidPerWindow = *partial.MinValidPerWindow + } + + if partial.TwapLookbackWindow != nil { + oracleParams.TwapLookbackWindow = time.Duration(partial.TwapLookbackWindow.Int64()) + } + + if partial.MinVoters != nil { + oracleParams.MinVoters = partial.MinVoters.Uint64() + } + + if partial.ValidatorFeeRatio != nil { + oracleParams.ValidatorFeeRatio = *partial.ValidatorFeeRatio + } + + return oracleParams +} diff --git a/x/oracle/keeper/sudo_test.go b/x/oracle/keeper/sudo_test.go new file mode 100644 index 000000000..d62d9a9e2 --- /dev/null +++ b/x/oracle/keeper/sudo_test.go @@ -0,0 +1,94 @@ +package keeper_test + +import ( + "testing" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" + + "github.com/NibiruChain/nibiru/x/common/testutil" + "github.com/NibiruChain/nibiru/x/common/testutil/testapp" + oraclekeeper "github.com/NibiruChain/nibiru/x/oracle/keeper" + oracletypes "github.com/NibiruChain/nibiru/x/oracle/types" +) + +// TestSuiteOracleSudo tests sudo-only functions in the oracle module. +func TestSuiteOracleSudo(t *testing.T) { + suite.Run(t, new(SuiteOracleSudo)) +} + +type SuiteOracleSudo struct { + suite.Suite +} + +// TestEditOracleParams tests the business logic for +// "oraclekeeper.Keeper.Sudo().EditOracleParams" +func (s *SuiteOracleSudo) TestEditOracleParams() { + nibiru, ctx := testapp.NewNibiruTestAppAndContext() + + // Change to all non-defaults to test EditOracleParams as a setter . + votePeriod := sdk.NewInt(1_234) + voteThreshold := sdk.MustNewDecFromStr("0.4") + rewardBand := sdk.MustNewDecFromStr("0.5") + whitelist := []string{"aave:usdc", "sol:usdc"} + slashFraction := sdk.MustNewDecFromStr("0.5") + slashWindow := sdk.NewInt(2_000) + minValidPerWindow := sdk.MustNewDecFromStr("0.5") + twapLookbackWindow := sdk.NewInt(int64(time.Second * 30)) + minVoters := sdk.NewInt(2) + validatorFeeRatio := sdk.MustNewDecFromStr("0.7") + msgEditParams := oracletypes.MsgEditOracleParams{ + VotePeriod: &votePeriod, + VoteThreshold: &voteThreshold, + RewardBand: &rewardBand, + Whitelist: whitelist, + SlashFraction: &slashFraction, + SlashWindow: &slashWindow, + MinValidPerWindow: &minValidPerWindow, + TwapLookbackWindow: &twapLookbackWindow, + MinVoters: &minVoters, + ValidatorFeeRatio: &validatorFeeRatio, + } + + s.T().Log("Params before MUST NOT be equal to default") + defaultParams := oracletypes.DefaultParams() + currParams, err := nibiru.OracleKeeper.Params.Get(ctx) + s.NoError(err) + s.Equal(currParams, defaultParams, + "Current params should be eqaul to defaults") + partialParams := msgEditParams + fullParams := oraclekeeper.MergeOracleParams(partialParams, defaultParams) + s.NotEqual(defaultParams, fullParams, + "new params after merge should not be defaults") + + invalidSender := testutil.AccAddress() + oracleMsgServer := oraclekeeper.NewMsgServerImpl(nibiru.OracleKeeper) + goCtx := sdk.WrapSDKContext(ctx) + msgEditParams.Sender = invalidSender.String() + _, err = oracleMsgServer.EditOracleParams( + goCtx, &msgEditParams, + ) + s.Error(err) + + s.T().Log("Params after MUST be equal to new ones with partialParams") + okSender := testapp.DefaultSudoRoot() + msgEditParams.Sender = okSender.String() + resp, err := oracleMsgServer.EditOracleParams( + goCtx, &msgEditParams, + ) + s.Require().NoError(err) + s.EqualValues(resp.NewParams.String(), fullParams.String()) + + s.T().Log("Changing to invalid params MUST fail") + slashWindow = sdk.NewInt(1_233) // slashWindow < vote period is not allowed. + msgEditParams = oracletypes.MsgEditOracleParams{ + Sender: okSender.String(), + SlashWindow: &slashWindow, + } + _, err = oracleMsgServer.EditOracleParams( + goCtx, &msgEditParams, + ) + s.Require().Error(err) + s.ErrorContains(err, "oracle parameter SlashWindow must be greater") +} diff --git a/x/oracle/keeper/test_utils.go b/x/oracle/keeper/test_utils.go index 5cef19d0e..d5b94e807 100644 --- a/x/oracle/keeper/test_utils.go +++ b/x/oracle/keeper/test_utils.go @@ -13,6 +13,9 @@ import ( "github.com/NibiruChain/nibiru/x/common/denoms" "github.com/NibiruChain/nibiru/x/oracle/types" + "github.com/NibiruChain/nibiru/x/sudo" + sudokeeper "github.com/NibiruChain/nibiru/x/sudo/keeper" + sudotypes "github.com/NibiruChain/nibiru/x/sudo/types" dbm "github.com/cometbft/cometbft-db" "github.com/cometbft/cometbft/crypto" "github.com/cometbft/cometbft/crypto/secp256k1" @@ -51,6 +54,7 @@ var ModuleBasics = module.NewBasicManager( distr.AppModuleBasic{}, staking.AppModuleBasic{}, params.AppModuleBasic{}, + sudo.AppModuleBasic{}, ) // MakeTestCodec nolint @@ -123,6 +127,7 @@ type TestFixture struct { OracleKeeper Keeper StakingKeeper stakingkeeper.Keeper DistrKeeper distrkeeper.Keeper + SudoKeeper types.SudoKeeper } // CreateTestFixture nolint @@ -135,6 +140,7 @@ func CreateTestFixture(t *testing.T) TestFixture { keyOracle := sdk.NewKVStoreKey(types.StoreKey) keyStaking := sdk.NewKVStoreKey(stakingtypes.StoreKey) keyDistr := sdk.NewKVStoreKey(distrtypes.StoreKey) + keySudo := sdk.NewKVStoreKey(sudotypes.StoreKey) db := dbm.NewMemDB() ms := store.NewCommitMultiStore(db) @@ -224,11 +230,15 @@ func CreateTestFixture(t *testing.T) TestFixture { bankKeeper.SendCoinsFromModuleToModule(ctx, faucetAccountName, stakingtypes.NotBondedPoolName, sdk.NewCoins(sdk.NewCoin(denoms.NIBI, InitTokens.MulRaw(int64(len(Addrs)))))) + sudoKeeper := sudokeeper.NewKeeper(appCodec, keySudo) + sudoAcc := authtypes.NewEmptyModuleAccount(sudotypes.ModuleName) + accountKeeper.SetModuleAccount(ctx, feeCollectorAcc) accountKeeper.SetModuleAccount(ctx, bondPool) accountKeeper.SetModuleAccount(ctx, notBondedPool) accountKeeper.SetModuleAccount(ctx, distrAcc) accountKeeper.SetModuleAccount(ctx, oracleAcc) + accountKeeper.SetModuleAccount(ctx, sudoAcc) for _, addr := range Addrs { accountKeeper.SetAccount(ctx, authtypes.NewBaseAccountWithAddress(addr)) @@ -243,6 +253,7 @@ func CreateTestFixture(t *testing.T) TestFixture { bankKeeper, distrKeeper, stakingKeeper, + sudoKeeper, distrtypes.ModuleName, ) @@ -254,11 +265,19 @@ func CreateTestFixture(t *testing.T) TestFixture { keeper.Params.Set(ctx, defaults) - return TestFixture{ctx, legacyAmino, accountKeeper, bankKeeper, keeper, *stakingKeeper, distrKeeper} + return TestFixture{ + ctx, legacyAmino, accountKeeper, bankKeeper, + keeper, + *stakingKeeper, + distrKeeper, + sudoKeeper, + } } // NewTestMsgCreateValidator test msg creator -func NewTestMsgCreateValidator(address sdk.ValAddress, pubKey cryptotypes.PubKey, amt sdk.Int) *stakingtypes.MsgCreateValidator { +func NewTestMsgCreateValidator( + address sdk.ValAddress, pubKey cryptotypes.PubKey, amt sdk.Int, +) *stakingtypes.MsgCreateValidator { commission := stakingtypes.NewCommissionRates(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) msg, _ := stakingtypes.NewMsgCreateValidator( address, pubKey, sdk.NewCoin(denoms.NIBI, amt), diff --git a/x/oracle/types/errors.go b/x/oracle/types/errors.go index 23fb21fa6..b51d42265 100644 --- a/x/oracle/types/errors.go +++ b/x/oracle/types/errors.go @@ -5,22 +5,35 @@ import ( "github.com/cometbft/cometbft/crypto/tmhash" + "sync/atomic" + sdkerrors "cosmossdk.io/errors" ) +var moduleErrorCodeIdx uint32 = 1 + +// registerError: Cleaner way of using 'sdkerrors.Register' without as much time +// manually writing integers. +func registerError(msg string) *sdkerrors.Error { + // Atomic for thread safety on concurrent calls + atomic.AddUint32(&moduleErrorCodeIdx, 1) + return sdkerrors.Register(ModuleName, moduleErrorCodeIdx, msg) +} + // Oracle Errors var ( - ErrInvalidExchangeRate = sdkerrors.Register(ModuleName, 2, "invalid exchange rate") - ErrNoPrevote = sdkerrors.Register(ModuleName, 3, "no prevote") - ErrNoVote = sdkerrors.Register(ModuleName, 4, "no vote") - ErrNoVotingPermission = sdkerrors.Register(ModuleName, 5, "unauthorized voter") - ErrInvalidHash = sdkerrors.Register(ModuleName, 6, "invalid hash") - ErrInvalidHashLength = sdkerrors.Register(ModuleName, 7, fmt.Sprintf("invalid hash length; should equal %d", tmhash.TruncatedSize)) - ErrVerificationFailed = sdkerrors.Register(ModuleName, 8, "hash verification failed") - ErrRevealPeriodMissMatch = sdkerrors.Register(ModuleName, 9, "reveal period of submitted vote do not match with registered prevote") - ErrInvalidSaltLength = sdkerrors.Register(ModuleName, 10, "invalid salt length; should be 1~4") - ErrNoAggregatePrevote = sdkerrors.Register(ModuleName, 11, "no aggregate prevote") - ErrNoAggregateVote = sdkerrors.Register(ModuleName, 12, "no aggregate vote") - ErrUnknownPair = sdkerrors.Register(ModuleName, 13, "unknown pair") - ErrNoValidTWAP = sdkerrors.Register(ModuleName, 14, "TWA price not found") + ErrInvalidExchangeRate = registerError("invalid exchange rate") + ErrNoPrevote = registerError("no prevote") + ErrNoVote = registerError("no vote") + ErrNoVotingPermission = registerError("unauthorized voter") + ErrInvalidHash = registerError("invalid hash") + ErrInvalidHashLength = registerError( + fmt.Sprintf("invalid hash length; should equal %d", tmhash.TruncatedSize)) + ErrHashVerificationFailed = registerError("hash verification failed") + ErrRevealPeriodMissMatch = registerError("reveal period of submitted vote do not match with registered prevote") + ErrInvalidSaltLength = registerError("invalid salt length; should be 1~4") + ErrNoAggregatePrevote = registerError("no aggregate prevote") + ErrNoAggregateVote = registerError("no aggregate vote") + ErrUnknownPair = registerError("unknown pair") + ErrNoValidTWAP = registerError("TWA price not found") ) diff --git a/x/oracle/types/expected_keeper.go b/x/oracle/types/expected_keeper.go index 4c47f8bd5..0d53c0395 100644 --- a/x/oracle/types/expected_keeper.go +++ b/x/oracle/types/expected_keeper.go @@ -41,3 +41,10 @@ type BankKeeper interface { // only used for simulation SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins } + +type SudoKeeper interface { + // CheckPermissions Checks if a contract is contained within the set of sudo + // contracts defined in the x/sudo module. These smart contracts are able to + // execute certain permissioned functions. + CheckPermissions(contract sdk.AccAddress, ctx sdk.Context) error +} diff --git a/x/oracle/types/msgs.go b/x/oracle/types/msgs.go index b49a5a3ea..317566226 100644 --- a/x/oracle/types/msgs.go +++ b/x/oracle/types/msgs.go @@ -13,6 +13,7 @@ var ( _ sdk.Msg = &MsgDelegateFeedConsent{} _ sdk.Msg = &MsgAggregateExchangeRatePrevote{} _ sdk.Msg = &MsgAggregateExchangeRateVote{} + _ sdk.Msg = &MsgEditOracleParams{} ) // oracle message types @@ -20,6 +21,7 @@ const ( TypeMsgDelegateFeedConsent = "delegate_feeder" TypeMsgAggregateExchangeRatePrevote = "aggregate_exchange_rate_prevote" TypeMsgAggregateExchangeRateVote = "aggregate_exchange_rate_vote" + TypeMsgEditOracleParams = "edit_oracle_params" ) //------------------------------------------------- @@ -149,6 +151,8 @@ func (msg MsgAggregateExchangeRateVote) ValidateBasic() error { return nil } +// ------------------------ MsgDelegateFeedConsent ------------------------ + // NewMsgDelegateFeedConsent creates a MsgDelegateFeedConsent instance func NewMsgDelegateFeedConsent(operatorAddress sdk.ValAddress, feederAddress sdk.AccAddress) *MsgDelegateFeedConsent { return &MsgDelegateFeedConsent{ @@ -192,3 +196,27 @@ func (msg MsgDelegateFeedConsent) ValidateBasic() error { return nil } + +// ------------------------ MsgEditOracleParams ------------------------ + +func (m MsgEditOracleParams) Route() string { return RouterKey } +func (m MsgEditOracleParams) Type() string { return TypeMsgEditOracleParams } + +func (m MsgEditOracleParams) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Sender); err != nil { + return err + } + return nil +} + +func (m MsgEditOracleParams) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +func (m MsgEditOracleParams) GetSigners() []sdk.AccAddress { + signer, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{signer} +} diff --git a/x/oracle/types/oracle.pb.go b/x/oracle/types/oracle.pb.go index a1e849d40..fc2b10c6d 100644 --- a/x/oracle/types/oracle.pb.go +++ b/x/oracle/types/oracle.pb.go @@ -59,7 +59,8 @@ type Params struct { // synonymous with submitting fewer valid votes than `MinValidPerWindow`. SlashWindow uint64 `protobuf:"varint,6,opt,name=slash_window,json=slashWindow,proto3" json:"slash_window,omitempty" yaml:"slash_window"` MinValidPerWindow github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,7,opt,name=min_valid_per_window,json=minValidPerWindow,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_valid_per_window" yaml:"min_valid_per_window"` - // Amount of time to look back for TWAP calculations + // Amount of time to look back for TWAP calculations. + // Ex: "900.000000069s" corresponds to 900 seconds and 69 nanoseconds in JSON. TwapLookbackWindow time.Duration `protobuf:"bytes,8,opt,name=twap_lookback_window,json=twapLookbackWindow,proto3,stdduration" json:"twap_lookback_window,omitempty" yaml:"twap_lookback_window"` // The minimum number of voters (i.e. oracle validators) per pair for it to be // considered a passing ballot. Recommended at least 4. diff --git a/x/oracle/types/tx.pb.go b/x/oracle/types/tx.pb.go index 62ca0e3a4..559b17c45 100644 --- a/x/oracle/types/tx.pb.go +++ b/x/oracle/types/tx.pb.go @@ -6,6 +6,7 @@ package types import ( context "context" fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" @@ -276,6 +277,120 @@ func (m *MsgDelegateFeedConsentResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgDelegateFeedConsentResponse proto.InternalMessageInfo +// MsgEditOracleParams: gRPC tx message for updating the x/oracle module params +// [SUDO] Only callable by sudoers. +type MsgEditOracleParams struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + VotePeriod *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=vote_period,json=votePeriod,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"vote_period,omitempty"` + // vote_threshold: [cosmossdk.io/math.LegacyDec] TODO: + VoteThreshold *github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=vote_threshold,json=voteThreshold,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"vote_threshold,omitempty"` + // reward_band: [cosmossdk.io/math.LegacyDec] TODO: + RewardBand *github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=reward_band,json=rewardBand,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"reward_band,omitempty"` + Whitelist []string `protobuf:"bytes,5,rep,name=whitelist,proto3" json:"whitelist,omitempty"` + // slash_fraction: [cosmossdk.io/math.LegacyDec] TODO: + SlashFraction *github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=slash_fraction,json=slashFraction,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"slash_fraction,omitempty"` + SlashWindow *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,7,opt,name=slash_window,json=slashWindow,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"slash_window,omitempty"` + // min_valid_per_window: [cosmossdk.io/math.LegacyDec] TODO: + MinValidPerWindow *github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,8,opt,name=min_valid_per_window,json=minValidPerWindow,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_valid_per_window,omitempty"` + TwapLookbackWindow *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,9,opt,name=twap_lookback_window,json=twapLookbackWindow,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"twap_lookback_window,omitempty"` + MinVoters *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,10,opt,name=min_voters,json=minVoters,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_voters,omitempty"` + // VoteThreshold: [cosmossdk.io/math.LegacyDec] TODO: + ValidatorFeeRatio *github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,11,opt,name=validator_fee_ratio,json=validatorFeeRatio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"validator_fee_ratio,omitempty"` +} + +func (m *MsgEditOracleParams) Reset() { *m = MsgEditOracleParams{} } +func (m *MsgEditOracleParams) String() string { return proto.CompactTextString(m) } +func (*MsgEditOracleParams) ProtoMessage() {} +func (*MsgEditOracleParams) Descriptor() ([]byte, []int) { + return fileDescriptor_11e362c65eb610f4, []int{6} +} +func (m *MsgEditOracleParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgEditOracleParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgEditOracleParams.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 *MsgEditOracleParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgEditOracleParams.Merge(m, src) +} +func (m *MsgEditOracleParams) XXX_Size() int { + return m.Size() +} +func (m *MsgEditOracleParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgEditOracleParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgEditOracleParams proto.InternalMessageInfo + +func (m *MsgEditOracleParams) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgEditOracleParams) GetWhitelist() []string { + if m != nil { + return m.Whitelist + } + return nil +} + +// MsgEditOracleParamsResponse defines the Msg/EditOracleParams response +// type. +type MsgEditOracleParamsResponse struct { + NewParams *Params `protobuf:"bytes,1,opt,name=new_params,json=newParams,proto3" json:"new_params,omitempty"` +} + +func (m *MsgEditOracleParamsResponse) Reset() { *m = MsgEditOracleParamsResponse{} } +func (m *MsgEditOracleParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgEditOracleParamsResponse) ProtoMessage() {} +func (*MsgEditOracleParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_11e362c65eb610f4, []int{7} +} +func (m *MsgEditOracleParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgEditOracleParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgEditOracleParamsResponse.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 *MsgEditOracleParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgEditOracleParamsResponse.Merge(m, src) +} +func (m *MsgEditOracleParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgEditOracleParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgEditOracleParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgEditOracleParamsResponse proto.InternalMessageInfo + +func (m *MsgEditOracleParamsResponse) GetNewParams() *Params { + if m != nil { + return m.NewParams + } + return nil +} + func init() { proto.RegisterType((*MsgAggregateExchangeRatePrevote)(nil), "nibiru.oracle.v1.MsgAggregateExchangeRatePrevote") proto.RegisterType((*MsgAggregateExchangeRatePrevoteResponse)(nil), "nibiru.oracle.v1.MsgAggregateExchangeRatePrevoteResponse") @@ -283,47 +398,72 @@ func init() { proto.RegisterType((*MsgAggregateExchangeRateVoteResponse)(nil), "nibiru.oracle.v1.MsgAggregateExchangeRateVoteResponse") proto.RegisterType((*MsgDelegateFeedConsent)(nil), "nibiru.oracle.v1.MsgDelegateFeedConsent") proto.RegisterType((*MsgDelegateFeedConsentResponse)(nil), "nibiru.oracle.v1.MsgDelegateFeedConsentResponse") + proto.RegisterType((*MsgEditOracleParams)(nil), "nibiru.oracle.v1.MsgEditOracleParams") + proto.RegisterType((*MsgEditOracleParamsResponse)(nil), "nibiru.oracle.v1.MsgEditOracleParamsResponse") } func init() { proto.RegisterFile("nibiru/oracle/v1/tx.proto", fileDescriptor_11e362c65eb610f4) } var fileDescriptor_11e362c65eb610f4 = []byte{ - // 555 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x3f, 0x6f, 0xd3, 0x40, - 0x18, 0xc6, 0x73, 0x4d, 0x55, 0xb5, 0x87, 0x4a, 0x8b, 0xfb, 0x47, 0x49, 0x88, 0xec, 0xe8, 0x40, - 0xa5, 0x95, 0xc0, 0x26, 0x45, 0x42, 0xa2, 0x13, 0xb4, 0xd0, 0x2d, 0x08, 0x79, 0x60, 0x60, 0x41, - 0x97, 0xe4, 0xe5, 0x62, 0xc9, 0xf5, 0x59, 0xbe, 0x6b, 0x94, 0xae, 0x88, 0x81, 0x11, 0x89, 0x89, - 0x2d, 0x1f, 0x00, 0x89, 0xaf, 0xc1, 0x58, 0x89, 0x85, 0x29, 0x42, 0x09, 0x03, 0x13, 0x83, 0xf9, - 0x02, 0xc8, 0x77, 0xb6, 0x49, 0x43, 0xfa, 0x27, 0x5b, 0x74, 0xcf, 0xef, 0xde, 0xf7, 0x79, 0x9f, - 0xbc, 0x67, 0x5c, 0x0e, 0xbc, 0xa6, 0x17, 0x1d, 0x3b, 0x3c, 0xa2, 0x2d, 0x1f, 0x9c, 0x6e, 0xdd, - 0x91, 0x3d, 0x3b, 0x8c, 0xb8, 0xe4, 0xc6, 0xaa, 0x96, 0x6c, 0x2d, 0xd9, 0xdd, 0x7a, 0x65, 0x9d, - 0x71, 0xc6, 0x95, 0xe8, 0x24, 0xbf, 0x34, 0x57, 0xa9, 0x32, 0xce, 0x99, 0x0f, 0x0e, 0x0d, 0x3d, - 0x87, 0x06, 0x01, 0x97, 0x54, 0x7a, 0x3c, 0x10, 0x5a, 0x25, 0x5f, 0x10, 0xb6, 0x1a, 0x82, 0x3d, - 0x61, 0x2c, 0x02, 0x46, 0x25, 0x3c, 0xeb, 0xb5, 0x3a, 0x34, 0x60, 0xe0, 0x52, 0x09, 0x2f, 0x22, - 0xe8, 0x72, 0x09, 0xc6, 0x2d, 0x3c, 0xdf, 0xa1, 0xa2, 0x53, 0x42, 0x35, 0xb4, 0xbd, 0x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, + // 915 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x96, 0x41, 0x6f, 0xdc, 0x44, + 0x14, 0xc7, 0xd7, 0x4d, 0xba, 0x64, 0x67, 0x49, 0x9b, 0x7a, 0xd3, 0xc8, 0xd9, 0x06, 0x3b, 0xb8, + 0x10, 0x12, 0x89, 0xb5, 0x49, 0x90, 0x40, 0xf4, 0x04, 0x69, 0x1b, 0x09, 0x89, 0xa5, 0xc1, 0x82, + 0x20, 0x71, 0xc0, 0xcc, 0xae, 0x5f, 0x6c, 0x2b, 0x5e, 0x8f, 0x35, 0x33, 0xcd, 0xa6, 0x57, 0xc4, + 0x01, 0x6e, 0x48, 0x3d, 0x71, 0xcb, 0x07, 0x40, 0xe2, 0x6b, 0xf4, 0x58, 0x89, 0x0b, 0xe2, 0xb0, + 0x42, 0x09, 0x42, 0x9c, 0x38, 0xec, 0x27, 0x40, 0x33, 0x1e, 0xbb, 0xdb, 0xcd, 0xb6, 0xcd, 0xee, + 0x29, 0xce, 0xbc, 0xff, 0xfc, 0xde, 0xff, 0x3d, 0x7b, 0xde, 0x2c, 0x5a, 0x4d, 0xe3, 0x4e, 0x4c, + 0x1f, 0xba, 0x84, 0xe2, 0x6e, 0x02, 0xee, 0xf1, 0xb6, 0xcb, 0x4f, 0x9c, 0x8c, 0x12, 0x4e, 0xf4, + 0xa5, 0x3c, 0xe4, 0xe4, 0x21, 0xe7, 0x78, 0xbb, 0xb9, 0x1c, 0x92, 0x90, 0xc8, 0xa0, 0x2b, 0x9e, + 0x72, 0x5d, 0x73, 0x2d, 0x24, 0x24, 0x4c, 0xc0, 0xc5, 0x59, 0xec, 0xe2, 0x34, 0x25, 0x1c, 0xf3, + 0x98, 0xa4, 0x4c, 0x45, 0xdf, 0xb8, 0x90, 0x40, 0xf1, 0x64, 0xd8, 0xfe, 0x4d, 0x43, 0x56, 0x9b, + 0x85, 0x9f, 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xff, 0xff, 0x67, 0xca, 0xa5, 0x9a, 0xbc, + 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -348,6 +488,7 @@ type MsgClient interface { // to another address known as a price feeder. // See https://github.com/NibiruChain/pricefeeder. DelegateFeedConsent(ctx context.Context, in *MsgDelegateFeedConsent, opts ...grpc.CallOption) (*MsgDelegateFeedConsentResponse, error) + EditOracleParams(ctx context.Context, in *MsgEditOracleParams, opts ...grpc.CallOption) (*MsgEditOracleParamsResponse, error) } type msgClient struct { @@ -385,6 +526,15 @@ func (c *msgClient) DelegateFeedConsent(ctx context.Context, in *MsgDelegateFeed return out, nil } +func (c *msgClient) EditOracleParams(ctx context.Context, in *MsgEditOracleParams, opts ...grpc.CallOption) (*MsgEditOracleParamsResponse, error) { + out := new(MsgEditOracleParamsResponse) + err := c.cc.Invoke(ctx, "/nibiru.oracle.v1.Msg/EditOracleParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // AggregateExchangeRatePrevote defines a method for submitting @@ -397,6 +547,7 @@ type MsgServer interface { // to another address known as a price feeder. // See https://github.com/NibiruChain/pricefeeder. DelegateFeedConsent(context.Context, *MsgDelegateFeedConsent) (*MsgDelegateFeedConsentResponse, error) + EditOracleParams(context.Context, *MsgEditOracleParams) (*MsgEditOracleParamsResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -412,6 +563,9 @@ func (*UnimplementedMsgServer) AggregateExchangeRateVote(ctx context.Context, re func (*UnimplementedMsgServer) DelegateFeedConsent(ctx context.Context, req *MsgDelegateFeedConsent) (*MsgDelegateFeedConsentResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method DelegateFeedConsent not implemented") } +func (*UnimplementedMsgServer) EditOracleParams(ctx context.Context, req *MsgEditOracleParams) (*MsgEditOracleParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method EditOracleParams not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -471,6 +625,24 @@ func _Msg_DelegateFeedConsent_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Msg_EditOracleParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgEditOracleParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).EditOracleParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/nibiru.oracle.v1.Msg/EditOracleParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).EditOracleParams(ctx, req.(*MsgEditOracleParams)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "nibiru.oracle.v1.Msg", HandlerType: (*MsgServer)(nil), @@ -487,6 +659,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "DelegateFeedConsent", Handler: _Msg_DelegateFeedConsent_Handler, }, + { + MethodName: "EditOracleParams", + Handler: _Msg_EditOracleParams_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "nibiru/oracle/v1/tx.proto", @@ -693,6 +869,188 @@ func (m *MsgDelegateFeedConsentResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *MsgEditOracleParams) 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 *MsgEditOracleParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgEditOracleParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ValidatorFeeRatio != nil { + { + size := m.ValidatorFeeRatio.Size() + i -= size + if _, err := m.ValidatorFeeRatio.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x5a + } + if m.MinVoters != nil { + { + size := m.MinVoters.Size() + i -= size + if _, err := m.MinVoters.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + } + if m.TwapLookbackWindow != nil { + { + size := m.TwapLookbackWindow.Size() + i -= size + if _, err := m.TwapLookbackWindow.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a + } + if m.MinValidPerWindow != nil { + { + size := m.MinValidPerWindow.Size() + i -= size + if _, err := m.MinValidPerWindow.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + } + if m.SlashWindow != nil { + { + size := m.SlashWindow.Size() + i -= size + if _, err := m.SlashWindow.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + if m.SlashFraction != nil { + { + size := m.SlashFraction.Size() + i -= size + if _, err := m.SlashFraction.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + if len(m.Whitelist) > 0 { + for iNdEx := len(m.Whitelist) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Whitelist[iNdEx]) + copy(dAtA[i:], m.Whitelist[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Whitelist[iNdEx]))) + i-- + dAtA[i] = 0x2a + } + } + if m.RewardBand != nil { + { + size := m.RewardBand.Size() + i -= size + if _, err := m.RewardBand.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if m.VoteThreshold != nil { + { + size := m.VoteThreshold.Size() + i -= size + if _, err := m.VoteThreshold.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.VotePeriod != nil { + { + size := m.VotePeriod.Size() + i -= size + if _, err := m.VotePeriod.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgEditOracleParamsResponse) 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 *MsgEditOracleParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgEditOracleParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.NewParams != nil { + { + size, err := m.NewParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -794,6 +1152,74 @@ func (m *MsgDelegateFeedConsentResponse) Size() (n int) { return n } +func (m *MsgEditOracleParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.VotePeriod != nil { + l = m.VotePeriod.Size() + n += 1 + l + sovTx(uint64(l)) + } + if m.VoteThreshold != nil { + l = m.VoteThreshold.Size() + n += 1 + l + sovTx(uint64(l)) + } + if m.RewardBand != nil { + l = m.RewardBand.Size() + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Whitelist) > 0 { + for _, s := range m.Whitelist { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } + if m.SlashFraction != nil { + l = m.SlashFraction.Size() + n += 1 + l + sovTx(uint64(l)) + } + if m.SlashWindow != nil { + l = m.SlashWindow.Size() + n += 1 + l + sovTx(uint64(l)) + } + if m.MinValidPerWindow != nil { + l = m.MinValidPerWindow.Size() + n += 1 + l + sovTx(uint64(l)) + } + if m.TwapLookbackWindow != nil { + l = m.TwapLookbackWindow.Size() + n += 1 + l + sovTx(uint64(l)) + } + if m.MinVoters != nil { + l = m.MinVoters.Size() + n += 1 + l + sovTx(uint64(l)) + } + if m.ValidatorFeeRatio != nil { + l = m.ValidatorFeeRatio.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgEditOracleParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.NewParams != nil { + l = m.NewParams.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1388,6 +1814,530 @@ func (m *MsgDelegateFeedConsentResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgEditOracleParams) 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: MsgEditOracleParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgEditOracleParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VotePeriod", 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 + } + var v github_com_cosmos_cosmos_sdk_types.Int + m.VotePeriod = &v + if err := m.VotePeriod.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VoteThreshold", 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 + } + var v github_com_cosmos_cosmos_sdk_types.Dec + m.VoteThreshold = &v + if err := m.VoteThreshold.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardBand", 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 + } + var v github_com_cosmos_cosmos_sdk_types.Dec + m.RewardBand = &v + if err := m.RewardBand.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Whitelist", 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.Whitelist = append(m.Whitelist, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SlashFraction", 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 + } + var v github_com_cosmos_cosmos_sdk_types.Dec + m.SlashFraction = &v + if err := m.SlashFraction.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SlashWindow", 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 + } + var v github_com_cosmos_cosmos_sdk_types.Int + m.SlashWindow = &v + if err := m.SlashWindow.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinValidPerWindow", 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 + } + var v github_com_cosmos_cosmos_sdk_types.Dec + m.MinValidPerWindow = &v + if err := m.MinValidPerWindow.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TwapLookbackWindow", 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 + } + var v github_com_cosmos_cosmos_sdk_types.Int + m.TwapLookbackWindow = &v + if err := m.TwapLookbackWindow.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinVoters", 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 + } + var v github_com_cosmos_cosmos_sdk_types.Int + m.MinVoters = &v + if err := m.MinVoters.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorFeeRatio", 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 + } + var v github_com_cosmos_cosmos_sdk_types.Dec + m.ValidatorFeeRatio = &v + if err := m.ValidatorFeeRatio.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + 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 *MsgEditOracleParamsResponse) 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: MsgEditOracleParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgEditOracleParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewParams", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.NewParams == nil { + m.NewParams = &Params{} + } + if err := m.NewParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + 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 skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/oracle/types/tx.pb.gw.go b/x/oracle/types/tx.pb.gw.go index a37229a8d..5c9ddb424 100644 --- a/x/oracle/types/tx.pb.gw.go +++ b/x/oracle/types/tx.pb.gw.go @@ -141,6 +141,42 @@ func local_request_Msg_DelegateFeedConsent_0(ctx context.Context, marshaler runt } +var ( + filter_Msg_EditOracleParams_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Msg_EditOracleParams_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MsgEditOracleParams + 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_EditOracleParams_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.EditOracleParams(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Msg_EditOracleParams_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MsgEditOracleParams + 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_EditOracleParams_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.EditOracleParams(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. @@ -216,6 +252,29 @@ func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server }) + mux.Handle("POST", pattern_Msg_EditOracleParams_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_EditOracleParams_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_EditOracleParams_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -317,6 +376,26 @@ func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client }) + mux.Handle("POST", pattern_Msg_EditOracleParams_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_EditOracleParams_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_EditOracleParams_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -326,6 +405,8 @@ var ( pattern_Msg_AggregateExchangeRateVote_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nibiru", "oracle", "vote"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Msg_DelegateFeedConsent_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nibiru", "oracle", "feeder-delegate"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Msg_EditOracleParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nibiru", "oracle", "edit-oracle-params"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -334,4 +415,6 @@ var ( forward_Msg_AggregateExchangeRateVote_0 = runtime.ForwardResponseMessage forward_Msg_DelegateFeedConsent_0 = runtime.ForwardResponseMessage + + forward_Msg_EditOracleParams_0 = runtime.ForwardResponseMessage ) diff --git a/x/sudo/doc.go b/x/sudo/doc.go index abff474ca..d75e435bd 100644 --- a/x/sudo/doc.go +++ b/x/sudo/doc.go @@ -1,7 +1,6 @@ package sudo /* - Package sudo provides a simple way to manage, verify, and run smart contracts with elevated permissions, mimicking the functionality of a Unix-based sudoers file. @@ -19,5 +18,4 @@ files. Note that this package does not provide actual system integration or execute commands with elevated privileges. It only offers a way to manage and verify permissions in a sudoers-like manner within your application. - */