mirror of
git://holbrook.no/eth-address-index
synced 2026-03-30 07:20:47 +02:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c09b43c762
|
||
|
|
3612c7e680
|
||
|
|
9a8b90ec61
|
||
|
|
155f8caf9b
|
||
|
|
8521b32382
|
||
|
|
40682382de
|
||
|
|
3b7bf3e773
|
||
|
|
c3d849ed65
|
||
|
|
bcd56d06a0
|
||
|
|
c71c9d6c0b
|
||
|
|
cdb7bdd777
|
||
|
|
243f0e325c
|
||
|
|
aab2107efc
|
||
|
|
aa99032d00 | ||
| 0d2ec53b69 | |||
| d68995329c |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -4,3 +4,5 @@ dist/
|
||||
__pycache__
|
||||
*.pyc
|
||||
gmon.out
|
||||
.idea
|
||||
venv
|
||||
|
||||
58
.gitlab-ci.yml
Normal file
58
.gitlab-ci.yml
Normal file
@@ -0,0 +1,58 @@
|
||||
stages:
|
||||
- test
|
||||
- run-coverage
|
||||
- slither-analyzer
|
||||
|
||||
|
||||
variables:
|
||||
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .cache/pip
|
||||
- .venv/
|
||||
|
||||
before_script:
|
||||
- python -V # Print out python version for debugging
|
||||
- pip install virtualenv
|
||||
- virtualenv venv
|
||||
- source venv/bin/activate
|
||||
|
||||
test:
|
||||
image: registry.gitlab.com/grassrootseconomics/cic-base-images/ci-solc-python:latest
|
||||
script:
|
||||
# install test dependencies
|
||||
- cd python
|
||||
- export PYTHONPATH=.
|
||||
- pip install --extra-index-url https://pip.grassrootseconomics.net
|
||||
--extra-index-url https://gitlab.com/api/v4/projects/27624814/packages/pypi/simple
|
||||
-r requirements.txt -r test_requirements.txt
|
||||
# run tests
|
||||
- bash run_tests.sh
|
||||
|
||||
run-coverage:
|
||||
stage: test
|
||||
image: registry.gitlab.com/grassrootseconomics/cic-base-images/ci-solc-python:latest
|
||||
script:
|
||||
- cd python
|
||||
- export PYTHONPATH=.
|
||||
- pip install --extra-index-url https://pip.grassrootseconomics.net
|
||||
--extra-index-url https://gitlab.com/api/v4/projects/27624814/packages/pypi/simple
|
||||
-r requirements.txt -r test_requirements.txt
|
||||
- pip install pytest pytest-cov
|
||||
- coverage run -m pytest
|
||||
- coverage html
|
||||
- coverage report --fail-under=90
|
||||
|
||||
coverage: '/^TOTAL.+?(\d+\%)$/'
|
||||
artifacts:
|
||||
reports:
|
||||
cobertura: python/htmlcov/index.html
|
||||
|
||||
slither-analyzer:
|
||||
image: registry.gitlab.com/grassrootseconomics/cic-base-images/ci-solc-python:latest
|
||||
allow_failure: true
|
||||
script:
|
||||
- cd solidity
|
||||
- slither AddressDeclarator.sol
|
||||
- slither AddressDeclarator.sol --print human-summary
|
||||
BIN
python/.coverage
Normal file
BIN
python/.coverage
Normal file
Binary file not shown.
7
python/.coveragerc
Normal file
7
python/.coveragerc
Normal file
@@ -0,0 +1,7 @@
|
||||
[run]
|
||||
branch = True
|
||||
[report]
|
||||
omit = .venv/*
|
||||
**/runnable/*.py
|
||||
[html]
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
- 0.7.2
|
||||
* Set bytes32(0) as topic for topic-less declaration
|
||||
- 0.7.1
|
||||
* Add topic option to declarations
|
||||
- 0.7.0
|
||||
* Change license
|
||||
- 0.6.3
|
||||
* Add contract metadata
|
||||
- 0.6.2
|
||||
* Remove haveDeclaration solidity method
|
||||
- 0.6.1
|
||||
* Fix broken calls for some chains; force block height parameter
|
||||
- 0.6.0
|
||||
* Upgrade deps
|
||||
- 0.5.0
|
||||
* Upgrade deps
|
||||
- 0.4.0
|
||||
* Upgrade chainlib
|
||||
- 0.3.0
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
[{"inputs":[{"internalType":"bytes32","name":"_initialDescription","type":"bytes32"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_declarator","type":"address"},{"indexed":false,"internalType":"address","name":"_subject","type":"address"},{"indexed":false,"internalType":"bytes32","name":"_proof","type":"bytes32"}],"name":"DeclarationAdded","type":"event"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"},{"internalType":"bytes32","name":"_proof","type":"bytes32"}],"name":"addDeclaration","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"contents","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_declarator","type":"address"},{"internalType":"address","name":"_subject","type":"address"}],"name":"declaration","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_declarator","type":"address"},{"internalType":"uint256","name":"_idx","type":"uint256"}],"name":"declarationAddressAt","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_declarator","type":"address"}],"name":"declarationCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"},{"internalType":"uint256","name":"_idx","type":"uint256"}],"name":"declaratorAddressAt","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"}],"name":"declaratorCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_declarator","type":"address"},{"internalType":"address","name":"_subject","type":"address"},{"internalType":"bytes32","name":"_proof","type":"bytes32"}],"name":"haveDeclaration","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_sum","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"}]
|
||||
[{"inputs":[{"internalType":"bytes32","name":"_initial","type":"bytes32"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_declarator","type":"address"},{"indexed":true,"internalType":"address","name":"_subject","type":"address"},{"indexed":true,"internalType":"bytes32","name":"_topic","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"_proof","type":"bytes32"}],"name":"DeclarationAdded","type":"event"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"},{"internalType":"bytes32","name":"_proof","type":"bytes32"},{"internalType":"bytes32","name":"_topic","type":"bytes32"}],"name":"addDeclaration","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"},{"internalType":"bytes32","name":"_proof","type":"bytes32"}],"name":"addDeclaration","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_declarator","type":"address"},{"internalType":"address","name":"_subject","type":"address"}],"name":"declaration","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_declarator","type":"address"},{"internalType":"address","name":"_subject","type":"address"},{"internalType":"bytes32","name":"_topic","type":"bytes32"}],"name":"declaration","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_declarator","type":"address"},{"internalType":"uint256","name":"_idx","type":"uint256"}],"name":"declarationAddressAt","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_declarator","type":"address"}],"name":"declarationCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"},{"internalType":"uint256","name":"_idx","type":"uint256"}],"name":"declaratorAddressAt","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"}],"name":"declaratorCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_sum","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"}]
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{"compiler":{"version":"0.8.18+commit.87f61d96"},"language":"Solidity","output":{"abi":[{"inputs":[{"internalType":"bytes32","name":"_initial","type":"bytes32"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_declarator","type":"address"},{"indexed":true,"internalType":"address","name":"_subject","type":"address"},{"indexed":true,"internalType":"bytes32","name":"_topic","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"_proof","type":"bytes32"}],"name":"DeclarationAdded","type":"event"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"},{"internalType":"bytes32","name":"_proof","type":"bytes32"},{"internalType":"bytes32","name":"_topic","type":"bytes32"}],"name":"addDeclaration","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"},{"internalType":"bytes32","name":"_proof","type":"bytes32"}],"name":"addDeclaration","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_declarator","type":"address"},{"internalType":"address","name":"_subject","type":"address"}],"name":"declaration","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_declarator","type":"address"},{"internalType":"address","name":"_subject","type":"address"},{"internalType":"bytes32","name":"_topic","type":"bytes32"}],"name":"declaration","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_declarator","type":"address"},{"internalType":"uint256","name":"_idx","type":"uint256"}],"name":"declarationAddressAt","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_declarator","type":"address"}],"name":"declarationCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"},{"internalType":"uint256","name":"_idx","type":"uint256"}],"name":"declaratorAddressAt","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"}],"name":"declaratorCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_sum","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"}],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"compilationTarget":{"AddressDeclarator.sol":"AddressDeclarator"},"evmVersion":"byzantium","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":false,"runs":200},"remappings":[]},"sources":{"AddressDeclarator.sol":{"keccak256":"0x44cf5a059a1525a4015b98dfad9ff85c7736a7c3dbd950fc06cf9f833cf46385","license":"AGPL-3.0-or-later","urls":["bzz-raw://0cfcaf0cb346885ba4bac8c9b2bd4bbdacc9d55ce263d04150ab4c1293747b15","dweb:/ipfs/QmTs821JYsbvnF3qDcyzSSaFpNXLBqcGuoRdZa6kLtAXWa"]}},"version":1}
|
||||
@@ -69,11 +69,10 @@ class AddressDeclarator(Declarator):
|
||||
return 2000000
|
||||
|
||||
|
||||
def constructor(self, sender_address, initial_description):
|
||||
def constructor(self, sender_address, description):
|
||||
code = AddressDeclarator.bytecode()
|
||||
enc = ABIContractEncoder()
|
||||
initial_description_hex = add_0x(initial_description)
|
||||
enc.bytes32(initial_description_hex)
|
||||
enc.bytes32(description)
|
||||
code += enc.get()
|
||||
tx = self.template(sender_address, None, use_nonce=True)
|
||||
tx = self.set_code(tx, code)
|
||||
|
||||
@@ -19,19 +19,25 @@ from chainlib.eth.contract import (
|
||||
)
|
||||
from chainlib.jsonrpc import JSONRPCRequest
|
||||
from chainlib.eth.constant import ZERO_ADDRESS
|
||||
from chainlib.block import BlockSpec
|
||||
from chainlib.eth.jsonrpc import to_blockheight_param
|
||||
|
||||
logg = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Declarator(TxFactory):
|
||||
|
||||
def add_declaration(self, contract_address, sender_address, subject_address, proof, tx_format=TxFormat.JSONRPC):
|
||||
def add_declaration(self, contract_address, sender_address, subject_address, proof, topic=None, tx_format=TxFormat.JSONRPC):
|
||||
enc = ABIContractEncoder()
|
||||
enc.method('addDeclaration')
|
||||
enc.typ(ABIContractType.ADDRESS)
|
||||
enc.typ(ABIContractType.BYTES32)
|
||||
if topic != None:
|
||||
enc.typ(ABIContractType.BYTES32)
|
||||
enc.address(subject_address)
|
||||
enc.bytes32(proof)
|
||||
if topic != None:
|
||||
enc.bytes32(topic)
|
||||
data = enc.get()
|
||||
tx = self.template(sender_address, contract_address, use_nonce=True)
|
||||
tx = self.set_code(tx, data)
|
||||
@@ -39,7 +45,7 @@ class Declarator(TxFactory):
|
||||
return tx
|
||||
|
||||
|
||||
def declarator_count(self, contract_address, subject_address, sender_address=ZERO_ADDRESS, id_generator=None):
|
||||
def declarator_count(self, contract_address, subject_address, sender_address=ZERO_ADDRESS, id_generator=None, height=BlockSpec.LATEST):
|
||||
j = JSONRPCRequest(id_generator)
|
||||
o = j.template()
|
||||
o['method'] = 'eth_call'
|
||||
@@ -51,11 +57,13 @@ class Declarator(TxFactory):
|
||||
tx = self.template(sender_address, contract_address)
|
||||
tx = self.set_code(tx, data)
|
||||
o['params'].append(self.normalize(tx))
|
||||
height = to_blockheight_param(height)
|
||||
o['params'].append(height)
|
||||
o = j.finalize(o)
|
||||
return o
|
||||
|
||||
|
||||
def declaration(self, contract_address, declarator_address, subject_address, sender_address=ZERO_ADDRESS, id_generator=None):
|
||||
def declaration(self, contract_address, declarator_address, subject_address, topic=None, sender_address=ZERO_ADDRESS, id_generator=None, height=BlockSpec.LATEST):
|
||||
j = JSONRPCRequest(id_generator)
|
||||
o = j.template()
|
||||
o['method'] = 'eth_call'
|
||||
@@ -63,17 +71,23 @@ class Declarator(TxFactory):
|
||||
enc.method('declaration')
|
||||
enc.typ(ABIContractType.ADDRESS)
|
||||
enc.typ(ABIContractType.ADDRESS)
|
||||
if topic != None:
|
||||
enc.typ(ABIContractType.BYTES32)
|
||||
enc.address(declarator_address)
|
||||
enc.address(subject_address)
|
||||
if topic != None:
|
||||
enc.bytes32(topic)
|
||||
data = add_0x(enc.get())
|
||||
tx = self.template(sender_address, contract_address)
|
||||
tx = self.set_code(tx, data)
|
||||
o['params'].append(self.normalize(tx))
|
||||
height = to_blockheight_param(height)
|
||||
o['params'].append(height)
|
||||
o = j.finalize(o)
|
||||
return o
|
||||
|
||||
|
||||
def declaration_address_at(self, contract_address, declarator_address, idx, sender_address=ZERO_ADDRESS, id_generator=None):
|
||||
def declaration_address_at(self, contract_address, declarator_address, idx, sender_address=ZERO_ADDRESS, id_generator=None, height=BlockSpec.LATEST):
|
||||
j = JSONRPCRequest(id_generator)
|
||||
o = j.template()
|
||||
o['method'] = 'eth_call'
|
||||
@@ -87,11 +101,13 @@ class Declarator(TxFactory):
|
||||
tx = self.template(sender_address, contract_address)
|
||||
tx = self.set_code(tx, data)
|
||||
o['params'].append(self.normalize(tx))
|
||||
height = to_blockheight_param(height)
|
||||
o['params'].append(height)
|
||||
o = j.finalize(o)
|
||||
return o
|
||||
|
||||
|
||||
def declarator_address_at(self, contract_address, subject_address, idx, sender_address=ZERO_ADDRESS, id_generator=None):
|
||||
def declarator_address_at(self, contract_address, subject_address, idx, sender_address=ZERO_ADDRESS, id_generator=None, height=BlockSpec.LATEST):
|
||||
j = JSONRPCRequest(id_generator)
|
||||
o = j.template()
|
||||
o['method'] = 'eth_call'
|
||||
@@ -105,6 +121,8 @@ class Declarator(TxFactory):
|
||||
tx = self.template(sender_address, contract_address)
|
||||
tx = self.set_code(tx, data)
|
||||
o['params'].append(self.normalize(tx))
|
||||
height = to_blockheight_param(height)
|
||||
o['params'].append(height)
|
||||
o = j.finalize(o)
|
||||
return o
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
"""Adds a new Address declaration
|
||||
|
||||
.. moduleauthor:: Louis Holbrook <dev@holbrook.no>
|
||||
.. pgp:: 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
|
||||
|
||||
@@ -7,8 +6,6 @@
|
||||
|
||||
# standard imports
|
||||
import os
|
||||
import json
|
||||
import argparse
|
||||
import logging
|
||||
|
||||
# external imports
|
||||
@@ -21,6 +18,19 @@ from hexathon import (
|
||||
add_0x,
|
||||
strip_0x,
|
||||
)
|
||||
from chainlib.eth.cli.arg import (
|
||||
Arg,
|
||||
ArgFlag,
|
||||
process_args,
|
||||
)
|
||||
from chainlib.eth.cli.config import (
|
||||
Config,
|
||||
process_config,
|
||||
)
|
||||
from chainlib.eth.cli.log import process_log
|
||||
from chainlib.eth.settings import process_settings
|
||||
from chainlib.settings import ChainSettings
|
||||
|
||||
|
||||
# local imports
|
||||
from eth_address_declarator.declarator import AddressDeclarator
|
||||
@@ -28,58 +38,57 @@ from eth_address_declarator.declarator import AddressDeclarator
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
logg = logging.getLogger()
|
||||
|
||||
script_dir = os.path.dirname(__file__)
|
||||
data_dir = os.path.join(script_dir, '..', 'data')
|
||||
|
||||
arg_flags = chainlib.eth.cli.argflag_std_write | chainlib.eth.cli.Flag.EXEC
|
||||
argparser = chainlib.eth.cli.ArgumentParser(arg_flags)
|
||||
argparser.add_argument('-a', '--address', type=str, help='Address to add declaration for')
|
||||
argparser.add_positional('declaration', type=str, help='SHA256 sum of endorsement data to add')
|
||||
def process_config_local(config, arg, args, flags):
|
||||
hsh = strip_0x(config.get('_POSARG'))
|
||||
if len(hsh) != 64:
|
||||
raise ValueError('declaration hash must be 32 bytes')
|
||||
config.add(hsh, '_DECLARATION')
|
||||
return config
|
||||
|
||||
|
||||
arg_flags = ArgFlag()
|
||||
arg = Arg(arg_flags)
|
||||
flags = arg_flags.STD_WRITE | arg_flags.WALLET | arg_flags.EXEC
|
||||
|
||||
argparser = chainlib.eth.cli.ArgumentParser()
|
||||
argparser = process_args(argparser, arg, flags)
|
||||
argparser.add_argument('declaration', type=str, help='SHA256 sum of endorsement data to add')
|
||||
args = argparser.parse_args()
|
||||
|
||||
extra_args = {
|
||||
'address': None,
|
||||
'declaration': None,
|
||||
}
|
||||
config = chainlib.eth.cli.Config.from_args(args, arg_flags, extra_args=extra_args, default_fee_limit=AddressDeclarator.gas())
|
||||
logg = process_log(args, logg)
|
||||
|
||||
wallet = chainlib.eth.cli.Wallet()
|
||||
wallet.from_config(config)
|
||||
config = Config()
|
||||
config = process_config(config, arg, args, flags, positional_name='declaration')
|
||||
config = process_config_local(config, arg, args, flags)
|
||||
logg.debug('config loaded:\n{}'.format(config))
|
||||
|
||||
rpc = chainlib.eth.cli.Rpc(wallet=wallet)
|
||||
conn = rpc.connect_by_config(config)
|
||||
|
||||
chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC'))
|
||||
settings = ChainSettings()
|
||||
settings = process_settings(settings, config)
|
||||
logg.debug('settings loaded:\n{}'.format(settings))
|
||||
|
||||
|
||||
def main():
|
||||
signer = rpc.get_signer()
|
||||
signer_address = rpc.get_sender_address()
|
||||
conn = settings.get('CONN')
|
||||
c = AddressDeclarator(
|
||||
settings.get('CHAIN_SPEC'),
|
||||
signer=settings.get('SIGNER'),
|
||||
gas_oracle=settings.get('FEE_ORACLE'),
|
||||
nonce_oracle=settings.get('NONCE_ORACLE'),
|
||||
)
|
||||
subject_address = to_checksum_address(settings.get('RECIPIENT'))
|
||||
contract_address = to_checksum_address(settings.get('EXEC'))
|
||||
|
||||
gas_oracle = rpc.get_gas_oracle()
|
||||
nonce_oracle = rpc.get_nonce_oracle()
|
||||
(tx_hash_hex, o) = c.add_declaration(
|
||||
settings.get('EXEC'),
|
||||
settings.get('SENDER_ADDRESS'),
|
||||
settings.get('RECIPIENT'),
|
||||
add_0x(config.get('_DECLARATION')),
|
||||
)
|
||||
|
||||
c = AddressDeclarator(chain_spec, signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle)
|
||||
|
||||
subject_address = to_checksum_address(config.get('_ADDRESS'))
|
||||
if not config.true('_UNSAFE') and subject_address != add_0x(config.get('_ADDRESS')):
|
||||
raise ValueError('invalid checksum address for subject_address')
|
||||
|
||||
contract_address = to_checksum_address(config.get('_EXEC_ADDRESS'))
|
||||
if not config.true('_UNSAFE') and contract_address != add_0x(config.get('_EXEC_ADDRESS')):
|
||||
raise ValueError('invalid checksum address for contract')
|
||||
|
||||
declaration = config.get('_DECLARATION')
|
||||
declaration_bytes = bytes.fromhex(strip_0x(declaration))
|
||||
if len(declaration_bytes) != 32:
|
||||
raise ValueError('declaration hash must be 32 bytes')
|
||||
declaration = add_0x(declaration)
|
||||
|
||||
(tx_hash_hex, o) = c.add_declaration(contract_address, signer_address, subject_address, declaration)
|
||||
|
||||
if config.get('_RPC_SEND'):
|
||||
if settings.get('RPC_SEND'):
|
||||
conn.do(o)
|
||||
if config.get('_WAIT'):
|
||||
if config.true('_WAIT'):
|
||||
r = conn.wait(tx_hash_hex)
|
||||
if r['status'] == 0:
|
||||
sys.stderr.write('EVM revert while deploying contract. Wish I had more to tell you')
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
"""Deploys address declaration contract
|
||||
|
||||
.. moduleauthor:: Louis Holbrook <dev@holbrook.no>
|
||||
.. pgp:: 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
|
||||
|
||||
"""
|
||||
|
||||
# standard imports
|
||||
import sys
|
||||
import os
|
||||
import json
|
||||
import argparse
|
||||
import logging
|
||||
from hexathon import (
|
||||
add_0x,
|
||||
strip_0x,
|
||||
)
|
||||
|
||||
# external imports
|
||||
import chainlib.eth.cli
|
||||
from chainlib.chain import ChainSpec
|
||||
from chainlib.eth.connection import EthHTTPConnection
|
||||
from chainlib.eth.tx import receipt
|
||||
|
||||
# local imports
|
||||
from eth_address_declarator.declarator import AddressDeclarator
|
||||
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
logg = logging.getLogger()
|
||||
|
||||
arg_flags = chainlib.eth.cli.argflag_std_write
|
||||
argparser = chainlib.eth.cli.ArgumentParser(arg_flags)
|
||||
argparser.add_argument('owner_description_hash', type=str, help='SHA256 of description metadata of contract deployer')
|
||||
args = argparser.parse_args()
|
||||
|
||||
extra_args = {
|
||||
'owner_description_hash': None,
|
||||
}
|
||||
config = chainlib.eth.cli.Config.from_args(args, arg_flags, extra_args=extra_args, default_fee_limit=AddressDeclarator.gas())
|
||||
|
||||
wallet = chainlib.eth.cli.Wallet()
|
||||
wallet.from_config(config)
|
||||
|
||||
rpc = chainlib.eth.cli.Rpc(wallet=wallet)
|
||||
conn = rpc.connect_by_config(config)
|
||||
|
||||
chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC'))
|
||||
|
||||
|
||||
def main():
|
||||
signer = rpc.get_signer()
|
||||
signer_address = rpc.get_sender_address()
|
||||
|
||||
gas_oracle = rpc.get_gas_oracle()
|
||||
nonce_oracle = rpc.get_nonce_oracle()
|
||||
|
||||
c = AddressDeclarator(chain_spec, signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle)
|
||||
|
||||
owner_description_hash = config.get('_OWNER_DESCRIPTION_HASH')
|
||||
owner_description_hash_bytes = bytes.fromhex(strip_0x(owner_description_hash))
|
||||
if len(owner_description_hash_bytes) != 32:
|
||||
raise ValueError('chain config hash must be 32 bytes')
|
||||
owner_description_hash = add_0x(owner_description_hash)
|
||||
|
||||
(tx_hash_hex, o) = c.constructor(signer_address, owner_description_hash)
|
||||
if config.get('_RPC_SEND'):
|
||||
conn.do(o)
|
||||
if config.get('_WAIT'):
|
||||
r = conn.wait(tx_hash_hex)
|
||||
if r['status'] == 0:
|
||||
sys.stderr.write('EVM revert while deploying contract. Wish I had more to tell you')
|
||||
sys.exit(1)
|
||||
# TODO: pass through translator for keys (evm tester uses underscore instead of camelcase)
|
||||
address = r['contractAddress']
|
||||
|
||||
print(address)
|
||||
else:
|
||||
print(tx_hash_hex)
|
||||
else:
|
||||
print(o)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
108
python/eth_address_declarator/runnable/publish.py
Normal file
108
python/eth_address_declarator/runnable/publish.py
Normal file
@@ -0,0 +1,108 @@
|
||||
"""Deploys address declaration contract
|
||||
|
||||
.. moduleauthor:: Louis Holbrook <dev@holbrook.no>
|
||||
.. pgp:: 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
|
||||
|
||||
"""
|
||||
|
||||
# standard imports
|
||||
import sys
|
||||
import os
|
||||
import logging
|
||||
from hexathon import (
|
||||
add_0x,
|
||||
strip_0x,
|
||||
)
|
||||
|
||||
# external imports
|
||||
import chainlib.eth.cli
|
||||
from chainlib.chain import ChainSpec
|
||||
from chainlib.eth.connection import EthHTTPConnection
|
||||
from chainlib.eth.tx import receipt
|
||||
from chainlib.eth.cli.arg import (
|
||||
Arg,
|
||||
ArgFlag,
|
||||
process_args,
|
||||
)
|
||||
from chainlib.eth.cli.config import (
|
||||
Config,
|
||||
process_config,
|
||||
)
|
||||
from chainlib.eth.cli.log import process_log
|
||||
from chainlib.eth.settings import process_settings
|
||||
from chainlib.settings import ChainSettings
|
||||
from chainlib.eth.constant import ZERO_CONTENT
|
||||
|
||||
# local imports
|
||||
from eth_address_declarator.declarator import AddressDeclarator
|
||||
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
logg = logging.getLogger()
|
||||
|
||||
|
||||
def process_config_local(config, arg, args, flags):
|
||||
hsh = args.owner_description_hash
|
||||
if hsh == None:
|
||||
hsh = ZERO_CONTENT
|
||||
hsh = add_0x(hsh)
|
||||
config.add(hsh, '_OWNER_DESCRIPTION_HASH')
|
||||
return config
|
||||
|
||||
|
||||
arg_flags = ArgFlag()
|
||||
arg = Arg(arg_flags)
|
||||
flags = arg_flags.STD_WRITE
|
||||
|
||||
argparser = chainlib.eth.cli.ArgumentParser()
|
||||
argparser = process_args(argparser, arg, flags)
|
||||
argparser.add_argument('--owner-description-hash', type=str, help='SHA256 of description metadata of contract deployer')
|
||||
args = argparser.parse_args()
|
||||
|
||||
logg = process_log(args, logg)
|
||||
|
||||
config = Config()
|
||||
config = process_config(config, arg, args, flags)
|
||||
config = process_config_local(config, arg, args, flags)
|
||||
logg.debug('config loaded:\n{}'.format(config))
|
||||
|
||||
settings = ChainSettings()
|
||||
settings = process_settings(settings, config)
|
||||
logg.debug('settings loaded:\n{}'.format(settings))
|
||||
|
||||
|
||||
def main():
|
||||
conn = settings.get('CONN')
|
||||
c = AddressDeclarator(
|
||||
settings.get('CHAIN_SPEC'),
|
||||
signer=settings.get('SIGNER'),
|
||||
gas_oracle=settings.get('FEE_ORACLE'),
|
||||
nonce_oracle=settings.get('NONCE_ORACLE'),
|
||||
)
|
||||
owner_description_hash = config.get('_OWNER_DESCRIPTION_HASH')
|
||||
owner_description_hash_bytes = bytes.fromhex(strip_0x(owner_description_hash))
|
||||
if len(owner_description_hash_bytes) != 32:
|
||||
raise ValueError('chain config hash must be 32 bytes')
|
||||
|
||||
(tx_hash_hex, o) = c.constructor(
|
||||
settings.get('SENDER_ADDRESS'),
|
||||
owner_description_hash,
|
||||
)
|
||||
if settings.get('RPC_SEND'):
|
||||
conn.do(o)
|
||||
if config.true('_WAIT'):
|
||||
r = conn.wait(tx_hash_hex)
|
||||
if r['status'] == 0:
|
||||
sys.stderr.write('EVM revert while deploying contract. Wish I had more to tell you')
|
||||
sys.exit(1)
|
||||
# TODO: pass through translator for keys (evm tester uses underscore instead of camelcase)
|
||||
address = r['contractAddress']
|
||||
|
||||
print(address)
|
||||
else:
|
||||
print(tx_hash_hex)
|
||||
else:
|
||||
print(o)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -6,10 +6,7 @@
|
||||
"""
|
||||
|
||||
# standard imports
|
||||
import urllib
|
||||
import os
|
||||
import json
|
||||
import argparse
|
||||
import logging
|
||||
import sys
|
||||
|
||||
@@ -18,10 +15,24 @@ import chainlib.eth.cli
|
||||
from chainlib.chain import ChainSpec
|
||||
from chainlib.error import JSONRPCException
|
||||
from chainlib.eth.address import to_checksum_address
|
||||
from chainlib.eth.constant import ZERO_ADDRESS
|
||||
from hexathon import (
|
||||
add_0x,
|
||||
strip_0x,
|
||||
)
|
||||
from chainlib.eth.cli.arg import (
|
||||
Arg,
|
||||
ArgFlag,
|
||||
process_args,
|
||||
)
|
||||
from chainlib.eth.cli.config import (
|
||||
Config,
|
||||
process_config,
|
||||
)
|
||||
from chainlib.eth.cli.log import process_log
|
||||
from chainlib.eth.settings import process_settings
|
||||
from chainlib.settings import ChainSettings
|
||||
|
||||
|
||||
# local imports
|
||||
from eth_address_declarator import Declarator
|
||||
@@ -30,35 +41,46 @@ from eth_address_declarator.declarator import AddressDeclarator
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
logg = logging.getLogger()
|
||||
|
||||
#argparser.add_argument('--resolve', action='store_true', help='Attempt to resolve the hashes to actual content')
|
||||
#argparser.add_argument('--resolve-http', dest='resolve_http', type=str, help='Base url to look up content hashes')
|
||||
arg_flags = chainlib.eth.cli.argflag_std_read | chainlib.eth.cli.Flag.EXEC | chainlib.eth.cli.Flag.WALLET
|
||||
argparser = chainlib.eth.cli.ArgumentParser(arg_flags, arg_long={'-a': '--declarator-address'})
|
||||
argparser.add_positional('address', type=str, help='Ethereum declaration address to look up')
|
||||
|
||||
def process_config_local(config, arg, args, flags):
|
||||
a = strip_0x(config.get('_POSARG'))
|
||||
ac = to_checksum_address(a)
|
||||
if config.true('_UNSAFE'):
|
||||
a = ac
|
||||
else:
|
||||
if a != ac:
|
||||
raise ValueError('declarator is not a valid checksum address')
|
||||
config.add(a, '_DECLARATOR')
|
||||
return config
|
||||
|
||||
|
||||
arg_flags = ArgFlag()
|
||||
arg = Arg(arg_flags)
|
||||
flags = arg_flags.STD_WRITE | arg_flags.WALLET | arg_flags.EXEC | arg_flags.SENDER
|
||||
|
||||
argparser = chainlib.eth.cli.ArgumentParser()
|
||||
argparser = process_args(argparser, arg, flags)
|
||||
argparser.add_argument('declarator', type=str, help='Ethereum declaration address to look up')
|
||||
args = argparser.parse_args()
|
||||
|
||||
extra_args = {
|
||||
'address': None,
|
||||
}
|
||||
config = chainlib.eth.cli.Config.from_args(args, arg_flags, extra_args=extra_args, default_fee_limit=AddressDeclarator.gas())
|
||||
logg = process_log(args, logg)
|
||||
|
||||
wallet = chainlib.eth.cli.Wallet()
|
||||
wallet.from_config(config)
|
||||
config = Config()
|
||||
config = process_config(config, arg, args, flags, positional_name='declarator')
|
||||
config = process_config_local(config, arg, args, flags)
|
||||
logg.debug('config loaded:\n{}'.format(config))
|
||||
|
||||
rpc = chainlib.eth.cli.Rpc()
|
||||
conn = rpc.connect_by_config(config)
|
||||
|
||||
chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC'))
|
||||
|
||||
declarator_address = config.get('_WALLET_ADDRESS')
|
||||
settings = ChainSettings()
|
||||
settings = process_settings(settings, config)
|
||||
logg.debug('settings loaded:\n{}'.format(settings))
|
||||
|
||||
|
||||
def out_element(e, w=sys.stdout):
|
||||
w.write(e[1] + '\n')
|
||||
|
||||
|
||||
def ls(ifc, conn, contract_address, declarator_address, subject_address, w=sys.stdout):
|
||||
o = ifc.declaration(contract_address, declarator_address, subject_address)
|
||||
def ls(ifc, conn, contract_address, declarator_address, subject_address, w=sys.stdout, sender_address=ZERO_ADDRESS):
|
||||
o = ifc.declaration(contract_address, declarator_address, subject_address, sender_address=sender_address)
|
||||
r = conn.do(o)
|
||||
declarations = ifc.parse_declaration(r)
|
||||
|
||||
@@ -68,41 +90,21 @@ def ls(ifc, conn, contract_address, declarator_address, subject_address, w=sys.s
|
||||
|
||||
def main():
|
||||
|
||||
c = Declarator(chain_spec)
|
||||
c = Declarator(
|
||||
settings.get('CHAIN_SPEC')
|
||||
)
|
||||
|
||||
contract_address = to_checksum_address(config.get('_EXEC_ADDRESS'))
|
||||
if not config.true('_UNSAFE') and contract_address != add_0x(config.get('_EXEC_ADDRESS')):
|
||||
raise ValueError('invalid checksum address for contract')
|
||||
|
||||
|
||||
declarator_address = to_checksum_address(config.get('_DECLARATOR_ADDRESS'))
|
||||
if not config.true('_UNSAFE') and declarator_address != add_0x(config.get('_DECLARATOR_ADDRESS')):
|
||||
raise ValueError('invalid checksum address for declarator')
|
||||
|
||||
subject_address = to_checksum_address(config.get('_ADDRESS'))
|
||||
if not config.true('_UNSAFE') and subject_address != add_0x(config.get('_ADDRESS')):
|
||||
raise ValueError('invalid checksum address for subject')
|
||||
|
||||
ls(c, conn, contract_address, declarator_address, subject_address)
|
||||
ls(
|
||||
c,
|
||||
settings.get('CONN'),
|
||||
settings.get('EXEC'),
|
||||
config.get('_DECLARATOR'),
|
||||
settings.get('RECIPIENT'),
|
||||
sender_address=settings.get('SENDER_ADDRESS'),
|
||||
)
|
||||
|
||||
declarations = []
|
||||
|
||||
# for d in declarations:
|
||||
# if not args.resolve:
|
||||
# print(d.hex())
|
||||
# continue
|
||||
# if args.resolve_http:
|
||||
# try:
|
||||
# r = try_sha256(d)
|
||||
# print(r)
|
||||
# continue
|
||||
# except urllib.error.HTTPError:
|
||||
# pass
|
||||
# try:
|
||||
# print(try_utf8(d))
|
||||
# except UnicodeDecodeError:
|
||||
# pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -12,6 +12,7 @@ from giftable_erc20_token import GiftableToken
|
||||
|
||||
# local imports
|
||||
from eth_address_declarator.declarator import AddressDeclarator
|
||||
#from eth_address_declarator.kv import AddressDeclaratorKV
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
logg = logging.getLogger()
|
||||
@@ -32,7 +33,7 @@ class TestAddressDeclaratorBase(EthTesterCase):
|
||||
self.assertEqual(r['status'], 1)
|
||||
|
||||
self.address = r['contract_address']
|
||||
logg.debug('address declarator deployed with address {}'.format(self.address))
|
||||
logg.debug('address declarator published with address {}'.format(self.address))
|
||||
|
||||
c = GiftableToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
(tx_hash_hex, o) = c.constructor(self.accounts[0], 'FooToken', 'FOO', 6)
|
||||
@@ -43,4 +44,4 @@ class TestAddressDeclaratorBase(EthTesterCase):
|
||||
self.assertEqual(r['status'], 1)
|
||||
|
||||
self.foo_token_address = r['contract_address']
|
||||
logg.debug('foo token deployed with address {}'.format(self.foo_token_address))
|
||||
logg.debug('foo token published with address {}'.format(self.foo_token_address))
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
confini~=0.6.0
|
||||
chainlib-eth>=0.1.0b1,<0.2.0
|
||||
chainlib-eth~=0.4.16
|
||||
chainlib==0.4.12
|
||||
|
||||
@@ -1,28 +1,29 @@
|
||||
[metadata]
|
||||
name = eth-address-index
|
||||
version = 0.5.0
|
||||
version = 0.7.2
|
||||
description = Signed metadata declarations for ethereum addresses
|
||||
author = Louis Holbrook
|
||||
author_email = dev@holbrook.no
|
||||
url = https://gitlab.com/cicnet/eth-address-index
|
||||
url = https://holbrook.no/src/eth-address-index/log.html
|
||||
keywords =
|
||||
ethereum
|
||||
classifiers =
|
||||
Programming Language :: Python :: 3
|
||||
Operating System :: OS Independent
|
||||
Development Status :: 3 - Alpha
|
||||
Environment :: No Input/Output (Daemon)
|
||||
Development Status :: 4 - Beta
|
||||
Environment :: Console
|
||||
Intended Audience :: Developers
|
||||
License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
|
||||
License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
|
||||
Topic :: Internet
|
||||
Topic :: Software Development :: Libraries
|
||||
#Topic :: Blockchain :: EVM
|
||||
license = GPL3
|
||||
license = AGPLv3+
|
||||
licence_files =
|
||||
LICENSE
|
||||
|
||||
[options]
|
||||
include_package_data = True
|
||||
python_requires = >= 3.6
|
||||
python_requires = >= 3.7
|
||||
packages =
|
||||
eth_address_declarator
|
||||
eth_address_declarator.runnable
|
||||
@@ -36,6 +37,6 @@ packages =
|
||||
|
||||
[options.entry_points]
|
||||
console_scripts =
|
||||
eth-address-declarator-deploy = eth_address_declarator.runnable.deploy:main
|
||||
eth-address-declarator-publish = eth_address_declarator.runnable.publish:main
|
||||
eth-address-declarator-add = eth_address_declarator.runnable.add:main
|
||||
eth-address-declarator-view = eth_address_declarator.runnable.view:main
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
eth-tester==0.5.0b3
|
||||
py-evm==0.3.0a20
|
||||
eth-accounts-index~=0.1.3
|
||||
eth_erc20~=0.1.5
|
||||
eth-accounts-index~=0.3.4
|
||||
eth_erc20~=0.5.0
|
||||
|
||||
@@ -51,7 +51,6 @@ class TestAddressDeclarator(TestAddressDeclaratorBase):
|
||||
|
||||
|
||||
def test_basic(self):
|
||||
|
||||
d = add_0x(os.urandom(32).hex())
|
||||
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||
|
||||
266
python/tests/test_addressdeclarator_kv.py
Normal file
266
python/tests/test_addressdeclarator_kv.py
Normal file
@@ -0,0 +1,266 @@
|
||||
# standard imports
|
||||
import os
|
||||
import unittest
|
||||
import json
|
||||
import logging
|
||||
import hashlib
|
||||
|
||||
# external imports
|
||||
from chainlib.eth.unittest.ethtester import EthTesterCase
|
||||
from chainlib.eth.contract import (
|
||||
ABIContractEncoder,
|
||||
ABIContractType,
|
||||
)
|
||||
from chainlib.eth.nonce import RPCNonceOracle
|
||||
from chainlib.eth.tx import receipt
|
||||
from giftable_erc20_token import GiftableToken
|
||||
from hexathon import (
|
||||
add_0x,
|
||||
strip_0x,
|
||||
)
|
||||
|
||||
# local imports
|
||||
from eth_address_declarator.declarator import AddressDeclarator
|
||||
from eth_address_declarator import Declarator
|
||||
from eth_address_declarator.unittest import TestAddressDeclaratorBase
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
logg = logging.getLogger()
|
||||
|
||||
testdir = os.path.dirname(__file__)
|
||||
|
||||
description = '0x{:<064s}'.format(b'foo'.hex())
|
||||
|
||||
|
||||
class TestAddressDeclarator(TestAddressDeclaratorBase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestAddressDeclarator, self).setUp()
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||
|
||||
#c = GiftableToken(signer=self.signer, nonce_oracle=nonce_oracle, chain_id=self.chain_spec.chain_id())
|
||||
c = GiftableToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
(tx_hash_hex, o) = c.constructor(self.accounts[0], 'BarToken', 'BAR', 6)
|
||||
self.rpc.do(o)
|
||||
|
||||
o = receipt(tx_hash_hex)
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(r['status'], 1)
|
||||
|
||||
self.bar_token_address = r['contract_address']
|
||||
|
||||
|
||||
def test_basic(self):
|
||||
k = add_0x(os.urandom(32).hex())
|
||||
v = add_0x(os.urandom(32).hex())
|
||||
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||
c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[0], self.foo_token_address, v, topic=k)
|
||||
self.rpc.do(o)
|
||||
o = receipt(tx_hash_hex)
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(r['status'], 1)
|
||||
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||
c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[1], self.foo_token_address, v, topic=k)
|
||||
self.rpc.do(o)
|
||||
o = receipt(tx_hash_hex)
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(r['status'], 1)
|
||||
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||
c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[0], self.bar_token_address, v, topic=k)
|
||||
self.rpc.do(o)
|
||||
|
||||
o = c.declarator_count(self.address, self.foo_token_address, sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(c.parse_declarator_count(r), 2)
|
||||
|
||||
o = c.declarator_count(self.address, self.bar_token_address, sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(c.parse_declarator_count(r), 1)
|
||||
|
||||
|
||||
def test_get_single_declaration(self):
|
||||
k = add_0x(os.urandom(32).hex())
|
||||
v = add_0x(os.urandom(32).hex())
|
||||
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||
c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[1], self.foo_token_address, v, topic=k)
|
||||
self.rpc.do(o)
|
||||
o = receipt(tx_hash_hex)
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(r['status'], 1)
|
||||
|
||||
o = c.declaration(self.address, self.accounts[1], self.foo_token_address, topic=k, sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(strip_0x(r)[128:], strip_0x(v))
|
||||
|
||||
|
||||
def test_kv_declarations(self):
|
||||
|
||||
k = add_0x(os.urandom(32).hex())
|
||||
v = add_0x(os.urandom(32).hex())
|
||||
w = add_0x(os.urandom(32).hex())
|
||||
|
||||
k_two = add_0x(os.urandom(32).hex())
|
||||
v_two = add_0x(os.urandom(32).hex())
|
||||
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||
c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[1], self.foo_token_address, v, topic=k)
|
||||
self.rpc.do(o)
|
||||
o = receipt(tx_hash_hex)
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(r['status'], 1)
|
||||
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||
c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[1], self.foo_token_address, w, topic=k)
|
||||
self.rpc.do(o)
|
||||
o = receipt(tx_hash_hex)
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(r['status'], 1)
|
||||
|
||||
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[1], self.foo_token_address, v_two, topic=k_two)
|
||||
self.rpc.do(o)
|
||||
o = receipt(tx_hash_hex)
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(r['status'], 1)
|
||||
# nonce_oracle = RPCNonceOracle(self.accounts[2], self.rpc)
|
||||
# c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
# (tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[2], self.foo_token_address, k, v)
|
||||
# self.rpc.do(o)
|
||||
#
|
||||
# c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
# (tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[2], self.bar_token_address, k, v)
|
||||
# self.rpc.do(o)
|
||||
|
||||
o = c.declaration(self.address, self.accounts[1], self.foo_token_address, topic=k, sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(strip_0x(r)[128:], strip_0x(v) + strip_0x(w))
|
||||
|
||||
o = c.declaration(self.address, self.accounts[1], self.foo_token_address, topic=k_two, sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(strip_0x(r)[128:], strip_0x(v_two))
|
||||
|
||||
|
||||
def test_declarator_to_subject(self):
|
||||
k = add_0x(os.urandom(32).hex())
|
||||
v = add_0x(os.urandom(32).hex())
|
||||
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||
c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[1], self.foo_token_address, v, topic=k)
|
||||
self.rpc.do(o)
|
||||
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[2], self.rpc)
|
||||
c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[2], self.foo_token_address, v, topic=k)
|
||||
self.rpc.do(o)
|
||||
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||
c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[1], self.bar_token_address, v, topic=k)
|
||||
self.rpc.do(o)
|
||||
|
||||
o = c.declaration_address_at(self.address, self.accounts[1], 0, sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(c.parse_declaration_address_at(r), strip_0x(self.foo_token_address))
|
||||
|
||||
o = c.declaration_address_at(self.address, self.accounts[2], 0, sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(c.parse_declaration_address_at(r), strip_0x(self.foo_token_address))
|
||||
|
||||
o = c.declaration_address_at(self.address, self.accounts[1], 1, sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(c.parse_declaration_address_at(r), strip_0x(self.bar_token_address))
|
||||
|
||||
|
||||
def test_subject_to_declarator(self):
|
||||
k = add_0x(os.urandom(32).hex())
|
||||
v = add_0x(os.urandom(32).hex())
|
||||
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||
c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[1], self.foo_token_address, v, topic=k)
|
||||
self.rpc.do(o)
|
||||
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[2], self.rpc)
|
||||
c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[2], self.foo_token_address, v, topic=k)
|
||||
self.rpc.do(o)
|
||||
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||
c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[1], self.bar_token_address, v, topic=k)
|
||||
self.rpc.do(o)
|
||||
|
||||
o = c.declarator_address_at(self.address, self.foo_token_address, 0, sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(c.parse_declaration_address_at(r), strip_0x(self.accounts[1]))
|
||||
|
||||
o = c.declarator_address_at(self.address, self.foo_token_address, 1, sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(c.parse_declaration_address_at(r), strip_0x(self.accounts[2]))
|
||||
|
||||
|
||||
def test_three_first(self):
|
||||
k = add_0x(os.urandom(32).hex())
|
||||
v = []
|
||||
for i in range(3):
|
||||
v.append(add_0x(os.urandom(32).hex()))
|
||||
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||
c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
|
||||
for proof in v:
|
||||
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[0], self.foo_token_address, proof, topic=k)
|
||||
self.rpc.do(o)
|
||||
|
||||
o = c.declarator_count(self.address, self.foo_token_address, sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(c.parse_declarator_count(r), 1)
|
||||
|
||||
o = c.declaration(self.address, self.accounts[0], self.foo_token_address, topic=k, sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
proofs = c.parse_declaration(r)
|
||||
self.assertEqual(len(proofs), 3)
|
||||
|
||||
for i in range(3):
|
||||
self.assertEqual(proofs[i], strip_0x(v[i]))
|
||||
|
||||
|
||||
def test_three_first_different(self):
|
||||
k = add_0x(os.urandom(32).hex())
|
||||
v = []
|
||||
a = []
|
||||
for i in range(3):
|
||||
v.append(add_0x(os.urandom(32).hex()))
|
||||
a.append(add_0x(os.urandom(20).hex()))
|
||||
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||
c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
|
||||
for i in range(3):
|
||||
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[0], a[i], v[i], topic=k)
|
||||
self.rpc.do(o)
|
||||
|
||||
for i in range(3):
|
||||
o = c.declarator_count(self.address, a[i], sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(c.parse_declarator_count(r), 1)
|
||||
|
||||
o = c.declaration(self.address, self.accounts[0], a[i], topic=k, sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
proofs = c.parse_declaration(r)
|
||||
self.assertEqual(len(proofs), 1)
|
||||
self.assertEqual(proofs[0], strip_0x(v[i]))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
[{"inputs":[{"internalType":"bytes32","name":"_initialDescription","type":"bytes32"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_declarator","type":"address"},{"indexed":false,"internalType":"address","name":"_subject","type":"address"},{"indexed":false,"internalType":"bytes32","name":"_proof","type":"bytes32"}],"name":"DeclarationAdded","type":"event"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"},{"internalType":"bytes32","name":"_proof","type":"bytes32"}],"name":"addDeclaration","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"contents","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_declarator","type":"address"},{"internalType":"address","name":"_subject","type":"address"}],"name":"declaration","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_declarator","type":"address"},{"internalType":"uint256","name":"_idx","type":"uint256"}],"name":"declarationAddressAt","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_declarator","type":"address"}],"name":"declarationCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"},{"internalType":"uint256","name":"_idx","type":"uint256"}],"name":"declaratorAddressAt","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"}],"name":"declaratorCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_declarator","type":"address"},{"internalType":"address","name":"_subject","type":"address"},{"internalType":"bytes32","name":"_proof","type":"bytes32"}],"name":"haveDeclaration","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_sum","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"}]
|
||||
[{"inputs":[{"internalType":"bytes32","name":"_initial","type":"bytes32"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_declarator","type":"address"},{"indexed":true,"internalType":"address","name":"_subject","type":"address"},{"indexed":true,"internalType":"bytes32","name":"_topic","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"_proof","type":"bytes32"}],"name":"DeclarationAdded","type":"event"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"},{"internalType":"bytes32","name":"_proof","type":"bytes32"},{"internalType":"bytes32","name":"_topic","type":"bytes32"}],"name":"addDeclaration","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"},{"internalType":"bytes32","name":"_proof","type":"bytes32"}],"name":"addDeclaration","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_declarator","type":"address"},{"internalType":"address","name":"_subject","type":"address"}],"name":"declaration","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_declarator","type":"address"},{"internalType":"address","name":"_subject","type":"address"},{"internalType":"bytes32","name":"_topic","type":"bytes32"}],"name":"declaration","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_declarator","type":"address"},{"internalType":"uint256","name":"_idx","type":"uint256"}],"name":"declarationAddressAt","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_declarator","type":"address"}],"name":"declarationCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"},{"internalType":"uint256","name":"_idx","type":"uint256"}],"name":"declaratorAddressAt","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"}],"name":"declaratorCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_sum","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"}]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
pragma solidity >0.6.11;
|
||||
pragma solidity >=0.8.0;
|
||||
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
contract AddressDeclarator {
|
||||
|
||||
@@ -8,21 +8,17 @@ contract AddressDeclarator {
|
||||
mapping( bytes32 => uint256 ) declarationContentIndex; // the _latest_ content pointer for the declarator to subject mapping
|
||||
mapping( address => address[] ) declarator;
|
||||
mapping( address => address[] ) declaratorReverse;
|
||||
mapping( bytes32 => bool ) declarationExistIndex;
|
||||
bytes32[][] public contents;
|
||||
|
||||
event DeclarationAdded(address _declarator, address _subject, bytes32 _proof);
|
||||
bytes32[][] contents;
|
||||
|
||||
constructor(bytes32 _initialDescription) public {
|
||||
bytes32[] memory foundation;
|
||||
|
||||
contents.push(foundation);
|
||||
contents[contents.length-1].push(blockhash(block.number));
|
||||
|
||||
addDeclaration(msg.sender, _initialDescription);
|
||||
// Implements Declarator
|
||||
event DeclarationAdded(address indexed _declarator, address indexed _subject, bytes32 indexed _topic, bytes32 _proof);
|
||||
|
||||
constructor(bytes32 _initial) {
|
||||
addDeclaration(address(this), _initial);
|
||||
}
|
||||
|
||||
|
||||
// Create a digest reference for a declarator and subject pair
|
||||
function toReference(address _declarator, address _subject) private pure returns ( bytes32 ) {
|
||||
bytes32 k;
|
||||
bytes memory addrMaterial = new bytes(40);
|
||||
@@ -38,7 +34,8 @@ contract AddressDeclarator {
|
||||
return k;
|
||||
}
|
||||
|
||||
function toReference(address _declarator, address _subject, bytes32 _proof) private pure returns ( bytes32[2] memory ) {
|
||||
// Create a digest reference for a declarator and subject pair on top of the given digest
|
||||
function toReference(address _declarator, address _subject, bytes32 _digest) private pure returns ( bytes32[2] memory ) {
|
||||
bytes32 k;
|
||||
bytes32[2] memory ks;
|
||||
bytes memory signMaterial = new bytes(64);
|
||||
@@ -48,7 +45,7 @@ contract AddressDeclarator {
|
||||
signMaterial[i] = k[i];
|
||||
}
|
||||
for (uint256 i = 0; i < 32; i++) {
|
||||
signMaterial[i+32] = _proof[i];
|
||||
signMaterial[i+32] = _digest[i];
|
||||
}
|
||||
|
||||
ks[0] = k;
|
||||
@@ -68,12 +65,12 @@ contract AddressDeclarator {
|
||||
}
|
||||
|
||||
// Implements Declarator
|
||||
function addDeclaration(address _subject, bytes32 _proof) public returns ( bool ) {
|
||||
function addDeclaration(address _subject, bytes32 _proof, bytes32 _topic) public returns ( bool ) {
|
||||
bytes32[2] memory ks;
|
||||
bytes32[] memory declarationContents;
|
||||
uint256 idx;
|
||||
ks = toReference(tx.origin, _subject, _proof);
|
||||
idx = declarationContentIndex[ks[0]];
|
||||
ks = toReference(tx.origin, _subject, _topic);
|
||||
idx = declarationContentIndex[ks[1]];
|
||||
if (idx == 0) { // This also works for the constructor :)
|
||||
declarator[_subject].push(tx.origin);
|
||||
contents.push(declarationContents);
|
||||
@@ -81,30 +78,29 @@ contract AddressDeclarator {
|
||||
idx = contents.length-1;
|
||||
}
|
||||
|
||||
declarationContentIndex[ks[0]] = idx;
|
||||
declarationContentIndex[ks[1]] = idx;
|
||||
contents[idx].push(_proof);
|
||||
|
||||
declarationExistIndex[ks[1]] = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Implements Declarator
|
||||
function declaration(address _declarator, address _subject) public view returns ( bytes32[] memory ) {
|
||||
bytes32 k;
|
||||
uint256 idx;
|
||||
k = toReference(_declarator, _subject);
|
||||
idx = declarationContentIndex[k];
|
||||
return contents[idx];
|
||||
function addDeclaration(address _subject, bytes32 _proof) public returns ( bool ) {
|
||||
return addDeclaration(_subject, _proof, bytes32(0));
|
||||
}
|
||||
|
||||
// Implements Declarator
|
||||
function haveDeclaration(address _declarator, address _subject, bytes32 _proof) public view returns (bool) {
|
||||
bytes32[2] memory ks;
|
||||
|
||||
ks = toReference(_declarator, _subject, _proof);
|
||||
function declaration(address _declarator, address _subject) public view returns ( bytes32[] memory ) {
|
||||
return declaration(_declarator, _subject, bytes32(0));
|
||||
}
|
||||
|
||||
return declarationExistIndex[ks[1]];
|
||||
// Implements Declarator
|
||||
function declaration(address _declarator, address _subject, bytes32 _topic) public view returns ( bytes32[] memory ) {
|
||||
bytes32[2] memory k;
|
||||
uint256 idx;
|
||||
k = toReference(_declarator, _subject, _topic);
|
||||
idx = declarationContentIndex[k[1]];
|
||||
return contents[idx];
|
||||
}
|
||||
|
||||
// Implements Declarator
|
||||
@@ -119,7 +115,7 @@ contract AddressDeclarator {
|
||||
|
||||
// Implements EIP165
|
||||
function supportsInterface(bytes4 _sum) public pure returns (bool) {
|
||||
if (_sum == 0x27beb910) { // Implements Declarator
|
||||
if (_sum == 0x21b7493b) { // Implements Declarator
|
||||
return true;
|
||||
}
|
||||
if (_sum == 0x01ffc9a7) { // EIP165
|
||||
|
||||
@@ -1,30 +1,15 @@
|
||||
SOLC = /usr/bin/solc
|
||||
|
||||
all: address_declarator token_index accounts_index
|
||||
all: address_declarator
|
||||
|
||||
address_declarator:
|
||||
$(SOLC) AddressDeclarator.sol --abi --evm-version byzantium | awk 'NR>3' > AddressDeclarator.json
|
||||
$(SOLC) AddressDeclarator.sol --bin --evm-version byzantium | awk 'NR>3' > AddressDeclarator.bin
|
||||
$(SOLC) AddressDeclarator.sol --metadata --evm-version byzantium | awk 'NR>3' > AddressDeclarator.metadata.json
|
||||
truncate -s -1 AddressDeclarator.bin
|
||||
|
||||
token_index:
|
||||
$(SOLC) TokenUniqueSymbolIndexAddressDeclarator.sol --abi --evm-version byzantium | awk 'NR>3' > TokenUniqueSymbolIndexAddressDeclarator.json
|
||||
$(SOLC) TokenUniqueSymbolIndexAddressDeclarator.sol --bin --evm-version byzantium | awk 'NR>3' > TokenUniqueSymbolIndexAddressDeclarator.bin
|
||||
truncate -s -1 TokenUniqueSymbolIndexAddressDeclarator.bin
|
||||
|
||||
|
||||
accounts_index:
|
||||
$(SOLC) AccountsIndexAddressDeclarator.sol --abi --evm-version byzantium | awk 'NR>3' > AccountsIndexAddressDeclarator.json
|
||||
$(SOLC) AccountsIndexAddressDeclarator.sol --bin --evm-version byzantium | awk 'NR>3' > AccountsIndexAddressDeclarator.bin
|
||||
truncate -s -1 AccountsIndexAddressDeclarator.bin
|
||||
|
||||
#test: all
|
||||
#python test.py
|
||||
#python test_tokenindex.py
|
||||
|
||||
install: all
|
||||
cp -v AddressDeclarator.{json,bin} ../python/eth_address_declarator/data/
|
||||
cp -v TokenUniqueSymbolIndexAddressDeclarator.{json,bin} ../python/eth_address_declarator/data/
|
||||
cp -v AccountsIndexAddressDeclarator.{json,bin} ../python/eth_address_declarator/data/
|
||||
cp -v *.json ../python/eth_address_declarator/data/
|
||||
cp -v *.bin ../python/eth_address_declarator/data/
|
||||
|
||||
.PHONY: test install
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
||||
[{"inputs":[{"internalType":"address","name":"_addressDeclaratorAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"addedAccount","type":"address"},{"indexed":true,"internalType":"uint256","name":"accountIndex","type":"uint256"}],"name":"AddressAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"add","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"addressDeclaratorAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"}],"name":"addressOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_idx","type":"uint256"}],"name":"entry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"entryCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"register","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"registry","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","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"}]
|
||||
Reference in New Issue
Block a user