mirror of
git://holbrook.no/eth-address-index
synced 2026-04-30 20:11:05 +02:00
Compare commits
7 Commits
lash/funga
...
rm
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af63615eeb
|
||
|
|
92e826d559
|
||
|
|
d5de82198c
|
||
|
|
3dd286285c
|
||
|
|
0053a1fc71
|
||
|
|
8dd4de4e50
|
||
|
|
c31e7fe86f
|
@@ -1,4 +1,10 @@
|
|||||||
- 0.1.2-pending
|
- 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
|
||||||
* Move to chainlib-eth
|
* Move to chainlib-eth
|
||||||
- 0.1.1-unreleased
|
- 0.1.1-unreleased
|
||||||
- 0.1.0-unreleased
|
- 0.1.0-unreleased
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -117,12 +117,15 @@ class Declarator(TxFactory):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def parse_declaration(self, v):
|
def parse_declaration(self, v):
|
||||||
cursor = 0
|
cursor = 0
|
||||||
|
r = []
|
||||||
|
try:
|
||||||
v = strip_0x(v)
|
v = strip_0x(v)
|
||||||
|
except ValueError:
|
||||||
|
return r
|
||||||
position = int.from_bytes(bytes.fromhex(v[cursor:cursor+64]), 'big')
|
position = int.from_bytes(bytes.fromhex(v[cursor:cursor+64]), 'big')
|
||||||
cursor += (position * 2)
|
cursor += (position * 2)
|
||||||
length = int.from_bytes(bytes.fromhex(v[cursor:cursor+64]), 'big')
|
length = int.from_bytes(bytes.fromhex(v[cursor:cursor+64]), 'big')
|
||||||
cursor += 64
|
cursor += 64
|
||||||
r = []
|
|
||||||
for i in range(length):
|
for i in range(length):
|
||||||
r.append(v[cursor:cursor+64])
|
r.append(v[cursor:cursor+64])
|
||||||
cursor += 64
|
cursor += 64
|
||||||
|
|||||||
@@ -32,14 +32,12 @@ logg = logging.getLogger()
|
|||||||
|
|
||||||
#argparser.add_argument('--resolve', action='store_true', help='Attempt to resolve the hashes to actual content')
|
#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')
|
#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
|
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)
|
argparser = chainlib.eth.cli.ArgumentParser(arg_flags, arg_long={'-a': '--declarator-address'})
|
||||||
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')
|
argparser.add_positional('address', type=str, help='Ethereum declaration address to look up')
|
||||||
args = argparser.parse_args()
|
args = argparser.parse_args()
|
||||||
|
|
||||||
extra_args = {
|
extra_args = {
|
||||||
'declarator_address': None,
|
|
||||||
'address': None,
|
'address': None,
|
||||||
}
|
}
|
||||||
config = chainlib.eth.cli.Config.from_args(args, arg_flags, extra_args=extra_args, default_fee_limit=AddressDeclarator.gas())
|
config = chainlib.eth.cli.Config.from_args(args, arg_flags, extra_args=extra_args, default_fee_limit=AddressDeclarator.gas())
|
||||||
@@ -52,6 +50,8 @@ conn = rpc.connect_by_config(config)
|
|||||||
|
|
||||||
chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC'))
|
chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC'))
|
||||||
|
|
||||||
|
declarator_address = config.get('_WALLET_ADDRESS')
|
||||||
|
|
||||||
|
|
||||||
def out_element(e, w=sys.stdout):
|
def out_element(e, w=sys.stdout):
|
||||||
w.write(e[1] + '\n')
|
w.write(e[1] + '\n')
|
||||||
|
|||||||
@@ -1,4 +1,2 @@
|
|||||||
confini>=0.3.6rc3,<0.5.0
|
confini~=0.6.0
|
||||||
crypto-dev-signer>=0.4.15rc2,<=0.4.15
|
chainlib-eth>=0.1.0b1,<0.2.0
|
||||||
chainlib-eth>=0.0.9a13,<=0.1.0
|
|
||||||
eth_erc20>=0.1.2a3,<=0.2.0
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
set -x
|
set -x
|
||||||
|
default_pythonpath=$PYTHONPATH:.
|
||||||
|
export PYTHONPATH=${default_pythonpath:-.}
|
||||||
for f in `ls tests/*.py`; do
|
for f in `ls tests/*.py`; do
|
||||||
python $f
|
python $f
|
||||||
if [ $? -gt 0 ]; then
|
if [ $? -gt 0 ]; then
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = eth-address-index
|
name = eth-address-index
|
||||||
version = 0.2.4a1
|
version = 0.5.0
|
||||||
description = Signed metadata declarations for ethereum addresses
|
description = Signed metadata declarations for ethereum addresses
|
||||||
author = Louis Holbrook
|
author = Louis Holbrook
|
||||||
author_email = dev@holbrook.no
|
author_email = dev@holbrook.no
|
||||||
@@ -28,11 +28,6 @@ packages =
|
|||||||
eth_address_declarator.runnable
|
eth_address_declarator.runnable
|
||||||
eth_address_declarator.unittest
|
eth_address_declarator.unittest
|
||||||
|
|
||||||
[options.extras_require]
|
|
||||||
testing =
|
|
||||||
eth-tester==0.5.0b2
|
|
||||||
py-evm==0.3.0a20
|
|
||||||
|
|
||||||
[options.package_data]
|
[options.package_data]
|
||||||
* =
|
* =
|
||||||
data/AddressDeclarator.json
|
data/AddressDeclarator.json
|
||||||
@@ -43,3 +38,4 @@ testing =
|
|||||||
console_scripts =
|
console_scripts =
|
||||||
eth-address-declarator-deploy = eth_address_declarator.runnable.deploy:main
|
eth-address-declarator-deploy = eth_address_declarator.runnable.deploy:main
|
||||||
eth-address-declarator-add = eth_address_declarator.runnable.add:main
|
eth-address-declarator-add = eth_address_declarator.runnable.add:main
|
||||||
|
eth-address-declarator-view = eth_address_declarator.runnable.view:main
|
||||||
|
|||||||
@@ -22,4 +22,7 @@ f.close()
|
|||||||
setup(
|
setup(
|
||||||
install_requires=requirements,
|
install_requires=requirements,
|
||||||
tests_require=test_requirements,
|
tests_require=test_requirements,
|
||||||
|
extras_require={
|
||||||
|
'dev': test_requirements,
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
eth-tester==0.5.0b3
|
eth-tester==0.5.0b3
|
||||||
py-evm==0.3.0a20
|
py-evm==0.3.0a20
|
||||||
eth-accounts-index>=0.1.2a3,<0.2.0
|
eth-accounts-index~=0.1.3
|
||||||
|
eth_erc20~=0.1.5
|
||||||
|
|||||||
@@ -183,5 +183,56 @@ class TestAddressDeclarator(TestAddressDeclaratorBase):
|
|||||||
self.assertEqual(c.parse_declaration_address_at(r), strip_0x(self.accounts[2]))
|
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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -20,20 +20,21 @@ contract AddressDeclarator {
|
|||||||
contents[contents.length-1].push(blockhash(block.number));
|
contents[contents.length-1].push(blockhash(block.number));
|
||||||
|
|
||||||
addDeclaration(msg.sender, _initialDescription);
|
addDeclaration(msg.sender, _initialDescription);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function toReference(address _declarator, address _subject) private pure returns ( bytes32 ) {
|
function toReference(address _declarator, address _subject) private pure returns ( bytes32 ) {
|
||||||
bytes32 k;
|
bytes32 k;
|
||||||
bytes memory signMaterial = new bytes(40);
|
bytes memory addrMaterial = new bytes(40);
|
||||||
bytes memory addrBytes = abi.encodePacked(_declarator);
|
bytes memory addrBytes = abi.encodePacked(_declarator);
|
||||||
for (uint256 i = 0; i < 20; i++) {
|
for (uint256 i = 0; i < 20; i++) {
|
||||||
signMaterial[i] = addrBytes[i];
|
addrMaterial[i] = addrBytes[i];
|
||||||
}
|
}
|
||||||
addrBytes = abi.encodePacked(_subject);
|
addrBytes = abi.encodePacked(_subject);
|
||||||
for (uint256 i = 0; i < 20; i++) {
|
for (uint256 i = 0; i < 20; i++) {
|
||||||
signMaterial[i+20] = addrBytes[i];
|
addrMaterial[i+20] = addrBytes[i];
|
||||||
}
|
}
|
||||||
k = sha256(signMaterial);
|
k = sha256(addrMaterial);
|
||||||
return k;
|
return k;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,9 +78,9 @@ contract AddressDeclarator {
|
|||||||
declarator[_subject].push(tx.origin);
|
declarator[_subject].push(tx.origin);
|
||||||
contents.push(declarationContents);
|
contents.push(declarationContents);
|
||||||
declarationIndex[tx.origin].push(_subject);
|
declarationIndex[tx.origin].push(_subject);
|
||||||
|
idx = contents.length-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
idx = contents.length-1;
|
|
||||||
declarationContentIndex[ks[0]] = idx;
|
declarationContentIndex[ks[0]] = idx;
|
||||||
contents[idx].push(_proof);
|
contents[idx].push(_proof);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user