Mirror.sol

Overview

Mirror.sol defines the Mirror smart contract, which acts as a critical component within a multifactor verification and game deployment ecosystem. The contract manages deployment and interaction with multiple specialized contracts including multifactor authentication modules, game contracts, token roots, and indexers. It maintains an internal state with references to root contracts, an index, public keys, and code cells for various contract types.

The contract provides administrative functions to update its internal state, ensure operational balance, deploy new contracts related to multifactor verification, games, and token roots, and manage whitelist updates for access control. It is designed with strict access control and validation logic to preserve the integrity and security of the system.


Contract: Mirror

State Variables

Constructor

constructor (
    address root,
    uint128 index,
    uint256 rootPubkey
)

Core Private and Modifier Functions

ensureBalance()

function ensureBalance() private pure

State Management Functions

setNewIndex

function setNewIndex(uint128 index) public senderIs(address(this)) accept

setNewCode

function setNewCode(uint8 id, TvmCell code) public senderIs(address(this)) accept

destroyNode

function destroyNode() public senderIs(address(this)) accept

Deployment Functions

deployPopitGame

function deployPopitGame(uint256 pubkey) public view senderIs(VerifiersLib.calculateMultifactorAddress(_code[m_MvMultifactor], pubkey, _root)) accept

deployMultifactor

function deployMultifactor(
    string name,
    string zkid,
    bytes proof,
    uint256 epk,
    bytes epk_sig,
    uint64 epk_expire_at,
    bytes jwk_modulus,
    bytes kid,
    uint64 jwk_modulus_expire_at,
    uint8 index_mod_4,
    string iss_base_64,
    string provider,
    string header_base_64,
    uint256 pub_recovery_key,
    bytes pub_recovery_key_sig,
    uint256 jwk_update_key,
    bytes jwk_update_key_sig,
    mapping(uint256 => bytes) root_provider_certificates
) public view accept

isDeployMultifactor

function isDeployMultifactor(
    string name,
    bool ready,
    string zkid,
    bytes proof,
    uint256 epk,
    bytes epk_sig,
    uint64 epk_expire_at,
    bytes jwk_modulus,
    bytes kid,
    uint64 jwk_modulus_expire_at,
    uint8 index_mod_4,
    string iss_base_64,
    string provider,
    string header_base_64,
    uint256 pub_recovery_key,
    bytes pub_recovery_key_sig,
    uint256 jwk_update_key,
    bytes jwk_update_key_sig,
    mapping(uint256 => bytes) root_provider_certificates,
    uint256 owner_pubkey
) public view senderIs(VerifiersLib.calculateIndexerAddress(_code[m_Indexer], name)) accept

updateWhiteList

function updateWhiteList(uint256 pubkey, uint8 index, string name) public view senderIs(VerifiersLib.calculateMultifactorAddress(_code[m_MvMultifactor], pubkey, _root)) accept

Token and Game Root Deployment

deployPopCoinRoot

function deployPopCoinRoot(
    string name,
    uint16 maxPopitIndex,
    mapping(uint16 => PopitMedia) popits_media,
    string description,
    bool isPublic,
    address popitGameOwner
) public view onlyOwnerPubkey(_rootPubkey) accept

Fallback and Getters

receive()

getVersion

function getVersion() external pure returns(string, string)

Implementation Details and Algorithms


Interactions with Other Contracts and Modules


Visual Diagram

classDiagram
class Mirror {
-string version
-address _root
-uint128 _index
-uint256 _rootPubkey
-mapping(uint8 => TvmCell) _code
+constructor(root, index, rootPubkey)
-ensureBalance()
+setNewIndex(index)
+setNewCode(id, code)
+destroyNode()
+deployPopitGame(pubkey)
+deployMultifactor(...)
+isDeployMultifactor(...)
+updateWhiteList(pubkey, index, name)
+deployPopCoinRoot(name, maxPopitIndex, popits_media, description, isPublic, popitGameOwner)
+receive()
+getVersion()
}
Mirror ..> VerifiersLib : uses
Mirror ..> PopitGame : deploys
Mirror ..> Multifactor : deploys
Mirror ..> PopCoinRoot : deploys
Mirror ..> NameIndex : deploys
Mirror ..> gosh : cryptographic ops

The diagram illustrates the Mirror contract with its main properties and methods, highlighting its usage of external libraries (VerifiersLib), deployment of specialized contracts (PopitGame, Multifactor, PopCoinRoot, NameIndex), and reliance on the gosh interface for cryptographic operations.