diff --git a/contracts/src/Assets.sol b/contracts/src/Assets.sol index b8f4db66ed..11fa5c12c9 100644 --- a/contracts/src/Assets.sol +++ b/contracts/src/Assets.sol @@ -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; diff --git a/contracts/test/Gateway.t.sol b/contracts/test/Gateway.t.sol index e17c7df1a9..96705c5c9f 100644 --- a/contracts/test/Gateway.t.sol +++ b/contracts/test/Gateway.t.sol @@ -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); + } }