Commit b1a0fb3e authored by hezhengjun's avatar hezhengjun Committed by whisker

token address fetched in sol contract

parent a7904920
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -19,6 +19,7 @@ contract Chain33Bank {
mapping(bytes32 => Chain33Deposit) chain33Deposits;
mapping(bytes32 => Chain33Burn) chain33Burns;
mapping(address => DepositBurnCount) depositBurnCounts;
mapping(bytes32 => address) public token2address;
struct Chain33Deposit {
bytes chain33Sender;
......@@ -78,6 +79,18 @@ contract Chain33Bank {
_;
}
/*
* @dev: Modifier to make sure this symbol not created now
*/
modifier created(string memory _symbol)
{
require(
hasBridgeTokenCreated(_symbol),
"The symbol has not been created yet"
);
_;
}
/*
* @dev: Constructor, sets bridgeTokenCount
*/
......@@ -206,8 +219,8 @@ contract Chain33Bank {
bridgeTokenCreated[symHash] = true;
depositBurnCounts[newBridgeTokenAddress] = DepositBurnCount(
uint256(0),
uint256(0)
);
uint256(0));
token2address[symHash] = newBridgeTokenAddress;
emit LogNewBridgeToken(
newBridgeTokenAddress,
......@@ -359,4 +372,13 @@ contract Chain33Bank {
deposit.amount
);
}
function getToken2address(string memory _symbol)
created(_symbol)
public view returns(address)
{
bytes32 symHash = keccak256(abi.encodePacked(_symbol));
return token2address[symHash];
}
}
\ No newline at end of file
......@@ -208,7 +208,6 @@ contract Chain33Bridge {
bytes memory _chain33Sender,
address payable _ethereumReceiver,
address _originalValidator,
address _tokenAddress,
string memory _symbol,
uint256 _amount
)
......@@ -220,13 +219,15 @@ contract Chain33Bridge {
prophecyClaimCount = prophecyClaimCount.add(1);
ClaimType claimType = ClaimType(_claimType);
address tokenAddress = bridgeBank.getToken2address(_symbol);
// Create the new ProphecyClaim
ProphecyClaim memory prophecyClaim = ProphecyClaim(
claimType,
_chain33Sender,
_ethereumReceiver,
_originalValidator,
_tokenAddress,
tokenAddress,
_symbol,
_amount,
Status.Pending
......@@ -241,7 +242,7 @@ contract Chain33Bridge {
_chain33Sender,
_ethereumReceiver,
_originalValidator,
_tokenAddress,
tokenAddress,
_symbol,
_amount
);
......
......@@ -130,7 +130,6 @@ contract Oracle {
ClaimType _claimType,
bytes memory _chain33Sender,
address payable _ethereumReceiver,
address _tokenAddress,
string memory _symbol,
uint256 _amount,
bytes32 _claimID,
......@@ -164,7 +163,6 @@ contract Oracle {
_chain33Sender,
_ethereumReceiver,
validatorAddress,
_tokenAddress,
_symbol,
_amount);
}
......
......@@ -467,7 +467,7 @@ func MakeNewProphecyClaim(newProphecyClaimPara *NewProphecyClaimPara, client *et
return "", err
}
tx, err := x2EthContracts.Oracle.NewOracleClaim(authVali, newProphecyClaimPara.ClaimType, newProphecyClaimPara.Chain33Sender, ethReceiver, newProphecyClaimPara.TokenAddr, newProphecyClaimPara.Symbol, amount, claimID, signature)
tx, err := x2EthContracts.Oracle.NewOracleClaim(authVali, newProphecyClaimPara.ClaimType, newProphecyClaimPara.Chain33Sender, ethReceiver, newProphecyClaimPara.Symbol, amount, claimID, signature)
if nil != err {
return "", err
}
......
......@@ -40,7 +40,7 @@ func RelayOracleClaimToEthereum(oracleInstance *generated.Oracle, client *ethcli
return "", err
}
tx, err := oracleInstance.NewOracleClaim(auth, uint8(claim.ClaimType), claim.Chain33Sender, claim.EthereumReceiver, claim.TokenContractAddress, claim.Symbol, claim.Amount, claimID, signature)
tx, err := oracleInstance.NewOracleClaim(auth, uint8(claim.ClaimType), claim.Chain33Sender, claim.EthereumReceiver, claim.Symbol, claim.Amount, claimID, signature)
if nil != err {
txslog.Error("RelayProphecyClaimToEthereum", "NewOracleClaim failed due to:", err.Error())
return "", err
......
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