mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-14 03:55:19 +00:00
permissioned incentive claims (#814)
This commit is contained in:
parent
bc1fab7836
commit
7f43e6336e
@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
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/version"
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth/client/utils"
|
"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())
|
inBuf := bufio.NewReader(cmd.InOrStdin())
|
||||||
cliCtx := context.NewCLIContextWithInputAndFrom(inBuf, args[0]).WithCodec(cdc)
|
cliCtx := context.NewCLIContextWithInputAndFrom(inBuf, args[0]).WithCodec(cdc)
|
||||||
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc))
|
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc))
|
||||||
|
|
||||||
owner, err := sdk.AccAddressFromBech32(args[0])
|
owner, err := sdk.AccAddressFromBech32(args[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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])
|
msg := types.NewMsgClaimUSDXMintingReward(owner, args[1])
|
||||||
err = msg.ValidateBasic()
|
err = msg.ValidateBasic()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -81,11 +88,17 @@ func getCmdClaimHard(cdc *codec.Codec) *cobra.Command {
|
|||||||
inBuf := bufio.NewReader(cmd.InOrStdin())
|
inBuf := bufio.NewReader(cmd.InOrStdin())
|
||||||
cliCtx := context.NewCLIContextWithInputAndFrom(inBuf, args[0]).WithCodec(cdc)
|
cliCtx := context.NewCLIContextWithInputAndFrom(inBuf, args[0]).WithCodec(cdc)
|
||||||
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc))
|
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc))
|
||||||
|
|
||||||
owner, err := sdk.AccAddressFromBech32(args[0])
|
owner, err := sdk.AccAddressFromBech32(args[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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])
|
msg := types.NewMsgClaimHardLiquidityProviderReward(owner, args[1])
|
||||||
err = msg.ValidateBasic()
|
err = msg.ValidateBasic()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -18,4 +18,5 @@ var (
|
|||||||
ErrZeroClaim = sdkerrors.Register(ModuleName, 9, "cannot claim - claim amount rounds to zero")
|
ErrZeroClaim = sdkerrors.Register(ModuleName, 9, "cannot claim - claim amount rounds to zero")
|
||||||
ErrClaimExpired = sdkerrors.Register(ModuleName, 10, "claim has expired")
|
ErrClaimExpired = sdkerrors.Register(ModuleName, 10, "claim has expired")
|
||||||
ErrInvalidClaimType = sdkerrors.Register(ModuleName, 11, "invalid claim type")
|
ErrInvalidClaimType = sdkerrors.Register(ModuleName, 11, "invalid claim type")
|
||||||
|
ErrInvalidClaimOwner = sdkerrors.Register(ModuleName, 12, "invalid claim owner")
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user