This repository has been archived by the owner on Dec 21, 2022. It is now read-only.
forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request: add block height control (#93)
* add block height control * disable bank handler * update * add MILESTONE_MERCURY_HEIGHT * enhance message * rename to milestoneMercuryHeight int64 Co-authored-by: aaron <[email protected]> Co-authored-by: Green <[email protected]> Co-authored-by: zhongqiuwood <[email protected]>
- Loading branch information
1 parent
b0d9d00
commit d951ae2
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ examples/build/* | |
docs/_build | ||
docs/tutorial | ||
docs/node_modules | ||
dev/testnet | ||
dev/cache | ||
dist | ||
tools-stamp | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package types | ||
|
||
import ( | ||
"strconv" | ||
"sync" | ||
) | ||
|
||
var ( | ||
MILESTONE_MERCURY_HEIGHT string | ||
milestoneMercuryHeight int64 | ||
once sync.Once | ||
) | ||
|
||
func string2number(input string) int64 { | ||
if len(input) == 0 { | ||
input = "0" | ||
} | ||
res, err := strconv.ParseInt(input, 10, 64) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return res | ||
} | ||
|
||
func initVersionBlockHeight() { | ||
once.Do(func() { | ||
milestoneMercuryHeight = string2number(MILESTONE_MERCURY_HEIGHT) | ||
}) | ||
} | ||
|
||
func init() { | ||
initVersionBlockHeight() | ||
} | ||
|
||
//disable transfer tokens to contract address by cli | ||
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters