-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(oracle):add updateparams service
- Loading branch information
Showing
6 changed files
with
509 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package keeper | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/ExocoreNetwork/exocore/x/oracle/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" | ||
) | ||
|
||
func (ms msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { | ||
ctx := sdk.UnwrapSDKContext(goCtx) | ||
|
||
if ms.authority != msg.Authority { | ||
return nil, govtypes.ErrInvalidSigner.Wrapf("invalid authority; expected %s, got %s", ms.authority, msg.Authority) | ||
} | ||
|
||
// store params | ||
if err := ms.SetParams(ctx, msg.Params); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &types.MsgUpdateParamsResponse{}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package types | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
) | ||
|
||
const TypeMsgUpdateParams = "update_params" | ||
|
||
var _ sdk.Msg = &MsgUpdateParams{} | ||
|
||
func (msg *MsgUpdateParams) Route() string { | ||
return RouterKey | ||
} | ||
|
||
func (msg *MsgUpdateParams) Type() string { | ||
return TypeMsgUpdateParams | ||
} | ||
|
||
// GetSignBytes returns the raw bytes for a MsgUpdateParams message that | ||
// the expected signer needs to sign. | ||
func (msg *MsgUpdateParams) GetSignBytes() []byte { | ||
bz := ModuleCdc.MustMarshalJSON(msg) | ||
return sdk.MustSortJSON(bz) | ||
} | ||
|
||
// ValidateBasic executes sanity validation on the provided data | ||
func (msg *MsgUpdateParams) ValidateBasic() error { | ||
if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { | ||
return sdkerrors.Wrap(err, "invalid authority address") | ||
} | ||
return msg.Params.Validate() | ||
} | ||
|
||
// GetSigners returns the expected signers for a MsgUpdateParams message | ||
func (msg *MsgUpdateParams) GetSigners() []sdk.AccAddress { | ||
addr, _ := sdk.AccAddressFromBech32(msg.Authority) | ||
Check warning Code scanning / gosec Returned error is not propagated up the stack. Warning
Returned error is not propagated up the stack.
|
||
return []sdk.AccAddress{addr} | ||
} |
Oops, something went wrong.