commit 1df3b031fda7b3d63dad015cfe42bd7b06ea0589
parent 191b6611fe542ab5cf299dff80ee6e525c072b47
Author: nolash <dev@holbrook.no>
Date: Fri, 1 Jan 2021 19:44:38 +0100
Enable chronological access even when processed out of order
Diffstat:
8 files changed, 183 insertions(+), 41 deletions(-)
diff --git a/python/erc20_approval_escrow/data/GiftableToken.abi.json b/python/erc20_approval_escrow/data/GiftableToken.json
diff --git a/python/erc20_approval_escrow/data/TransferApproval.bin b/python/erc20_approval_escrow/data/TransferApproval.bin
@@ -1 +1 @@
-608060405234801561001057600080fd5b50604051610f54380380610f548339818101604052602081101561003357600080fd5b810190808051604051939291908464010000000082111561005357600080fd5b8382019150602082018581111561006957600080fd5b825186602082028301116401000000008211171561008657600080fd5b8083526020830192505050908051906020019060200280838360005b838110156100bd5780820151818401526020810190506100a2565b5050505090500160405250505060005b815181101561014e576001600260008484815181106100e857fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806001019150506100cd565b50600160008190555050610ded806101676000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c80630a144391146100675780636c355091146100c157806381d12c5814610143578063b8adaa11146101e3578063f6d713dd14610227578063fe0d94c114610245575b600080fd5b6100a96004803603602081101561007d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610289565b60405180821515815260200191505060405180910390f35b61012d600480360360608110156100d757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506102a9565b6040518082815260200191505060405180910390f35b61016f6004803603602081101561015957600080fd5b81019080803590602001909291905050506104b7565b604051808681526020018573ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019550505050505060405180910390f35b61020f600480360360208110156101f957600080fd5b810190808035906020019092919050505061054d565b60405180821515815260200191505060405180910390f35b61022f61097f565b6040518082815260200191505060405180910390f35b6102716004803603602081101561025b57600080fd5b8101908080359060200190929190505050610985565b60405180821515815260200191505060405180910390f35b60026020528060005260406000206000915054906101000a900460ff1681565b600080600160008054815260200190815260200160002090506000548160000181905550848160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550338160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550838160030160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082816004018190555060008081548092919060010191905055508060030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168160020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168260010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fb609ae609609ee99268d05bc1371102cafe8d6b964bf082439ab16be2a01c87c84600401548560000154604051808381526020018281526020019250505060405180910390a480600001549150509392505050565b60016020528060005260406000206000915090508060000154908060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060040154905085565b6000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661060e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600d8152602001807f4552525f4e4f5f4143434553530000000000000000000000000000000000000081525060200191505060405180910390fd5b6000600160008481526020019081526020016000209050600081600001541161069f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f4552525f494e56414c49445f524551554553540000000000000000000000000081525060200191505060405180910390fd5b600060608260030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168360010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168460010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168560040154604051602401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200193505050506040516020818303038152906040527f23b872dd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040518082805190602001908083835b602083106108275780518252602082019150602081019050602083039250610804565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610889576040519150601f19603f3d011682016040523d82523d6000602084013e61088e565b606091505b50915091508161089a57fe5b7f607c56ea76669e46679e89091227c1a3f91841a4cf7588d5a6c84555fb59fdfd83600001546040518082815260200191505060405180910390a160016000846000015481526020019081526020016000206000808201600090556001820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556002820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556003820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905560048201600090555050819350505050919050565b60005481565b6000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610a46576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600d8152602001807f4552525f4e4f5f4143434553530000000000000000000000000000000000000081525060200191505060405180910390fd5b60006001600084815260200190815260200160002090506000816000015411610ad7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f4552525f494e56414c49445f524551554553540000000000000000000000000081525060200191505060405180910390fd5b600060608260030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168360010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168460020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168560040154604051602401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200193505050506040516020818303038152906040527f23b872dd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040518082805190602001908083835b60208310610c5f5780518252602082019150602081019050602083039250610c3c565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610cc1576040519150601f19603f3d011682016040523d82523d6000602084013e610cc6565b606091505b509150915081610cd257fe5b7fa445ec1ee84565906bc8646dcb62f6d1a75fc7a782a03e72220fb97f60ba89ab83600001546040518082815260200191505060405180910390a160016000846000015481526020019081526020016000206000808201600090556001820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556002820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556003820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556004820160009055505081935050505091905056fea264697066735822122027854a054b06dcbba643ec3336be99a459dab354eee6bab60354f36d6e9f233464736f6c63430007050033
-\ No newline at end of file
+60806040523480156200001157600080fd5b5060405162001755380380620017558339818101604052810190620000379190620001c3565b60005b8151811015620000f35760016004600084848151811062000084577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080620000ea90620002a9565b9150506200003a565b50600180819055506001600281905550506200036f565b6000620001216200011b846200023c565b62000208565b905080838252602082019050828560208602820111156200014157600080fd5b60005b858110156200017557816200015a88826200017f565b84526020840193506020830192505060018101905062000144565b5050509392505050565b600081519050620001908162000355565b92915050565b600082601f830112620001a857600080fd5b8151620001ba8482602086016200010a565b91505092915050565b600060208284031215620001d657600080fd5b600082015167ffffffffffffffff811115620001f157600080fd5b620001ff8482850162000196565b91505092915050565b6000604051905081810181811067ffffffffffffffff8211171562000232576200023162000326565b5b8060405250919050565b600067ffffffffffffffff8211156200025a576200025962000326565b5b602082029050602081019050919050565b600062000278826200027f565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000620002b6826200029f565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415620002ec57620002eb620002f7565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b62000360816200026b565b81146200036c57600080fd5b50565b6113d6806200037f6000396000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c80636e417c69116100665780636e417c691461015d5780637780c14f1461018d57806381d12c58146101ab578063b0addede146101df578063bac911ac1461020f5761009e565b806306661abd146100a357806308ae6377146100c15780630a144391146100df5780632d7788db1461010f57806357ec347a1461013f575b600080fd5b6100ab61023f565b6040516100b89190611163565b60405180910390f35b6100c9610245565b6040516100d69190611163565b60405180910390f35b6100f960048036038101906100f49190610f3b565b610270565b6040516101069190611108565b60405180910390f35b61012960048036038101906101249190610fb3565b610290565b6040516101369190611108565b60405180910390f35b610147610585565b6040516101549190611163565b60405180910390f35b61017760048036038101906101729190610fb3565b61059a565b6040516101849190611108565b60405180910390f35b6101956108c3565b6040516101a29190611163565b60405180910390f35b6101c560048036038101906101c09190610fb3565b6108c9565b6040516101d695949392919061117e565b60405180910390f35b6101f960048036038101906101f49190610f64565b61095f565b6040516102069190611163565b60405180910390f35b61022960048036038101906102249190610fb3565b610bf9565b6040516102369190611163565b60405180910390f35b60035481565b6000806002546001546102589190611221565b1415610267576000905061026d565b60025490505b90565b60046020528060005260406000206000915054906101000a900460ff1681565b6000600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661031e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161031590611123565b60405180910390fd5b60008060008481526020019081526020016000209050600081600001541161037b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161037290611143565b60405180910390fd5b6000808260030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168360010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168460010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16856004015460405160240161041a939291906110d1565b6040516020818303038152906040527f23b872dd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516104a491906110ba565b6000604051808303816000865af19150503d80600081146104e1576040519150601f19603f3d011682016040523d82523d6000602084013e6104e6565b606091505b50915091506104f88360000154610d98565b811561053e577f607c56ea76669e46679e89091227c1a3f91841a4cf7588d5a6c84555fb59fdfd83600001546040516105319190611163565b60405180910390a161057a565b7fdab20a0fcd702cf875c2d715d5c3fc99af66a716c94b3405408c94b7311c99eb83600001546040516105719190611163565b60405180910390a15b819350505050919050565b6000600180546105959190611221565b905090565b6000600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610628576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161061f90611123565b60405180910390fd5b600080600084815260200190815260200160002090506000816000015411610685576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161067c90611143565b60405180910390fd5b6000808260030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168360010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168460020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168560040154604051602401610724939291906110d1565b6040516020818303038152906040527f23b872dd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516107ae91906110ba565b6000604051808303816000865af19150503d80600081146107eb576040519150601f19603f3d011682016040523d82523d6000602084013e6107f0565b606091505b509150915081610829577f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b6108368360000154610d98565b811561087c577f607c56ea76669e46679e89091227c1a3f91841a4cf7588d5a6c84555fb59fdfd836000015460405161086f9190611163565b60405180910390a16108b8565b7fdab20a0fcd702cf875c2d715d5c3fc99af66a716c94b3405408c94b7311c99eb83600001546040516108af9190611163565b60405180910390a15b819350505050919050565b60025481565b60006020528060005260406000206000915090508060000154908060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060040154905085565b6000610969610ea0565b60015481600001818152505084816040019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505033816020019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505083816060019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050828160800181815250508060008060015481526020019081526020016000206000820151816000015560208201518160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060608201518160030160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506080820151816004015590505060036000815480929190610b3b906112fa565b919050555060016000815480929190610b53906112fa565b9190505550806060015173ffffffffffffffffffffffffffffffffffffffff16816040015173ffffffffffffffffffffffffffffffffffffffff16826020015173ffffffffffffffffffffffffffffffffffffffff167fb609ae609609ee99268d05bc1371102cafe8d6b964bf082439ab16be2a01c87c84608001518560000151604051610be29291906111d1565b60405180910390a480600001519150509392505050565b600080600060025490505b600154811015610d8c5760008060008381526020019081526020016000206040518060a0016040529081600082015481526020016001820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016003820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016004820154815250509050600081600001511115610d785784831415610d695780600001519350505050610d93565b8280610d74906112fa565b9350505b508080610d84906112fa565b915050610c04565b5060009150505b919050565b6000808281526020019081526020016000206000808201600090556001820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556002820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556003820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556004820160009055505060036000815480929190610e45906112d0565b919050555060006003541115610e9357600254811415610e8e576000610e6b6000610bf9565b90506000811415610e8457600154600281905550610e8c565b806002819055505b505b610e9d565b6001546002819055505b50565b6040518060a0016040528060008152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600081525090565b600081359050610f2081611372565b92915050565b600081359050610f3581611389565b92915050565b600060208284031215610f4d57600080fd5b6000610f5b84828501610f11565b91505092915050565b600080600060608486031215610f7957600080fd5b6000610f8786828701610f11565b9350506020610f9886828701610f11565b9250506040610fa986828701610f26565b9150509250925092565b600060208284031215610fc557600080fd5b6000610fd384828501610f26565b91505092915050565b610fe581611255565b82525050565b610ff481611267565b82525050565b6000611005826111fa565b61100f8185611205565b935061101f81856020860161129d565b80840191505092915050565b6000611038600d83611210565b91507f4552525f4e4f5f414343455353000000000000000000000000000000000000006000830152602082019050919050565b6000611078601383611210565b91507f4552525f494e56414c49445f52455155455354000000000000000000000000006000830152602082019050919050565b6110b481611293565b82525050565b60006110c68284610ffa565b915081905092915050565b60006060820190506110e66000830186610fdc565b6110f36020830185610fdc565b61110060408301846110ab565b949350505050565b600060208201905061111d6000830184610feb565b92915050565b6000602082019050818103600083015261113c8161102b565b9050919050565b6000602082019050818103600083015261115c8161106b565b9050919050565b600060208201905061117860008301846110ab565b92915050565b600060a08201905061119360008301886110ab565b6111a06020830187610fdc565b6111ad6040830186610fdc565b6111ba6060830185610fdc565b6111c760808301846110ab565b9695505050505050565b60006040820190506111e660008301856110ab565b6111f360208301846110ab565b9392505050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b600061122c82611293565b915061123783611293565b92508282101561124a57611249611343565b5b828203905092915050565b600061126082611273565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60005b838110156112bb5780820151818401526020810190506112a0565b838111156112ca576000848401525b50505050565b60006112db82611293565b915060008214156112ef576112ee611343565b5b600182039050919050565b600061130582611293565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561133857611337611343565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b61137b81611255565b811461138657600080fd5b50565b61139281611293565b811461139d57600080fd5b5056fea2646970667358221220d441a811b83873b5e6f885838296dc5de101a07165838838514de472d224d11f64736f6c63430008000033
+\ No newline at end of file
diff --git a/python/erc20_approval_escrow/data/TransferApproval.json b/python/erc20_approval_escrow/data/TransferApproval.json
@@ -1 +1 @@
-[{"inputs":[{"internalType":"address[]","name":"_approvers","type":"address[]"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"serial","type":"uint256"}],"name":"NewExecution","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"serial","type":"uint256"}],"name":"NewRejection","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_sender","type":"address"},{"indexed":true,"internalType":"address","name":"_recipient","type":"address"},{"indexed":true,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_serial","type":"uint256"}],"name":"NewRequest","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"approvers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_serial","type":"uint256"}],"name":"execute","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_serial","type":"uint256"}],"name":"reject","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"request","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"requests","outputs":[{"internalType":"uint256","name":"serial","type":"uint256"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"serial","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
+[{"inputs":[{"internalType":"address[]","name":"_approvers","type":"address[]"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"serial","type":"uint256"}],"name":"NewExecution","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"serial","type":"uint256"}],"name":"NewRejection","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_sender","type":"address"},{"indexed":true,"internalType":"address","name":"_recipient","type":"address"},{"indexed":true,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_serial","type":"uint256"}],"name":"NewRequest","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"serial","type":"uint256"}],"name":"TransferFail","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"approvers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"count","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"createRequest","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_serial","type":"uint256"}],"name":"executeRequest","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_idx","type":"uint256"}],"name":"getSerialAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastSerial","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lo","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextSerial","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_serial","type":"uint256"}],"name":"rejectRequest","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"requests","outputs":[{"internalType":"uint256","name":"serial","type":"uint256"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"stateMutability":"view","type":"function"}]
diff --git a/python/tests/test_app.py b/python/tests/test_app.py
@@ -25,11 +25,11 @@ class Test(unittest.TestCase):
'gas_limit': 9000000,
})
- f = open(os.path.join(testdir, '../erc20_approval_escrow/data/ERC20ApprovalEscrow.bin'), 'r')
+ f = open(os.path.join(testdir, '../erc20_approval_escrow/data/TransferApproval.bin'), 'r')
bytecode = f.read()
f.close()
- f = open(os.path.join(testdir, '../erc20_approval_escrow/data/ERC20ApprovalEscrow.abi.json'), 'r')
+ f = open(os.path.join(testdir, '../erc20_approval_escrow/data/TransferApproval.json'), 'r')
self.abi_wallet = json.load(f)
f.close()
@@ -49,7 +49,7 @@ class Test(unittest.TestCase):
bytecode = f.read()
f.close()
- f = open(os.path.join(testdir, '../erc20_approval_escrow/data/GiftableToken.abi.json'), 'r')
+ f = open(os.path.join(testdir, '../erc20_approval_escrow/data/GiftableToken.json'), 'r')
self.abi_token = json.load(f)
f.close()
@@ -64,6 +64,7 @@ class Test(unittest.TestCase):
tx_hash = c.functions.mint(1000).transact({'from': self.w3.eth.accounts[0]})
tx_hash = c.functions.transfer(self.w3.eth.accounts[1], 100).transact({'from': self.w3.eth.accounts[0]})
tx_hash = c.functions.transfer(self.w3.eth.accounts[2], 100).transact({'from': self.w3.eth.accounts[0]})
+ tx_hash = c.functions.transfer(self.w3.eth.accounts[4], 100).transact({'from': self.w3.eth.accounts[0]})
def tearDown(self):
@@ -76,11 +77,11 @@ class Test(unittest.TestCase):
self.assertFalse(c.functions.approvers(self.w3.eth.accounts[1]).call())
- def test_approval_missing(self):
+ def test_get(self):
w = self.w3.eth.contract(abi=self.abi_wallet, address=self.address_wallet)
t = self.w3.eth.contract(abi=self.abi_token, address=self.address_token)
- tx_hash = w.functions.request(self.w3.eth.accounts[3], t.address, 10).transact({'from': self.w3.eth.accounts[2]})
+ tx_hash = w.functions.createRequest(self.w3.eth.accounts[3], t.address, 10).transact({'from': self.w3.eth.accounts[2]})
r = self.w3.eth.getTransactionReceipt(tx_hash)
topic_match = 'b609ae609609ee99268d05bc1371102cafe8d6b964bf082439ab16be2a01c87c'
@@ -88,9 +89,38 @@ class Test(unittest.TestCase):
topic = log.topics[0]
self.assertEqual(topic.hex()[2:], topic_match)
serial = int(log.data[66:], 16)
- self.eth_tester.mine_block()
+
+ for i in range(1, 3):
+ tx_hash = w.functions.createRequest(self.w3.eth.accounts[3+i], t.address, 10*(i+1)).transact({'from': self.w3.eth.accounts[2]})
+
+ tq_count = w.functions.count().call()
+ assert (tq_count == 3);
+
+ for i in range(w.functions.nextSerial().call(), w.functions.lastSerial().call()):
+ tqg = w.functions.requests(i).call()
+
+ assert (tqg[0] == i)
+ assert (tqg[1] == self.w3.eth.accounts[2])
+ assert (tqg[2] == self.w3.eth.accounts[3+(i-1)])
+ assert (tqg[3] == t.address)
+ assert (tqg[4] == 10*i)
+
+
+
+ def test_approval_missing(self):
+ w = self.w3.eth.contract(abi=self.abi_wallet, address=self.address_wallet)
+ t = self.w3.eth.contract(abi=self.abi_token, address=self.address_token)
+
+ tx_hash = w.functions.createRequest(self.w3.eth.accounts[3], t.address, 10).transact({'from': self.w3.eth.accounts[2]})
+ r = self.w3.eth.getTransactionReceipt(tx_hash)
+
+ topic_match = 'b609ae609609ee99268d05bc1371102cafe8d6b964bf082439ab16be2a01c87c'
+ log = r.logs[0]
+ topic = log.topics[0]
+ serial = int(log.data[66:], 16)
- with self.assertRaises(eth_tester.exceptions.TransactionFailed):
+ #with self.assertRaises(eth_tester.exceptions.TransactionFailed):
+ with self.assertRaises(Exception):
w.functions.execute(serial).transact({'from': self.w3.eth.accounts[0]})
@@ -101,7 +131,7 @@ class Test(unittest.TestCase):
t.functions.approve(w.address, 10).transact({'from': self.w3.eth.accounts[2]})
self.eth_tester.mine_block()
- tx_hash = w.functions.request(self.w3.eth.accounts[3], t.address, 10).transact({'from': self.w3.eth.accounts[2]})
+ tx_hash = w.functions.createRequest(self.w3.eth.accounts[3], t.address, 10).transact({'from': self.w3.eth.accounts[2]})
r = self.w3.eth.getTransactionReceipt(tx_hash)
topic_match = 'b609ae609609ee99268d05bc1371102cafe8d6b964bf082439ab16be2a01c87c'
@@ -109,12 +139,12 @@ class Test(unittest.TestCase):
topic = log.topics[0]
self.assertEqual(topic.hex()[2:], topic_match)
serial = int(log.data[66:], 16)
- self.eth_tester.mine_block()
- with self.assertRaises(eth_tester.exceptions.TransactionFailed):
+ #with self.assertRaises(eth_tester.exceptions.TransactionFailed):
+ with self.assertRaises(Exception):
w.functions.execute(serial).transact({'from': self.w3.eth.accounts[3]})
- tx_hashh = w.functions.execute(serial).transact({'from': self.w3.eth.accounts[0]})
+ tx_hashh = w.functions.executeRequest(serial).transact({'from': self.w3.eth.accounts[0]})
r = self.w3.eth.getTransactionReceipt(tx_hashh)
self.assertEqual(t.functions.balanceOf(self.w3.eth.accounts[2]).call(), 90)
@@ -128,17 +158,16 @@ class Test(unittest.TestCase):
t.functions.approve(w.address, 10).transact({'from': self.w3.eth.accounts[2]})
self.eth_tester.mine_block()
- tx_hash = w.functions.request(self.w3.eth.accounts[3], t.address, 10).transact({'from': self.w3.eth.accounts[2]})
+ tx_hash = w.functions.createRequest(self.w3.eth.accounts[3], t.address, 10).transact({'from': self.w3.eth.accounts[2]})
r = self.w3.eth.getTransactionReceipt(tx_hash)
+
topic_match = 'b609ae609609ee99268d05bc1371102cafe8d6b964bf082439ab16be2a01c87c'
log = r.logs[0]
topic = log.topics[0]
- self.assertEqual(topic.hex()[2:], topic_match)
serial = int(log.data[66:], 16)
- self.eth_tester.mine_block()
-
- tx_hash = w.functions.reject(serial).transact({'from': self.w3.eth.accounts[0]})
+
+ tx_hash = w.functions.rejectRequest(serial).transact({'from': self.w3.eth.accounts[0]})
r = self.w3.eth.getTransactionReceipt(tx_hash)
self.assertEqual(t.functions.balanceOf(self.w3.eth.accounts[2]).call(), 100)
@@ -146,5 +175,52 @@ class Test(unittest.TestCase):
self.assertEqual(t.functions.allowances(self.w3.eth.accounts[2], w.address).call(), 0)
+ def test_index_after_removal(self):
+ w = self.w3.eth.contract(abi=self.abi_wallet, address=self.address_wallet)
+ t = self.w3.eth.contract(abi=self.abi_token, address=self.address_token)
+
+ for i in range(0, 4):
+ amount = 10*(i+1)
+ sender = self.w3.eth.accounts[3+i];
+ tx_hash = w.functions.createRequest(sender, t.address, amount).transact({'from': self.w3.eth.accounts[2]})
+ t.functions.approve(w.address, amount).transact({'from': sender})
+ self.eth_tester.mine_block()
+
+ tq_count = w.functions.count().call()
+ assert (tq_count == 4);
+ assert (w.functions.lastSerial().call() == 4)
+ assert (w.functions.nextSerial().call() == 1)
+
+ w.functions.rejectRequest(2).transact({'from': self.w3.eth.accounts[0]})
+ assert (w.functions.count(). call() == 3)
+ assert (w.functions.nextSerial().call() == 1)
+ assert (w.functions.lastSerial(). call() == 4)
+
+ w.functions.rejectRequest(1).transact({'from': self.w3.eth.accounts[0]})
+ assert (w.functions.count(). call() == 2)
+ assert (w.functions.nextSerial().call() == 3)
+ assert (w.functions.lastSerial(). call() == 4)
+
+ w.functions.createRequest(self.w3.eth.accounts[3], t.address, 42).transact({'from': self.w3.eth.accounts[2]})
+ assert (w.functions.count(). call() == 3)
+ assert (w.functions.lastSerial(). call() == 5)
+ assert (w.functions.nextSerial(). call() == 3)
+
+ w.functions.rejectRequest(3).transact({'from': self.w3.eth.accounts[0]})
+ assert (w.functions.count(). call() == 2)
+ assert (w.functions.lastSerial(). call() == 5)
+ assert (w.functions.nextSerial(). call() == 4)
+
+ w.functions.rejectRequest(4).transact({'from': self.w3.eth.accounts[0]})
+ assert (w.functions.count(). call() == 1)
+ assert (w.functions.nextSerial(). call() == 5)
+ assert (w.functions.lastSerial(). call() == 5)
+
+ w.functions.rejectRequest(5).transact({'from': self.w3.eth.accounts[0]})
+ assert (w.functions.count(). call() == 0)
+ assert (w.functions.nextSerial(). call() == 0)
+ assert (w.functions.lastSerial(). call() == 5)
+
+
if __name__ == '__main__':
unittest.main()
diff --git a/solidity/Makefile b/solidity/Makefile
@@ -1,7 +1,7 @@
all:
- solc --bin ERC20ApprovalEscrow.sol | awk 'NR>3' > ERC20ApprovalEscrow.bin
- truncate -s -1 ERC20ApprovalEscrow.bin
- solc --abi ERC20ApprovalEscrow.sol | awk 'NR>3' > ERC20ApprovalEscrow.abi.json
+ solc --bin TransferApproval.sol | awk 'NR>3' > TransferApproval.bin
+ truncate -s -1 TransferApproval.bin
+ solc --abi TransferApproval.sol | awk 'NR>3' > TransferApproval.json
install: all
cp -v *{json,bin} ../python/erc20_approval_escrow/data/
diff --git a/solidity/TransferApproval.bin b/solidity/TransferApproval.bin
@@ -1 +1 @@
-608060405234801561001057600080fd5b50604051610f54380380610f548339818101604052602081101561003357600080fd5b810190808051604051939291908464010000000082111561005357600080fd5b8382019150602082018581111561006957600080fd5b825186602082028301116401000000008211171561008657600080fd5b8083526020830192505050908051906020019060200280838360005b838110156100bd5780820151818401526020810190506100a2565b5050505090500160405250505060005b815181101561014e576001600260008484815181106100e857fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806001019150506100cd565b50600160008190555050610ded806101676000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c80630a144391146100675780636c355091146100c157806381d12c5814610143578063b8adaa11146101e3578063f6d713dd14610227578063fe0d94c114610245575b600080fd5b6100a96004803603602081101561007d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610289565b60405180821515815260200191505060405180910390f35b61012d600480360360608110156100d757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506102a9565b6040518082815260200191505060405180910390f35b61016f6004803603602081101561015957600080fd5b81019080803590602001909291905050506104b7565b604051808681526020018573ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019550505050505060405180910390f35b61020f600480360360208110156101f957600080fd5b810190808035906020019092919050505061054d565b60405180821515815260200191505060405180910390f35b61022f61097f565b6040518082815260200191505060405180910390f35b6102716004803603602081101561025b57600080fd5b8101908080359060200190929190505050610985565b60405180821515815260200191505060405180910390f35b60026020528060005260406000206000915054906101000a900460ff1681565b600080600160008054815260200190815260200160002090506000548160000181905550848160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550338160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550838160030160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082816004018190555060008081548092919060010191905055508060030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168160020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168260010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fb609ae609609ee99268d05bc1371102cafe8d6b964bf082439ab16be2a01c87c84600401548560000154604051808381526020018281526020019250505060405180910390a480600001549150509392505050565b60016020528060005260406000206000915090508060000154908060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060040154905085565b6000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661060e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600d8152602001807f4552525f4e4f5f4143434553530000000000000000000000000000000000000081525060200191505060405180910390fd5b6000600160008481526020019081526020016000209050600081600001541161069f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f4552525f494e56414c49445f524551554553540000000000000000000000000081525060200191505060405180910390fd5b600060608260030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168360010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168460010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168560040154604051602401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200193505050506040516020818303038152906040527f23b872dd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040518082805190602001908083835b602083106108275780518252602082019150602081019050602083039250610804565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610889576040519150601f19603f3d011682016040523d82523d6000602084013e61088e565b606091505b50915091508161089a57fe5b7f607c56ea76669e46679e89091227c1a3f91841a4cf7588d5a6c84555fb59fdfd83600001546040518082815260200191505060405180910390a160016000846000015481526020019081526020016000206000808201600090556001820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556002820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556003820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905560048201600090555050819350505050919050565b60005481565b6000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610a46576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600d8152602001807f4552525f4e4f5f4143434553530000000000000000000000000000000000000081525060200191505060405180910390fd5b60006001600084815260200190815260200160002090506000816000015411610ad7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f4552525f494e56414c49445f524551554553540000000000000000000000000081525060200191505060405180910390fd5b600060608260030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168360010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168460020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168560040154604051602401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200193505050506040516020818303038152906040527f23b872dd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040518082805190602001908083835b60208310610c5f5780518252602082019150602081019050602083039250610c3c565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610cc1576040519150601f19603f3d011682016040523d82523d6000602084013e610cc6565b606091505b509150915081610cd257fe5b7fa445ec1ee84565906bc8646dcb62f6d1a75fc7a782a03e72220fb97f60ba89ab83600001546040518082815260200191505060405180910390a160016000846000015481526020019081526020016000206000808201600090556001820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556002820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556003820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556004820160009055505081935050505091905056fea264697066735822122027854a054b06dcbba643ec3336be99a459dab354eee6bab60354f36d6e9f233464736f6c63430007050033
-\ No newline at end of file
+60806040523480156200001157600080fd5b5060405162001755380380620017558339818101604052810190620000379190620001c3565b60005b8151811015620000f35760016004600084848151811062000084577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080620000ea90620002a9565b9150506200003a565b50600180819055506001600281905550506200036f565b6000620001216200011b846200023c565b62000208565b905080838252602082019050828560208602820111156200014157600080fd5b60005b858110156200017557816200015a88826200017f565b84526020840193506020830192505060018101905062000144565b5050509392505050565b600081519050620001908162000355565b92915050565b600082601f830112620001a857600080fd5b8151620001ba8482602086016200010a565b91505092915050565b600060208284031215620001d657600080fd5b600082015167ffffffffffffffff811115620001f157600080fd5b620001ff8482850162000196565b91505092915050565b6000604051905081810181811067ffffffffffffffff8211171562000232576200023162000326565b5b8060405250919050565b600067ffffffffffffffff8211156200025a576200025962000326565b5b602082029050602081019050919050565b600062000278826200027f565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000620002b6826200029f565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415620002ec57620002eb620002f7565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b62000360816200026b565b81146200036c57600080fd5b50565b6113d6806200037f6000396000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c80636e417c69116100665780636e417c691461015d5780637780c14f1461018d57806381d12c58146101ab578063b0addede146101df578063bac911ac1461020f5761009e565b806306661abd146100a357806308ae6377146100c15780630a144391146100df5780632d7788db1461010f57806357ec347a1461013f575b600080fd5b6100ab61023f565b6040516100b89190611163565b60405180910390f35b6100c9610245565b6040516100d69190611163565b60405180910390f35b6100f960048036038101906100f49190610f3b565b610270565b6040516101069190611108565b60405180910390f35b61012960048036038101906101249190610fb3565b610290565b6040516101369190611108565b60405180910390f35b610147610585565b6040516101549190611163565b60405180910390f35b61017760048036038101906101729190610fb3565b61059a565b6040516101849190611108565b60405180910390f35b6101956108c3565b6040516101a29190611163565b60405180910390f35b6101c560048036038101906101c09190610fb3565b6108c9565b6040516101d695949392919061117e565b60405180910390f35b6101f960048036038101906101f49190610f64565b61095f565b6040516102069190611163565b60405180910390f35b61022960048036038101906102249190610fb3565b610bf9565b6040516102369190611163565b60405180910390f35b60035481565b6000806002546001546102589190611221565b1415610267576000905061026d565b60025490505b90565b60046020528060005260406000206000915054906101000a900460ff1681565b6000600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661031e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161031590611123565b60405180910390fd5b60008060008481526020019081526020016000209050600081600001541161037b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161037290611143565b60405180910390fd5b6000808260030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168360010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168460010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16856004015460405160240161041a939291906110d1565b6040516020818303038152906040527f23b872dd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516104a491906110ba565b6000604051808303816000865af19150503d80600081146104e1576040519150601f19603f3d011682016040523d82523d6000602084013e6104e6565b606091505b50915091506104f88360000154610d98565b811561053e577f607c56ea76669e46679e89091227c1a3f91841a4cf7588d5a6c84555fb59fdfd83600001546040516105319190611163565b60405180910390a161057a565b7fdab20a0fcd702cf875c2d715d5c3fc99af66a716c94b3405408c94b7311c99eb83600001546040516105719190611163565b60405180910390a15b819350505050919050565b6000600180546105959190611221565b905090565b6000600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610628576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161061f90611123565b60405180910390fd5b600080600084815260200190815260200160002090506000816000015411610685576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161067c90611143565b60405180910390fd5b6000808260030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168360010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168460020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168560040154604051602401610724939291906110d1565b6040516020818303038152906040527f23b872dd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516107ae91906110ba565b6000604051808303816000865af19150503d80600081146107eb576040519150601f19603f3d011682016040523d82523d6000602084013e6107f0565b606091505b509150915081610829577f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b6108368360000154610d98565b811561087c577f607c56ea76669e46679e89091227c1a3f91841a4cf7588d5a6c84555fb59fdfd836000015460405161086f9190611163565b60405180910390a16108b8565b7fdab20a0fcd702cf875c2d715d5c3fc99af66a716c94b3405408c94b7311c99eb83600001546040516108af9190611163565b60405180910390a15b819350505050919050565b60025481565b60006020528060005260406000206000915090508060000154908060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060040154905085565b6000610969610ea0565b60015481600001818152505084816040019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505033816020019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505083816060019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050828160800181815250508060008060015481526020019081526020016000206000820151816000015560208201518160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060608201518160030160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506080820151816004015590505060036000815480929190610b3b906112fa565b919050555060016000815480929190610b53906112fa565b9190505550806060015173ffffffffffffffffffffffffffffffffffffffff16816040015173ffffffffffffffffffffffffffffffffffffffff16826020015173ffffffffffffffffffffffffffffffffffffffff167fb609ae609609ee99268d05bc1371102cafe8d6b964bf082439ab16be2a01c87c84608001518560000151604051610be29291906111d1565b60405180910390a480600001519150509392505050565b600080600060025490505b600154811015610d8c5760008060008381526020019081526020016000206040518060a0016040529081600082015481526020016001820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016003820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016004820154815250509050600081600001511115610d785784831415610d695780600001519350505050610d93565b8280610d74906112fa565b9350505b508080610d84906112fa565b915050610c04565b5060009150505b919050565b6000808281526020019081526020016000206000808201600090556001820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556002820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556003820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556004820160009055505060036000815480929190610e45906112d0565b919050555060006003541115610e9357600254811415610e8e576000610e6b6000610bf9565b90506000811415610e8457600154600281905550610e8c565b806002819055505b505b610e9d565b6001546002819055505b50565b6040518060a0016040528060008152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600081525090565b600081359050610f2081611372565b92915050565b600081359050610f3581611389565b92915050565b600060208284031215610f4d57600080fd5b6000610f5b84828501610f11565b91505092915050565b600080600060608486031215610f7957600080fd5b6000610f8786828701610f11565b9350506020610f9886828701610f11565b9250506040610fa986828701610f26565b9150509250925092565b600060208284031215610fc557600080fd5b6000610fd384828501610f26565b91505092915050565b610fe581611255565b82525050565b610ff481611267565b82525050565b6000611005826111fa565b61100f8185611205565b935061101f81856020860161129d565b80840191505092915050565b6000611038600d83611210565b91507f4552525f4e4f5f414343455353000000000000000000000000000000000000006000830152602082019050919050565b6000611078601383611210565b91507f4552525f494e56414c49445f52455155455354000000000000000000000000006000830152602082019050919050565b6110b481611293565b82525050565b60006110c68284610ffa565b915081905092915050565b60006060820190506110e66000830186610fdc565b6110f36020830185610fdc565b61110060408301846110ab565b949350505050565b600060208201905061111d6000830184610feb565b92915050565b6000602082019050818103600083015261113c8161102b565b9050919050565b6000602082019050818103600083015261115c8161106b565b9050919050565b600060208201905061117860008301846110ab565b92915050565b600060a08201905061119360008301886110ab565b6111a06020830187610fdc565b6111ad6040830186610fdc565b6111ba6060830185610fdc565b6111c760808301846110ab565b9695505050505050565b60006040820190506111e660008301856110ab565b6111f360208301846110ab565b9392505050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b600061122c82611293565b915061123783611293565b92508282101561124a57611249611343565b5b828203905092915050565b600061126082611273565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60005b838110156112bb5780820151818401526020810190506112a0565b838111156112ca576000848401525b50505050565b60006112db82611293565b915060008214156112ef576112ee611343565b5b600182039050919050565b600061130582611293565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561133857611337611343565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b61137b81611255565b811461138657600080fd5b50565b61139281611293565b811461139d57600080fd5b5056fea2646970667358221220d441a811b83873b5e6f885838296dc5de101a07165838838514de472d224d11f64736f6c63430008000033
+\ No newline at end of file
diff --git a/solidity/TransferApproval.json b/solidity/TransferApproval.json
@@ -1 +1 @@
-[{"inputs":[{"internalType":"address[]","name":"_approvers","type":"address[]"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"serial","type":"uint256"}],"name":"NewExecution","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"serial","type":"uint256"}],"name":"NewRejection","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_sender","type":"address"},{"indexed":true,"internalType":"address","name":"_recipient","type":"address"},{"indexed":true,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_serial","type":"uint256"}],"name":"NewRequest","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"approvers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_serial","type":"uint256"}],"name":"execute","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_serial","type":"uint256"}],"name":"reject","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"request","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"requests","outputs":[{"internalType":"uint256","name":"serial","type":"uint256"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"serial","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
+[{"inputs":[{"internalType":"address[]","name":"_approvers","type":"address[]"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"serial","type":"uint256"}],"name":"NewExecution","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"serial","type":"uint256"}],"name":"NewRejection","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_sender","type":"address"},{"indexed":true,"internalType":"address","name":"_recipient","type":"address"},{"indexed":true,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_serial","type":"uint256"}],"name":"NewRequest","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"serial","type":"uint256"}],"name":"TransferFail","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"approvers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"count","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"createRequest","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_serial","type":"uint256"}],"name":"executeRequest","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_idx","type":"uint256"}],"name":"getSerialAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastSerial","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lo","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextSerial","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_serial","type":"uint256"}],"name":"rejectRequest","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"requests","outputs":[{"internalType":"uint256","name":"serial","type":"uint256"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"stateMutability":"view","type":"function"}]
diff --git a/solidity/TransferApproval.sol b/solidity/TransferApproval.sol
@@ -10,65 +10,131 @@ contract ERC20ApprovalEscrow {
address token;
uint256 value;
}
- uint256 public serial;
+ //mapping(uint256 => Transaction) public requests;
mapping(uint256 => Transaction) public requests;
+ //Transaction[] public requests;
+ uint256 hi;
+ uint256 public lo;
+ uint256 public count;
+
mapping(address => bool) public approvers;
event NewRequest(address indexed _sender, address indexed _recipient, address indexed _token, uint256 _value, uint256 _serial);
event NewExecution(uint256 serial);
event NewRejection(uint256 serial);
+ event TransferFail(uint256 serial);
constructor(address[] memory _approvers) public {
for (uint i = 0; i < _approvers.length; i++) {
approvers[_approvers[i]] = true;
}
- serial = 1;
+ hi = 1;
+ lo = 1;
}
- function request(address _recipient, address _token, uint256 _value) public returns (uint256) {
- Transaction storage txx = requests[serial];
+ function createRequest(address _recipient, address _token, uint256 _value) public returns (uint256) {
+ Transaction memory txx;
- txx.serial = serial;
+ txx.serial = hi;
txx.recipient = _recipient;
txx.sender = msg.sender;
txx.token = _token;
txx.value = _value;
-
- serial++;
+
+ requests[hi] = txx;
+ count++;
+ hi++;
emit NewRequest(txx.sender, txx.recipient, txx.token, txx.value, txx.serial);
return txx.serial;
}
- function execute(uint256 _serial) public returns (bool) {
+ function removeItem(uint256 serialToRemove) private {
+ //Transaction memory lastTxx = requests[requests.length-1];
+ //requests.pop();
+ //uint256 idxToReplace = requests[serialToRemove];
+
+ delete requests[serialToRemove];
+ count--;
+
+ if (count > 0) {
+ if (serialToRemove == lo) {
+ uint256 i;
+ i = getSerialAt(0);
+ if (i == 0) {
+ lo = hi;
+ } else {
+ lo = i;
+ }
+ }
+ } else {
+ lo = hi;
+ }
+ }
+
+ function lastSerial() public view returns ( uint256 ) {
+ return hi - 1;
+ }
+
+ function nextSerial() public view returns ( uint256 ) {
+ if (hi - lo == 0) {
+ return 0;
+ }
+ return lo;
+ }
+
+ function getSerialAt(uint256 _idx) public view returns ( uint256 ) {
+ uint256 i;
+ for (uint256 j = lo; j < hi; j++) {
+ Transaction memory txx = requests[j];
+ if (txx.serial > 0) {
+ if (i == _idx) {
+ return txx.serial;
+ }
+ i++;
+ }
+ }
+ return 0;
+ }
+
+ function executeRequest(uint256 _serial) public returns (bool) {
require(approvers[msg.sender], 'ERR_NO_ACCESS');
Transaction storage txx = requests[_serial];
require(txx.serial > 0, 'ERR_INVALID_REQUEST');
- (bool success, bytes memory _) = txx.token.call(abi.encodeWithSignature("transferFrom(address,address,uint256)", txx.sender, txx.recipient, txx.value));
+ (bool success, bytes memory _r) = txx.token.call(abi.encodeWithSignature("transferFrom(address,address,uint256)", txx.sender, txx.recipient, txx.value));
assert(success);
- emit NewExecution(txx.serial);
+ removeItem(txx.serial);
- delete requests[txx.serial];
+ if (success) {
+ emit NewRejection(txx.serial);
+ } else {
+ emit TransferFail(txx.serial);
+ }
return success;
}
- function reject(uint256 _serial) public returns (bool) {
+ function rejectRequest(uint256 _serial) public returns (bool) {
require(approvers[msg.sender], 'ERR_NO_ACCESS');
Transaction storage txx = requests[_serial];
require(txx.serial > 0, 'ERR_INVALID_REQUEST');
- (bool success, bytes memory _) = txx.token.call(abi.encodeWithSignature("transferFrom(address,address,uint256)", txx.sender, txx.sender, txx.value));
- assert(success);
+ (bool success, bytes memory _r) = txx.token.call(abi.encodeWithSignature("transferFrom(address,address,uint256)", txx.sender, txx.sender, txx.value));
- emit NewRejection(txx.serial);
+ removeItem(txx.serial);
+
+ if (success) {
+ emit NewRejection(txx.serial);
+ } else {
+ emit TransferFail(txx.serial);
+ }
- delete requests[txx.serial];
+ //delete requests[txx.serial];
return success;
}