github.com/klaytn/klaytn@v1.12.1/contracts/storagetrie/StorageTrieStoreTest.sol (about)

     1  pragma solidity >0.8.0;
     2  
     3  contract StorageTrieStoreTest {
     4      struct Identity {
     5          string publicKey;
     6          string hash;
     7      }
     8  
     9      address public owner; // ex : 0xe5e4a8f4ecc2b6298be33fed07a09599db4e46fa
    10  
    11      string public rootCaCertificate; // ROOT_CA
    12      mapping(string => string) caCertificates; // CA_C1
    13  
    14      mapping(string => Identity) identites;
    15  
    16      modifier onlyOwner {
    17          require(msg.sender == owner);
    18          _;
    19      }
    20  
    21      constructor() {
    22          owner = msg.sender;
    23      }
    24  
    25      function insertIdentity(string calldata _serialNumber, string calldata _publicKey, string calldata _hash)
    26          public 
    27      {
    28          require(bytes(_serialNumber).length > 0);
    29          require(bytes(_publicKey).length > 0);
    30          require(bytes(_hash).length > 0);
    31  
    32          identites[_serialNumber] = Identity(_publicKey, _hash);
    33      }
    34  
    35      function getIdentity(string calldata _serialNumber)
    36          public
    37          view
    38          returns (string memory, string memory) 
    39      {
    40          require(bytes(_serialNumber).length > 0);
    41  
    42          Identity memory identity = identites[_serialNumber];
    43          return (identity.publicKey, identity.hash);
    44      }
    45  
    46      function deleteIdentity(string calldata _serialNumber)
    47          public
    48          onlyOwner 
    49      {
    50          require(bytes(_serialNumber).length > 0);
    51  
    52          delete identites[_serialNumber];
    53      }
    54  
    55      function insertCaCertificate(string calldata _caKey, string calldata _caCert)
    56          public
    57          onlyOwner 
    58      {
    59          require(bytes(_caKey).length > 0);
    60          require(bytes(_caCert).length > 0);
    61  
    62          caCertificates[_caKey] = _caCert;
    63      }
    64  
    65      function getCaCertificate(string calldata _caKey)
    66          public
    67          view
    68          returns (string memory) 
    69      {
    70          require(bytes(_caKey).length > 0);
    71  
    72          return caCertificates[_caKey];
    73      }
    74  
    75      function deleteCaCertificate(string calldata _caKey)
    76          public
    77          onlyOwner 
    78      {
    79          require(bytes(_caKey).length > 0);
    80  
    81          delete caCertificates[_caKey];
    82      }
    83  }