Skip to content

Commit

Permalink
fix missing import of template and fix miniToken checker issue
Browse files Browse the repository at this point in the history
  • Loading branch information
unclezoro authored and HaoyangLiu committed Jul 3, 2020
1 parent 3132ded commit 9eb2c15
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
11 changes: 9 additions & 2 deletions contracts/TokenHub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ contract TokenHub is ITokenHub, System, IParamSubscriber, IApplication, ISystemR
require(bep2eTokenDecimals<=BEP2_TOKEN_DECIMALS || (bep2eTokenDecimals>BEP2_TOKEN_DECIMALS && amount.mod(10**(bep2eTokenDecimals-BEP2_TOKEN_DECIMALS))==0), "invalid transfer amount: precision loss in amount conversion");
convertedAmount = convertToBep2Amount(amount, bep2eTokenDecimals);// convert to bep2 amount
if (isMiniBEP2Token(bep2TokenSymbol)) {
require(convertedAmount > 1e8 , "For miniToken, the transfer amount must be either large than 1");
require(convertedAmount >= 1e8 , "For miniToken, the transfer amount must not be less than 1");
}
require(bep2eTokenDecimals>=BEP2_TOKEN_DECIMALS || (bep2eTokenDecimals<BEP2_TOKEN_DECIMALS && convertedAmount>amount), "amount is too large, uint256 overflow");
require(convertedAmount<=MAX_BEP2_TOTAL_SUPPLY, "amount is too large, exceed maximum bep2 token amount");
Expand Down Expand Up @@ -591,7 +591,14 @@ contract TokenHub is ITokenHub, System, IParamSubscriber, IApplication, ISystemR
assembly {
mstore(add(symbolBytes, 32), symbol)
}
uint256 symbolLength = symbolBytes.length;
uint8 symbolLength = 0;
for (uint8 j = 0; j < 32; j++) {
if (symbolBytes[j] != 0) {
symbolLength++;
} else {
break;
}
}
if (symbolLength < MINIMUM_BEP2E_SYMBOL_LEN + 5) {
return false;
}
Expand Down
11 changes: 9 additions & 2 deletions contracts/TokenHub.template
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ contract TokenHub is ITokenHub, System, IParamSubscriber, IApplication, ISystemR
require(bep2eTokenDecimals<=BEP2_TOKEN_DECIMALS || (bep2eTokenDecimals>BEP2_TOKEN_DECIMALS && amount.mod(10**(bep2eTokenDecimals-BEP2_TOKEN_DECIMALS))==0), "invalid transfer amount: precision loss in amount conversion");
convertedAmount = convertToBep2Amount(amount, bep2eTokenDecimals);// convert to bep2 amount
if (isMiniBEP2Token(bep2TokenSymbol)) {
require(convertedAmount > 1e8 , "For miniToken, the transfer amount must be either large than 1");
require(convertedAmount >= 1e8 , "For miniToken, the transfer amount must not be less than 1");
}
require(bep2eTokenDecimals>=BEP2_TOKEN_DECIMALS || (bep2eTokenDecimals<BEP2_TOKEN_DECIMALS && convertedAmount>amount), "amount is too large, uint256 overflow");
require(convertedAmount<=MAX_BEP2_TOTAL_SUPPLY, "amount is too large, exceed maximum bep2 token amount");
Expand Down Expand Up @@ -596,7 +596,14 @@ contract TokenHub is ITokenHub, System, IParamSubscriber, IApplication, ISystemR
assembly {
mstore(add(symbolBytes, 32), symbol)
}
uint256 symbolLength = symbolBytes.length;
uint8 symbolLength = 0;
for (uint8 j = 0; j < 32; j++) {
if (symbolBytes[j] != 0) {
symbolLength++;
} else {
break;
}
}
if (symbolLength < MINIMUM_BEP2E_SYMBOL_LEN + 5) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion genesis.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions validators.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const web3 = require("web3")
const RLP = require('rlp');

// Configure
const validators = [
Expand Down

0 comments on commit 9eb2c15

Please sign in to comment.