eth-address-index

signed metadata declarations for ethereum addresses
Log | Files | Refs

commit 8dfc908510cdc50d610f4c09a3b6519405ab339c
parent 28abd891dcc696753f2a12d35afe83fd80b86771
Author: nolash <dev@holbrook.no>
Date:   Tue, 29 Dec 2020 21:19:12 +0100

Add interface for token index

Diffstat:
Mpython/eth_address_declarator/declarator.py | 14+++++++-------
Apython/eth_token_index/__init__.py | 1+
Apython/eth_token_index/data/ERC20.json | 1+
Apython/eth_token_index/data/GiftableToken.bin | 2++
Apython/eth_token_index/data/GiftableToken.json | 1+
Mpython/eth_token_index/data/TokenUniqueSymbolIndex.bin | 4++--
Mpython/eth_token_index/data/TokenUniqueSymbolIndex.json | 2+-
Apython/eth_token_index/index.py | 84+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apython/tests/test_inteface.py | 100+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpython/tests/test_tokenindex.py | 8++++----
Msolidity/TokenUniqueSymbolIndex.bin | 4++--
Msolidity/TokenUniqueSymbolIndex.json | 2+-
Msolidity/TokenUniqueSymbolIndex.sol | 4++--
13 files changed, 208 insertions(+), 19 deletions(-)

diff --git a/python/eth_address_declarator/declarator.py b/python/eth_address_declarator/declarator.py @@ -15,15 +15,15 @@ moddir = os.path.dirname(__file__) datadir = os.path.join(moddir, 'data') -class TokenEndorser: +class AddressDeclarator: __abi = None __bytecode = None __address = None def __init__(self, w3, address, signer_address=None): - abi = TokenEndorser.abi() - TokenEndorser.bytecode() + abi = AddressDeclarator.abi() + AddressDeclarator.bytecode() self.__address = address self.contract = w3.eth.contract(abi=abi, address=address) self.w3 = w3 @@ -37,20 +37,20 @@ class TokenEndorser: @staticmethod def abi(): - if TokenEndorser.__abi == None: + if AddressDeclarator.__abi == None: f = open(os.path.join(datadir, 'AccountDeclarator.json'), 'r') AccountDeclarator.__abi = json.load(f) f.close() - return TokenEndorser.__abi + return AddressDeclarator.__abi @staticmethod def bytecode(): - if TokenEndorser.__bytecode == None: + if AddressDeclarator.__bytecode == None: f = open(os.path.join(datadir, 'AccountDeclarator.bin')) AccountDeclarator.__bytecode = f.read() f.close() - return TokenEndorser.__bytecode + return AddressDeclarator.__bytecode # def token_from_symbol(self, symbol): diff --git a/python/eth_token_index/__init__.py b/python/eth_token_index/__init__.py @@ -0,0 +1 @@ +from .index import TokenUniqueSymbolIndex diff --git a/python/eth_token_index/data/ERC20.json b/python/eth_token_index/data/ERC20.json @@ -0,0 +1 @@ +[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}] diff --git a/python/eth_token_index/data/GiftableToken.bin b/python/eth_token_index/data/GiftableToken.bin @@ -0,0 +1 @@ +60806040523480156200001157600080fd5b506040516200120338038062001203833981810160405260608110156200003757600080fd5b81019080805160405193929190846401000000008211156200005857600080fd5b838201915060208201858111156200006f57600080fd5b82518660018202830111640100000000821117156200008d57600080fd5b8083526020830192505050908051906020019080838360005b83811015620000c3578082015181840152602081019050620000a6565b50505050905090810190601f168015620000f15780820380516001836020036101000a031916815260200191505b50604052602001805160405193929190846401000000008211156200011557600080fd5b838201915060208201858111156200012c57600080fd5b82518660018202830111640100000000821117156200014a57600080fd5b8083526020830192505050908051906020019080838360005b838110156200018057808201518184015260208101905062000163565b50505050905090810190601f168015620001ae5780820380516001836020036101000a031916815260200191505b5060405260200180519060200190929190505050336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082600290805190602001906200021a929190620002af565b50816003908051906020019062000233929190620002af565b5080600460006101000a81548160ff021916908360ff16021790555060018060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050505062000365565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282620002e7576000855562000333565b82601f106200030257805160ff191683800117855562000333565b8280016001018555821562000333579182015b828111156200033257825182559160200191906001019062000315565b5b50905062000342919062000346565b5090565b5b808211156200036157600081600090555060010162000347565b5090565b610e8e80620003756000396000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c806355b6ed5c1161007157806355b6ed5c146102bd57806370a082311461033557806395d89b411461038d578063983b2d5614610410578063a0712d681461046a578063a9059cbb146104ae576100b4565b806306fdde03146100b9578063095ea7b31461013c57806318160ddd146101a057806323b872dd146101be5780633092afd514610242578063313ce5671461029c575b600080fd5b6100c1610512565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101015780820151818401526020810190506100e6565b50505050905090810190601f16801561012e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101886004803603604081101561015257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105b0565b60405180821515815260200191505060405180910390f35b6101a86106ab565b6040518082815260200191505060405180910390f35b61022a600480360360608110156101d457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106b1565b60405180821515815260200191505060405180910390f35b6102846004803603602081101561025857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109a8565b60405180821515815260200191505060405180910390f35b6102a4610a9a565b604051808260ff16815260200191505060405180910390f35b61031f600480360360408110156102d357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610aad565b6040518082815260200191505060405180910390f35b6103776004803603602081101561034b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ad2565b6040518082815260200191505060405180910390f35b610395610aea565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103d55780820151818401526020810190506103ba565b50505050905090810190601f1680156104025780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104526004803603602081101561042657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b88565b60405180821515815260200191505060405180910390f35b6104966004803603602081101561048057600080fd5b8101908080359060200190929190505050610c43565b60405180821515815260200191505060405180910390f35b6104fa600480360360408110156104c457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610d01565b60405180821515815260200191505060405180910390f35b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105a85780601f1061057d576101008083540402835291602001916105a8565b820191906000526020600020905b81548152906001019060200180831161058b57829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60055481565b600081600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561073c57600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561078857600080fd5b81600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205403600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055503373ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f5f7542858008eeb041631f30e6109ae94b83a58e9a58261dd2c42c508850f939856040518082815260200191505060405180910390a4600190509392505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610a3057508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610a3957600080fd5b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b600460009054906101000a900460ff1681565b6007602052816000526040600020602052806000526040600020600091509150505481565b60066020528060005260406000206000915090505481565b60038054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b805780601f10610b5557610100808354040283529160200191610b80565b820191906000526020600020905b815481529060010190602001808311610b6357829003601f168201915b505050505081565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610be357600080fd5b60018060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b6000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610c9b57600080fd5b81600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508160056000828254019250508190555060019050919050565b600081600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610d4f57600080fd5b81600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509291505056fea2646970667358221220decedd646f4686c330f11369f5c7b4908d8940d20f00c85711890c5f75172d8764736f6c63430007050033 +\ No newline at end of file diff --git a/python/eth_token_index/data/GiftableToken.json b/python/eth_token_index/data/GiftableToken.json @@ -0,0 +1 @@ +[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"_decimals","type":"uint8"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":true,"internalType":"address","name":"_spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"TransferFrom","type":"event"},{"inputs":[{"internalType":"address","name":"_minter","type":"address"}],"name":"addMinter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"mint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_minter","type":"address"}],"name":"removeMinter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}] diff --git a/python/eth_token_index/data/TokenUniqueSymbolIndex.bin b/python/eth_token_index/data/TokenUniqueSymbolIndex.bin @@ -1 +1 @@ -608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600260009080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506109e3806100c46000396000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c80638da5cb5b1161005b5780638da5cb5b146100ec578063bb34534c1461010a578063cbb834341461013a578063d22057a9146101585761007d565b80634f64b2be146100825780637ef50298146100b2578063880ad0af146100e2575b600080fd5b61009c600480360381019061009791906106dd565b610188565b6040516100a991906107bb565b60405180910390f35b6100cc60048036038101906100c7919061060e565b6101c7565b6040516100d99190610811565b60405180910390f35b6100ea6101df565b005b6100f461021a565b60405161010191906107bb565b60405180910390f35b610124600480360381019061011f919061060e565b61023e565b60405161013191906107bb565b60405180910390f35b6101426102c4565b60405161014f9190610811565b60405180910390f35b610172600480360381019061016d9190610660565b6102d1565b60405161017f91906107d6565b60405180910390f35b6002818154811061019857600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60016020528060005260406000206000915090505481565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610211906107f1565b60405180910390fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000806001600084815260200190815260200160002054905060028181548110610291577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16915050919050565b6000600280549050905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461032c57600080fd5b60606000806000808673ffffffffffffffffffffffffffffffffffffffff166040516024016040516020818303038152906040527f95d89b41000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516103db91906107a4565b6000604051808303816000865af19150503d8060008114610418576040519150601f19603f3d011682016040523d82523d6000602084013e61041d565b606091505b50915091508161042c57600080fd5b80806020019051810190610440919061069c565b945060028560405161045291906107a4565b602060405180830381855afa15801561046f573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906104929190610637565b93508388146104a057600080fd5b60016000858152602001908152602001600020549250600083146104c357600080fd5b60028054905060016000868152602001908152602001600020819055506002879080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019550505050505092915050565b60006105656105608461085d565b61082c565b90508281526020810184848401111561057d57600080fd5b610588848285610906565b509392505050565b60008135905061059f81610968565b92915050565b6000813590506105b48161097f565b92915050565b6000815190506105c98161097f565b92915050565b600082601f8301126105e057600080fd5b81516105f0848260208601610552565b91505092915050565b60008135905061060881610996565b92915050565b60006020828403121561062057600080fd5b600061062e848285016105a5565b91505092915050565b60006020828403121561064957600080fd5b6000610657848285016105ba565b91505092915050565b6000806040838503121561067357600080fd5b6000610681858286016105a5565b925050602061069285828601610590565b9150509250929050565b6000602082840312156106ae57600080fd5b600082015167ffffffffffffffff8111156106c857600080fd5b6106d4848285016105cf565b91505092915050565b6000602082840312156106ef57600080fd5b60006106fd848285016105f9565b91505092915050565b61070f816108b4565b82525050565b61071e816108c6565b82525050565b600061072f8261088d565b6107398185610898565b9350610749818560208601610906565b80840191505092915050565b60006107626017836108a3565b91507f6f776e65722063616e6e6f74206265206368616e6765640000000000000000006000830152602082019050919050565b61079e816108fc565b82525050565b60006107b08284610724565b915081905092915050565b60006020820190506107d06000830184610706565b92915050565b60006020820190506107eb6000830184610715565b92915050565b6000602082019050818103600083015261080a81610755565b9050919050565b60006020820190506108266000830184610795565b92915050565b6000604051905081810181811067ffffffffffffffff8211171561085357610852610939565b5b8060405250919050565b600067ffffffffffffffff82111561087857610877610939565b5b601f19601f8301169050602081019050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b60006108bf826108dc565b9050919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60005b83811015610924578082015181840152602081019050610909565b83811115610933576000848401525b50505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610971816108b4565b811461097c57600080fd5b50565b610988816108d2565b811461099357600080fd5b50565b61099f816108fc565b81146109aa57600080fd5b5056fea264697066735822122065acf4d9b69a14b392a3392cf17e2db9d96934bf3e05a4ed9f7d8be85f6aebaa64736f6c63430008000033 -\ No newline at end of file +608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600260009080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610ae3806100c46000396000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c8063bb34534c1161005b578063bb34534c146100da578063cbb834341461010a578063d22057a914610128578063e2095c07146101585761007d565b80637ef5029814610082578063880ad0af146100b25780638da5cb5b146100bc575b600080fd5b61009c60048036038101906100979190610655565b610188565b6040516100a99190610858565b60405180910390f35b6100ba6101a0565b005b6100c46101db565b6040516100d19190610802565b60405180910390f35b6100f460048036038101906100ef9190610655565b6101ff565b6040516101019190610802565b60405180910390f35b610112610285565b60405161011f9190610858565b60405180910390f35b610142600480360381019061013d91906106a7565b61029e565b60405161014f919061081d565b60405180910390f35b610172600480360381019061016d9190610724565b61051f565b60405161017f9190610802565b60405180910390f35b60016020528060005260406000206000915090505481565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101d290610838565b60405180910390fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000806001600084815260200190815260200160002054905060028181548110610252577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16915050919050565b600060016002805490506102999190610951565b905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102f957600080fd5b60606000806000808673ffffffffffffffffffffffffffffffffffffffff166040516024016040516020818303038152906040527f95d89b41000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516103a891906107eb565b6000604051808303816000865af19150503d80600081146103e5576040519150601f19603f3d011682016040523d82523d6000602084013e6103ea565b606091505b5091509150816103f957600080fd5b8080602001905181019061040d91906106e3565b945060028560405161041f91906107eb565b602060405180830381855afa15801561043c573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525081019061045f919061067e565b935083881461046d57600080fd5b600160008581526020019081526020016000205492506000831461049057600080fd5b60028054905060016000868152602001908152602001600020819055506002879080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019550505050505092915050565b6000600260018361053091906108fb565b81548110610567577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60006105ac6105a7846108a4565b610873565b9050828152602081018484840111156105c457600080fd5b6105cf8482856109d7565b509392505050565b6000813590506105e681610a68565b92915050565b6000813590506105fb81610a7f565b92915050565b60008151905061061081610a7f565b92915050565b600082601f83011261062757600080fd5b8151610637848260208601610599565b91505092915050565b60008135905061064f81610a96565b92915050565b60006020828403121561066757600080fd5b6000610675848285016105ec565b91505092915050565b60006020828403121561069057600080fd5b600061069e84828501610601565b91505092915050565b600080604083850312156106ba57600080fd5b60006106c8858286016105ec565b92505060206106d9858286016105d7565b9150509250929050565b6000602082840312156106f557600080fd5b600082015167ffffffffffffffff81111561070f57600080fd5b61071b84828501610616565b91505092915050565b60006020828403121561073657600080fd5b600061074484828501610640565b91505092915050565b61075681610985565b82525050565b61076581610997565b82525050565b6000610776826108d4565b61078081856108df565b93506107908185602086016109d7565b80840191505092915050565b60006107a96017836108ea565b91507f6f776e65722063616e6e6f74206265206368616e6765640000000000000000006000830152602082019050919050565b6107e5816109cd565b82525050565b60006107f7828461076b565b915081905092915050565b6000602082019050610817600083018461074d565b92915050565b6000602082019050610832600083018461075c565b92915050565b600060208201905081810360008301526108518161079c565b9050919050565b600060208201905061086d60008301846107dc565b92915050565b6000604051905081810181811067ffffffffffffffff8211171561089a57610899610a39565b5b8060405250919050565b600067ffffffffffffffff8211156108bf576108be610a39565b5b601f19601f8301169050602081019050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b6000610906826109cd565b9150610911836109cd565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561094657610945610a0a565b5b828201905092915050565b600061095c826109cd565b9150610967836109cd565b92508282101561097a57610979610a0a565b5b828203905092915050565b6000610990826109ad565b9050919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60005b838110156109f55780820151818401526020810190506109da565b83811115610a04576000848401525b50505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610a7181610985565b8114610a7c57600080fd5b50565b610a88816109a3565b8114610a9357600080fd5b50565b610a9f816109cd565b8114610aaa57600080fd5b5056fea2646970667358221220ac61ec9cee18728f473ca43d704ed11cffb389e5a9605129d3bb031e61a9457764736f6c63430008000033 +\ 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"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"}],"name":"addressOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"},{"internalType":"address","name":"_token","type":"address"}],"name":"register","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"registry","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"registryCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokens","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}] +[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"}],"name":"addressOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_idx","type":"uint256"}],"name":"entry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"},{"internalType":"address","name":"_token","type":"address"}],"name":"register","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"registry","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"registryCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}] diff --git a/python/eth_token_index/index.py b/python/eth_token_index/index.py @@ -0,0 +1,84 @@ +# Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 +# SPDX-License-Identifier: GPL-3.0-or-later +# File-version: 1 +# Description: Python interface to abi and bin files for faucet contracts + +# standard imports +import logging +import json +import os +import hashlib + +logg = logging.getLogger(__name__) + +moddir = os.path.dirname(__file__) +datadir = os.path.join(moddir, 'data') + + +class TokenUniqueSymbolIndex: + + __abi = None + __bytecode = None + __address = None + __erc20_abi = None + + def __init__(self, w3, address, signer_address=None): + abi = TokenUniqueSymbolIndex.abi() + TokenUniqueSymbolIndex.bytecode() + self.__address = address + self.contract = w3.eth.contract(abi=abi, address=address) + self.w3 = w3 + if signer_address != None: + self.signer_address = signer_address + else: + if type(self.w3.eth.defaultAccount).__name__ == 'Empty': + self.w3.eth.defaultAccount = self.w3.eth.accounts[0] + self.signer_address = self.w3.eth.defaultAccount + + f = open(os.path.join(datadir, 'ERC20.json'), 'r') + TokenUniqueSymbolIndex.__erc20_abi = json.load(f) + f.close() + + + @staticmethod + def abi(): + if TokenUniqueSymbolIndex.__abi == None: + f = open(os.path.join(datadir, 'TokenUniqueSymbolIndex.json'), 'r') + TokenUniqueSymbolIndex.__abi = json.load(f) + f.close() + return TokenUniqueSymbolIndex.__abi + + + @staticmethod + def bytecode(): + if TokenUniqueSymbolIndex.__bytecode == None: + f = open(os.path.join(datadir, 'TokenUniqueSymbolIndex.bin')) + TokenUniqueSymbolIndex.__bytecode = f.read() + f.close() + return TokenUniqueSymbolIndex.__bytecode + + + def add(self, address): + c = self.w3.eth.contract(abi=TokenUniqueSymbolIndex.__erc20_abi, address=address) + s = c.functions.symbol().call() + h = to_ref(s) + return self.contract.functions.register(h, address).transact({'from':self.signer_address}) + + + def count(self): + return self.contract.functions.registryCount().call() + + + def get_index(self, idx): + return self.contract.functions.tokens(idx).call() + + + def get_token_by_symbol(self, symbol): + ref = to_ref(symbol) + return self.contract.functions.addressOf(symbol).call() + + +def to_ref(s): + h = hashlib.new('sha256') + h.update(s.encode('utf-8')) + return h.digest().hex() diff --git a/python/tests/test_inteface.py b/python/tests/test_inteface.py @@ -0,0 +1,100 @@ +import os +import unittest +import json +import logging +import hashlib + +import web3 +import eth_tester +import eth_abi + +from eth_token_index import TokenUniqueSymbolIndex + +logging.basicConfig(level=logging.DEBUG) +logg = logging.getLogger() + +logging.getLogger('web3').setLevel(logging.WARNING) +logging.getLogger('eth.vm').setLevel(logging.WARNING) + +testdir = os.path.dirname(__file__) + + +class Test(unittest.TestCase): + + contract = None + + def setUp(self): + eth_params = eth_tester.backends.pyevm.main.get_default_genesis_params({ + 'gas_limit': 9000000, + }) + + # create store of used accounts + #f = open(os.path.join(testdir, '../eth_token_index/data/TokenUniqueSymbolIndex.bin'), 'r') + f = open(os.path.join(testdir, '../eth_token_index/data/TokenUniqueSymbolIndex.bin'), 'r') + bytecode = f.read() + f.close() + + #f = open(os.path.join(testdir, '../eth_token_index/data/TokenUniqueSymbolIndex.json'), 'r') + f = open(os.path.join(testdir, '../eth_token_index/data/TokenUniqueSymbolIndex.json'), 'r') + self.abi = json.load(f) + f.close() + + + backend = eth_tester.PyEVMBackend(eth_params) + self.eth_tester = eth_tester.EthereumTester(backend) + provider = web3.Web3.EthereumTesterProvider(self.eth_tester) + self.w3 = web3.Web3(provider) + c = self.w3.eth.contract(abi=self.abi, bytecode=bytecode) + tx_hash = c.constructor().transact({'from': self.w3.eth.accounts[0]}) + + r = self.w3.eth.getTransactionReceipt(tx_hash) + + self.address = r.contractAddress + + + # create token + f = open(os.path.join(testdir, '../eth_token_index/data/GiftableToken.bin'), 'r') + bytecode = f.read() + f.close() + + f = open(os.path.join(testdir, '../eth_token_index/data/GiftableToken.json'), 'r') + self.abi_token = json.load(f) + f.close() + + t = self.w3.eth.contract(abi=self.abi_token, bytecode=bytecode) + tx_hash = t.constructor('Foo Token', 'FOO', 18).transact({'from': self.w3.eth.accounts[0]}) + + r = self.w3.eth.getTransactionReceipt(tx_hash) + + self.address_token_one = r.contractAddress + + t = self.w3.eth.contract(abi=self.abi_token, bytecode=bytecode) + tx_hash = t.constructor('Bar Token', 'BAR', 18).transact({'from': self.w3.eth.accounts[0]}) + + r = self.w3.eth.getTransactionReceipt(tx_hash) + + self.address_token_two = r.contractAddress + + t = self.w3.eth.contract(abi=self.abi_token, bytecode=bytecode) + tx_hash = t.constructor('Bar Token Duplicate', 'BAR', 18).transact({'from': self.w3.eth.accounts[0]}) + + r = self.w3.eth.getTransactionReceipt(tx_hash) + + self.address_token_three = r.contractAddress + + + def tearDown(self): + pass + + + def test_basic(self): + ifc = TokenUniqueSymbolIndex(self.w3, self.address) + + logg.info('tx {}'.format(ifc.add(self.address_token_one))) + logg.info('tx {}'.format(ifc.add(self.address_token_two))) + + assert ifc.count() == 2 + + +if __name__ == '__main__': + unittest.main() diff --git a/python/tests/test_tokenindex.py b/python/tests/test_tokenindex.py @@ -28,12 +28,12 @@ class Test(unittest.TestCase): # create store of used accounts #f = open(os.path.join(testdir, '../eth_token_index/data/TokenUniqueSymbolIndex.bin'), 'r') - f = open(os.path.join(testdir, '../../solidity/TokenUniqueSymbolIndex.bin'), 'r') + f = open(os.path.join(testdir, '../eth_token_index/data/TokenUniqueSymbolIndex.bin'), 'r') bytecode = f.read() f.close() #f = open(os.path.join(testdir, '../eth_token_index/data/TokenUniqueSymbolIndex.json'), 'r') - f = open(os.path.join(testdir, '../../solidity/TokenUniqueSymbolIndex.json'), 'r') + f = open(os.path.join(testdir, '../eth_token_index/data/TokenUniqueSymbolIndex.json'), 'r') self.abi = json.load(f) f.close() @@ -51,11 +51,11 @@ class Test(unittest.TestCase): # create token - f = open(os.path.join(testdir, '../eth_token_endorser/data/GiftableToken.bin'), 'r') + f = open(os.path.join(testdir, '../eth_token_index/data/GiftableToken.bin'), 'r') bytecode = f.read() f.close() - f = open(os.path.join(testdir, '../eth_token_endorser/data/GiftableToken.json'), 'r') + f = open(os.path.join(testdir, '../eth_token_index/data/GiftableToken.json'), 'r') self.abi_token = json.load(f) f.close() diff --git a/solidity/TokenUniqueSymbolIndex.bin b/solidity/TokenUniqueSymbolIndex.bin @@ -1 +1 @@ -608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600260009080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506109e3806100c46000396000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c80638da5cb5b1161005b5780638da5cb5b146100ec578063bb34534c1461010a578063cbb834341461013a578063d22057a9146101585761007d565b80634f64b2be146100825780637ef50298146100b2578063880ad0af146100e2575b600080fd5b61009c600480360381019061009791906106dd565b610188565b6040516100a991906107bb565b60405180910390f35b6100cc60048036038101906100c7919061060e565b6101c7565b6040516100d99190610811565b60405180910390f35b6100ea6101df565b005b6100f461021a565b60405161010191906107bb565b60405180910390f35b610124600480360381019061011f919061060e565b61023e565b60405161013191906107bb565b60405180910390f35b6101426102c4565b60405161014f9190610811565b60405180910390f35b610172600480360381019061016d9190610660565b6102d1565b60405161017f91906107d6565b60405180910390f35b6002818154811061019857600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60016020528060005260406000206000915090505481565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610211906107f1565b60405180910390fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000806001600084815260200190815260200160002054905060028181548110610291577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16915050919050565b6000600280549050905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461032c57600080fd5b60606000806000808673ffffffffffffffffffffffffffffffffffffffff166040516024016040516020818303038152906040527f95d89b41000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516103db91906107a4565b6000604051808303816000865af19150503d8060008114610418576040519150601f19603f3d011682016040523d82523d6000602084013e61041d565b606091505b50915091508161042c57600080fd5b80806020019051810190610440919061069c565b945060028560405161045291906107a4565b602060405180830381855afa15801561046f573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906104929190610637565b93508388146104a057600080fd5b60016000858152602001908152602001600020549250600083146104c357600080fd5b60028054905060016000868152602001908152602001600020819055506002879080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019550505050505092915050565b60006105656105608461085d565b61082c565b90508281526020810184848401111561057d57600080fd5b610588848285610906565b509392505050565b60008135905061059f81610968565b92915050565b6000813590506105b48161097f565b92915050565b6000815190506105c98161097f565b92915050565b600082601f8301126105e057600080fd5b81516105f0848260208601610552565b91505092915050565b60008135905061060881610996565b92915050565b60006020828403121561062057600080fd5b600061062e848285016105a5565b91505092915050565b60006020828403121561064957600080fd5b6000610657848285016105ba565b91505092915050565b6000806040838503121561067357600080fd5b6000610681858286016105a5565b925050602061069285828601610590565b9150509250929050565b6000602082840312156106ae57600080fd5b600082015167ffffffffffffffff8111156106c857600080fd5b6106d4848285016105cf565b91505092915050565b6000602082840312156106ef57600080fd5b60006106fd848285016105f9565b91505092915050565b61070f816108b4565b82525050565b61071e816108c6565b82525050565b600061072f8261088d565b6107398185610898565b9350610749818560208601610906565b80840191505092915050565b60006107626017836108a3565b91507f6f776e65722063616e6e6f74206265206368616e6765640000000000000000006000830152602082019050919050565b61079e816108fc565b82525050565b60006107b08284610724565b915081905092915050565b60006020820190506107d06000830184610706565b92915050565b60006020820190506107eb6000830184610715565b92915050565b6000602082019050818103600083015261080a81610755565b9050919050565b60006020820190506108266000830184610795565b92915050565b6000604051905081810181811067ffffffffffffffff8211171561085357610852610939565b5b8060405250919050565b600067ffffffffffffffff82111561087857610877610939565b5b601f19601f8301169050602081019050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b60006108bf826108dc565b9050919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60005b83811015610924578082015181840152602081019050610909565b83811115610933576000848401525b50505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610971816108b4565b811461097c57600080fd5b50565b610988816108d2565b811461099357600080fd5b50565b61099f816108fc565b81146109aa57600080fd5b5056fea264697066735822122065acf4d9b69a14b392a3392cf17e2db9d96934bf3e05a4ed9f7d8be85f6aebaa64736f6c63430008000033 -\ No newline at end of file +608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600260009080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610ae3806100c46000396000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c8063bb34534c1161005b578063bb34534c146100da578063cbb834341461010a578063d22057a914610128578063e2095c07146101585761007d565b80637ef5029814610082578063880ad0af146100b25780638da5cb5b146100bc575b600080fd5b61009c60048036038101906100979190610655565b610188565b6040516100a99190610858565b60405180910390f35b6100ba6101a0565b005b6100c46101db565b6040516100d19190610802565b60405180910390f35b6100f460048036038101906100ef9190610655565b6101ff565b6040516101019190610802565b60405180910390f35b610112610285565b60405161011f9190610858565b60405180910390f35b610142600480360381019061013d91906106a7565b61029e565b60405161014f919061081d565b60405180910390f35b610172600480360381019061016d9190610724565b61051f565b60405161017f9190610802565b60405180910390f35b60016020528060005260406000206000915090505481565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101d290610838565b60405180910390fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000806001600084815260200190815260200160002054905060028181548110610252577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16915050919050565b600060016002805490506102999190610951565b905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102f957600080fd5b60606000806000808673ffffffffffffffffffffffffffffffffffffffff166040516024016040516020818303038152906040527f95d89b41000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516103a891906107eb565b6000604051808303816000865af19150503d80600081146103e5576040519150601f19603f3d011682016040523d82523d6000602084013e6103ea565b606091505b5091509150816103f957600080fd5b8080602001905181019061040d91906106e3565b945060028560405161041f91906107eb565b602060405180830381855afa15801561043c573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525081019061045f919061067e565b935083881461046d57600080fd5b600160008581526020019081526020016000205492506000831461049057600080fd5b60028054905060016000868152602001908152602001600020819055506002879080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019550505050505092915050565b6000600260018361053091906108fb565b81548110610567577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60006105ac6105a7846108a4565b610873565b9050828152602081018484840111156105c457600080fd5b6105cf8482856109d7565b509392505050565b6000813590506105e681610a68565b92915050565b6000813590506105fb81610a7f565b92915050565b60008151905061061081610a7f565b92915050565b600082601f83011261062757600080fd5b8151610637848260208601610599565b91505092915050565b60008135905061064f81610a96565b92915050565b60006020828403121561066757600080fd5b6000610675848285016105ec565b91505092915050565b60006020828403121561069057600080fd5b600061069e84828501610601565b91505092915050565b600080604083850312156106ba57600080fd5b60006106c8858286016105ec565b92505060206106d9858286016105d7565b9150509250929050565b6000602082840312156106f557600080fd5b600082015167ffffffffffffffff81111561070f57600080fd5b61071b84828501610616565b91505092915050565b60006020828403121561073657600080fd5b600061074484828501610640565b91505092915050565b61075681610985565b82525050565b61076581610997565b82525050565b6000610776826108d4565b61078081856108df565b93506107908185602086016109d7565b80840191505092915050565b60006107a96017836108ea565b91507f6f776e65722063616e6e6f74206265206368616e6765640000000000000000006000830152602082019050919050565b6107e5816109cd565b82525050565b60006107f7828461076b565b915081905092915050565b6000602082019050610817600083018461074d565b92915050565b6000602082019050610832600083018461075c565b92915050565b600060208201905081810360008301526108518161079c565b9050919050565b600060208201905061086d60008301846107dc565b92915050565b6000604051905081810181811067ffffffffffffffff8211171561089a57610899610a39565b5b8060405250919050565b600067ffffffffffffffff8211156108bf576108be610a39565b5b601f19601f8301169050602081019050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b6000610906826109cd565b9150610911836109cd565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561094657610945610a0a565b5b828201905092915050565b600061095c826109cd565b9150610967836109cd565b92508282101561097a57610979610a0a565b5b828203905092915050565b6000610990826109ad565b9050919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60005b838110156109f55780820151818401526020810190506109da565b83811115610a04576000848401525b50505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610a7181610985565b8114610a7c57600080fd5b50565b610a88816109a3565b8114610a9357600080fd5b50565b610a9f816109cd565b8114610aaa57600080fd5b5056fea2646970667358221220ac61ec9cee18728f473ca43d704ed11cffb389e5a9605129d3bb031e61a9457764736f6c63430008000033 +\ No newline at end of file diff --git a/solidity/TokenUniqueSymbolIndex.json b/solidity/TokenUniqueSymbolIndex.json @@ -1 +1 @@ -[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"}],"name":"addressOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"},{"internalType":"address","name":"_token","type":"address"}],"name":"register","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"registry","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"registryCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokens","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}] +[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"}],"name":"addressOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_idx","type":"uint256"}],"name":"entry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"},{"internalType":"address","name":"_token","type":"address"}],"name":"register","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"registry","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"registryCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}] diff --git a/solidity/TokenUniqueSymbolIndex.sol b/solidity/TokenUniqueSymbolIndex.sol @@ -8,7 +8,7 @@ contract TokenUniqueSymbolIndex { address public owner; mapping ( bytes32 => uint256 ) public registry; - address[] public tokens; + address[] tokens; constructor() { owner = msg.sender; @@ -50,6 +50,6 @@ contract TokenUniqueSymbolIndex { } function registryCount() public view returns ( uint256 ) { - return tokens.length; + return tokens.length - 1; } }