Correct interface in solidity contract

This commit is contained in:
nolash 2021-11-14 05:23:44 +01:00
parent 7d27faa960
commit 8c1339aac5
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
7 changed files with 19 additions and 30 deletions

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
[{"inputs":[{"internalType":"bytes32[]","name":"_identifiers","type":"bytes32[]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"bytes32","name":"_identifier","type":"bytes32"}],"name":"addressOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_identifier","type":"bytes32"}],"name":"chainOf","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_chain","type":"bytes32"}],"name":"configSumOf","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"identifiers","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_identifier","type":"bytes32"},{"internalType":"address","name":"_address","type":"address"},{"internalType":"bytes32","name":"_chainDescriptor","type":"bytes32"},{"internalType":"bytes32","name":"_chainConfig","type":"bytes32"}],"name":"set","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_sum","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]
[{"inputs":[{"internalType":"bytes32[]","name":"_identifiers","type":"bytes32[]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"bytes32","name":"_identifier","type":"bytes32"}],"name":"addressOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_identifier","type":"bytes32"},{"internalType":"bytes32","name":"_reference","type":"bytes32"}],"name":"bind","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"identifiers","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_identifier","type":"bytes32"},{"internalType":"address","name":"_address","type":"address"}],"name":"set","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_sum","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]

View File

@ -93,22 +93,14 @@ class ContractRegistry(Registry):
raise NotImplementedError()
def set(self, contract_address, sender_address, identifier_string, address, chain_spec, chain_config_hash):
def set(self, contract_address, sender_address, identifier_string, address):
enc = ABIContractEncoder()
enc.method('set')
enc.typ(ABIContractType.BYTES32)
enc.typ(ABIContractType.ADDRESS)
enc.typ(ABIContractType.BYTES32)
enc.typ(ABIContractType.BYTES32)
identifier = to_identifier(identifier_string)
enc.bytes32(identifier)
enc.address(address)
chain_str = str(chain_spec)
h = hashlib.new('sha256')
h.update(chain_str.encode('utf-8'))
chain_description_hash_bytes = h.digest()
enc.bytes32(chain_description_hash_bytes.hex())
enc.bytes32(chain_config_hash)
data = enc.encode()
tx = self.template(sender_address, contract_address, use_nonce=True)
tx = self.set_code(tx, data)

View File

@ -76,7 +76,7 @@ def main():
raise ValueError('chain config hash must be 32 bytes')
chain_config_hash = add_0x(chain_config_hash)
(tx_hash_hex, o) = c.set(registry_address, signer_address, config.get('_IDENTIFIER'), subject_address, chain_spec, chain_config_hash)
(tx_hash_hex, o) = c.set(registry_address, signer_address, config.get('_IDENTIFIER'), subject_address)
if config.get('_RPC_SEND'):
conn.do(o)

View File

@ -1,2 +1,2 @@
confini>=0.3.6rc3,<0.5.0
chainlib-eth>=0.0.9a3,<=0.1.0
confini~=0.5.2
chainlib-eth~=0.0.12

View File

@ -1,6 +1,6 @@
[metadata]
name = eth-contract-registry
version = 0.6.3a3
version = 0.7.1a2
description = Ethereum Smart Contract key-value registry
author = Louis Holbrook
author_email = dev@holbrook.no

View File

@ -12,8 +12,7 @@ contract CICRegistry {
bytes32[] public identifiers;
mapping (bytes32 => address) entries; // contractidentifier -> address
mapping (bytes32 => bytes32) chainIdentifiers; // contractidentifier -> chainidentifier
mapping (bytes32 => bytes32) chainConfigs; // chainidentifier -> chainconfig
mapping (bytes32 => bytes32[]) entryBindings; // contractidentifier -> chainidentifier
constructor(bytes32[] memory _identifiers) public {
owner = msg.sender;
@ -22,9 +21,11 @@ contract CICRegistry {
}
}
function set(bytes32 _identifier, address _address, bytes32 _chainDescriptor, bytes32 _chainConfig) public returns (bool) {
function set(bytes32 _identifier, address _address) public returns (bool) {
require(msg.sender == owner);
require(entries[_identifier] == address(0));
require(_address != address(0));
bool found = false;
for (uint i = 0; i < identifiers.length; i++) {
if (identifiers[i] == _identifier) {
@ -34,11 +35,16 @@ contract CICRegistry {
require(found);
entries[_identifier] = _address;
chainIdentifiers[_identifier] = _chainDescriptor;
chainConfigs[_chainDescriptor] = _chainConfig;
return true;
}
function bind(bytes32 _identifier, bytes32 _reference) public returns (bool) {
require(msg.sender == owner);
require(entries[_identifier] != address(0));
entryBindings[_identifier].push(_reference);
}
// Implements EIP 173
function transferOwnership(address _newOwner) public returns (bool) {
require(msg.sender == owner);
@ -51,17 +57,8 @@ contract CICRegistry {
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];
}
// Implements EIP 165
function supportsInterface(bytes4 _sum) public pure returns (bool) {
if (_sum == 0xbb34534c) { // Registry
if (_sum == 0x633ee8e7) { // Registry
return true;
}
if (_sum == 0x01ffc9a7) { // EIP165