Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
fix token assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
simonDos committed Nov 9, 2023
1 parent d90805d commit a2b6042
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ test-blockchain/data
*.log

.DS_Store
.vscode
*.env

coverage/
Expand Down
2 changes: 1 addition & 1 deletion contracts/root/depositManager/DepositManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ contract DepositManager is DepositManagerStorage, IDepositManager, ERC721Holder
}
// new: bridge POL as MATIC, child chain behaviour does not change
else if (_token == registry.contractMap(keccak256("pol"))) {
_token == registry.contractMap(keccak256("matic"));
_token = registry.contractMap(keccak256("matic"));
}

deposits[_depositId] = DepositBlock(keccak256(abi.encodePacked(_user, _token, _amountOrToken)), now);
Expand Down
5 changes: 3 additions & 2 deletions test/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export async function depositOnRoot(
const NewDepositBlockEvent = logs.find(
log => log.event === 'NewDepositBlock'
)
return NewDepositBlockEvent.args.depositBlockId
return NewDepositBlockEvent
}

export async function deposit(
Expand All @@ -265,13 +265,14 @@ export async function deposit(
) {
let depositBlockId
if (options.rootDeposit) {
depositBlockId = await depositOnRoot(
const newDepositBlockEvent = await depositOnRoot(
depositManager,
rootContract,
user,
amountOrToken,
options
)
depositBlockId = newDepositBlockEvent.args.depositBlockId
} else {
depositBlockId = '0x' + crypto.randomBytes(32).toString('hex')
}
Expand Down
8 changes: 6 additions & 2 deletions test/integration/root/DepositManagerUpdate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,18 @@ contract('DepositManager Update @skip-on-coverage', async function(accounts) {
const bob = '0x' + crypto.randomBytes(20).toString('hex')

// using the utils function more granularly here so we can call fireDepositFromMainToMatic with the correct token address
const depositBlockId = await utils.depositOnRoot(
const newDepositBlockEvent = await utils.depositOnRoot(
depositManager,
pol,
bob,
amount,
{ rootDeposit: true, erc20: true }
)
await utils.fireDepositFromMainToMatic(childContracts.childChain, '0xa', bob, e20.rootERC20.address, amount, depositBlockId)

// token has been changed to MATIC
assert.strictEqual(newDepositBlockEvent.args.token, e20.rootERC20.address)

await utils.fireDepositFromMainToMatic(childContracts.childChain, '0xa', bob, e20.rootERC20.address, amount, newDepositBlockEvent.args.depositBlockId)

// deposit on child chain is technically still in MATIC
utils.assertBigNumberEquality(await e20.childToken.balanceOf(bob), amount)
Expand Down

0 comments on commit a2b6042

Please sign in to comment.