permissioned incentive claims (#814)

This commit is contained in:
Denali Marsh 2021-02-10 15:58:05 +01:00 committed by GitHub
parent bc1fab7836
commit 7f43e6336e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils"
@ -50,11 +51,17 @@ func getCmdClaimCdp(cdc *codec.Codec) *cobra.Command {
inBuf := bufio.NewReader(cmd.InOrStdin())
cliCtx := context.NewCLIContextWithInputAndFrom(inBuf, args[0]).WithCodec(cdc)
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc))
owner, err := sdk.AccAddressFromBech32(args[0])
if err != nil {
return err
}
sender := cliCtx.GetFromAddress()
if !sender.Equals(owner) {
return sdkerrors.Wrapf(types.ErrInvalidClaimOwner, "tx sender %s does not match claim owner %s", sender, owner)
}
msg := types.NewMsgClaimUSDXMintingReward(owner, args[1])
err = msg.ValidateBasic()
if err != nil {
@ -81,11 +88,17 @@ func getCmdClaimHard(cdc *codec.Codec) *cobra.Command {
inBuf := bufio.NewReader(cmd.InOrStdin())
cliCtx := context.NewCLIContextWithInputAndFrom(inBuf, args[0]).WithCodec(cdc)
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc))
owner, err := sdk.AccAddressFromBech32(args[0])
if err != nil {
return err
}
sender := cliCtx.GetFromAddress()
if !sender.Equals(owner) {
return sdkerrors.Wrapf(types.ErrInvalidClaimOwner, "tx sender %s does not match claim owner %s", sender, owner)
}
msg := types.NewMsgClaimHardLiquidityProviderReward(owner, args[1])
err = msg.ValidateBasic()
if err != nil {

View File

@ -18,4 +18,5 @@ var (
ErrZeroClaim = sdkerrors.Register(ModuleName, 9, "cannot claim - claim amount rounds to zero")
ErrClaimExpired = sdkerrors.Register(ModuleName, 10, "claim has expired")
ErrInvalidClaimType = sdkerrors.Register(ModuleName, 11, "invalid claim type")
ErrInvalidClaimOwner = sdkerrors.Register(ModuleName, 12, "invalid claim owner")
)