Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrongly register PNA as ENA #1351

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions contracts/src/Assets.sol
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,11 @@ library Assets {
// NOTE: Explicitly allow a token to be re-registered. This offers resiliency
// in case a previous registration attempt of the same token failed on the remote side.
// It means that registration can be retried.
// But register a PNA here is not allowed
TokenInfo storage info = $.tokenRegistry[token];
if(info.foreignID != bytes32(0)) {
revert TokenAlreadyRegistered();
}
info.isRegistered = true;

ticket.dest = $.assetHubParaID;
Expand Down
8 changes: 8 additions & 0 deletions contracts/test/Gateway.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1014,4 +1014,12 @@ contract GatewayTest is Test {
bytes memory encodedParams = abi.encode(params);
MockGateway(address(gateway)).agentExecutePublic(encodedParams);
}

function testRegisterForeignTokenAsNativeTokenWillFail() public {
testRegisterForeignToken();
address dotToken = MockGateway(address(gateway)).tokenAddressOf(dotTokenID);
uint256 fee = IGateway(address(gateway)).quoteRegisterTokenFee();
vm.expectRevert(Assets.TokenAlreadyRegistered.selector);
IGateway(address(gateway)).registerToken{value: fee}(dotToken);
}
}
Loading