From f433c5009e424f715c844198b75059fabd7f2891 Mon Sep 17 00:00:00 2001 From: MengXiangJian <805442788@qq.com> Date: Wed, 6 Jan 2021 11:46:51 +0800 Subject: [PATCH] Merge PR: add ErrSwapTokenPairNotExist and optimeze prompt of community-pool-spend proposal (#537) * add ErrSwapTokenPairNotExist and optimeze prompt of community-pool-spend proposal * optimize prompt for param change proposal Co-authored-by: Zhong Qiu <36867992+zhongqiuwood@users.noreply.github.com> --- x/distribution/client/cli/tx.go | 4 ++-- x/farm/keeper/whitelist.go | 6 +++--- x/farm/types/errors.go | 12 +++++++++--- x/params/client/cli/tx.go | 4 ++-- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/x/distribution/client/cli/tx.go b/x/distribution/client/cli/tx.go index f01167afa4..e0585d8676 100644 --- a/x/distribution/client/cli/tx.go +++ b/x/distribution/client/cli/tx.go @@ -125,13 +125,13 @@ Where proposal.json contains: "recipient": "okexchain1hw4r48aww06ldrfeuq2v438ujnl6alsz0685a0", "amount": [ { - "denom": %s, + "denom": "%s", "amount": "10000" } ], "deposit": [ { - "denom": %s, + "denom": "%s", "amount": "10000" } ] diff --git a/x/farm/keeper/whitelist.go b/x/farm/keeper/whitelist.go index 25768c28c7..37fc9dc1e2 100644 --- a/x/farm/keeper/whitelist.go +++ b/x/farm/keeper/whitelist.go @@ -43,7 +43,7 @@ func (k Keeper) satisfyWhiteListAdmittance(ctx sdk.Context, pool types.FarmPool) // locked token is common token // check the existence of locked token with default quoteTokenSymbol in Params if !k.isSwapTokenPairExisted(ctx, pool.MinLockAmount.Denom, quoteTokenSymbol) { - return types.ErrTokenNotExist(swaptypes.GetSwapTokenPairName(pool.MinLockAmount.Denom, quoteTokenSymbol)) + return types.ErrSwapTokenPairNotExist(swaptypes.GetSwapTokenPairName(pool.MinLockAmount.Denom, quoteTokenSymbol)) } @@ -65,11 +65,11 @@ func (k Keeper) satisfyWhiteListAdmittance(ctx sdk.Context, pool types.FarmPool) // base or quote token don't contain default quoteTokenSymbol in Params // check the existence of locked token both with default quoteTokenSymbol in Params if !k.isSwapTokenPairExisted(ctx, tokenSymbol0, quoteTokenSymbol) { - return types.ErrTokenNotExist(swaptypes.GetSwapTokenPairName(tokenSymbol0, quoteTokenSymbol)) + return types.ErrSwapTokenPairNotExist(swaptypes.GetSwapTokenPairName(tokenSymbol0, quoteTokenSymbol)) } if !k.isSwapTokenPairExisted(ctx, tokenSymbol1, quoteTokenSymbol) { - return types.ErrTokenNotExist(swaptypes.GetSwapTokenPairName(tokenSymbol1, quoteTokenSymbol)) + return types.ErrSwapTokenPairNotExist(swaptypes.GetSwapTokenPairName(tokenSymbol1, quoteTokenSymbol)) } return nil diff --git a/x/farm/types/errors.go b/x/farm/types/errors.go index 9b93774d47..826ef4a582 100644 --- a/x/farm/types/errors.go +++ b/x/farm/types/errors.go @@ -22,18 +22,19 @@ const ( CodePoolNotFinished uint32 = 66006 CodeUnexpectedProposalType uint32 = 66007 CodeInvalidAddress uint32 = 66008 - CodeRemainingAmountNotZero uint32 = 66009 + CodeRemainingAmountNotZero uint32 = 66009 CodeInvalidPoolOwner uint32 = 66010 CodeInvalidDenom uint32 = 66011 CodeSendCoinsFromAccountToModuleFailed uint32 = 66012 CodeUnknownFarmMsgType uint32 = 66013 CodeUnknownFarmQueryType uint32 = 66014 - CodeInvalidInputAmount uint32 = 66015 + CodeInvalidInputAmount uint32 = 66015 CodeInsufficientAmount uint32 = 66016 CodeInvalidStartHeight uint32 = 66017 CodePoolNameLength uint32 = 66018 CodeLockAmountBelowMinimum uint32 = 66019 CodeSendCoinsFromModuleToAccountFailed uint32 = 66020 + CodeSwapTokenPairNotExist uint32 = 66021 ) // ErrInvalidInput returns an error when an input parameter is invalid @@ -81,7 +82,7 @@ func ErrUnexpectedProposalType(proposalType string) sdk.EnvelopedErr { // ErrNilAddress returns an error when an empty address appears func ErrNilAddress() sdk.EnvelopedErr { - return sdk.EnvelopedErr{Err: sdkerrors.New(DefaultParamspace, CodeInvalidAddress, fmt.Sprintf("failed. address is required"))} + return sdk.EnvelopedErr{Err: sdkerrors.New(DefaultParamspace, CodeInvalidAddress, fmt.Sprintf("failed. address is required"))} } // ErrRemainingAmountNotZero returns an error when the remaining amount in yieldedTokenInfo is not zero @@ -143,3 +144,8 @@ func ErrLockAmountBelowMinimum(minLockAmount, amount sdk.Dec) sdk.EnvelopedErr { func ErrSendCoinsFromModuleToAccountFailed(content string) sdk.EnvelopedErr { return sdk.EnvelopedErr{Err: sdkerrors.New(DefaultParamspace, CodeSendCoinsFromModuleToAccountFailed, fmt.Sprintf("failed. send coins from module to account failed %s", content))} } + +// ErrSwapTokenPairNotExist returns an error when a swap token pair not exists +func ErrSwapTokenPairNotExist(tokenName string) sdk.EnvelopedErr { + return sdk.EnvelopedErr{Err: sdkerrors.New(DefaultParamspace, CodeSwapTokenPairNotExist, fmt.Sprintf("failed. swap token pair %s does not exist", tokenName))} +} \ No newline at end of file diff --git a/x/params/client/cli/tx.go b/x/params/client/cli/tx.go index 4f47a721c9..29566f5c4d 100644 --- a/x/params/client/cli/tx.go +++ b/x/params/client/cli/tx.go @@ -54,14 +54,14 @@ Where proposal.json contains: ], "deposit": [ { - "denom": common.NativeToken, + "denom": "%s", "amount": "10000" } ], "height": "1000" } `, - version.ClientName, + version.ClientName, sdk.DefaultBondDenom, ), ), RunE: func(cmd *cobra.Command, args []string) error {