Add bridge contract reference on ERC677BridgeToken
This commit is contained in:
parent
5892b37929
commit
ac473ca5dc
|
@ -15,6 +15,7 @@ contract ERC677BridgeToken is
|
|||
MintableToken {
|
||||
|
||||
Version.Version public getTokenInterfacesVersion = Version.Version(2, 0, 0);
|
||||
address public bridgeContract;
|
||||
|
||||
constructor(
|
||||
string _name,
|
||||
|
@ -22,6 +23,10 @@ contract ERC677BridgeToken is
|
|||
uint8 _decimals)
|
||||
public DetailedERC20(_name, _symbol, _decimals) {}
|
||||
|
||||
function setBridgeContract(address _bridgeContract) onlyOwner public {
|
||||
bridgeContract = _bridgeContract;
|
||||
}
|
||||
|
||||
modifier validRecipient(address _recipient) {
|
||||
require(_recipient != address(0) && _recipient != address(this));
|
||||
_;
|
||||
|
|
|
@ -133,6 +133,20 @@ async function deployHome() {
|
|||
homeNonce++
|
||||
console.log('[Home] Bridgeble Token: ', erc677token.options.address)
|
||||
|
||||
console.log('\nset bridge contract on ERC677BridgeToken')
|
||||
const setBridgeContractData = await erc677token.methods
|
||||
.setBridgeContract(homeBridgeStorage.options.address)
|
||||
.encodeABI({ from: DEPLOYMENT_ACCOUNT_ADDRESS })
|
||||
const setBridgeContract = await sendRawTxHome({
|
||||
data: setBridgeContractData,
|
||||
nonce: homeNonce,
|
||||
to: erc677token.options.address,
|
||||
privateKey: deploymentPrivateKey,
|
||||
url: HOME_RPC_URL
|
||||
})
|
||||
assert.equal(setBridgeContract.status, '0x1', 'Transaction Failed')
|
||||
homeNonce++
|
||||
|
||||
console.log('transferring ownership of Bridgeble token to homeBridge contract')
|
||||
const txOwnershipData = await erc677token.methods
|
||||
.transferOwnership(homeBridgeStorage.options.address)
|
||||
|
|
|
@ -181,6 +181,20 @@ async function deployForeign() {
|
|||
assert.equal(txInitializeBridge.status, '0x1', 'Transaction Failed')
|
||||
foreignNonce++
|
||||
|
||||
console.log('\nset bridge contract on ERC677BridgeToken')
|
||||
const setBridgeContractData = await erc677bridgeToken.methods
|
||||
.setBridgeContract(foreignBridgeStorage.options.address)
|
||||
.encodeABI({ from: DEPLOYMENT_ACCOUNT_ADDRESS })
|
||||
const setBridgeContract = await sendRawTxForeign({
|
||||
data: setBridgeContractData,
|
||||
nonce: foreignNonce,
|
||||
to: erc677bridgeToken.options.address,
|
||||
privateKey: deploymentPrivateKey,
|
||||
url: FOREIGN_RPC_URL
|
||||
})
|
||||
assert.equal(setBridgeContract.status, '0x1', 'Transaction Failed')
|
||||
foreignNonce++
|
||||
|
||||
console.log('transferring ownership of ERC677BridgeToken token to foreignBridge contract')
|
||||
const txOwnershipData = await erc677bridgeToken.methods
|
||||
.transferOwnership(foreignBridgeStorage.options.address)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const POA20 = artifacts.require("ERC677BridgeToken.sol");
|
||||
const ERC677ReceiverTest = artifacts.require("ERC677ReceiverTest.sol")
|
||||
const {ERROR_MSG} = require('./setup');
|
||||
const { ERROR_MSG, ZERO_ADDRESS} = require('./setup');
|
||||
|
||||
contract('ERC677BridgeToken', async (accounts) => {
|
||||
let token
|
||||
|
@ -31,6 +31,29 @@ contract('ERC677BridgeToken', async (accounts) => {
|
|||
minor.should.be.bignumber.gte(0)
|
||||
patch.should.be.bignumber.gte(0)
|
||||
})
|
||||
|
||||
describe('#bridgeContract', async() => {
|
||||
it('can set bridge contract', async () => {
|
||||
const bridgeAddress = '0x630d2c61234224fd9705457be61b830a0ea81822';
|
||||
(await token.bridgeContract()).should.be.equal(ZERO_ADDRESS);
|
||||
|
||||
await token.setBridgeContract(bridgeAddress).should.be.fulfilled;
|
||||
|
||||
(await token.bridgeContract()).should.be.equal(bridgeAddress);
|
||||
})
|
||||
|
||||
it('only owner can set bridge contract', async () => {
|
||||
const bridgeAddress = '0x630d2c61234224fd9705457be61b830a0ea81822';
|
||||
(await token.bridgeContract()).should.be.equal(ZERO_ADDRESS);
|
||||
|
||||
await token.setBridgeContract(bridgeAddress, {from: user }).should.be.rejectedWith(ERROR_MSG);
|
||||
(await token.bridgeContract()).should.be.equal(ZERO_ADDRESS);
|
||||
|
||||
await token.setBridgeContract(bridgeAddress, {from: owner }).should.be.fulfilled;
|
||||
(await token.bridgeContract()).should.be.equal(bridgeAddress);
|
||||
})
|
||||
})
|
||||
|
||||
describe('#mint', async() => {
|
||||
it('can mint by owner', async () => {
|
||||
(await token.totalSupply()).should.be.bignumber.equal(0);
|
||||
|
|
Loading…
Reference in New Issue