Skip to content
This repository has been archived by the owner on Dec 21, 2022. It is now read-only.

Commit

Permalink
Merge pull request: refactor func HigherThanMercury(height int64) a b…
Browse files Browse the repository at this point in the history
…it (#98)
  • Loading branch information
zhongqiuwood authored Mar 6, 2021
1 parent 6adf841 commit 3aba61b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
36 changes: 20 additions & 16 deletions types/milestone.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import (
"sync"
)

// Disable followings after milestoneMercuryHeight
// 1. TransferToContractBlock
// 2. ChangeEvmDenomByProposal
// 3. BankTransferBlock

var (
MILESTONE_MERCURY_HEIGHT string
milestoneMercuryHeight int64
Expand Down Expand Up @@ -33,26 +38,25 @@ func init() {
}

//disable transfer tokens to contract address by cli
func higherThanMercury(height int64) bool {
func HigherThanMercury(height int64) bool {
if milestoneMercuryHeight == 0 {
// milestoneMercuryHeight not enabled
return false
}
return height > milestoneMercuryHeight
}


//disable transfer tokens to contract address by cli
func IsDisableTransferToContractBlock(height int64) bool {
return higherThanMercury(height)
}

//disable change the param EvmDenom by proposal
func IsDisableChangeEvmDenomByProposal(height int64) bool {
return higherThanMercury(height)
}

//disable transfer tokens by module of cosmos-sdk/bank
func IsDisableBankTransferBlock(height int64) bool {
return higherThanMercury(height)
}
////disable transfer tokens to contract address by cli
//func IsDisableTransferToContractBlock(height int64) bool {
// return higherThanMercury(height)
//}
//
////disable change the param EvmDenom by proposal
//func IsDisableChangeEvmDenomByProposal(height int64) bool {
// return higherThanMercury(height)
//}
//
////disable transfer tokens by module of cosmos-sdk/bank
//func IsDisableBankTransferBlock(height int64) bool {
// return higherThanMercury(height)
//}
2 changes: 1 addition & 1 deletion x/bank/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
func NewHandler(k keeper.Keeper) sdk.Handler {
return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {

if sdk.IsDisableBankTransferBlock(ctx.BlockHeight()) {
if sdk.HigherThanMercury(ctx.BlockHeight()) {
return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "bank message is disabled")
}

Expand Down

0 comments on commit 3aba61b

Please sign in to comment.