diff --git a/python/okota/token_index/index.py b/python/okota/token_index/index.py index 187455b..38368f9 100644 --- a/python/okota/token_index/index.py +++ b/python/okota/token_index/index.py @@ -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): diff --git a/python/setup.cfg b/python/setup.cfg index d4d82b8..ca04ede 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -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 diff --git a/python/tests/test_tokenindex.py b/python/tests/test_tokenindex.py index 36a49ba..b067c73 100644 --- a/python/tests/test_tokenindex.py +++ b/python/tests/test_tokenindex.py @@ -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__':