mirror of
git://holbrook.no/eth-address-index
synced 2026-03-31 15:50:49 +02:00
Compare commits
1 Commits
tmp
...
lash/funga
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b5621c53df
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -4,5 +4,3 @@ dist/
|
||||
__pycache__
|
||||
*.pyc
|
||||
gmon.out
|
||||
.idea
|
||||
venv
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
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
BIN
python/.coverage
Binary file not shown.
@@ -1,7 +0,0 @@
|
||||
[run]
|
||||
branch = True
|
||||
[report]
|
||||
omit = .venv/*
|
||||
**/runnable/*.py
|
||||
[html]
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
- 0.4.0
|
||||
* Upgrade chainlib
|
||||
- 0.3.0
|
||||
* Use -a and -e flag combination for consistency
|
||||
- 0.2.5
|
||||
* Remove proof array idx overwrite when adding multiple proofs to subject
|
||||
- 0.1.2
|
||||
- 0.1.2-pending
|
||||
* Move to chainlib-eth
|
||||
- 0.1.1-unreleased
|
||||
- 0.1.0-unreleased
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -117,15 +117,12 @@ class Declarator(TxFactory):
|
||||
@classmethod
|
||||
def parse_declaration(self, v):
|
||||
cursor = 0
|
||||
r = []
|
||||
try:
|
||||
v = strip_0x(v)
|
||||
except ValueError:
|
||||
return r
|
||||
v = strip_0x(v)
|
||||
position = int.from_bytes(bytes.fromhex(v[cursor:cursor+64]), 'big')
|
||||
cursor += (position * 2)
|
||||
length = int.from_bytes(bytes.fromhex(v[cursor:cursor+64]), 'big')
|
||||
cursor += 64
|
||||
r = []
|
||||
for i in range(length):
|
||||
r.append(v[cursor:cursor+64])
|
||||
cursor += 64
|
||||
|
||||
@@ -32,12 +32,14 @@ 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'})
|
||||
arg_flags = chainlib.eth.cli.argflag_std_read | chainlib.eth.cli.Flag.EXEC
|
||||
argparser = chainlib.eth.cli.ArgumentParser(arg_flags)
|
||||
argparser.add_argument('--declarator-address', required=True, type=str, help='Declarator of address')
|
||||
argparser.add_positional('address', type=str, help='Ethereum declaration address to look up')
|
||||
args = argparser.parse_args()
|
||||
|
||||
extra_args = {
|
||||
'declarator_address': None,
|
||||
'address': None,
|
||||
}
|
||||
config = chainlib.eth.cli.Config.from_args(args, arg_flags, extra_args=extra_args, default_fee_limit=AddressDeclarator.gas())
|
||||
@@ -50,8 +52,6 @@ conn = rpc.connect_by_config(config)
|
||||
|
||||
chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC'))
|
||||
|
||||
declarator_address = config.get('_WALLET_ADDRESS')
|
||||
|
||||
|
||||
def out_element(e, w=sys.stdout):
|
||||
w.write(e[1] + '\n')
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
confini~=0.6.0
|
||||
chainlib-eth>=0.1.0b1,<0.2.0
|
||||
confini>=0.3.6rc3,<0.5.0
|
||||
chainlib-eth>=0.0.10a5,<=0.1.0
|
||||
eth_erc20>=0.1.2a3,<=0.2.0
|
||||
funga>=0.5.1a1,<0.6.0
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
set -e
|
||||
set -x
|
||||
default_pythonpath=$PYTHONPATH:.
|
||||
export PYTHONPATH=${default_pythonpath:-.}
|
||||
for f in `ls tests/*.py`; do
|
||||
python $f
|
||||
if [ $? -gt 0 ]; then
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[metadata]
|
||||
name = eth-address-index
|
||||
version = 0.5.0
|
||||
version = 0.2.5a1
|
||||
description = Signed metadata declarations for ethereum addresses
|
||||
author = Louis Holbrook
|
||||
author_email = dev@holbrook.no
|
||||
@@ -28,6 +28,11 @@ packages =
|
||||
eth_address_declarator.runnable
|
||||
eth_address_declarator.unittest
|
||||
|
||||
[options.extras_require]
|
||||
testing =
|
||||
eth-tester==0.5.0b2
|
||||
py-evm==0.3.0a20
|
||||
|
||||
[options.package_data]
|
||||
* =
|
||||
data/AddressDeclarator.json
|
||||
@@ -38,4 +43,3 @@ packages =
|
||||
console_scripts =
|
||||
eth-address-declarator-deploy = eth_address_declarator.runnable.deploy:main
|
||||
eth-address-declarator-add = eth_address_declarator.runnable.add:main
|
||||
eth-address-declarator-view = eth_address_declarator.runnable.view:main
|
||||
|
||||
@@ -22,7 +22,4 @@ f.close()
|
||||
setup(
|
||||
install_requires=requirements,
|
||||
tests_require=test_requirements,
|
||||
extras_require={
|
||||
'dev': test_requirements,
|
||||
},
|
||||
)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
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.1.2a3,<0.2.0
|
||||
|
||||
@@ -183,56 +183,5 @@ class TestAddressDeclarator(TestAddressDeclaratorBase):
|
||||
self.assertEqual(c.parse_declaration_address_at(r), strip_0x(self.accounts[2]))
|
||||
|
||||
|
||||
def test_three_first(self):
|
||||
d = []
|
||||
for i in range(3):
|
||||
d.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 d:
|
||||
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[0], self.foo_token_address, proof)
|
||||
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, 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(d[i]))
|
||||
|
||||
|
||||
def test_three_first_different(self):
|
||||
d = []
|
||||
a = []
|
||||
for i in range(3):
|
||||
d.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], d[i])
|
||||
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], 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(d[i]))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -20,21 +20,20 @@ contract AddressDeclarator {
|
||||
contents[contents.length-1].push(blockhash(block.number));
|
||||
|
||||
addDeclaration(msg.sender, _initialDescription);
|
||||
|
||||
}
|
||||
|
||||
function toReference(address _declarator, address _subject) private pure returns ( bytes32 ) {
|
||||
bytes32 k;
|
||||
bytes memory addrMaterial = new bytes(40);
|
||||
bytes memory signMaterial = new bytes(40);
|
||||
bytes memory addrBytes = abi.encodePacked(_declarator);
|
||||
for (uint256 i = 0; i < 20; i++) {
|
||||
addrMaterial[i] = addrBytes[i];
|
||||
signMaterial[i] = addrBytes[i];
|
||||
}
|
||||
addrBytes = abi.encodePacked(_subject);
|
||||
for (uint256 i = 0; i < 20; i++) {
|
||||
addrMaterial[i+20] = addrBytes[i];
|
||||
signMaterial[i+20] = addrBytes[i];
|
||||
}
|
||||
k = sha256(addrMaterial);
|
||||
k = sha256(signMaterial);
|
||||
return k;
|
||||
}
|
||||
|
||||
@@ -78,9 +77,9 @@ contract AddressDeclarator {
|
||||
declarator[_subject].push(tx.origin);
|
||||
contents.push(declarationContents);
|
||||
declarationIndex[tx.origin].push(_subject);
|
||||
idx = contents.length-1;
|
||||
}
|
||||
|
||||
idx = contents.length-1;
|
||||
declarationContentIndex[ks[0]] = idx;
|
||||
contents[idx].push(_proof);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user