Correct token index identifier generation
This commit is contained in:
parent
8d67bcdfd2
commit
397c1310f7
@ -23,9 +23,8 @@ from chainlib.jsonrpc import JSONRPCRequest
|
||||
from chainlib.eth.constant import ZERO_ADDRESS
|
||||
from hexathon import (
|
||||
add_0x,
|
||||
strip_0x,
|
||||
)
|
||||
from cic_contracts.registry import to_identifier
|
||||
|
||||
# local imports
|
||||
from .interface import (
|
||||
#TokenUniqueSymbolIndex,
|
||||
@ -38,6 +37,13 @@ moddir = os.path.dirname(__file__)
|
||||
datadir = os.path.join(moddir, '..', 'data')
|
||||
|
||||
|
||||
def to_identifier(txt):
|
||||
identifier_bytes = txt.upper().encode('utf-8')
|
||||
h = hashlib.sha256()
|
||||
identifier_bytes = h.update(identifier_bytes)
|
||||
identifier = h.digest()
|
||||
return identifier.hex()
|
||||
|
||||
|
||||
#class TokenUniqueSymbolIndexAddressDeclarator(TokenUniqueSymbolIndex):
|
||||
class TokenUniqueSymbolIndexAddressDeclarator(CICTokenIndex):
|
||||
|
@ -1,6 +1,6 @@
|
||||
[metadata]
|
||||
name = okota
|
||||
version = 0.2.5
|
||||
version = 0.2.6
|
||||
description = Registries for CIC using the eth-address-index backend
|
||||
author = Louis Holbrook
|
||||
author_email = dev@holbrook.no
|
||||
|
@ -87,12 +87,17 @@ class TestTokenIndex(TestAddressDeclaratorBase):
|
||||
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)
|
||||
|
||||
h = hashlib.sha256()
|
||||
h.update('FOO'.encode('utf-8'))
|
||||
z = h.digest()
|
||||
|
||||
identifier = to_identifier('FOO')
|
||||
#h = hashlib.sha256()
|
||||
#h.update('FOO'.encode('utf-8'))
|
||||
#z = h.digest()
|
||||
|
||||
self.assertEqual(proofs[0], z.hex())
|
||||
#self.assertEqual(proofs[0], z.hex())
|
||||
self.assertEqual(proofs[0], identifier)
|
||||
|
||||
identifier = to_identifier('foo')
|
||||
self.assertEqual(proofs[0], identifier)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
Reference in New Issue
Block a user