re-al-Foundation / rwa-contracts

Core dev environment for the RWA Governance contracts
0 stars 0 forks source link

[RRR-02C] Inexistent Emittance of Minted IDs #91

Closed chasebrownn closed 7 months ago

chasebrownn commented 7 months ago

RRR-02C: Inexistent Emittance of Minted IDs

Type Severity Location
Standard Conformity RealReceiver.sol:L166-L168, L184-L186

Description:

The RealReceiver::_migrateNFT and RealReceiver::_migrateNFTBatch functions will not emit the NFT IDs that were minted as a result of the migration thereby hindering user experience.

Example:

/**
 * @notice Internal method for handling migration payloads for migrating to a veRWA NFT.
 * @param payload Payload containing NFT lock data.
 */
function _migrateNFT(bytes memory payload) internal {
    (, bytes memory toAddressBytes, uint256 amount, uint256 duration) =
        abi.decode(payload, (uint16, bytes, uint256, uint256));

    address to = toAddressBytes.toAddress(0);

    (bool success,) = address(veRwaNFT).call(
        abi.encodeWithSignature("migrate(address,uint256,uint256)", to, amount, duration)
    );
    if (!success) revert MigrationFailed(SEND_NFT);

    emit MigrationMessageReceived(SEND_NFT, to, payload);
}

/**
 * @notice Internal method for handling migration payloads for migrating a batch of veRWA NFTs.
 * @param payload Payload containing NFT lock data.
 */
function _migrateNFTBatch(bytes memory payload) internal {
    (, bytes memory toAddressBytes, uint256[] memory amounts, uint256[] memory durations) =
        abi.decode(payload, (uint16, bytes, uint256[], uint256[]));

    address to = toAddressBytes.toAddress(0);

    (bool success,) = address(veRwaNFT).call(
        abi.encodeWithSignature("migrateBatch(address,uint256[],uint256[])", to, amounts, durations)
    );
    if (!success) revert MigrationFailed(SEND_NFT_BATCH);

    emit MigrationMessageReceived(SEND_NFT_BATCH, to, payload);
}

Recommendation:

We advise relevant events to be emitted by the RealReceiver properly signifying the IDs that were minted for the user as part of the migration.

chasebrownn commented 7 months ago

TokenId doesnt matter since it'll (more than likely) be minted on the other side as a completely different tokenId. The token being migrated is also chosen by the user on the front end