From a461f9fc554f431503aaad2707c530c29de04b51 Mon Sep 17 00:00:00 2001 From: Louis Holbrook Date: Thu, 31 Dec 2020 21:29:40 +0000 Subject: [PATCH] Add token registry --- AccountsIndex.sol => AccountRegistry.sol | 3 ++- AddressDeclarator.sol | 15 ++++++++++++ CHANGELOG | 4 ++++ ConverterRegistry.sol | 1 + Dockerfile | 24 +++++++++++++++++++ Faucet.sol | 3 ++- Makefile | 21 +++++++++------- Network.sol | 2 +- Registry.sol | 11 +++++++-- RegistryClient.sol | 11 +++++++++ RegistryStandard.sol | 12 ++++++++++ RegistryStandard.txt | 3 +++ TokenEndorsement.sol | 3 +++ TokenRegistry.sol | 18 ++++++++++++++ TokenRegistryClient.sol | 18 ++++++++++++++ VERSION | 1 + ...AccountsIndex.abi => AccountRegistry.json} | 0 abis/{Converter.abi => Converter.json} | 0 abis/ConverterRegistry.abi | 1 - abis/ConverterRegistry.json | 1 + abis/{ERC20.abi => ERC20.json} | 0 abis/{Faucet.abi => Faucet.json} | 0 abis/Network.abi | 1 - abis/Network.json | 1 + abis/Registry.json | 1 + abis/{Registry.abi => RegistryClient.json} | 2 +- abis/TokenEndorser.json | 1 + abis/TokenRegistry.json | 1 + ...sferApproval.abi => TransferApproval.json} | 0 calculate_erc165.py | 16 +++++++++++++ util/mergeabis.py | 13 ++++++++++ 31 files changed, 171 insertions(+), 17 deletions(-) rename AccountsIndex.sol => AccountRegistry.sol (96%) create mode 100644 AddressDeclarator.sol create mode 100644 CHANGELOG create mode 100644 Dockerfile create mode 100644 RegistryClient.sol create mode 100644 RegistryStandard.sol create mode 100644 RegistryStandard.txt create mode 100644 TokenEndorsement.sol create mode 100644 TokenRegistry.sol create mode 100644 TokenRegistryClient.sol create mode 100644 VERSION rename abis/{AccountsIndex.abi => AccountRegistry.json} (100%) rename abis/{Converter.abi => Converter.json} (100%) delete mode 100644 abis/ConverterRegistry.abi create mode 100644 abis/ConverterRegistry.json rename abis/{ERC20.abi => ERC20.json} (100%) rename abis/{Faucet.abi => Faucet.json} (100%) delete mode 100644 abis/Network.abi create mode 100644 abis/Network.json create mode 100644 abis/Registry.json rename abis/{Registry.abi => RegistryClient.json} (67%) create mode 100644 abis/TokenEndorser.json create mode 100644 abis/TokenRegistry.json rename abis/{TransferApproval.abi => TransferApproval.json} (100%) create mode 100644 calculate_erc165.py create mode 100644 util/mergeabis.py diff --git a/AccountsIndex.sol b/AccountRegistry.sol similarity index 96% rename from AccountsIndex.sol rename to AccountRegistry.sol index b572ca7..665922d 100644 --- a/AccountsIndex.sol +++ b/AccountRegistry.sol @@ -5,7 +5,8 @@ pragma solidity >=0.6.12; // File-version: 2 -interface AccountsIndex { + +interface AccountRegistry { event AccountAdded(address indexed addedAccount, uint256 indexed accountIndex); function accounts(uint256 _idx) external view returns (address); diff --git a/AddressDeclarator.sol b/AddressDeclarator.sol new file mode 100644 index 0000000..c4a78d3 --- /dev/null +++ b/AddressDeclarator.sol @@ -0,0 +1,15 @@ +pragma solidity >=0.6.12; + +// Author: Louis Holbrook 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 ); +} diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..705c94b --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,4 @@ +- 0.0.2 + * Add token endorser contract +- 0.0.1 + * Consolidate all existing contract interfaces diff --git a/ConverterRegistry.sol b/ConverterRegistry.sol index 937a092..09dc0ca 100644 --- a/ConverterRegistry.sol +++ b/ConverterRegistry.sol @@ -8,4 +8,5 @@ pragma solidity >=0.6.12; interface ConverterRegistry { function getConvertibleTokens() external view returns (address[] memory); function newConverter(uint16 _type, string memory _name, string memory _symbol, uint8 _decimals, uint32 _maxConversionFee, address[] memory _reserveTokens, uint32[] memory _reserveWeights) external returns(address); + function getConvertersByAnchors(address[] memory _anchors) external view returns (address[] memory); } diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bbf5385 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM ethereum/solc:0.6.12 + +# The solc image messes up the alpine environment, so we have to go all over again +FROM alpine +COPY --from=0 /usr/bin/solc /usr/bin/solc + +RUN apk update && \ + apk add make + +WORKDIR /usr/src + +COPY ./Makefile ./cic-contracts/Makefile +COPY ./*.sol ./cic-contracts/ + +RUN cd cic-contracts && \ + make -B && make install -B + +#RUN mkdir -vp /usr/local/share/cic/solidity && \ +# cp -rv cic-contracts/abis + +LABEL authors="Louis Holbrook 0826EDA1702D1E87C6E2875121D2E7BB88C2A746" +LABEL spdx-license-identifier="GPL-3.0-or-later" +LABEL description="Ethereum smart contract interfaces used by the CIC component suite" +LABEL version="3" diff --git a/Faucet.sol b/Faucet.sol index 958040a..faa123e 100644 --- a/Faucet.sol +++ b/Faucet.sol @@ -2,7 +2,7 @@ pragma solidity >=0.6.12; // Author: Louis Holbrook 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); } diff --git a/Makefile b/Makefile index e660649..dedd011 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,25 @@ # Author: Louis Holbrook 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 # SPDX-License-Identifier: GPL-3.0-or-later -# File-version: 3 +# File-version: 5 INPUTS = $(wildcard *.sol) +OUTPUTS = $(patsubst %.sol, %.json, $(INPUTS)) PREFIX = /usr/local/share/cic/solidity/abi -%.abi: $(wildcard *.sol) - install -vDm0644 $@ $(PREFIX)/$@ +#%.abi.json: $(wildcard *.sol) +# install -vDm0644 $@ $(PREFIX)/$@ -%.sol: - solc $@ --abi | awk 'NR>3' > $(basename $@).abi +.SUFFIXES: .sol .json -# TODO: improve, does not detect changes in sol files (I suck at writing makefiles) -all: $(INPUTS) +.sol.json: + solc $(basename $@).sol --abi | awk 'NR>3' > $@ -install: $(wildcard *.abi) +all: $(OUTPUTS) + +install: $(OUTPUTS) + install -vDm0644 -t $(PREFIX) $? clean: - rm -vf *.abi + rm -vf *.json .PHONY: clean install diff --git a/Network.sol b/Network.sol index 3fae3a9..c0a4cde 100644 --- a/Network.sol +++ b/Network.sol @@ -14,6 +14,6 @@ interface Network { uint256 _toAmount, address _trader ); - function convert(address) external view returns (address); + function convert(address[] memory _path, uint256 _amount, uint256 _minReturn) external payable returns (uint256); function rateByPath(address,uint256) external view returns (uint256); } diff --git a/Registry.sol b/Registry.sol index 9d6a9e1..2c7f44c 100644 --- a/Registry.sol +++ b/Registry.sol @@ -5,6 +5,13 @@ pragma solidity >=0.6.12; // File-version: 1 -interface RegistryClient { - function addressOf(address) external view returns (address); +interface Registry { + function owner() external view returns (address); + function identifiers() external view returns (bytes32[] memory); + function chainOf(bytes32 _identifier) external view returns (bytes32); + function configSumOf(bytes32 _chain) external view returns (bytes32); + function set (bytes32 _identifier, address _address, bytes32 _chainDescriptor, bytes32 _chainConfig) external returns (bool); + function seal() external returns (bool); + // TODO: extend RegistryClient, but flatten files + function addressOf(bytes32) external view returns (address); } diff --git a/RegistryClient.sol b/RegistryClient.sol new file mode 100644 index 0000000..279a1dc --- /dev/null +++ b/RegistryClient.sol @@ -0,0 +1,11 @@ +pragma solidity >=0.6.12; + +// Author: Louis Holbrook 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 +// SPDX-License-Identifier: GPL-3.0-or-later +// File-version: 2 + + +interface RegistryClient { + function registryCount() external view returns (uint256); + function addressOf(bytes32) external view returns (address); +} diff --git a/RegistryStandard.sol b/RegistryStandard.sol new file mode 100644 index 0000000..e85507e --- /dev/null +++ b/RegistryStandard.sol @@ -0,0 +1,12 @@ +pragma solidity >=0.6.12; + +// Author: Louis Holbrook 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); +} diff --git a/RegistryStandard.txt b/RegistryStandard.txt new file mode 100644 index 0000000..43e8f5e --- /dev/null +++ b/RegistryStandard.txt @@ -0,0 +1,3 @@ +registryCount() +addressOf(bytes32) +register(bytes32,address) diff --git a/TokenEndorsement.sol b/TokenEndorsement.sol new file mode 100644 index 0000000..4f4155a --- /dev/null +++ b/TokenEndorsement.sol @@ -0,0 +1,3 @@ +interface TokenEndorser { + function getBySymbol(address _tokenAddress) external view returns ( bytes32 ); +} diff --git a/TokenRegistry.sol b/TokenRegistry.sol new file mode 100644 index 0000000..eb91256 --- /dev/null +++ b/TokenRegistry.sol @@ -0,0 +1,18 @@ +pragma solidity >=0.6.12; + +// Author: Louis Holbrook 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 ); +} diff --git a/TokenRegistryClient.sol b/TokenRegistryClient.sol new file mode 100644 index 0000000..eb91256 --- /dev/null +++ b/TokenRegistryClient.sol @@ -0,0 +1,18 @@ +pragma solidity >=0.6.12; + +// Author: Louis Holbrook 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 ); +} diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..4e379d2 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.0.2 diff --git a/abis/AccountsIndex.abi b/abis/AccountRegistry.json similarity index 100% rename from abis/AccountsIndex.abi rename to abis/AccountRegistry.json diff --git a/abis/Converter.abi b/abis/Converter.json similarity index 100% rename from abis/Converter.abi rename to abis/Converter.json diff --git a/abis/ConverterRegistry.abi b/abis/ConverterRegistry.abi deleted file mode 100644 index b405748..0000000 --- a/abis/ConverterRegistry.abi +++ /dev/null @@ -1 +0,0 @@ -[{"inputs":[],"name":"getConvertibleTokens","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_type","type":"uint16"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"_decimals","type":"uint8"},{"internalType":"uint32","name":"_maxConversionFee","type":"uint32"},{"internalType":"address[]","name":"_reserveTokens","type":"address[]"},{"internalType":"uint32[]","name":"_reserveWeights","type":"uint32[]"}],"name":"newConverter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"}] diff --git a/abis/ConverterRegistry.json b/abis/ConverterRegistry.json new file mode 100644 index 0000000..34e1559 --- /dev/null +++ b/abis/ConverterRegistry.json @@ -0,0 +1 @@ +[{"inputs":[{"internalType":"address[]","name":"_anchors","type":"address[]"}],"name":"getConvertersByAnchors","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getConvertibleTokens","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_type","type":"uint16"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"_decimals","type":"uint8"},{"internalType":"uint32","name":"_maxConversionFee","type":"uint32"},{"internalType":"address[]","name":"_reserveTokens","type":"address[]"},{"internalType":"uint32[]","name":"_reserveWeights","type":"uint32[]"}],"name":"newConverter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"}] diff --git a/abis/ERC20.abi b/abis/ERC20.json similarity index 100% rename from abis/ERC20.abi rename to abis/ERC20.json diff --git a/abis/Faucet.abi b/abis/Faucet.json similarity index 100% rename from abis/Faucet.abi rename to abis/Faucet.json diff --git a/abis/Network.abi b/abis/Network.abi deleted file mode 100644 index 68e237a..0000000 --- a/abis/Network.abi +++ /dev/null @@ -1 +0,0 @@ -[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_smartToken","type":"address"},{"indexed":true,"internalType":"address","name":"_fromToken","type":"address"},{"indexed":true,"internalType":"address","name":"_toToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"_fromAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_toAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"_trader","type":"address"}],"name":"Conversion","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"convert","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"rateByPath","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}] diff --git a/abis/Network.json b/abis/Network.json new file mode 100644 index 0000000..e9a8973 --- /dev/null +++ b/abis/Network.json @@ -0,0 +1 @@ +[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_smartToken","type":"address"},{"indexed":true,"internalType":"address","name":"_fromToken","type":"address"},{"indexed":true,"internalType":"address","name":"_toToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"_fromAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_toAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"_trader","type":"address"}],"name":"Conversion","type":"event"},{"inputs":[{"internalType":"address[]","name":"_path","type":"address[]"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_minReturn","type":"uint256"}],"name":"convert","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"rateByPath","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}] diff --git a/abis/Registry.json b/abis/Registry.json new file mode 100644 index 0000000..30813e4 --- /dev/null +++ b/abis/Registry.json @@ -0,0 +1 @@ +[{"inputs":[{"internalType":"bytes32","name":"","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":[],"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":[],"name":"seal","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","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"}] diff --git a/abis/Registry.abi b/abis/RegistryClient.json similarity index 67% rename from abis/Registry.abi rename to abis/RegistryClient.json index 1ff5f61..2b3baa8 100644 --- a/abis/Registry.abi +++ b/abis/RegistryClient.json @@ -1 +1 @@ -[{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"addressOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}] +[{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"addressOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}] diff --git a/abis/TokenEndorser.json b/abis/TokenEndorser.json new file mode 100644 index 0000000..388a916 --- /dev/null +++ b/abis/TokenEndorser.json @@ -0,0 +1 @@ +[{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"bytes32","name":"_data","type":"bytes32"}],"name":"add","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"endorsement","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"endorser","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"endorserTokenCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"tokenSymbolIndex","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokens","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}] diff --git a/abis/TokenRegistry.json b/abis/TokenRegistry.json new file mode 100644 index 0000000..388a916 --- /dev/null +++ b/abis/TokenRegistry.json @@ -0,0 +1 @@ +[{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"bytes32","name":"_data","type":"bytes32"}],"name":"add","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"endorsement","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"endorser","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"endorserTokenCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"tokenSymbolIndex","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokens","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}] diff --git a/abis/TransferApproval.abi b/abis/TransferApproval.json similarity index 100% rename from abis/TransferApproval.abi rename to abis/TransferApproval.json diff --git a/calculate_erc165.py b/calculate_erc165.py new file mode 100644 index 0000000..dcf1cfa --- /dev/null +++ b/calculate_erc165.py @@ -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() diff --git a/util/mergeabis.py b/util/mergeabis.py new file mode 100644 index 0000000..d7608ad --- /dev/null +++ b/util/mergeabis.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 + +import sys +import json + +merged = [] +for a in sys.argv[1:]: + f = open(a, 'r') + j = json.load(f) + f.close() + merged += j + +print(json.dumps(merged))