Skip to content

Commit

Permalink
convert to address lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
alistair-singh committed Oct 21, 2024
1 parent 855af17 commit 45fee2a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
5 changes: 2 additions & 3 deletions contracts/src/Gateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
MultiAddress,
Ticket,
Costs,
TokenInfo,
AgentExecuteCommand
} from "./Types.sol";
import {Upgrade} from "./Upgrade.sol";
Expand Down Expand Up @@ -439,8 +438,8 @@ contract Gateway is IGateway, IInitializable, IUpgradable {
return Assets.isTokenRegistered(token);
}

function tokenInfo(address token) external view returns (TokenInfo memory) {
return AssetsStorage.layout().tokenRegistry[token];
function tokenForeignIDOf(address token) external view returns (bytes32) {
return AssetsStorage.layout().tokenRegistry[token].foreignID;
}

// Total fee for registering a token
Expand Down
4 changes: 2 additions & 2 deletions contracts/src/interfaces/IGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ interface IGateway {
/// @dev Check whether a token is registered
function isTokenRegistered(address token) external view returns (bool);

/// @dev Get information about a token.
function tokenInfo(address token) external view returns (TokenInfo memory);
/// @dev Get token id an ERC20 contract address.
function tokenForeignIDOf(address token) external view returns (bytes32);

/// @dev Quote a fee in Ether for registering a token, covering
/// 1. Delivery costs to BridgeHub
Expand Down
15 changes: 6 additions & 9 deletions contracts/test/ForkUpgrade.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@ contract ForkUpgradeTest is Test {
}

function checkLegacyToken() public {
TokenInfo memory weth = GatewayPNA(GatewayProxy).tokenInfo(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
assertEq(weth.isRegistered, true);
assertEq(weth.foreignID, bytes32(""));
TokenInfo memory myth = GatewayPNA(GatewayProxy).tokenInfo(0xBA41Ddf06B7fFD89D1267b5A93BFeF2424eb2003);
assertEq(myth.isRegistered, true);
assertEq(myth.foreignID, bytes32(""));
assert(IGateway(GatewayProxy).isTokenRegistered(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2));
assertEq(IGateway(GatewayProxy).tokenForeignIDOf(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2), bytes32(""));
assert(IGateway(GatewayProxy).isTokenRegistered(0xBA41Ddf06B7fFD89D1267b5A93BFeF2424eb2003));
assertEq(IGateway(GatewayProxy).tokenForeignIDOf(0xBA41Ddf06B7fFD89D1267b5A93BFeF2424eb2003), bytes32(""));
}

function registerForeignToken() public {
Expand All @@ -57,9 +55,8 @@ contract ForkUpgradeTest is Test {
emit IGateway.ForeignTokenRegistered(dotId, address(0x0));

GatewayPNA(GatewayProxy).registerForeignToken(abi.encode(params));
TokenInfo memory dot = GatewayPNA(GatewayProxy).tokenInfo(0x70D9d338A6b17957B16836a90192BD8CDAe0b53d);
assertEq(dot.isRegistered, true);
assertEq(dot.foreignID, dotId);
assert(IGateway(GatewayProxy).isTokenRegistered(0x70D9d338A6b17957B16836a90192BD8CDAe0b53d));
assertEq(IGateway(GatewayProxy).tokenForeignIDOf(0x70D9d338A6b17957B16836a90192BD8CDAe0b53d), dotId);
}

function testSanityCheck() public {
Expand Down

0 comments on commit 45fee2a

Please sign in to comment.