From a60e9383a53ec8870e3aa429c307e8e3fe84cdf4 Mon Sep 17 00:00:00 2001 From: nolash Date: Tue, 22 Dec 2020 07:11:42 +0100 Subject: [PATCH] Move test to python unittest --- solidity/TokenEndorser.bin | 1 - solidity/TokenEndorser.json | 1 - solidity/TokenEndorser.sol | 5 +++++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/solidity/TokenEndorser.bin b/solidity/TokenEndorser.bin index 7049ccd..e69de29 100644 --- a/solidity/TokenEndorser.bin +++ b/solidity/TokenEndorser.bin @@ -1 +0,0 @@ -608060405234801561001057600080fd5b506001600081905550600460009080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610bc48061008c6000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80632d580ef61461005c578063427f91a61461008c5780634f64b2be146100bc578063c82d6828146100ec578063e6088e831461011c575b600080fd5b6100766004803603810190610071919061079a565b61014c565b604051610083919061095e565b60405180910390f35b6100a660048036038101906100a19190610771565b610561565b6040516100b39190610994565b60405180910390f35b6100d660048036038101906100d19190610864565b610579565b6040516100e39190610943565b60405180910390f35b610106600480360381019061010191906107d6565b6105b8565b6040516101139190610994565b60405180910390f35b61013660048036038101906101319190610812565b6105e9565b6040516101439190610979565b60405180910390f35b600061015783610601565b50600080602867ffffffffffffffff81111561019c577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156101ce5781602001600182028036833780820191505090505b5090506000856040516020016101e49190610911565b604051602081830303815290604052905060005b60148110156102c05781818151811061023a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602001015160f81c60f81b83828151811061027e577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080806102b890610aa0565b9150506101f8565b50336040516020016102d29190610911565b604051602081830303815290604052905060005b60148110156103ba57818181518110610328577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602001015160f81c60f81b8360148361034191906109c5565b81518110610378577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080806103b290610aa0565b9150506102e6565b506002826040516103cb919061092c565b602060405180830381855afa1580156103e8573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525081019061040b919061083b565b92506000801b60016000858152602001908152602001600020541461042f57600080fd5b846001600085815260200190815260200160002081905550600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490806001815401808255809150506001900390600052602060002001600090919091909150556000543373ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167fb8a4220b7c147fc6e04861db14024976c551727749a09806414670fac57e53408860405161054c9190610979565b60405180910390a46001935050505092915050565b60026020528060005260406000206000915090505481565b6004818154811061058957600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600360205281600052604060002081815481106105d457600080fd5b90600052602060002001600091509150505481565b60016020528060005260406000206000915090505481565b600080600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411156106535760009050610718565b6004829080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600054600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060008081548092919061070e90610aa0565b9190505550600190505b919050565b60008135905061072c81610b49565b92915050565b60008135905061074181610b60565b92915050565b60008151905061075681610b60565b92915050565b60008135905061076b81610b77565b92915050565b60006020828403121561078357600080fd5b60006107918482850161071d565b91505092915050565b600080604083850312156107ad57600080fd5b60006107bb8582860161071d565b92505060206107cc85828601610732565b9150509250929050565b600080604083850312156107e957600080fd5b60006107f78582860161071d565b92505060206108088582860161075c565b9150509250929050565b60006020828403121561082457600080fd5b600061083284828501610732565b91505092915050565b60006020828403121561084d57600080fd5b600061085b84828501610747565b91505092915050565b60006020828403121561087657600080fd5b60006108848482850161075c565b91505092915050565b61089681610a1b565b82525050565b6108ad6108a882610a1b565b610ae9565b82525050565b6108bc81610a2d565b82525050565b6108cb81610a39565b82525050565b60006108dc826109af565b6108e681856109ba565b93506108f6818560208601610a6d565b80840191505092915050565b61090b81610a63565b82525050565b600061091d828461089c565b60148201915081905092915050565b600061093882846108d1565b915081905092915050565b6000602082019050610958600083018461088d565b92915050565b600060208201905061097360008301846108b3565b92915050565b600060208201905061098e60008301846108c2565b92915050565b60006020820190506109a96000830184610902565b92915050565b600081519050919050565b600081905092915050565b60006109d082610a63565b91506109db83610a63565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610a1057610a0f610b0d565b5b828201905092915050565b6000610a2682610a43565b9050919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60005b83811015610a8b578082015181840152602081019050610a70565b83811115610a9a576000848401525b50505050565b6000610aab82610a63565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415610ade57610add610b0d565b5b600182019050919050565b6000610af482610afb565b9050919050565b6000610b0682610b3c565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008160601b9050919050565b610b5281610a1b565b8114610b5d57600080fd5b50565b610b6981610a39565b8114610b7457600080fd5b50565b610b8081610a63565b8114610b8b57600080fd5b5056fea2646970667358221220bdfe2b23cf9bc8fac35e8b06e83bc20d08b1c9b009c2e1d7c2ccf4932a53601e64736f6c63430008000033 \ No newline at end of file diff --git a/solidity/TokenEndorser.json b/solidity/TokenEndorser.json index 44c473a..e69de29 100644 --- a/solidity/TokenEndorser.json +++ b/solidity/TokenEndorser.json @@ -1 +0,0 @@ -[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_token","type":"address"},{"indexed":true,"internalType":"address","name":"_adder","type":"address"},{"indexed":true,"internalType":"uint256","name":"_index","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"_data","type":"bytes32"}],"name":"EndorsementAdded","type":"event"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"bytes32","name":"_data","type":"bytes32"}],"name":"add","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"endorsement","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"endorsers","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenIndex","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"}] diff --git a/solidity/TokenEndorser.sol b/solidity/TokenEndorser.sol index 00ff906..e3fab7b 100644 --- a/solidity/TokenEndorser.sol +++ b/solidity/TokenEndorser.sol @@ -8,6 +8,7 @@ contract TokenEndorsement { mapping ( bytes32 => bytes32 ) public endorsement; mapping ( address => uint256 ) public tokenIndex; mapping ( address => uint256[] ) public endorsers; + mapping ( string => address ) public tokenSymbolIndex; address[] public tokens; event EndorsementAdded(address indexed _token, address indexed _adder, uint256 indexed _index, bytes32 _data); @@ -21,8 +22,12 @@ contract TokenEndorsement { if (tokenIndex[_token] > 0) { return false; } + string memory token_symbol = _token.call(abi.encodeWithSignature('symbol()')); + require(tokenSymbolIndex[token_symbol] = address(0)); + tokens.push(_token); tokenIndex[_token] = count; + tokenSymbolIndex[token_symbol] = _token; count++; return true; }