Commit 5cc71170 authored by hezhengjun's avatar hezhengjun

only bridge token could be locked and tranfer to contract:evmxgo

parent adff0614
...@@ -17,7 +17,7 @@ import "../GoAssetBridge.sol"; ...@@ -17,7 +17,7 @@ import "../GoAssetBridge.sol";
contract BridgeBank is GoAssetBank, EvmAssetBank { contract BridgeBank is GoAssetBank, EvmAssetBank {
using SafeMath for uint256; using SafeMath for uint256;
address public operator; address public operator;
Oracle public oracle; Oracle public oracle;
GoAssetBridge public goAssetBridge; GoAssetBridge public goAssetBridge;
...@@ -82,8 +82,19 @@ contract BridgeBank is GoAssetBank, EvmAssetBank { ...@@ -82,8 +82,19 @@ contract BridgeBank is GoAssetBank, EvmAssetBank {
); );
_; _;
} }
/*
* @dev: Modifier to make sure this symbol not created now
*/
modifier onlyBridgeToken(address _token)
{
require(
(address(0) == _token) && (msg.value == 0),
"Only bridge token could be locked and tranfer to contract:evmxgo"
);
_;
}
/* /*
* @dev: Fallback function allows operator to send funds to the bank directly * @dev: Fallback function allows operator to send funds to the bank directly
* This feature is used for testing and is available at the operator's own risk. * This feature is used for testing and is available at the operator's own risk.
*/ */
...@@ -219,36 +230,20 @@ contract BridgeBank is GoAssetBank, EvmAssetBank { ...@@ -219,36 +230,20 @@ contract BridgeBank is GoAssetBank, EvmAssetBank {
) )
public public
availableNonce() availableNonce()
onlyBridgeToken(_token)
payable payable
{ {
string memory symbol; string memory symbol;
require(
// Chain33 deposit BridgeToken(_token).transferFrom(msg.sender, address(this), _amount),
if (msg.value > 0) { "Contract token allowances insufficient to complete this lock request"
require( );
_token == address(0), // Set symbol to the ERC20 token's symbol
"BTY deposits require the 'token' address to be the null address" symbol = BridgeToken(_token).symbol();
); require(
require( tokenAllow2Lock[keccak256(abi.encodePacked(symbol))] == _token,
msg.value == _amount,
"The transactions value must be equal the specified amount(BTY decimal is 8)"
);
// Set the the symbol to BTY
symbol = "BTY";
// ERC20 deposit
} else {
require(
BridgeToken(_token).transferFrom(msg.sender, address(this), _amount),
"Contract token allowances insufficient to complete this lock request"
);
// Set symbol to the ERC20 token's symbol
symbol = BridgeToken(_token).symbol();
require(
tokenAllow2Lock[keccak256(abi.encodePacked(symbol))] == _token,
'The token is not allowed to be locked from Chain33.' 'The token is not allowed to be locked from Chain33.'
); );
}
lockFunds( lockFunds(
msg.sender, msg.sender,
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment