evm-tokenvote

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 8174db231d4beae2845e853a7c7822c2ecd833ea
parent 4a5f1df4a302cadca3c81cdd887e3e5e29666dbc
Author: lash <dev@holbrook.no>
Date:   Fri,  5 May 2023 10:51:37 +0100

Add proposal object, init state in contract proposal

Diffstat:
Mpython/evm_tokenvote/__init__.py | 2++
Mpython/evm_tokenvote/data/Voter.bin | 4++--
Mpython/evm_tokenvote/data/Voter.metadata.json | 2+-
Mpython/evm_tokenvote/unittest/base.py | 10++++++++--
Mpython/evm_tokenvote/voter.py | 87+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpython/tests/test_base.py | 24+++++++++++++++++++++++-
Msolidity/Voter.sol | 12+++++++-----
7 files changed, 130 insertions(+), 11 deletions(-)

diff --git a/python/evm_tokenvote/__init__.py b/python/evm_tokenvote/__init__.py @@ -1 +1,3 @@ from .voter import Voter +from .voter import Proposal +from .voter import ProposalState diff --git a/python/evm_tokenvote/data/Voter.bin b/python/evm_tokenvote/data/Voter.bin @@ -1 +1 @@ -60806040523480156200001157600080fd5b50604051620028163803806200281683398181016040528101906200003791906200012a565b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505062000171565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620000f282620000c5565b9050919050565b6200010481620000e5565b81146200011057600080fd5b50565b6000815190506200012481620000f9565b92915050565b60008060408385031215620001445762000143620000c0565b5b6000620001548582860162000113565b9250506020620001678582860162000113565b9150509250929050565b61269580620001816000396000f3fe608060405234801561001057600080fd5b50600436106100bb576000357c010000000000000000000000000000000000000000000000000000000090048063b05c65ba11610083578063b05c65ba14610193578063b384abef146101c3578063ce746024146101f3578063e99a943e14610211578063fc0c546a14610241576100bb565b8063013cf08b146100c05780632b49d425146100f75780634bb278f31461011557806370a08231146101335780638bb5221314610163575b600080fd5b6100da60048036038101906100d5919061181b565b61025f565b6040516100ee9897969594939291906118eb565b60405180910390f35b6100ff610300565b60405161010c9190611969565b60405180910390f35b61011d610306565b60405161012a919061199f565b60405180910390f35b61014d600480360381019061014891906119e6565b6104e8565b60405161015a9190611969565b60405180910390f35b61017d60048036038101906101789190611a3f565b610500565b60405161018a919061199f565b60405180910390f35b6101ad60048036038101906101a89190611c30565b61075c565b6040516101ba9190611969565b60405180910390f35b6101dd60048036038101906101d89190611cb3565b6109e4565b6040516101ea919061199f565b60405180910390f35b6101fb610e44565b6040516102089190611969565b60405180910390f35b61022b60048036038101906102269190611cf3565b6111cd565b6040516102389190611969565b60405180910390f35b6102496111e7565b6040516102569190611d46565b60405180910390f35b6001818154811061026f57600080fd5b90600052602060002090600702016000915090508060000154908060030154908060040154908060050154908060060160009054906101000a900462ffffff16908060060160039054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060060160179054906101000a900460ff16908060060160189054906101000a900460ff16905088565b60035481565b60008060008060016003548154811061032257610321611d61565b5b90600052602060002090600702019250600060018460060160179054906101000a900460ff161660ff161461038c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161038390611ded565b60405180910390fd5b600060028460060160179054906101000a900460ff161660ff16146103e6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103dd90611e59565b60405180910390fd5b60006103f18461120b565b0361040257600093505050506104e5565b60018360060160178282829054906101000a900460ff161792506101000a81548160ff021916908360ff1602179055506001600360008282546104459190611ea8565b92505081905550620f4240836004015461045f9190611edc565b9150620f424083600301546104749190611edc565b90508260060160009054906101000a900462ffffff1662ffffff16828261049b9190611f4d565b10156104dd5760048360060160178282829054906101000a900460ff161792506101000a81548160ff021916908360ff160217905550600093505050506104e5565b600193505050505b90565b60046020528060005260406000206000915090505481565b60008060008060008060008060018a815481106105205761051f611d61565b5b906000526020600020906007020196504387600501541115610577576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161056e90611fca565b60405180910390fd5b600060028860060160179054906101000a900460ff161660ff1611156105a7576000975050505050505050610756565b8660060160189054906101000a900460ff169150866001018054905089836105cf9190611fea565b60ff1611156105ee578187600101805490506105eb919061201f565b98505b81896105fa9190611fea565b98508660060160179054906101000a900460ff1690508195505b8860ff168660ff1610156106a357866002018660ff168154811061063b5761063a611d61565b5b9060005260206000200154925060008311801561065757508383145b1561066757600881179050610681565b83831115610680578293508560ff169450600819811690505b5b60018261068e9190611fea565b9150858061069b90612054565b965050610614565b818760060160186101000a81548160ff021916908360ff160217905550808760060160176101000a81548160ff021916908360ff16021790555086600101805490508760060160189054906101000a900460ff1660ff1610156107315760028760060160178282829054906101000a900460ff161792506101000a81548160ff021916908360ff1602179055505b600060028860060160179054906101000a900460ff161660ff16119750505050505050505b92915050565b6000610766611686565b6000806101008751106107ae576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107a5906120c9565b60405180910390fd5b338360e0019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505087836000018181525050868360200181905250848360c0019062ffffff16908162ffffff1681525050854361081b9190611ea8565b9050808360a0018181525050600180549050915060018390806001815401808255809150506001900390600052602060002090600702016000909190919091506000820151816000015560208201518160010190805190602001906108819291906116fd565b50604082015181600201908051906020019061089e92919061174a565b50606082015181600301556080820151816004015560a0820151816005015560c08201518160060160006101000a81548162ffffff021916908362ffffff16021790555060e08201518160060160036101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506101008201518160060160176101000a81548160ff021916908360ff1602179055506101208201518160060160186101000a81548160ff021916908360ff16021790555050506109996001838154811061098657610985611d61565b5b906000526020600020906007020161120b565b836060018181525050818562ffffff16827f5a41400aa51d78e9e5ca645b0d045817eaa7d90e4344d773fdbe24ffb183d3ce60405160405180910390a4819350505050949350505050565b600080600060606109f43361146a565b600160035481548110610a0a57610a09611d61565b5b906000526020600020906007020192506000610a258461120b565b03610a365760009350505050610e3e565b43836005015410610a7c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a7390612135565b60405180910390fd5b6000600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115610b4857600354600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414610b47576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b3e906121a1565b60405180910390fd5b5b82600101805490508610610b91576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b889061220d565b60405180910390fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16333087604051602401610bdd9392919061228c565b6040516020818303038152906040527f23b872dd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610c679190612334565b6000604051808303816000865af19150503d8060008114610ca4576040519150601f19603f3d011682016040523d82523d6000602084013e610ca9565b606091505b50809250819350505081610cf2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ce990612397565b60405180910390fd5b80806020019051810190610d0691906123e3565b915081610d48576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d3f9061245c565b60405180910390fd5b600354600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555084600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610ddd9190611ea8565b9250508190555084836004016000828254610df89190611ea8565b9250508190555084836002018781548110610e1657610e15611d61565b5b906000526020600020016000828254610e2f9190611ea8565b92505081905550600193505050505b92915050565b600080600060606000600160035481548110610e6357610e62611d61565b5b90600052602060002090600702019350600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050600354600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205403610f845743846005015411610f6757600060018560060160179054906101000a900460ff161660ff1614610f62576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f5990611fca565b60405180910390fd5b610f83565b80846004016000828254610f7b919061247c565b925050819055505b5b6000600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1633826040516024016110589291906124b0565b6040516020818303038152906040527fa9059cbb000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516110e29190612334565b6000604051808303816000865af19150503d806000811461111f576040519150601f19603f3d011682016040523d82523d6000602084013e611124565b606091505b5080935081945050508261116d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161116490612397565b60405180910390fd5b8180602001905181019061118191906123e3565b9250826111c3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111ba9061245c565b60405180910390fd5b8094505050505090565b600060606111dd8582868661075c565b9150509392505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080606060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166040516024016040516020818303038152906040527f18160ddd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516112da9190612334565b6000604051808303816000865af19150503d8060008114611317576040519150601f19603f3d011682016040523d82523d6000602084013e61131c565b606091505b50809350819450505082611365576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161135c90612397565b60405180910390fd5b8180602001905181019061137991906124ee565b9050600081116113be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113b590612567565b60405180910390fd5b60008560030154036113d85780856003018190555061145e565b60108560060160178282829054906101000a900460ff161792506101000a81548160ff021916908360ff16021790555060018560060160178282829054906101000a900460ff161792506101000a81548160ff021916908360ff16021790555060016003600082825461144b9190611ea8565b9250508190555060009350505050611465565b8093505050505b919050565b60006060600073ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16036114cb575050611683565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16836040516024016115159190611d46565b6040516020818303038152906040527f3ef25013000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161159f9190612334565b6000604051808303816000865af19150503d80600081146115dc576040519150601f19603f3d011682016040523d82523d6000602084013e6115e1565b606091505b5080925081935050508161162a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611621906125d3565b60405180910390fd5b8080602001905181019061163e91906123e3565b915081611680576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116779061263f565b60405180910390fd5b50505b50565b604051806101400160405280600080191681526020016060815260200160608152602001600081526020016000815260200160008152602001600062ffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600060ff168152602001600060ff1681525090565b828054828255906000526020600020908101928215611739579160200282015b8281111561173857825182559160200191906001019061171d565b5b5090506117469190611797565b5090565b828054828255906000526020600020908101928215611786579160200282015b8281111561178557825182559160200191906001019061176a565b5b50905061179391906117b4565b5090565b5b808211156117b0576000816000905550600101611798565b5090565b5b808211156117cd5760008160009055506001016117b5565b5090565b6000604051905090565b600080fd5b600080fd5b6000819050919050565b6117f8816117e5565b811461180357600080fd5b50565b600081359050611815816117ef565b92915050565b600060208284031215611831576118306117db565b5b600061183f84828501611806565b91505092915050565b6000819050919050565b61185b81611848565b82525050565b61186a816117e5565b82525050565b600062ffffff82169050919050565b61188881611870565b82525050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006118b98261188e565b9050919050565b6118c9816118ae565b82525050565b600060ff82169050919050565b6118e5816118cf565b82525050565b600061010082019050611901600083018b611852565b61190e602083018a611861565b61191b6040830189611861565b6119286060830188611861565b611935608083018761187f565b61194260a08301866118c0565b61194f60c08301856118dc565b61195c60e08301846118dc565b9998505050505050505050565b600060208201905061197e6000830184611861565b92915050565b60008115159050919050565b61199981611984565b82525050565b60006020820190506119b46000830184611990565b92915050565b6119c3816118ae565b81146119ce57600080fd5b50565b6000813590506119e0816119ba565b92915050565b6000602082840312156119fc576119fb6117db565b5b6000611a0a848285016119d1565b91505092915050565b611a1c816118cf565b8114611a2757600080fd5b50565b600081359050611a3981611a13565b92915050565b60008060408385031215611a5657611a556117db565b5b6000611a6485828601611806565b9250506020611a7585828601611a2a565b9150509250929050565b611a8881611848565b8114611a9357600080fd5b50565b600081359050611aa581611a7f565b92915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b611af982611ab0565b810181811067ffffffffffffffff82111715611b1857611b17611ac1565b5b80604052505050565b6000611b2b6117d1565b9050611b378282611af0565b919050565b600067ffffffffffffffff821115611b5757611b56611ac1565b5b602082029050602081019050919050565b600080fd5b6000611b80611b7b84611b3c565b611b21565b90508083825260208201905060208402830185811115611ba357611ba2611b68565b5b835b81811015611bcc5780611bb88882611a96565b845260208401935050602081019050611ba5565b5050509392505050565b600082601f830112611beb57611bea611aab565b5b8135611bfb848260208601611b6d565b91505092915050565b611c0d81611870565b8114611c1857600080fd5b50565b600081359050611c2a81611c04565b92915050565b60008060008060808587031215611c4a57611c496117db565b5b6000611c5887828801611a96565b945050602085013567ffffffffffffffff811115611c7957611c786117e0565b5b611c8587828801611bd6565b9350506040611c9687828801611806565b9250506060611ca787828801611c1b565b91505092959194509250565b60008060408385031215611cca57611cc96117db565b5b6000611cd885828601611806565b9250506020611ce985828601611806565b9150509250929050565b600080600060608486031215611d0c57611d0b6117db565b5b6000611d1a86828701611a96565b9350506020611d2b86828701611806565b9250506040611d3c86828701611c1b565b9150509250925092565b6000602082019050611d5b60008301846118c0565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082825260208201905092915050565b7f4552525f414c52454144595f53544154455f46494e414c000000000000000000600082015250565b6000611dd7601783611d90565b9150611de282611da1565b602082019050919050565b60006020820190508181036000830152611e0681611dca565b9050919050565b7f4552525f5343414e5f4649525354000000000000000000000000000000000000600082015250565b6000611e43600e83611d90565b9150611e4e82611e0d565b602082019050919050565b60006020820190508181036000830152611e7281611e36565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000611eb3826117e5565b9150611ebe836117e5565b9250828201905080821115611ed657611ed5611e79565b5b92915050565b6000611ee7826117e5565b9150611ef2836117e5565b9250828202611f00816117e5565b91508282048414831517611f1757611f16611e79565b5b5092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000611f58826117e5565b9150611f63836117e5565b925082611f7357611f72611f1e565b5b828204905092915050565b7f4552525f5052454d415455524500000000000000000000000000000000000000600082015250565b6000611fb4600d83611d90565b9150611fbf82611f7e565b602082019050919050565b60006020820190508181036000830152611fe381611fa7565b9050919050565b6000611ff5826118cf565b9150612000836118cf565b9250828201905060ff81111561201957612018611e79565b5b92915050565b600061202a826118cf565b9150612035836118cf565b9250828203905060ff81111561204e5761204d611e79565b5b92915050565b600061205f826118cf565b915060ff820361207257612071611e79565b5b600182019050919050565b7f4552525f544f4f5f4d414e595f4f5054494f4e53000000000000000000000000600082015250565b60006120b3601483611d90565b91506120be8261207d565b602082019050919050565b600060208201905081810360008301526120e2816120a6565b9050919050565b7f4552525f444541444c494e450000000000000000000000000000000000000000600082015250565b600061211f600c83611d90565b915061212a826120e9565b602082019050919050565b6000602082019050818103600083015261214e81612112565b9050919050565b7f4552525f5245434f5645525f4649525354000000000000000000000000000000600082015250565b600061218b601183611d90565b915061219682612155565b602082019050919050565b600060208201905081810360008301526121ba8161217e565b9050919050565b7f4552525f4f5054494f4e5f494e56414c49440000000000000000000000000000600082015250565b60006121f7601283611d90565b9150612202826121c1565b602082019050919050565b60006020820190508181036000830152612226816121ea565b9050919050565b6000819050919050565b600061225261224d6122488461188e565b61222d565b61188e565b9050919050565b600061226482612237565b9050919050565b600061227682612259565b9050919050565b6122868161226b565b82525050565b60006060820190506122a160008301866118c0565b6122ae602083018561227d565b6122bb6040830184611861565b949350505050565b600081519050919050565b600081905092915050565b60005b838110156122f75780820151818401526020810190506122dc565b60008484015250505050565b600061230e826122c3565b61231881856122ce565b93506123288185602086016122d9565b80840191505092915050565b60006123408284612303565b915081905092915050565b7f4552525f544f4b454e0000000000000000000000000000000000000000000000600082015250565b6000612381600983611d90565b915061238c8261234b565b602082019050919050565b600060208201905081810360008301526123b081612374565b9050919050565b6123c081611984565b81146123cb57600080fd5b50565b6000815190506123dd816123b7565b92915050565b6000602082840312156123f9576123f86117db565b5b6000612407848285016123ce565b91505092915050565b7f4552525f5452414e534645520000000000000000000000000000000000000000600082015250565b6000612446600c83611d90565b915061245182612410565b602082019050919050565b6000602082019050818103600083015261247581612439565b9050919050565b6000612487826117e5565b9150612492836117e5565b92508282039050818111156124aa576124a9611e79565b5b92915050565b60006040820190506124c560008301856118c0565b6124d26020830184611861565b9392505050565b6000815190506124e8816117ef565b92915050565b600060208284031215612504576125036117db565b5b6000612512848285016124d9565b91505092915050565b7f4552525f5a45524f5f535550504c590000000000000000000000000000000000600082015250565b6000612551600f83611d90565b915061255c8261251b565b602082019050919050565b6000602082019050818103600083015261258081612544565b9050919050565b7f4552525f52454749535452590000000000000000000000000000000000000000600082015250565b60006125bd600c83611d90565b91506125c882612587565b602082019050919050565b600060208201905081810360008301526125ec816125b0565b9050919050565b7f4552525f554e415554485f4143434f554e540000000000000000000000000000600082015250565b6000612629601283611d90565b9150612634826125f3565b602082019050919050565b600060208201905081810360008301526126588161261c565b905091905056fea2646970667358221220a0b7b83d19bc524deed35c525a9cc71cd4913685d498275e0e14b750b93dd57564736f6c63430008130033 -\ No newline at end of file +60806040523480156200001157600080fd5b506040516200282a3803806200282a83398181016040528101906200003791906200012a565b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505062000171565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620000f282620000c5565b9050919050565b6200010481620000e5565b81146200011057600080fd5b50565b6000815190506200012481620000f9565b92915050565b60008060408385031215620001445762000143620000c0565b5b6000620001548582860162000113565b9250506020620001678582860162000113565b9150509250929050565b6126a980620001816000396000f3fe608060405234801561001057600080fd5b50600436106100bb576000357c010000000000000000000000000000000000000000000000000000000090048063b05c65ba11610083578063b05c65ba14610193578063b384abef146101c3578063ce746024146101f3578063e99a943e14610211578063fc0c546a14610241576100bb565b8063013cf08b146100c05780632b49d425146100f75780634bb278f31461011557806370a08231146101335780638bb5221314610163575b600080fd5b6100da60048036038101906100d5919061182f565b61025f565b6040516100ee9897969594939291906118ff565b60405180910390f35b6100ff610300565b60405161010c919061197d565b60405180910390f35b61011d610306565b60405161012a91906119b3565b60405180910390f35b61014d600480360381019061014891906119fa565b6104e8565b60405161015a919061197d565b60405180910390f35b61017d60048036038101906101789190611a53565b610500565b60405161018a91906119b3565b60405180910390f35b6101ad60048036038101906101a89190611c44565b61075c565b6040516101ba919061197d565b60405180910390f35b6101dd60048036038101906101d89190611cc7565b6109f8565b6040516101ea91906119b3565b60405180910390f35b6101fb610e58565b604051610208919061197d565b60405180910390f35b61022b60048036038101906102269190611d07565b6111e1565b604051610238919061197d565b60405180910390f35b6102496111fb565b6040516102569190611d5a565b60405180910390f35b6001818154811061026f57600080fd5b90600052602060002090600702016000915090508060000154908060030154908060040154908060050154908060060160009054906101000a900462ffffff16908060060160039054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060060160179054906101000a900460ff16908060060160189054906101000a900460ff16905088565b60035481565b60008060008060016003548154811061032257610321611d75565b5b90600052602060002090600702019250600060028460060160179054906101000a900460ff161660ff161461038c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161038390611e01565b60405180910390fd5b600060048460060160179054906101000a900460ff161660ff16146103e6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103dd90611e6d565b60405180910390fd5b60006103f18461121f565b0361040257600093505050506104e5565b60028360060160178282829054906101000a900460ff161792506101000a81548160ff021916908360ff1602179055506001600360008282546104459190611ebc565b92505081905550620f4240836004015461045f9190611ef0565b9150620f424083600301546104749190611ef0565b90508260060160009054906101000a900462ffffff1662ffffff16828261049b9190611f61565b10156104dd5760088360060160178282829054906101000a900460ff161792506101000a81548160ff021916908360ff160217905550600093505050506104e5565b600193505050505b90565b60046020528060005260406000206000915090505481565b60008060008060008060008060018a815481106105205761051f611d75565b5b906000526020600020906007020196504387600501541115610577576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161056e90611fde565b60405180910390fd5b600060048860060160179054906101000a900460ff161660ff1611156105a7576000975050505050505050610756565b8660060160189054906101000a900460ff169150866001018054905089836105cf9190611ffe565b60ff1611156105ee578187600101805490506105eb9190612033565b98505b81896105fa9190611ffe565b98508660060160179054906101000a900460ff1690508195505b8860ff168660ff1610156106a357866002018660ff168154811061063b5761063a611d75565b5b9060005260206000200154925060008311801561065757508383145b1561066757601081179050610681565b83831115610680578293508560ff169450601019811690505b5b60018261068e9190611ffe565b9150858061069b90612068565b965050610614565b818760060160186101000a81548160ff021916908360ff160217905550808760060160176101000a81548160ff021916908360ff16021790555086600101805490508760060160189054906101000a900460ff1660ff1610156107315760048760060160178282829054906101000a900460ff161792506101000a81548160ff021916908360ff1602179055505b600060048860060160179054906101000a900460ff161660ff16119750505050505050505b92915050565b600061076661169a565b6000806101008751106107ae576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107a5906120dd565b60405180910390fd5b338360e0019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505087836000018181525050868360200181905250848360c0019062ffffff16908162ffffff1681525050854361081b9190611ebc565b9050808360a00181815250506001805490509150600183610100019060ff16908160ff16815250506001839080600181540180825580915050600190039060005260206000209060070201600090919091909150600082015181600001556020820151816001019080519060200190610895929190611711565b5060408201518160020190805190602001906108b292919061175e565b50606082015181600301556080820151816004015560a0820151816005015560c08201518160060160006101000a81548162ffffff021916908362ffffff16021790555060e08201518160060160036101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506101008201518160060160176101000a81548160ff021916908360ff1602179055506101208201518160060160186101000a81548160ff021916908360ff16021790555050506109ad6001838154811061099a57610999611d75565b5b906000526020600020906007020161121f565b836060018181525050818562ffffff16827f5a41400aa51d78e9e5ca645b0d045817eaa7d90e4344d773fdbe24ffb183d3ce60405160405180910390a4819350505050949350505050565b60008060006060610a083361147e565b600160035481548110610a1e57610a1d611d75565b5b906000526020600020906007020192506000610a398461121f565b03610a4a5760009350505050610e52565b43836005015410610a90576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a8790612149565b60405180910390fd5b6000600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115610b5c57600354600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414610b5b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b52906121b5565b60405180910390fd5b5b82600101805490508610610ba5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b9c90612221565b60405180910390fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16333087604051602401610bf1939291906122a0565b6040516020818303038152906040527f23b872dd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610c7b9190612348565b6000604051808303816000865af19150503d8060008114610cb8576040519150601f19603f3d011682016040523d82523d6000602084013e610cbd565b606091505b50809250819350505081610d06576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cfd906123ab565b60405180910390fd5b80806020019051810190610d1a91906123f7565b915081610d5c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d5390612470565b60405180910390fd5b600354600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555084600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610df19190611ebc565b9250508190555084836004016000828254610e0c9190611ebc565b9250508190555084836002018781548110610e2a57610e29611d75565b5b906000526020600020016000828254610e439190611ebc565b92505081905550600193505050505b92915050565b600080600060606000600160035481548110610e7757610e76611d75565b5b90600052602060002090600702019350600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050600354600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205403610f985743846005015411610f7b57600060028560060160179054906101000a900460ff161660ff1614610f76576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f6d90611fde565b60405180910390fd5b610f97565b80846004016000828254610f8f9190612490565b925050819055505b5b6000600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16338260405160240161106c9291906124c4565b6040516020818303038152906040527fa9059cbb000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516110f69190612348565b6000604051808303816000865af19150503d8060008114611133576040519150601f19603f3d011682016040523d82523d6000602084013e611138565b606091505b50809350819450505082611181576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611178906123ab565b60405180910390fd5b8180602001905181019061119591906123f7565b9250826111d7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111ce90612470565b60405180910390fd5b8094505050505090565b600060606111f18582868661075c565b9150509392505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080606060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166040516024016040516020818303038152906040527f18160ddd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516112ee9190612348565b6000604051808303816000865af19150503d806000811461132b576040519150601f19603f3d011682016040523d82523d6000602084013e611330565b606091505b50809350819450505082611379576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611370906123ab565b60405180910390fd5b8180602001905181019061138d9190612502565b9050600081116113d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113c99061257b565b60405180910390fd5b60008560030154036113ec57808560030181905550611472565b60208560060160178282829054906101000a900460ff161792506101000a81548160ff021916908360ff16021790555060028560060160178282829054906101000a900460ff161792506101000a81548160ff021916908360ff16021790555060016003600082825461145f9190611ebc565b9250508190555060009350505050611479565b8093505050505b919050565b60006060600073ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16036114df575050611697565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16836040516024016115299190611d5a565b6040516020818303038152906040527f3ef25013000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516115b39190612348565b6000604051808303816000865af19150503d80600081146115f0576040519150601f19603f3d011682016040523d82523d6000602084013e6115f5565b606091505b5080925081935050508161163e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611635906125e7565b60405180910390fd5b8080602001905181019061165291906123f7565b915081611694576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161168b90612653565b60405180910390fd5b50505b50565b604051806101400160405280600080191681526020016060815260200160608152602001600081526020016000815260200160008152602001600062ffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600060ff168152602001600060ff1681525090565b82805482825590600052602060002090810192821561174d579160200282015b8281111561174c578251825591602001919060010190611731565b5b50905061175a91906117ab565b5090565b82805482825590600052602060002090810192821561179a579160200282015b8281111561179957825182559160200191906001019061177e565b5b5090506117a791906117c8565b5090565b5b808211156117c45760008160009055506001016117ac565b5090565b5b808211156117e15760008160009055506001016117c9565b5090565b6000604051905090565b600080fd5b600080fd5b6000819050919050565b61180c816117f9565b811461181757600080fd5b50565b60008135905061182981611803565b92915050565b600060208284031215611845576118446117ef565b5b60006118538482850161181a565b91505092915050565b6000819050919050565b61186f8161185c565b82525050565b61187e816117f9565b82525050565b600062ffffff82169050919050565b61189c81611884565b82525050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006118cd826118a2565b9050919050565b6118dd816118c2565b82525050565b600060ff82169050919050565b6118f9816118e3565b82525050565b600061010082019050611915600083018b611866565b611922602083018a611875565b61192f6040830189611875565b61193c6060830188611875565b6119496080830187611893565b61195660a08301866118d4565b61196360c08301856118f0565b61197060e08301846118f0565b9998505050505050505050565b60006020820190506119926000830184611875565b92915050565b60008115159050919050565b6119ad81611998565b82525050565b60006020820190506119c860008301846119a4565b92915050565b6119d7816118c2565b81146119e257600080fd5b50565b6000813590506119f4816119ce565b92915050565b600060208284031215611a1057611a0f6117ef565b5b6000611a1e848285016119e5565b91505092915050565b611a30816118e3565b8114611a3b57600080fd5b50565b600081359050611a4d81611a27565b92915050565b60008060408385031215611a6a57611a696117ef565b5b6000611a788582860161181a565b9250506020611a8985828601611a3e565b9150509250929050565b611a9c8161185c565b8114611aa757600080fd5b50565b600081359050611ab981611a93565b92915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b611b0d82611ac4565b810181811067ffffffffffffffff82111715611b2c57611b2b611ad5565b5b80604052505050565b6000611b3f6117e5565b9050611b4b8282611b04565b919050565b600067ffffffffffffffff821115611b6b57611b6a611ad5565b5b602082029050602081019050919050565b600080fd5b6000611b94611b8f84611b50565b611b35565b90508083825260208201905060208402830185811115611bb757611bb6611b7c565b5b835b81811015611be05780611bcc8882611aaa565b845260208401935050602081019050611bb9565b5050509392505050565b600082601f830112611bff57611bfe611abf565b5b8135611c0f848260208601611b81565b91505092915050565b611c2181611884565b8114611c2c57600080fd5b50565b600081359050611c3e81611c18565b92915050565b60008060008060808587031215611c5e57611c5d6117ef565b5b6000611c6c87828801611aaa565b945050602085013567ffffffffffffffff811115611c8d57611c8c6117f4565b5b611c9987828801611bea565b9350506040611caa8782880161181a565b9250506060611cbb87828801611c2f565b91505092959194509250565b60008060408385031215611cde57611cdd6117ef565b5b6000611cec8582860161181a565b9250506020611cfd8582860161181a565b9150509250929050565b600080600060608486031215611d2057611d1f6117ef565b5b6000611d2e86828701611aaa565b9350506020611d3f8682870161181a565b9250506040611d5086828701611c2f565b9150509250925092565b6000602082019050611d6f60008301846118d4565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082825260208201905092915050565b7f4552525f414c52454144595f53544154455f46494e414c000000000000000000600082015250565b6000611deb601783611da4565b9150611df682611db5565b602082019050919050565b60006020820190508181036000830152611e1a81611dde565b9050919050565b7f4552525f5343414e5f4649525354000000000000000000000000000000000000600082015250565b6000611e57600e83611da4565b9150611e6282611e21565b602082019050919050565b60006020820190508181036000830152611e8681611e4a565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000611ec7826117f9565b9150611ed2836117f9565b9250828201905080821115611eea57611ee9611e8d565b5b92915050565b6000611efb826117f9565b9150611f06836117f9565b9250828202611f14816117f9565b91508282048414831517611f2b57611f2a611e8d565b5b5092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000611f6c826117f9565b9150611f77836117f9565b925082611f8757611f86611f32565b5b828204905092915050565b7f4552525f5052454d415455524500000000000000000000000000000000000000600082015250565b6000611fc8600d83611da4565b9150611fd382611f92565b602082019050919050565b60006020820190508181036000830152611ff781611fbb565b9050919050565b6000612009826118e3565b9150612014836118e3565b9250828201905060ff81111561202d5761202c611e8d565b5b92915050565b600061203e826118e3565b9150612049836118e3565b9250828203905060ff81111561206257612061611e8d565b5b92915050565b6000612073826118e3565b915060ff820361208657612085611e8d565b5b600182019050919050565b7f4552525f544f4f5f4d414e595f4f5054494f4e53000000000000000000000000600082015250565b60006120c7601483611da4565b91506120d282612091565b602082019050919050565b600060208201905081810360008301526120f6816120ba565b9050919050565b7f4552525f444541444c494e450000000000000000000000000000000000000000600082015250565b6000612133600c83611da4565b915061213e826120fd565b602082019050919050565b6000602082019050818103600083015261216281612126565b9050919050565b7f4552525f5245434f5645525f4649525354000000000000000000000000000000600082015250565b600061219f601183611da4565b91506121aa82612169565b602082019050919050565b600060208201905081810360008301526121ce81612192565b9050919050565b7f4552525f4f5054494f4e5f494e56414c49440000000000000000000000000000600082015250565b600061220b601283611da4565b9150612216826121d5565b602082019050919050565b6000602082019050818103600083015261223a816121fe565b9050919050565b6000819050919050565b600061226661226161225c846118a2565b612241565b6118a2565b9050919050565b60006122788261224b565b9050919050565b600061228a8261226d565b9050919050565b61229a8161227f565b82525050565b60006060820190506122b560008301866118d4565b6122c26020830185612291565b6122cf6040830184611875565b949350505050565b600081519050919050565b600081905092915050565b60005b8381101561230b5780820151818401526020810190506122f0565b60008484015250505050565b6000612322826122d7565b61232c81856122e2565b935061233c8185602086016122ed565b80840191505092915050565b60006123548284612317565b915081905092915050565b7f4552525f544f4b454e0000000000000000000000000000000000000000000000600082015250565b6000612395600983611da4565b91506123a08261235f565b602082019050919050565b600060208201905081810360008301526123c481612388565b9050919050565b6123d481611998565b81146123df57600080fd5b50565b6000815190506123f1816123cb565b92915050565b60006020828403121561240d5761240c6117ef565b5b600061241b848285016123e2565b91505092915050565b7f4552525f5452414e534645520000000000000000000000000000000000000000600082015250565b600061245a600c83611da4565b915061246582612424565b602082019050919050565b600060208201905081810360008301526124898161244d565b9050919050565b600061249b826117f9565b91506124a6836117f9565b92508282039050818111156124be576124bd611e8d565b5b92915050565b60006040820190506124d960008301856118d4565b6124e66020830184611875565b9392505050565b6000815190506124fc81611803565b92915050565b600060208284031215612518576125176117ef565b5b6000612526848285016124ed565b91505092915050565b7f4552525f5a45524f5f535550504c590000000000000000000000000000000000600082015250565b6000612565600f83611da4565b91506125708261252f565b602082019050919050565b6000602082019050818103600083015261259481612558565b9050919050565b7f4552525f52454749535452590000000000000000000000000000000000000000600082015250565b60006125d1600c83611da4565b91506125dc8261259b565b602082019050919050565b60006020820190508181036000830152612600816125c4565b9050919050565b7f4552525f554e415554485f4143434f554e540000000000000000000000000000600082015250565b600061263d601283611da4565b915061264882612607565b602082019050919050565b6000602082019050818103600083015261266c81612630565b905091905056fea264697066735822122047d41ca0f2e88e8d08bcf196d122a8378c2e0035d55b74c163578c19415d2c6f64736f6c63430008130033 +\ No newline at end of file diff --git a/python/evm_tokenvote/data/Voter.metadata.json b/python/evm_tokenvote/data/Voter.metadata.json @@ -1 +1 @@ -{"compiler":{"version":"0.8.19+commit.7dd6d404"},"language":"Solidity","output":{"abi":[{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_accountsRegistry","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_blockDeadline","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"voteTargetPpm","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"_proposalIdx","type":"uint256"}],"name":"ProposalAdded","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentProposal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"finalize","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"proposals","outputs":[{"internalType":"bytes32","name":"description","type":"bytes32"},{"internalType":"uint256","name":"supply","type":"uint256"},{"internalType":"uint256","name":"total","type":"uint256"},{"internalType":"uint256","name":"blockDeadline","type":"uint256"},{"internalType":"uint24","name":"targetVotePpm","type":"uint24"},{"internalType":"address","name":"proposer","type":"address"},{"internalType":"uint8","name":"state","type":"uint8"},{"internalType":"uint8","name":"scanCursor","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_description","type":"bytes32"},{"internalType":"uint256","name":"_blockWait","type":"uint256"},{"internalType":"uint24","name":"_targetVotePpm","type":"uint24"}],"name":"propose","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_description","type":"bytes32"},{"internalType":"bytes32[]","name":"_options","type":"bytes32[]"},{"internalType":"uint256","name":"_blockWait","type":"uint256"},{"internalType":"uint24","name":"_targetVotePpm","type":"uint24"}],"name":"proposeMulti","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"recover","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_proposalIndex","type":"uint256"},{"internalType":"uint8","name":"_count","type":"uint8"}],"name":"scan","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_optionIndex","type":"uint256"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"vote","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"compilationTarget":{"Voter.sol":"ERC20Vote"},"evmVersion":"byzantium","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":false,"runs":200},"remappings":[]},"sources":{"Voter.sol":{"keccak256":"0xde0c2d2b93eb1b8395ddda127f03853fd72fc50c4f03b2111bd12ad8174c54aa","license":"AGPL-3.0-or-later","urls":["bzz-raw://21663dac73fcb74ebbcba9da995c20ce56cfad1612ca106d53c84c21193aceb1","dweb:/ipfs/QmcrAcJBtKZmj1aqGH3uicbDEGBYwZqi9H52PXMJCbE4qa"]}},"version":1} +{"compiler":{"version":"0.8.19+commit.7dd6d404"},"language":"Solidity","output":{"abi":[{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_accountsRegistry","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_blockDeadline","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"voteTargetPpm","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"_proposalIdx","type":"uint256"}],"name":"ProposalAdded","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentProposal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"finalize","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"proposals","outputs":[{"internalType":"bytes32","name":"description","type":"bytes32"},{"internalType":"uint256","name":"supply","type":"uint256"},{"internalType":"uint256","name":"total","type":"uint256"},{"internalType":"uint256","name":"blockDeadline","type":"uint256"},{"internalType":"uint24","name":"targetVotePpm","type":"uint24"},{"internalType":"address","name":"proposer","type":"address"},{"internalType":"uint8","name":"state","type":"uint8"},{"internalType":"uint8","name":"scanCursor","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_description","type":"bytes32"},{"internalType":"uint256","name":"_blockWait","type":"uint256"},{"internalType":"uint24","name":"_targetVotePpm","type":"uint24"}],"name":"propose","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_description","type":"bytes32"},{"internalType":"bytes32[]","name":"_options","type":"bytes32[]"},{"internalType":"uint256","name":"_blockWait","type":"uint256"},{"internalType":"uint24","name":"_targetVotePpm","type":"uint24"}],"name":"proposeMulti","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"recover","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_proposalIndex","type":"uint256"},{"internalType":"uint8","name":"_count","type":"uint8"}],"name":"scan","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_optionIndex","type":"uint256"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"vote","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"compilationTarget":{"Voter.sol":"ERC20Vote"},"evmVersion":"byzantium","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":false,"runs":200},"remappings":[]},"sources":{"Voter.sol":{"keccak256":"0xb8270f6a79fdead93f5f83c67e3de1fe69aee6316d697a327fff692c10226e41","license":"AGPL-3.0-or-later","urls":["bzz-raw://2b44be01e24d05c3a6e51a78adfb4b6e04fdbc81a2003bfedf3e7ac5528e9266","dweb:/ipfs/QmVY4XtyfNb42Pt1xZ1z3EFYAh7qyscmfWDhEuWKWY44Jd"]}},"version":1} diff --git a/python/evm_tokenvote/unittest/base.py b/python/evm_tokenvote/unittest/base.py @@ -28,8 +28,8 @@ class TestEvmVote(TestGiftableToken): c = ERC20(self.chain_spec) o = c.total_supply(self.address, sender_address=self.accounts[0]) r = self.rpc.do(o) - supply = int(r, 16) - self.assertGreater(supply, 0) + self.supply = int(r, 16) + self.assertGreater(self.supply, 0) nonce_oracle = RPCNonceOracle(self.accounts[0], conn=self.conn) c = Voter(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) @@ -40,3 +40,9 @@ class TestEvmVote(TestGiftableToken): self.assertEqual(r['status'], 1) self.voter_address = to_checksum_address(r['contract_address']) logg.debug('published voter on address {} with hash {}'.format(self.voter_address, tx_hash)) + + self.alice = self.accounts[1] + self.bob = self.accounts[2] + self.carol = self.accounts[3] + self.dave = self.accounts[4] + self.mallory = self.accounts[8] diff --git a/python/evm_tokenvote/voter.py b/python/evm_tokenvote/voter.py @@ -1,6 +1,7 @@ # standard imports import logging import os +import enum # external imports from chainlib.eth.constant import ZERO_ADDRESS @@ -29,6 +30,32 @@ from evm_tokenvote.data import data_dir logg = logging.getLogger() +class ProposalState(enum.IntEnum): + INIT = 1 + FINAL = 2 + SCANNED = 4 + INSUFFICIENT = 8 + TIED = 16 + SUPPLYCHANGE = 32 + + +class Proposal: + + def __init__(self, description_digest, *args, **kwargs): + self.description_digest = description_digest + self.supply = kwargs.get('supply') + self.total = kwargs.get('total') + self.block_deadline = kwargs.get('block_deadline') + self.target_vote_ppm = kwargs.get('target_vote_ppm') + self.proposer = kwargs.get('proposer') + self.state = kwargs.get('state') + self.serial = kwargs.get('serial') + + + def __str__(self): + return "proposal with description: " + self.description_digest + + class Voter(TxFactory): __abi = None @@ -97,3 +124,63 @@ class Voter(TxFactory): tx = self.finalize(tx, tx_format, id_generator=id_generator) return tx + + def get_proposal(self, contract_address, proposal_idx, sender_address=ZERO_ADDRESS, id_generator=None): + j = JSONRPCRequest(id_generator) + o = j.template() + o['method'] = 'eth_call' + enc = ABIContractEncoder() + enc.method('proposals') + enc.typ(ABIContractType.UINT256) + enc.uint256(proposal_idx) + data = add_0x(enc.get()) + tx = self.template(sender_address, contract_address) + tx = self.set_code(tx, data) + o['params'].append(self.normalize(tx)) + o['params'].append('latest') + o = j.finalize(o) + return o + + + @classmethod + def parse_proposal(self, v, serial=None): + v = strip_0x(v) + logg.debug("proposal {}".format(v)) + + cursor = 0 + dec = ABIContractDecoder() + dec.typ(ABIContractType.BYTES32) + dec.typ(ABIContractType.UINT256) + dec.typ(ABIContractType.UINT256) + dec.typ(ABIContractType.UINT256) + dec.typ(ABIContractType.UINT256) # actually uint24 + dec.typ(ABIContractType.ADDRESS) + dec.typ(ABIContractType.UINT8) + dec.val(v[cursor:cursor+64]) + #cursor += 64 # options pos + #cursor += 64 # optionsvotes pos + cursor += 64 + dec.val(v[cursor:cursor+64]) + cursor += 64 + dec.val(v[cursor:cursor+64]) + cursor += 64 + dec.val(v[cursor:cursor+64]) + cursor += 64 + dec.val(v[cursor:cursor+64]) + cursor += 64 + dec.val(v[cursor:cursor+64]) + cursor += 64 + dec.val(v[cursor:cursor+64]) + + r = dec.get() + logg.debug('rrr {}'.format(r)) + o = Proposal(r[0], + supply=r[1], + total=r[2], + block_deadline=r[3], + target_vote_ppm=r[4], + proposer=r[5], + state=r[6], + serial=serial, + ) + return o diff --git a/python/tests/test_base.py b/python/tests/test_base.py @@ -4,18 +4,25 @@ import logging import os from chainlib.eth.nonce import RPCNonceOracle from chainlib.eth.tx import receipt +from chainlib.eth.block import block_latest +from chainlib.eth.block import block_by_number +from hexathon import same as same_hex # local imports from evm_tokenvote.unittest import TestEvmVote from evm_tokenvote import Voter +from evm_tokenvote import ProposalState logging.basicConfig(level=logging.DEBUG) +logg = logging.getLogger() + +hash_of_foo = '2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae' class TestVoteBase(TestEvmVote): def test_propose(self): - description = os.urandom(32).hex() + description = hash_of_foo nonce_oracle = RPCNonceOracle(self.accounts[1], conn=self.conn) c = Voter(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) (tx_hash, o) = c.propose(self.voter_address, self.accounts[1], description, 100) @@ -24,6 +31,21 @@ class TestVoteBase(TestEvmVote): r = self.rpc.do(o) self.assertEqual(r['status'], 1) + o = block_latest() + block_height = self.rpc.do(o) + + o = c.get_proposal(self.voter_address, 0, sender_address=self.accounts[0]) + r = self.rpc.do(o) + proposal = c.parse_proposal(r) + logg.debug('proposal {}'.format(proposal)) + self.assertTrue(same_hex(proposal.description_digest, description)) + self.assertEqual(proposal.supply, self.supply) + self.assertEqual(proposal.total, 0) + self.assertEqual(proposal.block_deadline, block_height + 100) + self.assertEqual(proposal.target_vote_ppm, 500000) + self.assertTrue(same_hex(proposal.proposer, self.alice)) + self.assertEqual(proposal.state, ProposalState.INIT) + if __name__ == '__main__': unittest.main() diff --git a/solidity/Voter.sol b/solidity/Voter.sol @@ -9,11 +9,12 @@ pragma solidity ^0.8.0; // TODO: voter registration vote, to enforce 50% per-entity cap rule contract ERC20Vote { - uint8 constant STATE_FINAL = 1; - uint8 constant STATE_SCANNED = 2; - uint8 constant STATE_INSUFFICIENT = 4; - uint8 constant STATE_TIED = 8; - uint8 constant STATE_SUPPLYCHANGE = 16; + uint8 constant STATE_INIT = 1; + uint8 constant STATE_FINAL = 2; + uint8 constant STATE_SCANNED = 4; + uint8 constant STATE_INSUFFICIENT = 8; + uint8 constant STATE_TIED = 16; + uint8 constant STATE_SUPPLYCHANGE = 32; address public token; @@ -59,6 +60,7 @@ contract ERC20Vote { l_blockDeadline = block.number + _blockWait; l_proposal.blockDeadline = l_blockDeadline; l_proposalIndex = proposals.length; + l_proposal.state = STATE_INIT; proposals.push(l_proposal); l_proposal.supply = checkSupply(proposals[l_proposalIndex]);