Skip to content

Conversation

@YukiTsuchida
Copy link
Contributor

@YukiTsuchida YukiTsuchida commented Nov 13, 2025

  • Implemented Authenticator.sol and signTx().
  • Implemented unit tests for signTx and its helper functions.
graph TD
    subgraph " "
        direction LR
        CrossModule[(CrossModule)]
    end

    subgraph "Implementation abstract"
        direction TB
        Initiator[Initiator]
        Authenticator[Authenticator]
        TxAuthManager[TxAuthManager]
        TxManager[TxManager]
        TxRunner[TxRunner]
    end

    subgraph "Base Contracts & Interfaces"
        direction TB
        IInitiator{{IInitiator}}
        IAuthenticator{{IAuthenticator}}
        TxAuthManagerBase((TxAuthManagerBase))
        TxManagerBase((TxManagerBase))
        TxRunnerBase((TxRunnerBase))
    end

    subgraph "Storage (ERC7201)"
        direction TB
        CrossStore[CrossStore]
    end

    CrossModule -- inherits --> Initiator
    CrossModule -- inherits --> Authenticator
    CrossModule -- inherits --> TxAuthManager
    CrossModule -- inherits --> TxManager
    CrossModule -- inherits --> TxRunner

    Initiator -- implements --> IInitiator
    Initiator -- inherits & uses --> TxAuthManagerBase
    Initiator -- inherits & uses --> TxManagerBase

    TxAuthManager -- implements --> TxAuthManagerBase
    TxAuthManager -- uses storage --> CrossStore

    TxManager -- implements --> TxManagerBase
    TxManager -- inherits & uses --> TxRunnerBase
    TxManager -- uses storage --> CrossStore

    TxRunner -- implements --> TxRunnerBase
    
    Authenticator -- implements --> IAuthenticator
    Authenticator -- inherits & uses --> TxAuthManagerBase
    Authenticator -- inherits & uses --> TxManagerBase
    
    classDef interface fill:#e6f7ff,stroke:#0056b3,stroke-width:2px
    class IInitiator,IAuthenticator interface
    
    classDef base fill:#f0f0f0,stroke:#333,stroke-width:2px
    class TxAuthManagerBase,TxManagerBase,TxRunnerBase base
    
    classDef storage fill:#fffbe6,stroke:#d4a017,stroke-width:2px
    class CrossStore storage
Loading
graph TD
    %% =========================
    %% High-level architecture
    %% =========================
    subgraph "Deployed App Contract"
        direction TB
        CrossModule[(CrossModule)]
        style CrossModule stroke-width:2px

        subgraph "Abstract Impl (in CrossModule)"
            direction LR
            Initiator[Initiator]
            Authenticator[Authenticator]
            TxRunner[TxRunner]
        end

        subgraph "Shared Storage (ERC-7201 layout in callers)"
            direction TB
            CrossStore[(CrossStore)]
        end

        CrossModule -- inherits --> Initiator
        CrossModule -- inherits --> Authenticator
        CrossModule -- inherits --> TxRunner
        CrossModule --- CrossStore
    end

    %% ============ Facets / Delegates ============
    subgraph "Delegatecall Targets (Stateless Logic Contracts)"
        direction TB
        AuthFacet[[TxAuthManagerDelegate]]
        TxFacet[[TxManagerDelegate]]

        class AuthFacet,TxFacet facet
    end

    %% ============ Interfaces ============
    subgraph "Interfaces"
        direction TB
        ITxAuthManager{{ITxAuthManager}}
        ITxManager{{ITxManager}}
        class ITxAuthManager,ITxManager interface
    end

    %% ============ Wiring / Calls ============
    Initiator -- "«delegatecall» initAuthState/sign/getAuthState" --> AuthFacet
    Initiator -- "«delegatecall» createTx/isTxRecorded/runIfCompleted" --> TxFacet

    Authenticator -- "«delegatecall» initAuthState/sign/getAuthState" --> AuthFacet
    Authenticator -- "«delegatecall» createTx/isTxRecorded/runIfCompleted" --> TxFacet

    AuthFacet -. implements .-> ITxAuthManager
    TxFacet -. implements .-> ITxManager

    %% Delegates operate on caller storage via ERC-7201 slots
    AuthFacet -- "reads/writes via delegatecall" --> CrossStore
    TxFacet -- "reads/writes via delegatecall" --> CrossStore

    %% ============ Upgradability / Address slots ============
    subgraph "Facet Address Registry (in CrossModule storage)"
        direction TB
        AuthFacetAddr[(authFacetAddress)]
        TxFacetAddr[(txFacetAddress)]
    end
    CrossModule --- AuthFacetAddr
    CrossModule --- TxFacetAddr

    Admin[Admin/Owner/Role] -- "setAuthFacet()/setTxFacet()" --> CrossModule

    %% ============ Execution Path example ============
    subgraph "Tx Flow (example)"
        direction LR
        User[EOA/Relayer] -->|initiateTx()| Initiator
        Initiator -->|"derive txID, gather signers"| Initiator
        Initiator -- "«delegatecall» initAuthState(signers)" --> AuthFacet
        Initiator -- "«delegatecall» createTx(txID,msg)" --> TxFacet
        Initiator -->|"sign() → «delegatecall»"| AuthFacet
        AuthFacet -->|"remaining=0 ?"| Initiator
        Initiator -->|"if completed → «delegatecall» runIfCompleted(txID)"| TxFacet
        TxFacet -->|"calls _runTx via TxRunner in CrossModule"| TxRunner
    end

    %% ============ Styling ============
    classDef facet fill:#eef9f0,stroke:#2b8a3e,stroke-width:2px
    classDef interface fill:#e6f7ff,stroke:#0056b3,stroke-width:2px

Loading

@github-actions
Copy link

github-actions bot commented Nov 13, 2025

LCOV of commit 3c51170 during Coverage Report #90

Summary coverage rate:
  lines......: 98.2% (224 of 228 lines)
  functions..: 100.0% (47 of 47 functions)
  branches...: no data found

Files changed coverage rate:
                                     |Lines       |Functions  |Branches    
  Filename                           |Rate     Num|Rate    Num|Rate     Num
  =========================================================================
  src/core/Authenticator.sol         |22.2%     18| 0.0%     4|    -      0
  src/core/CrossModule.sol           |39.3%     28| 0.0%    11|    -      0

Full coverage report

interface IAuthenticator {
error AuthStateAlreadyInitialized(bytes32 txID);
error IDNotFound(bytes32 txID);
error AuthAlreadyCompleted(bytes32 txID);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed duplicate error definitions (already defined in TxAuthManagerBase).

@YukiTsuchida YukiTsuchida changed the title feat: implement Authenticator contract with signTx and related functi… feat: implement Authenticator abstract contract with signTx Nov 13, 2025
@YukiTsuchida YukiTsuchida marked this pull request as ready for review November 13, 2025 02:12
@YukiTsuchida YukiTsuchida self-assigned this Nov 13, 2025
@YukiTsuchida YukiTsuchida marked this pull request as draft November 13, 2025 07:40
@YukiTsuchida YukiTsuchida deleted the impl-authenticator branch January 16, 2026 08:29
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