commit d3d731e76d015c1f0570ac7bd7fb3f11bcb053a8
parent 8dfc908510cdc50d610f4c09a3b6519405ab339c
Author: nolash <dev@holbrook.no>
Date: Tue, 29 Dec 2020 22:27:34 +0100
Add interface definitions for token index
Diffstat:
4 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/solidity/TokenUniqueSymbolIndex.bin b/solidity/TokenUniqueSymbolIndex.bin
@@ -1 +1 @@
-608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600260009080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610ae3806100c46000396000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c8063bb34534c1161005b578063bb34534c146100da578063cbb834341461010a578063d22057a914610128578063e2095c07146101585761007d565b80637ef5029814610082578063880ad0af146100b25780638da5cb5b146100bc575b600080fd5b61009c60048036038101906100979190610655565b610188565b6040516100a99190610858565b60405180910390f35b6100ba6101a0565b005b6100c46101db565b6040516100d19190610802565b60405180910390f35b6100f460048036038101906100ef9190610655565b6101ff565b6040516101019190610802565b60405180910390f35b610112610285565b60405161011f9190610858565b60405180910390f35b610142600480360381019061013d91906106a7565b61029e565b60405161014f919061081d565b60405180910390f35b610172600480360381019061016d9190610724565b61051f565b60405161017f9190610802565b60405180910390f35b60016020528060005260406000206000915090505481565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101d290610838565b60405180910390fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000806001600084815260200190815260200160002054905060028181548110610252577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16915050919050565b600060016002805490506102999190610951565b905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102f957600080fd5b60606000806000808673ffffffffffffffffffffffffffffffffffffffff166040516024016040516020818303038152906040527f95d89b41000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516103a891906107eb565b6000604051808303816000865af19150503d80600081146103e5576040519150601f19603f3d011682016040523d82523d6000602084013e6103ea565b606091505b5091509150816103f957600080fd5b8080602001905181019061040d91906106e3565b945060028560405161041f91906107eb565b602060405180830381855afa15801561043c573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525081019061045f919061067e565b935083881461046d57600080fd5b600160008581526020019081526020016000205492506000831461049057600080fd5b60028054905060016000868152602001908152602001600020819055506002879080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019550505050505092915050565b6000600260018361053091906108fb565b81548110610567577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60006105ac6105a7846108a4565b610873565b9050828152602081018484840111156105c457600080fd5b6105cf8482856109d7565b509392505050565b6000813590506105e681610a68565b92915050565b6000813590506105fb81610a7f565b92915050565b60008151905061061081610a7f565b92915050565b600082601f83011261062757600080fd5b8151610637848260208601610599565b91505092915050565b60008135905061064f81610a96565b92915050565b60006020828403121561066757600080fd5b6000610675848285016105ec565b91505092915050565b60006020828403121561069057600080fd5b600061069e84828501610601565b91505092915050565b600080604083850312156106ba57600080fd5b60006106c8858286016105ec565b92505060206106d9858286016105d7565b9150509250929050565b6000602082840312156106f557600080fd5b600082015167ffffffffffffffff81111561070f57600080fd5b61071b84828501610616565b91505092915050565b60006020828403121561073657600080fd5b600061074484828501610640565b91505092915050565b61075681610985565b82525050565b61076581610997565b82525050565b6000610776826108d4565b61078081856108df565b93506107908185602086016109d7565b80840191505092915050565b60006107a96017836108ea565b91507f6f776e65722063616e6e6f74206265206368616e6765640000000000000000006000830152602082019050919050565b6107e5816109cd565b82525050565b60006107f7828461076b565b915081905092915050565b6000602082019050610817600083018461074d565b92915050565b6000602082019050610832600083018461075c565b92915050565b600060208201905081810360008301526108518161079c565b9050919050565b600060208201905061086d60008301846107dc565b92915050565b6000604051905081810181811067ffffffffffffffff8211171561089a57610899610a39565b5b8060405250919050565b600067ffffffffffffffff8211156108bf576108be610a39565b5b601f19601f8301169050602081019050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b6000610906826109cd565b9150610911836109cd565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561094657610945610a0a565b5b828201905092915050565b600061095c826109cd565b9150610967836109cd565b92508282101561097a57610979610a0a565b5b828203905092915050565b6000610990826109ad565b9050919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60005b838110156109f55780820151818401526020810190506109da565b83811115610a04576000848401525b50505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610a7181610985565b8114610a7c57600080fd5b50565b610a88816109a3565b8114610a9357600080fd5b50565b610a9f816109cd565b8114610aaa57600080fd5b5056fea2646970667358221220ac61ec9cee18728f473ca43d704ed11cffb389e5a9605129d3bb031e61a9457764736f6c63430008000033
-\ No newline at end of file
+608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600260009080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610af7806100c46000396000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c80638da5cb5b1161005b5780638da5cb5b146100ec578063bb34534c1461010a578063cbb834341461013a578063d22057a9146101585761007d565b806301ffc9a7146100825780637ef50298146100b2578063880ad0af146100e2575b600080fd5b61009c60048036038101906100979190610721565b610188565b6040516100a9919061085b565b60405180910390f35b6100cc60048036038101906100c79190610693565b610240565b6040516100d99190610896565b60405180910390f35b6100ea610258565b005b6100f4610293565b6040516101019190610840565b60405180910390f35b610124600480360381019061011f9190610693565b6102b7565b6040516101319190610840565b60405180910390f35b61014261033d565b60405161014f9190610896565b60405180910390f35b610172600480360381019061016d91906106e5565b610356565b60405161017f919061085b565b60405180910390f35b600063325d15e260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156101e0576001905061023b565b6301ffc9a760e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161415610236576001905061023b565b600090505b919050565b60016020528060005260406000206000915090505481565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028a90610876565b60405180910390fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080600160008481526020019081526020016000205490506002818154811061030a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16915050919050565b600060016002805490506103519190610939565b905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103b157600080fd5b60606000806000808673ffffffffffffffffffffffffffffffffffffffff166040516024016040516020818303038152906040527f95d89b41000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516104609190610829565b6000604051808303816000865af19150503d806000811461049d576040519150601f19603f3d011682016040523d82523d6000602084013e6104a2565b606091505b5091509150816104b157600080fd5b808060200190518101906104c5919061074a565b94506002856040516104d79190610829565b602060405180830381855afa1580156104f4573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525081019061051791906106bc565b935083881461052557600080fd5b600160008581526020019081526020016000205492506000831461054857600080fd5b60028054905060016000868152602001908152602001600020819055506002879080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019550505050505092915050565b60006105ea6105e5846108e2565b6108b1565b90508281526020810184848401111561060257600080fd5b61060d8482856109eb565b509392505050565b60008135905061062481610a7c565b92915050565b60008135905061063981610a93565b92915050565b60008151905061064e81610a93565b92915050565b60008135905061066381610aaa565b92915050565b600082601f83011261067a57600080fd5b815161068a8482602086016105d7565b91505092915050565b6000602082840312156106a557600080fd5b60006106b38482850161062a565b91505092915050565b6000602082840312156106ce57600080fd5b60006106dc8482850161063f565b91505092915050565b600080604083850312156106f857600080fd5b60006107068582860161062a565b925050602061071785828601610615565b9150509250929050565b60006020828403121561073357600080fd5b600061074184828501610654565b91505092915050565b60006020828403121561075c57600080fd5b600082015167ffffffffffffffff81111561077657600080fd5b61078284828501610669565b91505092915050565b6107948161096d565b82525050565b6107a38161097f565b82525050565b60006107b482610912565b6107be818561091d565b93506107ce8185602086016109eb565b80840191505092915050565b60006107e7601783610928565b91507f6f776e65722063616e6e6f74206265206368616e6765640000000000000000006000830152602082019050919050565b610823816109e1565b82525050565b600061083582846107a9565b915081905092915050565b6000602082019050610855600083018461078b565b92915050565b6000602082019050610870600083018461079a565b92915050565b6000602082019050818103600083015261088f816107da565b9050919050565b60006020820190506108ab600083018461081a565b92915050565b6000604051905081810181811067ffffffffffffffff821117156108d8576108d7610a4d565b5b8060405250919050565b600067ffffffffffffffff8211156108fd576108fc610a4d565b5b601f19601f8301169050602081019050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b6000610944826109e1565b915061094f836109e1565b92508282101561096257610961610a1e565b5b828203905092915050565b6000610978826109c1565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60005b83811015610a095780820151818401526020810190506109ee565b83811115610a18576000848401525b50505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610a858161096d565b8114610a9057600080fd5b50565b610a9c8161098b565b8114610aa757600080fd5b50565b610ab381610995565b8114610abe57600080fd5b5056fea2646970667358221220aba1cf99d509278647e13b624d530a127d5d43b7d9bbad9c25df27fcbd8dfef464736f6c63430008000033
+\ 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":[{"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"}]
+[{"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":"bytes4","name":"_interfaceCode","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]
diff --git a/solidity/TokenUniqueSymbolIndex.sol b/solidity/TokenUniqueSymbolIndex.sol
@@ -15,6 +15,17 @@ contract TokenUniqueSymbolIndex {
tokens.push(address(0));
}
+ // EIP 165
+ function supportsInterface(bytes4 _interfaceCode) public pure returns ( bool ) {
+ if (_interfaceCode == bytes4(0x325d15e2)) {
+ return true;
+ }
+ if (_interfaceCode == bytes4(0x01ffc9a7)) {
+ return true;
+ }
+ return false;
+ }
+
// EIP 172
function transferOwnership() public {
revert("owner cannot be changed");
diff --git a/solidity/test_tokenindex.py b/solidity/test_tokenindex.py
@@ -52,3 +52,7 @@ except:
if not fail:
raise RuntimeError('expected fail on register same token to same address')
+
+assert(c.functions.supportsInterface('0x325d15e2').call())
+assert(c.functions.supportsInterface('0x01ffc9a7').call())
+assert(not c.functions.supportsInterface('0xffffffff').call())