commit fb79808354134f5fb71bbc497c381272d57b3433
parent 8c033e056ed3862c4085d24fe97ca1cee1df1a8d
Author: lash <dev@holbrook.no>
Date: Thu, 3 Aug 2023 16:52:08 +0100
Add readme
Diffstat:
7 files changed, 59 insertions(+), 8 deletions(-)
diff --git a/README.md b/README.md
@@ -0,0 +1,47 @@
+# erc20-limiter
+
+These smart contract implementations define value limits for tokens by holders.
+
+The contracts satisfy the [CIC TokenLimit](https://git.grassecon.net/cicnet/cic-contracts/#tokenlimit) interface.
+
+
+## Defining limits
+
+The `setLimit(token, value)` method set the limit of `token` that the transaction signer will accept to `value`.
+
+Values are _inclusive_; if `42` is returned, a balance up to and including `42` should be approved.
+
+A limit of `0` means that the "holder" will categorically not accept a token.
+
+
+### Defining limits for others
+
+An alternative `setLimitFor(token, holder, value)` method exists, where the contract `owner` may change the limit for a _smart contract_.
+
+If smart contract capable of transacting against this method itself does so, the result is the same as if that contract called `setLimit()`.
+
+The `owner` for the contract defined and managed according to the [ERC173](https://eips.ethereum.org/EIPS/eip-173) standard.
+
+
+## Honoring limits
+
+Limits will only be honored if integrated into the proper context.
+
+One example of context is to implement a limit check in the `transfer` and `transferFrom` methods of ERC20 tokens.
+
+
+## ACL Index variant
+
+The `LimitIndex.sol` contract variant includes an implementation of the [CIC ACL](https://git.grassecon.net/cicnet/cic-contracts/#acl) interface.
+
+In this case, any non-zero limit of a token for a holder results in a `true` value being returned. Otherwise, `false` is returned.
+
+The `LimitIndex.sol` contract takes a regular `Limit.sol` token address as argument, or more specifically a contract that satisfies this interface:
+
+```
+interface Limiter {
+ function limitOf(address,address) external view returns(uint256);
+ function setLimit(address,uint256) external;
+ function setLimitFor(address,address,uint256) external;
+}
+```
diff --git a/python/erc20_limiter/data/Limiter.bin b/python/erc20_limiter/data/Limiter.bin
@@ -1 +1 @@
-608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610983806100606000396000f3fe608060405234801561001057600080fd5b506004361061007f576000357c01000000000000000000000000000000000000000000000000000000009004806301ffc9a71461008457806323778613146100b457806336db43b5146100e45780638da5cb5b14610100578063bdd554401461011e578063f2fde38b1461013a575b600080fd5b61009e60048036038101906100999190610685565b61016a565b6040516100ab91906106cd565b60405180910390f35b6100ce60048036038101906100c99190610746565b61026c565b6040516100db919061079f565b60405180910390f35b6100fe60048036038101906100f991906107e6565b6102f3565b005b610108610378565b6040516101159190610835565b60405180910390f35b61013860048036038101906101339190610850565b61039c565b005b610154600480360381019061014f91906108a3565b6104e6565b60405161016191906106cd565b60405180910390f35b60006301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036101be5760019050610267565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036102105760019050610267565b63237786137c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036102625760019050610267565b600090505b919050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b80600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061042157508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610460576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104579061092d565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b60008060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461054157600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050826000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36001915050919050565b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6106628161062d565b811461066d57600080fd5b50565b60008135905061067f81610659565b92915050565b60006020828403121561069b5761069a610628565b5b60006106a984828501610670565b91505092915050565b60008115159050919050565b6106c7816106b2565b82525050565b60006020820190506106e260008301846106be565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610713826106e8565b9050919050565b61072381610708565b811461072e57600080fd5b50565b6000813590506107408161071a565b92915050565b6000806040838503121561075d5761075c610628565b5b600061076b85828601610731565b925050602061077c85828601610731565b9150509250929050565b6000819050919050565b61079981610786565b82525050565b60006020820190506107b46000830184610790565b92915050565b6107c381610786565b81146107ce57600080fd5b50565b6000813590506107e0816107ba565b92915050565b600080604083850312156107fd576107fc610628565b5b600061080b85828601610731565b925050602061081c858286016107d1565b9150509250929050565b61082f81610708565b82525050565b600060208201905061084a6000830184610826565b92915050565b60008060006060848603121561086957610868610628565b5b600061087786828701610731565b935050602061088886828701610731565b9250506040610899868287016107d1565b9150509250925092565b6000602082840312156108b9576108b8610628565b5b60006108c784828501610731565b91505092915050565b600082825260208201905092915050565b7f4552525f41585800000000000000000000000000000000000000000000000000600082015250565b60006109176007836108d0565b9150610922826108e1565b602082019050919050565b600060208201905081810360008301526109468161090a565b905091905056fea2646970667358221220ae88dd476f4b24adfae68410611cc64e22e747c3dd822fa91011f5db46a9161e64736f6c63430008130033
-\ No newline at end of file
+608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610a3a806100606000396000f3fe608060405234801561001057600080fd5b506004361061007f576000357c01000000000000000000000000000000000000000000000000000000009004806301ffc9a71461008457806323778613146100b457806336db43b5146100e45780638da5cb5b14610100578063bdd554401461011e578063f2fde38b1461013a575b600080fd5b61009e600480360381019061009991906106d0565b61016a565b6040516100ab9190610718565b60405180910390f35b6100ce60048036038101906100c99190610791565b61026c565b6040516100db91906107ea565b60405180910390f35b6100fe60048036038101906100f99190610831565b6102f3565b005b610108610378565b6040516101159190610880565b60405180910390f35b6101386004803603810190610133919061089b565b61039c565b005b610154600480360381019061014f91906108ee565b610531565b6040516101619190610718565b60405180910390f35b60006301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036101be5760019050610267565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036102105760019050610267565b63237786137c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036102625760019050610267565b600090505b919050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b80600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061042457508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610463576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161045a90610978565b60405180910390fd5b823b9050600081116104aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104a1906109e4565b60405180910390fd5b81600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555050505050565b60008060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461058c57600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050826000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36001915050919050565b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6106ad81610678565b81146106b857600080fd5b50565b6000813590506106ca816106a4565b92915050565b6000602082840312156106e6576106e5610673565b5b60006106f4848285016106bb565b91505092915050565b60008115159050919050565b610712816106fd565b82525050565b600060208201905061072d6000830184610709565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061075e82610733565b9050919050565b61076e81610753565b811461077957600080fd5b50565b60008135905061078b81610765565b92915050565b600080604083850312156107a8576107a7610673565b5b60006107b68582860161077c565b92505060206107c78582860161077c565b9150509250929050565b6000819050919050565b6107e4816107d1565b82525050565b60006020820190506107ff60008301846107db565b92915050565b61080e816107d1565b811461081957600080fd5b50565b60008135905061082b81610805565b92915050565b6000806040838503121561084857610847610673565b5b60006108568582860161077c565b92505060206108678582860161081c565b9150509250929050565b61087a81610753565b82525050565b60006020820190506108956000830184610871565b92915050565b6000806000606084860312156108b4576108b3610673565b5b60006108c28682870161077c565b93505060206108d38682870161077c565b92505060406108e48682870161081c565b9150509250925092565b60006020828403121561090457610903610673565b5b60006109128482850161077c565b91505092915050565b600082825260208201905092915050565b7f4552525f41585800000000000000000000000000000000000000000000000000600082015250565b600061096260078361091b565b915061096d8261092c565b602082019050919050565b6000602082019050818103600083015261099181610955565b9050919050565b7f4552525f4143434f554e54000000000000000000000000000000000000000000600082015250565b60006109ce600b8361091b565b91506109d982610998565b602082019050919050565b600060208201905081810360008301526109fd816109c1565b905091905056fea2646970667358221220bfbd3dc4c68c3de06c71999bd996ad177fed19a8220f8c83e606cc8291101fe264736f6c63430008130033
+\ No newline at end of file
diff --git a/python/erc20_limiter/data/Limiter.metadata.json b/python/erc20_limiter/data/Limiter.metadata.json
@@ -1 +1 @@
-{"compiler":{"version":"0.8.19+commit.7dd6d404"},"language":"Solidity","output":{"abi":[{"inputs":[],"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"},{"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":{"Limiter.sol":"Limiter"},"evmVersion":"byzantium","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":false,"runs":200},"remappings":[]},"sources":{"Limiter.sol":{"keccak256":"0xe75d2e061598eaa9bbcb16988fdfa5529bf389ca4e3c0e882dcb410b740c6e99","license":"AGPL-3.0-or-later","urls":["bzz-raw://e19eb2419d10a285b95dbcccc4405d36917f199048e5b32d14c1539c1638933a","dweb:/ipfs/QmZ4haakZYs8LbC9ZxMqGnfa8PrWGp1H4rLtC1rFKG5miS"]}},"version":1}
+{"compiler":{"version":"0.8.19+commit.7dd6d404"},"language":"Solidity","output":{"abi":[{"inputs":[],"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"},{"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":{"Limiter.sol":"Limiter"},"evmVersion":"byzantium","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":false,"runs":200},"remappings":[]},"sources":{"Limiter.sol":{"keccak256":"0x12883f46af450e37bdea27719f8bc194dff663000a2aea7354b0b0a50bc2b8f3","license":"AGPL-3.0-or-later","urls":["bzz-raw://56753e2ca5ae015eb021a214e2325197618a49181a514cfb5383b9dbcd403829","dweb:/ipfs/QmZWQ3Aw8kjYo7v3Nu68HWQpadBA1iqHzM2NJpbAVd97bh"]}},"version":1}
diff --git a/python/erc20_limiter/data/LimiterIndex.bin b/python/erc20_limiter/data/LimiterIndex.bin
@@ -1 +1 @@
-60806040523480156200001157600080fd5b5060405162000da338038062000da38339818101604052810190620000379190620001b0565b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050620001f7565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620001338262000106565b9050919050565b620001458162000126565b81146200015157600080fd5b50565b60008151905062000165816200013a565b92915050565b6000620001788262000126565b9050919050565b6200018a816200016b565b81146200019657600080fd5b50565b600081519050620001aa816200017f565b92915050565b60008060408385031215620001ca57620001c962000101565b5b6000620001da8582860162000154565b9250506020620001ed8582860162000199565b9150509250929050565b610b9c80620002076000396000f3fe608060405234801561001057600080fd5b506004361061009a576000357c0100000000000000000000000000000000000000000000000000000000900480633ef25013116100785780633ef250131461011b5780638da5cb5b1461014b578063bdd5544014610169578063f2fde38b146101855761009a565b806301ffc9a71461009f57806323778613146100cf57806336db43b5146100ff575b600080fd5b6100b960048036038101906100b491906107fc565b6101b5565b6040516100c69190610844565b60405180910390f35b6100e960048036038101906100e491906108bd565b610309565b6040516100f69190610916565b60405180910390f35b6101196004803603810190610114919061095d565b6103cd565b005b6101356004803603810190610130919061099d565b6103dc565b6040516101429190610844565b60405180910390f35b6101536104c3565b60405161016091906109d9565b60405180910390f35b610183600480360381019061017e91906109f4565b6104e7565b005b61019f600480360381019061019a919061099d565b61065d565b6040516101ac9190610844565b60405180910390f35b60006301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036102095760019050610304565b633ef250137c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361025b5760019050610304565b63237786137c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036102ad5760019050610304565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036102ff5760019050610304565b600090505b919050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632377861384846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401610384929190610a47565b602060405180830381865afa1580156103a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103c59190610a85565b905092915050565b6103d88233836104e7565b5050565b600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632377861384600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518363ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040161047a929190610a47565b602060405180830381865afa158015610497573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104bb9190610a85565b119050919050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061056c57508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b6105ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105a290610b0f565b60405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663bdd554408484846040518463ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040161062693929190610b2f565b600060405180830381600087803b15801561064057600080fd5b505af1158015610654573d6000803e3d6000fd5b50505050505050565b60008060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146106b857600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050826000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36001915050919050565b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6107d9816107a4565b81146107e457600080fd5b50565b6000813590506107f6816107d0565b92915050565b6000602082840312156108125761081161079f565b5b6000610820848285016107e7565b91505092915050565b60008115159050919050565b61083e81610829565b82525050565b60006020820190506108596000830184610835565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061088a8261085f565b9050919050565b61089a8161087f565b81146108a557600080fd5b50565b6000813590506108b781610891565b92915050565b600080604083850312156108d4576108d361079f565b5b60006108e2858286016108a8565b92505060206108f3858286016108a8565b9150509250929050565b6000819050919050565b610910816108fd565b82525050565b600060208201905061092b6000830184610907565b92915050565b61093a816108fd565b811461094557600080fd5b50565b60008135905061095781610931565b92915050565b600080604083850312156109745761097361079f565b5b6000610982858286016108a8565b925050602061099385828601610948565b9150509250929050565b6000602082840312156109b3576109b261079f565b5b60006109c1848285016108a8565b91505092915050565b6109d38161087f565b82525050565b60006020820190506109ee60008301846109ca565b92915050565b600080600060608486031215610a0d57610a0c61079f565b5b6000610a1b868287016108a8565b9350506020610a2c868287016108a8565b9250506040610a3d86828701610948565b9150509250925092565b6000604082019050610a5c60008301856109ca565b610a6960208301846109ca565b9392505050565b600081519050610a7f81610931565b92915050565b600060208284031215610a9b57610a9a61079f565b5b6000610aa984828501610a70565b91505092915050565b600082825260208201905092915050565b7f4552525f41585800000000000000000000000000000000000000000000000000600082015250565b6000610af9600783610ab2565b9150610b0482610ac3565b602082019050919050565b60006020820190508181036000830152610b2881610aec565b9050919050565b6000606082019050610b4460008301866109ca565b610b5160208301856109ca565b610b5e6040830184610907565b94935050505056fea264697066735822122016fb852dceb2839c2b2f07f6501f25abb0abe053c45719851c3cf41248c044d164736f6c63430008130033
-\ No newline at end of file
+60806040523480156200001157600080fd5b5060405162000c6238038062000c628339818101604052810190620000379190620001b0565b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050620001f7565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620001338262000106565b9050919050565b620001458162000126565b81146200015157600080fd5b50565b60008151905062000165816200013a565b92915050565b6000620001788262000126565b9050919050565b6200018a816200016b565b81146200019657600080fd5b50565b600081519050620001aa816200017f565b92915050565b60008060408385031215620001ca57620001c962000101565b5b6000620001da8582860162000154565b9250506020620001ed8582860162000199565b9150509250929050565b610a5b80620002076000396000f3fe608060405234801561001057600080fd5b506004361061009a576000357c0100000000000000000000000000000000000000000000000000000000900480633ef25013116100785780633ef250131461011b5780638da5cb5b1461014b578063bdd5544014610169578063f2fde38b146101855761009a565b806301ffc9a71461009f57806323778613146100cf57806336db43b5146100ff575b600080fd5b6100b960048036038101906100b49190610738565b6101b5565b6040516100c69190610780565b60405180910390f35b6100e960048036038101906100e491906107f9565b610309565b6040516100f69190610852565b60405180910390f35b61011960048036038101906101149190610899565b6103cd565b005b610135600480360381019061013091906108d9565b6103dc565b6040516101429190610780565b60405180910390f35b6101536104c3565b6040516101609190610915565b60405180910390f35b610183600480360381019061017e9190610930565b6104e7565b005b61019f600480360381019061019a91906108d9565b610599565b6040516101ac9190610780565b60405180910390f35b60006301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036102095760019050610304565b633ef250137c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361025b5760019050610304565b63237786137c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036102ad5760019050610304565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036102ff5760019050610304565b600090505b919050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632377861384846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401610384929190610983565b602060405180830381865afa1580156103a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103c591906109c1565b905092915050565b6103d88233836104e7565b5050565b600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632377861384600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518363ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040161047a929190610983565b602060405180830381865afa158015610497573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104bb91906109c1565b119050919050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663bdd554408484846040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401610562939291906109ee565b600060405180830381600087803b15801561057c57600080fd5b505af1158015610590573d6000803e3d6000fd5b50505050505050565b60008060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146105f457600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050826000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36001915050919050565b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610715816106e0565b811461072057600080fd5b50565b6000813590506107328161070c565b92915050565b60006020828403121561074e5761074d6106db565b5b600061075c84828501610723565b91505092915050565b60008115159050919050565b61077a81610765565b82525050565b60006020820190506107956000830184610771565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006107c68261079b565b9050919050565b6107d6816107bb565b81146107e157600080fd5b50565b6000813590506107f3816107cd565b92915050565b600080604083850312156108105761080f6106db565b5b600061081e858286016107e4565b925050602061082f858286016107e4565b9150509250929050565b6000819050919050565b61084c81610839565b82525050565b60006020820190506108676000830184610843565b92915050565b61087681610839565b811461088157600080fd5b50565b6000813590506108938161086d565b92915050565b600080604083850312156108b0576108af6106db565b5b60006108be858286016107e4565b92505060206108cf85828601610884565b9150509250929050565b6000602082840312156108ef576108ee6106db565b5b60006108fd848285016107e4565b91505092915050565b61090f816107bb565b82525050565b600060208201905061092a6000830184610906565b92915050565b600080600060608486031215610949576109486106db565b5b6000610957868287016107e4565b9350506020610968868287016107e4565b925050604061097986828701610884565b9150509250925092565b60006040820190506109986000830185610906565b6109a56020830184610906565b9392505050565b6000815190506109bb8161086d565b92915050565b6000602082840312156109d7576109d66106db565b5b60006109e5848285016109ac565b91505092915050565b6000606082019050610a036000830186610906565b610a106020830185610906565b610a1d6040830184610843565b94935050505056fea2646970667358221220dc667a5b0e9e0a550b8a205f4d150d6658abf72dfea71a87a8b2f7042c9ad81264736f6c63430008130033
+\ No newline at end of file
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"},{"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":"0xf75e17753d0aa896c0a2c134e4a8c3e4b14aaa86482323bb6add99f455f72a92","license":"AGPL-3.0-or-later","urls":["bzz-raw://6ff6dfefb6c0e6c99e57eaebf43668fc861292765299d8ee01d55ea6e49843c7","dweb:/ipfs/QmTXMTnMuieiZwE1CPDD1MLHwY3JVyCwPwJ4xuuBVcUC5G"]}},"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/Limiter.sol b/solidity/Limiter.sol
@@ -26,7 +26,12 @@ contract Limiter {
}
function setLimitFor(address _token, address _holder, uint256 _value) public {
- require(msg.sender == owner || msg.sender == _holder, 'ERR_AXX');
+ uint256 sz;
+ require(msg.sender == owner || msg.sender == _holder, 'ERR_AXX');
+ assembly {
+ sz := extcodesize(_holder)
+ }
+ require(sz > 0, 'ERR_ACCOUNT');
limit[_token][_holder] = _value;
}
diff --git a/solidity/LimiterIndex.sol b/solidity/LimiterIndex.sol
@@ -35,7 +35,6 @@ contract LimiterTokenRegistry {
}
function setLimitFor(address _token, address _holder, uint256 _value) public {
- require(msg.sender == owner || msg.sender == _holder, 'ERR_AXX');
limiter.setLimitFor(_token, _holder, _value);
}