Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: wormhole-foundation/native-token-transfers
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f4e10ab4c2a3b0f53ae7220d734fa255c43b109c
Choose a base ref
..
head repository: wormhole-foundation/native-token-transfers
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e9e648f1ab2a4e2c899109835cb2dee4f3d4aa54
Choose a head ref
5 changes: 5 additions & 0 deletions evm/README.md
Original file line number Diff line number Diff line change
@@ -244,3 +244,8 @@ bash sh/configure_wormhole_ntt.sh -n NETWORK_TYPE -c CHAIN_NAME -k PRIVATE_KEY
-n testnet, mainnet
-c avalanche, ethereum, sepolia
```

#### Additional Notes
Tokens powered by NTT in __burn__ mode require the `burn` method to be present. This method is not present in the standard ERC20 interface, but is found in the `ERC20Burnable` interface.

The `mint` and `setMinter` methods found in the [`INttToken` Interface](src/interfaces/INTTToken.sol) are not found in the standard `ERC20` interface.
4 changes: 2 additions & 2 deletions evm/src/NttManager/NttManager.sol
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import "wormhole-solidity-sdk/libraries/BytesParsing.sol";
import "../libraries/RateLimiter.sol";

import "../interfaces/INttManager.sol";
import "../interfaces/INTTToken.sol";
import "../interfaces/INttToken.sol";
import "../interfaces/ITransceiver.sol";

import {ManagerBase} from "./ManagerBase.sol";
@@ -455,7 +455,7 @@ contract NttManager is INttManager, RateLimiter, ManagerBase {
IERC20(token).safeTransfer(recipient, untrimmedAmount);
} else if (mode == Mode.BURNING) {
// mint tokens to the specified recipient
INTTToken(token).mint(recipient, untrimmedAmount);
INttToken(token).mint(recipient, untrimmedAmount);
} else {
revert InvalidMode(uint8(mode));
}
12 changes: 0 additions & 12 deletions evm/src/interfaces/INTTToken.sol

This file was deleted.

36 changes: 36 additions & 0 deletions evm/src/interfaces/INttToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// SPDX-License-Identifier: Apache 2
pragma solidity >=0.8.8 <0.9.0;

interface INttToken {
/// @notice Error when the caller is not the minter.
/// @dev Selector 0x5fb5729e.
/// @param caller The caller of the function.
error CallerNotMinter(address caller);

/// @notice Error when the minter is the zero address.
/// @dev Selector 0x04a208c7.
error InvalidMinterZeroAddress();

/// @notice Error when insufficient balance to burn the amount.
/// @dev Selector 0xcf479181.
/// @param balance The balance of the account.
/// @param amount The amount to burn.
error InsufficientBalance(uint256 balance, uint256 amount);

/// @notice The minter has been changed.
/// @dev Topic0
/// 0x0b5e7be615a67a819aff3f47c967d1535cead1b98db60fafdcbf22dcaa8fa5a9.
/// @param newMinter The new minter.
event NewMinter(address previousMinter, address newMinter);

// NOTE: the `mint` method is not present in the standard ERC20 interface.
function mint(address account, uint256 amount) external;

// NOTE: the `setMinter` method is not present in the standard ERC20 interface.
function setMinter(address newMinter) external;

// NOTE: NttTokens in `burn` mode require the `burn` method to be present.
// This method is not present in the standard ERC20 interface, but is
// found in the `ERC20Burnable` interface.
function burn(uint256 amount) external;
}
20 changes: 14 additions & 6 deletions evm/test/NttManager.t.sol
Original file line number Diff line number Diff line change
@@ -72,12 +72,20 @@ contract TestNttManager is Test, IRateLimiterEvents {

// === pure unit tests

function test_countSetBits() public {
assertEq(countSetBits(5), 2);
assertEq(countSetBits(0), 0);
assertEq(countSetBits(15), 4);
assertEq(countSetBits(16), 1);
assertEq(countSetBits(65535), 16);
// naive implementation of countSetBits to test against
function simpleCount(uint64 n) public pure returns (uint8) {
uint8 count;

while (n > 0) {
count += uint8(n & 1);
n >>= 1;
}

return count;
}

function testFuzz_countSetBits(uint64 n) public {
assertEq(simpleCount(n), countSetBits(n));
}

// === Deployments with rate limiter disabled
Loading