diff --git a/app/ante.go b/app/ante.go index 57d33d8d7..001ad5cc6 100644 --- a/app/ante.go +++ b/app/ante.go @@ -122,15 +122,11 @@ func (min MinCommissionDecorator) AnteHandle( simulate bool, next sdk.AnteHandler, ) (newCtx sdk.Context, err error) { msgs := tx.GetMsgs() - minCommissionRate := sdk.NewDecWithPrec(5, 2) // 5% as a fraction - maxVotingPower := sdk.NewDec(100) // 100% // Fetch parameter from parameter module - params, found := min.pk.GetAnteHandlerParam(ctx) - if found { - minCommissionRate = params.MinCommissionRate - maxVotingPower = params.MaxVotingPower - } + params := min.pk.GetParams(ctx) + minCommissionRate := params.MinCommissionRate + maxVotingPower := params.MaxVotingPower validMsg := func(m sdk.Msg) error { switch msg := m.(type) { diff --git a/app/app.go b/app/app.go index 7fbe4602f..ac1494047 100644 --- a/app/app.go +++ b/app/app.go @@ -500,6 +500,13 @@ func NewElysApp( ) bApp.SetParamStore(&app.ConsensusParamsKeeper) + app.ParameterKeeper = *parametermodulekeeper.NewKeeper( + appCodec, + keys[parametermoduletypes.StoreKey], + keys[parametermoduletypes.MemStoreKey], + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + // add capability keeper and ScopeToModule for ibc module app.CapabilityKeeper = capabilitykeeper.NewKeeper( appCodec, @@ -734,6 +741,7 @@ func NewElysApp( tkeys[ammmoduletypes.TStoreKey], app.GetSubspace(ammmoduletypes.ModuleName), authtypes.NewModuleAddress(govtypes.ModuleName).String(), + &app.ParameterKeeper, app.BankKeeper, app.AccountKeeper, app.OracleKeeper, @@ -802,12 +810,6 @@ func NewElysApp( ) burnerModule := burnermodule.NewAppModule(appCodec, app.BurnerKeeper, app.AccountKeeper, app.BankKeeper) - app.ParameterKeeper = *parametermodulekeeper.NewKeeper( - appCodec, - keys[parametermoduletypes.StoreKey], - keys[parametermoduletypes.MemStoreKey], - app.GetSubspace(parametermoduletypes.ModuleName), - ) parameterModule := parametermodule.NewAppModule(appCodec, app.ParameterKeeper, app.AccountKeeper, app.BankKeeper) wasmDir := filepath.Join(homePath, "wasm") @@ -907,8 +909,8 @@ func NewElysApp( AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)). AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)). AddRoute(oracletypes.RouterKey, oraclemodule.NewAssetInfoProposalHandler(&app.OracleKeeper)). - AddRoute(incentivemoduletypes.RouterKey, incentivemodule.NewPoolInfoProposalHandler(&app.IncentiveKeeper)). - AddRoute(parametermoduletypes.RouterKey, parametermodule.NewParameterChangeProposalHandler(&app.ParameterKeeper)) + AddRoute(incentivemoduletypes.RouterKey, incentivemodule.NewPoolInfoProposalHandler(&app.IncentiveKeeper)) + // The gov proposal types can be individually enabled if len(enabledProposals) != 0 { govRouter.AddRoute(wasmmodule.RouterKey, wasmmodule.NewWasmProposalHandler(app.WasmKeeper, enabledProposals)) @@ -924,6 +926,7 @@ func NewElysApp( app.BankKeeper, app.OracleKeeper, app.AssetprofileKeeper, + &app.ParameterKeeper, ) app.ClockKeeper = *clockmodulekeeper.NewKeeper( @@ -1165,6 +1168,7 @@ func NewElysApp( // so that other modules that want to create or claim capabilities afterwards in InitChain // can do so safely. genesisModuleOrder := []string{ + parametermoduletypes.ModuleName, capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, @@ -1194,7 +1198,6 @@ func NewElysApp( tokenomicsmoduletypes.ModuleName, burnermoduletypes.ModuleName, ammmoduletypes.ModuleName, - parametermoduletypes.ModuleName, marginmoduletypes.ModuleName, wasmmodule.ModuleName, accountedpoolmoduletypes.ModuleName, @@ -1493,7 +1496,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(incentivemoduletypes.ModuleName) paramsKeeper.Subspace(burnermoduletypes.ModuleName) paramsKeeper.Subspace(ammmoduletypes.ModuleName) - paramsKeeper.Subspace(parametermoduletypes.ModuleName) paramsKeeper.Subspace(marginmoduletypes.ModuleName) paramsKeeper.Subspace(accountedpoolmoduletypes.ModuleName) paramsKeeper.Subspace(transferhooktypes.ModuleName) diff --git a/app/setup_handlers.go b/app/setup_handlers.go index af45bf00b..d5f2bbf35 100644 --- a/app/setup_handlers.go +++ b/app/setup_handlers.go @@ -26,7 +26,6 @@ import ( leveragelptypes "github.com/elys-network/elys/x/leveragelp/types" margintypes "github.com/elys-network/elys/x/margin/types" oracletypes "github.com/elys-network/elys/x/oracle/types" - parametertypes "github.com/elys-network/elys/x/parameter/types" stablestaketypes "github.com/elys-network/elys/x/stablestake/types" tokenomicstypes "github.com/elys-network/elys/x/tokenomics/types" transferhooktypes "github.com/elys-network/elys/x/transferhook/types" @@ -77,8 +76,6 @@ func setUpgradeHandler(app *ElysApp) { keyTable = margintypes.ParamKeyTable() //nolint:staticcheck case oracletypes.ModuleName: keyTable = oracletypes.ParamKeyTable() //nolint:staticcheck - case parametertypes.ModuleName: - keyTable = parametertypes.ParamKeyTable() //nolint:staticcheck case tokenomicstypes.ModuleName: keyTable = tokenomicstypes.ParamKeyTable() //nolint:staticcheck case accountedpooltypes.ModuleName: diff --git a/config.yml b/config.yml index 0edefe4cc..5ba07336e 100644 --- a/config.yml +++ b/config.yml @@ -432,10 +432,11 @@ genesis: denom: "ueden" amount: "1000000" parameter: - anteHandlerParam: - minCommissionRate: "0.05" - maxVotingPower: "0.66" - minSelfDelegation: "1" + params: + min_commission_rate: "0.05" + max_voting_power: "0.66" + min_self_delegation: "1" + broker_address: "" margin: params: leverage_max: "10" @@ -457,7 +458,6 @@ genesis: incremental_borrow_interest_payment_enabled: true whitelisting_enabled: false invariant_check_epoch: day - broker_address: "elys1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqnrec2l" take_profit_borrow_interest_rate_min: "0.00000003" funding_fee_base_rate: "0.0003" funding_fee_max_rate: "0.001" diff --git a/dockernet/src/init_chain.sh b/dockernet/src/init_chain.sh index 7774d4f02..e7ee00484 100644 --- a/dockernet/src/init_chain.sh +++ b/dockernet/src/init_chain.sh @@ -24,7 +24,7 @@ set_elys_genesis() { jq '.app_state.staking.params.unbonding_time = $newVal' --arg newVal "$UNBONDING_TIME" $genesis_config > json.tmp && mv json.tmp $genesis_config jq '.app_state.gov.deposit_params.max_deposit_period = $newVal' --arg newVal "$MAX_DEPOSIT_PERIOD" $genesis_config > json.tmp && mv json.tmp $genesis_config jq '.app_state.gov.voting_params.voting_period = $newVal' --arg newVal "$VOTING_PERIOD" $genesis_config > json.tmp && mv json.tmp $genesis_config - jq '.app_state.parameter.anteHandlerParamList[0].maxVotingPower = $newVal' --arg newVal "100.000000000000000000" $genesis_config > json.tmp && mv json.tmp $genesis_config + jq '.app_state.parameter.params.maxVotingPower = $newVal' --arg newVal "100.000000000000000000" $genesis_config > json.tmp && mv json.tmp $genesis_config } set_band_genesis() { diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index ad183f094..cc8a5d6cf 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -37851,8 +37851,6 @@ paths: pool_creation_fee: type: string format: uint64 - broker_address: - type: string description: >- QueryParamsResponse is response type for the Query/Params RPC method. @@ -41267,6 +41265,8 @@ paths: method signatures required by gogoproto. + valid_collateral: + type: boolean position_size: type: object properties: @@ -41293,20 +41293,7 @@ paths: liquidation_price: type: string estimated_pnl: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. + type: string available_liquidity: type: object properties: @@ -41430,8 +41417,6 @@ paths: type: boolean invariant_check_epoch: type: string - broker_address: - type: string take_profit_borrow_interest_rate_min: type: string funding_fee_base_rate: @@ -42711,131 +42696,6 @@ paths: additionalProperties: {} tags: - Query - /elys-network/elys/parameter/ante_handler_param: - get: - operationId: ElysParameterAnteHandlerParamAll - responses: - '200': - description: A successful response. - schema: - type: object - properties: - ante_handler_param: - type: array - items: - type: object - properties: - min_commission_rate: - type: string - max_voting_power: - type: string - min_self_delegation: - type: string - pagination: - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise - description: >- - PageResponse is to be embedded in gRPC response messages where - the - - corresponding request message has used PageRequest. - - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: pagination.key - description: |- - key is a value returned in PageResponse.next_key to begin - querying the next page most efficiently. Only one of offset or key - should be set. - in: query - required: false - type: string - format: byte - - name: pagination.offset - description: >- - offset is a numeric offset that can be used when key is unavailable. - - It is less efficient than using key. Only one of offset or key - should - - be set. - in: query - required: false - type: string - format: uint64 - - name: pagination.limit - description: >- - limit is the total number of results to be returned in the result - page. - - If left empty it will default to a value to be set by each app. - in: query - required: false - type: string - format: uint64 - - name: pagination.count_total - description: >- - count_total is set to true to indicate that the result set should - include - - a count of the total number of items available for pagination in - UIs. - - count_total is only respected when offset is used. It is ignored - when key - - is set. - in: query - required: false - type: boolean - - name: pagination.reverse - description: >- - reverse is set to true if results are to be returned in the - descending order. - - - Since: cosmos-sdk 0.43 - in: query - required: false - type: boolean - tags: - - Query /elys-network/elys/parameter/params: get: summary: Parameters queries the parameters of the module. @@ -42849,6 +42709,15 @@ paths: params: description: params holds all the parameters of this module. type: object + properties: + min_commission_rate: + type: string + max_voting_power: + type: string + min_self_delegation: + type: string + broker_address: + type: string description: >- QueryParamsResponse is response type for the Query/Params RPC method. @@ -82653,8 +82522,6 @@ definitions: pool_creation_fee: type: string format: uint64 - broker_address: - type: string description: Params defines the parameters for the module. elys.amm.Pool: type: object @@ -83029,8 +82896,6 @@ definitions: pool_creation_fee: type: string format: uint64 - broker_address: - type: string description: QueryParamsResponse is response type for the Query/Params RPC method. elys.amm.QuerySlippageTrackAllResponse: type: object @@ -85033,20 +84898,6 @@ definitions: type: string open_price: type: string - elys.margin.MsgBrokerCloseResponse: - type: object - properties: - id: - type: string - format: uint64 - amount: - type: string - elys.margin.MsgBrokerOpenResponse: - type: object - properties: - id: - type: string - format: uint64 elys.margin.MsgCloseResponse: type: object properties: @@ -85112,8 +84963,6 @@ definitions: type: boolean invariant_check_epoch: type: string - broker_address: - type: string take_profit_borrow_interest_rate_min: type: string funding_fee_base_rate: @@ -85174,8 +85023,6 @@ definitions: type: boolean invariant_check_epoch: type: string - broker_address: - type: string take_profit_borrow_interest_rate_min: type: string funding_fee_base_rate: @@ -85756,6 +85603,8 @@ definitions: NOTE: The amount field is an Int which implements the custom method signatures required by gogoproto. + valid_collateral: + type: boolean position_size: type: object properties: @@ -85779,17 +85628,7 @@ definitions: liquidation_price: type: string estimated_pnl: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. + type: string available_liquidity: type: object properties: @@ -86193,7 +86032,15 @@ definitions: type: string format: uint64 description: QueryParamsResponse is response type for the Query/Params RPC method. - elys.parameter.AnteHandlerParam: + elys.parameter.MsgUpdateBrokerAddressResponse: + type: object + elys.parameter.MsgUpdateMaxVotingPowerResponse: + type: object + elys.parameter.MsgUpdateMinCommissionResponse: + type: object + elys.parameter.MsgUpdateMinSelfDelegationResponse: + type: object + elys.parameter.Params: type: object properties: min_commission_rate: @@ -86202,55 +86049,24 @@ definitions: type: string min_self_delegation: type: string - elys.parameter.Params: - type: object + broker_address: + type: string description: Params defines the parameters for the module. - elys.parameter.QueryAllAnteHandlerParamResponse: - type: object - properties: - ante_handler_param: - type: array - items: - type: object - properties: - min_commission_rate: - type: string - max_voting_power: - type: string - min_self_delegation: - type: string - pagination: - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise - description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. - - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } elys.parameter.QueryParamsResponse: type: object properties: params: description: params holds all the parameters of this module. type: object + properties: + min_commission_rate: + type: string + max_voting_power: + type: string + min_self_delegation: + type: string + broker_address: + type: string description: QueryParamsResponse is response type for the Query/Params RPC method. elys.stablestake.MsgBondResponse: type: object diff --git a/proto/elys/amm/params.proto b/proto/elys/amm/params.proto index ae24f0088..7922ce03d 100644 --- a/proto/elys/amm/params.proto +++ b/proto/elys/amm/params.proto @@ -10,5 +10,4 @@ message Params { option (gogoproto.goproto_stringer) = false; uint64 pool_creation_fee = 1; - string broker_address = 2; } diff --git a/proto/elys/margin/params.proto b/proto/elys/margin/params.proto index 34b84b681..805433079 100644 --- a/proto/elys/margin/params.proto +++ b/proto/elys/margin/params.proto @@ -63,25 +63,24 @@ message Params { bool incremental_borrow_interest_payment_enabled = 17; bool whitelisting_enabled = 18; string invariant_check_epoch = 19; - string broker_address = 20; - string take_profit_borrow_interest_rate_min = 21 [ + string take_profit_borrow_interest_rate_min = 20 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; - string funding_fee_base_rate = 22 [ + string funding_fee_base_rate = 21 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; - string funding_fee_max_rate = 23 [ + string funding_fee_max_rate = 22 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; - string funding_fee_min_rate = 24 [ + string funding_fee_min_rate = 23 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; - string funding_fee_collection_address = 25; - string swap_fee = 26 [ + string funding_fee_collection_address = 24; + string swap_fee = 25 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; diff --git a/proto/elys/margin/tx.proto b/proto/elys/margin/tx.proto index 3f2fb32c2..1265c71a2 100644 --- a/proto/elys/margin/tx.proto +++ b/proto/elys/margin/tx.proto @@ -13,8 +13,6 @@ import "elys/margin/types.proto"; service Msg { rpc Open (MsgOpen ) returns (MsgOpenResponse ); rpc Close (MsgClose ) returns (MsgCloseResponse ); - rpc BrokerOpen (MsgBrokerOpen ) returns (MsgBrokerOpenResponse ); - rpc BrokerClose (MsgBrokerClose ) returns (MsgBrokerCloseResponse ); rpc UpdateParams (MsgUpdateParams) returns (MsgUpdateParamsResponse); rpc UpdatePools (MsgUpdatePools ) returns (MsgUpdatePoolsResponse ); rpc Whitelist (MsgWhitelist ) returns (MsgWhitelistResponse ); @@ -50,38 +48,6 @@ message MsgCloseResponse { ]; } -message MsgBrokerOpen { - string creator = 1; - Position position = 2; - string leverage = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; - string trading_asset = 4; - cosmos.base.v1beta1.Coin collateral = 5 [(gogoproto.nullable) = false ] ; - string take_profit_price = 6 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; - string owner = 7; -} - -message MsgBrokerOpenResponse { - uint64 id = 1; -} - -message MsgBrokerClose { - string creator = 1; - uint64 id = 2; - string owner = 3; - string amount = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; -} - -message MsgBrokerCloseResponse { - uint64 id = 1; - string amount = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; -} - message MsgUpdateParams { // authority is the address that controls the module (defaults to x/gov unless overwritten). diff --git a/proto/elys/parameter/ante_handler_param.proto b/proto/elys/parameter/ante_handler_param.proto deleted file mode 100644 index 660a2239b..000000000 --- a/proto/elys/parameter/ante_handler_param.proto +++ /dev/null @@ -1,23 +0,0 @@ -syntax = "proto3"; -package elys.parameter; - -import "gogoproto/gogo.proto"; -import "cosmos/base/v1beta1/coin.proto"; - -option go_package = "github.com/elys-network/elys/x/parameter/types"; - -message AnteHandlerParam { - string min_commission_rate = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - string max_voting_power = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - string min_self_delegation = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; -} - diff --git a/proto/elys/parameter/genesis.proto b/proto/elys/parameter/genesis.proto index 373da456c..6b1902c58 100644 --- a/proto/elys/parameter/genesis.proto +++ b/proto/elys/parameter/genesis.proto @@ -4,13 +4,11 @@ package elys.parameter; import "gogoproto/gogo.proto"; import "elys/parameter/params.proto"; -import "elys/parameter/ante_handler_param.proto"; option go_package = "github.com/elys-network/elys/x/parameter/types"; // GenesisState defines the parameter module's genesis state. message GenesisState { - Params params = 1 [(gogoproto.nullable) = false]; - AnteHandlerParam ante_handler_param = 2 [(gogoproto.nullable) = false]; + Params params = 1 [(gogoproto.nullable) = false]; } diff --git a/proto/elys/parameter/params.proto b/proto/elys/parameter/params.proto index 3a3722efb..384d12a68 100644 --- a/proto/elys/parameter/params.proto +++ b/proto/elys/parameter/params.proto @@ -8,5 +8,18 @@ option go_package = "github.com/elys-network/elys/x/parameter/types"; // Params defines the parameters for the module. message Params { option (gogoproto.goproto_stringer) = false; - + + string min_commission_rate = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string max_voting_power = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string min_self_delegation = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + string broker_address = 4; } diff --git a/proto/elys/parameter/proposal.proto b/proto/elys/parameter/proposal.proto deleted file mode 100644 index 540da71ae..000000000 --- a/proto/elys/parameter/proposal.proto +++ /dev/null @@ -1,22 +0,0 @@ -syntax = "proto3"; -package elys.parameter; - -option go_package = "github.com/elys-network/elys/x/parameter/types"; - -message ProposalUpdateMinCommission { - string title = 1; - string description = 2; - string min_commission = 3; -} - -message ProposalUpdateMaxVotingPower { - string title = 1; - string description = 2; - string max_voting_power = 3; -} - -message ProposalUpdateMinSelfDelegation { - string title = 1; - string description = 2; - string min_self_delegation = 3; -} diff --git a/proto/elys/parameter/query.proto b/proto/elys/parameter/query.proto index a39b60e67..9c1010fe8 100644 --- a/proto/elys/parameter/query.proto +++ b/proto/elys/parameter/query.proto @@ -4,24 +4,15 @@ package elys.parameter; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; import "elys/parameter/params.proto"; -import "elys/parameter/ante_handler_param.proto"; option go_package = "github.com/elys-network/elys/x/parameter/types"; // Query defines the gRPC querier service. service Query { - // Parameters queries the parameters of the module. rpc Params (QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/elys-network/elys/parameter/params"; - - } - - rpc AnteHandlerParamAll (QueryAllAnteHandlerParamRequest) returns (QueryAllAnteHandlerParamResponse) { - option (google.api.http).get = "/elys-network/elys/parameter/ante_handler_param"; - } } // QueryParamsRequest is request type for the Query/Params RPC method. @@ -29,17 +20,6 @@ message QueryParamsRequest {} // QueryParamsResponse is response type for the Query/Params RPC method. message QueryParamsResponse { - // params holds all the parameters of this module. Params params = 1 [(gogoproto.nullable) = false]; } - -message QueryAllAnteHandlerParamRequest { - cosmos.base.query.v1beta1.PageRequest pagination = 1; -} - -message QueryAllAnteHandlerParamResponse { - repeated AnteHandlerParam ante_handler_param = 1 [(gogoproto.nullable) = false]; - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} - diff --git a/proto/elys/parameter/tx.proto b/proto/elys/parameter/tx.proto index 03b10bb2e..b16d953bd 100644 --- a/proto/elys/parameter/tx.proto +++ b/proto/elys/parameter/tx.proto @@ -4,4 +4,33 @@ package elys.parameter; option go_package = "github.com/elys-network/elys/x/parameter/types"; // Msg defines the Msg service. -service Msg {} \ No newline at end of file +service Msg { + rpc UpdateMinCommission(MsgUpdateMinCommission) returns (MsgUpdateMinCommissionResponse); + rpc UpdateMaxVotingPower(MsgUpdateMaxVotingPower) returns (MsgUpdateMaxVotingPowerResponse); + rpc UpdateMinSelfDelegation(MsgUpdateMinSelfDelegation) returns (MsgUpdateMinSelfDelegationResponse); + rpc UpdateBrokerAddress(MsgUpdateBrokerAddress) returns (MsgUpdateBrokerAddressResponse); +} + +message MsgUpdateMinCommission { + string creator = 1; + string min_commission = 2; +} +message MsgUpdateMinCommissionResponse {} + +message MsgUpdateMaxVotingPower { + string creator = 1; + string max_voting_power = 3; +} +message MsgUpdateMaxVotingPowerResponse {} + +message MsgUpdateMinSelfDelegation { + string creator = 1; + string min_self_delegation = 3; +} +message MsgUpdateMinSelfDelegationResponse {} + +message MsgUpdateBrokerAddress { + string creator = 1; + string broker_address = 3; +} +message MsgUpdateBrokerAddressResponse {} \ No newline at end of file diff --git a/scripts/examples/transferhook/mars.yml b/scripts/examples/transferhook/mars.yml index 9e80cb8fe..823658694 100644 --- a/scripts/examples/transferhook/mars.yml +++ b/scripts/examples/transferhook/mars.yml @@ -375,10 +375,11 @@ genesis: denom: "ueden" amount: "1000000" parameter: - anteHandlerParam: - minCommissionRate: "0.05" - maxVotingPower: "0.66" - minSelfDelegation: "1" + params: + min_commission_rate: "0.05" + max_voting_power: "0.66" + min_self_delegation: "1" + broker_address: "" margin: params: leverage_max: "10" diff --git a/testutil/keeper/amm.go b/testutil/keeper/amm.go index ae122b35e..e639cdd49 100644 --- a/testutil/keeper/amm.go +++ b/testutil/keeper/amm.go @@ -51,6 +51,7 @@ func AmmKeeper(t testing.TB) (*keeper.Keeper, sdk.Context, *mocks.AccountedPoolK authtypes.NewModuleAddress(govtypes.ModuleName).String(), nil, nil, + nil, oracleKeeper, nil, nil, diff --git a/testutil/keeper/margin.go b/testutil/keeper/margin.go index 9dc45b8a2..d6d095dae 100644 --- a/testutil/keeper/margin.go +++ b/testutil/keeper/margin.go @@ -40,6 +40,7 @@ func MarginKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { nil, nil, nil, + nil, ) ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) diff --git a/testutil/keeper/parameter.go b/testutil/keeper/parameter.go index 796fdcafc..4ddd736f9 100644 --- a/testutil/keeper/parameter.go +++ b/testutil/keeper/parameter.go @@ -11,7 +11,8 @@ import ( "github.com/cosmos/cosmos-sdk/store" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - typesparams "github.com/cosmos/cosmos-sdk/x/params/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/elys-network/elys/x/parameter/keeper" "github.com/elys-network/elys/x/parameter/types" "github.com/stretchr/testify/require" @@ -30,17 +31,11 @@ func ParameterKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { registry := codectypes.NewInterfaceRegistry() cdc := codec.NewProtoCodec(registry) - paramsSubspace := typesparams.NewSubspace(cdc, - types.Amino, - storeKey, - memStoreKey, - "ParameterParams", - ) k := keeper.NewKeeper( cdc, storeKey, memStoreKey, - paramsSubspace, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) diff --git a/wasmbindings/client/register_custom_plugins.go b/wasmbindings/client/register_custom_plugins.go index f5ae557dc..ae46e16a0 100644 --- a/wasmbindings/client/register_custom_plugins.go +++ b/wasmbindings/client/register_custom_plugins.go @@ -79,19 +79,19 @@ func RegisterCustomPlugins( clockMessenger := clockclientwasm.NewMessenger(clock) commitmentQuerier := commitmentclientwasm.NewQuerier(commitment, staking, epochs) - commitmentMessenger := commitmentclientwasm.NewMessenger(commitment, staking, assetprofile, stablestake) + commitmentMessenger := commitmentclientwasm.NewMessenger(commitment, staking, assetprofile, stablestake, parameter) epochsQuerier := epochsclientwasm.NewQuerier(epochs) epochsMessenger := epochsclientwasm.NewMessenger(epochs) incentiveQuerier := incentiveclientwasm.NewQuerier(incentive, staking) - incentiveMessenger := incentiveclientwasm.NewMessenger(incentive, staking, commitment) + incentiveMessenger := incentiveclientwasm.NewMessenger(incentive, staking, commitment, parameter) leveragelpQuerier := leveragelpclientwasm.NewQuerier(leveragelp) - leveragelpMessenger := leveragelpclientwasm.NewMessenger(leveragelp) + leveragelpMessenger := leveragelpclientwasm.NewMessenger(leveragelp, parameter) marginQuerier := marginclientwasm.NewQuerier(margin) - marginMessenger := marginclientwasm.NewMessenger(margin) + marginMessenger := marginclientwasm.NewMessenger(margin, parameter) oracleQuerier := oracleclientwasm.NewQuerier(oracle) oracleMessenger := oracleclientwasm.NewMessenger(oracle) @@ -100,7 +100,7 @@ func RegisterCustomPlugins( parameterMessenger := parameterclientwasm.NewMessenger(parameter) stablestakeQuerier := stablestakeclientwasm.NewQuerier(stablestake) - stablestakeMessenger := stablestakeclientwasm.NewMessenger(stablestake) + stablestakeMessenger := stablestakeclientwasm.NewMessenger(stablestake, parameter) tokenomicsQuerier := tokenomicsclientwasm.NewQuerier(tokenomics) tokenomicsMessenger := tokenomicsclientwasm.NewMessenger(tokenomics) diff --git a/wasmbindings/externals/auth/query_accounts.go b/wasmbindings/externals/auth/query_accounts.go index 4c4c9c80c..adfd1cffd 100644 --- a/wasmbindings/externals/auth/query_accounts.go +++ b/wasmbindings/externals/auth/query_accounts.go @@ -9,7 +9,7 @@ import ( ) func (oq *Querier) queryAccounts(ctx sdk.Context, req *types.QueryAccountsRequest) ([]byte, error) { - res, err := oq.keeper.Accounts(ctx, req) + res, err := oq.keeper.Accounts(sdk.WrapSDKContext(ctx), req) if err != nil { return nil, errorsmod.Wrap(err, "failed to get accounts") } diff --git a/wasmbindings/types/types.go b/wasmbindings/types/types.go index 6f761a391..c85d9d4ed 100644 --- a/wasmbindings/types/types.go +++ b/wasmbindings/types/types.go @@ -193,8 +193,7 @@ type ElysQuery struct { OraclePriceFeederAll *oracletypes.QueryAllPriceFeederRequest `json:"oracle_price_feeder_all,omitempty"` // parameter queriers - ParameterParams *parametertypes.QueryParamsRequest `json:"parameter_params,omitempty"` - ParameterAnteHandlerParamAll *parametertypes.QueryAllAnteHandlerParamRequest `json:"parameter_ante_handler_param_all,omitempty"` + ParameterParams *parametertypes.QueryParamsRequest `json:"parameter_params,omitempty"` // stablestake queriers StableStakeParams *stablestaketypes.QueryParamsRequest `json:"stable_stake_params,omitempty"` @@ -239,26 +238,17 @@ type ElysMsg struct { // accountedpool messages // amm messages - AmmCreatePool *ammtypes.MsgCreatePool `json:"amm_create_pool,omitempty"` - AmmJoinPool *ammtypes.MsgJoinPool `json:"amm_join_pool,omitempty"` - AmmExitPool *ammtypes.MsgExitPool `json:"amm_exit_pool,omitempty"` - AmmSwapExactAmountIn *ammtypes.MsgSwapExactAmountIn `json:"amm_swap_exact_amount_in,omitempty"` - AmmSwapExactAmountOut *ammtypes.MsgSwapExactAmountOut `json:"amm_swap_exact_amount_out,omitempty"` - AmmSwapByDenom *ammtypes.MsgSwapByDenom `json:"amm_swap_by_denom,omitempty"` - AmmFeedMultipleExternalLiquidity *ammtypes.MsgFeedMultipleExternalLiquidity `json:"amm_feed_multiple_external_liquidity,omitempty"` - AmmUpdatePoolParams *ammtypes.MsgUpdatePoolParams `json:"amm_update_pool_params,omitempty"` + AmmCreatePool *ammtypes.MsgCreatePool `json:"amm_create_pool,omitempty"` + AmmJoinPool *ammtypes.MsgJoinPool `json:"amm_join_pool,omitempty"` + AmmExitPool *ammtypes.MsgExitPool `json:"amm_exit_pool,omitempty"` + AmmSwapExactAmountIn *ammtypes.MsgSwapExactAmountIn `json:"amm_swap_exact_amount_in,omitempty"` + AmmSwapExactAmountOut *ammtypes.MsgSwapExactAmountOut `json:"amm_swap_exact_amount_out,omitempty"` + AmmSwapByDenom *ammtypes.MsgSwapByDenom `json:"amm_swap_by_denom,omitempty"` // assetprofile messages - AssetProfileCreateEntry *assetprofiletypes.MsgCreateEntry `json:"asset_profile_create_entry,omitempty"` - AssetProfileUpdateEntry *assetprofiletypes.MsgUpdateEntry `json:"asset_profile_update_entry,omitempty"` - AssetProfileDeleteEntry *assetprofiletypes.MsgDeleteEntry `json:"asset_profile_delete_entry,omitempty"` - // auth messages - // burner messages - // clock messages - ClockUpdateParams *clocktypes.MsgUpdateParams `json:"clock_update_params,omitempty"` // commitment messages CommitmentCommitLiquidTokens *commitmenttypes.MsgCommitLiquidTokens `json:"commitment_commit_liquid_tokens,omitempty"` @@ -281,30 +271,14 @@ type ElysMsg struct { IncentiveWithdrawValidatorCommission *incentivetypes.MsgWithdrawValidatorCommission `json:"incentive_withdraw_validator_commission"` // leveragelp messages - LeveragelpOpen *leveragelptypes.MsgOpen `json:"leveragelp_open,omitempty"` - LeveragelpClose *leveragelptypes.MsgClose `json:"leveragelp_close,omitempty"` - LeveragelpUpdateParams *leveragelptypes.MsgUpdateParams `json:"leveragelp_update_params,omitempty"` - LeveragelpUpdatePools *leveragelptypes.MsgUpdatePools `json:"leveragelp_update_pools,omitempty"` - LeveragelpWhitelist *leveragelptypes.MsgWhitelist `json:"leveragelp_whitelist,omitempty"` - LeveragelpDewhitelist *leveragelptypes.MsgDewhitelist `json:"leveragelp_dewhitelist,omitempty"` + LeveragelpOpen *leveragelptypes.MsgOpen `json:"leveragelp_open,omitempty"` + LeveragelpClose *leveragelptypes.MsgClose `json:"leveragelp_close,omitempty"` // margin messages - MarginOpen *margintypes.MsgOpen `json:"margin_open,omitempty"` - MarginClose *margintypes.MsgClose `json:"margin_close,omitempty"` - MarginBrokerOpen *margintypes.MsgBrokerOpen `json:"margin_broker_open,omitempty"` - MarginBrokerClose *margintypes.MsgBrokerClose `json:"margin_broker_close,omitempty"` - MarginUpdateParams *margintypes.MsgUpdateParams `json:"margin_update_params,omitempty"` - MarginUpdatePools *margintypes.MsgUpdatePools `json:"margin_update_pools,omitempty"` - MarginWhitelist *margintypes.MsgWhitelist `json:"margin_whitelist,omitempty"` - MarginDewhitelist *margintypes.MsgDewhitelist `json:"margin_dewhitelist,omitempty"` + MarginOpen *margintypes.MsgOpen `json:"margin_open,omitempty"` + MarginClose *margintypes.MsgClose `json:"margin_close,omitempty"` // oracle messages - OracleFeedPrice *oracletypes.MsgFeedPrice `json:"oracle_feed_price,omitempty"` - OracleFeedMultiplePrices *oracletypes.MsgFeedMultiplePrices `json:"oracle_feed_multiple_price,omitempty"` - OracleRequestBandPrice *oracletypes.MsgRequestBandPrice `json:"oracle_request_band_price,omitempty"` - OracleSetPriceFeeder *oracletypes.MsgSetPriceFeeder `json:"oracle_set_price_feeder,omitempty"` - OracleDeletePriceFeeder *oracletypes.MsgDeletePriceFeeder `json:"oracle_delete_price_feeder,omitempty"` - // parameter messages // stablestake messages @@ -312,14 +286,6 @@ type ElysMsg struct { StakestakeUnbond *stablestaketypes.MsgUnbond `json:"stablestake_unbond,omitempty"` // tokenomics messages - TokenomicsCreateAirdrop *tokenomicstypes.MsgCreateAirdrop `json:"tokenomics_create_airdrop,omitempty"` - TokenomicsUpdateAirdrop *tokenomicstypes.MsgUpdateAirdrop `json:"tokenomics_update_airdrop,omitempty"` - TokenomicsDeleteAirdrop *tokenomicstypes.MsgDeleteAirdrop `json:"tokenomics_delete_airdrop,omitempty"` - TokenomicsUpdateGenesisInflation *tokenomicstypes.MsgUpdateGenesisInflation `json:"tokenomics_update_genesis_inflation,omitempty"` - TokenomicsCreateTimeBasedInflation *tokenomicstypes.MsgCreateTimeBasedInflation `json:"tokenomics_create_time_based_inflation,omitempty"` - TokenomicsUpdateTimeBasedInflation *tokenomicstypes.MsgUpdateTimeBasedInflation `json:"tokenomics_update_time_based_inflation,omitempty"` - TokenomicsDeleteTimeBasedInflation *tokenomicstypes.MsgDeleteTimeBasedInflation `json:"tokenomics_delete_time_based_inflation,omitempty"` - // transferhook messages } diff --git a/x/amm/client/wasm/messenger.go b/x/amm/client/wasm/messenger.go index 3824c2164..01a5a624c 100644 --- a/x/amm/client/wasm/messenger.go +++ b/x/amm/client/wasm/messenger.go @@ -29,10 +29,6 @@ func (m *Messenger) HandleMsg(ctx sdk.Context, contractAddr sdk.AccAddress, cont return m.msgSwapExactAmountOut(ctx, contractAddr, msg.AmmSwapExactAmountOut) case msg.AmmSwapByDenom != nil: return m.msgSwapByDenom(ctx, contractAddr, msg.AmmSwapByDenom) - case msg.AmmFeedMultipleExternalLiquidity != nil: - return m.msgFeedMultipleExternalLiquidity(ctx, contractAddr, msg.AmmFeedMultipleExternalLiquidity) - case msg.AmmUpdatePoolParams != nil: - return m.msgUpdatePoolParams(ctx, contractAddr, msg.AmmUpdatePoolParams) default: // This handler cannot handle the message return nil, nil, wasmbindingstypes.ErrCannotHandleMsg diff --git a/x/amm/client/wasm/msg_feed_multiple_external_liquidity.go b/x/amm/client/wasm/msg_feed_multiple_external_liquidity.go deleted file mode 100644 index e4f41baa5..000000000 --- a/x/amm/client/wasm/msg_feed_multiple_external_liquidity.go +++ /dev/null @@ -1,44 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - ammkeeper "github.com/elys-network/elys/x/amm/keeper" - ammtypes "github.com/elys-network/elys/x/amm/types" -) - -func (m *Messenger) msgFeedMultipleExternalLiquidity(ctx sdk.Context, contractAddr sdk.AccAddress, msg *ammtypes.MsgFeedMultipleExternalLiquidity) ([]sdk.Event, [][]byte, error) { - if msg == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "FeedMultipleExternalLiquidity null msg"} - } - - if msg.Sender != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "FeedMultipleExternalLiquidity wrong sender"} - } - - msgServer := ammkeeper.NewMsgServerImpl(*m.keeper) - - if err := msg.ValidateBasic(); err != nil { - return nil, nil, errorsmod.Wrap(err, "failed validating msg") - } - - res, err := msgServer.FeedMultipleExternalLiquidity( - sdk.WrapSDKContext(ctx), - msg, - ) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "FeedMultipleExternalLiquidity msg") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize FeedMultipleExternalLiquidity response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} diff --git a/x/amm/client/wasm/msg_update_pool_params.go b/x/amm/client/wasm/msg_update_pool_params.go deleted file mode 100644 index 0a9f8e9c4..000000000 --- a/x/amm/client/wasm/msg_update_pool_params.go +++ /dev/null @@ -1,44 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - ammkeeper "github.com/elys-network/elys/x/amm/keeper" - ammtypes "github.com/elys-network/elys/x/amm/types" -) - -func (m *Messenger) msgUpdatePoolParams(ctx sdk.Context, contractAddr sdk.AccAddress, msg *ammtypes.MsgUpdatePoolParams) ([]sdk.Event, [][]byte, error) { - if msg == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "update pool params null msg"} - } - - if msg.Sender != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "update pool params wrong sender"} - } - - msgServer := ammkeeper.NewMsgServerImpl(*m.keeper) - - if err := msg.ValidateBasic(); err != nil { - return nil, nil, errorsmod.Wrap(err, "failed validating msg") - } - - res, err := msgServer.UpdatePoolParams( - sdk.WrapSDKContext(ctx), - msg, - ) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "update pool params msg") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize update pool params response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} diff --git a/x/amm/keeper/apply_discount.go b/x/amm/keeper/apply_discount.go deleted file mode 100644 index 55ba662b5..000000000 --- a/x/amm/keeper/apply_discount.go +++ /dev/null @@ -1,30 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/elys-network/elys/x/amm/types" -) - -// ApplyDiscount applies discount to swap fee if applicable -func (k Keeper) ApplyDiscount(ctx sdk.Context, swapFee sdk.Dec, discount sdk.Dec, sender string) (sdk.Dec, sdk.Dec, error) { - // if discount is nil, return swap fee and zero discount - if discount.IsNil() { - return swapFee, sdk.ZeroDec(), nil - } - - // if discount is zero, return swap fee and zero discount - if discount.IsZero() { - return swapFee, sdk.ZeroDec(), nil - } - - // check if discount is positive and signer address is broker address otherwise throw an error - if discount.IsPositive() && sender != k.BrokerAddress(ctx) { - return sdk.ZeroDec(), sdk.ZeroDec(), sdkerrors.Wrapf(types.ErrInvalidDiscount, "discount %s is positive and signer address %s is not broker address %s", discount, sender, k.BrokerAddress(ctx)) - } - - // apply discount percentage to swap fee - swapFee = swapFee.Mul(sdk.OneDec().Sub(discount)) - - return swapFee, discount, nil -} diff --git a/x/amm/keeper/apply_discount_test.go b/x/amm/keeper/apply_discount_test.go deleted file mode 100644 index 0cf251ad9..000000000 --- a/x/amm/keeper/apply_discount_test.go +++ /dev/null @@ -1,102 +0,0 @@ -package keeper_test - -import ( - "testing" - - "github.com/cosmos/cosmos-sdk/types" - keepertest "github.com/elys-network/elys/testutil/keeper" - "github.com/stretchr/testify/require" -) - -func TestApplyDiscount(t *testing.T) { - // Mock context and keeper - k, ctx, _, _ := keepertest.AmmKeeper(t) - - // Define test cases - tests := []struct { - name string - swapFee types.Dec - discount types.Dec - sender string - wantFee types.Dec - wantError bool - }{ - { - name: "Zero discount", - swapFee: types.NewDecWithPrec(100, 2), // 1.00 as an example - discount: types.ZeroDec(), - sender: "testSender", - wantFee: types.NewDecWithPrec(100, 2), - }, - { - name: "Positive discount with valid broker address", - swapFee: types.NewDecWithPrec(100, 2), - discount: types.NewDecWithPrec(10, 2), // 0.10 (10%) - sender: k.BrokerAddress(ctx), - wantFee: types.NewDecWithPrec(90, 2), // 0.90 after discount - }, - { - name: "Positive discount with invalid broker address", - swapFee: types.NewDecWithPrec(100, 2), - discount: types.NewDecWithPrec(10, 2), - sender: "invalidBroker", - wantError: true, - }, - { - name: "Boundary value for discount", - swapFee: types.NewDecWithPrec(100, 2), - discount: types.NewDecWithPrec(9999, 4), // 0.9999 (99.99%) - sender: k.BrokerAddress(ctx), - wantFee: types.NewDecWithPrec(1, 4), // 0.01 after discount - }, - { - name: "Discount greater than swap fee", - swapFee: types.NewDecWithPrec(50, 2), // 0.50 - discount: types.NewDecWithPrec(75, 2), // 0.75 - sender: k.BrokerAddress(ctx), - wantFee: types.NewDecWithPrec(125, 3), - }, - { - name: "Invalid swap fee", - swapFee: types.NewDecWithPrec(-100, 2), // -1.00 (invalid) - discount: types.NewDecWithPrec(10, 2), - sender: "testSender", - wantError: true, - }, - { - name: "Zero swap fee with valid discount", - swapFee: types.ZeroDec(), - discount: types.NewDecWithPrec(10, 2), - sender: k.BrokerAddress(ctx), - wantFee: types.ZeroDec(), - }, - { - name: "Large discount with valid broker address", - swapFee: types.NewDecWithPrec(100, 2), - discount: types.NewDecWithPrec(9000, 4), // 0.90 (90%) - sender: k.BrokerAddress(ctx), - wantFee: types.NewDecWithPrec(10, 2), // 0.10 after discount - }, - { - name: "Large discount with invalid broker address", - swapFee: types.NewDecWithPrec(100, 2), - discount: types.NewDecWithPrec(9000, 4), // 0.90 - sender: "invalidBroker", - wantError: true, - }, - } - - for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { - fee, discount, err := k.ApplyDiscount(ctx, tc.swapFee, tc.discount, tc.sender) - - if tc.wantError { - require.Error(t, err) - } else { - require.NoError(t, err) - require.Equal(t, tc.wantFee, fee) - require.Equal(t, tc.discount, discount) - } - }) - } -} diff --git a/x/amm/keeper/calc_in_route_spot_price.go b/x/amm/keeper/calc_in_route_spot_price.go index 15b941b5e..9ed73a568 100644 --- a/x/amm/keeper/calc_in_route_spot_price.go +++ b/x/amm/keeper/calc_in_route_spot_price.go @@ -40,11 +40,8 @@ func (k Keeper) CalcInRouteSpotPrice(ctx sdk.Context, tokenIn sdk.Coin, routes [ swapFee = overrideSwapFee } - // Apply discount to swap fee if applicable - swapFee, _, err := k.ApplyDiscount(ctx, swapFee, discount, k.BrokerAddress(ctx)) - if err != nil { - return sdk.ZeroDec(), sdk.Coin{}, sdk.ZeroDec(), sdk.ZeroDec(), sdk.Coin{}, err - } + // Apply discount to swap fee + swapFee = types.ApplyDiscount(swapFee, discount) // Calculate the total discounted swap fee totalDiscountedSwapFee = totalDiscountedSwapFee.Add(swapFee) diff --git a/x/amm/keeper/calc_out_route_spot_price.go b/x/amm/keeper/calc_out_route_spot_price.go index 9dcb6b44a..7deb55809 100644 --- a/x/amm/keeper/calc_out_route_spot_price.go +++ b/x/amm/keeper/calc_out_route_spot_price.go @@ -40,11 +40,8 @@ func (k Keeper) CalcOutRouteSpotPrice(ctx sdk.Context, tokenOut sdk.Coin, routes swapFee = overrideSwapFee } - // Apply discount to swap fee if applicable - swapFee, _, err := k.ApplyDiscount(ctx, swapFee, discount, k.BrokerAddress(ctx)) - if err != nil { - return sdk.ZeroDec(), sdk.Coin{}, sdk.ZeroDec(), sdk.ZeroDec(), sdk.Coin{}, err - } + // Apply discount + swapFee = types.ApplyDiscount(swapFee, discount) // Calculate the total discounted swap fee totalDiscountedSwapFee = totalDiscountedSwapFee.Add(swapFee) diff --git a/x/amm/keeper/keeper.go b/x/amm/keeper/keeper.go index eb0c85dbc..bc82ca6d9 100644 --- a/x/amm/keeper/keeper.go +++ b/x/amm/keeper/keeper.go @@ -11,6 +11,7 @@ import ( "github.com/elys-network/elys/x/amm/types" commitmentkeeper "github.com/elys-network/elys/x/commitment/keeper" + pkeeper "github.com/elys-network/elys/x/parameter/keeper" ) type ( @@ -22,6 +23,7 @@ type ( authority string hooks types.AmmHooks + parameterKeeper *pkeeper.Keeper bankKeeper types.BankKeeper accountKeeper types.AccountKeeper oracleKeeper types.OracleKeeper @@ -38,6 +40,7 @@ func NewKeeper( ps paramtypes.Subspace, authority string, + parameterKeeper *pkeeper.Keeper, bankKeeper types.BankKeeper, accountKeeper types.AccountKeeper, oracleKeeper types.OracleKeeper, @@ -57,6 +60,7 @@ func NewKeeper( paramstore: ps, authority: authority, + parameterKeeper: parameterKeeper, bankKeeper: bankKeeper, accountKeeper: accountKeeper, oracleKeeper: oracleKeeper, diff --git a/x/amm/keeper/params.go b/x/amm/keeper/params.go index 1c6675d38..99f4b8be6 100644 --- a/x/amm/keeper/params.go +++ b/x/amm/keeper/params.go @@ -9,7 +9,6 @@ import ( func (k Keeper) GetParams(ctx sdk.Context) types.Params { return types.NewParams( k.PoolCreationFee(ctx), - k.BrokerAddress(ctx), ) } @@ -23,9 +22,3 @@ func (k Keeper) PoolCreationFee(ctx sdk.Context) (res uint64) { k.paramstore.Get(ctx, types.KeyPoolCreationFee, &res) return } - -// BrokerAddress returns the BrokerAddress param -func (k Keeper) BrokerAddress(ctx sdk.Context) (res string) { - k.paramstore.Get(ctx, types.KeyBrokerAddress, &res) - return -} diff --git a/x/amm/keeper/route_exact_amount_in.go b/x/amm/keeper/route_exact_amount_in.go index d002347a6..5d17a2dc4 100644 --- a/x/amm/keeper/route_exact_amount_in.go +++ b/x/amm/keeper/route_exact_amount_in.go @@ -3,6 +3,7 @@ package keeper import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/elys-network/elys/x/amm/types" ) @@ -73,10 +74,14 @@ func (k Keeper) RouteExactAmountIn( } // Apply discount to swap fee if applicable - swapFee, _, err = k.ApplyDiscount(ctx, swapFee, discount, sender.String()) - if err != nil { - return math.Int{}, sdk.ZeroDec(), sdk.ZeroDec(), err + brokerAddress := k.parameterKeeper.GetParams(ctx).BrokerAddress + if discount.IsNil() { + discount = sdk.ZeroDec() + } + if discount.IsPositive() && sender.String() != brokerAddress { + return math.Int{}, sdk.ZeroDec(), sdk.ZeroDec(), sdkerrors.Wrapf(types.ErrInvalidDiscount, "discount %s is positive and signer address %s is not broker address %s", discount, sender, brokerAddress) } + swapFee = types.ApplyDiscount(swapFee, discount) // Calculate the total discounted swap fee totalDiscountedSwapFee = totalDiscountedSwapFee.Add(swapFee) diff --git a/x/amm/keeper/route_exact_amount_out.go b/x/amm/keeper/route_exact_amount_out.go index 7c09808e4..dd6071f61 100644 --- a/x/amm/keeper/route_exact_amount_out.go +++ b/x/amm/keeper/route_exact_amount_out.go @@ -5,6 +5,7 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/elys-network/elys/x/amm/types" ) @@ -99,10 +100,14 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, } // Apply discount to swap fee if applicable - swapFee, discount, err = k.ApplyDiscount(ctx, swapFee, discount, sender.String()) - if err != nil { - return math.Int{}, sdk.ZeroDec(), sdk.ZeroDec(), err + brokerAddress := k.parameterKeeper.GetParams(ctx).BrokerAddress + if discount.IsNil() { + discount = sdk.ZeroDec() + } + if discount.IsPositive() && sender.String() != brokerAddress { + return math.Int{}, sdk.ZeroDec(), sdk.ZeroDec(), sdkerrors.Wrapf(types.ErrInvalidDiscount, "discount %s is positive and signer address %s is not broker address %s", discount, sender, brokerAddress) } + swapFee = types.ApplyDiscount(swapFee, discount) // Calculate the total discounted swap fee totalDiscountedSwapFee = totalDiscountedSwapFee.Add(swapFee) diff --git a/x/amm/types/apply_discount.go b/x/amm/types/apply_discount.go new file mode 100644 index 000000000..ba05e3178 --- /dev/null +++ b/x/amm/types/apply_discount.go @@ -0,0 +1,12 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// ApplyDiscount applies discount to swap fee if applicable +func ApplyDiscount(swapFee sdk.Dec, discount sdk.Dec) sdk.Dec { + // apply discount percentage to swap fee + swapFee = swapFee.Mul(sdk.OneDec().Sub(discount)) + return swapFee +} diff --git a/x/amm/types/apply_discount_test.go b/x/amm/types/apply_discount_test.go new file mode 100644 index 000000000..922c19e12 --- /dev/null +++ b/x/amm/types/apply_discount_test.go @@ -0,0 +1,63 @@ +package types_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/amm/types" + "github.com/stretchr/testify/require" +) + +func TestApplyDiscount(t *testing.T) { + // Define test cases + tests := []struct { + name string + swapFee sdk.Dec + discount sdk.Dec + wantFee sdk.Dec + }{ + { + name: "Zero discount", + swapFee: sdk.NewDecWithPrec(100, 2), // 1.00 as an example + discount: sdk.ZeroDec(), + wantFee: sdk.NewDecWithPrec(100, 2), + }, + { + name: "Positive discount with valid broker address", + swapFee: sdk.NewDecWithPrec(100, 2), + discount: sdk.NewDecWithPrec(10, 2), // 0.10 (10%) + wantFee: sdk.NewDecWithPrec(90, 2), // 0.90 after discount + }, + { + name: "Boundary value for discount", + swapFee: sdk.NewDecWithPrec(100, 2), + discount: sdk.NewDecWithPrec(9999, 4), // 0.9999 (99.99%) + wantFee: sdk.NewDecWithPrec(1, 4), // 0.01 after discount + }, + { + name: "Discount greater than swap fee", + swapFee: sdk.NewDecWithPrec(50, 2), // 0.50 + discount: sdk.NewDecWithPrec(75, 2), // 0.75 + wantFee: sdk.NewDecWithPrec(125, 3), + }, + { + name: "Zero swap fee with valid discount", + swapFee: sdk.ZeroDec(), + discount: sdk.NewDecWithPrec(10, 2), + wantFee: sdk.ZeroDec(), + }, + { + name: "Large discount with valid broker address", + swapFee: sdk.NewDecWithPrec(100, 2), + discount: sdk.NewDecWithPrec(9000, 4), // 0.90 (90%) + wantFee: sdk.NewDecWithPrec(10, 2), // 0.10 after discount + }, + } + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + fee := types.ApplyDiscount(tc.swapFee, tc.discount) + require.Equal(t, tc.wantFee, fee) + }) + } +} diff --git a/x/amm/types/params.go b/x/amm/types/params.go index 4757a17e4..3995b600a 100644 --- a/x/amm/types/params.go +++ b/x/amm/types/params.go @@ -14,7 +14,6 @@ var ( KeyBrokerAddress = []byte("BrokerAddress") // TODO: Determine the default value DefaultPoolCreationFee uint64 = 0 - DefaultBrokerAddress string = "" ) // ParamKeyTable the param key table for launch module @@ -25,11 +24,9 @@ func ParamKeyTable() paramtypes.KeyTable { // NewParams creates a new Params instance func NewParams( poolCreationFee uint64, - brokerAddress string, ) Params { return Params{ PoolCreationFee: poolCreationFee, - BrokerAddress: brokerAddress, } } @@ -37,7 +34,6 @@ func NewParams( func DefaultParams() Params { return NewParams( DefaultPoolCreationFee, - DefaultBrokerAddress, ) } @@ -45,7 +41,6 @@ func DefaultParams() Params { func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyPoolCreationFee, &p.PoolCreationFee, validatePoolCreationFee), - paramtypes.NewParamSetPair(KeyBrokerAddress, &p.BrokerAddress, validateBrokerAddress), } } @@ -54,9 +49,6 @@ func (p Params) Validate() error { if err := validatePoolCreationFee(p.PoolCreationFee); err != nil { return err } - if err := validateBrokerAddress(p.BrokerAddress); err != nil { - return err - } return nil } @@ -79,16 +71,3 @@ func validatePoolCreationFee(v interface{}) error { return nil } - -// validateBrokerAddress validates the BrokerAddress param -func validateBrokerAddress(v interface{}) error { - brokerAddress, ok := v.(string) - if !ok { - return fmt.Errorf("invalid parameter type: %T", v) - } - - // TODO implement validation - _ = brokerAddress - - return nil -} diff --git a/x/amm/types/params.pb.go b/x/amm/types/params.pb.go index f75444f0f..99f1539a6 100644 --- a/x/amm/types/params.pb.go +++ b/x/amm/types/params.pb.go @@ -26,7 +26,6 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { PoolCreationFee uint64 `protobuf:"varint,1,opt,name=pool_creation_fee,json=poolCreationFee,proto3" json:"pool_creation_fee,omitempty"` - BrokerAddress string `protobuf:"bytes,2,opt,name=broker_address,json=brokerAddress,proto3" json:"broker_address,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -68,13 +67,6 @@ func (m *Params) GetPoolCreationFee() uint64 { return 0 } -func (m *Params) GetBrokerAddress() string { - if m != nil { - return m.BrokerAddress - } - return "" -} - func init() { proto.RegisterType((*Params)(nil), "elys.amm.Params") } @@ -82,21 +74,19 @@ func init() { func init() { proto.RegisterFile("elys/amm/params.proto", fileDescriptor_1209ca218537a425) } var fileDescriptor_1209ca218537a425 = []byte{ - // 215 bytes of a gzipped FileDescriptorProto + // 184 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4d, 0xcd, 0xa9, 0x2c, 0xd6, 0x4f, 0xcc, 0xcd, 0xd5, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x00, 0x09, 0xeb, 0x25, 0xe6, 0xe6, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, - 0x05, 0xf5, 0x41, 0x2c, 0x88, 0xbc, 0x52, 0x22, 0x17, 0x5b, 0x00, 0x58, 0xbd, 0x90, 0x16, 0x97, + 0x05, 0xf5, 0x41, 0x2c, 0x88, 0xbc, 0x92, 0x15, 0x17, 0x5b, 0x00, 0x58, 0xbd, 0x90, 0x16, 0x97, 0x60, 0x41, 0x7e, 0x7e, 0x4e, 0x7c, 0x72, 0x51, 0x6a, 0x62, 0x49, 0x66, 0x7e, 0x5e, 0x7c, 0x5a, 0x6a, 0xaa, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x4b, 0x10, 0x3f, 0x48, 0xc2, 0x19, 0x2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0x80, 0x9d, + 0x59, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x76, 0x86, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, + 0x80, 0xf9, 0xf7, 0xd8, 0xbf, 0x00, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -119,13 +109,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.BrokerAddress) > 0 { - i -= len(m.BrokerAddress) - copy(dAtA[i:], m.BrokerAddress) - i = encodeVarintParams(dAtA, i, uint64(len(m.BrokerAddress))) - i-- - dAtA[i] = 0x12 - } if m.PoolCreationFee != 0 { i = encodeVarintParams(dAtA, i, uint64(m.PoolCreationFee)) i-- @@ -154,10 +137,6 @@ func (m *Params) Size() (n int) { if m.PoolCreationFee != 0 { n += 1 + sovParams(uint64(m.PoolCreationFee)) } - l = len(m.BrokerAddress) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } return n } @@ -215,38 +194,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BrokerAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - 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 ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.BrokerAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/assetprofile/client/wasm/messenger.go b/x/assetprofile/client/wasm/messenger.go index 0a6873375..e74a4d63b 100644 --- a/x/assetprofile/client/wasm/messenger.go +++ b/x/assetprofile/client/wasm/messenger.go @@ -17,12 +17,6 @@ func NewMessenger(keeper *keeper.Keeper) *Messenger { func (m *Messenger) HandleMsg(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmbindingstypes.ElysMsg) ([]sdk.Event, [][]byte, error) { switch { - case msg.AssetProfileCreateEntry != nil: - return m.msgCreateEntry(ctx, contractAddr, msg.AssetProfileCreateEntry) - case msg.AssetProfileUpdateEntry != nil: - return m.msgUpdateEntry(ctx, contractAddr, msg.AssetProfileUpdateEntry) - case msg.AssetProfileDeleteEntry != nil: - return m.msgDeleteEntry(ctx, contractAddr, msg.AssetProfileDeleteEntry) default: // This handler cannot handle the message return nil, nil, wasmbindingstypes.ErrCannotHandleMsg diff --git a/x/assetprofile/client/wasm/msg_create_entry.go b/x/assetprofile/client/wasm/msg_create_entry.go deleted file mode 100644 index a0988c379..000000000 --- a/x/assetprofile/client/wasm/msg_create_entry.go +++ /dev/null @@ -1,44 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - keeper "github.com/elys-network/elys/x/assetprofile/keeper" - types "github.com/elys-network/elys/x/assetprofile/types" -) - -func (m *Messenger) msgCreateEntry(ctx sdk.Context, contractAddr sdk.AccAddress, msg *types.MsgCreateEntry) ([]sdk.Event, [][]byte, error) { - if msg == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "CreateEntry null msg"} - } - - if msg.Authority != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "create entry wrong sender"} - } - - msgServer := keeper.NewMsgServerImpl(*m.keeper) - - if err := msg.ValidateBasic(); err != nil { - return nil, nil, errorsmod.Wrap(err, "failed validating msg") - } - - res, err := msgServer.CreateEntry( - sdk.WrapSDKContext(ctx), - msg, - ) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "CreateEntry msg") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize CreateEntry response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} diff --git a/x/assetprofile/client/wasm/msg_delete_entry.go b/x/assetprofile/client/wasm/msg_delete_entry.go deleted file mode 100644 index 7d5df4b5f..000000000 --- a/x/assetprofile/client/wasm/msg_delete_entry.go +++ /dev/null @@ -1,44 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - keeper "github.com/elys-network/elys/x/assetprofile/keeper" - types "github.com/elys-network/elys/x/assetprofile/types" -) - -func (m *Messenger) msgDeleteEntry(ctx sdk.Context, contractAddr sdk.AccAddress, msg *types.MsgDeleteEntry) ([]sdk.Event, [][]byte, error) { - if msg == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "DeleteEntry null msg"} - } - - if msg.Authority != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "delete entry wrong sender"} - } - - msgServer := keeper.NewMsgServerImpl(*m.keeper) - - if err := msg.ValidateBasic(); err != nil { - return nil, nil, errorsmod.Wrap(err, "failed validating msg") - } - - res, err := msgServer.DeleteEntry( - sdk.WrapSDKContext(ctx), - msg, - ) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "DeleteEntry msg") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize DeleteEntry response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} diff --git a/x/assetprofile/client/wasm/msg_update_entry.go b/x/assetprofile/client/wasm/msg_update_entry.go deleted file mode 100644 index a786a77b1..000000000 --- a/x/assetprofile/client/wasm/msg_update_entry.go +++ /dev/null @@ -1,44 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - keeper "github.com/elys-network/elys/x/assetprofile/keeper" - types "github.com/elys-network/elys/x/assetprofile/types" -) - -func (m *Messenger) msgUpdateEntry(ctx sdk.Context, contractAddr sdk.AccAddress, msg *types.MsgUpdateEntry) ([]sdk.Event, [][]byte, error) { - if msg == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "UpdateEntry null msg"} - } - - if msg.Authority != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "update entry wrong sender"} - } - - msgServer := keeper.NewMsgServerImpl(*m.keeper) - - if err := msg.ValidateBasic(); err != nil { - return nil, nil, errorsmod.Wrap(err, "failed validating msg") - } - - res, err := msgServer.UpdateEntry( - sdk.WrapSDKContext(ctx), - msg, - ) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "UpdateEntry msg") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize UpdateEntry response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} diff --git a/x/clock/client/wasm/messenger.go b/x/clock/client/wasm/messenger.go index 4e51adc3e..f1373458c 100644 --- a/x/clock/client/wasm/messenger.go +++ b/x/clock/client/wasm/messenger.go @@ -17,8 +17,6 @@ func NewMessenger(keeper *keeper.Keeper) *Messenger { func (m *Messenger) HandleMsg(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmbindingstypes.ElysMsg) ([]sdk.Event, [][]byte, error) { switch { - case msg.ClockUpdateParams != nil: - return m.msgUpdateParams(ctx, contractAddr, msg.ClockUpdateParams) default: // This handler cannot handle the message return nil, nil, wasmbindingstypes.ErrCannotHandleMsg diff --git a/x/clock/client/wasm/msg_update_params.go b/x/clock/client/wasm/msg_update_params.go deleted file mode 100644 index 6d56bd0da..000000000 --- a/x/clock/client/wasm/msg_update_params.go +++ /dev/null @@ -1,44 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - keeper "github.com/elys-network/elys/x/clock/keeper" - types "github.com/elys-network/elys/x/clock/types" -) - -func (m *Messenger) msgUpdateParams(ctx sdk.Context, contractAddr sdk.AccAddress, msg *types.MsgUpdateParams) ([]sdk.Event, [][]byte, error) { - if msg == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "UpdateParams null msg"} - } - - if msg.Authority != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "update params wrong sender"} - } - - msgServer := keeper.NewMsgServerImpl(*m.keeper) - - if err := msg.ValidateBasic(); err != nil { - return nil, nil, errorsmod.Wrap(err, "failed validating msg") - } - - res, err := msgServer.UpdateParams( - sdk.WrapSDKContext(ctx), - msg, - ) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "UpdateParams msg") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize UpdateParams response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} diff --git a/x/commitment/client/wasm/messenger.go b/x/commitment/client/wasm/messenger.go index fb8ee1f03..230114eb9 100644 --- a/x/commitment/client/wasm/messenger.go +++ b/x/commitment/client/wasm/messenger.go @@ -6,23 +6,26 @@ import ( wasmbindingstypes "github.com/elys-network/elys/wasmbindings/types" apKeeper "github.com/elys-network/elys/x/assetprofile/keeper" "github.com/elys-network/elys/x/commitment/keeper" + parameterkeeper "github.com/elys-network/elys/x/parameter/keeper" stableKeeper "github.com/elys-network/elys/x/stablestake/keeper" ) // Messenger handles messages for the Commitment module. type Messenger struct { - keeper *keeper.Keeper - stakingKeeper *stakingkeeper.Keeper - apKeeper *apKeeper.Keeper - stableKeeper *stableKeeper.Keeper + keeper *keeper.Keeper + stakingKeeper *stakingkeeper.Keeper + apKeeper *apKeeper.Keeper + stableKeeper *stableKeeper.Keeper + parameterKeeper *parameterkeeper.Keeper } -func NewMessenger(keeper *keeper.Keeper, stakingKeeper *stakingkeeper.Keeper, apKeeper *apKeeper.Keeper, stableKeeper *stableKeeper.Keeper) *Messenger { +func NewMessenger(keeper *keeper.Keeper, stakingKeeper *stakingkeeper.Keeper, apKeeper *apKeeper.Keeper, stableKeeper *stableKeeper.Keeper, parameterKeeper *parameterkeeper.Keeper) *Messenger { return &Messenger{ - keeper: keeper, - stakingKeeper: stakingKeeper, - apKeeper: apKeeper, - stableKeeper: stableKeeper, + keeper: keeper, + stakingKeeper: stakingKeeper, + apKeeper: apKeeper, + stableKeeper: stableKeeper, + parameterKeeper: parameterKeeper, } } diff --git a/x/commitment/client/wasm/msg_cancel_vest.go b/x/commitment/client/wasm/msg_cancel_vest.go index 2c842a52e..2948a2ea3 100644 --- a/x/commitment/client/wasm/msg_cancel_vest.go +++ b/x/commitment/client/wasm/msg_cancel_vest.go @@ -17,7 +17,8 @@ func (m *Messenger) msgCancelVest(ctx sdk.Context, contractAddr sdk.AccAddress, return nil, nil, wasmvmtypes.InvalidRequest{Err: "cancel vest null msg"} } - if msgCancelVest.Creator != contractAddr.String() { + brokerAddress := m.parameterKeeper.GetParams(ctx).BrokerAddress + if msgCancelVest.Creator != contractAddr.String() && contractAddr.String() != brokerAddress { return nil, nil, wasmvmtypes.InvalidRequest{Err: "cancel vest wrong sender"} } @@ -54,7 +55,7 @@ func performMsgCancelVestEden(f *commitmentkeeper.Keeper, ctx sdk.Context, contr return nil, errorsmod.Wrap(err, "failed validating msgMsgCancelVest") } - _, err := msgServer.CancelVest(ctx, msgMsgCancelVest) // Discard the response because it's empty + _, err := msgServer.CancelVest(sdk.WrapSDKContext(ctx), msgMsgCancelVest) // Discard the response because it's empty if err != nil { return nil, errorsmod.Wrap(err, "eden vesting msg") } diff --git a/x/commitment/client/wasm/msg_commit_liquid_tokens.go b/x/commitment/client/wasm/msg_commit_liquid_tokens.go index 8012af2c9..1c945d007 100644 --- a/x/commitment/client/wasm/msg_commit_liquid_tokens.go +++ b/x/commitment/client/wasm/msg_commit_liquid_tokens.go @@ -15,7 +15,8 @@ func (m *Messenger) msgCommitLiquidTokens(ctx sdk.Context, contractAddr sdk.AccA return nil, nil, wasmvmtypes.InvalidRequest{Err: "CommitLiquidTokens null msg"} } - if msg.Creator != contractAddr.String() { + brokerAddress := m.parameterKeeper.GetParams(ctx).BrokerAddress + if msg.Creator != contractAddr.String() && contractAddr.String() != brokerAddress { return nil, nil, wasmvmtypes.InvalidRequest{Err: "commit liquid tokens wrong sender"} } diff --git a/x/commitment/client/wasm/msg_commit_unclaimed_rewards.go b/x/commitment/client/wasm/msg_commit_unclaimed_rewards.go index df3b24512..d58ee6aa4 100644 --- a/x/commitment/client/wasm/msg_commit_unclaimed_rewards.go +++ b/x/commitment/client/wasm/msg_commit_unclaimed_rewards.go @@ -15,7 +15,8 @@ func (m *Messenger) msgCommitClaimedRewards(ctx sdk.Context, contractAddr sdk.Ac return nil, nil, wasmvmtypes.InvalidRequest{Err: "CommitUnclaimedRewards null msg"} } - if msg.Creator != contractAddr.String() { + brokerAddress := m.parameterKeeper.GetParams(ctx).BrokerAddress + if msg.Creator != contractAddr.String() && contractAddr.String() != brokerAddress { return nil, nil, wasmvmtypes.InvalidRequest{Err: "commit unclaimed rewards wrong sender"} } diff --git a/x/commitment/client/wasm/msg_stake.go b/x/commitment/client/wasm/msg_stake.go index 682f88a04..d27662e95 100644 --- a/x/commitment/client/wasm/msg_stake.go +++ b/x/commitment/client/wasm/msg_stake.go @@ -18,7 +18,8 @@ func (m *Messenger) msgStake(ctx sdk.Context, contractAddr sdk.AccAddress, msgSt return nil, nil, wasmvmtypes.InvalidRequest{Err: "Invalid staking parameter"} } - if msgStake.Creator != contractAddr.String() { + brokerAddress := m.parameterKeeper.GetParams(ctx).BrokerAddress + if msgStake.Creator != contractAddr.String() && contractAddr.String() != brokerAddress { return nil, nil, wasmvmtypes.InvalidRequest{Err: "stake wrong sender"} } @@ -39,7 +40,7 @@ func (m *Messenger) msgStake(ctx sdk.Context, contractAddr sdk.AccAddress, msgSt return nil, nil, errorsmod.Wrap(err, "failed validating msgMsgBond") } - _, err = msgServer.Bond(ctx, msgMsgBond) + _, err = msgServer.Bond(sdk.WrapSDKContext(ctx), msgMsgBond) if err != nil { // Discard the response because it's empty return nil, nil, errorsmod.Wrap(err, "usdc staking msg") } @@ -56,7 +57,7 @@ func (m *Messenger) msgStake(ctx sdk.Context, contractAddr sdk.AccAddress, msgSt return nil, nil, errorsmod.Wrap(err, "failed validating msgMsgStake") } - res, err = msgServer.Stake(ctx, msgMsgStake) + res, err = msgServer.Stake(sdk.WrapSDKContext(ctx), msgMsgStake) if err != nil { // Discard the response because it's empty return nil, nil, errorsmod.Wrap(err, "elys staking msg") } diff --git a/x/commitment/client/wasm/msg_uncommit_tokens.go b/x/commitment/client/wasm/msg_uncommit_tokens.go index 650bf70e1..77530e5af 100644 --- a/x/commitment/client/wasm/msg_uncommit_tokens.go +++ b/x/commitment/client/wasm/msg_uncommit_tokens.go @@ -15,7 +15,8 @@ func (m *Messenger) msgUncommitTokens(ctx sdk.Context, contractAddr sdk.AccAddre return nil, nil, wasmvmtypes.InvalidRequest{Err: "UncommitTokens null msg"} } - if msg.Creator != contractAddr.String() { + brokerAddress := m.parameterKeeper.GetParams(ctx).BrokerAddress + if msg.Creator != contractAddr.String() && contractAddr.String() != brokerAddress { return nil, nil, wasmvmtypes.InvalidRequest{Err: "uncommit tokens wrong sender"} } diff --git a/x/commitment/client/wasm/msg_unstake.go b/x/commitment/client/wasm/msg_unstake.go index 8f35b0753..1c64af3a5 100644 --- a/x/commitment/client/wasm/msg_unstake.go +++ b/x/commitment/client/wasm/msg_unstake.go @@ -18,7 +18,8 @@ func (m *Messenger) msgUnstake(ctx sdk.Context, contractAddr sdk.AccAddress, msg return nil, nil, wasmvmtypes.InvalidRequest{Err: "Invalid unstaking parameter"} } - if msgUnstake.Creator != contractAddr.String() { + brokerAddress := m.parameterKeeper.GetParams(ctx).BrokerAddress + if msgUnstake.Creator != contractAddr.String() && contractAddr.String() != brokerAddress { return nil, nil, wasmvmtypes.InvalidRequest{Err: "unstake wrong sender"} } @@ -39,7 +40,7 @@ func (m *Messenger) msgUnstake(ctx sdk.Context, contractAddr sdk.AccAddress, msg return nil, nil, errorsmod.Wrap(err, "failed validating msgMsgBond") } - _, err = msgServer.Unbond(ctx, msgMsgUnBond) + _, err = msgServer.Unbond(sdk.WrapSDKContext(ctx), msgMsgUnBond) if err != nil { // Discard the response because it's empty return nil, nil, errorsmod.Wrap(err, "usdc unstaking msg") } @@ -55,7 +56,7 @@ func (m *Messenger) msgUnstake(ctx sdk.Context, contractAddr sdk.AccAddress, msg return nil, nil, errorsmod.Wrap(err, "failed validating msgMsgUnstake") } - res, err = msgServer.Unstake(ctx, msgMsgUnstake) + res, err = msgServer.Unstake(sdk.WrapSDKContext(ctx), msgMsgUnstake) if err != nil { // Discard the response because it's empty return nil, nil, errorsmod.Wrap(err, "elys unstaking msg") } diff --git a/x/commitment/client/wasm/msg_update_vesting_info.go b/x/commitment/client/wasm/msg_update_vesting_info.go index bf2e38719..76425951d 100644 --- a/x/commitment/client/wasm/msg_update_vesting_info.go +++ b/x/commitment/client/wasm/msg_update_vesting_info.go @@ -15,7 +15,8 @@ func (m *Messenger) msgUpdateVestingInfo(ctx sdk.Context, contractAddr sdk.AccAd return nil, nil, wasmvmtypes.InvalidRequest{Err: "UpdateVestingInfo null msg"} } - if msg.Authority != contractAddr.String() { + brokerAddress := m.parameterKeeper.GetParams(ctx).BrokerAddress + if msg.Authority != contractAddr.String() && contractAddr.String() != brokerAddress { return nil, nil, wasmvmtypes.InvalidRequest{Err: "update vesting info wrong sender"} } diff --git a/x/commitment/client/wasm/msg_vest.go b/x/commitment/client/wasm/msg_vest.go index d50e0b179..51908c36c 100644 --- a/x/commitment/client/wasm/msg_vest.go +++ b/x/commitment/client/wasm/msg_vest.go @@ -17,7 +17,8 @@ func (m *Messenger) msgVest(ctx sdk.Context, contractAddr sdk.AccAddress, msgVes return nil, nil, wasmvmtypes.InvalidRequest{Err: "Vest null msg"} } - if msgVest.Creator != contractAddr.String() { + brokerAddress := m.parameterKeeper.GetParams(ctx).BrokerAddress + if msgVest.Creator != contractAddr.String() && contractAddr.String() != brokerAddress { return nil, nil, wasmvmtypes.InvalidRequest{Err: "vest wrong sender"} } @@ -54,7 +55,7 @@ func performMsgVestEden(f *commitmentkeeper.Keeper, ctx sdk.Context, contractAdd return nil, errorsmod.Wrap(err, "failed validating msgVest") } - _, err := msgServer.Vest(ctx, msgMsgVest) // Discard the response because it's empty + _, err := msgServer.Vest(sdk.WrapSDKContext(ctx), msgMsgVest) // Discard the response because it's empty if err != nil { return nil, errorsmod.Wrap(err, "eden vesting msg") } diff --git a/x/commitment/client/wasm/msg_vest_now.go b/x/commitment/client/wasm/msg_vest_now.go index 4d89f2321..981d65119 100644 --- a/x/commitment/client/wasm/msg_vest_now.go +++ b/x/commitment/client/wasm/msg_vest_now.go @@ -15,7 +15,8 @@ func (m *Messenger) msgVestNow(ctx sdk.Context, contractAddr sdk.AccAddress, msg return nil, nil, wasmvmtypes.InvalidRequest{Err: "VestNow null msg"} } - if msg.Creator != contractAddr.String() { + brokerAddress := m.parameterKeeper.GetParams(ctx).BrokerAddress + if msg.Creator != contractAddr.String() && contractAddr.String() != brokerAddress { return nil, nil, wasmvmtypes.InvalidRequest{Err: "vest now wrong sender"} } diff --git a/x/commitment/client/wasm/query_params.go b/x/commitment/client/wasm/query_params.go index 7956f2608..eaf890880 100644 --- a/x/commitment/client/wasm/query_params.go +++ b/x/commitment/client/wasm/query_params.go @@ -9,7 +9,7 @@ import ( ) func (oq *Querier) queryParams(ctx sdk.Context, req *types.QueryParamsRequest) ([]byte, error) { - res, err := oq.keeper.Params(ctx, req) + res, err := oq.keeper.Params(sdk.WrapSDKContext(ctx), req) if err != nil { return nil, errorsmod.Wrap(err, "failed to get params") } diff --git a/x/incentive/client/wasm/messenger.go b/x/incentive/client/wasm/messenger.go index cb191fe49..e178ba820 100644 --- a/x/incentive/client/wasm/messenger.go +++ b/x/incentive/client/wasm/messenger.go @@ -6,6 +6,7 @@ import ( wasmbindingstypes "github.com/elys-network/elys/wasmbindings/types" commitmentkeeper "github.com/elys-network/elys/x/commitment/keeper" "github.com/elys-network/elys/x/incentive/keeper" + parameterkeeper "github.com/elys-network/elys/x/parameter/keeper" ) // Messenger handles messages for the Incentive module. @@ -13,9 +14,15 @@ type Messenger struct { keeper *keeper.Keeper stakingKeeper *stakingkeeper.Keeper commitmentKeeper *commitmentkeeper.Keeper + parameterKeeper *parameterkeeper.Keeper } -func NewMessenger(keeper *keeper.Keeper, stakingKeeper *stakingkeeper.Keeper, commitmentKeeper *commitmentkeeper.Keeper) *Messenger { +func NewMessenger( + keeper *keeper.Keeper, + stakingKeeper *stakingkeeper.Keeper, + commitmentKeeper *commitmentkeeper.Keeper, + parameterKeeper *parameterkeeper.Keeper, +) *Messenger { return &Messenger{ keeper: keeper, stakingKeeper: stakingKeeper, diff --git a/x/incentive/client/wasm/msg_begin_redelegate.go b/x/incentive/client/wasm/msg_begin_redelegate.go index 7d5334483..a599cd6fb 100644 --- a/x/incentive/client/wasm/msg_begin_redelegate.go +++ b/x/incentive/client/wasm/msg_begin_redelegate.go @@ -15,6 +15,12 @@ import ( func (m *Messenger) msgBeginRedelegate(ctx sdk.Context, contractAddr sdk.AccAddress, msgRedelegate *stakingtypes.MsgBeginRedelegate) ([]sdk.Event, [][]byte, error) { var res *wasmbindingstypes.RequestResponse var err error + + brokerAddress := m.parameterKeeper.GetParams(ctx).BrokerAddress + if msgRedelegate.DelegatorAddress != contractAddr.String() && contractAddr.String() != brokerAddress { + return nil, nil, wasmvmtypes.InvalidRequest{Err: "wrong sender"} + } + if msgRedelegate.Amount.Denom != paramtypes.Elys { return nil, nil, errorsmod.Wrap(err, "invalid asset!") } @@ -61,7 +67,7 @@ func performMsgRedelegateElys(f *stakingkeeper.Keeper, ctx sdk.Context, contract return nil, errorsmod.Wrap(err, "failed validating msgMsgDelegate") } - _, err = msgServer.BeginRedelegate(ctx, msgMsgRedelegate) // Discard the response because it's empty + _, err = msgServer.BeginRedelegate(sdk.WrapSDKContext(ctx), msgMsgRedelegate) // Discard the response because it's empty if err != nil { return nil, errorsmod.Wrap(err, "elys redelegation msg") } diff --git a/x/incentive/client/wasm/msg_cancel_unbonding_delegation.go b/x/incentive/client/wasm/msg_cancel_unbonding_delegation.go index 97224c389..dd3215a95 100644 --- a/x/incentive/client/wasm/msg_cancel_unbonding_delegation.go +++ b/x/incentive/client/wasm/msg_cancel_unbonding_delegation.go @@ -15,6 +15,12 @@ import ( func (m *Messenger) msgCancelUnbondingDelegation(ctx sdk.Context, contractAddr sdk.AccAddress, msgCancelUnbonding *stakingtypes.MsgCancelUnbondingDelegation) ([]sdk.Event, [][]byte, error) { var res *wasmbindingstypes.RequestResponse var err error + + brokerAddress := m.parameterKeeper.GetParams(ctx).BrokerAddress + if msgCancelUnbonding.DelegatorAddress != contractAddr.String() && contractAddr.String() != brokerAddress { + return nil, nil, wasmvmtypes.InvalidRequest{Err: "wrong sender"} + } + if msgCancelUnbonding.Amount.Denom != paramtypes.Elys { return nil, nil, errorsmod.Wrap(err, "invalid asset!") } @@ -56,7 +62,7 @@ func performMsgCancelUnbondingElys(f *stakingkeeper.Keeper, ctx sdk.Context, con return nil, errorsmod.Wrap(err, "failed validating msgCancelUnbonding") } - _, err = msgServer.CancelUnbondingDelegation(ctx, msgMsgCancelUnbonding) + _, err = msgServer.CancelUnbondingDelegation(sdk.WrapSDKContext(ctx), msgMsgCancelUnbonding) if err != nil { return nil, errorsmod.Wrap(err, "elys cancel bonding msg") } diff --git a/x/incentive/client/wasm/msg_withdraw_rewards.go b/x/incentive/client/wasm/msg_withdraw_rewards.go index efd2883f5..8ad483fa8 100644 --- a/x/incentive/client/wasm/msg_withdraw_rewards.go +++ b/x/incentive/client/wasm/msg_withdraw_rewards.go @@ -16,6 +16,11 @@ func (m *Messenger) msgWithdrawRewards(ctx sdk.Context, contractAddr sdk.AccAddr var res *wasmbindingstypes.RequestResponse var err error + brokerAddress := m.parameterKeeper.GetParams(ctx).BrokerAddress + if msgWithdrawRewards.DelegatorAddress != contractAddr.String() && contractAddr.String() != brokerAddress { + return nil, nil, wasmvmtypes.InvalidRequest{Err: "wrong sender"} + } + res, err = performMsgWithdrawRewards(m.keeper, ctx, contractAddr, msgWithdrawRewards) if err != nil { return nil, nil, errorsmod.Wrap(err, "perform withdraw rewards") @@ -48,7 +53,7 @@ func performMsgWithdrawRewards(f *incentivekeeper.Keeper, ctx sdk.Context, contr return nil, errorsmod.Wrap(err, "failed validating msgMsgWithdrawRewards") } - _, err = msgServer.WithdrawRewards(ctx, msgMsgWithdrawRewards) // Discard the response because it's empty + _, err = msgServer.WithdrawRewards(sdk.WrapSDKContext(ctx), msgMsgWithdrawRewards) // Discard the response because it's empty if err != nil { return nil, errorsmod.Wrap(err, "withdraw rewards msg") } diff --git a/x/incentive/client/wasm/msg_withdraw_validator_commission.go b/x/incentive/client/wasm/msg_withdraw_validator_commission.go index ac0aafba4..739872f1b 100644 --- a/x/incentive/client/wasm/msg_withdraw_validator_commission.go +++ b/x/incentive/client/wasm/msg_withdraw_validator_commission.go @@ -16,6 +16,11 @@ func (m *Messenger) msgWithdrawValidatorCommission(ctx sdk.Context, contractAddr var res *wasmbindingstypes.RequestResponse var err error + brokerAddress := m.parameterKeeper.GetParams(ctx).BrokerAddress + if msgWithdrawValidatorCommission.DelegatorAddress != contractAddr.String() && contractAddr.String() != brokerAddress { + return nil, nil, wasmvmtypes.InvalidRequest{Err: "wrong sender"} + } + res, err = performMsgWithdrawValidatorCommissions(m.keeper, ctx, contractAddr, msgWithdrawValidatorCommission) if err != nil { return nil, nil, errorsmod.Wrap(err, "perform withdraw validator commission") @@ -53,7 +58,7 @@ func performMsgWithdrawValidatorCommissions(f *incentivekeeper.Keeper, ctx sdk.C return nil, errorsmod.Wrap(err, "failed validating msgWithdrawValidatorCommission") } - _, err = msgServer.WithdrawValidatorCommission(ctx, msgMsgWithdrawValidatorCommissions) // Discard the response because it's empty + _, err = msgServer.WithdrawValidatorCommission(sdk.WrapSDKContext(ctx), msgMsgWithdrawValidatorCommissions) // Discard the response because it's empty if err != nil { return nil, errorsmod.Wrap(err, "withdraw validator commission msg") } diff --git a/x/leveragelp/client/wasm/messenger.go b/x/leveragelp/client/wasm/messenger.go index 0b518a818..159556003 100644 --- a/x/leveragelp/client/wasm/messenger.go +++ b/x/leveragelp/client/wasm/messenger.go @@ -4,15 +4,23 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" wasmbindingstypes "github.com/elys-network/elys/wasmbindings/types" "github.com/elys-network/elys/x/leveragelp/keeper" + parameterkeeper "github.com/elys-network/elys/x/parameter/keeper" ) // Messenger handles messages for the Leverage LP module. type Messenger struct { - keeper *keeper.Keeper + keeper *keeper.Keeper + parameterKeeper *parameterkeeper.Keeper } -func NewMessenger(keeper *keeper.Keeper) *Messenger { - return &Messenger{keeper: keeper} +func NewMessenger( + keeper *keeper.Keeper, + parameterKeeper *parameterkeeper.Keeper, +) *Messenger { + return &Messenger{ + keeper: keeper, + parameterKeeper: parameterKeeper, + } } func (m *Messenger) HandleMsg(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmbindingstypes.ElysMsg) ([]sdk.Event, [][]byte, error) { @@ -21,14 +29,6 @@ func (m *Messenger) HandleMsg(ctx sdk.Context, contractAddr sdk.AccAddress, cont return m.msgOpen(ctx, contractAddr, msg.LeveragelpOpen) case msg.LeveragelpClose != nil: return m.msgClose(ctx, contractAddr, msg.LeveragelpClose) - case msg.LeveragelpUpdateParams != nil: - return m.msgUpdateParams(ctx, contractAddr, msg.LeveragelpUpdateParams) - case msg.LeveragelpUpdatePools != nil: - return m.msgUpdatePools(ctx, contractAddr, msg.LeveragelpUpdatePools) - case msg.LeveragelpWhitelist != nil: - return m.msgWhitelist(ctx, contractAddr, msg.LeveragelpWhitelist) - case msg.LeveragelpDewhitelist != nil: - return m.msgDewhitelist(ctx, contractAddr, msg.LeveragelpDewhitelist) default: // This handler cannot handle the message return nil, nil, wasmbindingstypes.ErrCannotHandleMsg diff --git a/x/leveragelp/client/wasm/msg_close.go b/x/leveragelp/client/wasm/msg_close.go index ac9d7d01f..240b2026c 100644 --- a/x/leveragelp/client/wasm/msg_close.go +++ b/x/leveragelp/client/wasm/msg_close.go @@ -15,7 +15,8 @@ func (m *Messenger) msgClose(ctx sdk.Context, contractAddr sdk.AccAddress, msgCl return nil, nil, wasmvmtypes.InvalidRequest{Err: "Close null msg"} } - if msgClose.Creator != contractAddr.String() { + brokerAddress := m.parameterKeeper.GetParams(ctx).BrokerAddress + if msgClose.Creator != contractAddr.String() && contractAddr.String() != brokerAddress { return nil, nil, wasmvmtypes.InvalidRequest{Err: "close wrong sender"} } @@ -46,7 +47,7 @@ func PerformMsgClose(f *leveragelpkeeper.Keeper, ctx sdk.Context, contractAddr s return nil, errorsmod.Wrap(err, "failed validating msgMsgClose") } - _, err := msgServer.Close(ctx, msgMsgClose) // Discard the response because it's empty + _, err := msgServer.Close(sdk.WrapSDKContext(ctx), msgMsgClose) // Discard the response because it's empty if err != nil { return nil, errorsmod.Wrap(err, "leveragelp close msg") diff --git a/x/leveragelp/client/wasm/msg_dewhitelist.go b/x/leveragelp/client/wasm/msg_dewhitelist.go deleted file mode 100644 index 0b5f56dde..000000000 --- a/x/leveragelp/client/wasm/msg_dewhitelist.go +++ /dev/null @@ -1,44 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - keeper "github.com/elys-network/elys/x/leveragelp/keeper" - types "github.com/elys-network/elys/x/leveragelp/types" -) - -func (m *Messenger) msgDewhitelist(ctx sdk.Context, contractAddr sdk.AccAddress, msg *types.MsgDewhitelist) ([]sdk.Event, [][]byte, error) { - if msg == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "Dewhitelist null msg"} - } - - if msg.Authority != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "dewhitelist wrong sender"} - } - - msgServer := keeper.NewMsgServerImpl(*m.keeper) - - if err := msg.ValidateBasic(); err != nil { - return nil, nil, errorsmod.Wrap(err, "failed validating msg") - } - - res, err := msgServer.Dewhitelist( - sdk.WrapSDKContext(ctx), - msg, - ) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "Dewhitelist msg") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize Dewhitelist response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} diff --git a/x/leveragelp/client/wasm/msg_open.go b/x/leveragelp/client/wasm/msg_open.go index df9271f3f..1141079f3 100644 --- a/x/leveragelp/client/wasm/msg_open.go +++ b/x/leveragelp/client/wasm/msg_open.go @@ -16,7 +16,8 @@ func (m *Messenger) msgOpen(ctx sdk.Context, contractAddr sdk.AccAddress, msgOpe return nil, nil, wasmvmtypes.InvalidRequest{Err: "Open null msg"} } - if msgOpen.Creator != contractAddr.String() { + brokerAddress := m.parameterKeeper.GetParams(ctx).BrokerAddress + if msgOpen.Creator != contractAddr.String() && contractAddr.String() != brokerAddress { return nil, nil, wasmvmtypes.InvalidRequest{Err: "open wrong sender"} } @@ -47,7 +48,7 @@ func PerformMsgOpen(f *leveragelpkeeper.Keeper, ctx sdk.Context, contractAddr sd return nil, errorsmod.Wrap(err, "failed validating msgMsgOpen") } - _, err := msgServer.Open(ctx, msgMsgOpen) // Discard the response because it's empty + _, err := msgServer.Open(sdk.WrapSDKContext(ctx), msgMsgOpen) // Discard the response because it's empty if err != nil { return nil, errorsmod.Wrap(err, "leveragelp open msg") diff --git a/x/leveragelp/client/wasm/msg_update_params.go b/x/leveragelp/client/wasm/msg_update_params.go deleted file mode 100644 index 61df01492..000000000 --- a/x/leveragelp/client/wasm/msg_update_params.go +++ /dev/null @@ -1,44 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - keeper "github.com/elys-network/elys/x/leveragelp/keeper" - types "github.com/elys-network/elys/x/leveragelp/types" -) - -func (m *Messenger) msgUpdateParams(ctx sdk.Context, contractAddr sdk.AccAddress, msg *types.MsgUpdateParams) ([]sdk.Event, [][]byte, error) { - if msg == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "UpdateParams null msg"} - } - - if msg.Authority != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "update params wrong sender"} - } - - msgServer := keeper.NewMsgServerImpl(*m.keeper) - - if err := msg.ValidateBasic(); err != nil { - return nil, nil, errorsmod.Wrap(err, "failed validating msg") - } - - res, err := msgServer.UpdateParams( - sdk.WrapSDKContext(ctx), - msg, - ) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "UpdateParams msg") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize UpdateParams response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} diff --git a/x/leveragelp/client/wasm/msg_update_pools.go b/x/leveragelp/client/wasm/msg_update_pools.go deleted file mode 100644 index 55fb9862a..000000000 --- a/x/leveragelp/client/wasm/msg_update_pools.go +++ /dev/null @@ -1,44 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - keeper "github.com/elys-network/elys/x/leveragelp/keeper" - types "github.com/elys-network/elys/x/leveragelp/types" -) - -func (m *Messenger) msgUpdatePools(ctx sdk.Context, contractAddr sdk.AccAddress, msg *types.MsgUpdatePools) ([]sdk.Event, [][]byte, error) { - if msg == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "UpdatePools null msg"} - } - - if msg.Authority != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "update pools wrong sender"} - } - - msgServer := keeper.NewMsgServerImpl(*m.keeper) - - if err := msg.ValidateBasic(); err != nil { - return nil, nil, errorsmod.Wrap(err, "failed validating msg") - } - - res, err := msgServer.UpdatePools( - sdk.WrapSDKContext(ctx), - msg, - ) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "UpdatePools msg") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize UpdatePools response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} diff --git a/x/leveragelp/client/wasm/msg_whitelist.go b/x/leveragelp/client/wasm/msg_whitelist.go deleted file mode 100644 index 284ad7134..000000000 --- a/x/leveragelp/client/wasm/msg_whitelist.go +++ /dev/null @@ -1,44 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - keeper "github.com/elys-network/elys/x/leveragelp/keeper" - types "github.com/elys-network/elys/x/leveragelp/types" -) - -func (m *Messenger) msgWhitelist(ctx sdk.Context, contractAddr sdk.AccAddress, msg *types.MsgWhitelist) ([]sdk.Event, [][]byte, error) { - if msg == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "Whitelist null msg"} - } - - if msg.Authority != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "whitelist wrong sender"} - } - - msgServer := keeper.NewMsgServerImpl(*m.keeper) - - if err := msg.ValidateBasic(); err != nil { - return nil, nil, errorsmod.Wrap(err, "failed validating msg") - } - - res, err := msgServer.Whitelist( - sdk.WrapSDKContext(ctx), - msg, - ) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "Whitelist msg") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize Whitelist response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} diff --git a/x/margin/client/cli/tx.go b/x/margin/client/cli/tx.go index 15783303e..1acbea0d7 100644 --- a/x/margin/client/cli/tx.go +++ b/x/margin/client/cli/tx.go @@ -34,8 +34,6 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand(CmdOpen()) cmd.AddCommand(CmdClose()) - cmd.AddCommand(CmdBrokerOpen()) - cmd.AddCommand(CmdBrokerClose()) cmd.AddCommand(CmdUpdateParams()) cmd.AddCommand(CmdUpdatePools()) cmd.AddCommand(CmdWhitelist()) diff --git a/x/margin/client/cli/tx_broker_close.go b/x/margin/client/cli/tx_broker_close.go deleted file mode 100644 index 5565b1ae6..000000000 --- a/x/margin/client/cli/tx_broker_close.go +++ /dev/null @@ -1,64 +0,0 @@ -package cli - -import ( - "errors" - "strconv" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/tx" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/margin/types" - "github.com/spf13/cobra" -) - -var _ = strconv.Itoa(0) - -func CmdBrokerClose() *cobra.Command { - cmd := &cobra.Command{ - Use: "broker-close [mtp-id] [mtp-owner] [flags]", - Short: "Close margin position as a broker", - Example: `elysd tx margin broker-close 1 sif123 10000000 --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000`, - Args: cobra.ExactArgs(3), - RunE: func(cmd *cobra.Command, args []string) (err error) { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - signer := clientCtx.GetFromAddress() - if signer == nil { - return errors.New("signer address is missing") - } - - argMtpId, err := strconv.ParseUint(args[0], 10, 64) - if err != nil { - return errors.New("invalid mtp id") - } - - argMtpOwner := args[1] - if argMtpOwner == "" { - return errors.New("invalid mtp owner address") - } - - argAmount, ok := sdk.NewIntFromString(args[2]) - if !ok { - return errors.New("invalid amount") - } - - msg := types.NewMsgBrokerClose( - signer.String(), - argMtpId, - argMtpOwner, - argAmount, - ) - if err := msg.ValidateBasic(); err != nil { - return err - } - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} diff --git a/x/margin/client/cli/tx_broker_open.go b/x/margin/client/cli/tx_broker_open.go deleted file mode 100644 index 96dccb89e..000000000 --- a/x/margin/client/cli/tx_broker_open.go +++ /dev/null @@ -1,96 +0,0 @@ -package cli - -import ( - "errors" - "strconv" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/tx" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/margin/types" - "github.com/spf13/cobra" -) - -var _ = strconv.Itoa(0) - -func CmdBrokerOpen() *cobra.Command { - cmd := &cobra.Command{ - Use: "broker-open [position] [leverage] [trading-asset] [collateral] [owner] [flags]", - Short: "Open margin position as a broker", - Example: `Infinte profitability: -elysd tx margin broker-open long 5 uatom 100000000uusdc sif123 --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 -Finite profitability: -elysd tx margin broker-open short 5 uatom 100000000uusdc sif123 --take-profit 100 --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000`, - Args: cobra.ExactArgs(5), - RunE: func(cmd *cobra.Command, args []string) (err error) { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - signer := clientCtx.GetFromAddress() - if signer == nil { - return errors.New("signer address is missing") - } - - argPosition := types.GetPositionFromString(args[0]) - - argLeverage, err := sdk.NewDecFromStr(args[1]) - if err != nil { - return err - } - - argTradingAsset := args[2] - - argCollateral, err := sdk.ParseCoinNormalized(args[3]) - if err != nil { - return err - } - - argMtpOwner := args[5] - if argMtpOwner == "" { - return errors.New("invalid mtp owner address") - } - - takeProfitPriceStr, err := cmd.Flags().GetString(flagTakeProfitPrice) - if err != nil { - return err - } - - var takeProfitPrice sdk.Dec - if takeProfitPriceStr != types.InfinitePriceString { - takeProfitPrice, err = sdk.NewDecFromStr(takeProfitPriceStr) - if err != nil { - return errors.New("invalid take profit price") - } - } else { - takeProfitPrice, err = sdk.NewDecFromStr(types.TakeProfitPriceDefault) - if err != nil { - return errors.New("failed to set default take profit price") - } - } - - msg := types.NewMsgBrokerOpen( - signer.String(), - argPosition, - argLeverage, - argTradingAsset, - argCollateral, - takeProfitPrice, - argMtpOwner, - ) - - if err := msg.ValidateBasic(); err != nil { - return err - } - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - cmd.Flags().String(flagTakeProfitPrice, types.InfinitePriceString, "Optional take profit price") - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} diff --git a/x/margin/client/wasm/messenger.go b/x/margin/client/wasm/messenger.go index 86d63ae09..f00431564 100644 --- a/x/margin/client/wasm/messenger.go +++ b/x/margin/client/wasm/messenger.go @@ -4,15 +4,23 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" wasmbindingstypes "github.com/elys-network/elys/wasmbindings/types" "github.com/elys-network/elys/x/margin/keeper" + parameterkeeper "github.com/elys-network/elys/x/parameter/keeper" ) // Messenger handles messages for the Margin module. type Messenger struct { - keeper *keeper.Keeper + keeper *keeper.Keeper + parameterKeeper *parameterkeeper.Keeper } -func NewMessenger(keeper *keeper.Keeper) *Messenger { - return &Messenger{keeper: keeper} +func NewMessenger( + keeper *keeper.Keeper, + parameterKeeper *parameterkeeper.Keeper, +) *Messenger { + return &Messenger{ + keeper: keeper, + parameterKeeper: parameterKeeper, + } } func (m *Messenger) HandleMsg(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmbindingstypes.ElysMsg) ([]sdk.Event, [][]byte, error) { @@ -21,18 +29,6 @@ func (m *Messenger) HandleMsg(ctx sdk.Context, contractAddr sdk.AccAddress, cont return m.msgOpen(ctx, contractAddr, msg.MarginOpen) case msg.MarginClose != nil: return m.msgClose(ctx, contractAddr, msg.MarginClose) - case msg.MarginBrokerOpen != nil: - return m.msgBrokerOpen(ctx, contractAddr, msg.MarginBrokerOpen) - case msg.MarginBrokerClose != nil: - return m.msgBrokerClose(ctx, contractAddr, msg.MarginBrokerClose) - case msg.MarginUpdateParams != nil: - return m.msgUpdateParams(ctx, contractAddr, msg.MarginUpdateParams) - case msg.MarginUpdatePools != nil: - return m.msgUpdatePools(ctx, contractAddr, msg.MarginUpdatePools) - case msg.MarginWhitelist != nil: - return m.msgWhitelist(ctx, contractAddr, msg.MarginWhitelist) - case msg.MarginDewhitelist != nil: - return m.msgDewhitelist(ctx, contractAddr, msg.MarginDewhitelist) default: // This handler cannot handle the message return nil, nil, wasmbindingstypes.ErrCannotHandleMsg diff --git a/x/margin/client/wasm/msg_broker_close.go b/x/margin/client/wasm/msg_broker_close.go deleted file mode 100644 index 3893696c2..000000000 --- a/x/margin/client/wasm/msg_broker_close.go +++ /dev/null @@ -1,57 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - marginkeeper "github.com/elys-network/elys/x/margin/keeper" - margintypes "github.com/elys-network/elys/x/margin/types" -) - -func (m *Messenger) msgBrokerClose(ctx sdk.Context, contractAddr sdk.AccAddress, msgBrokerClose *margintypes.MsgBrokerClose) ([]sdk.Event, [][]byte, error) { - if msgBrokerClose == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "Broker Close null msg"} - } - - if msgBrokerClose.Creator != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "broker close wrong sender"} - } - - res, err := PerformMsgBrokerClose(m.keeper, ctx, contractAddr, msgBrokerClose) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "perform broker close") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize broker close response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} - -func PerformMsgBrokerClose(f *marginkeeper.Keeper, ctx sdk.Context, contractAddr sdk.AccAddress, msgBrokerClose *margintypes.MsgBrokerClose) (*margintypes.MsgBrokerCloseResponse, error) { - if msgBrokerClose == nil { - return nil, wasmvmtypes.InvalidRequest{Err: "margin broker close null margin broker close"} - } - msgServer := marginkeeper.NewMsgServerImpl(*f) - - msgMsgBrokerClose := margintypes.NewMsgBrokerClose(msgBrokerClose.Creator, uint64(msgBrokerClose.Id), msgBrokerClose.Owner, msgBrokerClose.Amount) - - if err := msgMsgBrokerClose.ValidateBasic(); err != nil { - return nil, errorsmod.Wrap(err, "failed validating msgMsgBrokerClose") - } - - _, err := msgServer.BrokerClose(ctx, msgMsgBrokerClose) // Discard the response because it's empty - - if err != nil { - return nil, errorsmod.Wrap(err, "margin broker close msg") - } - - var resp = &margintypes.MsgBrokerCloseResponse{} - return resp, nil -} diff --git a/x/margin/client/wasm/msg_broker_open.go b/x/margin/client/wasm/msg_broker_open.go deleted file mode 100644 index fb0a219a3..000000000 --- a/x/margin/client/wasm/msg_broker_open.go +++ /dev/null @@ -1,65 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - marginkeeper "github.com/elys-network/elys/x/margin/keeper" - margintypes "github.com/elys-network/elys/x/margin/types" -) - -func (m *Messenger) msgBrokerOpen(ctx sdk.Context, contractAddr sdk.AccAddress, msgBrokerOpen *margintypes.MsgBrokerOpen) ([]sdk.Event, [][]byte, error) { - if msgBrokerOpen == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "Broker Open null msg"} - } - - if msgBrokerOpen.Creator != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "broker open wrong sender"} - } - - res, err := PerformMsgBrokerOpen(m.keeper, ctx, contractAddr, msgBrokerOpen) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "perform broker open") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize broker open response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} - -func PerformMsgBrokerOpen(f *marginkeeper.Keeper, ctx sdk.Context, contractAddr sdk.AccAddress, msgBrokerOpen *margintypes.MsgBrokerOpen) (*margintypes.MsgBrokerOpenResponse, error) { - if msgBrokerOpen == nil { - return nil, wasmvmtypes.InvalidRequest{Err: "margin broker open null margin broker open"} - } - msgServer := marginkeeper.NewMsgServerImpl(*f) - - msgMsgBrokerOpen := margintypes.NewMsgBrokerOpen( - msgBrokerOpen.Creator, - msgBrokerOpen.Position, - msgBrokerOpen.Leverage, - msgBrokerOpen.TradingAsset, - msgBrokerOpen.Collateral, - msgBrokerOpen.TakeProfitPrice, - msgBrokerOpen.Owner, - ) - - if err := msgMsgBrokerOpen.ValidateBasic(); err != nil { - return nil, errorsmod.Wrap(err, "failed validating msgMsgBrokerOpen") - } - - _, err := msgServer.BrokerOpen(ctx, msgMsgBrokerOpen) // Discard the response because it's empty - - if err != nil { - return nil, errorsmod.Wrap(err, "margin broker open msg") - } - - var resp = &margintypes.MsgBrokerOpenResponse{} - return resp, nil -} diff --git a/x/margin/client/wasm/msg_close.go b/x/margin/client/wasm/msg_close.go index 163117713..114bb7f3a 100644 --- a/x/margin/client/wasm/msg_close.go +++ b/x/margin/client/wasm/msg_close.go @@ -15,7 +15,8 @@ func (m *Messenger) msgClose(ctx sdk.Context, contractAddr sdk.AccAddress, msgCl return nil, nil, wasmvmtypes.InvalidRequest{Err: "Close null msg"} } - if msgClose.Creator != contractAddr.String() { + brokerAddress := m.parameterKeeper.GetParams(ctx).BrokerAddress + if msgClose.Creator != contractAddr.String() && contractAddr.String() != brokerAddress { return nil, nil, wasmvmtypes.InvalidRequest{Err: "close wrong sender"} } @@ -46,7 +47,7 @@ func PerformMsgClose(f *marginkeeper.Keeper, ctx sdk.Context, contractAddr sdk.A return nil, errorsmod.Wrap(err, "failed validating msgMsgClose") } - _, err := msgServer.Close(ctx, msgMsgClose) // Discard the response because it's empty + _, err := msgServer.Close(sdk.WrapSDKContext(ctx), msgMsgClose) // Discard the response because it's empty if err != nil { return nil, errorsmod.Wrap(err, "margin close msg") diff --git a/x/margin/client/wasm/msg_dewhitelist.go b/x/margin/client/wasm/msg_dewhitelist.go deleted file mode 100644 index a800ea2e2..000000000 --- a/x/margin/client/wasm/msg_dewhitelist.go +++ /dev/null @@ -1,44 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - keeper "github.com/elys-network/elys/x/margin/keeper" - types "github.com/elys-network/elys/x/margin/types" -) - -func (m *Messenger) msgDewhitelist(ctx sdk.Context, contractAddr sdk.AccAddress, msg *types.MsgDewhitelist) ([]sdk.Event, [][]byte, error) { - if msg == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "Dewhitelist null msg"} - } - - if msg.Authority != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "dewhitelist wrong sender"} - } - - msgServer := keeper.NewMsgServerImpl(*m.keeper) - - if err := msg.ValidateBasic(); err != nil { - return nil, nil, errorsmod.Wrap(err, "failed validating msg") - } - - res, err := msgServer.Dewhitelist( - sdk.WrapSDKContext(ctx), - msg, - ) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "Dewhitelist msg") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize Dewhitelist response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} diff --git a/x/margin/client/wasm/msg_open.go b/x/margin/client/wasm/msg_open.go index 28fd07154..2cc622250 100644 --- a/x/margin/client/wasm/msg_open.go +++ b/x/margin/client/wasm/msg_open.go @@ -15,7 +15,8 @@ func (m *Messenger) msgOpen(ctx sdk.Context, contractAddr sdk.AccAddress, msgOpe return nil, nil, wasmvmtypes.InvalidRequest{Err: "Open null msg"} } - if msgOpen.Creator != contractAddr.String() { + brokerAddress := m.parameterKeeper.GetParams(ctx).BrokerAddress + if msgOpen.Creator != contractAddr.String() && contractAddr.String() != brokerAddress { return nil, nil, wasmvmtypes.InvalidRequest{Err: "open wrong sender"} } @@ -53,7 +54,7 @@ func PerformMsgOpen(f *marginkeeper.Keeper, ctx sdk.Context, contractAddr sdk.Ac return nil, errorsmod.Wrap(err, "failed validating msgMsgOpen") } - _, err := msgServer.Open(ctx, msgMsgOpen) // Discard the response because it's empty + _, err := msgServer.Open(sdk.WrapSDKContext(ctx), msgMsgOpen) // Discard the response because it's empty if err != nil { return nil, errorsmod.Wrap(err, "margin open msg") diff --git a/x/margin/client/wasm/msg_update_params.go b/x/margin/client/wasm/msg_update_params.go deleted file mode 100644 index baa85d6ef..000000000 --- a/x/margin/client/wasm/msg_update_params.go +++ /dev/null @@ -1,44 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - keeper "github.com/elys-network/elys/x/margin/keeper" - types "github.com/elys-network/elys/x/margin/types" -) - -func (m *Messenger) msgUpdateParams(ctx sdk.Context, contractAddr sdk.AccAddress, msg *types.MsgUpdateParams) ([]sdk.Event, [][]byte, error) { - if msg == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "UpdateParams null msg"} - } - - if msg.Authority != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "update params wrong sender"} - } - - msgServer := keeper.NewMsgServerImpl(*m.keeper) - - if err := msg.ValidateBasic(); err != nil { - return nil, nil, errorsmod.Wrap(err, "failed validating msg") - } - - res, err := msgServer.UpdateParams( - sdk.WrapSDKContext(ctx), - msg, - ) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "UpdateParams msg") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize UpdateParams response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} diff --git a/x/margin/client/wasm/msg_update_pools.go b/x/margin/client/wasm/msg_update_pools.go deleted file mode 100644 index 8044054ee..000000000 --- a/x/margin/client/wasm/msg_update_pools.go +++ /dev/null @@ -1,44 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - keeper "github.com/elys-network/elys/x/margin/keeper" - types "github.com/elys-network/elys/x/margin/types" -) - -func (m *Messenger) msgUpdatePools(ctx sdk.Context, contractAddr sdk.AccAddress, msg *types.MsgUpdatePools) ([]sdk.Event, [][]byte, error) { - if msg == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "UpdatePools null msg"} - } - - if msg.Authority != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "update pools wrong sender"} - } - - msgServer := keeper.NewMsgServerImpl(*m.keeper) - - if err := msg.ValidateBasic(); err != nil { - return nil, nil, errorsmod.Wrap(err, "failed validating msg") - } - - res, err := msgServer.UpdatePools( - sdk.WrapSDKContext(ctx), - msg, - ) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "UpdatePools msg") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize UpdatePools response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} diff --git a/x/margin/client/wasm/msg_whitelist.go b/x/margin/client/wasm/msg_whitelist.go deleted file mode 100644 index 40b791af9..000000000 --- a/x/margin/client/wasm/msg_whitelist.go +++ /dev/null @@ -1,44 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - keeper "github.com/elys-network/elys/x/margin/keeper" - types "github.com/elys-network/elys/x/margin/types" -) - -func (m *Messenger) msgWhitelist(ctx sdk.Context, contractAddr sdk.AccAddress, msg *types.MsgWhitelist) ([]sdk.Event, [][]byte, error) { - if msg == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "Whitelist null msg"} - } - - if msg.Authority != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "whitelist wrong sender"} - } - - msgServer := keeper.NewMsgServerImpl(*m.keeper) - - if err := msg.ValidateBasic(); err != nil { - return nil, nil, errorsmod.Wrap(err, "failed validating msg") - } - - res, err := msgServer.Whitelist( - sdk.WrapSDKContext(ctx), - msg, - ) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "Whitelist msg") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize Whitelist response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} diff --git a/x/margin/client/wasm/query_get_status.go b/x/margin/client/wasm/query_get_status.go index 3a0677abf..d15eb4bcc 100644 --- a/x/margin/client/wasm/query_get_status.go +++ b/x/margin/client/wasm/query_get_status.go @@ -9,7 +9,7 @@ import ( ) func (oq *Querier) queryGetStatus(ctx sdk.Context, query *types.StatusRequest) ([]byte, error) { - res, err := oq.keeper.GetStatus(ctx, query) + res, err := oq.keeper.GetStatus(sdk.WrapSDKContext(ctx), query) if err != nil { return nil, errorsmod.Wrap(err, "failed to get status") } diff --git a/x/margin/client/wasm/query_get_whitelist.go b/x/margin/client/wasm/query_get_whitelist.go index 4a489a8a1..1d65c40be 100644 --- a/x/margin/client/wasm/query_get_whitelist.go +++ b/x/margin/client/wasm/query_get_whitelist.go @@ -9,7 +9,7 @@ import ( ) func (oq *Querier) queryGetWhitelist(ctx sdk.Context, query *types.WhitelistRequest) ([]byte, error) { - res, err := oq.keeper.GetWhitelist(ctx, query) + res, err := oq.keeper.GetWhitelist(sdk.WrapSDKContext(ctx), query) if err != nil { return nil, errorsmod.Wrap(err, "failed to get whitelist") } diff --git a/x/margin/client/wasm/query_is_whitelisted.go b/x/margin/client/wasm/query_is_whitelisted.go index 5e1f4a9d3..71374b235 100644 --- a/x/margin/client/wasm/query_is_whitelisted.go +++ b/x/margin/client/wasm/query_is_whitelisted.go @@ -9,7 +9,7 @@ import ( ) func (oq *Querier) queryIsWhitelisted(ctx sdk.Context, query *types.IsWhitelistedRequest) ([]byte, error) { - res, err := oq.keeper.IsWhitelisted(ctx, query) + res, err := oq.keeper.IsWhitelisted(sdk.WrapSDKContext(ctx), query) if err != nil { return nil, errorsmod.Wrap(err, "failed to get is whitelisted") } diff --git a/x/margin/client/wasm/query_mtp.go b/x/margin/client/wasm/query_mtp.go index ae4a48afe..205082be0 100644 --- a/x/margin/client/wasm/query_mtp.go +++ b/x/margin/client/wasm/query_mtp.go @@ -9,7 +9,7 @@ import ( ) func (oq *Querier) queryMtp(ctx sdk.Context, query *types.MTPRequest) ([]byte, error) { - res, err := oq.keeper.MTP(ctx, query) + res, err := oq.keeper.MTP(sdk.WrapSDKContext(ctx), query) if err != nil { return nil, errorsmod.Wrap(err, "failed to get mtp") } diff --git a/x/margin/client/wasm/query_params.go b/x/margin/client/wasm/query_params.go index b319264ac..0f7d869ba 100644 --- a/x/margin/client/wasm/query_params.go +++ b/x/margin/client/wasm/query_params.go @@ -9,7 +9,7 @@ import ( ) func (oq *Querier) queryParams(ctx sdk.Context, query *types.ParamsRequest) ([]byte, error) { - res, err := oq.keeper.Params(ctx, query) + res, err := oq.keeper.Params(sdk.WrapSDKContext(ctx), query) if err != nil { return nil, errorsmod.Wrap(err, "failed to get params") } diff --git a/x/margin/client/wasm/query_pool.go b/x/margin/client/wasm/query_pool.go index ec4814526..4ca319480 100644 --- a/x/margin/client/wasm/query_pool.go +++ b/x/margin/client/wasm/query_pool.go @@ -9,7 +9,7 @@ import ( ) func (oq *Querier) queryPool(ctx sdk.Context, query *types.QueryGetPoolRequest) ([]byte, error) { - res, err := oq.keeper.Pool(ctx, query) + res, err := oq.keeper.Pool(sdk.WrapSDKContext(ctx), query) if err != nil { return nil, errorsmod.Wrap(err, "failed to get pool") } diff --git a/x/margin/client/wasm/query_pools.go b/x/margin/client/wasm/query_pools.go index 3ffb4a080..21a6f5ef5 100644 --- a/x/margin/client/wasm/query_pools.go +++ b/x/margin/client/wasm/query_pools.go @@ -9,7 +9,7 @@ import ( ) func (oq *Querier) queryPools(ctx sdk.Context, query *types.QueryAllPoolRequest) ([]byte, error) { - res, err := oq.keeper.Pools(ctx, query) + res, err := oq.keeper.Pools(sdk.WrapSDKContext(ctx), query) if err != nil { return nil, errorsmod.Wrap(err, "failed to get pools") } diff --git a/x/margin/client/wasm/query_positions.go b/x/margin/client/wasm/query_positions.go index a31d9a715..2e600045c 100644 --- a/x/margin/client/wasm/query_positions.go +++ b/x/margin/client/wasm/query_positions.go @@ -9,7 +9,7 @@ import ( ) func (oq *Querier) queryPositions(ctx sdk.Context, query *types.PositionsRequest) ([]byte, error) { - res, err := oq.keeper.GetPositions(ctx, query) + res, err := oq.keeper.GetPositions(sdk.WrapSDKContext(ctx), query) if err != nil { return nil, errorsmod.Wrap(err, "failed to get positions") } diff --git a/x/margin/client/wasm/query_positions_by_pool.go b/x/margin/client/wasm/query_positions_by_pool.go index 7e988619e..ff5334c6c 100644 --- a/x/margin/client/wasm/query_positions_by_pool.go +++ b/x/margin/client/wasm/query_positions_by_pool.go @@ -9,7 +9,7 @@ import ( ) func (oq *Querier) queryPositionsByPool(ctx sdk.Context, query *types.PositionsByPoolRequest) ([]byte, error) { - res, err := oq.keeper.GetPositionsByPool(ctx, query) + res, err := oq.keeper.GetPositionsByPool(sdk.WrapSDKContext(ctx), query) if err != nil { return nil, errorsmod.Wrap(err, "failed to get positions by pool") } diff --git a/x/margin/client/wasm/query_positions_for_address.go b/x/margin/client/wasm/query_positions_for_address.go index 5f685c26e..de43398e3 100644 --- a/x/margin/client/wasm/query_positions_for_address.go +++ b/x/margin/client/wasm/query_positions_for_address.go @@ -9,7 +9,7 @@ import ( ) func (oq *Querier) queryPositionsForAddress(ctx sdk.Context, query *types.PositionsForAddressRequest) ([]byte, error) { - res, err := oq.keeper.GetPositionsForAddress(ctx, query) + res, err := oq.keeper.GetPositionsForAddress(sdk.WrapSDKContext(ctx), query) if err != nil { return nil, errorsmod.Wrap(err, "failed to get positions for address") } diff --git a/x/margin/keeper/apply_discount.go b/x/margin/keeper/apply_discount.go deleted file mode 100644 index dbda27fef..000000000 --- a/x/margin/keeper/apply_discount.go +++ /dev/null @@ -1,30 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/elys-network/elys/x/amm/types" -) - -// ApplyDiscount applies discount to swap fee if applicable -func (k Keeper) ApplyDiscount(ctx sdk.Context, swapFee sdk.Dec, discount sdk.Dec, sender string) (sdk.Dec, sdk.Dec, error) { - // if discount is nil, return swap fee and zero discount - if discount.IsNil() { - return swapFee, sdk.ZeroDec(), nil - } - - // if discount is zero, return swap fee and zero discount - if discount.IsZero() { - return swapFee, sdk.ZeroDec(), nil - } - - // check if discount is positive and signer address is broker address otherwise throw an error - if discount.IsPositive() && sender != k.GetBrokerAddress(ctx).String() { - return sdk.ZeroDec(), sdk.ZeroDec(), sdkerrors.Wrapf(types.ErrInvalidDiscount, "discount %s is positive and signer address %s is not broker address %s", discount, sender, k.GetBrokerAddress(ctx)) - } - - // apply discount percentage to swap fee - swapFee = swapFee.Mul(sdk.OneDec().Sub(discount)) - - return swapFee, discount, nil -} diff --git a/x/margin/keeper/broker_close.go b/x/margin/keeper/broker_close.go deleted file mode 100644 index d601e54c5..000000000 --- a/x/margin/keeper/broker_close.go +++ /dev/null @@ -1,19 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/margin/types" -) - -func (k Keeper) BrokerClose(ctx sdk.Context, msg *types.MsgBrokerClose) (*types.MsgBrokerCloseResponse, error) { - msgClose := types.NewMsgClose(msg.Owner, msg.Id, msg.Amount) - - res, err := k.Close(ctx, msgClose) - if err != nil { - return nil, err - } - - return &types.MsgBrokerCloseResponse{ - Id: res.Id, - }, nil -} diff --git a/x/margin/keeper/broker_open.go b/x/margin/keeper/broker_open.go deleted file mode 100644 index 09269129b..000000000 --- a/x/margin/keeper/broker_open.go +++ /dev/null @@ -1,19 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/margin/types" -) - -func (k Keeper) BrokerOpen(ctx sdk.Context, msg *types.MsgBrokerOpen) (*types.MsgBrokerOpenResponse, error) { - msgOpen := types.NewMsgOpen(msg.Owner, msg.Position, msg.Leverage, msg.TradingAsset, msg.Collateral, msg.TakeProfitPrice) - - res, err := k.Open(ctx, msgOpen) - if err != nil { - return nil, err - } - - return &types.MsgBrokerOpenResponse{ - Id: res.Id, - }, nil -} diff --git a/x/margin/keeper/get_amm_pool_test.go b/x/margin/keeper/get_amm_pool_test.go index d039a66ae..182acf8a9 100644 --- a/x/margin/keeper/get_amm_pool_test.go +++ b/x/margin/keeper/get_amm_pool_test.go @@ -14,7 +14,7 @@ import ( func TestGetAmmPool_PoolNotFound(t *testing.T) { mockAmm := new(mocks.AmmKeeper) - k := keeper.NewKeeper(nil, nil, nil, "cosmos1ysxv266l8w76lq0vy44ktzajdr9u9yhlxzlvga", mockAmm, nil, nil, nil) + k := keeper.NewKeeper(nil, nil, nil, "cosmos1ysxv266l8w76lq0vy44ktzajdr9u9yhlxzlvga", mockAmm, nil, nil, nil, nil) ctx := sdk.Context{} // mock or setup a context borrowAsset := "testAsset" @@ -32,7 +32,7 @@ func TestGetAmmPool_PoolNotFound(t *testing.T) { func TestGetAmmPool_PoolFound(t *testing.T) { mockAmm := new(mocks.AmmKeeper) - k := keeper.NewKeeper(nil, nil, nil, "cosmos1ysxv266l8w76lq0vy44ktzajdr9u9yhlxzlvga", mockAmm, nil, nil, nil) + k := keeper.NewKeeper(nil, nil, nil, "cosmos1ysxv266l8w76lq0vy44ktzajdr9u9yhlxzlvga", mockAmm, nil, nil, nil, nil) ctx := sdk.Context{} // mock or setup a context borrowAsset := "testAsset" diff --git a/x/margin/keeper/get_first_valid_pool_test.go b/x/margin/keeper/get_first_valid_pool_test.go index 45ab0df6a..1a8a85664 100644 --- a/x/margin/keeper/get_first_valid_pool_test.go +++ b/x/margin/keeper/get_first_valid_pool_test.go @@ -14,7 +14,7 @@ import ( func TestGetFirstValidPool_NoPoolID(t *testing.T) { mockAmm := new(mocks.AmmKeeper) - k := keeper.NewKeeper(nil, nil, nil, "cosmos1ysxv266l8w76lq0vy44ktzajdr9u9yhlxzlvga", mockAmm, nil, nil, nil) + k := keeper.NewKeeper(nil, nil, nil, "cosmos1ysxv266l8w76lq0vy44ktzajdr9u9yhlxzlvga", mockAmm, nil, nil, nil, nil) ctx := sdk.Context{} // mock or setup a context collateralAsset := ptypes.BaseCurrency @@ -33,7 +33,7 @@ func TestGetFirstValidPool_NoPoolID(t *testing.T) { func TestGetFirstValidPool_ValidPoolID(t *testing.T) { mockAmm := new(mocks.AmmKeeper) - k := keeper.NewKeeper(nil, nil, nil, "cosmos1ysxv266l8w76lq0vy44ktzajdr9u9yhlxzlvga", mockAmm, nil, nil, nil) + k := keeper.NewKeeper(nil, nil, nil, "cosmos1ysxv266l8w76lq0vy44ktzajdr9u9yhlxzlvga", mockAmm, nil, nil, nil, nil) ctx := sdk.Context{} // mock or setup a context collateralAsset := ptypes.BaseCurrency diff --git a/x/margin/keeper/keeper.go b/x/margin/keeper/keeper.go index c3cfa2f29..c5a9da32e 100644 --- a/x/margin/keeper/keeper.go +++ b/x/margin/keeper/keeper.go @@ -18,6 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/query" ammtypes "github.com/elys-network/elys/x/amm/types" "github.com/elys-network/elys/x/margin/types" + pkeeper "github.com/elys-network/elys/x/parameter/keeper" ) type ( @@ -31,14 +32,15 @@ type ( types.CloseLongChecker types.CloseShortChecker - cdc codec.BinaryCodec - storeKey storetypes.StoreKey - memKey storetypes.StoreKey - authority string - amm types.AmmKeeper - bankKeeper types.BankKeeper - oracleKeeper ammtypes.OracleKeeper - apKeeper types.AssetProfileKeeper + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + authority string + parameterKeeper *pkeeper.Keeper + amm types.AmmKeeper + bankKeeper types.BankKeeper + oracleKeeper ammtypes.OracleKeeper + apKeeper types.AssetProfileKeeper hooks types.MarginHooks } @@ -53,6 +55,7 @@ func NewKeeper( bk types.BankKeeper, oracleKeeper ammtypes.OracleKeeper, apKeeper types.AssetProfileKeeper, + parameterKeeper *pkeeper.Keeper, ) *Keeper { // ensure that authority is a valid AccAddress if _, err := sdk.AccAddressFromBech32(authority); err != nil { @@ -60,14 +63,15 @@ func NewKeeper( } keeper := &Keeper{ - cdc: cdc, - storeKey: storeKey, - memKey: memKey, - authority: authority, - amm: amm, - bankKeeper: bk, - oracleKeeper: oracleKeeper, - apKeeper: apKeeper, + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + authority: authority, + amm: amm, + bankKeeper: bk, + oracleKeeper: oracleKeeper, + apKeeper: apKeeper, + parameterKeeper: parameterKeeper, } keeper.AuthorizationChecker = keeper diff --git a/x/margin/keeper/msg_server_broker_close.go b/x/margin/keeper/msg_server_broker_close.go deleted file mode 100644 index 8395bd2a4..000000000 --- a/x/margin/keeper/msg_server_broker_close.go +++ /dev/null @@ -1,24 +0,0 @@ -package keeper - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - "github.com/elys-network/elys/x/margin/types" -) - -func (k msgServer) BrokerClose(goCtx context.Context, msg *types.MsgBrokerClose) (*types.MsgBrokerCloseResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - // get broker address - brokerAddress := k.GetBrokerAddress(ctx).String() - - // check if broker is allowed - if brokerAddress != msg.Creator { - return nil, sdkerrors.Wrapf(govtypes.ErrInvalidSigner, "invalid broker address; expected %s, got %s", brokerAddress, msg.Creator) - } - - return k.Keeper.BrokerClose(ctx, msg) -} diff --git a/x/margin/keeper/msg_server_broker_open.go b/x/margin/keeper/msg_server_broker_open.go deleted file mode 100644 index 8840eacb4..000000000 --- a/x/margin/keeper/msg_server_broker_open.go +++ /dev/null @@ -1,24 +0,0 @@ -package keeper - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - "github.com/elys-network/elys/x/margin/types" -) - -func (k msgServer) BrokerOpen(goCtx context.Context, msg *types.MsgBrokerOpen) (*types.MsgBrokerOpenResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - // get broker address - brokerAddress := k.GetBrokerAddress(ctx).String() - - // check if broker is allowed - if brokerAddress != msg.Creator { - return nil, sdkerrors.Wrapf(govtypes.ErrInvalidSigner, "invalid broker address; expected %s, got %s", brokerAddress, msg.Creator) - } - - return k.Keeper.BrokerOpen(ctx, msg) -} diff --git a/x/margin/keeper/open_test.go b/x/margin/keeper/open_test.go index 2704f535b..65bde79ed 100644 --- a/x/margin/keeper/open_test.go +++ b/x/margin/keeper/open_test.go @@ -20,7 +20,7 @@ func TestOpen_ErrorCheckUserAuthorization(t *testing.T) { mockChecker := new(mocks.OpenChecker) mockAssetProfile := new(mocks.AssetProfileKeeper) - k := keeper.NewKeeper(nil, nil, nil, "cosmos1ysxv266l8w76lq0vy44ktzajdr9u9yhlxzlvga", nil, nil, nil, mockAssetProfile) + k := keeper.NewKeeper(nil, nil, nil, "cosmos1ysxv266l8w76lq0vy44ktzajdr9u9yhlxzlvga", nil, nil, nil, mockAssetProfile, nil) k.OpenChecker = mockChecker var ( @@ -48,7 +48,7 @@ func TestOpen_ErrorCheckMaxOpenPositions(t *testing.T) { mockChecker := new(mocks.OpenChecker) mockAssetProfile := new(mocks.AssetProfileKeeper) - k := keeper.NewKeeper(nil, nil, nil, "cosmos1ysxv266l8w76lq0vy44ktzajdr9u9yhlxzlvga", nil, nil, nil, mockAssetProfile) + k := keeper.NewKeeper(nil, nil, nil, "cosmos1ysxv266l8w76lq0vy44ktzajdr9u9yhlxzlvga", nil, nil, nil, mockAssetProfile, nil) k.OpenChecker = mockChecker var ( @@ -79,7 +79,7 @@ func TestOpen_ErrorPreparePools(t *testing.T) { mockChecker := new(mocks.OpenChecker) mockAssetProfile := new(mocks.AssetProfileKeeper) - k := keeper.NewKeeper(nil, nil, nil, "cosmos1ysxv266l8w76lq0vy44ktzajdr9u9yhlxzlvga", nil, nil, nil, mockAssetProfile) + k := keeper.NewKeeper(nil, nil, nil, "cosmos1ysxv266l8w76lq0vy44ktzajdr9u9yhlxzlvga", nil, nil, nil, mockAssetProfile, nil) k.OpenChecker = mockChecker var ( @@ -112,7 +112,7 @@ func TestOpen_ErrorCheckPoolHealth(t *testing.T) { mockChecker := new(mocks.OpenChecker) mockAssetProfile := new(mocks.AssetProfileKeeper) - k := keeper.NewKeeper(nil, nil, nil, "cosmos1ysxv266l8w76lq0vy44ktzajdr9u9yhlxzlvga", nil, nil, nil, mockAssetProfile) + k := keeper.NewKeeper(nil, nil, nil, "cosmos1ysxv266l8w76lq0vy44ktzajdr9u9yhlxzlvga", nil, nil, nil, mockAssetProfile, nil) k.OpenChecker = mockChecker var ( @@ -145,7 +145,7 @@ func TestOpen_ErrorInvalidPosition(t *testing.T) { mockChecker := new(mocks.OpenChecker) mockAssetProfile := new(mocks.AssetProfileKeeper) - k := keeper.NewKeeper(nil, nil, nil, "cosmos1ysxv266l8w76lq0vy44ktzajdr9u9yhlxzlvga", nil, nil, nil, mockAssetProfile) + k := keeper.NewKeeper(nil, nil, nil, "cosmos1ysxv266l8w76lq0vy44ktzajdr9u9yhlxzlvga", nil, nil, nil, mockAssetProfile, nil) k.OpenChecker = mockChecker var ( @@ -171,7 +171,7 @@ func TestOpen_ErrorOpenLong(t *testing.T) { mockChecker := new(mocks.OpenChecker) mockAssetProfile := new(mocks.AssetProfileKeeper) - k := keeper.NewKeeper(nil, nil, nil, "cosmos1ysxv266l8w76lq0vy44ktzajdr9u9yhlxzlvga", nil, nil, nil, mockAssetProfile) + k := keeper.NewKeeper(nil, nil, nil, "cosmos1ysxv266l8w76lq0vy44ktzajdr9u9yhlxzlvga", nil, nil, nil, mockAssetProfile, nil) k.OpenChecker = mockChecker var ( @@ -205,7 +205,7 @@ func TestOpen_ErrorOpenShort(t *testing.T) { mockChecker := new(mocks.OpenChecker) mockAssetProfile := new(mocks.AssetProfileKeeper) - k := keeper.NewKeeper(nil, nil, nil, "cosmos1ysxv266l8w76lq0vy44ktzajdr9u9yhlxzlvga", nil, nil, nil, mockAssetProfile) + k := keeper.NewKeeper(nil, nil, nil, "cosmos1ysxv266l8w76lq0vy44ktzajdr9u9yhlxzlvga", nil, nil, nil, mockAssetProfile, nil) k.OpenChecker = mockChecker var ( @@ -239,7 +239,7 @@ func TestOpen_Successful(t *testing.T) { mockChecker := new(mocks.OpenChecker) mockAssetProfile := new(mocks.AssetProfileKeeper) - k := keeper.NewKeeper(nil, nil, nil, "cosmos1ysxv266l8w76lq0vy44ktzajdr9u9yhlxzlvga", nil, nil, nil, mockAssetProfile) + k := keeper.NewKeeper(nil, nil, nil, "cosmos1ysxv266l8w76lq0vy44ktzajdr9u9yhlxzlvga", nil, nil, nil, mockAssetProfile, nil) k.OpenChecker = mockChecker var ( diff --git a/x/margin/keeper/params.go b/x/margin/keeper/params.go index 7df86cc0e..ed1302ff8 100644 --- a/x/margin/keeper/params.go +++ b/x/margin/keeper/params.go @@ -143,15 +143,6 @@ func (k Keeper) IsWhitelistingEnabled(ctx sdk.Context) bool { return k.GetParams(ctx).WhitelistingEnabled } -func (k Keeper) GetBrokerAddress(ctx sdk.Context) sdk.AccAddress { - addr, err := sdk.AccAddressFromBech32(k.GetParams(ctx).BrokerAddress) - if err != nil { - panic(err) - } - - return addr -} - func (k Keeper) GetTakeProfitBorrowInterestRateMin(ctx sdk.Context) sdk.Dec { return k.GetParams(ctx).TakeProfitBorrowInterestRateMin } diff --git a/x/margin/types/msgs.go b/x/margin/types/msgs.go index 3ffdf62e4..e797bda8e 100644 --- a/x/margin/types/msgs.go +++ b/x/margin/types/msgs.go @@ -8,8 +8,6 @@ import ( const ( TypeMsgOpen = "open" TypeMsgClose = "close" - TypeMsgBrokerOpen = "broker_open" - TypeMsgBrokerClose = "broker_close" TypeMsgUpdateParams = "update_params" TypeMsgWhitelist = "whitelist" TypeMsgUpdatePools = "update_pools" @@ -19,8 +17,6 @@ const ( var ( _ sdk.Msg = &MsgClose{} _ sdk.Msg = &MsgOpen{} - _ sdk.Msg = &MsgBrokerClose{} - _ sdk.Msg = &MsgBrokerOpen{} _ sdk.Msg = &MsgUpdateParams{} _ sdk.Msg = &MsgWhitelist{} _ sdk.Msg = &MsgUpdatePools{} @@ -104,93 +100,6 @@ func (msg *MsgOpen) ValidateBasic() error { return nil } -func NewMsgBrokerClose(creator string, id uint64, owner string, amount sdk.Int) *MsgBrokerClose { - return &MsgBrokerClose{ - Creator: creator, - Id: id, - Owner: owner, - Amount: amount, - } -} - -func (msg *MsgBrokerClose) Route() string { - return RouterKey -} - -func (msg *MsgBrokerClose) Type() string { - return TypeMsgBrokerClose -} - -func (msg *MsgBrokerClose) GetSigners() []sdk.AccAddress { - creator, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - panic(err) - } - return []sdk.AccAddress{creator} -} - -func (msg *MsgBrokerClose) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(msg) - return sdk.MustSortJSON(bz) -} - -func (msg *MsgBrokerClose) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) - } - _, err = sdk.AccAddressFromBech32(msg.Owner) - if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid owner address (%s)", err) - } - return nil -} - -func NewMsgBrokerOpen(creator string, position Position, leverage sdk.Dec, tradingAsset string, collateral sdk.Coin, takeProfitPrice sdk.Dec, owner string) *MsgBrokerOpen { - return &MsgBrokerOpen{ - Creator: creator, - Position: position, - Leverage: leverage, - TradingAsset: tradingAsset, - Collateral: collateral, - TakeProfitPrice: takeProfitPrice, - Owner: owner, - } -} - -func (msg *MsgBrokerOpen) Route() string { - return RouterKey -} - -func (msg *MsgBrokerOpen) Type() string { - return TypeMsgBrokerOpen -} - -func (msg *MsgBrokerOpen) GetSigners() []sdk.AccAddress { - creator, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - panic(err) - } - return []sdk.AccAddress{creator} -} - -func (msg *MsgBrokerOpen) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(msg) - return sdk.MustSortJSON(bz) -} - -func (msg *MsgBrokerOpen) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) - } - _, err = sdk.AccAddressFromBech32(msg.Owner) - if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid owner address (%s)", err) - } - return nil -} - func (msg *MsgUpdateParams) GetSigners() []sdk.AccAddress { creator, err := sdk.AccAddressFromBech32(msg.Authority) if err != nil { diff --git a/x/margin/types/params.go b/x/margin/types/params.go index a5f314605..e5a7ff4ac 100644 --- a/x/margin/types/params.go +++ b/x/margin/types/params.go @@ -62,7 +62,6 @@ func NewParams() Params { BorrowInterestRateIncrease: sdk.NewDecWithPrec(33, 10), BorrowInterestRateMax: sdk.NewDecWithPrec(27, 7), BorrowInterestRateMin: sdk.NewDecWithPrec(3, 8), - BrokerAddress: ZeroAddress, EpochLength: (int64)(1), ForceCloseFundAddress: ZeroAddress, ForceCloseFundPercentage: sdk.OneDec(), @@ -108,7 +107,6 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair(KeyIncrementalBorrowInterestPaymentEnabled, &p.IncrementalBorrowInterestPaymentEnabled, validateIncrementalBorrowInterestPaymentEnabled), paramtypes.NewParamSetPair(KeyWhitelistingEnabled, &p.WhitelistingEnabled, validateWhitelistingEnabled), paramtypes.NewParamSetPair(KeyInvariantCheckEpoch, &p.InvariantCheckEpoch, validateInvariantCheckEpoch), - paramtypes.NewParamSetPair(KeyBrokerAddress, &p.BrokerAddress, validateBrokerAddress), paramtypes.NewParamSetPair(KeyTakeProfitBorrowInterestRateMin, &p.TakeProfitBorrowInterestRateMin, validateTakeProfitBorrowInterestRateMin), paramtypes.NewParamSetPair(KeyFundingFeeBaseRate, &p.FundingFeeBaseRate, validateBorrowInterestRateMax), paramtypes.NewParamSetPair(KeyFundingFeeMinRate, &p.FundingFeeMinRate, validateBorrowInterestRateMax), @@ -177,9 +175,6 @@ func (p Params) Validate() error { if err := validateInvariantCheckEpoch(p.InvariantCheckEpoch); err != nil { return err } - if err := validateBrokerAddress(p.BrokerAddress); err != nil { - return err - } if err := validateTakeProfitBorrowInterestRateMin(p.TakeProfitBorrowInterestRateMin); err != nil { return err } @@ -469,15 +464,6 @@ func validateInvariantCheckEpoch(i interface{}) error { return nil } -func validateBrokerAddress(i interface{}) error { - _, ok := i.(string) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - return nil -} - func validateTakeProfitBorrowInterestRateMin(i interface{}) error { v, ok := i.(sdk.Dec) if !ok { diff --git a/x/margin/types/params.pb.go b/x/margin/types/params.pb.go index 8f489ba74..33745e4a0 100644 --- a/x/margin/types/params.pb.go +++ b/x/margin/types/params.pb.go @@ -45,13 +45,12 @@ type Params struct { IncrementalBorrowInterestPaymentEnabled bool `protobuf:"varint,17,opt,name=incremental_borrow_interest_payment_enabled,json=incrementalBorrowInterestPaymentEnabled,proto3" json:"incremental_borrow_interest_payment_enabled,omitempty"` WhitelistingEnabled bool `protobuf:"varint,18,opt,name=whitelisting_enabled,json=whitelistingEnabled,proto3" json:"whitelisting_enabled,omitempty"` InvariantCheckEpoch string `protobuf:"bytes,19,opt,name=invariant_check_epoch,json=invariantCheckEpoch,proto3" json:"invariant_check_epoch,omitempty"` - BrokerAddress string `protobuf:"bytes,20,opt,name=broker_address,json=brokerAddress,proto3" json:"broker_address,omitempty"` - TakeProfitBorrowInterestRateMin github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,21,opt,name=take_profit_borrow_interest_rate_min,json=takeProfitBorrowInterestRateMin,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"take_profit_borrow_interest_rate_min"` - FundingFeeBaseRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,22,opt,name=funding_fee_base_rate,json=fundingFeeBaseRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"funding_fee_base_rate"` - FundingFeeMaxRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,23,opt,name=funding_fee_max_rate,json=fundingFeeMaxRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"funding_fee_max_rate"` - FundingFeeMinRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,24,opt,name=funding_fee_min_rate,json=fundingFeeMinRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"funding_fee_min_rate"` - FundingFeeCollectionAddress string `protobuf:"bytes,25,opt,name=funding_fee_collection_address,json=fundingFeeCollectionAddress,proto3" json:"funding_fee_collection_address,omitempty"` - SwapFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,26,opt,name=swap_fee,json=swapFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swap_fee"` + TakeProfitBorrowInterestRateMin github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,20,opt,name=take_profit_borrow_interest_rate_min,json=takeProfitBorrowInterestRateMin,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"take_profit_borrow_interest_rate_min"` + FundingFeeBaseRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,21,opt,name=funding_fee_base_rate,json=fundingFeeBaseRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"funding_fee_base_rate"` + FundingFeeMaxRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,22,opt,name=funding_fee_max_rate,json=fundingFeeMaxRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"funding_fee_max_rate"` + FundingFeeMinRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,23,opt,name=funding_fee_min_rate,json=fundingFeeMinRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"funding_fee_min_rate"` + FundingFeeCollectionAddress string `protobuf:"bytes,24,opt,name=funding_fee_collection_address,json=fundingFeeCollectionAddress,proto3" json:"funding_fee_collection_address,omitempty"` + SwapFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,25,opt,name=swap_fee,json=swapFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swap_fee"` } func (m *Params) Reset() { *m = Params{} } @@ -135,13 +134,6 @@ func (m *Params) GetInvariantCheckEpoch() string { return "" } -func (m *Params) GetBrokerAddress() string { - if m != nil { - return m.BrokerAddress - } - return "" -} - func (m *Params) GetFundingFeeCollectionAddress() string { if m != nil { return m.FundingFeeCollectionAddress @@ -156,58 +148,57 @@ func init() { func init() { proto.RegisterFile("elys/margin/params.proto", fileDescriptor_f427d3667a99d828) } var fileDescriptor_f427d3667a99d828 = []byte{ - // 812 bytes of a gzipped FileDescriptorProto + // 792 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xc0, 0xbd, 0xb4, 0xa4, 0xe9, 0x38, 0x29, 0xe9, 0x24, 0xa6, 0x43, 0x2a, 0xec, 0x80, 0xf8, - 0x13, 0x29, 0xd4, 0x06, 0x7a, 0x40, 0xe2, 0x86, 0xdd, 0x18, 0x45, 0x22, 0xaa, 0x6b, 0x38, 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, 0xc6, 0x44, 0x5c, 0xe0, 0x09, 0x7a, 0xff, 0x4a, 0x11, 0x17, - 0xbe, 0x02, 0xa6, 0x81, 0xdc, 0xac, 0x64, 0xdb, 0xbf, 0x6c, 0x3b, 0x29, 0x88, 0xaf, 0x55, 0x06, - 0x50, 0x28, 0xdf, 0x7e, 0x53, 0xca, 0x47, 0x05, 0x11, 0x3f, 0x45, 0x38, 0x06, 0x96, 0x98, 0x98, - 0x46, 0x8c, 0x0b, 0x1a, 0x32, 0xdf, 0x48, 0x45, 0x36, 0x2a, 0x79, 0x76, 0x72, 0xd2, 0xb7, 0x8c, - 0x8b, 0xbe, 0xe3, 0xe0, 0x0f, 0xd0, 0x16, 0x64, 0xd2, 0x8f, 0x69, 0x02, 0x22, 0x32, 0x31, 0xb9, - 0x75, 0xe0, 0x1d, 0xde, 0x18, 0xd6, 0xdd, 0xd8, 0x77, 0x6e, 0x08, 0x87, 0xe8, 0x9e, 0x82, 0x54, - 0x9e, 0xb1, 0x84, 0x4e, 0xa6, 0x30, 0x05, 0x6a, 0x62, 0x05, 0x3a, 0x96, 0x49, 0x40, 0x36, 0xab, - 0xb5, 0xb3, 0xc0, 0x3d, 0xb1, 0xb4, 0x1f, 0x4a, 0x18, 0xfe, 0x0c, 0xe1, 0x94, 0xcd, 0xa9, 0xcc, - 0x40, 0xd0, 0x4c, 0x6a, 0x6e, 0xb8, 0x14, 0x9a, 0xdc, 0x76, 0x09, 0xed, 0xa4, 0x6c, 0xfe, 0x38, - 0x03, 0x31, 0x28, 0xc7, 0xf1, 0x4f, 0x68, 0x37, 0x93, 0x32, 0xc9, 0xa7, 0xaf, 0x32, 0x42, 0x95, - 0x32, 0xba, 0x6b, 0x51, 0x96, 0xbf, 0xca, 0x26, 0x45, 0xf7, 0x43, 0xa9, 0x7c, 0xa0, 0x7e, 0x22, - 0x35, 0xd0, 0x70, 0x2a, 0x02, 0x9a, 0x81, 0xf2, 0x41, 0x18, 0x16, 0x01, 0xa9, 0x57, 0x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6f, 0x53, 0x0f, 0x04, 0x98, 0x99, 0x54, - 0x63, 0xf7, 0xa3, 0x33, 0x2f, 0xaf, 0x5d, 0x8e, 0x3c, 0xda, 0x70, 0x77, 0xaa, 0x87, 0xff, 0x04, - 0x00, 0x00, 0xff, 0xff, 0xed, 0xdb, 0xa9, 0x87, 0x92, 0x09, 0x00, 0x00, + 0x14, 0xc0, 0xbd, 0xb4, 0xa4, 0xe9, 0x38, 0x85, 0x64, 0x62, 0xd3, 0xa1, 0x15, 0x76, 0x40, 0x08, + 0x22, 0x85, 0xda, 0x40, 0x0f, 0x48, 0xdc, 0xb0, 0x1b, 0xa3, 0x48, 0x44, 0x75, 0x0d, 0x27, 0x54, + 0x31, 0x1a, 0xef, 0xbe, 0xdd, 0x1d, 0x79, 0x77, 0x66, 0x3d, 0x33, 0x8e, 0xed, 0x03, 0xdf, 0x81, + 0x23, 0x12, 0x17, 0x3e, 0x4e, 0x8f, 0x3d, 0x22, 0x84, 0x2a, 0x94, 0x7c, 0x11, 0x34, 0xb3, 0xbb, + 0xb6, 0xdb, 0xa4, 0x10, 0x2d, 0x3d, 0xd9, 0x3b, 0x6f, 0xe6, 0xf7, 0x7b, 0x6f, 0xfe, 0x69, 0x10, + 0x81, 0x64, 0xa9, 0xbb, 0x29, 0x53, 0x11, 0x17, 0xdd, 0x8c, 0x29, 0x96, 0xea, 0x4e, 0xa6, 0xa4, + 0x91, 0xb8, 0x6e, 0x23, 0x9d, 0x3c, 0x72, 0xaf, 0x11, 0xc9, 0x48, 0xba, 0xf6, 0xae, 0xfd, 0x97, + 0x77, 0xf9, 0xe8, 0xaf, 0x3d, 0xb4, 0x35, 0x74, 0x63, 0xf0, 0x13, 0xb4, 0x93, 0xc0, 0x19, 0x28, + 0x16, 0x01, 0x4d, 0xd9, 0x82, 0x78, 0x07, 0xde, 0xe1, 0xed, 0x5e, 0xe7, 0xd9, 0x8b, 0x76, 0xed, + 0xcf, 0x17, 0xed, 0x4f, 0x22, 0x6e, 0xe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5, 0xcc, 0x6e, 0xd9, 0xf1, 0x03, + 0x80, 0xaf, 0x6f, 0xfe, 0xfa, 0x7b, 0xbb, 0xd6, 0x3b, 0x7e, 0x76, 0xde, 0xf2, 0x9e, 0x9f, 0xb7, + 0xbc, 0xbf, 0xcf, 0x5b, 0xde, 0x2f, 0x17, 0xad, 0xda, 0xf3, 0x8b, 0x56, 0xed, 0x8f, 0x8b, 0x56, + 0xed, 0xc7, 0xa3, 0x0d, 0xa0, 0x7d, 0x26, 0x3d, 0x10, 0x60, 0xe6, 0x52, 0x4d, 0xdc, 0x47, 0x77, + 0x51, 0xbe, 0xa7, 0x1c, 0x79, 0xbc, 0xe5, 0x1e, 0x4b, 0x0f, 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, + 0x8c, 0xdf, 0x43, 0xf2, 0x6b, 0x09, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -241,7 +232,7 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1 i-- - dAtA[i] = 0xd2 + dAtA[i] = 0xca if len(m.FundingFeeCollectionAddress) > 0 { i -= len(m.FundingFeeCollectionAddress) copy(dAtA[i:], m.FundingFeeCollectionAddress) @@ -249,7 +240,7 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1 i-- - dAtA[i] = 0xca + dAtA[i] = 0xc2 } { size := m.FundingFeeMinRate.Size() @@ -262,7 +253,7 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1 i-- - dAtA[i] = 0xc2 + dAtA[i] = 0xba { size := m.FundingFeeMaxRate.Size() i -= size @@ -274,7 +265,7 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1 i-- - dAtA[i] = 0xba + dAtA[i] = 0xb2 { size := m.FundingFeeBaseRate.Size() i -= size @@ -286,7 +277,7 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1 i-- - dAtA[i] = 0xb2 + dAtA[i] = 0xaa { size := m.TakeProfitBorrowInterestRateMin.Size() i -= size @@ -298,16 +289,7 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1 i-- - dAtA[i] = 0xaa - if len(m.BrokerAddress) > 0 { - i -= len(m.BrokerAddress) - copy(dAtA[i:], m.BrokerAddress) - i = encodeVarintParams(dAtA, i, uint64(len(m.BrokerAddress))) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xa2 - } + dAtA[i] = 0xa2 if len(m.InvariantCheckEpoch) > 0 { i -= len(m.InvariantCheckEpoch) copy(dAtA[i:], m.InvariantCheckEpoch) @@ -555,10 +537,6 @@ func (m *Params) Size() (n int) { if l > 0 { n += 2 + l + sovParams(uint64(l)) } - l = len(m.BrokerAddress) - if l > 0 { - n += 2 + l + sovParams(uint64(l)) - } l = m.TakeProfitBorrowInterestRateMin.Size() n += 2 + l + sovParams(uint64(l)) l = m.FundingFeeBaseRate.Size() @@ -1194,38 +1172,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { m.InvariantCheckEpoch = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 20: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BrokerAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - 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 ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.BrokerAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 21: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field TakeProfitBorrowInterestRateMin", wireType) } @@ -1259,7 +1205,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 22: + case 21: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field FundingFeeBaseRate", wireType) } @@ -1293,7 +1239,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 23: + case 22: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field FundingFeeMaxRate", wireType) } @@ -1327,7 +1273,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 24: + case 23: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field FundingFeeMinRate", wireType) } @@ -1361,7 +1307,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 25: + case 24: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field FundingFeeCollectionAddress", wireType) } @@ -1393,7 +1339,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } m.FundingFeeCollectionAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 26: + case 25: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field SwapFee", wireType) } diff --git a/x/margin/types/tx.pb.go b/x/margin/types/tx.pb.go index 161232f7b..c860639f6 100644 --- a/x/margin/types/tx.pb.go +++ b/x/margin/types/tx.pb.go @@ -242,234 +242,6 @@ func (m *MsgCloseResponse) GetId() uint64 { return 0 } -type MsgBrokerOpen struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - Position Position `protobuf:"varint,2,opt,name=position,proto3,enum=elys.margin.Position" json:"position,omitempty"` - Leverage github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=leverage,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"leverage"` - TradingAsset string `protobuf:"bytes,4,opt,name=trading_asset,json=tradingAsset,proto3" json:"trading_asset,omitempty"` - Collateral types.Coin `protobuf:"bytes,5,opt,name=collateral,proto3" json:"collateral"` - TakeProfitPrice github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=take_profit_price,json=takeProfitPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"take_profit_price"` - Owner string `protobuf:"bytes,7,opt,name=owner,proto3" json:"owner,omitempty"` -} - -func (m *MsgBrokerOpen) Reset() { *m = MsgBrokerOpen{} } -func (m *MsgBrokerOpen) String() string { return proto.CompactTextString(m) } -func (*MsgBrokerOpen) ProtoMessage() {} -func (*MsgBrokerOpen) Descriptor() ([]byte, []int) { - return fileDescriptor_01b9dbed35cc5a15, []int{4} -} -func (m *MsgBrokerOpen) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgBrokerOpen) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgBrokerOpen.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 *MsgBrokerOpen) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgBrokerOpen.Merge(m, src) -} -func (m *MsgBrokerOpen) XXX_Size() int { - return m.Size() -} -func (m *MsgBrokerOpen) XXX_DiscardUnknown() { - xxx_messageInfo_MsgBrokerOpen.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgBrokerOpen proto.InternalMessageInfo - -func (m *MsgBrokerOpen) GetCreator() string { - if m != nil { - return m.Creator - } - return "" -} - -func (m *MsgBrokerOpen) GetPosition() Position { - if m != nil { - return m.Position - } - return Position_UNSPECIFIED -} - -func (m *MsgBrokerOpen) GetTradingAsset() string { - if m != nil { - return m.TradingAsset - } - return "" -} - -func (m *MsgBrokerOpen) GetCollateral() types.Coin { - if m != nil { - return m.Collateral - } - return types.Coin{} -} - -func (m *MsgBrokerOpen) GetOwner() string { - if m != nil { - return m.Owner - } - return "" -} - -type MsgBrokerOpenResponse struct { - Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` -} - -func (m *MsgBrokerOpenResponse) Reset() { *m = MsgBrokerOpenResponse{} } -func (m *MsgBrokerOpenResponse) String() string { return proto.CompactTextString(m) } -func (*MsgBrokerOpenResponse) ProtoMessage() {} -func (*MsgBrokerOpenResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_01b9dbed35cc5a15, []int{5} -} -func (m *MsgBrokerOpenResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgBrokerOpenResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgBrokerOpenResponse.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 *MsgBrokerOpenResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgBrokerOpenResponse.Merge(m, src) -} -func (m *MsgBrokerOpenResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgBrokerOpenResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgBrokerOpenResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgBrokerOpenResponse proto.InternalMessageInfo - -func (m *MsgBrokerOpenResponse) GetId() uint64 { - if m != nil { - return m.Id - } - return 0 -} - -type MsgBrokerClose struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - Id uint64 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` - Owner string `protobuf:"bytes,3,opt,name=owner,proto3" json:"owner,omitempty"` - Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` -} - -func (m *MsgBrokerClose) Reset() { *m = MsgBrokerClose{} } -func (m *MsgBrokerClose) String() string { return proto.CompactTextString(m) } -func (*MsgBrokerClose) ProtoMessage() {} -func (*MsgBrokerClose) Descriptor() ([]byte, []int) { - return fileDescriptor_01b9dbed35cc5a15, []int{6} -} -func (m *MsgBrokerClose) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgBrokerClose) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgBrokerClose.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 *MsgBrokerClose) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgBrokerClose.Merge(m, src) -} -func (m *MsgBrokerClose) XXX_Size() int { - return m.Size() -} -func (m *MsgBrokerClose) XXX_DiscardUnknown() { - xxx_messageInfo_MsgBrokerClose.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgBrokerClose proto.InternalMessageInfo - -func (m *MsgBrokerClose) GetCreator() string { - if m != nil { - return m.Creator - } - return "" -} - -func (m *MsgBrokerClose) GetId() uint64 { - if m != nil { - return m.Id - } - return 0 -} - -func (m *MsgBrokerClose) GetOwner() string { - if m != nil { - return m.Owner - } - return "" -} - -type MsgBrokerCloseResponse struct { - Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` -} - -func (m *MsgBrokerCloseResponse) Reset() { *m = MsgBrokerCloseResponse{} } -func (m *MsgBrokerCloseResponse) String() string { return proto.CompactTextString(m) } -func (*MsgBrokerCloseResponse) ProtoMessage() {} -func (*MsgBrokerCloseResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_01b9dbed35cc5a15, []int{7} -} -func (m *MsgBrokerCloseResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgBrokerCloseResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgBrokerCloseResponse.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 *MsgBrokerCloseResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgBrokerCloseResponse.Merge(m, src) -} -func (m *MsgBrokerCloseResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgBrokerCloseResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgBrokerCloseResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgBrokerCloseResponse proto.InternalMessageInfo - -func (m *MsgBrokerCloseResponse) GetId() uint64 { - if m != nil { - return m.Id - } - return 0 -} - type MsgUpdateParams struct { // authority is the address that controls the module (defaults to x/gov unless overwritten). Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` @@ -481,7 +253,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_01b9dbed35cc5a15, []int{8} + return fileDescriptor_01b9dbed35cc5a15, []int{4} } func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -531,7 +303,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_01b9dbed35cc5a15, []int{9} + return fileDescriptor_01b9dbed35cc5a15, []int{5} } func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -570,7 +342,7 @@ func (m *MsgUpdatePools) Reset() { *m = MsgUpdatePools{} } func (m *MsgUpdatePools) String() string { return proto.CompactTextString(m) } func (*MsgUpdatePools) ProtoMessage() {} func (*MsgUpdatePools) Descriptor() ([]byte, []int) { - return fileDescriptor_01b9dbed35cc5a15, []int{10} + return fileDescriptor_01b9dbed35cc5a15, []int{6} } func (m *MsgUpdatePools) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -627,7 +399,7 @@ func (m *MsgUpdatePoolsResponse) Reset() { *m = MsgUpdatePoolsResponse{} func (m *MsgUpdatePoolsResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdatePoolsResponse) ProtoMessage() {} func (*MsgUpdatePoolsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_01b9dbed35cc5a15, []int{11} + return fileDescriptor_01b9dbed35cc5a15, []int{7} } func (m *MsgUpdatePoolsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -665,7 +437,7 @@ func (m *MsgWhitelist) Reset() { *m = MsgWhitelist{} } func (m *MsgWhitelist) String() string { return proto.CompactTextString(m) } func (*MsgWhitelist) ProtoMessage() {} func (*MsgWhitelist) Descriptor() ([]byte, []int) { - return fileDescriptor_01b9dbed35cc5a15, []int{12} + return fileDescriptor_01b9dbed35cc5a15, []int{8} } func (m *MsgWhitelist) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -715,7 +487,7 @@ func (m *MsgWhitelistResponse) Reset() { *m = MsgWhitelistResponse{} } func (m *MsgWhitelistResponse) String() string { return proto.CompactTextString(m) } func (*MsgWhitelistResponse) ProtoMessage() {} func (*MsgWhitelistResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_01b9dbed35cc5a15, []int{13} + return fileDescriptor_01b9dbed35cc5a15, []int{9} } func (m *MsgWhitelistResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -753,7 +525,7 @@ func (m *MsgDewhitelist) Reset() { *m = MsgDewhitelist{} } func (m *MsgDewhitelist) String() string { return proto.CompactTextString(m) } func (*MsgDewhitelist) ProtoMessage() {} func (*MsgDewhitelist) Descriptor() ([]byte, []int) { - return fileDescriptor_01b9dbed35cc5a15, []int{14} + return fileDescriptor_01b9dbed35cc5a15, []int{10} } func (m *MsgDewhitelist) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -803,7 +575,7 @@ func (m *MsgDewhitelistResponse) Reset() { *m = MsgDewhitelistResponse{} func (m *MsgDewhitelistResponse) String() string { return proto.CompactTextString(m) } func (*MsgDewhitelistResponse) ProtoMessage() {} func (*MsgDewhitelistResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_01b9dbed35cc5a15, []int{15} + return fileDescriptor_01b9dbed35cc5a15, []int{11} } func (m *MsgDewhitelistResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -837,10 +609,6 @@ func init() { proto.RegisterType((*MsgOpenResponse)(nil), "elys.margin.MsgOpenResponse") proto.RegisterType((*MsgClose)(nil), "elys.margin.MsgClose") proto.RegisterType((*MsgCloseResponse)(nil), "elys.margin.MsgCloseResponse") - proto.RegisterType((*MsgBrokerOpen)(nil), "elys.margin.MsgBrokerOpen") - proto.RegisterType((*MsgBrokerOpenResponse)(nil), "elys.margin.MsgBrokerOpenResponse") - proto.RegisterType((*MsgBrokerClose)(nil), "elys.margin.MsgBrokerClose") - proto.RegisterType((*MsgBrokerCloseResponse)(nil), "elys.margin.MsgBrokerCloseResponse") proto.RegisterType((*MsgUpdateParams)(nil), "elys.margin.MsgUpdateParams") proto.RegisterType((*MsgUpdateParamsResponse)(nil), "elys.margin.MsgUpdateParamsResponse") proto.RegisterType((*MsgUpdatePools)(nil), "elys.margin.MsgUpdatePools") @@ -854,58 +622,51 @@ func init() { func init() { proto.RegisterFile("elys/margin/tx.proto", fileDescriptor_01b9dbed35cc5a15) } var fileDescriptor_01b9dbed35cc5a15 = []byte{ - // 803 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x56, 0xcf, 0x6b, 0xe3,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0x4e, 0x2f, 0x5b, 0xda, 0xd9, 0x65, 0x4b, 0xbb, 0xb8, 0x6c, - 0x69, 0x7f, 0x5c, 0xb5, 0x0a, 0x67, 0x57, 0xad, 0xc2, 0x5f, 0x57, 0xad, 0xc2, 0xfe, 0x5b, 0xe5, - 0x69, 0x4a, 0x1a, 0xbd, 0x8b, 0x88, 0x98, 0x50, 0x36, 0x92, 0x0b, 0xfb, 0x78, 0xe6, 0x53, 0x6e, - 0x58, 0x95, 0xdf, 0x72, 0x5f, 0xfc, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x96, 0xb9, 0x1f, 0xd8, 0x59, - 0x0a, 0x00, 0x00, + // 703 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x5b, 0x4b, 0xdc, 0x40, + 0x14, 0xde, 0x9b, 0xab, 0x7b, 0x76, 0xab, 0xed, 0xb8, 0x6a, 0x4c, 0x6d, 0x5c, 0x63, 0x29, 0x0b, + 0x62, 0x82, 0xdb, 0xb7, 0x42, 0x29, 0x5e, 0x5a, 0xb0, 0xb0, 0xb8, 0x04, 0x4a, 0x41, 0x5a, 0x96, + 0xd9, 0x64, 0x1a, 0xa7, 0x66, 0x33, 0x21, 0x33, 0xde, 0xa0, 0x3f, 0xa2, 0x7f, 0xa9, 0x6f, 0x3e, + 0xfa, 0x58, 0xfa, 0x20, 0x45, 0xfb, 0x43, 0x4a, 0x26, 0xd9, 0x98, 0x5d, 0x6f, 0x60, 0xe9, 0x93, + 0xce, 0xf9, 0xce, 0xf9, 0xbe, 0xef, 0x9c, 0x39, 0xb3, 0x81, 0x3a, 0xf1, 0x4e, 0xb8, 0xd9, 0xc7, + 0xa1, 0x4b, 0x7d, 0x53, 0x1c, 0x1b, 0x41, 0xc8, 0x04, 0x43, 0xd5, 0x28, 0x6a, 0xc4, 0x51, 0xb5, + 0xee, 0x32, 0x97, 0xc9, 0xb8, 0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f, 0x2f, 0xb5, 0xdc, 0xee, 0x4a, 0xe6, 0xed, 0x47, 0x44, 0xab, + 0x3e, 0x11, 0x47, 0x2c, 0xdc, 0x97, 0x07, 0xf3, 0x78, 0xe8, 0x93, 0xd3, 0x2b, 0xcb, 0x6f, 0xce, + 0xcb, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x49, 0x89, 0x09, 0x31, 0x01, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -922,8 +683,6 @@ const _ = grpc.SupportPackageIsVersion4 type MsgClient interface { Open(ctx context.Context, in *MsgOpen, opts ...grpc.CallOption) (*MsgOpenResponse, error) Close(ctx context.Context, in *MsgClose, opts ...grpc.CallOption) (*MsgCloseResponse, error) - BrokerOpen(ctx context.Context, in *MsgBrokerOpen, opts ...grpc.CallOption) (*MsgBrokerOpenResponse, error) - BrokerClose(ctx context.Context, in *MsgBrokerClose, opts ...grpc.CallOption) (*MsgBrokerCloseResponse, error) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) UpdatePools(ctx context.Context, in *MsgUpdatePools, opts ...grpc.CallOption) (*MsgUpdatePoolsResponse, error) Whitelist(ctx context.Context, in *MsgWhitelist, opts ...grpc.CallOption) (*MsgWhitelistResponse, error) @@ -956,24 +715,6 @@ func (c *msgClient) Close(ctx context.Context, in *MsgClose, opts ...grpc.CallOp return out, nil } -func (c *msgClient) BrokerOpen(ctx context.Context, in *MsgBrokerOpen, opts ...grpc.CallOption) (*MsgBrokerOpenResponse, error) { - out := new(MsgBrokerOpenResponse) - err := c.cc.Invoke(ctx, "/elys.margin.Msg/BrokerOpen", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) BrokerClose(ctx context.Context, in *MsgBrokerClose, opts ...grpc.CallOption) (*MsgBrokerCloseResponse, error) { - out := new(MsgBrokerCloseResponse) - err := c.cc.Invoke(ctx, "/elys.margin.Msg/BrokerClose", 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, "/elys.margin.Msg/UpdateParams", in, out, opts...) @@ -1014,8 +755,6 @@ func (c *msgClient) Dewhitelist(ctx context.Context, in *MsgDewhitelist, opts .. type MsgServer interface { Open(context.Context, *MsgOpen) (*MsgOpenResponse, error) Close(context.Context, *MsgClose) (*MsgCloseResponse, error) - BrokerOpen(context.Context, *MsgBrokerOpen) (*MsgBrokerOpenResponse, error) - BrokerClose(context.Context, *MsgBrokerClose) (*MsgBrokerCloseResponse, error) UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) UpdatePools(context.Context, *MsgUpdatePools) (*MsgUpdatePoolsResponse, error) Whitelist(context.Context, *MsgWhitelist) (*MsgWhitelistResponse, error) @@ -1032,12 +771,6 @@ func (*UnimplementedMsgServer) Open(ctx context.Context, req *MsgOpen) (*MsgOpen func (*UnimplementedMsgServer) Close(ctx context.Context, req *MsgClose) (*MsgCloseResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Close not implemented") } -func (*UnimplementedMsgServer) BrokerOpen(ctx context.Context, req *MsgBrokerOpen) (*MsgBrokerOpenResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method BrokerOpen not implemented") -} -func (*UnimplementedMsgServer) BrokerClose(ctx context.Context, req *MsgBrokerClose) (*MsgBrokerCloseResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method BrokerClose not implemented") -} func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") } @@ -1091,42 +824,6 @@ func _Msg_Close_Handler(srv interface{}, ctx context.Context, dec func(interface return interceptor(ctx, in, info, handler) } -func _Msg_BrokerOpen_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgBrokerOpen) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).BrokerOpen(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/elys.margin.Msg/BrokerOpen", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).BrokerOpen(ctx, req.(*MsgBrokerOpen)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_BrokerClose_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgBrokerClose) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).BrokerClose(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/elys.margin.Msg/BrokerClose", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).BrokerClose(ctx, req.(*MsgBrokerClose)) - } - 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 { @@ -1211,14 +908,6 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "Close", Handler: _Msg_Close_Handler, }, - { - MethodName: "BrokerOpen", - Handler: _Msg_BrokerOpen_Handler, - }, - { - MethodName: "BrokerClose", - Handler: _Msg_BrokerClose_Handler, - }, { MethodName: "UpdateParams", Handler: _Msg_UpdateParams_Handler, @@ -1423,7 +1112,7 @@ func (m *MsgCloseResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgBrokerOpen) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateParams) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1433,231 +1122,34 @@ func (m *MsgBrokerOpen) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgBrokerOpen) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgBrokerOpen) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Owner) > 0 { - i -= len(m.Owner) - copy(dAtA[i:], m.Owner) - i = encodeVarintTx(dAtA, i, uint64(len(m.Owner))) - i-- - dAtA[i] = 0x3a - } - { - size := m.TakeProfitPrice.Size() - i -= size - if _, err := m.TakeProfitPrice.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - { - size, err := m.Collateral.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if m.Params != nil { + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 } - i-- - dAtA[i] = 0x2a - if len(m.TradingAsset) > 0 { - i -= len(m.TradingAsset) - copy(dAtA[i:], m.TradingAsset) - i = encodeVarintTx(dAtA, i, uint64(len(m.TradingAsset))) + 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] = 0x22 - } - { - size := m.Leverage.Size() - i -= size - if _, err := m.Leverage.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if m.Position != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Position)) - i-- - dAtA[i] = 0x10 - } - if len(m.Creator) > 0 { - i -= len(m.Creator) - copy(dAtA[i:], m.Creator) - i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgBrokerOpenResponse) 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 *MsgBrokerOpenResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgBrokerOpenResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Id != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Id)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *MsgBrokerClose) 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 *MsgBrokerClose) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgBrokerClose) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.Amount.Size() - i -= size - if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - if len(m.Owner) > 0 { - i -= len(m.Owner) - copy(dAtA[i:], m.Owner) - i = encodeVarintTx(dAtA, i, uint64(len(m.Owner))) - i-- - dAtA[i] = 0x1a - } - if m.Id != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Id)) - i-- - dAtA[i] = 0x10 - } - if len(m.Creator) > 0 { - i -= len(m.Creator) - copy(dAtA[i:], m.Creator) - i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgBrokerCloseResponse) 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 *MsgBrokerCloseResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgBrokerCloseResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.Amount.Size() - i -= size - if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if m.Id != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Id)) - i-- - dAtA[i] = 0x8 - } - 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 - if m.Params != nil { - { - 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 + dAtA[i] = 0xa } return len(dAtA) - i, nil } @@ -1957,84 +1449,6 @@ func (m *MsgCloseResponse) Size() (n int) { return n } -func (m *MsgBrokerOpen) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Creator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.Position != 0 { - n += 1 + sovTx(uint64(m.Position)) - } - l = m.Leverage.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.TradingAsset) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.Collateral.Size() - n += 1 + l + sovTx(uint64(l)) - l = m.TakeProfitPrice.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.Owner) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgBrokerOpenResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Id != 0 { - n += 1 + sovTx(uint64(m.Id)) - } - return n -} - -func (m *MsgBrokerClose) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Creator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.Id != 0 { - n += 1 + sovTx(uint64(m.Id)) - } - l = len(m.Owner) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.Amount.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} - -func (m *MsgBrokerCloseResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Id != 0 { - n += 1 + sovTx(uint64(m.Id)) - } - l = m.Amount.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} - func (m *MsgUpdateParams) Size() (n int) { if m == nil { return 0 @@ -2694,611 +2108,6 @@ func (m *MsgCloseResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgBrokerOpen) 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: MsgBrokerOpen: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgBrokerOpen: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Creator", 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.Creator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Position", wireType) - } - m.Position = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Position |= Position(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Leverage", 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 - } - if err := m.Leverage.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TradingAsset", 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.TradingAsset = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Collateral", 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 err := m.Collateral.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TakeProfitPrice", 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 - } - if err := m.TakeProfitPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Owner", 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.Owner = 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 *MsgBrokerOpenResponse) 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: MsgBrokerOpenResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgBrokerOpenResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - m.Id = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Id |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - 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 *MsgBrokerClose) 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: MsgBrokerClose: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgBrokerClose: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Creator", 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.Creator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - m.Id = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Id |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Owner", 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.Owner = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", 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 - } - if err := m.Amount.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 *MsgBrokerCloseResponse) 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: MsgBrokerCloseResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgBrokerCloseResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - m.Id = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Id |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", 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 - } - if err := m.Amount.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 *MsgUpdateParams) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/oracle/client/wasm/messenger.go b/x/oracle/client/wasm/messenger.go index 7c91b8c8d..fa9ee2693 100644 --- a/x/oracle/client/wasm/messenger.go +++ b/x/oracle/client/wasm/messenger.go @@ -17,16 +17,6 @@ func NewMessenger(keeper *keeper.Keeper) *Messenger { func (m *Messenger) HandleMsg(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmbindingstypes.ElysMsg) ([]sdk.Event, [][]byte, error) { switch { - case msg.OracleFeedPrice != nil: - return m.msgFeedPrice(ctx, contractAddr, msg.OracleFeedPrice) - case msg.OracleFeedMultiplePrices != nil: - return m.msgFeedMultiplePrices(ctx, contractAddr, msg.OracleFeedMultiplePrices) - case msg.OracleRequestBandPrice != nil: - return m.msgRequestBandPrice(ctx, contractAddr, msg.OracleRequestBandPrice) - case msg.OracleSetPriceFeeder != nil: - return m.msgSetPriceFeeder(ctx, contractAddr, msg.OracleSetPriceFeeder) - case msg.OracleDeletePriceFeeder != nil: - return m.msgDeletePriceFeeder(ctx, contractAddr, msg.OracleDeletePriceFeeder) default: // This handler cannot handle the message return nil, nil, wasmbindingstypes.ErrCannotHandleMsg diff --git a/x/oracle/client/wasm/msg_delete_price_feeder.go b/x/oracle/client/wasm/msg_delete_price_feeder.go deleted file mode 100644 index 922b436b3..000000000 --- a/x/oracle/client/wasm/msg_delete_price_feeder.go +++ /dev/null @@ -1,44 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - keeper "github.com/elys-network/elys/x/oracle/keeper" - types "github.com/elys-network/elys/x/oracle/types" -) - -func (m *Messenger) msgDeletePriceFeeder(ctx sdk.Context, contractAddr sdk.AccAddress, msg *types.MsgDeletePriceFeeder) ([]sdk.Event, [][]byte, error) { - if msg == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "DeletePriceFeeder null msg"} - } - - if msg.Feeder != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "delete price feeder wrong sender"} - } - - msgServer := keeper.NewMsgServerImpl(*m.keeper) - - if err := msg.ValidateBasic(); err != nil { - return nil, nil, errorsmod.Wrap(err, "failed validating msg") - } - - res, err := msgServer.DeletePriceFeeder( - sdk.WrapSDKContext(ctx), - msg, - ) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "DeletePriceFeeder msg") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize DeletePriceFeeder response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} diff --git a/x/oracle/client/wasm/msg_feed_multiple_prices.go b/x/oracle/client/wasm/msg_feed_multiple_prices.go deleted file mode 100644 index aed58e41c..000000000 --- a/x/oracle/client/wasm/msg_feed_multiple_prices.go +++ /dev/null @@ -1,44 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - keeper "github.com/elys-network/elys/x/oracle/keeper" - types "github.com/elys-network/elys/x/oracle/types" -) - -func (m *Messenger) msgFeedMultiplePrices(ctx sdk.Context, contractAddr sdk.AccAddress, msg *types.MsgFeedMultiplePrices) ([]sdk.Event, [][]byte, error) { - if msg == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "FeedMultiplePrices null msg"} - } - - if msg.Creator != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "feed multiple prices wrong sender"} - } - - msgServer := keeper.NewMsgServerImpl(*m.keeper) - - if err := msg.ValidateBasic(); err != nil { - return nil, nil, errorsmod.Wrap(err, "failed validating msg") - } - - res, err := msgServer.FeedMultiplePrices( - sdk.WrapSDKContext(ctx), - msg, - ) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "FeedMultiplePrices msg") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize FeedMultiplePrices response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} diff --git a/x/oracle/client/wasm/msg_feed_price.go b/x/oracle/client/wasm/msg_feed_price.go deleted file mode 100644 index 0d99caa7f..000000000 --- a/x/oracle/client/wasm/msg_feed_price.go +++ /dev/null @@ -1,44 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - keeper "github.com/elys-network/elys/x/oracle/keeper" - types "github.com/elys-network/elys/x/oracle/types" -) - -func (m *Messenger) msgFeedPrice(ctx sdk.Context, contractAddr sdk.AccAddress, msg *types.MsgFeedPrice) ([]sdk.Event, [][]byte, error) { - if msg == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "FeedPrice null msg"} - } - - if msg.Provider != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "feed price wrong sender"} - } - - msgServer := keeper.NewMsgServerImpl(*m.keeper) - - if err := msg.ValidateBasic(); err != nil { - return nil, nil, errorsmod.Wrap(err, "failed validating msg") - } - - res, err := msgServer.FeedPrice( - sdk.WrapSDKContext(ctx), - msg, - ) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "FeedPrice msg") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize FeedPrice response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} diff --git a/x/oracle/client/wasm/msg_request_band_price.go b/x/oracle/client/wasm/msg_request_band_price.go deleted file mode 100644 index 433f71c04..000000000 --- a/x/oracle/client/wasm/msg_request_band_price.go +++ /dev/null @@ -1,44 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - keeper "github.com/elys-network/elys/x/oracle/keeper" - types "github.com/elys-network/elys/x/oracle/types" -) - -func (m *Messenger) msgRequestBandPrice(ctx sdk.Context, contractAddr sdk.AccAddress, msg *types.MsgRequestBandPrice) ([]sdk.Event, [][]byte, error) { - if msg == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "RequestBandPrice null msg"} - } - - if msg.Creator != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "request band price wrong sender"} - } - - msgServer := keeper.NewMsgServerImpl(*m.keeper) - - if err := msg.ValidateBasic(); err != nil { - return nil, nil, errorsmod.Wrap(err, "failed validating msg") - } - - res, err := msgServer.RequestBandPrice( - sdk.WrapSDKContext(ctx), - msg, - ) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "RequestBandPrice msg") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize RequestBandPrice response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} diff --git a/x/oracle/client/wasm/msg_set_price_feeder.go b/x/oracle/client/wasm/msg_set_price_feeder.go deleted file mode 100644 index 4f084ed5f..000000000 --- a/x/oracle/client/wasm/msg_set_price_feeder.go +++ /dev/null @@ -1,44 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - keeper "github.com/elys-network/elys/x/oracle/keeper" - types "github.com/elys-network/elys/x/oracle/types" -) - -func (m *Messenger) msgSetPriceFeeder(ctx sdk.Context, contractAddr sdk.AccAddress, msg *types.MsgSetPriceFeeder) ([]sdk.Event, [][]byte, error) { - if msg == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "SetPriceFeeder null msg"} - } - - if msg.Feeder != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "set price feeder wrong sender"} - } - - msgServer := keeper.NewMsgServerImpl(*m.keeper) - - if err := msg.ValidateBasic(); err != nil { - return nil, nil, errorsmod.Wrap(err, "failed validating msg") - } - - res, err := msgServer.SetPriceFeeder( - sdk.WrapSDKContext(ctx), - msg, - ) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "SetPriceFeeder msg") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize SetPriceFeeder response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} diff --git a/x/parameter/client/cli/query.go b/x/parameter/client/cli/query.go index d76ea6c7b..1e9227646 100644 --- a/x/parameter/client/cli/query.go +++ b/x/parameter/client/cli/query.go @@ -25,7 +25,6 @@ func GetQueryCmd(queryRoute string) *cobra.Command { } cmd.AddCommand(CmdQueryParams()) - cmd.AddCommand(CmdListAnteHandlerParam()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/parameter/client/cli/query_ante_handler_param.go b/x/parameter/client/cli/query_ante_handler_param.go deleted file mode 100644 index fb8226dde..000000000 --- a/x/parameter/client/cli/query_ante_handler_param.go +++ /dev/null @@ -1,43 +0,0 @@ -package cli - -import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/elys-network/elys/x/parameter/types" - "github.com/spf13/cobra" -) - -func CmdListAnteHandlerParam() *cobra.Command { - cmd := &cobra.Command{ - Use: "list-ante-handler-param", - Short: "list all ante-handler-param", - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - - pageReq, err := client.ReadPageRequest(cmd.Flags()) - if err != nil { - return err - } - - queryClient := types.NewQueryClient(clientCtx) - - params := &types.QueryAllAnteHandlerParamRequest{ - Pagination: pageReq, - } - - res, err := queryClient.AnteHandlerParamAll(context.Background(), params) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddPaginationFlagsToCmd(cmd, cmd.Use) - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} diff --git a/x/parameter/client/cli/tx.go b/x/parameter/client/cli/tx.go index 29a0b3ffd..01e2593fb 100644 --- a/x/parameter/client/cli/tx.go +++ b/x/parameter/client/cli/tx.go @@ -7,13 +7,9 @@ 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/cosmos/cosmos-sdk/x/gov/client/cli" - "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" // "github.com/cosmos/cosmos-sdk/client/flags" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/parameter/types" ) @@ -35,176 +31,8 @@ func GetTxCmd() *cobra.Command { SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, } - cmd.AddCommand(CmdSubmitUpdateMinCommissionRateProposal()) - cmd.AddCommand(CmdSubmitUpdateMaxVotingPowerProposal()) - cmd.AddCommand(CmdSubmitUpdateMinSelfDelegationProposal()) // this line is used by starport scaffolding # 1 return cmd } - -func CmdSubmitUpdateMinCommissionRateProposal() *cobra.Command { - cmd := &cobra.Command{ - Use: "update-min-commission-rate-proposal [commission]", - Args: cobra.ExactArgs(1), - Short: "Submit an update comission rate proposal", - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - title, err := cmd.Flags().GetString(cli.FlagTitle) - if err != nil { - return err - } - - description, err := cmd.Flags().GetString(cli.FlagDescription) - if err != nil { - return err - } - - content := types.NewProposalUpdateMinCommission( - title, - description, - args[0], - ) - - from := clientCtx.GetFromAddress() - - depositStr, err := cmd.Flags().GetString(cli.FlagDeposit) - if err != nil { - return err - } - deposit, err := sdk.ParseCoinsNormalized(depositStr) - if err != nil { - return err - } - - msg, err := v1beta1.NewMsgSubmitProposal(content, deposit, from) - if err != nil { - return err - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - cmd.Flags().String(cli.FlagTitle, "", "title of proposal") - cmd.Flags().String(cli.FlagDescription, "", "description of proposal") - cmd.Flags().String(cli.FlagDeposit, "", "deposit of proposal") - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func CmdSubmitUpdateMaxVotingPowerProposal() *cobra.Command { - cmd := &cobra.Command{ - Use: "update-max-voting-power-proposal [max_voting_power]", - Args: cobra.ExactArgs(1), - Short: "Submit an update max voting power proposal", - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - title, err := cmd.Flags().GetString(cli.FlagTitle) - if err != nil { - return err - } - - description, err := cmd.Flags().GetString(cli.FlagDescription) - if err != nil { - return err - } - - content := types.NewProposalUpdateMaxVotingPower( - title, - description, - args[0], - ) - - from := clientCtx.GetFromAddress() - - depositStr, err := cmd.Flags().GetString(cli.FlagDeposit) - if err != nil { - return err - } - deposit, err := sdk.ParseCoinsNormalized(depositStr) - if err != nil { - return err - } - - msg, err := v1beta1.NewMsgSubmitProposal(content, deposit, from) - if err != nil { - return err - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - cmd.Flags().String(cli.FlagTitle, "", "title of proposal") - cmd.Flags().String(cli.FlagDescription, "", "description of proposal") - cmd.Flags().String(cli.FlagDeposit, "", "deposit of proposal") - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func CmdSubmitUpdateMinSelfDelegationProposal() *cobra.Command { - cmd := &cobra.Command{ - Use: "update-min-self-delegation-proposal [min_self_delegation]", - Args: cobra.ExactArgs(1), - Short: "Submit an update min self delegation proposal", - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - title, err := cmd.Flags().GetString(cli.FlagTitle) - if err != nil { - return err - } - - description, err := cmd.Flags().GetString(cli.FlagDescription) - if err != nil { - return err - } - - content := types.NewProposalUpdateMinSelfDelegation( - title, - description, - args[0], - ) - - from := clientCtx.GetFromAddress() - - depositStr, err := cmd.Flags().GetString(cli.FlagDeposit) - if err != nil { - return err - } - deposit, err := sdk.ParseCoinsNormalized(depositStr) - if err != nil { - return err - } - - msg, err := v1beta1.NewMsgSubmitProposal(content, deposit, from) - if err != nil { - return err - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - cmd.Flags().String(cli.FlagTitle, "", "title of proposal") - cmd.Flags().String(cli.FlagDescription, "", "description of proposal") - cmd.Flags().String(cli.FlagDeposit, "", "deposit of proposal") - flags.AddTxFlagsToCmd(cmd) - - return cmd -} diff --git a/x/parameter/client/wasm/querier.go b/x/parameter/client/wasm/querier.go index 321b9b9c0..e11d39fcc 100644 --- a/x/parameter/client/wasm/querier.go +++ b/x/parameter/client/wasm/querier.go @@ -21,8 +21,6 @@ func (oq *Querier) HandleQuery(ctx sdk.Context, query wasmbindingstypes.ElysQuer switch { case query.ParameterParams != nil: return oq.queryParams(ctx, query.ParameterParams) - case query.ParameterAnteHandlerParamAll != nil: - return oq.queryAnteHandlerParamAll(ctx, query.ParameterAnteHandlerParamAll) default: // This handler cannot handle the query return nil, wasmbindingstypes.ErrCannotHandleQuery diff --git a/x/parameter/client/wasm/query_ante_handler_param_all.go b/x/parameter/client/wasm/query_ante_handler_param_all.go deleted file mode 100644 index b8a7418c2..000000000 --- a/x/parameter/client/wasm/query_ante_handler_param_all.go +++ /dev/null @@ -1,22 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/x/parameter/types" -) - -func (oq *Querier) queryAnteHandlerParamAll(ctx sdk.Context, query *types.QueryAllAnteHandlerParamRequest) ([]byte, error) { - res, err := oq.keeper.AnteHandlerParamAll(ctx, query) - if err != nil { - return nil, errorsmod.Wrap(err, "failed to get ante handler param all") - } - - responseBytes, err := json.Marshal(res) - if err != nil { - return nil, errorsmod.Wrap(err, "failed to serialize ante handler param all response") - } - return responseBytes, nil -} diff --git a/x/parameter/client/wasm/query_params.go b/x/parameter/client/wasm/query_params.go index 2e4750a52..908811b13 100644 --- a/x/parameter/client/wasm/query_params.go +++ b/x/parameter/client/wasm/query_params.go @@ -9,7 +9,7 @@ import ( ) func (oq *Querier) queryParams(ctx sdk.Context, query *types.QueryParamsRequest) ([]byte, error) { - res, err := oq.keeper.Params(ctx, query) + res, err := oq.keeper.Params(sdk.WrapSDKContext(ctx), query) if err != nil { return nil, errorsmod.Wrap(err, "failed to get params") } diff --git a/x/parameter/genesis.go b/x/parameter/genesis.go index 06719971c..e585f2aa9 100644 --- a/x/parameter/genesis.go +++ b/x/parameter/genesis.go @@ -8,9 +8,6 @@ import ( // InitGenesis initializes the module's state from a provided genesis state. func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { - // Set the anteHandlerParam - k.SetAnteHandlerParam(ctx, genState.AnteHandlerParam) - // this line is used by starport scaffolding # genesis/module/init k.SetParams(ctx, genState.Params) } @@ -20,11 +17,6 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis := types.DefaultGenesis() genesis.Params = k.GetParams(ctx) - anteParam, bfound := k.GetAnteHandlerParam(ctx) - if bfound { - genesis.AnteHandlerParam = anteParam - } - // this line is used by starport scaffolding # genesis/module/export return genesis diff --git a/x/parameter/keeper/keeper.go b/x/parameter/keeper/keeper.go index f03daf98f..4cd6612d8 100644 --- a/x/parameter/keeper/keeper.go +++ b/x/parameter/keeper/keeper.go @@ -7,18 +7,16 @@ import ( "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/cosmos/cosmos-sdk/store/prefix" "github.com/elys-network/elys/x/parameter/types" ) type ( Keeper struct { - cdc codec.BinaryCodec - storeKey storetypes.StoreKey - memKey storetypes.StoreKey - paramstore paramtypes.Subspace + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + authority string } ) @@ -26,49 +24,16 @@ func NewKeeper( cdc codec.BinaryCodec, storeKey, memKey storetypes.StoreKey, - ps paramtypes.Subspace, - + authority string, ) *Keeper { - // set KeyTable if it has not already been set - if !ps.HasKeyTable() { - ps = ps.WithKeyTable(types.ParamKeyTable()) - } - return &Keeper{ - cdc: cdc, - storeKey: storeKey, - memKey: memKey, - paramstore: ps, + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + authority: authority, } } func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } - -// SetAnteHandlerParam set a specific anteHandlerParam in the store from its index -func (k Keeper) SetAnteHandlerParam(ctx sdk.Context, anteHandlerParam types.AnteHandlerParam) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AnteHandlerParamKeyPrefix)) - b := k.cdc.MustMarshal(&anteHandlerParam) - store.Set(types.AnteHandlerParamKey( - types.AnteStoreKey, - ), b) -} - -// GetAnteHandlerParam returns a anteHandlerParam from its index -func (k Keeper) GetAnteHandlerParam( - ctx sdk.Context, - -) (val types.AnteHandlerParam, found bool) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AnteHandlerParamKeyPrefix)) - - b := store.Get(types.AnteHandlerParamKey( - types.AnteStoreKey, - )) - if b == nil { - return val, false - } - - k.cdc.MustUnmarshal(b, &val) - return val, true -} diff --git a/x/parameter/keeper/msg_server.go b/x/parameter/keeper/msg_server.go index d337565e8..a6371b7ed 100644 --- a/x/parameter/keeper/msg_server.go +++ b/x/parameter/keeper/msg_server.go @@ -1,6 +1,11 @@ package keeper import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/elys-network/elys/x/parameter/types" ) @@ -15,3 +20,70 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer { } var _ types.MsgServer = msgServer{} + +func (k msgServer) UpdateMinCommission(goCtx context.Context, msg *types.MsgUpdateMinCommission) (*types.MsgUpdateMinCommissionResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if k.authority != msg.Creator { + return nil, sdkerrors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Creator) + } + + minComission, err := sdk.NewDecFromStr(msg.MinCommission) + if err != nil { + return nil, err + } + + params := k.GetParams(ctx) + params.MinCommissionRate = minComission + k.SetParams(ctx, params) + return &types.MsgUpdateMinCommissionResponse{}, nil +} + +func (k msgServer) UpdateMaxVotingPower(goCtx context.Context, msg *types.MsgUpdateMaxVotingPower) (*types.MsgUpdateMaxVotingPowerResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if k.authority != msg.Creator { + return nil, sdkerrors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Creator) + } + + maxVotingPower, err := sdk.NewDecFromStr(msg.MaxVotingPower) + if err != nil { + return nil, err + } + + params := k.GetParams(ctx) + params.MaxVotingPower = maxVotingPower + k.SetParams(ctx, params) + return &types.MsgUpdateMaxVotingPowerResponse{}, nil +} + +func (k msgServer) UpdateMinSelfDelegation(goCtx context.Context, msg *types.MsgUpdateMinSelfDelegation) (*types.MsgUpdateMinSelfDelegationResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if k.authority != msg.Creator { + return nil, sdkerrors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Creator) + } + + minSelfDelegation, ok := sdk.NewIntFromString(msg.MinSelfDelegation) + if !ok { + return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "minimum self delegation must be a positive integer") + } + + params := k.GetParams(ctx) + params.MinSelfDelegation = minSelfDelegation + k.SetParams(ctx, params) + return &types.MsgUpdateMinSelfDelegationResponse{}, nil +} + +func (k msgServer) UpdateBrokerAddress(goCtx context.Context, msg *types.MsgUpdateBrokerAddress) (*types.MsgUpdateBrokerAddressResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if k.authority != msg.Creator { + return nil, sdkerrors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Creator) + } + + params := k.GetParams(ctx) + params.BrokerAddress = msg.BrokerAddress + k.SetParams(ctx, params) + return &types.MsgUpdateBrokerAddressResponse{}, nil +} diff --git a/x/parameter/keeper/params.go b/x/parameter/keeper/params.go index 842081bf2..7c81ec2de 100644 --- a/x/parameter/keeper/params.go +++ b/x/parameter/keeper/params.go @@ -6,11 +6,21 @@ import ( ) // GetParams get all parameters as types.Params -func (k Keeper) GetParams(ctx sdk.Context) types.Params { - return types.NewParams() +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + store := ctx.KVStore(k.storeKey) + + b := store.Get([]byte(types.ParamsKey)) + if b == nil { + return + } + + k.cdc.MustUnmarshal(b, ¶ms) + return } // SetParams set the params func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { - k.paramstore.SetParamSet(ctx, ¶ms) + store := ctx.KVStore(k.storeKey) + b := k.cdc.MustMarshal(¶ms) + store.Set([]byte(types.ParamsKey), b) } diff --git a/x/parameter/keeper/query_ante_handler_param.go b/x/parameter/keeper/query_ante_handler_param.go deleted file mode 100644 index 3d1d36c2c..000000000 --- a/x/parameter/keeper/query_ante_handler_param.go +++ /dev/null @@ -1,40 +0,0 @@ -package keeper - -import ( - "context" - - "github.com/cosmos/cosmos-sdk/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/query" - "github.com/elys-network/elys/x/parameter/types" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -func (k Keeper) AnteHandlerParamAll(goCtx context.Context, req *types.QueryAllAnteHandlerParamRequest) (*types.QueryAllAnteHandlerParamResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - var anteHandlerParams []types.AnteHandlerParam - ctx := sdk.UnwrapSDKContext(goCtx) - - store := ctx.KVStore(k.storeKey) - anteHandlerParamStore := prefix.NewStore(store, types.KeyPrefix(types.AnteHandlerParamKeyPrefix)) - - pageRes, err := query.Paginate(anteHandlerParamStore, req.Pagination, func(key []byte, value []byte) error { - var anteHandlerParam types.AnteHandlerParam - if err := k.cdc.Unmarshal(value, &anteHandlerParam); err != nil { - return err - } - - anteHandlerParams = append(anteHandlerParams, anteHandlerParam) - return nil - }) - - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - - return &types.QueryAllAnteHandlerParamResponse{AnteHandlerParam: anteHandlerParams, Pagination: pageRes}, nil -} diff --git a/x/parameter/migrations/new_migrator.go b/x/parameter/migrations/new_migrator.go new file mode 100644 index 000000000..4fbf43f71 --- /dev/null +++ b/x/parameter/migrations/new_migrator.go @@ -0,0 +1,13 @@ +package migrations + +import ( + "github.com/elys-network/elys/x/parameter/keeper" +) + +type Migrator struct { + keeper keeper.Keeper +} + +func NewMigrator(keeper keeper.Keeper) Migrator { + return Migrator{keeper: keeper} +} diff --git a/x/parameter/migrations/v2_migration.go b/x/parameter/migrations/v2_migration.go new file mode 100644 index 000000000..e0b83fff5 --- /dev/null +++ b/x/parameter/migrations/v2_migration.go @@ -0,0 +1,17 @@ +package migrations + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/parameter/types" +) + +func (m Migrator) V2Migration(ctx sdk.Context) error { + params := types.NewParams( + sdk.NewDecWithPrec(5, 2), // min commission 0.05 + sdk.NewDecWithPrec(66, 1), // max voting power + sdk.NewInt(1), // min self delegation + "elys1mx32w9tnfxv0z5j000750h8ver7qf3xpj09w3uzvsr3hq68f4hxqte4gam", // broker address + ) + m.keeper.SetParams(ctx, params) + return nil +} diff --git a/x/parameter/module.go b/x/parameter/module.go index 41f944ce9..6b352cf24 100644 --- a/x/parameter/module.go +++ b/x/parameter/module.go @@ -19,6 +19,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" "github.com/elys-network/elys/x/parameter/client/cli" "github.com/elys-network/elys/x/parameter/keeper" + "github.com/elys-network/elys/x/parameter/migrations" "github.com/elys-network/elys/x/parameter/types" ) @@ -115,6 +116,11 @@ func NewAppModule( func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + m := migrations.NewMigrator(am.keeper) + err := cfg.RegisterMigration(types.ModuleName, 1, m.V2Migration) + if err != nil { + panic(err) + } } // RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) @@ -138,7 +144,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 -func (AppModule) ConsensusVersion() uint64 { return 1 } +func (AppModule) ConsensusVersion() uint64 { return 2 } // BeginBlock contains the logic that is automatically triggered at the beginning of each block func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} diff --git a/x/parameter/proposal_handler.go b/x/parameter/proposal_handler.go deleted file mode 100644 index 0bfe52f24..000000000 --- a/x/parameter/proposal_handler.go +++ /dev/null @@ -1,76 +0,0 @@ -package parameter - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - "github.com/elys-network/elys/x/parameter/keeper" - "github.com/elys-network/elys/x/parameter/types" -) - -func NewParameterChangeProposalHandler(k *keeper.Keeper) govtypes.Handler { - return func(ctx sdk.Context, content govtypes.Content) error { - switch c := content.(type) { - case *types.ProposalUpdateMinCommission: - return handleUpdateMinCommission(ctx, k, c) - case *types.ProposalUpdateMaxVotingPower: - return handleUpdateMaxVotingPower(ctx, k, c) - case *types.ProposalUpdateMinSelfDelegation: - return handleUpdateMinSelfDelegation(ctx, k, c) - - default: - return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized software upgrade proposal content type: %T", c) - } - } -} - -// Update min commission -func handleUpdateMinCommission(ctx sdk.Context, k *keeper.Keeper, p *types.ProposalUpdateMinCommission) error { - minComission, err := sdk.NewDecFromStr(p.MinCommission) - if err != nil { - return err - } - - params, bfound := k.GetAnteHandlerParam(ctx) - if !bfound { - return nil - } - params.MinCommissionRate = minComission - k.SetAnteHandlerParam(ctx, params) - - return nil -} - -// Update max voting power -func handleUpdateMaxVotingPower(ctx sdk.Context, k *keeper.Keeper, p *types.ProposalUpdateMaxVotingPower) error { - maxVotingPower, err := sdk.NewDecFromStr(p.MaxVotingPower) - if err != nil { - return err - } - - params, bfound := k.GetAnteHandlerParam(ctx) - if !bfound { - return nil - } - params.MaxVotingPower = maxVotingPower - k.SetAnteHandlerParam(ctx, params) - - return nil -} - -// Update min self delegation -func handleUpdateMinSelfDelegation(ctx sdk.Context, k *keeper.Keeper, p *types.ProposalUpdateMinSelfDelegation) error { - minSelfDelegation, ok := sdk.NewIntFromString(p.MinSelfDelegation) - if !ok { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "minimum self delegation must be a positive integer") - } - - params, bfound := k.GetAnteHandlerParam(ctx) - if !bfound { - return nil - } - params.MinSelfDelegation = minSelfDelegation - k.SetAnteHandlerParam(ctx, params) - - return nil -} diff --git a/x/parameter/types/ante_handler_param.pb.go b/x/parameter/types/ante_handler_param.pb.go deleted file mode 100644 index 5e3181592..000000000 --- a/x/parameter/types/ante_handler_param.pb.go +++ /dev/null @@ -1,419 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: elys/parameter/ante_handler_param.proto - -package types - -import ( - fmt "fmt" - _ "github.com/cosmos/cosmos-sdk/types" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/gogoproto/gogoproto" - 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 - -type AnteHandlerParam struct { - MinCommissionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=min_commission_rate,json=minCommissionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_commission_rate"` - MaxVotingPower github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=max_voting_power,json=maxVotingPower,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_voting_power"` - MinSelfDelegation github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=min_self_delegation,json=minSelfDelegation,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_self_delegation"` -} - -func (m *AnteHandlerParam) Reset() { *m = AnteHandlerParam{} } -func (m *AnteHandlerParam) String() string { return proto.CompactTextString(m) } -func (*AnteHandlerParam) ProtoMessage() {} -func (*AnteHandlerParam) Descriptor() ([]byte, []int) { - return fileDescriptor_61ae17167f40c52b, []int{0} -} -func (m *AnteHandlerParam) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *AnteHandlerParam) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_AnteHandlerParam.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 *AnteHandlerParam) XXX_Merge(src proto.Message) { - xxx_messageInfo_AnteHandlerParam.Merge(m, src) -} -func (m *AnteHandlerParam) XXX_Size() int { - return m.Size() -} -func (m *AnteHandlerParam) XXX_DiscardUnknown() { - xxx_messageInfo_AnteHandlerParam.DiscardUnknown(m) -} - -var xxx_messageInfo_AnteHandlerParam proto.InternalMessageInfo - -func init() { - proto.RegisterType((*AnteHandlerParam)(nil), "elys.parameter.AnteHandlerParam") -} - -func init() { - proto.RegisterFile("elys/parameter/ante_handler_param.proto", fileDescriptor_61ae17167f40c52b) -} - -var fileDescriptor_61ae17167f40c52b = []byte{ - // 320 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x91, 0xbd, 0x4e, 0x3a, 0x41, - 0x14, 0xc5, 0x77, 0xf9, 0x27, 0xff, 0xc4, 0x2d, 0x08, 0xa2, 0x05, 0xa1, 0x58, 0x8c, 0x85, 0xda, - 0xb0, 0x13, 0xe2, 0x13, 0x88, 0x14, 0xd8, 0x11, 0x4c, 0x8c, 0xb1, 0x70, 0x32, 0xbb, 0x5c, 0x96, - 0x09, 0x3b, 0x73, 0x37, 0x33, 0x57, 0x3e, 0xde, 0xc2, 0x07, 0xf1, 0x41, 0x28, 0x29, 0x8d, 0x05, - 0x31, 0xf0, 0x22, 0x66, 0x67, 0x95, 0xd0, 0x6a, 0x35, 0x1f, 0xf7, 0xe4, 0x77, 0x4e, 0xee, 0x09, - 0x2e, 0x21, 0x5b, 0x5a, 0x96, 0x0b, 0x23, 0x14, 0x10, 0x18, 0x26, 0x34, 0x01, 0x9f, 0x08, 0x3d, - 0xca, 0xc0, 0x70, 0xf7, 0x1d, 0xe5, 0x06, 0x09, 0xeb, 0xd5, 0x42, 0x18, 0xed, 0x85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x68, 0x8e, 0x66, 0xea, 0x1e, 0x6c, 0x71, 0xd0, 0xa8, 0x33, 0x88, 0xff, 0xbb, - 0xfd, 0x5f, 0x7f, 0x05, 0x00, 0x00, 0xff, 0xff, 0x4b, 0x36, 0x82, 0xe2, 0xf0, 0x01, 0x00, 0x00, -} - -func (m *AnteHandlerParam) 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 *AnteHandlerParam) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *AnteHandlerParam) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.MinSelfDelegation.Size() - i -= size - if _, err := m.MinSelfDelegation.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintAnteHandlerParam(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - { - size := m.MaxVotingPower.Size() - i -= size - if _, err := m.MaxVotingPower.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintAnteHandlerParam(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size := m.MinCommissionRate.Size() - i -= size - if _, err := m.MinCommissionRate.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintAnteHandlerParam(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func encodeVarintAnteHandlerParam(dAtA []byte, offset int, v uint64) int { - offset -= sovAnteHandlerParam(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *AnteHandlerParam) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.MinCommissionRate.Size() - n += 1 + l + sovAnteHandlerParam(uint64(l)) - l = m.MaxVotingPower.Size() - n += 1 + l + sovAnteHandlerParam(uint64(l)) - l = m.MinSelfDelegation.Size() - n += 1 + l + sovAnteHandlerParam(uint64(l)) - return n -} - -func sovAnteHandlerParam(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozAnteHandlerParam(x uint64) (n int) { - return sovAnteHandlerParam(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *AnteHandlerParam) 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 ErrIntOverflowAnteHandlerParam - } - 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: AnteHandlerParam: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: AnteHandlerParam: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MinCommissionRate", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAnteHandlerParam - } - 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 ErrInvalidLengthAnteHandlerParam - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAnteHandlerParam - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MinCommissionRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxVotingPower", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAnteHandlerParam - } - 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 ErrInvalidLengthAnteHandlerParam - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAnteHandlerParam - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MaxVotingPower.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MinSelfDelegation", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAnteHandlerParam - } - 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 ErrInvalidLengthAnteHandlerParam - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAnteHandlerParam - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MinSelfDelegation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAnteHandlerParam(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAnteHandlerParam - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipAnteHandlerParam(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, ErrIntOverflowAnteHandlerParam - } - 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, ErrIntOverflowAnteHandlerParam - } - 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, ErrIntOverflowAnteHandlerParam - } - 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, ErrInvalidLengthAnteHandlerParam - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupAnteHandlerParam - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthAnteHandlerParam - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthAnteHandlerParam = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowAnteHandlerParam = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupAnteHandlerParam = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/parameter/types/codec.go b/x/parameter/types/codec.go index d0aa4917e..aaf7e6103 100644 --- a/x/parameter/types/codec.go +++ b/x/parameter/types/codec.go @@ -3,23 +3,27 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" // this line is used by starport scaffolding # 1 "github.com/cosmos/cosmos-sdk/types/msgservice" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) func RegisterCodec(cdc *codec.LegacyAmino) { // this line is used by starport scaffolding # 2 + cdc.RegisterConcrete(&MsgUpdateMinCommission{}, "parameter/MsgUpdateMinCommission", nil) + cdc.RegisterConcrete(&MsgUpdateMaxVotingPower{}, "parameter/MsgUpdateMaxVotingPower", nil) + cdc.RegisterConcrete(&MsgUpdateMinSelfDelegation{}, "parameter/MsgUpdateMinSelfDelegation", nil) + cdc.RegisterConcrete(&MsgUpdateBrokerAddress{}, "parameter/MsgUpdateBrokerAddress", nil) + // this line is used by starport scaffolding # 2 } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { - - registry.RegisterImplementations( - (*govtypes.Content)(nil), - &ProposalUpdateMinCommission{}, - &ProposalUpdateMaxVotingPower{}, - &ProposalUpdateMinSelfDelegation{}, + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgUpdateMinCommission{}, + &MsgUpdateMaxVotingPower{}, + &MsgUpdateMinSelfDelegation{}, + &MsgUpdateBrokerAddress{}, ) // this line is used by starport scaffolding # 3 diff --git a/x/parameter/types/genesis.go b/x/parameter/types/genesis.go index b646afbe3..f2689b73b 100644 --- a/x/parameter/types/genesis.go +++ b/x/parameter/types/genesis.go @@ -1,21 +1,11 @@ package types -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) - // DefaultIndex is the default global index const DefaultIndex uint64 = 1 // DefaultGenesis returns the default genesis state func DefaultGenesis() *GenesisState { - anteParam := AnteHandlerParam{ - MinCommissionRate: sdk.NewDecWithPrec(5, 2), - MaxVotingPower: sdk.NewDecWithPrec(66, 1), - MinSelfDelegation: sdk.NewInt(1)} - return &GenesisState{ - AnteHandlerParam: anteParam, // this line is used by starport scaffolding # genesis/types/default Params: DefaultParams(), } diff --git a/x/parameter/types/genesis.pb.go b/x/parameter/types/genesis.pb.go index 2482a1cdf..e45d8583b 100644 --- a/x/parameter/types/genesis.pb.go +++ b/x/parameter/types/genesis.pb.go @@ -25,8 +25,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the parameter module's genesis state. type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - AnteHandlerParam AnteHandlerParam `protobuf:"bytes,2,opt,name=ante_handler_param,json=anteHandlerParam,proto3" json:"ante_handler_param"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -69,13 +68,6 @@ func (m *GenesisState) GetParams() Params { return Params{} } -func (m *GenesisState) GetAnteHandlerParam() AnteHandlerParam { - if m != nil { - return m.AnteHandlerParam - } - return AnteHandlerParam{} -} - func init() { proto.RegisterType((*GenesisState)(nil), "elys.parameter.GenesisState") } @@ -83,23 +75,19 @@ func init() { func init() { proto.RegisterFile("elys/parameter/genesis.proto", fileDescriptor_854dcce2a04e2574) } var fileDescriptor_854dcce2a04e2574 = []byte{ - // 241 bytes of a gzipped FileDescriptorProto + // 191 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x49, 0xcd, 0xa9, 0x2c, 0xd6, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x4d, 0x2d, 0x49, 0x2d, 0xd2, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x03, 0xc9, 0xea, 0xc1, 0x65, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x52, 0xfa, 0x20, 0x16, 0x44, 0x95, 0x94, 0x34, 0x9a, 0x19, - 0x60, 0x16, 0xd4, 0x08, 0x29, 0x75, 0x34, 0xc9, 0xc4, 0xbc, 0x92, 0xd4, 0xf8, 0x8c, 0xc4, 0xbc, - 0x94, 0x9c, 0xd4, 0xa2, 0x78, 0xb0, 0x30, 0x44, 0xa1, 0xd2, 0x2c, 0x46, 0x2e, 0x1e, 0x77, 0x88, - 0xed, 0xc1, 0x25, 0x89, 0x25, 0xa9, 0x42, 0x26, 0x5c, 0x6c, 0x10, 0x93, 0x24, 0x18, 0x15, 0x18, - 0x35, 0xb8, 0x8d, 0xc4, 0xf4, 0x50, 0x5d, 0xa3, 0x17, 0x00, 0x96, 0x75, 0x62, 0x39, 0x71, 0x4f, - 0x9e, 0x21, 0x08, 0xaa, 0x56, 0x28, 0x84, 0x4b, 0x08, 0xd3, 0x0a, 0x09, 0x26, 0xb0, 0x09, 0x0a, - 0xe8, 0x26, 0x38, 0xe6, 0x95, 0xa4, 0x7a, 0x40, 0x14, 0x82, 0x0d, 0x83, 0x9a, 0x25, 0x90, 0x88, - 0x2e, 0xee, 0x71, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, - 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x7a, 0xe9, 0x99, - 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x20, 0xd3, 0x75, 0xf3, 0x52, 0x4b, 0xca, - 0xf3, 0x8b, 0xb2, 0xc1, 0x1c, 0xfd, 0x0a, 0x24, 0x9f, 0x97, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, - 0x81, 0x7d, 0x6b, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xc4, 0x48, 0xe3, 0x8b, 0x79, 0x01, 0x00, - 0x00, + 0x60, 0x16, 0xd4, 0x08, 0x25, 0x17, 0x2e, 0x1e, 0x77, 0x88, 0x99, 0xc1, 0x25, 0x89, 0x25, 0xa9, + 0x42, 0x26, 0x5c, 0x6c, 0x10, 0x79, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x31, 0x3d, 0x54, + 0x3b, 0xf4, 0x02, 0xc0, 0xb2, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, 0xd5, 0x3a, 0x79, + 0x9c, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, + 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x5e, 0x7a, 0x66, 0x49, 0x46, + 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xc8, 0x24, 0xdd, 0xbc, 0xd4, 0x92, 0xf2, 0xfc, 0xa2, + 0x6c, 0x30, 0x47, 0xbf, 0x02, 0xc9, 0x59, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x67, + 0x19, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xd9, 0xfc, 0x1e, 0xaa, 0xf9, 0x00, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -122,16 +110,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size, err := m.AnteHandlerParam.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 { size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -164,8 +142,6 @@ func (m *GenesisState) Size() (n int) { _ = l l = m.Params.Size() n += 1 + l + sovGenesis(uint64(l)) - l = m.AnteHandlerParam.Size() - n += 1 + l + sovGenesis(uint64(l)) return n } @@ -237,39 +213,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AnteHandlerParam", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.AnteHandlerParam.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/parameter/types/keys.go b/x/parameter/types/keys.go index 6306c15ce..4c398cad3 100644 --- a/x/parameter/types/keys.go +++ b/x/parameter/types/keys.go @@ -15,10 +15,8 @@ const ( // MemStoreKey defines the in-memory store key MemStoreKey = "mem_parameter" - // AnteHandlerParamKeyPrefix is the prefix to retrieve all AnteHandlerParam - AnteHandlerParamKeyPrefix = "AnteHandlerParam/value/" - - AnteStoreKey = "ante-handler-param" + // ParamsKey is the prefix to retrieve all Params + ParamsKey = "Params/value/" ) const ( @@ -58,16 +56,3 @@ var _ binary.ByteOrder func KeyPrefix(p string) []byte { return []byte(p) } - -// AnteHandlerParamKey returns the store key to retrieve a AnteHandlerParam from the index fields -func AnteHandlerParamKey( - index string, -) []byte { - var key []byte - - indexBytes := []byte(index) - key = append(key, indexBytes...) - key = append(key, []byte("/")...) - - return key -} diff --git a/x/parameter/types/msgs.go b/x/parameter/types/msgs.go new file mode 100644 index 000000000..8a11af0ee --- /dev/null +++ b/x/parameter/types/msgs.go @@ -0,0 +1,106 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +var _ sdk.Msg = &MsgUpdateMinCommission{} + +func NewMsgExitPool(creator string, minCommission string) *MsgUpdateMinCommission { + return &MsgUpdateMinCommission{ + Creator: creator, + MinCommission: minCommission, + } +} + +func (msg *MsgUpdateMinCommission) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} + +func (msg *MsgUpdateMinCommission) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address (%s)", err) + } + return nil +} + +var _ sdk.Msg = &MsgUpdateMinCommission{} + +func NewMsgUpdateMaxVotingPower(creator string, maxVotingPower string) *MsgUpdateMaxVotingPower { + return &MsgUpdateMaxVotingPower{ + Creator: creator, + MaxVotingPower: maxVotingPower, + } +} + +func (msg *MsgUpdateMaxVotingPower) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} + +func (msg *MsgUpdateMaxVotingPower) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address (%s)", err) + } + return nil +} + +var _ sdk.Msg = &MsgUpdateMinCommission{} + +func NewMsgUpdateMinSelfDelegation(creator string, minSelfDelegation string) *MsgUpdateMinSelfDelegation { + return &MsgUpdateMinSelfDelegation{ + Creator: creator, + MinSelfDelegation: minSelfDelegation, + } +} + +func (msg *MsgUpdateMinSelfDelegation) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} + +func (msg *MsgUpdateMinSelfDelegation) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address (%s)", err) + } + return nil +} + +var _ sdk.Msg = &MsgUpdateBrokerAddress{} + +func NewMsgUpdateBrokerAddress(creator string, brokerAddress string) *MsgUpdateBrokerAddress { + return &MsgUpdateBrokerAddress{ + Creator: creator, + BrokerAddress: brokerAddress, + } +} + +func (msg *MsgUpdateBrokerAddress) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} + +func (msg *MsgUpdateBrokerAddress) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address (%s)", err) + } + return nil +} diff --git a/x/parameter/types/params.go b/x/parameter/types/params.go index 357196ad6..d0b1e0891 100644 --- a/x/parameter/types/params.go +++ b/x/parameter/types/params.go @@ -1,30 +1,28 @@ package types import ( - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + sdk "github.com/cosmos/cosmos-sdk/types" "gopkg.in/yaml.v2" ) -var _ paramtypes.ParamSet = (*Params)(nil) - -// ParamKeyTable the param key table for launch module -func ParamKeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) -} - // NewParams creates a new Params instance -func NewParams() Params { - return Params{} +func NewParams(minCommissionRate sdk.Dec, maxVotingPower sdk.Dec, minSelfDelegation sdk.Int, brokerAddress string) Params { + return Params{ + MinCommissionRate: minCommissionRate, + MaxVotingPower: maxVotingPower, + MinSelfDelegation: minSelfDelegation, + BrokerAddress: brokerAddress, + } } // DefaultParams returns a default set of parameters func DefaultParams() Params { - return NewParams() -} - -// ParamSetPairs get the params.ParamSet -func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{} + return NewParams( + sdk.NewDecWithPrec(5, 2), + sdk.NewDec(100), + sdk.OneInt(), + "", + ) } // Validate validates the set of params diff --git a/x/parameter/types/params.pb.go b/x/parameter/types/params.pb.go index 99469b4cc..aa540c1dc 100644 --- a/x/parameter/types/params.pb.go +++ b/x/parameter/types/params.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -25,6 +26,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { + MinCommissionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=min_commission_rate,json=minCommissionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_commission_rate"` + MaxVotingPower github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=max_voting_power,json=maxVotingPower,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_voting_power"` + MinSelfDelegation github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=min_self_delegation,json=minSelfDelegation,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_self_delegation"` + BrokerAddress string `protobuf:"bytes,4,opt,name=broker_address,json=brokerAddress,proto3" json:"broker_address,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -59,6 +64,13 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo +func (m *Params) GetBrokerAddress() string { + if m != nil { + return m.BrokerAddress + } + return "" +} + func init() { proto.RegisterType((*Params)(nil), "elys.parameter.Params") } @@ -66,17 +78,27 @@ func init() { func init() { proto.RegisterFile("elys/parameter/params.proto", fileDescriptor_b61780a5be327c2b) } var fileDescriptor_b61780a5be327c2b = []byte{ - // 148 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4e, 0xcd, 0xa9, 0x2c, - 0xd6, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x4d, 0x2d, 0x49, 0x2d, 0x82, 0xb0, 0x8a, 0xf5, 0x0a, 0x8a, - 0xf2, 0x4b, 0xf2, 0x85, 0xf8, 0x40, 0x92, 0x7a, 0x70, 0x49, 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, - 0xb0, 0x94, 0x3e, 0x88, 0x05, 0x51, 0xa5, 0xc4, 0xc7, 0xc5, 0x16, 0x00, 0xd6, 0x65, 0xc5, 0x32, - 0x63, 0x81, 0x3c, 0x83, 0x93, 0xc7, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, - 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, - 0xe9, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x83, 0x8c, 0xd6, 0xcd, - 0x4b, 0x2d, 0x29, 0xcf, 0x2f, 0xca, 0x06, 0x73, 0xf4, 0x2b, 0x90, 0x9c, 0x51, 0x52, 0x59, 0x90, - 0x5a, 0x9c, 0xc4, 0x06, 0xb6, 0xc0, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xdd, 0xab, 0x8d, - 0xa5, 0x00, 0x00, 0x00, + // 316 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x91, 0x31, 0x4b, 0xc3, 0x40, + 0x14, 0xc7, 0x93, 0x5a, 0x0a, 0x06, 0x2c, 0x1a, 0x1d, 0x82, 0x42, 0x2a, 0x82, 0xe2, 0xd2, 0xcb, + 0xe0, 0xe6, 0x66, 0xed, 0xa0, 0x5b, 0xa9, 0x20, 0xe2, 0xe0, 0x71, 0x4d, 0x5e, 0xe3, 0xd1, 0xdc, + 0xbd, 0x70, 0x77, 0xda, 0xf6, 0x5b, 0x38, 0x3a, 0xfa, 0x71, 0xba, 0xd9, 0x51, 0x1c, 0x8a, 0xb4, + 0x5f, 0x44, 0x72, 0xd1, 0xd0, 0x55, 0xa7, 0x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xfa, 0xeb, 0x5b, + 0xcb, 0xe9, 0x5c, 0xcd, 0x96, 0xa1, 0x3b, 0x5f, 0x86, 0xee, 0xd7, 0x32, 0x74, 0x5f, 0x56, 0xa1, + 0x33, 0x5f, 0x85, 0xce, 0xc7, 0x2a, 0x74, 0xee, 0xc9, 0x9a, 0x41, 0x51, 0x4e, 0x5b, 0x82, 0x19, + 0xa3, 0x1a, 0xd9, 0x4b, 0x34, 0x59, 0x2b, 0xd2, 0xda, 0x0c, 0x1a, 0xb6, 0xa2, 0xb3, 0xef, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xe2, 0x79, 0x2a, 0x74, 0xe7, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -99,6 +121,43 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.BrokerAddress) > 0 { + i -= len(m.BrokerAddress) + copy(dAtA[i:], m.BrokerAddress) + i = encodeVarintParams(dAtA, i, uint64(len(m.BrokerAddress))) + i-- + dAtA[i] = 0x22 + } + { + size := m.MinSelfDelegation.Size() + i -= size + if _, err := m.MinSelfDelegation.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.MaxVotingPower.Size() + i -= size + if _, err := m.MaxVotingPower.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.MinCommissionRate.Size() + i -= size + if _, err := m.MinCommissionRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -119,6 +178,16 @@ func (m *Params) Size() (n int) { } var l int _ = l + l = m.MinCommissionRate.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.MaxVotingPower.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.MinSelfDelegation.Size() + n += 1 + l + sovParams(uint64(l)) + l = len(m.BrokerAddress) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } return n } @@ -157,6 +226,140 @@ func (m *Params) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinCommissionRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinCommissionRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxVotingPower", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MaxVotingPower.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinSelfDelegation", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinSelfDelegation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BrokerAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BrokerAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/parameter/types/proposal.go b/x/parameter/types/proposal.go deleted file mode 100644 index 0021863ce..000000000 --- a/x/parameter/types/proposal.go +++ /dev/null @@ -1,117 +0,0 @@ -package types - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" -) - -const ( - ProposalTypeUpdateMinCommissionRate string = "UpdateMinCommissionRate" - ProposalTypeUpdateMaxVotingPower string = "UpdateMaxVotingPower" - ProposalTypeUpdateMinSelfDelegation string = "UpdateMinSelfDelegation" -) - -func init() { - gov.RegisterProposalType(ProposalTypeUpdateMinCommissionRate) - gov.RegisterProposalType(ProposalTypeUpdateMaxVotingPower) - gov.RegisterProposalType(ProposalTypeUpdateMinSelfDelegation) -} - -// NewProposalUpdateMinCommission creates a new ProposalUpdateMinCommission instance -func NewProposalUpdateMinCommission( - title, description string, - minCommission string, -) gov.Content { - return &ProposalUpdateMinCommission{ - Title: title, - Description: description, - MinCommission: minCommission, - } -} - -// Implements Proposal Interface -var _ gov.Content = &ProposalUpdateMinCommission{} - -// ProposalRoute gets the proposal's router key -func (sup *ProposalUpdateMinCommission) ProposalRoute() string { return RouterKey } - -// ProposalType is "SoftwareUpgrade" -func (sup *ProposalUpdateMinCommission) ProposalType() string { - return ProposalTypeUpdateMinCommissionRate -} - -// ValidateBasic validates the proposal -func (sup *ProposalUpdateMinCommission) ValidateBasic() error { - _, err := sdk.NewDecFromStr(sup.MinCommission) - if err != nil { - return err - } - // sup.MinCommission - return gov.ValidateAbstract(sup) -} - -// NewProposalUpdateMaxVotingPower creates a new ProposalUpdateMaxVotingPower instance -func NewProposalUpdateMaxVotingPower( - title, description string, - maxVotingPower string, -) gov.Content { - return &ProposalUpdateMaxVotingPower{ - Title: title, - Description: description, - MaxVotingPower: maxVotingPower, - } -} - -// Implements Proposal Interface -var _ gov.Content = &ProposalUpdateMaxVotingPower{} - -// ProposalRoute gets the proposal's router key -func (sup *ProposalUpdateMaxVotingPower) ProposalRoute() string { return RouterKey } - -// ProposalType is "SoftwareUpgrade" -func (sup *ProposalUpdateMaxVotingPower) ProposalType() string { - return ProposalTypeUpdateMaxVotingPower -} - -// ValidateBasic validates the proposal -func (sup *ProposalUpdateMaxVotingPower) ValidateBasic() error { - _, err := sdk.NewDecFromStr(sup.MaxVotingPower) - if err != nil { - return err - } - return gov.ValidateAbstract(sup) -} - -// NewProposalUpdateMinSelfDelegation creates a new NewProposalUpdateMinSelfDelegation instance -func NewProposalUpdateMinSelfDelegation( - title, description string, - minSelfDelegation string, -) gov.Content { - return &ProposalUpdateMinSelfDelegation{ - Title: title, - Description: description, - MinSelfDelegation: minSelfDelegation, - } -} - -// Implements Proposal Interface -var _ gov.Content = &ProposalUpdateMinSelfDelegation{} - -// ProposalRoute gets the proposal's router key -func (sup *ProposalUpdateMinSelfDelegation) ProposalRoute() string { return RouterKey } - -// ProposalType is "SoftwareUpgrade" -func (sup *ProposalUpdateMinSelfDelegation) ProposalType() string { - return ProposalTypeUpdateMinSelfDelegation -} - -// ValidateBasic validates the proposal -func (sup *ProposalUpdateMinSelfDelegation) ValidateBasic() error { - _, ok := sdk.NewIntFromString(sup.MinSelfDelegation) - if !ok { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "minimum self delegation must be a positive integer") - } - - return gov.ValidateAbstract(sup) -} diff --git a/x/parameter/types/proposal.pb.go b/x/parameter/types/proposal.pb.go deleted file mode 100644 index db128853f..000000000 --- a/x/parameter/types/proposal.pb.go +++ /dev/null @@ -1,969 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: elys/parameter/proposal.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 - -type ProposalUpdateMinCommission struct { - Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` - Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` - MinCommission string `protobuf:"bytes,3,opt,name=min_commission,json=minCommission,proto3" json:"min_commission,omitempty"` -} - -func (m *ProposalUpdateMinCommission) Reset() { *m = ProposalUpdateMinCommission{} } -func (m *ProposalUpdateMinCommission) String() string { return proto.CompactTextString(m) } -func (*ProposalUpdateMinCommission) ProtoMessage() {} -func (*ProposalUpdateMinCommission) Descriptor() ([]byte, []int) { - return fileDescriptor_f9a4532402d67c8f, []int{0} -} -func (m *ProposalUpdateMinCommission) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ProposalUpdateMinCommission) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ProposalUpdateMinCommission.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 *ProposalUpdateMinCommission) XXX_Merge(src proto.Message) { - xxx_messageInfo_ProposalUpdateMinCommission.Merge(m, src) -} -func (m *ProposalUpdateMinCommission) XXX_Size() int { - return m.Size() -} -func (m *ProposalUpdateMinCommission) XXX_DiscardUnknown() { - xxx_messageInfo_ProposalUpdateMinCommission.DiscardUnknown(m) -} - -var xxx_messageInfo_ProposalUpdateMinCommission proto.InternalMessageInfo - -func (m *ProposalUpdateMinCommission) GetTitle() string { - if m != nil { - return m.Title - } - return "" -} - -func (m *ProposalUpdateMinCommission) GetDescription() string { - if m != nil { - return m.Description - } - return "" -} - -func (m *ProposalUpdateMinCommission) GetMinCommission() string { - if m != nil { - return m.MinCommission - } - return "" -} - -type ProposalUpdateMaxVotingPower struct { - Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` - Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` - MaxVotingPower string `protobuf:"bytes,3,opt,name=max_voting_power,json=maxVotingPower,proto3" json:"max_voting_power,omitempty"` -} - -func (m *ProposalUpdateMaxVotingPower) Reset() { *m = ProposalUpdateMaxVotingPower{} } -func (m *ProposalUpdateMaxVotingPower) String() string { return proto.CompactTextString(m) } -func (*ProposalUpdateMaxVotingPower) ProtoMessage() {} -func (*ProposalUpdateMaxVotingPower) Descriptor() ([]byte, []int) { - return fileDescriptor_f9a4532402d67c8f, []int{1} -} -func (m *ProposalUpdateMaxVotingPower) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ProposalUpdateMaxVotingPower) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ProposalUpdateMaxVotingPower.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 *ProposalUpdateMaxVotingPower) XXX_Merge(src proto.Message) { - xxx_messageInfo_ProposalUpdateMaxVotingPower.Merge(m, src) -} -func (m *ProposalUpdateMaxVotingPower) XXX_Size() int { - return m.Size() -} -func (m *ProposalUpdateMaxVotingPower) XXX_DiscardUnknown() { - xxx_messageInfo_ProposalUpdateMaxVotingPower.DiscardUnknown(m) -} - -var xxx_messageInfo_ProposalUpdateMaxVotingPower proto.InternalMessageInfo - -func (m *ProposalUpdateMaxVotingPower) GetTitle() string { - if m != nil { - return m.Title - } - return "" -} - -func (m *ProposalUpdateMaxVotingPower) GetDescription() string { - if m != nil { - return m.Description - } - return "" -} - -func (m *ProposalUpdateMaxVotingPower) GetMaxVotingPower() string { - if m != nil { - return m.MaxVotingPower - } - return "" -} - -type ProposalUpdateMinSelfDelegation struct { - Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` - Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` - MinSelfDelegation string `protobuf:"bytes,3,opt,name=min_self_delegation,json=minSelfDelegation,proto3" json:"min_self_delegation,omitempty"` -} - -func (m *ProposalUpdateMinSelfDelegation) Reset() { *m = ProposalUpdateMinSelfDelegation{} } -func (m *ProposalUpdateMinSelfDelegation) String() string { return proto.CompactTextString(m) } -func (*ProposalUpdateMinSelfDelegation) ProtoMessage() {} -func (*ProposalUpdateMinSelfDelegation) Descriptor() ([]byte, []int) { - return fileDescriptor_f9a4532402d67c8f, []int{2} -} -func (m *ProposalUpdateMinSelfDelegation) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ProposalUpdateMinSelfDelegation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ProposalUpdateMinSelfDelegation.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 *ProposalUpdateMinSelfDelegation) XXX_Merge(src proto.Message) { - xxx_messageInfo_ProposalUpdateMinSelfDelegation.Merge(m, src) -} -func (m *ProposalUpdateMinSelfDelegation) XXX_Size() int { - return m.Size() -} -func (m *ProposalUpdateMinSelfDelegation) XXX_DiscardUnknown() { - xxx_messageInfo_ProposalUpdateMinSelfDelegation.DiscardUnknown(m) -} - -var xxx_messageInfo_ProposalUpdateMinSelfDelegation proto.InternalMessageInfo - -func (m *ProposalUpdateMinSelfDelegation) GetTitle() string { - if m != nil { - return m.Title - } - return "" -} - -func (m *ProposalUpdateMinSelfDelegation) GetDescription() string { - if m != nil { - return m.Description - } - return "" -} - -func (m *ProposalUpdateMinSelfDelegation) GetMinSelfDelegation() string { - if m != nil { - return m.MinSelfDelegation - } - return "" -} - -func init() { - proto.RegisterType((*ProposalUpdateMinCommission)(nil), "elys.parameter.ProposalUpdateMinCommission") - proto.RegisterType((*ProposalUpdateMaxVotingPower)(nil), "elys.parameter.ProposalUpdateMaxVotingPower") - proto.RegisterType((*ProposalUpdateMinSelfDelegation)(nil), "elys.parameter.ProposalUpdateMinSelfDelegation") -} - -func init() { proto.RegisterFile("elys/parameter/proposal.proto", fileDescriptor_f9a4532402d67c8f) } - -var fileDescriptor_f9a4532402d67c8f = []byte{ - // 297 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x91, 0xbf, 0x4a, 0xf4, 0x40, - 0x14, 0xc5, 0x77, 0xbe, 0x0f, 0x05, 0x47, 0x0c, 0x1a, 0x2d, 0x02, 0xea, 0xb8, 0x04, 0x84, 0x6d, - 0x4c, 0x0a, 0xdf, 0x40, 0x2d, 0x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58, 0xe0, 0xd3, 0x24, - 0xeb, 0x70, 0xed, 0x23, 0x5b, 0x62, 0xd9, 0xe7, 0xe4, 0xfc, 0xad, 0x24, 0x68, 0x51, 0x12, 0xf4, - 0x51, 0x12, 0xf4, 0x5a, 0x91, 0xc1, 0xa2, 0x22, 0x83, 0xf7, 0x8a, 0x0c, 0x6e, 0xa3, 0x9c, 0xb9, - 0xbb, 0x87, 0x49, 0x94, 0x2a, 0x11, 0xd7, 0x0d, 0x1e, 0x49, 0x70, 0x33, 0x65, 0xee, 0x9b, 0x21, - 0x2e, 0x7a, 0x7d, 0xbb, 0xb9, 0x06, 0x3b, 0x59, 0x6d, 0xda, 0x3e, 0xfe, 0x0c, 0x00, 0x00, 0xff, - 0xff, 0xac, 0x87, 0x6d, 0x07, 0x0e, 0x02, 0x00, 0x00, -} - -func (m *ProposalUpdateMinCommission) 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 *ProposalUpdateMinCommission) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ProposalUpdateMinCommission) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.MinCommission) > 0 { - i -= len(m.MinCommission) - copy(dAtA[i:], m.MinCommission) - i = encodeVarintProposal(dAtA, i, uint64(len(m.MinCommission))) - i-- - dAtA[i] = 0x1a - } - if len(m.Description) > 0 { - i -= len(m.Description) - copy(dAtA[i:], m.Description) - i = encodeVarintProposal(dAtA, i, uint64(len(m.Description))) - i-- - dAtA[i] = 0x12 - } - if len(m.Title) > 0 { - i -= len(m.Title) - copy(dAtA[i:], m.Title) - i = encodeVarintProposal(dAtA, i, uint64(len(m.Title))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ProposalUpdateMaxVotingPower) 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 *ProposalUpdateMaxVotingPower) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ProposalUpdateMaxVotingPower) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.MaxVotingPower) > 0 { - i -= len(m.MaxVotingPower) - copy(dAtA[i:], m.MaxVotingPower) - i = encodeVarintProposal(dAtA, i, uint64(len(m.MaxVotingPower))) - i-- - dAtA[i] = 0x1a - } - if len(m.Description) > 0 { - i -= len(m.Description) - copy(dAtA[i:], m.Description) - i = encodeVarintProposal(dAtA, i, uint64(len(m.Description))) - i-- - dAtA[i] = 0x12 - } - if len(m.Title) > 0 { - i -= len(m.Title) - copy(dAtA[i:], m.Title) - i = encodeVarintProposal(dAtA, i, uint64(len(m.Title))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ProposalUpdateMinSelfDelegation) 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 *ProposalUpdateMinSelfDelegation) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ProposalUpdateMinSelfDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.MinSelfDelegation) > 0 { - i -= len(m.MinSelfDelegation) - copy(dAtA[i:], m.MinSelfDelegation) - i = encodeVarintProposal(dAtA, i, uint64(len(m.MinSelfDelegation))) - i-- - dAtA[i] = 0x1a - } - if len(m.Description) > 0 { - i -= len(m.Description) - copy(dAtA[i:], m.Description) - i = encodeVarintProposal(dAtA, i, uint64(len(m.Description))) - i-- - dAtA[i] = 0x12 - } - if len(m.Title) > 0 { - i -= len(m.Title) - copy(dAtA[i:], m.Title) - i = encodeVarintProposal(dAtA, i, uint64(len(m.Title))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintProposal(dAtA []byte, offset int, v uint64) int { - offset -= sovProposal(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *ProposalUpdateMinCommission) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Title) - if l > 0 { - n += 1 + l + sovProposal(uint64(l)) - } - l = len(m.Description) - if l > 0 { - n += 1 + l + sovProposal(uint64(l)) - } - l = len(m.MinCommission) - if l > 0 { - n += 1 + l + sovProposal(uint64(l)) - } - return n -} - -func (m *ProposalUpdateMaxVotingPower) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Title) - if l > 0 { - n += 1 + l + sovProposal(uint64(l)) - } - l = len(m.Description) - if l > 0 { - n += 1 + l + sovProposal(uint64(l)) - } - l = len(m.MaxVotingPower) - if l > 0 { - n += 1 + l + sovProposal(uint64(l)) - } - return n -} - -func (m *ProposalUpdateMinSelfDelegation) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Title) - if l > 0 { - n += 1 + l + sovProposal(uint64(l)) - } - l = len(m.Description) - if l > 0 { - n += 1 + l + sovProposal(uint64(l)) - } - l = len(m.MinSelfDelegation) - if l > 0 { - n += 1 + l + sovProposal(uint64(l)) - } - return n -} - -func sovProposal(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozProposal(x uint64) (n int) { - return sovProposal(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *ProposalUpdateMinCommission) 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 ErrIntOverflowProposal - } - 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: ProposalUpdateMinCommission: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ProposalUpdateMinCommission: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProposal - } - 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 ErrInvalidLengthProposal - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProposal - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Title = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProposal - } - 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 ErrInvalidLengthProposal - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProposal - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Description = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MinCommission", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProposal - } - 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 ErrInvalidLengthProposal - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProposal - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.MinCommission = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProposal(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProposal - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ProposalUpdateMaxVotingPower) 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 ErrIntOverflowProposal - } - 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: ProposalUpdateMaxVotingPower: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ProposalUpdateMaxVotingPower: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProposal - } - 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 ErrInvalidLengthProposal - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProposal - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Title = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProposal - } - 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 ErrInvalidLengthProposal - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProposal - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Description = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxVotingPower", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProposal - } - 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 ErrInvalidLengthProposal - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProposal - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.MaxVotingPower = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProposal(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProposal - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ProposalUpdateMinSelfDelegation) 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 ErrIntOverflowProposal - } - 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: ProposalUpdateMinSelfDelegation: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ProposalUpdateMinSelfDelegation: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProposal - } - 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 ErrInvalidLengthProposal - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProposal - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Title = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProposal - } - 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 ErrInvalidLengthProposal - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProposal - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Description = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MinSelfDelegation", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProposal - } - 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 ErrInvalidLengthProposal - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProposal - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.MinSelfDelegation = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProposal(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProposal - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipProposal(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, ErrIntOverflowProposal - } - 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, ErrIntOverflowProposal - } - 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, ErrIntOverflowProposal - } - 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, ErrInvalidLengthProposal - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupProposal - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthProposal - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthProposal = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowProposal = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupProposal = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/parameter/types/query.pb.go b/x/parameter/types/query.pb.go index 5361f5b98..1cfe0187a 100644 --- a/x/parameter/types/query.pb.go +++ b/x/parameter/types/query.pb.go @@ -6,7 +6,6 @@ package types import ( context "context" fmt "fmt" - 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" @@ -113,141 +112,32 @@ func (m *QueryParamsResponse) GetParams() Params { return Params{} } -type QueryAllAnteHandlerParamRequest struct { - Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` -} - -func (m *QueryAllAnteHandlerParamRequest) Reset() { *m = QueryAllAnteHandlerParamRequest{} } -func (m *QueryAllAnteHandlerParamRequest) String() string { return proto.CompactTextString(m) } -func (*QueryAllAnteHandlerParamRequest) ProtoMessage() {} -func (*QueryAllAnteHandlerParamRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_8d15aa9fdb9a1470, []int{2} -} -func (m *QueryAllAnteHandlerParamRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryAllAnteHandlerParamRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryAllAnteHandlerParamRequest.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 *QueryAllAnteHandlerParamRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAllAnteHandlerParamRequest.Merge(m, src) -} -func (m *QueryAllAnteHandlerParamRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryAllAnteHandlerParamRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAllAnteHandlerParamRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryAllAnteHandlerParamRequest proto.InternalMessageInfo - -func (m *QueryAllAnteHandlerParamRequest) GetPagination() *query.PageRequest { - if m != nil { - return m.Pagination - } - return nil -} - -type QueryAllAnteHandlerParamResponse struct { - AnteHandlerParam []AnteHandlerParam `protobuf:"bytes,1,rep,name=ante_handler_param,json=anteHandlerParam,proto3" json:"ante_handler_param"` - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` -} - -func (m *QueryAllAnteHandlerParamResponse) Reset() { *m = QueryAllAnteHandlerParamResponse{} } -func (m *QueryAllAnteHandlerParamResponse) String() string { return proto.CompactTextString(m) } -func (*QueryAllAnteHandlerParamResponse) ProtoMessage() {} -func (*QueryAllAnteHandlerParamResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_8d15aa9fdb9a1470, []int{3} -} -func (m *QueryAllAnteHandlerParamResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryAllAnteHandlerParamResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryAllAnteHandlerParamResponse.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 *QueryAllAnteHandlerParamResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAllAnteHandlerParamResponse.Merge(m, src) -} -func (m *QueryAllAnteHandlerParamResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryAllAnteHandlerParamResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAllAnteHandlerParamResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryAllAnteHandlerParamResponse proto.InternalMessageInfo - -func (m *QueryAllAnteHandlerParamResponse) GetAnteHandlerParam() []AnteHandlerParam { - if m != nil { - return m.AnteHandlerParam - } - return nil -} - -func (m *QueryAllAnteHandlerParamResponse) GetPagination() *query.PageResponse { - if m != nil { - return m.Pagination - } - return nil -} - func init() { proto.RegisterType((*QueryParamsRequest)(nil), "elys.parameter.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "elys.parameter.QueryParamsResponse") - proto.RegisterType((*QueryAllAnteHandlerParamRequest)(nil), "elys.parameter.QueryAllAnteHandlerParamRequest") - proto.RegisterType((*QueryAllAnteHandlerParamResponse)(nil), "elys.parameter.QueryAllAnteHandlerParamResponse") } func init() { proto.RegisterFile("elys/parameter/query.proto", fileDescriptor_8d15aa9fdb9a1470) } var fileDescriptor_8d15aa9fdb9a1470 = []byte{ - // 448 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0x3d, 0x8f, 0xd3, 0x30, - 0x18, 0x8e, 0x0b, 0x74, 0xf0, 0x49, 0x08, 0xf9, 0x4e, 0xe8, 0x14, 0x50, 0x2e, 0xca, 0x09, 0xae, - 0x02, 0x61, 0xd3, 0x82, 0xc4, 0xdc, 0x0e, 0x50, 0x89, 0xa5, 0x54, 0x4c, 0x2c, 0x95, 0x53, 0x5e, - 0xa5, 0x11, 0xa9, 0x9d, 0xc6, 0x2e,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3, 0xa1, 0x1c, 0xef, 0x20, 0x7d, 0xbb, 0x46, 0xab, 0x67, 0x39, 0xa8, 0xb8, 0x6e, 0x7e, - 0x90, 0x07, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0x17, 0x5b, 0x2e, 0xf4, 0xf4, 0x03, 0x00, 0x00, + // 269 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4a, 0xcd, 0xa9, 0x2c, + 0xd6, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x4d, 0x2d, 0x49, 0x2d, 0xd2, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, + 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x03, 0xc9, 0xe9, 0xc1, 0xe5, 0xa4, 0x44, 0xd2, + 0xf3, 0xd3, 0xf3, 0xc1, 0x52, 0xfa, 0x20, 0x16, 0x44, 0x95, 0x94, 0x4c, 0x7a, 0x7e, 0x7e, 0x7a, + 0x4e, 0xaa, 0x7e, 0x62, 0x41, 0xa6, 0x7e, 0x62, 0x5e, 0x5e, 0x7e, 0x49, 0x62, 0x49, 0x66, 0x7e, + 0x5e, 0x31, 0x54, 0x56, 0x1a, 0xcd, 0x7c, 0x30, 0x0b, 0x2a, 0xa9, 0x24, 0xc2, 0x25, 0x14, 0x08, + 0xb2, 0x2f, 0x00, 0x2c, 0x18, 0x94, 0x5a, 0x58, 0x9a, 0x5a, 0x5c, 0xa2, 0xe4, 0xcd, 0x25, 0x8c, + 0x22, 0x5a, 0x5c, 0x90, 0x9f, 0x57, 0x9c, 0x2a, 0x64, 0xc2, 0xc5, 0x06, 0xd1, 0x2c, 0xc1, 0xa8, + 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xa6, 0x87, 0xea, 0x3c, 0x3d, 0x88, 0x7a, 0x27, 0x96, 0x13, 0xf7, + 0xe4, 0x19, 0x82, 0xa0, 0x6a, 0x8d, 0xda, 0x19, 0xb9, 0x58, 0xc1, 0xa6, 0x09, 0xd5, 0x71, 0xb1, + 0x41, 0x54, 0x08, 0x29, 0xa1, 0xeb, 0xc4, 0x74, 0x84, 0x94, 0x32, 0x5e, 0x35, 0x10, 0x27, 0x29, + 0x69, 0x37, 0x5d, 0x7e, 0x32, 0x99, 0x49, 0x55, 0x48, 0x59, 0x1f, 0xa4, 0x58, 0x37, 0x2f, 0xb5, + 0xa4, 0x3c, 0xbf, 0x28, 0x5b, 0x1f, 0xab, 0x97, 0x9d, 0x3c, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, + 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, + 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x2f, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x17, + 0x8b, 0x41, 0x15, 0x48, 0x46, 0x95, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x43, 0xcf, 0x18, + 0x10, 0x00, 0x00, 0xff, 0xff, 0x16, 0x0c, 0x21, 0x5c, 0xbc, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -264,7 +154,6 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Parameters queries the parameters of the module. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) - AnteHandlerParamAll(ctx context.Context, in *QueryAllAnteHandlerParamRequest, opts ...grpc.CallOption) (*QueryAllAnteHandlerParamResponse, error) } type queryClient struct { @@ -284,20 +173,10 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . return out, nil } -func (c *queryClient) AnteHandlerParamAll(ctx context.Context, in *QueryAllAnteHandlerParamRequest, opts ...grpc.CallOption) (*QueryAllAnteHandlerParamResponse, error) { - out := new(QueryAllAnteHandlerParamResponse) - err := c.cc.Invoke(ctx, "/elys.parameter.Query/AnteHandlerParamAll", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) - AnteHandlerParamAll(context.Context, *QueryAllAnteHandlerParamRequest) (*QueryAllAnteHandlerParamResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -307,9 +186,6 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } -func (*UnimplementedQueryServer) AnteHandlerParamAll(ctx context.Context, req *QueryAllAnteHandlerParamRequest) (*QueryAllAnteHandlerParamResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AnteHandlerParamAll not implemented") -} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -333,24 +209,6 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } -func _Query_AnteHandlerParamAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryAllAnteHandlerParamRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).AnteHandlerParamAll(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/elys.parameter.Query/AnteHandlerParamAll", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).AnteHandlerParamAll(ctx, req.(*QueryAllAnteHandlerParamRequest)) - } - return interceptor(ctx, in, info, handler) -} - var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "elys.parameter.Query", HandlerType: (*QueryServer)(nil), @@ -359,10 +217,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Params", Handler: _Query_Params_Handler, }, - { - MethodName: "AnteHandlerParamAll", - Handler: _Query_AnteHandlerParamAll_Handler, - }, }, Streams: []grpc.StreamDesc{}, Metadata: "elys/parameter/query.proto", @@ -424,90 +278,6 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryAllAnteHandlerParamRequest) 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 *QueryAllAnteHandlerParamRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryAllAnteHandlerParamRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = 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 -} - -func (m *QueryAllAnteHandlerParamResponse) 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 *QueryAllAnteHandlerParamResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryAllAnteHandlerParamResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = 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] = 0x12 - } - if len(m.AnteHandlerParam) > 0 { - for iNdEx := len(m.AnteHandlerParam) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.AnteHandlerParam[iNdEx].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 encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -539,38 +309,6 @@ func (m *QueryParamsResponse) Size() (n int) { return n } -func (m *QueryAllAnteHandlerParamRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryAllAnteHandlerParamResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.AnteHandlerParam) > 0 { - for _, e := range m.AnteHandlerParam { - 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 sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -710,212 +448,6 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAllAnteHandlerParamRequest) 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: QueryAllAnteHandlerParamRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllAnteHandlerParamRequest: 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:]) - 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 *QueryAllAnteHandlerParamResponse) 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: QueryAllAnteHandlerParamResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllAnteHandlerParamResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AnteHandlerParam", 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.AnteHandlerParam = append(m.AnteHandlerParam, AnteHandlerParam{}) - if err := m.AnteHandlerParam[len(m.AnteHandlerParam)-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 skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/parameter/types/query.pb.gw.go b/x/parameter/types/query.pb.gw.go index e185b865c..b076ffb76 100644 --- a/x/parameter/types/query.pb.gw.go +++ b/x/parameter/types/query.pb.gw.go @@ -51,42 +51,6 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal } -var ( - filter_Query_AnteHandlerParamAll_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_AnteHandlerParamAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAllAnteHandlerParamRequest - 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_AnteHandlerParamAll_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.AnteHandlerParamAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_AnteHandlerParamAll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAllAnteHandlerParamRequest - 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_AnteHandlerParamAll_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.AnteHandlerParamAll(ctx, &protoReq) - return msg, metadata, err - -} - // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -116,29 +80,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_AnteHandlerParamAll_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_AnteHandlerParamAll_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_AnteHandlerParamAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - return nil } @@ -200,37 +141,13 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_AnteHandlerParamAll_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_AnteHandlerParamAll_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_AnteHandlerParamAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - return nil } var ( pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"elys-network", "elys", "parameter", "params"}, "", runtime.AssumeColonVerbOpt(true))) - - pattern_Query_AnteHandlerParamAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"elys-network", "elys", "parameter", "ante_handler_param"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( forward_Query_Params_0 = runtime.ForwardResponseMessage - - forward_Query_AnteHandlerParamAll_0 = runtime.ForwardResponseMessage ) diff --git a/x/parameter/types/tx.pb.go b/x/parameter/types/tx.pb.go index 06e73fdc2..7df69fe5a 100644 --- a/x/parameter/types/tx.pb.go +++ b/x/parameter/types/tx.pb.go @@ -9,7 +9,11 @@ import ( grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" math "math" + math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. @@ -23,18 +27,399 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +type MsgUpdateMinCommission struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + MinCommission string `protobuf:"bytes,2,opt,name=min_commission,json=minCommission,proto3" json:"min_commission,omitempty"` +} + +func (m *MsgUpdateMinCommission) Reset() { *m = MsgUpdateMinCommission{} } +func (m *MsgUpdateMinCommission) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateMinCommission) ProtoMessage() {} +func (*MsgUpdateMinCommission) Descriptor() ([]byte, []int) { + return fileDescriptor_9d997b2afb1f3cab, []int{0} +} +func (m *MsgUpdateMinCommission) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateMinCommission) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateMinCommission.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 *MsgUpdateMinCommission) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateMinCommission.Merge(m, src) +} +func (m *MsgUpdateMinCommission) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateMinCommission) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateMinCommission.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateMinCommission proto.InternalMessageInfo + +func (m *MsgUpdateMinCommission) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgUpdateMinCommission) GetMinCommission() string { + if m != nil { + return m.MinCommission + } + return "" +} + +type MsgUpdateMinCommissionResponse struct { +} + +func (m *MsgUpdateMinCommissionResponse) Reset() { *m = MsgUpdateMinCommissionResponse{} } +func (m *MsgUpdateMinCommissionResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateMinCommissionResponse) ProtoMessage() {} +func (*MsgUpdateMinCommissionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9d997b2afb1f3cab, []int{1} +} +func (m *MsgUpdateMinCommissionResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateMinCommissionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateMinCommissionResponse.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 *MsgUpdateMinCommissionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateMinCommissionResponse.Merge(m, src) +} +func (m *MsgUpdateMinCommissionResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateMinCommissionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateMinCommissionResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateMinCommissionResponse proto.InternalMessageInfo + +type MsgUpdateMaxVotingPower struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + MaxVotingPower string `protobuf:"bytes,3,opt,name=max_voting_power,json=maxVotingPower,proto3" json:"max_voting_power,omitempty"` +} + +func (m *MsgUpdateMaxVotingPower) Reset() { *m = MsgUpdateMaxVotingPower{} } +func (m *MsgUpdateMaxVotingPower) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateMaxVotingPower) ProtoMessage() {} +func (*MsgUpdateMaxVotingPower) Descriptor() ([]byte, []int) { + return fileDescriptor_9d997b2afb1f3cab, []int{2} +} +func (m *MsgUpdateMaxVotingPower) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateMaxVotingPower) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateMaxVotingPower.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 *MsgUpdateMaxVotingPower) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateMaxVotingPower.Merge(m, src) +} +func (m *MsgUpdateMaxVotingPower) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateMaxVotingPower) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateMaxVotingPower.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateMaxVotingPower proto.InternalMessageInfo + +func (m *MsgUpdateMaxVotingPower) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgUpdateMaxVotingPower) GetMaxVotingPower() string { + if m != nil { + return m.MaxVotingPower + } + return "" +} + +type MsgUpdateMaxVotingPowerResponse struct { +} + +func (m *MsgUpdateMaxVotingPowerResponse) Reset() { *m = MsgUpdateMaxVotingPowerResponse{} } +func (m *MsgUpdateMaxVotingPowerResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateMaxVotingPowerResponse) ProtoMessage() {} +func (*MsgUpdateMaxVotingPowerResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9d997b2afb1f3cab, []int{3} +} +func (m *MsgUpdateMaxVotingPowerResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateMaxVotingPowerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateMaxVotingPowerResponse.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 *MsgUpdateMaxVotingPowerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateMaxVotingPowerResponse.Merge(m, src) +} +func (m *MsgUpdateMaxVotingPowerResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateMaxVotingPowerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateMaxVotingPowerResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateMaxVotingPowerResponse proto.InternalMessageInfo + +type MsgUpdateMinSelfDelegation struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + MinSelfDelegation string `protobuf:"bytes,3,opt,name=min_self_delegation,json=minSelfDelegation,proto3" json:"min_self_delegation,omitempty"` +} + +func (m *MsgUpdateMinSelfDelegation) Reset() { *m = MsgUpdateMinSelfDelegation{} } +func (m *MsgUpdateMinSelfDelegation) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateMinSelfDelegation) ProtoMessage() {} +func (*MsgUpdateMinSelfDelegation) Descriptor() ([]byte, []int) { + return fileDescriptor_9d997b2afb1f3cab, []int{4} +} +func (m *MsgUpdateMinSelfDelegation) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateMinSelfDelegation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateMinSelfDelegation.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 *MsgUpdateMinSelfDelegation) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateMinSelfDelegation.Merge(m, src) +} +func (m *MsgUpdateMinSelfDelegation) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateMinSelfDelegation) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateMinSelfDelegation.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateMinSelfDelegation proto.InternalMessageInfo + +func (m *MsgUpdateMinSelfDelegation) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgUpdateMinSelfDelegation) GetMinSelfDelegation() string { + if m != nil { + return m.MinSelfDelegation + } + return "" +} + +type MsgUpdateMinSelfDelegationResponse struct { +} + +func (m *MsgUpdateMinSelfDelegationResponse) Reset() { *m = MsgUpdateMinSelfDelegationResponse{} } +func (m *MsgUpdateMinSelfDelegationResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateMinSelfDelegationResponse) ProtoMessage() {} +func (*MsgUpdateMinSelfDelegationResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9d997b2afb1f3cab, []int{5} +} +func (m *MsgUpdateMinSelfDelegationResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateMinSelfDelegationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateMinSelfDelegationResponse.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 *MsgUpdateMinSelfDelegationResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateMinSelfDelegationResponse.Merge(m, src) +} +func (m *MsgUpdateMinSelfDelegationResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateMinSelfDelegationResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateMinSelfDelegationResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateMinSelfDelegationResponse proto.InternalMessageInfo + +type MsgUpdateBrokerAddress struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + BrokerAddress string `protobuf:"bytes,3,opt,name=broker_address,json=brokerAddress,proto3" json:"broker_address,omitempty"` +} + +func (m *MsgUpdateBrokerAddress) Reset() { *m = MsgUpdateBrokerAddress{} } +func (m *MsgUpdateBrokerAddress) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateBrokerAddress) ProtoMessage() {} +func (*MsgUpdateBrokerAddress) Descriptor() ([]byte, []int) { + return fileDescriptor_9d997b2afb1f3cab, []int{6} +} +func (m *MsgUpdateBrokerAddress) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateBrokerAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateBrokerAddress.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 *MsgUpdateBrokerAddress) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateBrokerAddress.Merge(m, src) +} +func (m *MsgUpdateBrokerAddress) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateBrokerAddress) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateBrokerAddress.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateBrokerAddress proto.InternalMessageInfo + +func (m *MsgUpdateBrokerAddress) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgUpdateBrokerAddress) GetBrokerAddress() string { + if m != nil { + return m.BrokerAddress + } + return "" +} + +type MsgUpdateBrokerAddressResponse struct { +} + +func (m *MsgUpdateBrokerAddressResponse) Reset() { *m = MsgUpdateBrokerAddressResponse{} } +func (m *MsgUpdateBrokerAddressResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateBrokerAddressResponse) ProtoMessage() {} +func (*MsgUpdateBrokerAddressResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9d997b2afb1f3cab, []int{7} +} +func (m *MsgUpdateBrokerAddressResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateBrokerAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateBrokerAddressResponse.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 *MsgUpdateBrokerAddressResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateBrokerAddressResponse.Merge(m, src) +} +func (m *MsgUpdateBrokerAddressResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateBrokerAddressResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateBrokerAddressResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateBrokerAddressResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgUpdateMinCommission)(nil), "elys.parameter.MsgUpdateMinCommission") + proto.RegisterType((*MsgUpdateMinCommissionResponse)(nil), "elys.parameter.MsgUpdateMinCommissionResponse") + proto.RegisterType((*MsgUpdateMaxVotingPower)(nil), "elys.parameter.MsgUpdateMaxVotingPower") + proto.RegisterType((*MsgUpdateMaxVotingPowerResponse)(nil), "elys.parameter.MsgUpdateMaxVotingPowerResponse") + proto.RegisterType((*MsgUpdateMinSelfDelegation)(nil), "elys.parameter.MsgUpdateMinSelfDelegation") + proto.RegisterType((*MsgUpdateMinSelfDelegationResponse)(nil), "elys.parameter.MsgUpdateMinSelfDelegationResponse") + proto.RegisterType((*MsgUpdateBrokerAddress)(nil), "elys.parameter.MsgUpdateBrokerAddress") + proto.RegisterType((*MsgUpdateBrokerAddressResponse)(nil), "elys.parameter.MsgUpdateBrokerAddressResponse") +} + func init() { proto.RegisterFile("elys/parameter/tx.proto", fileDescriptor_9d997b2afb1f3cab) } var fileDescriptor_9d997b2afb1f3cab = []byte{ - // 128 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4f, 0xcd, 0xa9, 0x2c, - 0xd6, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x4d, 0x2d, 0x49, 0x2d, 0xd2, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, - 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x03, 0x49, 0xe8, 0xc1, 0x25, 0x8c, 0x58, 0xb9, 0x98, 0x7d, 0x8b, - 0xd3, 0x9d, 0x3c, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, - 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x2f, 0x3d, - 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0xa4, 0x57, 0x37, 0x2f, 0xb5, 0xa4, - 0x3c, 0xbf, 0x28, 0x1b, 0xcc, 0xd1, 0xaf, 0x40, 0xb6, 0xa3, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, - 0x6c, 0x8f, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xbe, 0x9a, 0x90, 0x0f, 0x82, 0x00, 0x00, 0x00, + // 408 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0xdf, 0x6a, 0xdb, 0x30, + 0x18, 0xc5, 0xe3, 0x05, 0x36, 0x26, 0x48, 0xd8, 0x9c, 0xb1, 0x18, 0x5f, 0x78, 0x99, 0xd9, 0x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0x00, 0xff, 0xff, + 0xdd, 0x88, 0xed, 0x25, 0x58, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -49,6 +434,10 @@ 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 { + UpdateMinCommission(ctx context.Context, in *MsgUpdateMinCommission, opts ...grpc.CallOption) (*MsgUpdateMinCommissionResponse, error) + UpdateMaxVotingPower(ctx context.Context, in *MsgUpdateMaxVotingPower, opts ...grpc.CallOption) (*MsgUpdateMaxVotingPowerResponse, error) + UpdateMinSelfDelegation(ctx context.Context, in *MsgUpdateMinSelfDelegation, opts ...grpc.CallOption) (*MsgUpdateMinSelfDelegationResponse, error) + UpdateBrokerAddress(ctx context.Context, in *MsgUpdateBrokerAddress, opts ...grpc.CallOption) (*MsgUpdateBrokerAddressResponse, error) } type msgClient struct { @@ -59,22 +448,1266 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } +func (c *msgClient) UpdateMinCommission(ctx context.Context, in *MsgUpdateMinCommission, opts ...grpc.CallOption) (*MsgUpdateMinCommissionResponse, error) { + out := new(MsgUpdateMinCommissionResponse) + err := c.cc.Invoke(ctx, "/elys.parameter.Msg/UpdateMinCommission", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateMaxVotingPower(ctx context.Context, in *MsgUpdateMaxVotingPower, opts ...grpc.CallOption) (*MsgUpdateMaxVotingPowerResponse, error) { + out := new(MsgUpdateMaxVotingPowerResponse) + err := c.cc.Invoke(ctx, "/elys.parameter.Msg/UpdateMaxVotingPower", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateMinSelfDelegation(ctx context.Context, in *MsgUpdateMinSelfDelegation, opts ...grpc.CallOption) (*MsgUpdateMinSelfDelegationResponse, error) { + out := new(MsgUpdateMinSelfDelegationResponse) + err := c.cc.Invoke(ctx, "/elys.parameter.Msg/UpdateMinSelfDelegation", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateBrokerAddress(ctx context.Context, in *MsgUpdateBrokerAddress, opts ...grpc.CallOption) (*MsgUpdateBrokerAddressResponse, error) { + out := new(MsgUpdateBrokerAddressResponse) + err := c.cc.Invoke(ctx, "/elys.parameter.Msg/UpdateBrokerAddress", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { + UpdateMinCommission(context.Context, *MsgUpdateMinCommission) (*MsgUpdateMinCommissionResponse, error) + UpdateMaxVotingPower(context.Context, *MsgUpdateMaxVotingPower) (*MsgUpdateMaxVotingPowerResponse, error) + UpdateMinSelfDelegation(context.Context, *MsgUpdateMinSelfDelegation) (*MsgUpdateMinSelfDelegationResponse, error) + UpdateBrokerAddress(context.Context, *MsgUpdateBrokerAddress) (*MsgUpdateBrokerAddressResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. type UnimplementedMsgServer struct { } +func (*UnimplementedMsgServer) UpdateMinCommission(ctx context.Context, req *MsgUpdateMinCommission) (*MsgUpdateMinCommissionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateMinCommission not implemented") +} +func (*UnimplementedMsgServer) UpdateMaxVotingPower(ctx context.Context, req *MsgUpdateMaxVotingPower) (*MsgUpdateMaxVotingPowerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateMaxVotingPower not implemented") +} +func (*UnimplementedMsgServer) UpdateMinSelfDelegation(ctx context.Context, req *MsgUpdateMinSelfDelegation) (*MsgUpdateMinSelfDelegationResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateMinSelfDelegation not implemented") +} +func (*UnimplementedMsgServer) UpdateBrokerAddress(ctx context.Context, req *MsgUpdateBrokerAddress) (*MsgUpdateBrokerAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateBrokerAddress not implemented") +} + func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } +func _Msg_UpdateMinCommission_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateMinCommission) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateMinCommission(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.parameter.Msg/UpdateMinCommission", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateMinCommission(ctx, req.(*MsgUpdateMinCommission)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateMaxVotingPower_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateMaxVotingPower) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateMaxVotingPower(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.parameter.Msg/UpdateMaxVotingPower", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateMaxVotingPower(ctx, req.(*MsgUpdateMaxVotingPower)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateMinSelfDelegation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateMinSelfDelegation) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateMinSelfDelegation(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.parameter.Msg/UpdateMinSelfDelegation", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateMinSelfDelegation(ctx, req.(*MsgUpdateMinSelfDelegation)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateBrokerAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateBrokerAddress) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateBrokerAddress(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.parameter.Msg/UpdateBrokerAddress", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateBrokerAddress(ctx, req.(*MsgUpdateBrokerAddress)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "elys.parameter.Msg", HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{}, - Metadata: "elys/parameter/tx.proto", + Methods: []grpc.MethodDesc{ + { + MethodName: "UpdateMinCommission", + Handler: _Msg_UpdateMinCommission_Handler, + }, + { + MethodName: "UpdateMaxVotingPower", + Handler: _Msg_UpdateMaxVotingPower_Handler, + }, + { + MethodName: "UpdateMinSelfDelegation", + Handler: _Msg_UpdateMinSelfDelegation_Handler, + }, + { + MethodName: "UpdateBrokerAddress", + Handler: _Msg_UpdateBrokerAddress_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "elys/parameter/tx.proto", +} + +func (m *MsgUpdateMinCommission) 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 *MsgUpdateMinCommission) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateMinCommission) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.MinCommission) > 0 { + i -= len(m.MinCommission) + copy(dAtA[i:], m.MinCommission) + i = encodeVarintTx(dAtA, i, uint64(len(m.MinCommission))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateMinCommissionResponse) 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 *MsgUpdateMinCommissionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateMinCommissionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateMaxVotingPower) 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 *MsgUpdateMaxVotingPower) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateMaxVotingPower) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.MaxVotingPower) > 0 { + i -= len(m.MaxVotingPower) + copy(dAtA[i:], m.MaxVotingPower) + i = encodeVarintTx(dAtA, i, uint64(len(m.MaxVotingPower))) + i-- + dAtA[i] = 0x1a + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateMaxVotingPowerResponse) 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 *MsgUpdateMaxVotingPowerResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateMaxVotingPowerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateMinSelfDelegation) 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 *MsgUpdateMinSelfDelegation) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateMinSelfDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.MinSelfDelegation) > 0 { + i -= len(m.MinSelfDelegation) + copy(dAtA[i:], m.MinSelfDelegation) + i = encodeVarintTx(dAtA, i, uint64(len(m.MinSelfDelegation))) + i-- + dAtA[i] = 0x1a + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateMinSelfDelegationResponse) 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 *MsgUpdateMinSelfDelegationResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateMinSelfDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil } + +func (m *MsgUpdateBrokerAddress) 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 *MsgUpdateBrokerAddress) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateBrokerAddress) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.BrokerAddress) > 0 { + i -= len(m.BrokerAddress) + copy(dAtA[i:], m.BrokerAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.BrokerAddress))) + i-- + dAtA[i] = 0x1a + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateBrokerAddressResponse) 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 *MsgUpdateBrokerAddressResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateBrokerAddressResponse) 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 *MsgUpdateMinCommission) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.MinCommission) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateMinCommissionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateMaxVotingPower) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.MaxVotingPower) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateMaxVotingPowerResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateMinSelfDelegation) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.MinSelfDelegation) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateMinSelfDelegationResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateBrokerAddress) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.BrokerAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateBrokerAddressResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgUpdateMinCommission) 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: MsgUpdateMinCommission: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateMinCommission: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", 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.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinCommission", 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.MinCommission = 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 *MsgUpdateMinCommissionResponse) 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: MsgUpdateMinCommissionResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateMinCommissionResponse: 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 *MsgUpdateMaxVotingPower) 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: MsgUpdateMaxVotingPower: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateMaxVotingPower: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", 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.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxVotingPower", 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.MaxVotingPower = 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 *MsgUpdateMaxVotingPowerResponse) 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: MsgUpdateMaxVotingPowerResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateMaxVotingPowerResponse: 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 *MsgUpdateMinSelfDelegation) 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: MsgUpdateMinSelfDelegation: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateMinSelfDelegation: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", 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.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinSelfDelegation", 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.MinSelfDelegation = 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 *MsgUpdateMinSelfDelegationResponse) 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: MsgUpdateMinSelfDelegationResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateMinSelfDelegationResponse: 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 *MsgUpdateBrokerAddress) 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: MsgUpdateBrokerAddress: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateBrokerAddress: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", 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.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BrokerAddress", 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.BrokerAddress = 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 *MsgUpdateBrokerAddressResponse) 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: MsgUpdateBrokerAddressResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateBrokerAddressResponse: 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 skipTx(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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/stablestake/client/wasm/messenger.go b/x/stablestake/client/wasm/messenger.go index 791c9ecb7..042a929e4 100644 --- a/x/stablestake/client/wasm/messenger.go +++ b/x/stablestake/client/wasm/messenger.go @@ -3,16 +3,21 @@ package wasm import ( sdk "github.com/cosmos/cosmos-sdk/types" wasmbindingstypes "github.com/elys-network/elys/wasmbindings/types" + parameterkeeper "github.com/elys-network/elys/x/parameter/keeper" "github.com/elys-network/elys/x/stablestake/keeper" ) // Messenger handles messages for the Stable Stake module. type Messenger struct { - keeper *keeper.Keeper + keeper *keeper.Keeper + parameterKeeper *parameterkeeper.Keeper } -func NewMessenger(keeper *keeper.Keeper) *Messenger { - return &Messenger{keeper: keeper} +func NewMessenger(keeper *keeper.Keeper, parameterKeeper *parameterkeeper.Keeper) *Messenger { + return &Messenger{ + keeper: keeper, + parameterKeeper: parameterKeeper, + } } func (m *Messenger) HandleMsg(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmbindingstypes.ElysMsg) ([]sdk.Event, [][]byte, error) { diff --git a/x/stablestake/client/wasm/msg_bond.go b/x/stablestake/client/wasm/msg_bond.go index 4578207f9..c2f52a7f5 100644 --- a/x/stablestake/client/wasm/msg_bond.go +++ b/x/stablestake/client/wasm/msg_bond.go @@ -14,8 +14,8 @@ func (m *Messenger) msgBond(ctx sdk.Context, contractAddr sdk.AccAddress, msg *t if msg == nil { return nil, nil, wasmvmtypes.InvalidRequest{Err: "Bond null msg"} } - - if msg.Creator != contractAddr.String() { + brokerAddress := m.parameterKeeper.GetParams(ctx).BrokerAddress + if msg.Creator != contractAddr.String() && contractAddr.String() != brokerAddress { return nil, nil, wasmvmtypes.InvalidRequest{Err: "bond wrong sender"} } diff --git a/x/stablestake/client/wasm/msg_unbond.go b/x/stablestake/client/wasm/msg_unbond.go index 06e84a47a..8d66eb071 100644 --- a/x/stablestake/client/wasm/msg_unbond.go +++ b/x/stablestake/client/wasm/msg_unbond.go @@ -15,7 +15,8 @@ func (m *Messenger) msgUnbond(ctx sdk.Context, contractAddr sdk.AccAddress, msg return nil, nil, wasmvmtypes.InvalidRequest{Err: "Unbond null msg"} } - if msg.Creator != contractAddr.String() { + brokerAddress := m.parameterKeeper.GetParams(ctx).BrokerAddress + if msg.Creator != contractAddr.String() && contractAddr.String() != brokerAddress { return nil, nil, wasmvmtypes.InvalidRequest{Err: "unbond wrong sender"} } diff --git a/x/tokenomics/client/wasm/messenger.go b/x/tokenomics/client/wasm/messenger.go index 696bc05a4..4fe8ff016 100644 --- a/x/tokenomics/client/wasm/messenger.go +++ b/x/tokenomics/client/wasm/messenger.go @@ -17,18 +17,6 @@ func NewMessenger(keeper *keeper.Keeper) *Messenger { func (m *Messenger) HandleMsg(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmbindingstypes.ElysMsg) ([]sdk.Event, [][]byte, error) { switch { - case msg.TokenomicsCreateAirdrop != nil: - return m.msgCreateAirdrop(ctx, contractAddr, msg.TokenomicsCreateAirdrop) - case msg.TokenomicsUpdateAirdrop != nil: - return m.msgUpdateAirdrop(ctx, contractAddr, msg.TokenomicsUpdateAirdrop) - case msg.TokenomicsDeleteAirdrop != nil: - return m.msgDeleteAirdrop(ctx, contractAddr, msg.TokenomicsDeleteAirdrop) - case msg.TokenomicsCreateTimeBasedInflation != nil: - return m.msgCreateTimeBasedInflation(ctx, contractAddr, msg.TokenomicsCreateTimeBasedInflation) - case msg.TokenomicsUpdateTimeBasedInflation != nil: - return m.msgUpdateTimeBasedInflation(ctx, contractAddr, msg.TokenomicsUpdateTimeBasedInflation) - case msg.TokenomicsDeleteTimeBasedInflation != nil: - return m.msgDeleteTimeBasedInflation(ctx, contractAddr, msg.TokenomicsDeleteTimeBasedInflation) default: // This handler cannot handle the message return nil, nil, wasmbindingstypes.ErrCannotHandleMsg diff --git a/x/tokenomics/client/wasm/msg_create_airdrop.go b/x/tokenomics/client/wasm/msg_create_airdrop.go deleted file mode 100644 index d584ce38a..000000000 --- a/x/tokenomics/client/wasm/msg_create_airdrop.go +++ /dev/null @@ -1,44 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - keeper "github.com/elys-network/elys/x/tokenomics/keeper" - types "github.com/elys-network/elys/x/tokenomics/types" -) - -func (m *Messenger) msgCreateAirdrop(ctx sdk.Context, contractAddr sdk.AccAddress, msg *types.MsgCreateAirdrop) ([]sdk.Event, [][]byte, error) { - if msg == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "CreateAirdrop null msg"} - } - - if msg.Authority != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "create airdrop wrong sender"} - } - - msgServer := keeper.NewMsgServerImpl(*m.keeper) - - if err := msg.ValidateBasic(); err != nil { - return nil, nil, errorsmod.Wrap(err, "failed validating msg") - } - - res, err := msgServer.CreateAirdrop( - sdk.WrapSDKContext(ctx), - msg, - ) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "CreateAirdrop msg") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize CreateAirdrop response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} diff --git a/x/tokenomics/client/wasm/msg_create_time_based_inflation.go b/x/tokenomics/client/wasm/msg_create_time_based_inflation.go deleted file mode 100644 index ccca9068a..000000000 --- a/x/tokenomics/client/wasm/msg_create_time_based_inflation.go +++ /dev/null @@ -1,44 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - keeper "github.com/elys-network/elys/x/tokenomics/keeper" - types "github.com/elys-network/elys/x/tokenomics/types" -) - -func (m *Messenger) msgCreateTimeBasedInflation(ctx sdk.Context, contractAddr sdk.AccAddress, msg *types.MsgCreateTimeBasedInflation) ([]sdk.Event, [][]byte, error) { - if msg == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "CreateTimeBasedInflation null msg"} - } - - if msg.Authority != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "create time based inflation wrong sender"} - } - - msgServer := keeper.NewMsgServerImpl(*m.keeper) - - if err := msg.ValidateBasic(); err != nil { - return nil, nil, errorsmod.Wrap(err, "failed validating msg") - } - - res, err := msgServer.CreateTimeBasedInflation( - sdk.WrapSDKContext(ctx), - msg, - ) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "CreateTimeBasedInflation msg") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize CreateTimeBasedInflation response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} diff --git a/x/tokenomics/client/wasm/msg_delete_airdrop.go b/x/tokenomics/client/wasm/msg_delete_airdrop.go deleted file mode 100644 index e0eb543ce..000000000 --- a/x/tokenomics/client/wasm/msg_delete_airdrop.go +++ /dev/null @@ -1,44 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - keeper "github.com/elys-network/elys/x/tokenomics/keeper" - types "github.com/elys-network/elys/x/tokenomics/types" -) - -func (m *Messenger) msgDeleteAirdrop(ctx sdk.Context, contractAddr sdk.AccAddress, msg *types.MsgDeleteAirdrop) ([]sdk.Event, [][]byte, error) { - if msg == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "DeleteAirdrop null msg"} - } - - if msg.Authority != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "create airdrop wrong sender"} - } - - msgServer := keeper.NewMsgServerImpl(*m.keeper) - - if err := msg.ValidateBasic(); err != nil { - return nil, nil, errorsmod.Wrap(err, "failed validating msg") - } - - res, err := msgServer.DeleteAirdrop( - sdk.WrapSDKContext(ctx), - msg, - ) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "DeleteAirdrop msg") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize DeleteAirdrop response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} diff --git a/x/tokenomics/client/wasm/msg_delete_time_based_inflation.go b/x/tokenomics/client/wasm/msg_delete_time_based_inflation.go deleted file mode 100644 index bd5ef05c0..000000000 --- a/x/tokenomics/client/wasm/msg_delete_time_based_inflation.go +++ /dev/null @@ -1,44 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - keeper "github.com/elys-network/elys/x/tokenomics/keeper" - types "github.com/elys-network/elys/x/tokenomics/types" -) - -func (m *Messenger) msgDeleteTimeBasedInflation(ctx sdk.Context, contractAddr sdk.AccAddress, msg *types.MsgDeleteTimeBasedInflation) ([]sdk.Event, [][]byte, error) { - if msg == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "DeleteTimeBasedInflation null msg"} - } - - if msg.Authority != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "delete time based inflation wrong sender"} - } - - msgServer := keeper.NewMsgServerImpl(*m.keeper) - - if err := msg.ValidateBasic(); err != nil { - return nil, nil, errorsmod.Wrap(err, "failed validating msg") - } - - res, err := msgServer.DeleteTimeBasedInflation( - sdk.WrapSDKContext(ctx), - msg, - ) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "DeleteTimeBasedInflation msg") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize DeleteTimeBasedInflation response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} diff --git a/x/tokenomics/client/wasm/msg_update_airdrop.go b/x/tokenomics/client/wasm/msg_update_airdrop.go deleted file mode 100644 index fcf0df8ca..000000000 --- a/x/tokenomics/client/wasm/msg_update_airdrop.go +++ /dev/null @@ -1,44 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - keeper "github.com/elys-network/elys/x/tokenomics/keeper" - types "github.com/elys-network/elys/x/tokenomics/types" -) - -func (m *Messenger) msgUpdateAirdrop(ctx sdk.Context, contractAddr sdk.AccAddress, msg *types.MsgUpdateAirdrop) ([]sdk.Event, [][]byte, error) { - if msg == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "UpdateAirdrop null msg"} - } - - if msg.Authority != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "update airdrop wrong sender"} - } - - msgServer := keeper.NewMsgServerImpl(*m.keeper) - - if err := msg.ValidateBasic(); err != nil { - return nil, nil, errorsmod.Wrap(err, "failed validating msg") - } - - res, err := msgServer.UpdateAirdrop( - sdk.WrapSDKContext(ctx), - msg, - ) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "UpdateAirdrop msg") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize UpdateAirdrop response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} diff --git a/x/tokenomics/client/wasm/msg_update_genesis_inflation.go b/x/tokenomics/client/wasm/msg_update_genesis_inflation.go deleted file mode 100644 index 8ceba0323..000000000 --- a/x/tokenomics/client/wasm/msg_update_genesis_inflation.go +++ /dev/null @@ -1,44 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - keeper "github.com/elys-network/elys/x/tokenomics/keeper" - types "github.com/elys-network/elys/x/tokenomics/types" -) - -func (m *Messenger) msgUpdateGenesisInflation(ctx sdk.Context, contractAddr sdk.AccAddress, msg *types.MsgUpdateGenesisInflation) ([]sdk.Event, [][]byte, error) { - if msg == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "UpdateGenesisInflation null msg"} - } - - if msg.Authority != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "update genesis inflation wrong sender"} - } - - msgServer := keeper.NewMsgServerImpl(*m.keeper) - - if err := msg.ValidateBasic(); err != nil { - return nil, nil, errorsmod.Wrap(err, "failed validating msg") - } - - res, err := msgServer.UpdateGenesisInflation( - sdk.WrapSDKContext(ctx), - msg, - ) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "UpdateGenesisInflation msg") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize UpdateGenesisInflation response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -} diff --git a/x/tokenomics/client/wasm/msg_update_time_based_inflation.go b/x/tokenomics/client/wasm/msg_update_time_based_inflation.go deleted file mode 100644 index eb56407f7..000000000 --- a/x/tokenomics/client/wasm/msg_update_time_based_inflation.go +++ /dev/null @@ -1,44 +0,0 @@ -package wasm - -import ( - "encoding/json" - - errorsmod "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - keeper "github.com/elys-network/elys/x/tokenomics/keeper" - types "github.com/elys-network/elys/x/tokenomics/types" -) - -func (m *Messenger) msgUpdateTimeBasedInflation(ctx sdk.Context, contractAddr sdk.AccAddress, msg *types.MsgUpdateTimeBasedInflation) ([]sdk.Event, [][]byte, error) { - if msg == nil { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "UpdateTimeBasedInflation null msg"} - } - - if msg.Authority != contractAddr.String() { - return nil, nil, wasmvmtypes.InvalidRequest{Err: "update time based inflation wrong sender"} - } - - msgServer := keeper.NewMsgServerImpl(*m.keeper) - - if err := msg.ValidateBasic(); err != nil { - return nil, nil, errorsmod.Wrap(err, "failed validating msg") - } - - res, err := msgServer.UpdateTimeBasedInflation( - sdk.WrapSDKContext(ctx), - msg, - ) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "UpdateTimeBasedInflation msg") - } - - responseBytes, err := json.Marshal(*res) - if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize UpdateTimeBasedInflation response") - } - - resp := [][]byte{responseBytes} - - return nil, resp, nil -}