commit 8d84dbb4871179d2669c4a6247113e93c8c84563
parent 97174b4eb8e23cbd37dd26e7dc34e6f28ca5aaac
Author: lash <dev@holbrook.no>
Date: Thu, 3 Aug 2023 15:15:49 +0100
Update contract with acl interface, add eip173 to index version
Diffstat:
4 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/python/erc20_limiter/data/LimiterIndex.bin b/python/erc20_limiter/data/LimiterIndex.bin
@@ -1 +1 @@
-608060405234801561001057600080fd5b506040516109b93803806109b98339818101604052810190610032919061015b565b81600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505061019b565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100ea826100bf565b9050919050565b6100fa816100df565b811461010557600080fd5b50565b600081519050610117816100f1565b92915050565b6000610128826100df565b9050919050565b6101388161011d565b811461014357600080fd5b50565b6000815190506101558161012f565b92915050565b60008060408385031215610172576101716100ba565b5b600061018085828601610108565b925050602061019185828601610146565b9150509250929050565b61080f806101aa6000396000f3fe608060405234801561001057600080fd5b5060043610610074576000357c01000000000000000000000000000000000000000000000000000000009004806301ffc9a71461007957806323778613146100a957806336db43b5146100d95780633ef25013146100f5578063bdd5544014610125575b600080fd5b610093600480360381019061008e9190610507565b610141565b6040516100a0919061054f565b60405180910390f35b6100c360048036038101906100be91906105c8565b610243565b6040516100d09190610621565b60405180910390f35b6100f360048036038101906100ee9190610668565b610306565b005b61010f600480360381019061010a91906106a8565b610315565b60405161011c919061054f565b60405180910390f35b61013f600480360381019061013a91906106d5565b6103fa565b005b60006301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191603610195576001905061023e565b63b7bca6257c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036101e7576001905061023e565b63237786137c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191603610239576001905061023e565b600090505b919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632377861384846040518363ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004016102bd929190610737565b602060405180830381865afa1580156102da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102fe9190610775565b905092915050565b6103118233836103fa565b5050565b60008060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632377861384600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518363ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004016103b1929190610737565b602060405180830381865afa1580156103ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103f29190610775565b119050919050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663bdd554408484846040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401610473939291906107a2565b600060405180830381600087803b15801561048d57600080fd5b505af11580156104a1573d6000803e3d6000fd5b50505050505050565b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6104e4816104af565b81146104ef57600080fd5b50565b600081359050610501816104db565b92915050565b60006020828403121561051d5761051c6104aa565b5b600061052b848285016104f2565b91505092915050565b60008115159050919050565b61054981610534565b82525050565b60006020820190506105646000830184610540565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006105958261056a565b9050919050565b6105a58161058a565b81146105b057600080fd5b50565b6000813590506105c28161059c565b92915050565b600080604083850312156105df576105de6104aa565b5b60006105ed858286016105b3565b92505060206105fe858286016105b3565b9150509250929050565b6000819050919050565b61061b81610608565b82525050565b60006020820190506106366000830184610612565b92915050565b61064581610608565b811461065057600080fd5b50565b6000813590506106628161063c565b92915050565b6000806040838503121561067f5761067e6104aa565b5b600061068d858286016105b3565b925050602061069e85828601610653565b9150509250929050565b6000602082840312156106be576106bd6104aa565b5b60006106cc848285016105b3565b91505092915050565b6000806000606084860312156106ee576106ed6104aa565b5b60006106fc868287016105b3565b935050602061070d868287016105b3565b925050604061071e86828701610653565b9150509250925092565b6107318161058a565b82525050565b600060408201905061074c6000830185610728565b6107596020830184610728565b9392505050565b60008151905061076f8161063c565b92915050565b60006020828403121561078b5761078a6104aa565b5b600061079984828501610760565b91505092915050565b60006060820190506107b76000830186610728565b6107c46020830185610728565b6107d16040830184610612565b94935050505056fea26469706673582212207ee27d09ef3d423a98e3dbc9563133658799e67ea2ceabcfe9327dda839ee8b464736f6c63430008130033
-\ No newline at end of file
+60806040523480156200001157600080fd5b5060405162000c6238038062000c628339818101604052810190620000379190620001b0565b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050620001f7565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620001338262000106565b9050919050565b620001458162000126565b81146200015157600080fd5b50565b60008151905062000165816200013a565b92915050565b6000620001788262000126565b9050919050565b6200018a816200016b565b81146200019657600080fd5b50565b600081519050620001aa816200017f565b92915050565b60008060408385031215620001ca57620001c962000101565b5b6000620001da8582860162000154565b9250506020620001ed8582860162000199565b9150509250929050565b610a5b80620002076000396000f3fe608060405234801561001057600080fd5b506004361061009a576000357c0100000000000000000000000000000000000000000000000000000000900480633ef25013116100785780633ef250131461011b5780638da5cb5b1461014b578063bdd5544014610169578063f2fde38b146101855761009a565b806301ffc9a71461009f57806323778613146100cf57806336db43b5146100ff575b600080fd5b6100b960048036038101906100b49190610738565b6101b5565b6040516100c69190610780565b60405180910390f35b6100e960048036038101906100e491906107f9565b610309565b6040516100f69190610852565b60405180910390f35b61011960048036038101906101149190610899565b6103cd565b005b610135600480360381019061013091906108d9565b6103dc565b6040516101429190610780565b60405180910390f35b6101536104c3565b6040516101609190610915565b60405180910390f35b610183600480360381019061017e9190610930565b6104e7565b005b61019f600480360381019061019a91906108d9565b610599565b6040516101ac9190610780565b60405180910390f35b60006301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036102095760019050610304565b633ef250137c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361025b5760019050610304565b63237786137c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036102ad5760019050610304565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036102ff5760019050610304565b600090505b919050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632377861384846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401610384929190610983565b602060405180830381865afa1580156103a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103c591906109c1565b905092915050565b6103d88233836104e7565b5050565b600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632377861384600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518363ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040161047a929190610983565b602060405180830381865afa158015610497573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104bb91906109c1565b119050919050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663bdd554408484846040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401610562939291906109ee565b600060405180830381600087803b15801561057c57600080fd5b505af1158015610590573d6000803e3d6000fd5b50505050505050565b60008060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146105f457600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050826000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36001915050919050565b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610715816106e0565b811461072057600080fd5b50565b6000813590506107328161070c565b92915050565b60006020828403121561074e5761074d6106db565b5b600061075c84828501610723565b91505092915050565b60008115159050919050565b61077a81610765565b82525050565b60006020820190506107956000830184610771565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006107c68261079b565b9050919050565b6107d6816107bb565b81146107e157600080fd5b50565b6000813590506107f3816107cd565b92915050565b600080604083850312156108105761080f6106db565b5b600061081e858286016107e4565b925050602061082f858286016107e4565b9150509250929050565b6000819050919050565b61084c81610839565b82525050565b60006020820190506108676000830184610843565b92915050565b61087681610839565b811461088157600080fd5b50565b6000813590506108938161086d565b92915050565b600080604083850312156108b0576108af6106db565b5b60006108be858286016107e4565b92505060206108cf85828601610884565b9150509250929050565b6000602082840312156108ef576108ee6106db565b5b60006108fd848285016107e4565b91505092915050565b61090f816107bb565b82525050565b600060208201905061092a6000830184610906565b92915050565b600080600060608486031215610949576109486106db565b5b6000610957868287016107e4565b9350506020610968868287016107e4565b925050604061097986828701610884565b9150509250925092565b60006040820190506109986000830185610906565b6109a56020830184610906565b9392505050565b6000815190506109bb8161086d565b92915050565b6000602082840312156109d7576109d66106db565b5b60006109e5848285016109ac565b91505092915050565b6000606082019050610a036000830186610906565b610a106020830185610906565b610a1d6040830184610843565b94935050505056fea2646970667358221220dc667a5b0e9e0a550b8a205f4d150d6658abf72dfea71a87a8b2f7042c9ad81264736f6c63430008130033
+\ No newline at end of file
diff --git a/python/erc20_limiter/data/LimiterIndex.json b/python/erc20_limiter/data/LimiterIndex.json
@@ -1 +1 @@
-[{"inputs":[{"internalType":"address","name":"_holder","type":"address"},{"internalType":"contract Limiter","name":"_limiter","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"have","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_holder","type":"address"}],"name":"limitOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"setLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_holder","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"setLimitFor","outputs":[],"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":"_holder","type":"address"},{"internalType":"contract Limiter","name":"_limiter","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"have","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_holder","type":"address"}],"name":"limitOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"setLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_holder","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"setLimitFor","outputs":[],"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/erc20_limiter/data/LimiterIndex.metadata.json b/python/erc20_limiter/data/LimiterIndex.metadata.json
@@ -1 +1 @@
-{"compiler":{"version":"0.8.19+commit.7dd6d404"},"language":"Solidity","output":{"abi":[{"inputs":[{"internalType":"address","name":"_holder","type":"address"},{"internalType":"contract Limiter","name":"_limiter","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"have","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_holder","type":"address"}],"name":"limitOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"setLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_holder","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"setLimitFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_sum","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"}],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"compilationTarget":{"LimiterIndex.sol":"LimiterTokenRegistry"},"evmVersion":"byzantium","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":false,"runs":200},"remappings":[]},"sources":{"LimiterIndex.sol":{"keccak256":"0x8bc7716c5a8b9d698a4f8571a89b4da77c790d5d17f6f5e0f83f31fe6faef649","license":"AGPL-3.0-or-later","urls":["bzz-raw://4135e14e8203ca39fc809c7505222686b61dee82362fd3eb0f295b61bb44182a","dweb:/ipfs/Qmf5bCwu61UAK9atMghHbZJC88tfq2X43UDwq2nxeExDZR"]}},"version":1}
+{"compiler":{"version":"0.8.19+commit.7dd6d404"},"language":"Solidity","output":{"abi":[{"inputs":[{"internalType":"address","name":"_holder","type":"address"},{"internalType":"contract Limiter","name":"_limiter","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"have","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_holder","type":"address"}],"name":"limitOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"setLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_holder","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"setLimitFor","outputs":[],"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":{"LimiterIndex.sol":"LimiterTokenRegistry"},"evmVersion":"byzantium","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":false,"runs":200},"remappings":[]},"sources":{"LimiterIndex.sol":{"keccak256":"0x9fd0c38e85af9b5c270c9fd05289279487a4d23b7df0a69d58d04cce7cc96b12","license":"AGPL-3.0-or-later","urls":["bzz-raw://b1e085fc05ff9b23e74cbda4cee4f8c69153d9737601ae1735c443735e2bc1d4","dweb:/ipfs/QmbqZmpnped8P1NgiMcTX8tCH9foN1rNDBKSdWL2o9r8Hd"]}},"version":1}
diff --git a/solidity/LimiterIndex.sol b/solidity/LimiterIndex.sol
@@ -12,10 +12,16 @@ interface Limiter {
}
contract LimiterTokenRegistry {
+ address public owner;
Limiter limiter;
address holder;
+ // Implements EIP173
+ event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); // EIP173
+
+
constructor(address _holder, Limiter _limiter) {
+ owner = msg.sender;
holder = _holder;
limiter = _limiter;
}
@@ -32,20 +38,36 @@ contract LimiterTokenRegistry {
limiter.setLimitFor(_token, _holder, _value);
}
+ // Implements ACL
function have(address _token) public view returns(bool) {
return limiter.limitOf(_token, holder) > 0;
}
+ // Implements EIP173
+ function transferOwnership(address _newOwner) public returns (bool) {
+ address oldOwner;
+
+ require(msg.sender == owner);
+ oldOwner = owner;
+ owner = _newOwner;
+
+ emit OwnershipTransferred(oldOwner, owner);
+ return true;
+ }
+
function supportsInterface(bytes4 _sum) public pure returns (bool) {
if (_sum == 0x01ffc9a7) { // ERC165
return true;
}
- if (_sum == 0xb7bca625) { // AccountsIndex
+ if (_sum == 0x3ef25013) { // ACL
return true;
}
if (_sum == 0x23778613) { // TokenLimit
return true;
}
+ if (_sum == 0x9493f8b2) { // ERC173
+ return true;
+ }
return false;
}
}