1. Upgrade openzeppelin to 1.9.0
2. Fix claimTokens on Foreign side 3. Fix compiler warnings
This commit is contained in:
parent
7bd9ac3f81
commit
27123afdf9
|
@ -1,5 +1,5 @@
|
|||
pragma solidity 0.4.21;
|
||||
import "zeppelin-solidity/contracts/token/ERC20/ERC20.sol";
|
||||
import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
|
||||
|
||||
|
||||
contract ERC677 is ERC20 {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
pragma solidity 0.4.21;
|
||||
|
||||
import "zeppelin-solidity/contracts/token/ERC20/BurnableToken.sol";
|
||||
import "zeppelin-solidity/contracts/token/ERC20/MintableToken.sol";
|
||||
import "zeppelin-solidity/contracts/token/ERC20/DetailedERC20.sol";
|
||||
import "openzeppelin-solidity/contracts/token/ERC20/BurnableToken.sol";
|
||||
import "openzeppelin-solidity/contracts/token/ERC20/MintableToken.sol";
|
||||
import "openzeppelin-solidity/contracts/token/ERC20/DetailedERC20.sol";
|
||||
import "./IBurnableMintableERC677Token.sol";
|
||||
import "./ERC677Receiver.sol";
|
||||
|
||||
|
@ -65,7 +65,7 @@ contract POA20 is
|
|||
|
||||
DetailedERC20 token = DetailedERC20(_token);
|
||||
uint256 balance = token.balanceOf(address(this));
|
||||
token.transfer(_to, balance);
|
||||
require(token.transfer(_to, balance));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import "../libraries/Message.sol";
|
|||
import "./U_Validatable.sol";
|
||||
import "../IBurnableMintableERC677Token.sol";
|
||||
import "../ERC677Receiver.sol";
|
||||
import "zeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol";
|
||||
import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol";
|
||||
|
||||
|
||||
contract ForeignBridge is ERC677Receiver, Validatable {
|
||||
|
@ -44,7 +44,7 @@ contract ForeignBridge is ERC677Receiver, Validatable {
|
|||
return isInitialized();
|
||||
}
|
||||
|
||||
function onTokenTransfer(address _from, uint256 _value, bytes _data) external returns(bool) {
|
||||
function onTokenTransfer(address _from, uint256 _value, bytes /*_data*/) external returns(bool) {
|
||||
require(msg.sender == address(erc677token()));
|
||||
require(withinLimit(_value));
|
||||
setTotalSpentPerDay(getCurrentDay(), totalSpentPerDay(getCurrentDay()).add(_value));
|
||||
|
@ -63,7 +63,7 @@ contract ForeignBridge is ERC677Receiver, Validatable {
|
|||
uintStorage[keccak256("minPerTx")] = _minPerTx;
|
||||
}
|
||||
|
||||
function claimTokens(address _token, address _to) public onlyOwner {
|
||||
function claimTokens(address _token, address _to) external onlyOwner {
|
||||
require(_to != address(0));
|
||||
if (_token == address(0)) {
|
||||
_to.transfer(address(this).balance);
|
||||
|
@ -72,7 +72,10 @@ contract ForeignBridge is ERC677Receiver, Validatable {
|
|||
|
||||
ERC20Basic token = ERC20Basic(_token);
|
||||
uint256 balance = token.balanceOf(this);
|
||||
token.transfer(_to, balance);
|
||||
require(token.transfer(_to, balance));
|
||||
}
|
||||
|
||||
function claimTokensFromErc677(address _token, address _to) external onlyOwner {
|
||||
erc677token().claimTokens(_token, _to);
|
||||
}
|
||||
|
||||
|
@ -178,7 +181,7 @@ contract ForeignBridge is ERC677Receiver, Validatable {
|
|||
}
|
||||
}
|
||||
|
||||
function isAlreadyProcessed(uint256 _number) public view returns(bool) {
|
||||
function isAlreadyProcessed(uint256 _number) public pure returns(bool) {
|
||||
return _number & 2**255 == 2**255;
|
||||
}
|
||||
|
||||
|
@ -210,7 +213,7 @@ contract ForeignBridge is ERC677Receiver, Validatable {
|
|||
return boolStorage[keccak256("isInitialized")];
|
||||
}
|
||||
|
||||
function homeGasPrice() internal view returns(uint256) {
|
||||
function homeGasPrice() internal pure returns(uint256) {
|
||||
return 1000000000 wei;
|
||||
}
|
||||
|
||||
|
|
|
@ -1889,11 +1889,6 @@
|
|||
"is-obj": "1.0.1"
|
||||
}
|
||||
},
|
||||
"dotenv": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-4.0.0.tgz",
|
||||
"integrity": "sha1-hk7xN5rO1Vzm+V3r7NzhefegzR0="
|
||||
},
|
||||
"duplexer": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz",
|
||||
|
@ -2087,16 +2082,6 @@
|
|||
"webpack-cli": "2.0.13"
|
||||
}
|
||||
},
|
||||
"ethjs-abi": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/ethjs-abi/-/ethjs-abi-0.2.1.tgz",
|
||||
"integrity": "sha1-4KepOn6BFjqUR3utVu3lJKtt5TM=",
|
||||
"requires": {
|
||||
"bn.js": "4.11.6",
|
||||
"js-sha3": "0.5.5",
|
||||
"number-to-bn": "1.7.0"
|
||||
}
|
||||
},
|
||||
"ethjs-unit": {
|
||||
"version": "0.1.6",
|
||||
"resolved": "https://registry.npmjs.org/ethjs-unit/-/ethjs-unit-0.1.6.tgz",
|
||||
|
@ -4400,7 +4385,8 @@
|
|||
"js-sha3": {
|
||||
"version": "0.5.5",
|
||||
"resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.5.tgz",
|
||||
"integrity": "sha1-uvDA6MVK1ZA0R9+Wreekobynmko="
|
||||
"integrity": "sha1-uvDA6MVK1ZA0R9+Wreekobynmko=",
|
||||
"dev": true
|
||||
},
|
||||
"js-tokens": {
|
||||
"version": "3.0.2",
|
||||
|
@ -5820,6 +5806,11 @@
|
|||
"integrity": "sha1-XG2ixdflgx6P+jlklQ+NZnSskLg=",
|
||||
"dev": true
|
||||
},
|
||||
"openzeppelin-solidity": {
|
||||
"version": "1.9.0",
|
||||
"resolved": "https://registry.npmjs.org/openzeppelin-solidity/-/openzeppelin-solidity-1.9.0.tgz",
|
||||
"integrity": "sha512-MGI8clDbjrfWUg90AM82O+CHOaabtE2u9HyaUhBMKfWdIaO1urRUIgXIrEuloLvFEBHb5rtcgTARb5DkhUB4KQ=="
|
||||
},
|
||||
"optimist": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz",
|
||||
|
@ -9067,15 +9058,6 @@
|
|||
"integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM="
|
||||
}
|
||||
}
|
||||
},
|
||||
"zeppelin-solidity": {
|
||||
"version": "1.8.0",
|
||||
"resolved": "https://registry.npmjs.org/zeppelin-solidity/-/zeppelin-solidity-1.8.0.tgz",
|
||||
"integrity": "sha512-7Mxq6Y7EES0PSLrRF6v0EVYqBVRRo8hFrr7m3jEs69VbbQ5kpANzizeEdbP1/PWKSOmBOg208qP2vSA0FlzFLA==",
|
||||
"requires": {
|
||||
"dotenv": "4.0.0",
|
||||
"ethjs-abi": "0.2.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
"dependencies": {
|
||||
"ganache-cli": "^6.1.0",
|
||||
"nodemon": "^1.17.2",
|
||||
"openzeppelin-solidity": "^1.9.0",
|
||||
"truffle": "^4.1.6",
|
||||
"web3-utils": "^1.0.0-beta.34",
|
||||
"zeppelin-solidity": "^1.8.0"
|
||||
"web3-utils": "^1.0.0-beta.34"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^4.1.2",
|
||||
|
|
|
@ -484,17 +484,15 @@ contract('ForeignBridge', async (accounts) => {
|
|||
|
||||
let tokenSecond = await POA20.new("Roman Token", "RST", 18);
|
||||
|
||||
await tokenSecond.mint(accounts[0], 500).should.be.fulfilled;
|
||||
'500'.should.be.bignumber.equal(await tokenSecond.balanceOf(accounts[0]))
|
||||
await tokenSecond.transfer(foreignBridge.address, '350');
|
||||
await tokenSecond.mint(accounts[0], 150).should.be.fulfilled;
|
||||
'150'.should.be.bignumber.equal(await tokenSecond.balanceOf(accounts[0]))
|
||||
await tokenSecond.transfer(token.address, '150');
|
||||
'0'.should.be.bignumber.equal(await tokenSecond.balanceOf(accounts[0]))
|
||||
'350'.should.be.bignumber.equal(await tokenSecond.balanceOf(foreignBridge.address))
|
||||
'150'.should.be.bignumber.equal(await tokenSecond.balanceOf(token.address))
|
||||
|
||||
await foreignBridge.claimTokens(tokenSecond.address, accounts[3], {from: owner});
|
||||
await foreignBridge.claimTokensFromErc677(tokenSecond.address, accounts[3], {from: owner});
|
||||
'0'.should.be.bignumber.equal(await tokenSecond.balanceOf(foreignBridge.address))
|
||||
'500'.should.be.bignumber.equal(await tokenSecond.balanceOf(accounts[3]))
|
||||
'150'.should.be.bignumber.equal(await tokenSecond.balanceOf(accounts[3]))
|
||||
})
|
||||
})
|
||||
describe('#isAlreadyProcessed', async () => {
|
||||
|
|
|
@ -13,7 +13,7 @@ contract ERC677ReceiverTest is ERC677Receiver {
|
|||
from = _from;
|
||||
value = _value;
|
||||
data = _data;
|
||||
require(this.call(_data));
|
||||
require(address(this).call(_data));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue