Skip to content

Commit

Permalink
Fix wrongly register PNA as ENA (#1351)
Browse files Browse the repository at this point in the history
  • Loading branch information
yrong authored Dec 13, 2024
1 parent 40d12a0 commit 20a8046
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
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);
}
}

0 comments on commit 20a8046

Please sign in to comment.