mirror of
git://holbrook.no/eth-contract-registry
synced 2026-05-20 11:11:13 +02:00
Initial commit, ported from cic-registry
This commit is contained in:
10
solidity/Makefile
Normal file
10
solidity/Makefile
Normal file
@@ -0,0 +1,10 @@
|
||||
SOLC = /usr/bin/solc
|
||||
|
||||
all:
|
||||
$(SOLC) --bin Registry.sol --evm-version byzantium | awk 'NR>3' > Registry.bin
|
||||
truncate -s -1 Registry.bin
|
||||
$(SOLC) --abi Registry.sol --evm-version byzantium | awk 'NR>3' > Registry.json
|
||||
|
||||
install: all
|
||||
cp -v *{json,bin} ../python/contract_registry/data/
|
||||
|
||||
58
solidity/Registry.sol
Normal file
58
solidity/Registry.sol
Normal file
@@ -0,0 +1,58 @@
|
||||
pragma solidity >0.6.11;
|
||||
|
||||
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// File-version: 2
|
||||
// Description: Top-level smart contract registry for the CIC network
|
||||
|
||||
|
||||
contract CICRegistry {
|
||||
address public owner;
|
||||
|
||||
bytes32[] public identifiers;
|
||||
mapping (bytes32 => address) entries; // contractidentifier -> address
|
||||
mapping (bytes32 => bytes32) chainIdentifiers; // contractidentifier -> chainidentifier
|
||||
mapping (bytes32 => bytes32) chainConfigs; // chainidentifier -> chainconfig
|
||||
|
||||
constructor(bytes32[] memory _identifiers) public {
|
||||
owner = msg.sender;
|
||||
for (uint i = 0; i < _identifiers.length; i++) {
|
||||
identifiers.push(_identifiers[i]);
|
||||
}
|
||||
}
|
||||
|
||||
function set(bytes32 _identifier, address _address, bytes32 _chainDescriptor, bytes32 _chainConfig) public returns (bool) {
|
||||
require(msg.sender == owner);
|
||||
require(entries[_identifier] == address(0));
|
||||
bool found = false;
|
||||
for (uint i = 0; i < identifiers.length; i++) {
|
||||
if (identifiers[i] == _identifier) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
require(found);
|
||||
|
||||
entries[_identifier] = _address;
|
||||
chainIdentifiers[_identifier] = _chainDescriptor;
|
||||
chainConfigs[_chainDescriptor] = _chainConfig;
|
||||
return true;
|
||||
}
|
||||
|
||||
// function seal() public returns (bool) {
|
||||
// require(msg.sender == owner);
|
||||
// owner = address(0);
|
||||
// return true;
|
||||
// }
|
||||
|
||||
function addressOf(bytes32 _identifier) public view returns (address) {
|
||||
return entries[_identifier];
|
||||
}
|
||||
|
||||
function chainOf(bytes32 _identifier) public view returns (bytes32) {
|
||||
return chainIdentifiers[_identifier];
|
||||
}
|
||||
|
||||
function configSumOf(bytes32 _chain) public view returns (bytes32) {
|
||||
return chainConfigs[_chain];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user