Skip to content

Commit

Permalink
Return back erc677token() for native-to-erc mediator
Browse files Browse the repository at this point in the history
  • Loading branch information
k1rill-fedoseev committed Jun 26, 2020
1 parent 65c0a17 commit 445c009
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Expand Up @@ -54,10 +54,9 @@ contract ForeignAMBNativeToErc20 is BasicAMBNativeToErc20, ReentrancyGuard, Base

/**
* @dev Public getter for token contract.
* Internal _erc677token() is hidden from the end users, in order to not confuse them with the supported token standard.
* @return address of the used token contract
*/
function erc20token() external view returns (ERC677) {
function erc677token() public view returns (ERC677) {
return _erc677token();
}

Expand All @@ -80,7 +79,7 @@ contract ForeignAMBNativeToErc20 is BasicAMBNativeToErc20, ReentrancyGuard, Base
}
}

IBurnableMintableERC677Token(_erc677token()).mint(_receiver, valueToMint);
IBurnableMintableERC677Token(erc677token()).mint(_receiver, valueToMint);
emit TokensBridged(_receiver, valueToMint, _messageId);
}

Expand All @@ -90,7 +89,7 @@ contract ForeignAMBNativeToErc20 is BasicAMBNativeToErc20, ReentrancyGuard, Base
* @param _value amount of tokens to be received
*/
function executeActionOnFixedTokens(address _receiver, uint256 _value) internal {
IBurnableMintableERC677Token(_erc677token()).mint(_receiver, _value);
IBurnableMintableERC677Token(erc677token()).mint(_receiver, _value);
}

/**
Expand Down Expand Up @@ -118,7 +117,7 @@ contract ForeignAMBNativeToErc20 is BasicAMBNativeToErc20, ReentrancyGuard, Base
// When transferFrom is called, after the transfer, the ERC677 token will call onTokenTransfer from this contract
// which will call passMessage.
require(!lock());
ERC677 token = _erc677token();
ERC677 token = erc677token();
address to = address(this);
require(withinLimit(_value));
setTotalSpentPerDay(getCurrentDay(), totalSpentPerDay(getCurrentDay()).add(_value));
Expand Down Expand Up @@ -149,7 +148,7 @@ contract ForeignAMBNativeToErc20 is BasicAMBNativeToErc20, ReentrancyGuard, Base
* otherwise it will be empty.
*/
function onTokenTransfer(address _from, uint256 _value, bytes _data) external bridgeMessageAllowed returns (bool) {
ERC677 token = _erc677token();
ERC677 token = erc677token();
require(msg.sender == address(token));
if (!lock()) {
require(withinLimit(_value));
Expand Down Expand Up @@ -180,7 +179,7 @@ contract ForeignAMBNativeToErc20 is BasicAMBNativeToErc20, ReentrancyGuard, Base
* @param _fee amount of tokens to be minted.
*/
function onFeeDistribution(address _feeManager, uint256 _fee) internal {
IBurnableMintableERC677Token(_erc677token()).mint(_feeManager, _fee);
IBurnableMintableERC677Token(erc677token()).mint(_feeManager, _fee);
}

/**
Expand All @@ -189,7 +188,7 @@ contract ForeignAMBNativeToErc20 is BasicAMBNativeToErc20, ReentrancyGuard, Base
* @param _to address that will receive the locked tokens on this contract.
*/
function claimTokensFromErc677(address _token, address _to) external onlyIfUpgradeabilityOwner {
IBurnableMintableERC677Token(_erc677token()).claimTokens(_token, _to);
IBurnableMintableERC677Token(erc677token()).claimTokens(_token, _to);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions test/amb_native_to_erc20/foreign_mediator.test.js
Expand Up @@ -74,7 +74,7 @@ contract('ForeignAMBNativeToErc20', async accounts => {
expect(await contract.requestGasLimit()).to.be.bignumber.equal(ZERO)
expect(await contract.decimalShift()).to.be.bignumber.equal(ZERO)
expect(await contract.owner()).to.be.equal(ZERO_ADDRESS)
expect(await contract.erc20token()).to.be.equal(ZERO_ADDRESS)
expect(await contract.erc677token()).to.be.equal(ZERO_ADDRESS)
expect(await contract.feeManagerContract()).to.be.equal(ZERO_ADDRESS)

// When
Expand Down Expand Up @@ -237,7 +237,7 @@ contract('ForeignAMBNativeToErc20', async accounts => {
expect(await contract.requestGasLimit()).to.be.bignumber.equal(maxGasPerTx)
expect(await contract.decimalShift()).to.be.bignumber.equal(ZERO)
expect(await contract.owner()).to.be.equal(owner)
expect(await contract.erc20token()).to.be.equal(token.address)
expect(await contract.erc677token()).to.be.equal(token.address)
expect(await contract.feeManagerContract()).to.be.equal(feeManager.address)

expectEventInLogs(logs, 'ExecutionDailyLimitChanged', { newLimit: executionDailyLimit })
Expand Down

0 comments on commit 445c009

Please sign in to comment.