Skip to content

Commit

Permalink
resolves #959, souradeeps feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
wsdt committed Jul 5, 2023
1 parent 8f7ce6b commit e86871e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/boba/contracts/contracts/Teleportation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import '@openzeppelin/contracts/utils/Address.sol';
/**
* @title Teleportation
*
* Bridge the native asset or whitelisted ERC20 tokens between whitelisted networks (L2's/L1's).
*
* Bridge the native asset or whitelisted ERC20 tokens between whitelisted networks (L2's/L1's).
*
* @notice The contract itself emits events and locks the funds to be bridged/teleported. These events are then picked up by a backend service that releases the corresponding token or native asset on the destination network. Withdrawal periods (e.g. for optimistic rollups) are not handled by the contract itself, but would be handled on the Teleportation service if deemed necessary.
* @dev Implementation of the Teleportation service can be found at https://github.com/bobanetwork/boba within /packages/boba/teleportation if not moved.
*/
Expand Down Expand Up @@ -55,7 +55,7 @@ contract Teleportation is PausableUpgradeable, MulticallUpgradeable {
* Variables *
*************/

/// @dev Wallet that is being used to release teleported assets on the destination network.
/// @dev Wallet that is being used to release teleported assets on the destination network.
address public disburser;

/// @dev General owner wallet to change configurations.
Expand Down Expand Up @@ -255,7 +255,7 @@ contract Teleportation is PausableUpgradeable, MulticallUpgradeable {
require(_amount >= supToken.minDepositAmount, "Deposit amount too small");
require(_amount <= supToken.maxDepositAmount, "Deposit amount too big");
// minimal workaround to keep logic concise
require(address(0) != _token || (address(0) == _token && _amount == msg.value), "Native amount invalid");
require((address(0) != _token && msg.value == 0) || (address(0) == _token && _amount == msg.value), "Native amount invalid");

// check if the total amount transferred is smaller than the maximum amount of tokens can be transferred in 24 hours
// if it's out of 24 hours, reset the transferred amount to 0 and set the transferTimestampCheckPoint to the current time
Expand Down
24 changes: 24 additions & 0 deletions packages/boba/contracts/test/endToEndTests/teleportation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,30 @@ describe('Asset Teleportation Tests', async () => {
expect(preBalance.sub(_amount)).to.be.eq(postBalance.add(gasFee))
})

it('should not teleport native asset if amount is not equal msg.value', async () => {
const _amount = ethers.utils.parseEther('1')
await expect(
Proxy__Teleportation.teleportAsset(
ethers.constants.AddressZero,
_amount,
chainId4,
{ value: ethers.utils.parseEther('1.00001') }
)
).to.be.revertedWith('Native amount invalid')
})

it('should not teleport token if msg.value > 0', async () => {
const _amount = ethers.utils.parseEther('1')
await expect(
Proxy__Teleportation.teleportAsset(
L2Boba.address,
_amount,
chainId4,
{ value: _amount }
)
).to.be.revertedWith('Native amount invalid')
})

it('should disburse native asset and emit events', async () => {
const _amount = ethers.utils.parseEther('100')
const payload = [
Expand Down

0 comments on commit e86871e

Please sign in to comment.