Skip to content

Commit

Permalink
Add claimTokensFromErc677 on ForeignBridgeErc677ToErc677
Browse files Browse the repository at this point in the history
  • Loading branch information
patitonar committed Jul 1, 2019
1 parent bb3c6bc commit bba6829
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity 0.4.24;

import "./BasicForeignBridgeErcToErc.sol";
import "../ERC677Bridge.sol";
import "../../interfaces/IBurnableMintableERC677Token.sol";


contract ForeignBridgeErc677ToErc677 is ERC677Bridge, BasicForeignBridgeErcToErc {
Expand Down Expand Up @@ -40,6 +41,10 @@ contract ForeignBridgeErc677ToErc677 is ERC677Bridge, BasicForeignBridgeErcToErc
return isInitialized();
}

function claimTokensFromErc677(address _token, address _to) external onlyIfUpgradeabilityOwner {
IBurnableMintableERC677Token(erc677token()).claimTokens(_token, _to);
}

function erc20token() public view returns(ERC20Basic) {
return erc677token();
}
Expand Down
37 changes: 37 additions & 0 deletions test/erc_to_erc/foreign_bridge.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,43 @@ contract('ForeignBridge_ERC20_to_ERC20', async accounts => {
expect(await tokenSecond.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO)
expect(await tokenSecond.balanceOf(accounts[3])).to.be.bignumber.equal(halfEther)
})
it('can call claimTokens on tokenAddress', async () => {
const owner = accounts[0]
token = await ERC677BridgeToken.new('Some ERC20', 'RSZT', 18)
const foreignBridgeImpl = await ForeignBridgeErc677ToErc677.new()
const storageProxy = await EternalStorageProxy.new().should.be.fulfilled
await storageProxy.upgradeTo('1', foreignBridgeImpl.address).should.be.fulfilled
const foreignBridge = await ForeignBridgeErc677ToErc677.at(storageProxy.address)
await foreignBridge.initialize(
validatorContract.address,
token.address,
requireBlockConfirmations,
gasPrice,
dailyLimit,
maxPerTx,
minPerTx,
homeDailyLimit,
homeMaxPerTx,
owner
)
await token.transferOwnership(foreignBridge.address).should.be.fulfilled

const tokenSecond = await ERC677BridgeToken.new('Test Token', 'TST', 18)

await tokenSecond.mint(accounts[0], halfEther).should.be.fulfilled
expect(await tokenSecond.balanceOf(accounts[0])).to.be.bignumber.equal(halfEther)

await tokenSecond.transfer(token.address, halfEther)
expect(await tokenSecond.balanceOf(accounts[0])).to.be.bignumber.equal(ZERO)
expect(await tokenSecond.balanceOf(token.address)).to.be.bignumber.equal(halfEther)

await foreignBridge
.claimTokensFromErc677(tokenSecond.address, accounts[3], { from: accounts[3] })
.should.be.rejectedWith(ERROR_MSG)
await foreignBridge.claimTokensFromErc677(tokenSecond.address, accounts[3], { from: owner }).should.be.fulfilled
expect(await tokenSecond.balanceOf(token.address)).to.be.bignumber.equal(ZERO)
expect(await tokenSecond.balanceOf(accounts[3])).to.be.bignumber.equal(halfEther)
})
})
describe('#ForeignBridgeErc677ToErc677_onTokenTransfer', async () => {
it('can only be called from token contract', async () => {
Expand Down

0 comments on commit bba6829

Please sign in to comment.