概要

このコントラクトは、トークンエコシステムにおける「コンプライアンス審査官」として機能します。 連携する各種レジストリ(IRS, TIR, CTR)の情報を統括し、特定のウォレットアドレスがトークンを保有・取引する資格があるかを総合的に検証するisVerified関数を提供します。

IdentityRegistryコントラクトは、ERC3643のオンチェーン検証システム(EVS)の中核をなすスマートコントラクトです。 トークンコントラクトからisVerified関数の呼び出しを受けると、まずIdentityRegistryStorageコントラクトに問い合わせて、対象のウォレットアドレスに紐づくオンチェーンIDを取得します。

次に、ClaimTopicsRegistryコントラクトから必須クレームのリストを、TrustedIssuersRegistryコントラクトから信頼できる発行者のリストを取得します。 そして、取得したオンチェーンIDが、これらの要件をすべて満たしているか(信頼できる発行者から、必須のクレームを全て受け取っているか)を検証します。 この検証プロセスには、クレームのデジタル署名が有効であるかのチェックも含まれます。

このコントラクトはトークンごとにデプロイされ、それぞれのトークンが持つ独自のコンプライアンス要件を管理します。 IDの登録や更新といった管理機能は、エージェント権限を持つアドレスのみに許可されています。

機能

  • 投資家の適格性の総合的な検証(isVerified)
  • 投資家IDの登録・更新・削除(エージェント限定)
  • 連携する各種レジストリ(IRS, TIR, CTR)の設定・管理(オーナー限定)
  • 登録済みID情報や連携コントラクトアドレスの参照

フロー

投資家の適格性検証 (isVerified)

sequenceDiagram
    actor TokenContract as トークンコントラクト
    participant IR as IdentityRegistry
    participant IRS as IdentityRegistryStorage
    participant CTR as ClaimTopicsRegistry
    participant TIR as TrustedIssuersRegistry
    participant InvestorID as 投資家のONCHAINID
    participant IssuerID as 発行者のONCHAINID

    TokenContract->>IR: 1. isVerified(userAddress)
    activate IR

    IR->>IRS: 2. storedIdentity(userAddress)
    activate IRS
    IRS-->>IR: 3. 投資家のONCHAINIDアドレス
    deactivate IRS

    IR->>CTR: 4. getClaimTopics()
    activate CTR
    CTR-->>IR: 5. 必須トピックのリスト
    deactivate CTR

    Note over IR: 必須トピックごとにループ処理
    IR->>TIR: 6. getTrustedIssuersForClaimTopic(topic)
    activate TIR
    TIR-->>IR: 7. 信頼できる発行者のリスト
    deactivate TIR

    Note over IR: 信頼できる発行者ごとにループ処理
    IR->>InvestorID: 8. getClaim(claimId)
    activate InvestorID
    InvestorID-->>IR: 9. クレーム情報
    deactivate InvestorID

    IR->>IssuerID: 10. isClaimValid(signature, data)
    activate IssuerID
    IssuerID-->>IR: 11. true (署名有効)
    deactivate IssuerID
    
    Note over IR: 全ての必須クレームが<br>有効であることを確認
    IR-->>TokenContract: 12. true (検証成功)
    deactivate IR

コード

IdentityRegistry.sol
// SPDX-License-Identifier: GPL-3.0
//
//                                             :+#####%%%%%%%%%%%%%%+
//                                         .-*@@@%+.:+%@@@@@%%#***%@@%=
//                                     :=*%@@@#=.      :#@@%       *@@@%=
//                       .-+*%@%*-.:+%@@@@@@+.     -*+:  .=#.       :%@@@%-
//                   :=*@@@@%%@@@@@@@@@%@@@-   .=#@@@%@%=             =@@@@#.
//             -=+#%@@%#*=:.  :%@@@@%.   -*@@#*@@@@@@@#=:-              *@@@@+
//            =@@%=:.     :=:   *@@@@@%#-   =%*%@@@@#+-.        =+       :%@@@%-
//           -@@%.     .+@@@     =+=-.         @@#-           +@@@%-       =@@@@%:
//          :@@@.    .+@@#%:                   :    .=*=-::.-%@@@+*@@=       +@@@@#.
//          %@@:    +@%%*                         =%@@@@@@@@@@@#.  .*@%-       +@@@@*.
//         #@@=                                .+@@@@%:=*@@@@@-      :%@%:      .*@@@@+
//        *@@*                                +@@@#-@@%-:%@@*          +@@#.      :%@@@@-
//       -@@%           .:-=++*##%%%@@@@@@@@@@@@*. :@+.@@@%:            .#@@+       =@@@@#:
//      .@@@*-+*#%%%@@@@@@@@@@@@@@@@%%#**@@%@@@.   *@=*@@#                :#@%=      .#@@@@#-
//      -%@@@@@@@@@@@@@@@*+==-:-@@@=    *@# .#@*-=*@@@@%=                 -%@@@*       =@@@@@%-
//         -+%@@@#.   %@%%=   -@@:+@: -@@*    *@@*-::                   -%@@%=.         .*@@@@@#
//            *@@@*  +@* *@@##@@-  #@*@@+    -@@=          .         :+@@@#:           .-+@@@%+-
//             +@@@%*@@:..=@@@@*   .@@@*   .#@#.       .=+-       .=%@@@*.         :+#@@@@*=:
//              =@@@@%@@@@@@@@@@@@@@@@@@@@@@%-      :+#*.       :*@@@%=.       .=#@@@@%+:
//               .%@@=                 .....    .=#@@+.       .#@@@*:       -*%@@@@%+.
//                 +@@#+===---:::...         .=%@@*-         +@@@+.      -*@@@@@%+.
//                  -@@@@@@@@@@@@@@@@@@@@@@%@@@@=          -@@@+      -#@@@@@#=.
//                    ..:::---===+++***###%%%@@@#-       .#@@+     -*@@@@@#=.
//                                           @@@@@@+.   +@@*.   .+@@@@@%=.
//                                          -@@@@@=   =@@%:   -#@@@@%+.
//                                          +@@@@@. =@@@=  .+@@@@@*:
//                                          #@@@@#:%@@#. :*@@@@#-
//                                          @@@@@%@@@= :#@@@@+.
//                                         :@@@@@@@#.:#@@@%-
//                                         +@@@@@@-.*@@@*:
//                                         #@@@@#.=@@@+.
//                                         @@@@+-%@%=
//                                        :@@@#%@%=
//                                        +@@@@%-
//                                        :#%%=
//
/**
 *     NOTICE
 *
 *     The T-REX software is licensed under a proprietary license or the GPL v.3.
 *     If you choose to receive it under the GPL v.3 license, the following applies:
 *     T-REX is a suite of smart contracts implementing the ERC-3643 standard and
 *     developed by Tokeny to manage and transfer financial assets on EVM blockchains
 *
 *     Copyright (C) 2023, Tokeny sàrl.
 *
 *     This program is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU General Public License
 *     along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

pragma solidity 0.8.17;

import "@onchain-id/solidity/contracts/interface/IClaimIssuer.sol";
import "@onchain-id/solidity/contracts/interface/IIdentity.sol";

import "../interface/IClaimTopicsRegistry.sol";
import "../interface/ITrustedIssuersRegistry.sol";
import "../interface/IIdentityRegistry.sol";
import "../../roles/AgentRoleUpgradeable.sol";
import "../interface/IIdentityRegistryStorage.sol";
import "../storage/IRStorage.sol";


contract IdentityRegistry is IIdentityRegistry, AgentRoleUpgradeable, IRStorage {

    /**
     *  @dev the constructor initiates the Identity Registry smart contract
     *  @param _trustedIssuersRegistry the trusted issuers registry linked to the Identity Registry
     *  @param _claimTopicsRegistry the claim topics registry linked to the Identity Registry
     *  @param _identityStorage the identity registry storage linked to the Identity Registry
     *  emits a `ClaimTopicsRegistrySet` event
     *  emits a `TrustedIssuersRegistrySet` event
     *  emits an `IdentityStorageSet` event
     */
    function init(
        address _trustedIssuersRegistry,
        address _claimTopicsRegistry,
        address _identityStorage
    ) external initializer {
        require(
            _trustedIssuersRegistry != address(0)
            && _claimTopicsRegistry != address(0)
            && _identityStorage != address(0)
        , "invalid argument - zero address");
        _tokenTopicsRegistry = IClaimTopicsRegistry(_claimTopicsRegistry);
        _tokenIssuersRegistry = ITrustedIssuersRegistry(_trustedIssuersRegistry);
        _tokenIdentityStorage = IIdentityRegistryStorage(_identityStorage);
        emit ClaimTopicsRegistrySet(_claimTopicsRegistry);
        emit TrustedIssuersRegistrySet(_trustedIssuersRegistry);
        emit IdentityStorageSet(_identityStorage);
        __Ownable_init();
    }

    /**
     *  @dev See {IIdentityRegistry-batchRegisterIdentity}.
     */
    function batchRegisterIdentity(
        address[] calldata _userAddresses,
        IIdentity[] calldata _identities,
        uint16[] calldata _countries
    ) external override {
        for (uint256 i = 0; i < _userAddresses.length; i++) {
            registerIdentity(_userAddresses[i], _identities[i], _countries[i]);
        }
    }

    /**
     *  @dev See {IIdentityRegistry-updateIdentity}.
     */
    function updateIdentity(address _userAddress, IIdentity _identity) external override onlyAgent {
        IIdentity oldIdentity = identity(_userAddress);
        _tokenIdentityStorage.modifyStoredIdentity(_userAddress, _identity);
        emit IdentityUpdated(oldIdentity, _identity);
    }

    /**
     *  @dev See {IIdentityRegistry-updateCountry}.
     */
    function updateCountry(address _userAddress, uint16 _country) external override onlyAgent {
        _tokenIdentityStorage.modifyStoredInvestorCountry(_userAddress, _country);
        emit CountryUpdated(_userAddress, _country);
    }

    /**
     *  @dev See {IIdentityRegistry-deleteIdentity}.
     */
    function deleteIdentity(address _userAddress) external override onlyAgent {
        IIdentity oldIdentity = identity(_userAddress);
        _tokenIdentityStorage.removeIdentityFromStorage(_userAddress);
        emit IdentityRemoved(_userAddress, oldIdentity);
    }

    /**
     *  @dev See {IIdentityRegistry-setIdentityRegistryStorage}.
     */
    function setIdentityRegistryStorage(address _identityRegistryStorage) external override onlyOwner {
        _tokenIdentityStorage = IIdentityRegistryStorage(_identityRegistryStorage);
        emit IdentityStorageSet(_identityRegistryStorage);
    }

    /**
     *  @dev See {IIdentityRegistry-setClaimTopicsRegistry}.
     */
    function setClaimTopicsRegistry(address _claimTopicsRegistry) external override onlyOwner {
        _tokenTopicsRegistry = IClaimTopicsRegistry(_claimTopicsRegistry);
        emit ClaimTopicsRegistrySet(_claimTopicsRegistry);
    }

    /**
     *  @dev See {IIdentityRegistry-setTrustedIssuersRegistry}.
     */
    function setTrustedIssuersRegistry(address _trustedIssuersRegistry) external override onlyOwner {
        _tokenIssuersRegistry = ITrustedIssuersRegistry(_trustedIssuersRegistry);
        emit TrustedIssuersRegistrySet(_trustedIssuersRegistry);
    }

    /**
     *  @dev See {IIdentityRegistry-isVerified}.
     */
    // solhint-disable-next-line code-complexity
    function isVerified(address _userAddress) external view override returns (bool) {
        if (address(identity(_userAddress)) == address(0)) {return false;}
        uint256[] memory requiredClaimTopics = _tokenTopicsRegistry.getClaimTopics();
        if (requiredClaimTopics.length == 0) {
            return true;
        }

        uint256 foundClaimTopic;
        uint256 scheme;
        address issuer;
        bytes memory sig;
        bytes memory data;
        uint256 claimTopic;
        for (claimTopic = 0; claimTopic < requiredClaimTopics.length; claimTopic++) {
            IClaimIssuer[] memory trustedIssuers =
            _tokenIssuersRegistry.getTrustedIssuersForClaimTopic(requiredClaimTopics[claimTopic]);

            if (trustedIssuers.length == 0) {return false;}

            bytes32[] memory claimIds = new bytes32[](trustedIssuers.length);
            for (uint256 i = 0; i < trustedIssuers.length; i++) {
                claimIds[i] = keccak256(abi.encode(trustedIssuers[i], requiredClaimTopics[claimTopic]));
            }

            for (uint256 j = 0; j < claimIds.length; j++) {
                (foundClaimTopic, scheme, issuer, sig, data, ) = identity(_userAddress).getClaim(claimIds[j]);

                if (foundClaimTopic == requiredClaimTopics[claimTopic]) {
                    try IClaimIssuer(issuer).isClaimValid(identity(_userAddress), requiredClaimTopics[claimTopic], sig,
                        data) returns(bool _validity) {

                        if (
                            _validity
                        ) {
                            j = claimIds.length;
                        }
                        if (!_validity && j == (claimIds.length - 1)) {
                            return false;
                        }
                    } catch {
                        if (j == (claimIds.length - 1)) {
                            return false;
                        }
                    }
                } else if (j == (claimIds.length - 1)) {
                    return false;
                }
            }
        }
        return true;
    }

    /**
     *  @dev See {IIdentityRegistry-investorCountry}.
     */
    function investorCountry(address _userAddress) external view override returns (uint16) {
        return _tokenIdentityStorage.storedInvestorCountry(_userAddress);
    }

    /**
     *  @dev See {IIdentityRegistry-issuersRegistry}.
     */
    function issuersRegistry() external view override returns (ITrustedIssuersRegistry) {
        return _tokenIssuersRegistry;
    }

    /**
     *  @dev See {IIdentityRegistry-topicsRegistry}.
     */
    function topicsRegistry() external view override returns (IClaimTopicsRegistry) {
        return _tokenTopicsRegistry;
    }

    /**
     *  @dev See {IIdentityRegistry-identityStorage}.
     */
    function identityStorage() external view override returns (IIdentityRegistryStorage) {
        return _tokenIdentityStorage;
    }

    /**
     *  @dev See {IIdentityRegistry-contains}.
     */
    function contains(address _userAddress) external view override returns (bool) {
        if (address(identity(_userAddress)) == address(0)) {
            return false;
        }
        return true;
    }

    /**
     *  @dev See {IIdentityRegistry-registerIdentity}.
     */
    function registerIdentity(
        address _userAddress,
        IIdentity _identity,
        uint16 _country
    ) public override onlyAgent {
        _tokenIdentityStorage.addIdentityToStorage(_userAddress, _identity, _country);
        emit IdentityRegistered(_userAddress, _identity);
    }

    /**
     *  @dev See {IIdentityRegistry-identity}.
     */
    function identity(address _userAddress) public view override returns (IIdentity) {
        return _tokenIdentityStorage.storedIdentity(_userAddress);
    }
}

変数

_tokenTopicsRegistry

solidity
IClaimTopicsRegistry internal _tokenTopicsRegistry;

このIdentityRegistryコントラクトが参照するClaimTopicsRegistryコントラクトのインスタンスを保持。

_tokenIssuersRegistry

solidity
ITrustedIssuersRegistry internal _tokenIssuersRegistry;

このIdentityRegistryコントラクトが参照するTrustedIssuersRegistryコントラクトのインスタンスを保持。

_tokenIdentityStorage

solidity
IIdentityRegistryStorage internal _tokenIdentityStorage;

このIdentityRegistryコントラクトが参照するIdentityRegistryStorageコントラクトのインスタンスを保持。

イベント

ClaimTopicsRegistrySet

solidity
event ClaimTopicsRegistrySet(address indexed claimTopicsRegistry);

連携するClaimTopicsRegistryコントラクトが設定された時に発行されるイベント。

IdentityStorageSet

solidity
event IdentityStorageSet(address indexed identityStorage);

連携するIdentityRegistryStorageコントラクトが設定された時に発行されるイベント。

TrustedIssuersRegistrySet

solidity
event TrustedIssuersRegistrySet(address indexed trustedIssuersRegistry);

連携するTrustedIssuersRegistryコントラクトが設定された時に発行されるイベント。

IdentityRegistered

solidity
event IdentityRegistered(address indexed investorAddress, IIdentity indexed identity);

新しいIDが登録された時に発行されるイベント。

IdentityRemoved

solidity
event IdentityRemoved(address indexed investorAddress, IIdentity indexed identity);

IDが登録から削除された時に発行されるイベント。

IdentityUpdated

solidity
event IdentityUpdated(IIdentity indexed oldIdentity, IIdentity indexed newIdentity);

登録されているIDが更新された時に発行されるイベント。

CountryUpdated

solidity
event CountryUpdated(address indexed investorAddress, uint16 indexed country);

投資家の国情報が更新された時に発行されるイベント。

関数

init

solidity
function init(
    address _trustedIssuersRegistry,
    address _claimTopicsRegistry,
    address _identityStorage
) external initializer {
    require(
        _trustedIssuersRegistry != address(0)
        && _claimTopicsRegistry != address(0)
        && _identityStorage != address(0)
    , "invalid argument - zero address");
    _tokenTopicsRegistry = IClaimTopicsRegistry(_claimTopicsRegistry);
    _tokenIssuersRegistry = ITrustedIssuersRegistry(_trustedIssuersRegistry);
    _tokenIdentityStorage = IIdentityRegistryStorage(_identityStorage);
    emit ClaimTopicsRegistrySet(_claimTopicsRegistry);
    emit TrustedIssuersRegistrySet(_trustedIssuersRegistry);
    emit IdentityStorageSet(_identityStorage);
    __Ownable_init();
}

プロキシコントラクトの初期設定を行う初期化関数。 initializer修飾子により、一度だけ呼び出し可能です。 このIdentityRegistryコントラクトが検証ロジックを実行するために必要な、3つの連携先レジストリコントラクトのアドレスを設定して自身をオーナーとして初期化します。

引数

  • _trustedIssuersRegistry
    • 連携するTrustedIssuersRegistryのコントラクトアドレス。
  • _claimTopicsRegistry
    • 連携するClaimTopicsRegistryのコントラクトアドレス。
  • _identityStorage
    • 連携するIdentityRegistryStorageのコントラクトアドレス。

batchRegisterIdentity

solidity
function batchRegisterIdentity(
    address[] calldata _userAddresses,
    IIdentity[] calldata _identities,
    uint16[] calldata _countries
) external override {
    for (uint256 i = 0; i < _userAddresses.length; i++) {
        registerIdentity(_userAddresses[i], _identities[i], _countries[i]);
    }
}

複数のユーザーIDを一度に登録するバッチ処理関数。 内部でregisterIdentity関数をループ処理で呼び出します。 各IDの登録は個別にエージェント権限のチェックを受けます。

引数

  • _userAddresses
    • 登録するユーザーのウォレットアドレスの配列。
  • _identities
    • 各ユーザーのオンチェーンIDの配列。
  • _countries
    • 各ユーザーの国コードの配列。

updateIdentity

solidity
function updateIdentity(address _userAddress, IIdentity _identity) external override onlyAgent {
    IIdentity oldIdentity = identity(_userAddress);
    _tokenIdentityStorage.modifyStoredIdentity(_userAddress, _identity);
    emit IdentityUpdated(oldIdentity, _identity);
}

登録済みユーザーのオンチェーンIDを更新する関数。 onlyAgent修飾子により、エージェントのみが呼び出し可能です。 連携するIdentityRegistryStorageコントラクトのmodifyStoredIdentity関数を呼び出して、実際のデータ更新を行います。

引数

  • _userAddress
    • 更新対象のユーザーのウォレットアドレス。
  • _identity
    • 新しいオンチェーンIDのコントラクトアドレス。

updateCountry

solidity
function updateCountry(address _userAddress, uint16 _country) external override onlyAgent {
    _tokenIdentityStorage.modifyStoredInvestorCountry(_userAddress, _country);
    emit CountryUpdated(_userAddress, _country);
}

登録済みユーザーの国情報を更新する関数。 onlyAgent修飾子により、エージェントのみが呼び出し可能です。 連携するIdentityRegistryStorageコントラクトのmodifyStoredInvestorCountry関数を呼び出して、実際のデータ更新を行います。

引数

  • _userAddress
    • 更新対象のユーザーのウォレットアドレス。
  • _country
    • 新しい国コード。

deleteIdentity

solidity
function deleteIdentity(address _userAddress) external override onlyAgent {
    IIdentity oldIdentity = identity(_userAddress);
    _tokenIdentityStorage.removeIdentityFromStorage(_userAddress);
    emit IdentityRemoved(_userAddress, oldIdentity);
}

ユーザーの登録情報を削除する関数。 onlyAgent修飾子により、エージェントのみが呼び出し可能です。 連携するIdentityRegistryStorageコントラクトのremoveIdentityFromStorage関数を呼び出して、実際のデータ削除を行います。

引数

  • _userAddress
    • 削除対象のユーザーのウォレットアドレス。

setIdentityRegistryStorage

solidity
function setIdentityRegistryStorage(address _identityRegistryStorage) external override onlyOwner {
    _tokenIdentityStorage = IIdentityRegistryStorage(_identityRegistryStorage);
    emit IdentityStorageSet(_identityRegistryStorage);
}

連携するIdentityRegistryStorageコントラクトを更新する関数。 onlyOwner修飾子により、所有者のみが呼び出し可能です。

引数

  • _identityRegistryStorage
    • 新しく設定するIdentityRegistryStorageのコントラクトアドレス。

setClaimTopicsRegistry

solidity
function setClaimTopicsRegistry(address _claimTopicsRegistry) external override onlyOwner {
    _tokenTopicsRegistry = IClaimTopicsRegistry(_claimTopicsRegistry);
    emit ClaimTopicsRegistrySet(_claimTopicsRegistry);
}

連携するClaimTopicsRegistryコントラクトを更新する関数。 onlyOwner修飾子により、所有者のみが呼び出し可能です。

引数

  • _claimTopicsRegistry
    • 新しく設定するClaimTopicsRegistryのコントラクトアドレス。

setTrustedIssuersRegistry

solidity
function setTrustedIssuersRegistry(address _trustedIssuersRegistry) external override onlyOwner {
    _tokenIssuersRegistry = ITrustedIssuersRegistry(_trustedIssuersRegistry);
    emit TrustedIssuersRegistrySet(_trustedIssuersRegistry);
}

連携するTrustedIssuersRegistryコントラクトを更新する関数。 onlyOwner修飾子により、所有者のみが呼び出し可能です。

引数

  • _trustedIssuersRegistry
    • 新しく設定するTrustedIssuersRegistryのコントラクトアドレス。

isVerified

solidity
function isVerified(address _userAddress) external view override returns (bool) {
    if (address(identity(_userAddress)) == address(0)) {return false;}
    uint256[] memory requiredClaimTopics = _tokenTopicsRegistry.getClaimTopics();
    if (requiredClaimTopics.length == 0) {
        return true;
    }

    uint256 foundClaimTopic;
    uint256 scheme;
    address issuer;
    bytes memory sig;
    bytes memory data;
    uint256 claimTopic;
    for (claimTopic = 0; claimTopic < requiredClaimTopics.length; claimTopic++) {
        IClaimIssuer[] memory trustedIssuers =
        _tokenIssuersRegistry.getTrustedIssuersForClaimTopic(requiredClaimTopics[claimTopic]);

        if (trustedIssuers.length == 0) {return false;}

        bytes32[] memory claimIds = new bytes32[](trustedIssuers.length);
        for (uint256 i = 0; i < trustedIssuers.length; i++) {
            claimIds[i] = keccak256(abi.encode(trustedIssuers[i], requiredClaimTopics[claimTopic]));
        }

        for (uint256 j = 0; j < claimIds.length; j++) {
            (foundClaimTopic, scheme, issuer, sig, data, ) = identity(_userAddress).getClaim(claimIds[j]);

            if (foundClaimTopic == requiredClaimTopics[claimTopic]) {
                try IClaimIssuer(issuer).isClaimValid(identity(_userAddress), requiredClaimTopics[claimTopic], sig,
                    data) returns(bool _validity) {

                    if (
                        _validity
                    ) {
                        j = claimIds.length;
                    }
                    if (!_validity && j == (claimIds.length - 1)) {
                        return false;
                    }
                } catch {
                    if (j == (claimIds.length - 1)) {
                        return false;
                    }
                }
            } else if (j == (claimIds.length - 1)) {
                return false;
            }
        }
    }
    return true;
}

指定されたアドレスが、トークンを取引する資格があるかを総合的に検証する関数。 このコントラクトの最も重要な機能です。 まず、連携するClaimTopicsRegistryコントラクトから必須クレームトピックのリストを取得します。 次に、各必須トピックについて、連携するTrustedIssuersRegistryコントラクトからそのトピックを発行できる信頼された発行者のリストを取得します。 最後に、ユーザーのオンチェーンIDを調べ、少なくとも1つの信頼された発行者から、その必須トピックの有効なクレーム(署名検証に成功するもの)を受け取っているかを検証します。 全ての必須トピックについてこの条件を満たした場合にのみtrueを返します。

引数

  • _userAddress
    • 検証したいユーザーのウォレットアドレス。

戻り値

  • bool
    • 全ての要件を満たしていればtrue、そうでなければfalse。

investorCountry

solidity
function investorCountry(address _userAddress) external view override returns (uint16) {
    return _tokenIdentityStorage.storedInvestorCountry(_userAddress);
}

ウォレットアドレスに紐づく国コードを返す関数。 連携するIdentityRegistryStorageコントラクトのstoredInvestorCountry関数を呼び出し、結果を返します。

引数

  • _userAddress
    • 国コードを取得したいウォレットアドレス。

戻り値

  • uint16
    • 国コード。

issuersRegistry

solidity
function issuersRegistry() external view override returns (ITrustedIssuersRegistry) {
    return _tokenIssuersRegistry;
}

現在連携しているTrustedIssuersRegistryコントラクトのアドレスを返す関数。 _tokenIssuersRegistryの値を返します。

戻り値

  • ITrustedIssuersRegistry
    • TrustedIssuersRegistryコントラクトのインスタンス。

topicsRegistry

solidity
function topicsRegistry() external view override returns (IClaimTopicsRegistry) {
    return _tokenTopicsRegistry;
}

現在連携しているClaimTopicsRegistryコントラクトのアドレスを返す関数。 _tokenTopicsRegistryの値を返します。

戻り値

  • IClaimTopicsRegistry
    • ClaimTopicsRegistryコントラクトのインスタンス。

identityStorage

solidity
function identityStorage() external view override returns (IIdentityRegistryStorage) {
    return _tokenIdentityStorage;
}

現在連携しているIdentityRegistryStorageコントラクトのアドレスを返す関数。 _tokenIdentityStorageの値を返します。

戻り値

  • IIdentityRegistryStorage
    • IdentityRegistryStorageコントラクトのインスタンス。

contains

solidity
function contains(address _userAddress) external view override returns (bool) {
    if (address(identity(_userAddress)) == address(0)) {
        return false;
    }
    return true;
}

指定されたウォレットアドレスがレジストリに登録されているかを確認する関数。 内部でidentity関数を呼び出し、返されたオンチェーンIDアドレスがゼロアドレスでないかどうかで登録の有無を判断します。

引数

  • _userAddress
    • 確認したいウォレットアドレス。

戻り値

  • bool
    • 登録されていればtrue、そうでなければfalse。

registerIdentity

solidity
function registerIdentity(
    address _userAddress,
    IIdentity _identity,
    uint16 _country
) public override onlyAgent {
    _tokenIdentityStorage.addIdentityToStorage(_userAddress, _identity, _country);
    emit IdentityRegistered(_userAddress, _identity);
}

ユーザーのID情報を登録する関数。 onlyAgent修飾子により、エージェントのみが呼び出し可能です。 連携するIdentityRegistryStorageコントラクトのaddIdentityToStorage関数を呼び出して、実際のデータ保存を行います。

引数

  • _userAddress
    • 登録するユーザーのウォレットアドレス。
  • _identity
    • ユーザーのオンチェーンIDコントラクトのアドレス。
  • _country
    • ユーザーの国籍を示す国コード。

identity

solidity
function identity(address _userAddress) public view override returns (IIdentity) {
    return _tokenIdentityStorage.storedIdentity(_userAddress);
}

ウォレットアドレスに紐づくオンチェーンIDのアドレスを返す関数。 連携するIdentityRegistryStorageコントラクトのstoredIdentity関数を呼び出し、結果を返します。

引数

  • _userAddress
    • オンチェーンIDを取得したいウォレットアドレス。

戻り値

  • IIdentity
    • オンチェーンIDのコントラクトアドレス。