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

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
geoff-vball committed Apr 3, 2024
1 parent 105e268 commit 03530c0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion contracts/src/ERC20Destination.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ contract ERC20Destination is IERC20Bridge, TeleporterTokenDestination, ERC20 {
amount = _deposit(amount);
require(
amount > input.primaryFee + input.secondaryFee,
"TeleporterTokenDestination: insufficient amount to cover fees"
"ERC20Destination: insufficient amount to cover fees"
);

amount -= input.primaryFee;
Expand Down
13 changes: 9 additions & 4 deletions contracts/src/NativeTokenDestination.sol
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,18 @@ contract NativeTokenDestination is
require(
currentReserveImbalance == 0, "NativeTokenDestination: contract undercollateralized"
);
uint256 amount = msg.value;
require(
amount > input.primaryFee + input.secondaryFee,
"NativeTokenDestination: insufficient amount to cover fees"
);

// TODO we need to guarantee that this function deposits the whole amount, or find a workaround.
_deposit(input.primaryFee);
if (input.primaryFee > 0) {
_deposit(input.primaryFee);
amount -= input.primaryFee;
}

uint256 amount = msg.value - input.primaryFee;
_burn(amount);

_send(input, _scaleTokens(amount, false));
Expand Down Expand Up @@ -260,8 +267,6 @@ contract NativeTokenDestination is
* @dev See {TeleportTokenDestination-_withdraw}
*/
function _withdraw(address recipient, uint256 amount) internal virtual override {
require(recipient != address(0), "NativeTokenDestination: zero recipient address");

uint256 scaledAmount = _scaleTokens(amount, true);

// If the contract has not yet been collateralized, we will deduct as many tokens
Expand Down
5 changes: 5 additions & 0 deletions contracts/test/NativeTokenDestinationTests.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ contract NativeTokenDestinationTest is NativeTokenBridgeTest, TeleporterTokenDes
function setUp() public override {
TeleporterTokenDestinationTest.setUp();

vm.mockCall(
NATIVE_MINTER_PRECOMPILE_ADDRESS,
abi.encodeWithSelector(INativeMinter.mintNativeCoin.selector),
""
);
mockWrappedToken = new ExampleWAVAX();
app = new NativeTokenDestination({
teleporterRegistryAddress: MOCK_TELEPORTER_REGISTRY_ADDRESS,
Expand Down

0 comments on commit 03530c0

Please sign in to comment.