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 89c107f commit 105e268
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 36 deletions.
2 changes: 1 addition & 1 deletion abi-bindings/go/ERC20Destination/ERC20Destination.go

Large diffs are not rendered by default.

49 changes: 35 additions & 14 deletions abi-bindings/go/NativeTokenDestination/NativeTokenDestination.go

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
5 changes: 0 additions & 5 deletions contracts/pkg/sumdb/sum.golang.org/latest

This file was deleted.

25 changes: 11 additions & 14 deletions contracts/src/NativeTokenDestination.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

pragma solidity 0.8.18;

import {TeleporterTokenDestination, TeleporterFeeInfo, TeleporterMessageInput} from "./TeleporterTokenDestination.sol";
import {
TeleporterTokenDestination,
TeleporterFeeInfo,
TeleporterMessageInput
} from "./TeleporterTokenDestination.sol";
import {Address} from "@openzeppelin/[email protected]/utils/Address.sol";
import {IWarpMessenger} from
"@avalabs/[email protected]/contracts/interfaces/IWarpMessenger.sol";
import {INativeMinter} from
"@avalabs/[email protected]/contracts/interfaces/INativeMinter.sol";
import {INativeTokenDestination} from "./interfaces/INativeTokenDestination.sol";
import {TeleporterOwnerUpgradeable} from "@teleporter/upgrades/TeleporterOwnerUpgradeable.sol";
import {SafeERC20TransferFrom} from "@teleporter/SafeERC20TransferFrom.sol";
import {IERC20} from "@openzeppelin/[email protected]/token/ERC20/IERC20.sol";
// We need IAllowList as an indirect dependency in order to compile.
// solhint-disable-next-line no-unused-import
import {IAllowList} from "@avalabs/[email protected]/contracts/interfaces/IAllowList.sol";
Expand Down Expand Up @@ -164,7 +164,9 @@ contract NativeTokenDestination is
* transfer to the recipient. The caller must be the wrapped native token contract.
*/
receive() external payable {
require(msg.sender == feeTokenAddress, "NativeTokenDestination: invalid receive payable sender");
require(
msg.sender == feeTokenAddress, "NativeTokenDestination: invalid receive payable sender"
);
}

/**
Expand All @@ -176,11 +178,9 @@ contract NativeTokenDestination is
);

// TODO we need to guarantee that this function deposits the whole amount, or find a workaround.
uint256 amount = msg.value;
_deposit(amount);
// token.approve(address(_getTeleporterMessenger()), input.primaryFee);
_deposit(input.primaryFee);

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

_send(input, _scaleTokens(amount, false));
Expand All @@ -189,9 +189,7 @@ contract NativeTokenDestination is
/**
* @dev See {INativeTokenDestination-reportTotalBurnedTxFees}.
*/
function reportBurnedTxFees(
address[] calldata allowedRelayerAddresses
) external payable {
function reportBurnedTxFees(address[] calldata allowedRelayerAddresses) external payable {
uint256 adjustedFeeAmount;
if (msg.value > 0) {
adjustedFeeAmount = _deposit(msg.value);
Expand Down Expand Up @@ -300,7 +298,6 @@ contract NativeTokenDestination is
*/
function _burn(uint256 amount) internal virtual override {
// Burn native token by sending to BURN_FOR_TRANSFER_ADDRESS
token.withdraw(amount);
Address.sendValue(payable(BURN_FOR_TRANSFER_ADDRESS), amount);
}

Expand Down
1 change: 0 additions & 1 deletion contracts/src/interfaces/INativeTokenDestination.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

pragma solidity 0.8.18;

import {TeleporterFeeInfo} from "@teleporter/ITeleporterMessenger.sol";
import {INativeTokenBridge} from "./INativeTokenBridge.sol";

/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/NativeTokenDestinationTests.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pragma solidity 0.8.18;

import {TeleporterTokenDestinationTest} from "./TeleporterTokenDestinationTests.t.sol";
import {NativeTokenBridgeTest} from "./NativeTokenBridgeTests.t.sol";
import {NativeTokenDestination, TeleporterMessageInput, TeleporterFeeInfo, SendTokensInput} from "../src/NativeTokenDestination.sol";
import {NativeTokenDestination, TeleporterMessageInput, TeleporterFeeInfo} from "../src/NativeTokenDestination.sol";
import {IWrappedNativeToken} from "../src/interfaces/IWrappedNativeToken.sol";
import {ExampleWAVAX} from "../src/mocks/ExampleWAVAX.sol";
import {INativeMinter} from
Expand Down

0 comments on commit 105e268

Please sign in to comment.