Skip to content

Commit

Permalink
Merge PR: add ErrSwapTokenPairNotExist and optimeze prompt of communi…
Browse files Browse the repository at this point in the history
…ty-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 <[email protected]>
  • Loading branch information
xiangjianmeng and zhongqiuwood authored Jan 6, 2021
1 parent a4fa835 commit f433c50
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
4 changes: 2 additions & 2 deletions x/distribution/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ Where proposal.json contains:
"recipient": "okexchain1hw4r48aww06ldrfeuq2v438ujnl6alsz0685a0",
"amount": [
{
"denom": %s,
"denom": "%s",
"amount": "10000"
}
],
"deposit": [
{
"denom": %s,
"denom": "%s",
"amount": "10000"
}
]
Expand Down
6 changes: 3 additions & 3 deletions x/farm/keeper/whitelist.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

}

Expand All @@ -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
Expand Down
12 changes: 9 additions & 3 deletions x/farm/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))}
}
4 changes: 2 additions & 2 deletions x/params/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f433c50

Please sign in to comment.