eth-token-index

Token symbol to address unique index
Log | Files | Refs

commit d15ad541dc449957b0415d81af7640033e34ecde
parent c94b344264262dddb9ee2edce247b3d53164f619
Author: lash <dev@holbrook.no>
Date:   Sat, 25 Mar 2023 18:00:10 +0000

Add registry tests

Diffstat:
Mpython/eth_token_index/data/TokenUniqueSymbolIndex.bin | 4++--
Mpython/eth_token_index/data/TokenUniqueSymbolIndex.json | 2+-
Mpython/eth_token_index/data/TokenUniqueSymbolIndex.metadata.json | 2+-
Mpython/eth_token_index/index.py | 22+++++++++++++++++++++-
Mpython/test_requirements.txt | 1+
Mpython/tests/test_tokenindex.py | 162+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
Msolidity/TokenUniqueSymbolIndex.sol | 22+++++++++++++++-------
7 files changed, 191 insertions(+), 24 deletions(-)

diff --git a/python/eth_token_index/data/TokenUniqueSymbolIndex.bin b/python/eth_token_index/data/TokenUniqueSymbolIndex.bin @@ -1 +1 @@ -608060405234801561001057600080fd5b5033600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600360009080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611864806100c56000396000f3fe608060405234801561001057600080fd5b5060043610610112576000357c0100000000000000000000000000000000000000000000000000000000900480633ea053eb116100b4578063bb34534c11610083578063bb34534c146102f1578063da2824a814610321578063e2095c0714610351578063f2fde38b1461038157610112565b80633ea053eb146102435780634420e486146102735780635ae06f7e146102a35780638da5cb5b146102d357610112565b80631c5a9d9c116100f05780631c5a9d9c1461019557806328f2d4da146101c557806329092d0e146101f55780633480c7041461022557610112565b806301ffc9a7146101175780630a3b0a4f146101475780630cbb0f8314610177575b600080fd5b610131600480360381019061012c919061110e565b6103b1565b60405161013e9190611156565b60405180910390f35b610161600480360381019061015c91906111cf565b6105a9565b60405161016e9190611156565b60405180910390f35b61017f6105bb565b60405161018c9190611215565b60405180910390f35b6101af60048036038101906101aa91906111cf565b6105d4565b6040516101bc9190611156565b60405180910390f35b6101df60048036038101906101da919061125c565b6105db565b6040516101ec91906112a2565b60405180910390f35b61020f600480360381019061020a91906111cf565b6105ff565b60405161021c9190611156565b60405180910390f35b61022d610943565b60405161023a9190611215565b60405180910390f35b61025d600480360381019061025891906111cf565b610950565b60405161026a9190611156565b60405180910390f35b61028d600480360381019061028891906111cf565b610957565b60405161029a9190611156565b60405180910390f35b6102bd60048036038101906102b891906111cf565b610ca2565b6040516102ca9190611156565b60405180910390f35b6102db610d8c565b6040516102e891906112cc565b60405180910390f35b61030b60048036038101906103069190611313565b610db2565b60405161031891906112cc565b60405180910390f35b61033b600480360381019061033691906111cf565b610e12565b6040516103489190611156565b60405180910390f35b61036b6004803603810190610366919061125c565b610f05565b60405161037891906112cc565b60405180910390f35b61039b600480360381019061039691906111cf565b610f59565b6040516103a89190611156565b60405180910390f35b60006312625fe57c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361040557600190506105a4565b63b7bca6257c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361045757600190506105a4565b639479f0ae7c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036104a957600190506105a4565b6301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036104fb57600190506105a4565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361054d57600190506105a4565b6380c84bd67c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361059f57600190506105a4565b600090505b919050565b60006105b482610957565b9050919050565b600060016003805490506105cf919061136f565b905090565b6000919050565b600581815481106105eb57600080fd5b906000526020600020016000915090505481565b60008060008060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661068f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161068690611400565b60405180910390fd5b6000600102600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205403610714576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161070b9061146c565b60405180910390fd5b6001600380549050610726919061136f565b905060016000600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205481526020019081526020016000205491508082101561086257600381815481106107995761079861148c565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600383815481106107d8576107d761148c565b5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600581815481106108345761083361148c565b5b9060005260206000200154600583815481106108535761085261148c565b5b90600052602060002001819055505b6003805480610874576108736114bb565b5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690559055600060016000600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548152602001908152602001600020819055507f24a12366c02e13fe4a9e03d86a8952e85bb74a456c16e4a18b6d8295700b74bb8460405161093091906112cc565b60405180910390a1600192505050919050565b6000600580549050905090565b6000919050565b60008060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166109ae57600080fd5b60606000806000808673ffffffffffffffffffffffffffffffffffffffff166040516024016040516020818303038152906040527f95d89b41000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610a5d919061155b565b6000604051808303816000865af19150503d8060008114610a9a576040519150601f19603f3d011682016040523d82523d6000602084013e610a9f565b606091505b509150915081610aae57600080fd5b80806020019051810190610ac291906116a9565b9450602085511115610b09576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b009061173e565b60405180910390fd5b84610b1390611793565b93506001600085815260200190815260200160002054925060008314610b3857600080fd5b60038054905060016000868152602001908152602001600020819055506003879080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600584908060018154018082558091505060019003906000526020600020016000909190919091505583600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550837f3465c39c7e9b14641553cf015fbfe670207bd64c689d17806d885bda47899feb88604051610c5591906112cc565b60405180910390a27fa226db3f664042183ee0281230bba26cbf7b5057e50aee7f25a175ff45ce4d7f87604051610c8c91906112cc565b60405180910390a1600195505050505050919050565b60003373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610cfe57600080fd5b6000808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff02191690557f9002f14780245e47491e7a2caae4712e7cea2e298e4e76c6916845145b90a51c82604051610d7b91906112cc565b60405180910390a160019050919050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000806001600084815260200190815260200160002054905060038181548110610ddf57610dde61148c565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16915050919050565b60003373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610e6e57600080fd5b60016000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f6ff3aa2ea7b53070f6d9d07a445d338d89e8edef44250ffa8be19f53910d4a2e82604051610ef491906112cc565b60405180910390a160019050919050565b60006003600183610f1691906117fa565b81548110610f2757610f2661148c565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600080600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610fb657600080fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905082600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36001915050919050565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6110eb816110b6565b81146110f657600080fd5b50565b600081359050611108816110e2565b92915050565b600060208284031215611124576111236110ac565b5b6000611132848285016110f9565b91505092915050565b60008115159050919050565b6111508161113b565b82525050565b600060208201905061116b6000830184611147565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061119c82611171565b9050919050565b6111ac81611191565b81146111b757600080fd5b50565b6000813590506111c9816111a3565b92915050565b6000602082840312156111e5576111e46110ac565b5b60006111f3848285016111ba565b91505092915050565b6000819050919050565b61120f816111fc565b82525050565b600060208201905061122a6000830184611206565b92915050565b611239816111fc565b811461124457600080fd5b50565b60008135905061125681611230565b92915050565b600060208284031215611272576112716110ac565b5b600061128084828501611247565b91505092915050565b6000819050919050565b61129c81611289565b82525050565b60006020820190506112b76000830184611293565b92915050565b6112c681611191565b82525050565b60006020820190506112e160008301846112bd565b92915050565b6112f081611289565b81146112fb57600080fd5b50565b60008135905061130d816112e7565b92915050565b600060208284031215611329576113286110ac565b5b6000611337848285016112fe565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061137a826111fc565b9150611385836111fc565b925082820390508181111561139d5761139c611340565b5b92915050565b600082825260208201905092915050565b7f4552525f41585800000000000000000000000000000000000000000000000000600082015250565b60006113ea6007836113a3565b91506113f5826113b4565b602082019050919050565b60006020820190508181036000830152611419816113dd565b9050919050565b7f4552525f4e4f545f464f554e4400000000000000000000000000000000000000600082015250565b6000611456600d836113a3565b915061146182611420565b602082019050919050565b6000602082019050818103600083015261148581611449565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b600081519050919050565b600081905092915050565b60005b8381101561151e578082015181840152602081019050611503565b60008484015250505050565b6000611535826114ea565b61153f81856114f5565b935061154f818560208601611500565b80840191505092915050565b6000611567828461152a565b915081905092915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6115c58261157c565b810181811067ffffffffffffffff821117156115e4576115e361158d565b5b80604052505050565b60006115f76110a2565b905061160382826115bc565b919050565b600067ffffffffffffffff8211156116235761162261158d565b5b61162c8261157c565b9050602081019050919050565b600061164c61164784611608565b6115ed565b90508281526020810184848401111561166857611667611577565b5b611673848285611500565b509392505050565b600082601f8301126116905761168f611572565b5b81516116a0848260208601611639565b91505092915050565b6000602082840312156116bf576116be6110ac565b5b600082015167ffffffffffffffff8111156116dd576116dc6110b1565b5b6116e98482850161167b565b91505092915050565b7f4552525f544f4b454e5f53594d424f4c5f544f4f5f4c4f4e4700000000000000600082015250565b60006117286019836113a3565b9150611733826116f2565b602082019050919050565b600060208201905081810360008301526117578161171b565b9050919050565b6000819050602082019050919050565b600061177a8251611289565b80915050919050565b60008160020a8302905092915050565b600061179e826114ea565b826117a88461175e565b90506117b38161176e565b925060208210156117f3576117ee7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83602003600802611783565b831692505b5050919050565b6000611805826111fc565b9150611810836111fc565b925082820190508082111561182857611827611340565b5b9291505056fea264697066735822122044b20aedb83f940e8885b9693e4ee4776635417706ff96023627700fd69c01fb64736f6c63430008120033 -\ No newline at end of file +608060405234801561001057600080fd5b5033600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600360009080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506005600060010290806001815401808255809150506001900390600052602060002001600090919091909150556119f4806100f26000396000f3fe608060405234801561001057600080fd5b506004361061011d576000357c0100000000000000000000000000000000000000000000000000000000900480634420e486116100b4578063d56b7d4e11610083578063d56b7d4e1461032c578063da2824a81461035c578063e2095c071461038c578063f2fde38b146103bc5761011d565b80634420e4861461027e5780635ae06f7e146102ae5780638da5cb5b146102de578063bb34534c146102fc5761011d565b80631c5a9d9c116100f05780631c5a9d9c146101d057806329092d0e146102005780633480c704146102305780633ea053eb1461024e5761011d565b806301ffc9a7146101225780630a3b0a4f146101525780630cbb0f8314610182578063110c57b3146101a0575b600080fd5b61013c6004803603810190610137919061129e565b6103ec565b60405161014991906112e6565b60405180910390f35b61016c6004803603810190610167919061135f565b6105e4565b60405161017991906112e6565b60405180910390f35b61018a6105f6565b60405161019791906113a5565b60405180910390f35b6101ba60048036038101906101b591906113ec565b61060f565b6040516101c79190611432565b60405180910390f35b6101ea60048036038101906101e5919061135f565b610633565b6040516101f791906112e6565b60405180910390f35b61021a6004803603810190610215919061135f565b61063a565b60405161022791906112e6565b60405180910390f35b610238610a93565b60405161024591906113a5565b60405180910390f35b6102686004803603810190610263919061135f565b610aac565b60405161027591906112e6565b60405180910390f35b6102986004803603810190610293919061135f565b610ab3565b6040516102a591906112e6565b60405180910390f35b6102c860048036038101906102c3919061135f565b610dfe565b6040516102d591906112e6565b60405180910390f35b6102e6610ee8565b6040516102f3919061145c565b60405180910390f35b610316600480360381019061031191906114a3565b610f0e565b604051610323919061145c565b60405180910390f35b610346600480360381019061034191906113ec565b610f6e565b6040516103539190611432565b60405180910390f35b6103766004803603810190610371919061135f565b610fa2565b60405161038391906112e6565b60405180910390f35b6103a660048036038101906103a191906113ec565b611095565b6040516103b3919061145c565b60405180910390f35b6103d660048036038101906103d1919061135f565b6110e9565b6040516103e391906112e6565b60405180910390f35b600063effbf6717c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361044057600190506105df565b63b7bca6257c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361049257600190506105df565b639479f0ae7c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036104e457600190506105df565b6301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361053657600190506105df565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361058857600190506105df565b6380c84bd67c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036105da57600190506105df565b600090505b919050565b60006105ef82610ab3565b9050919050565b6000600160038054905061060a91906114ff565b905090565b6005818154811061061f57600080fd5b906000526020600020016000915090505481565b6000919050565b60008060008060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16806106e35750600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610722576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161071990611590565b60405180910390fd5b6000600102600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054036107a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161079e906115fc565b60405180910390fd5b60016003805490506107b991906114ff565b905060016000600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548152602001908152602001600020549150808210156108f5576003818154811061082c5761082b61161c565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166003838154811061086b5761086a61161c565b5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600581815481106108c7576108c661161c565b5b9060005260206000200154600583815481106108e6576108e561161c565b5b90600052602060002001819055505b816001600060026000600387815481106109125761091161161c565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054815260200190815260200160002081905550600380548061099c5761099b61164b565b5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055905560058054806109e3576109e261164b565b5b60019003818190600052602060002001600090559055600060016000600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548152602001908152602001600020819055507f24a12366c02e13fe4a9e03d86a8952e85bb74a456c16e4a18b6d8295700b74bb84604051610a80919061145c565b60405180910390a1600192505050919050565b60006001600580549050610aa791906114ff565b905090565b6000919050565b60008060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610b0a57600080fd5b60606000806000808673ffffffffffffffffffffffffffffffffffffffff166040516024016040516020818303038152906040527f95d89b41000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610bb991906116eb565b6000604051808303816000865af19150503d8060008114610bf6576040519150601f19603f3d011682016040523d82523d6000602084013e610bfb565b606091505b509150915081610c0a57600080fd5b80806020019051810190610c1e9190611839565b9450602085511115610c65576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c5c906118ce565b60405180910390fd5b84610c6f90611923565b93506001600085815260200190815260200160002054925060008314610c9457600080fd5b60038054905060016000868152602001908152602001600020819055506003879080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600584908060018154018082558091505060019003906000526020600020016000909190919091505583600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550837f3465c39c7e9b14641553cf015fbfe670207bd64c689d17806d885bda47899feb88604051610db1919061145c565b60405180910390a27fa226db3f664042183ee0281230bba26cbf7b5057e50aee7f25a175ff45ce4d7f87604051610de8919061145c565b60405180910390a1600195505050505050919050565b60003373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610e5a57600080fd5b6000808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff02191690557f9002f14780245e47491e7a2caae4712e7cea2e298e4e76c6916845145b90a51c82604051610ed7919061145c565b60405180910390a160019050919050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000806001600084815260200190815260200160002054905060038181548110610f3b57610f3a61161c565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16915050919050565b60006005600183610f7f919061198a565b81548110610f9057610f8f61161c565b5b90600052602060002001549050919050565b60003373ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610ffe57600080fd5b60016000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f6ff3aa2ea7b53070f6d9d07a445d338d89e8edef44250ffa8be19f53910d4a2e82604051611084919061145c565b60405180910390a160019050919050565b600060036001836110a6919061198a565b815481106110b7576110b661161c565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600080600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461114657600080fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905082600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36001915050919050565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b61127b81611246565b811461128657600080fd5b50565b60008135905061129881611272565b92915050565b6000602082840312156112b4576112b361123c565b5b60006112c284828501611289565b91505092915050565b60008115159050919050565b6112e0816112cb565b82525050565b60006020820190506112fb60008301846112d7565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061132c82611301565b9050919050565b61133c81611321565b811461134757600080fd5b50565b60008135905061135981611333565b92915050565b6000602082840312156113755761137461123c565b5b60006113838482850161134a565b91505092915050565b6000819050919050565b61139f8161138c565b82525050565b60006020820190506113ba6000830184611396565b92915050565b6113c98161138c565b81146113d457600080fd5b50565b6000813590506113e6816113c0565b92915050565b6000602082840312156114025761140161123c565b5b6000611410848285016113d7565b91505092915050565b6000819050919050565b61142c81611419565b82525050565b60006020820190506114476000830184611423565b92915050565b61145681611321565b82525050565b6000602082019050611471600083018461144d565b92915050565b61148081611419565b811461148b57600080fd5b50565b60008135905061149d81611477565b92915050565b6000602082840312156114b9576114b861123c565b5b60006114c78482850161148e565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061150a8261138c565b91506115158361138c565b925082820390508181111561152d5761152c6114d0565b5b92915050565b600082825260208201905092915050565b7f4552525f41585800000000000000000000000000000000000000000000000000600082015250565b600061157a600783611533565b915061158582611544565b602082019050919050565b600060208201905081810360008301526115a98161156d565b9050919050565b7f4552525f4e4f545f464f554e4400000000000000000000000000000000000000600082015250565b60006115e6600d83611533565b91506115f1826115b0565b602082019050919050565b60006020820190508181036000830152611615816115d9565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b600081519050919050565b600081905092915050565b60005b838110156116ae578082015181840152602081019050611693565b60008484015250505050565b60006116c58261167a565b6116cf8185611685565b93506116df818560208601611690565b80840191505092915050565b60006116f782846116ba565b915081905092915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6117558261170c565b810181811067ffffffffffffffff821117156117745761177361171d565b5b80604052505050565b6000611787611232565b9050611793828261174c565b919050565b600067ffffffffffffffff8211156117b3576117b261171d565b5b6117bc8261170c565b9050602081019050919050565b60006117dc6117d784611798565b61177d565b9050828152602081018484840111156117f8576117f7611707565b5b611803848285611690565b509392505050565b600082601f8301126118205761181f611702565b5b81516118308482602086016117c9565b91505092915050565b60006020828403121561184f5761184e61123c565b5b600082015167ffffffffffffffff81111561186d5761186c611241565b5b6118798482850161180b565b91505092915050565b7f4552525f544f4b454e5f53594d424f4c5f544f4f5f4c4f4e4700000000000000600082015250565b60006118b8601983611533565b91506118c382611882565b602082019050919050565b600060208201905081810360008301526118e7816118ab565b9050919050565b6000819050602082019050919050565b600061190a8251611419565b80915050919050565b60008160020a8302905092915050565b600061192e8261167a565b82611938846118ee565b9050611943816118fe565b925060208210156119835761197e7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83602003600802611913565b831692505b5050919050565b60006119958261138c565b91506119a08361138c565b92508282019050808211156119b8576119b76114d0565b5b9291505056fea2646970667358221220d02eaf4aafec599cc9dbd2e68d89e98e71a3ca83ecf62049f1d35453a670622a64736f6c63430008120033 +\ No newline at end of file diff --git a/python/eth_token_index/data/TokenUniqueSymbolIndex.json b/python/eth_token_index/data/TokenUniqueSymbolIndex.json @@ -1 +1 @@ -[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_token","type":"address"}],"name":"AddressAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"_symbol","type":"bytes32"},{"indexed":false,"internalType":"address","name":"_token","type":"address"}],"name":"AddressKey","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_token","type":"address"}],"name":"AddressRemoved","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"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_writer","type":"address"}],"name":"WriterAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_writer","type":"address"}],"name":"WriterDeleted","type":"event"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"activate","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"add","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_writer","type":"address"}],"name":"addWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"}],"name":"addressOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"deactivate","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_writer","type":"address"}],"name":"deleteWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","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":"identifierCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"identifiers","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"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":"address","name":"_token","type":"address"}],"name":"remove","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","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"}] +[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_token","type":"address"}],"name":"AddressAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"_symbol","type":"bytes32"},{"indexed":false,"internalType":"address","name":"_token","type":"address"}],"name":"AddressKey","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_token","type":"address"}],"name":"AddressRemoved","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"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_writer","type":"address"}],"name":"WriterAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_writer","type":"address"}],"name":"WriterDeleted","type":"event"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"activate","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"add","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_writer","type":"address"}],"name":"addWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"}],"name":"addressOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"deactivate","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_writer","type":"address"}],"name":"deleteWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","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":[{"internalType":"uint256","name":"_idx","type":"uint256"}],"name":"identifier","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"identifierCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"identifierList","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"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":"address","name":"_token","type":"address"}],"name":"remove","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","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"}] diff --git a/python/eth_token_index/data/TokenUniqueSymbolIndex.metadata.json b/python/eth_token_index/data/TokenUniqueSymbolIndex.metadata.json @@ -1 +1 @@ -{"compiler":{"version":"0.8.18+commit.87f61d96"},"language":"Solidity","output":{"abi":[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_token","type":"address"}],"name":"AddressAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"_symbol","type":"bytes32"},{"indexed":false,"internalType":"address","name":"_token","type":"address"}],"name":"AddressKey","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_token","type":"address"}],"name":"AddressRemoved","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"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_writer","type":"address"}],"name":"WriterAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_writer","type":"address"}],"name":"WriterDeleted","type":"event"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"activate","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"add","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_writer","type":"address"}],"name":"addWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"}],"name":"addressOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"deactivate","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_writer","type":"address"}],"name":"deleteWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","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":"identifierCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"identifiers","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"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":"address","name":"_token","type":"address"}],"name":"remove","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","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"}],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"compilationTarget":{"TokenUniqueSymbolIndex.sol":"TokenUniqueSymbolIndex"},"evmVersion":"byzantium","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":false,"runs":200},"remappings":[]},"sources":{"TokenUniqueSymbolIndex.sol":{"keccak256":"0x7ab6b392718181f82a79bb425715f39e77d191678a2b544cb3e72f0385a384fe","license":"AGPL-3.0-or-later","urls":["bzz-raw://3bcff1c12c6b3dbf96e43e7413958ef6336de0afb7dfd20b1d003c742b05ea5b","dweb:/ipfs/QmNwTu4Fjji8ewpNsMtivGEiwgdzvWEhdFYrWePQ7KPENG"]}},"version":1} +{"compiler":{"version":"0.8.18+commit.87f61d96"},"language":"Solidity","output":{"abi":[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_token","type":"address"}],"name":"AddressAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"_symbol","type":"bytes32"},{"indexed":false,"internalType":"address","name":"_token","type":"address"}],"name":"AddressKey","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_token","type":"address"}],"name":"AddressRemoved","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"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_writer","type":"address"}],"name":"WriterAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_writer","type":"address"}],"name":"WriterDeleted","type":"event"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"activate","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"add","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_writer","type":"address"}],"name":"addWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"}],"name":"addressOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"deactivate","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_writer","type":"address"}],"name":"deleteWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","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":[{"internalType":"uint256","name":"_idx","type":"uint256"}],"name":"identifier","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"identifierCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"identifierList","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"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":"address","name":"_token","type":"address"}],"name":"remove","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","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"}],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"compilationTarget":{"TokenUniqueSymbolIndex.sol":"TokenUniqueSymbolIndex"},"evmVersion":"byzantium","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":false,"runs":200},"remappings":[]},"sources":{"TokenUniqueSymbolIndex.sol":{"keccak256":"0x472d243e57b740cc7d8cec688bbd7fa76f979f6d857965cda1728d710595cc5e","license":"AGPL-3.0-or-later","urls":["bzz-raw://76a5eacbf65373e2275f1a9a1ec7120d98db592b395ad0503d62e0d18bf23905","dweb:/ipfs/QmNs8Bk5SuFUVG571QyoWQYk2B9ouGhqGU4vMNkQW9dM9j"]}},"version":1} diff --git a/python/eth_token_index/index.py b/python/eth_token_index/index.py @@ -33,7 +33,7 @@ datadir = os.path.join(moddir, 'data') def to_identifier(s): r = s.encode('utf-8').hex() - assert len(r) < 64 + assert len(r) <= 64 return '{:0<64}'.format(r) @@ -144,6 +144,26 @@ class TokenUniqueSymbolIndex(TxFactory): return o + def identifier(self, contract_address, idx, sender_address=ZERO_ADDRESS, id_generator=None): + j = JSONRPCRequest(id_generator) + o = j.template() + o['method'] = 'eth_call' + enc = ABIContractEncoder() + enc.method('identifier') + enc.typ(ABIContractType.UINT256) + enc.uint256(idx) + data = add_0x(enc.encode()) + tx = self.template(sender_address, contract_address) + tx = self.set_code(tx, data) + o['params'].append(self.normalize(tx)) + o = j.finalize(o) + return o + + + def identifier_count(self, contract_address, sender_address=ZERO_ADDRESS, id_generator=None): + return self.call_noarg('identifierCount', contract_address, sender_address=sender_address, id_generator=id_generator) + + @classmethod def parse_address_of(self, v): return abi_decode_single(ABIContractType.ADDRESS, v) diff --git a/python/test_requirements.txt b/python/test_requirements.txt @@ -1,3 +1,4 @@ eth-tester==0.5.0b3 py-evm==0.3.0a20 eth-address-index~=0.6.0 +eth-accounts-index~=0.5.1 diff --git a/python/tests/test_tokenindex.py b/python/tests/test_tokenindex.py @@ -9,10 +9,14 @@ import hashlib from chainlib.eth.unittest.ethtester import EthTesterCase from chainlib.eth.nonce import RPCNonceOracle from chainlib.eth.tx import receipt +from chainlib.error import JSONRPCException from giftable_erc20_token import GiftableToken from chainlib.eth.tx import unpack from hexathon import strip_0x +from hexathon import same as same_hex from chainlib.eth.contract import ABIContractEncoder +from chainlib.eth.unittest.ethtester import EthTesterCase +from eth_accounts_index import AccountsIndex # local imports from eth_token_index.index import ( @@ -20,17 +24,13 @@ from eth_token_index.index import ( to_identifier, ) -# test imports -from eth_address_declarator.declarator import Declarator -from eth_address_declarator.unittest import TestAddressDeclaratorBase - logging.basicConfig(level=logging.DEBUG) logg = logging.getLogger() testdir = os.path.dirname(__file__) -class TestTokenUniqueSymbolIndex(TestAddressDeclaratorBase): +class TestTokenUniqueSymbolIndex(EthTesterCase): def setUp(self): super(TestTokenUniqueSymbolIndex, self).setUp() @@ -43,21 +43,32 @@ class TestTokenUniqueSymbolIndex(TestAddressDeclaratorBase): r = self.rpc.do(o) self.assertEqual(r['status'], 1) - self.token_index_address = r['contract_address'] + self.address = r['contract_address'] - (tx_hash_hex, o) = c.add_writer(self.token_index_address, self.accounts[0], self.accounts[0]) + (tx_hash_hex, o) = c.add_writer(self.address, self.accounts[0], self.accounts[0]) self.rpc.do(o) o = receipt(tx_hash_hex) r = self.rpc.do(o) self.assertEqual(r['status'], 1) + c = GiftableToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash_hex, o) = c.constructor(self.accounts[0], 'FooToken', 'FOO', 6) + self.rpc.do(o) + + o = receipt(tx_hash_hex) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + + self.foo_token_address = r['contract_address'] + logg.debug('foo token published with address {}'.format(self.foo_token_address)) + def test_register(self): nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) c = TokenUniqueSymbolIndex(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) - (tx_hash_hex, o) = c.register(self.token_index_address, self.accounts[0], self.foo_token_address) + (tx_hash_hex, o) = c.register(self.address, self.accounts[0], self.foo_token_address) self.rpc.do(o) e = unpack(bytes.fromhex(strip_0x(o['params'][0])), self.chain_spec) @@ -65,21 +76,148 @@ class TestTokenUniqueSymbolIndex(TestAddressDeclaratorBase): r = self.rpc.do(o) self.assertEqual(r['status'], 1) - o = c.address_of(self.token_index_address, 'FOO', sender_address=self.accounts[0]) + o = c.address_of(self.address, 'FOO', sender_address=self.accounts[0]) r = self.rpc.do(o) address = c.parse_address_of(r) self.assertEqual(address, strip_0x(self.foo_token_address)) - o = c.entry(self.token_index_address, 0, sender_address=self.accounts[0]) + o = c.entry(self.address, 0, sender_address=self.accounts[0]) r = self.rpc.do(o) address = c.parse_entry(r) self.assertEqual(address, strip_0x(self.foo_token_address)) - o = c.entry_count(self.token_index_address, sender_address=self.accounts[0]) + o = c.entry_count(self.address, sender_address=self.accounts[0]) r = self.rpc.do(o) count = c.parse_entry_count(r) self.assertEqual(count, 1) - + + + + def test_identifiers(self): + nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) + c = TokenUniqueSymbolIndex(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash_hex, o) = c.register(self.address, self.accounts[0], self.foo_token_address) + self.rpc.do(o) + + tokens = [ + self.foo_token_address, + ] + nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) + token_names = [ + 'BAR', + 'BAZ', + 'XYZZY', + ] + for token_name in token_names: + c = GiftableToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash_hex, o) = c.constructor(self.accounts[0], '{} Token'.format(token_name), token_name, 6) + self.rpc.do(o) + o = receipt(tx_hash_hex) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + + token_address = r['contract_address'] + + c = TokenUniqueSymbolIndex(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash_hex, o) = c.register(self.address, self.accounts[0], token_address) + self.rpc.do(o) + o = receipt(tx_hash_hex) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + + tokens.append(token_address) + + token_names = ['FOO'] + token_names + + i = 0 + for token_name in token_names: + o = c.address_of(self.address, token_name, sender_address=self.accounts[0]) + r = self.rpc.do(o) + r = strip_0x(r) + logg.debug('tokenn {} {} {}'.format(token_name, r, tokens[i])) + self.assertTrue(same_hex(r[24:], tokens[i])) + i += 1 + + o = c.identifier_count(self.address, sender_address=self.accounts[0]) + r = self.rpc.do(o) + self.assertEqual(int(r, 16), 4) + + c = AccountsIndex(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash_hex, o) = c.remove(self.address, self.accounts[0], tokens[1]) + self.rpc.do(o) + o = receipt(tx_hash_hex) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + + c = TokenUniqueSymbolIndex(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + o = c.identifier(self.address, 4, sender_address=self.accounts[0]) + with self.assertRaises(Exception): + self.rpc.do(o) + + o = c.identifier(self.address, 0, sender_address=self.accounts[0]) + r = self.rpc.do(o) + self.assertEqual(strip_0x(r)[:6], b'FOO'.hex()) + + o = c.identifier_count(self.address, sender_address=self.accounts[0]) + r = self.rpc.do(o) + self.assertEqual(int(r, 16), 3) + + next_token_test = tokens[2] + token_names = [ + 'FOO', + 'XYZZY', + 'BAZ', + ] + tokens = [ + tokens[0], + tokens[3], + tokens[2], + ] + i = 0 + for token_name in token_names: + o = c.address_of(self.address, token_name, sender_address=self.accounts[0]) + r = self.rpc.do(o) + r = strip_0x(r) + logg.debug('tokenn {} {} {}'.format(token_name, r, tokens[i])) + self.assertTrue(same_hex(r[24:], tokens[i])) + i += 1 + + c = AccountsIndex(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash_hex, o) = c.remove(self.address, self.accounts[0], next_token_test) + self.rpc.do(o) + o = receipt(tx_hash_hex) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + + c = TokenUniqueSymbolIndex(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + o = c.identifier(self.address, 1, sender_address=self.accounts[0]) + r = self.rpc.do(o) + self.assertEqual(strip_0x(r)[:10], b'XYZZY'.hex()) + + token_names = [ + 'FOO', + 'XYZZY', + ] + tokens = [ + tokens[0], + tokens[1], + ] + i = 0 + for token_name in token_names: + o = c.address_of(self.address, token_name, sender_address=self.accounts[0]) + r = self.rpc.do(o) + r = strip_0x(r) + logg.debug('tokenn {} {} {}'.format(token_name, r, tokens[i])) + self.assertTrue(same_hex(r[24:], tokens[i])) + i += 1 + + o = c.identifier_count(self.address, sender_address=self.accounts[0]) + r = self.rpc.do(o) + self.assertEqual(int(r, 16), 2) + + + + if __name__ == '__main__': unittest.main() diff --git a/solidity/TokenUniqueSymbolIndex.sol b/solidity/TokenUniqueSymbolIndex.sol @@ -12,7 +12,7 @@ contract TokenUniqueSymbolIndex { address public owner; // Implements Registry - bytes32[] public identifiers; + bytes32[] public identifierList; // Implements EIP173 event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); @@ -35,6 +35,7 @@ contract TokenUniqueSymbolIndex { constructor() { owner = msg.sender; tokens.push(address(0)); + identifierList.push(bytes32(0)); } // Implements AccountsIndex @@ -71,7 +72,7 @@ contract TokenUniqueSymbolIndex { registry[token_symbol_key] = tokens.length; tokens.push(_token); - identifiers.push(token_symbol_key); + identifierList.push(token_symbol_key); tokenIndex[_token] = token_symbol_key; emit AddressKey(token_symbol_key, _token); @@ -89,18 +90,20 @@ contract TokenUniqueSymbolIndex { uint256 i; uint256 l; - require(isWriter[msg.sender], 'ERR_AXX'); + require(isWriter[msg.sender] || msg.sender == owner, 'ERR_AXX'); require(tokenIndex[_token] != bytes32(0), 'ERR_NOT_FOUND'); l = tokens.length - 1; - i = registry[tokenIndex[_token]]; if (i < l) { tokens[i] = tokens[l]; - identifiers[i] = identifiers[l]; + identifierList[i] = identifierList[l]; } + registry[tokenIndex[tokens[i]]] = i; tokens.pop(); + identifierList.pop(); registry[tokenIndex[_token]] = 0; + emit AddressRemoved(_token); return true; } @@ -157,13 +160,18 @@ contract TokenUniqueSymbolIndex { } // Implements Registry + function identifier(uint256 _idx) public view returns(bytes32) { + return identifierList[_idx + 1]; + } + + // Implements Registry function identifierCount() public view returns(uint256) { - return identifiers.length; + return identifierList.length - 1; } // Implements EIP165 function supportsInterface(bytes4 _sum) public pure returns (bool) { - if (_sum == 0x12625fe5) { // Registry + if (_sum == 0xeffbf671) { // Registry return true; } if (_sum == 0xb7bca625) { // AccountsIndex