Skip to content

Feat/xmorse - #3

Merged
riemannulus merged 6 commits into
mainfrom
feat/xmorse
Oct 23, 2025
Merged

Feat/xmorse#3
riemannulus merged 6 commits into
mainfrom
feat/xmorse

Conversation

@riemannulus

Copy link
Copy Markdown
Contributor

No description provided.

…d comprehensive tests for cross-chain NFT transfers and message encoding/decoding.
- Removed direct treasury initialization in xMorse constructor; treasury address is now set via a dedicated function.
- Updated xMorse to ensure proper handling of NFT transfers using the mirror contract.
- Added tests for xMorse and xMorseCollateral to validate treasury functionality and cross-chain NFT transfers.
- Enhanced LibTransfer to improve NFT transfer logic and added tests for reentrancy protection.
- Updated LibTransfer to utilize the mirror address for NFT transfers.
- Added new test suite for LibTransfer to validate sendNFT and sendNFTPartial functionalities.
- Introduced MockDN404 and SimpleMulticall contracts for testing purposes.
- Created xDN404Treasury test suite to ensure correct NFT withdrawal behavior.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces cross-chain NFT transfer functionality for the xMorse protocol, enabling NFT bridging between Ethereum and Mitosis chains using Hyperlane infrastructure.

Key changes:

  • Added xMorseCollateral contract for locking NFTs on the source chain (Ethereum)
  • Modified xMorse initialization to support external treasury setup
  • Implemented comprehensive test coverage for cross-chain transfers and collateral operations

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/xMorseCollateral.t.sol Unit tests for collateral contract covering NFT locking, transfers, and ownership
test/xMorse.t.sol Unit tests for xMorse token including initialization, finalization, and DN404 functionality
test/xDN404Treasury.t.sol Fixed treasury initialization to set skipNFT before token transfer
test/utils/HyperlaneTestUtils.sol Added hook fee configuration and improved documentation for message relay
test/libs/LibTransfer.t.sol Updated revert testing to use try-catch pattern for library calls
test/integration/CrossChainTransfer.t.sol Integration tests for end-to-end cross-chain transfers (marked as skipped pending MockMailbox)
src/xMorseCollateral.sol Implements collateral contract with correct mirror NFT contract handling
src/xMorse.sol Modified initialization flow to support external treasury setup and fixed NFT fetching
src/xDN404Treasury.sol Removed automatic skipNFT setting from constructor
src/libs/LibTransfer.sol Fixed operator precedence in multicall array size calculation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/xMorse.sol Outdated

import { xDN404Base } from './xDN404Base.sol';
import { xDN404Treasury } from './xDN404Treasury.sol';
import { xDN404Treasury } from './xDN404Treasury.sol'; // For type casting only

Copilot AI Oct 21, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment 'For type casting only' is misleading since xDN404Treasury is no longer instantiated in this contract but the import is still used for type information. Consider updating to 'For type reference' or 'For type information' to be more accurate.

Suggested change
import { xDN404Treasury } from './xDN404Treasury.sol'; // For type casting only
import { xDN404Treasury } from './xDN404Treasury.sol'; // For type reference

Copilot uses AI. Check for mistakes.
Comment thread src/xMorse.sol Outdated
Comment on lines +56 to +63

constructor(address _mailbox) xDN404Base(_mailbox) { }

/// @notice Set treasury address (only callable once during initialization phase)
function setTreasury(address _treasury) external onlyOwner {
StorageV1 storage $ = _getStorageV1();
require($.initializing, TreasuryAlreadySet());

Copilot AI Oct 21, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the same error TreasuryAlreadySet() for two different conditions (not initializing vs treasury already set) makes debugging difficult. The first check should use a different error like NotInInitializationPhase() to distinguish between these failure cases.

Suggested change
constructor(address _mailbox) xDN404Base(_mailbox) { }
/// @notice Set treasury address (only callable once during initialization phase)
function setTreasury(address _treasury) external onlyOwner {
StorageV1 storage $ = _getStorageV1();
require($.initializing, TreasuryAlreadySet());
error NotInInitializationPhase();
constructor(address _mailbox) xDN404Base(_mailbox) { }
/// @notice Set treasury address (only callable once during initialization phase)
function setTreasury(address _treasury) external onlyOwner {
StorageV1 storage $ = _getStorageV1();
require($.initializing, NotInInitializationPhase());

Copilot uses AI. Check for mistakes.
@riemannulus
riemannulus marked this pull request as ready for review October 21, 2025 10:39
- Introduced xMorseStaking contract for NFT staking with reward distribution.
- Updated xMorse constructor to accept a mirror address for improved functionality.
- Added interfaces and tests for xMorseStaking to ensure proper staking and reward mechanisms.
- Enhanced existing tests to validate integration with the new staking contract.
- Introduced IValidatorRewardDistributor interface for claiming operator rewards.
- Updated distributeRewards function to allow both owner and operator to distribute rewards, with automatic claiming from the ValidatorRewardDistributor if configured.
- Added functions to set and retrieve the ValidatorRewardDistributor and validator addresses.
- Implemented events for tracking updates to the validator reward distributor and validator address.
- Created VariableRewardTest to validate reward distribution with variable amounts and multiple users.
- Deleted xDN404Treasury contract and its associated ABI file.
- Updated xMorse and related contracts to remove dependencies on the treasury.
- Adjusted tests to reflect the removal of treasury functionality and ensure proper NFT handling.
- Enhanced xMorse to manage NFT mappings directly without treasury involvement.
@riemannulus
riemannulus merged commit a976c0b into main Oct 23, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants