Skip to content

Commit

Permalink
Adding transfer ownership to ForeignMultiAMBErc20ToErc677 bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
leonprou committed Apr 16, 2024
1 parent be8a2d8 commit e1f814f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ contract ForeignMultiAMBErc20ToErc677 is BasicMultiAMBErc20ToErc677 {
return isInitialized();
}

/**
* @dev Transfer token ownership to the new owner. The metod is called by the bridge owner to deprecate the bridge.
* @param _token address address of the token to move ownership.
* @param _owner address address of the new owner.
*/
function transferTokenOwnership( address _token, address _owner) external onlyOwner {
IBurnableMintableERC677Token(_token)
.transferOwnership(_owner);
}

/**
* @dev Executes action on the request to withdraw tokens relayed from the other network
* @param _token address of the token contract
Expand Down
31 changes: 31 additions & 0 deletions test/multi_amb_erc20_to_erc677/foreign_mediator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,37 @@ contract('ForeignMultiAMBErc20ToErc677', async accounts => {
})
})

describe('transferTokenOwnership', () => {
let tokenOwner
beforeEach(async () => {
await contract.initialize(
ambBridgeContract.address,
otherSideMediator.address,
[dailyLimit, maxPerTx, minPerTx],
[executionDailyLimit, executionMaxPerTx],
maxGasPerTx,
owner
).should.be.fulfilled
tokenOwner = accounts[0]
await token.transferOwnership(contract.address).should.be.fulfilled
})

it('should transfer ownership', async () => {
// Given
expect(await token.owner()).to.be.equal(contract.address)


// When
const newOwner = accounts[7]
await contract.transferTokenOwnership(token.address, ZERO_ADDRESS, { from: owner }).should.be.rejected
await contract.transferTokenOwnership(token.address, newOwner, { from: newOwner }).should.be.rejected
await contract.transferTokenOwnership(token.address, newOwner, { from: owner }).should.be.fulfilled

// // Then
expect(await token.owner()).to.be.equal(newOwner)
})
})

describe('getBridgeMode', () => {
it('should return mediator mode and interface', async function() {
const bridgeModeHash = '0xb1516c26' // 4 bytes of keccak256('multi-erc-to-erc-amb')
Expand Down

0 comments on commit e1f814f

Please sign in to comment.