Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R4R: fix miniToken checker issue #21

Merged
merged 1 commit into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.