Add ERC165 calculator

This commit is contained in:
nolash 2020-12-29 21:51:37 +01:00
parent e485d221a8
commit 83eae00818
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
9 changed files with 72 additions and 3 deletions

15
AddressDeclarator.sol Normal file
View File

@ -0,0 +1,15 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: GPL-3.0-or-later
// File-version: 1
// Description: The ERC20 standard interface as specified in EIP20 (sha256:9f843cbb25a737c9351b0b6a6f54b86864490d0d5284f6877b4929d481d34312)
interface AddressDeclarator {
function addDeclaration(address _address, bytes32 _proof) external returns ( bytes32 );
function declaratorCount(address _objectAddress) external view returns ( uint256 );
function declaratorAddressAt(address _targetAddress, uint256 _idx) external view returns ( address );
function declaration(address _subjectAddress, address _objectAddress) external view returns ( bytes32[] memory );
function declarationCount(address _subjectAddress) external view returns ( uint256 );
function declarationAddressAt(address _subjectAddress, uint256 _idx) external view returns ( address );
}

View File

@ -21,4 +21,4 @@ RUN cd cic-contracts && \
LABEL authors="Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746"
LABEL spdx-license-identifier="GPL-3.0-or-later"
LABEL description="Ethereum smart contract interfaces used by the CIC component suite"
LABEL version="1"
LABEL version="3"

View File

@ -2,7 +2,7 @@ pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: GPL-3.0-or-later
// File-version: 2
// File-version: 3
interface Faucet {
@ -13,4 +13,5 @@ interface Faucet {
function token() external view returns (address);
function setAmount(uint256 _amount) external returns (bool);
function giveTo(address _recipient) external returns (bool);
function gimme() external returns (bool);
}

View File

@ -2,9 +2,10 @@ pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: GPL-3.0-or-later
// File-version: 1
// File-version: 2
interface RegistryClient {
function registryCount() external view returns (uint256);
function addressOf(bytes32) external view returns (address);
}

12
RegistryStandard.sol Normal file
View File

@ -0,0 +1,12 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: GPL-3.0-or-later
// File-version: 1
interface RegistryStandard {
function registryCount() external view returns (uint256);
function addressOf(bytes32) external view returns (address);
function register(bytes32,address) external view returns (bool);
}

3
RegistryStandard.txt Normal file
View File

@ -0,0 +1,3 @@
registryCount()
addressOf(bytes32)
register(bytes32,address)

3
TokenEndorsement.sol Normal file
View File

@ -0,0 +1,3 @@
interface TokenEndorser {
function getBySymbol(address _tokenAddress) external view returns ( bytes32 );
}

18
TokenRegistryClient.sol Normal file
View File

@ -0,0 +1,18 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: GPL-3.0-or-later
// File-version: 1
// Description: The ERC20 standard interface as specified in EIP20 (sha256:9f843cbb25a737c9351b0b6a6f54b86864490d0d5284f6877b4929d481d34312)
// TODO: Rename everything to something more generic
interface TokenEndorser {
function endorsement(bytes32) external view returns ( bytes32 );
function tokenIndex(address) external view returns ( uint256 );
function endorser(address, uint256) external view returns ( uint256 );
function endorserTokenCount(address) external view returns ( uint256 );
function tokenSymbolIndex(string memory) external view returns ( address );
function tokens(uint256) external view returns ( address );
function add(address _token, bytes32 _data) external returns ( bool );
}

16
calculate_erc165.py Normal file
View File

@ -0,0 +1,16 @@
import sys
import web3
f = open(sys.argv[1], 'r')
z = b''
for i in range(32):
z += b'\x00'
while True:
l = f.readline()
if l == '':
break
print('line {}'.format(l))
h = web3.Web3.keccak(text=l)
z = bytes([a ^ b for a, b in zip(h, z)])
print(h.hex(), z.hex())
f.close()