From 364731b2209088ca06d8d14bf50808f553395073 Mon Sep 17 00:00:00 2001 From: nolash Date: Mon, 15 Feb 2021 18:20:00 +0100 Subject: [PATCH] Add legacy deploy script, python pacakging --- python/MANIFEST.in | 1 + python/requirements.txt | 2 + .../data/RedistributedDemurrageToken.bin | 1 + .../data/RedistributedDemurrageToken.json | 1 + python/sarafu_token/runnable/legacy/deploy.py | 133 ++++++++++++++++++ python/setup.cfg | 41 ++++++ python/setup.py | 10 ++ solidity/RedistributedDemurrageToken.sol | 8 +- 8 files changed, 193 insertions(+), 4 deletions(-) create mode 100644 python/MANIFEST.in create mode 100644 python/requirements.txt create mode 100644 python/sarafu_token/data/RedistributedDemurrageToken.bin create mode 100644 python/sarafu_token/data/RedistributedDemurrageToken.json create mode 100644 python/sarafu_token/runnable/legacy/deploy.py create mode 100644 python/setup.cfg create mode 100644 python/setup.py diff --git a/python/MANIFEST.in b/python/MANIFEST.in new file mode 100644 index 0000000..bfb091f --- /dev/null +++ b/python/MANIFEST.in @@ -0,0 +1 @@ +include sarafu_token/data/* diff --git a/python/requirements.txt b/python/requirements.txt new file mode 100644 index 0000000..a136619 --- /dev/null +++ b/python/requirements.txt @@ -0,0 +1,2 @@ +chainlib~=0.0.1a7 +crypto-dev-signer~=0.4.13rc2 diff --git a/python/sarafu_token/data/RedistributedDemurrageToken.bin b/python/sarafu_token/data/RedistributedDemurrageToken.bin new file mode 100644 index 0000000..c47baf9 --- /dev/null +++ b/python/sarafu_token/data/RedistributedDemurrageToken.bin @@ -0,0 +1 @@ +60e06040523480156200001157600080fd5b50604051620033c2380380620033c2833981810160405281019062000037919062000416565b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600960008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055504260808181525050603c82620001079190620006dd565b60a08181525050856001908051906020019062000126929190620002af565b5084600290805190602001906200013f929190620002af565b508360ff16600381905550620f42406d04ee2d6d415b85acef8100000000620001699190620006dd565b6006819055507001000000000000000000000000000000006006600082825417925050819055508260c0818152505080600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000620001fe6000620f4240600060016200024e640100000000026401000000009004565b905060078190806001815401808255809150506001900390600052602060002001600090919091909150558460ff16600a6200023b9190620005a0565b60058190555050505050505050620008dd565b600080608c620fffff86169060020a02600102811790506068640fffffffff87169060020a0260010281179050602068ffffffffffffffffff85169060020a026001028117905063ffffffff83166001028117905080915050949350505050565b828054620002bd90620007bf565b90600052602060002090601f016020900481019282620002e157600085556200032d565b82601f10620002fc57805160ff19168380011785556200032d565b828001600101855582156200032d579182015b828111156200032c5782518255916020019190600101906200030f565b5b5090506200033c919062000340565b5090565b5b808211156200035b57600081600090555060010162000341565b5090565b600062000376620003708462000512565b620004de565b9050828152602081018484840111156200038f57600080fd5b6200039c84828562000789565b509392505050565b600081519050620003b5816200088f565b92915050565b600082601f830112620003cd57600080fd5b8151620003df8482602086016200035f565b91505092915050565b600081519050620003f981620008a9565b92915050565b6000815190506200041081620008c3565b92915050565b60008060008060008060c087890312156200043057600080fd5b600087015167ffffffffffffffff8111156200044b57600080fd5b6200045989828a01620003bb565b965050602087015167ffffffffffffffff8111156200047757600080fd5b6200048589828a01620003bb565b95505060406200049889828a01620003ff565b9450506060620004ab89828a01620003e8565b9350506080620004be89828a01620003e8565b92505060a0620004d189828a01620003a4565b9150509295509295509295565b6000604051905081810181811067ffffffffffffffff8211171562000508576200050762000853565b5b8060405250919050565b600067ffffffffffffffff82111562000530576200052f62000853565b5b601f19601f8301169050602081019050919050565b6000808291508390505b600185111562000597578086048111156200056f576200056e620007f5565b5b60018516156200057f5780820291505b80810290506200058f8562000882565b94506200054f565b94509492505050565b6000620005ad8262000772565b9150620005ba8362000772565b9250620005e97fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8484620005f1565b905092915050565b600082620006035760019050620006d6565b81620006135760009050620006d6565b81600181146200062c576002811462000637576200066d565b6001915050620006d6565b60ff8411156200064c576200064b620007f5565b5b8360020a915084821115620006665762000665620007f5565b5b50620006d6565b5060208310610133831016604e8410600b8410161715620006a75782820a905083811115620006a157620006a0620007f5565b5b620006d6565b620006b6848484600162000545565b92509050818404811115620006d057620006cf620007f5565b5b81810290505b9392505050565b6000620006ea8262000772565b9150620006f78362000772565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615620007335762000732620007f5565b5b828202905092915050565b60006200074b8262000752565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b83811015620007a95780820151818401526020810190506200078c565b83811115620007b9576000848401525b50505050565b60006002820490506001821680620007d857607f821691505b60208210811415620007ef57620007ee62000824565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000600282049050919050565b6200089a816200073e565b8114620008a657600080fd5b50565b620008b48162000772565b8114620008c057600080fd5b50565b620008ce816200077c565b8114620008da57600080fd5b50565b60805160a05160c051612a766200094c60003960008181610a1401528181610b7c01528181610cfb015281816116e701528181611cfc0152611d34015260008181610f98015281816116410152611782015260008181610fc4015281816117a301526117e80152612a766000f3fe608060405234801561001057600080fd5b506004361061022e576000357c0100000000000000000000000000000000000000000000000000000000900480636d5055a611610142578063a9059cbb116100ca578063e3ab207a11610099578063e3ab207a1461070d578063e54d63f71461073d578063e80952951461076d578063eda4e6d61461078b578063fc958aed146107a95761022e565b8063a9059cbb1461065f578063b470aade1461068f578063bf4c16f1146106ad578063d2ae3991146106dd5761022e565b80638da5cb5b116101115780638da5cb5b146105a55780638f1df6bc146105c357806395d89b41146105e1578063983b2d56146105ff5780639da7d8ba1461062f5761022e565b80636d5055a6146104f75780636ffa8a051461052757806370a0823114610557578063731f237c146105875761022e565b8063313ce567116101c5578063449a52f811610194578063449a52f8146104195780634abfbba214610449578063573cc507146104795780636787a9be146104975780636a2d094e146104c75761022e565b8063313ce5671461036b57806335b16eb81461038957806340452d91146103b957806340fc89f5146103e95761022e565b8063216ea5ec11610201578063216ea5ec146102bd578063229ba197146102ed57806323b872dd1461030b578063313334871461033b5761022e565b806306fdde0314610233578063095ea7b31461025157806318160ddd146102815780631989c6a81461029f575b600080fd5b61023b6107c7565b604051610248919061268f565b60405180910390f35b61026b60048036038101906102669190612416565b610855565b6040516102789190612659565b60405180910390f35b610289610979565b6040516102969190612711565b60405180910390f35b6102a761097f565b6040516102b49190612711565b60405180910390f35b6102d760048036038101906102d291906124cd565b61098c565b6040516102e49190612711565b60405180910390f35b6102f5610a12565b6040516103029190612711565b60405180910390f35b610325600480360381019061032091906123c7565b610a36565b6040516103329190612659565b60405180910390f35b610355600480360381019061035091906124cd565b610b60565b6040516103629190612711565b60405180910390f35b610373610c11565b6040516103809190612711565b60405180910390f35b6103a3600480360381019061039e919061239e565b610c17565b6040516103b09190612659565b60405180910390f35b6103d360048036038101906103ce919061247b565b610e3d565b6040516103e09190612674565b60405180910390f35b61040360048036038101906103fe9190612452565b610e61565b6040516104109190612711565b60405180910390f35b610433600480360381019061042e9190612416565b610e92565b6040516104409190612659565b60405180910390f35b610463600480360381019061045e919061247b565b610f94565b6040516104709190612711565b60405180910390f35b610481610ff4565b60405161048e9190612711565b60405180910390f35b6104b160048036038101906104ac919061247b565b610ffa565b6040516104be9190612711565b60405180910390f35b6104e160048036038101906104dc919061247b565b611040565b6040516104ee9190612711565b60405180910390f35b610511600480360381019061050c919061239e565b611061565b60405161051e9190612711565b60405180910390f35b610541600480360381019061053c9190612452565b6110c9565b60405161054e9190612711565b60405180910390f35b610571600480360381019061056c919061239e565b6110fc565b60405161057e9190612711565b60405180910390f35b61058f611194565b60405161059c9190612659565b60405180910390f35b6105ad611274565b6040516105ba919061263e565b60405180910390f35b6105cb611298565b6040516105d89190612659565b60405180910390f35b6105e9611429565b6040516105f6919061268f565b60405180910390f35b6106196004803603810190610614919061239e565b6114b7565b6040516106269190612659565b60405180910390f35b61064960048036038101906106449190612452565b611573565b6040516106569190612711565b60405180910390f35b61067960048036038101906106749190612416565b61159f565b6040516106869190612659565b60405180910390f35b61069761163f565b6040516106a49190612711565b60405180910390f35b6106c760048036038101906106c2919061247b565b611663565b6040516106d49190612711565b60405180910390f35b6106f760048036038101906106f2919061247b565b61167f565b6040516107049190612711565b60405180910390f35b61072760048036038101906107229190612452565b6116b7565b6040516107349190612711565b60405180910390f35b610757600480360381019061075291906124cd565b6116cb565b6040516107649190612711565b60405180910390f35b61077561177c565b6040516107829190612711565b60405180910390f35b6107936117e6565b6040516107a09190612711565b60405180910390f35b6107b161180a565b6040516107be9190612711565b60405180910390f35b600180546107d4906128e2565b80601f0160208091040260200160405190810160405280929190818152602001828054610800906128e2565b801561084d5780601f106108225761010080835404028352916020019161084d565b820191906000526020600020905b81548152906001019060200180831161083057829003601f168201915b505050505081565b600080610860611298565b5061086a33610c17565b5061087483610ffa565b905080600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546109029190612748565b925050819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040516109669190612711565b60405180910390a3600191505092915050565b60045481565b6000600780549050905090565b6000806000808514156109d4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109cb906126b1565b60405180910390fd5b8385106109e057600080fd5b84846109ec919061279e565b915084826109fa91906127cf565b90508084610a089190612829565b9250505092915050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000806000610a43611298565b50610a4d33610c17565b50610a5784610ffa565b915081600a60008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610ae257600080fd5b610aed868684611810565b90508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef86604051610b4c9190612711565b60405180910390a380925050509392505050565b6000806000620f424091506d04ee2d6d415b85acef81000000007f0000000000000000000000000000000000000000000000000000000000000000610ba5919061279e565b905060005b84811015610bec57620f42408284610bc291906127cf565b610bcc919061279e565b83610bd79190612829565b92508080610be490612914565b915050610baa565b50620f42408583610bfd91906127cf565b610c07919061279e565b9250505092915050565b60035481565b600080600080600080600080610c2c89611061565b91506000821480610c445750610c4061177c565b8210155b15610c59576000975050505050505050610e38565b6007600183610c689190612829565b81548110610c9f577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549650610cb587610e61565b94506000851415610cd0576000975050505050505050610e38565b610cd987611573565b9550610ce4876110c9565b90506d04ee2d6d415b85acef8100000000620f42407f0000000000000000000000000000000000000000000000000000000000000000610d24919061279e565b8688610d30919061279e565b610d3a91906127cf565b610d44919061279e565b9350620f42408185610d5691906127cf565b610d60919061279e565b92507fffffffffffffffffffffffffffffffffffffff00000000ffffffffffffffffff600102600860008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282541692505081905550610ddc89846118a2565b50818973ffffffffffffffffffffffffffffffffffffffff167f9a2a887706623ad3ff7fc85652deeceabe9fe1e00466c597972079ee91ea40d385604051610e249190612711565b60405180910390a360019750505050505050505b919050565b60078181548110610e4d57600080fd5b906000526020600020016000915090505481565b60006068710fffffffff00000000000000000000000000600102831660019004908060020a82049150509050919050565b600080600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610eeb57600080fd5b610ef3611298565b508290508260046000828254610f099190612748565b92505081905550610f1a84826118a2565b508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fab8530f87dc9b59234c4623bf917212bb2536d647574c8e7e5da92c2ede0c9f885604051610f789190612711565b60405180910390a3610f88611a14565b50600191505092915050565b60007f000000000000000000000000000000000000000000000000000000000000000082610fc291906127cf565b7f0000000000000000000000000000000000000000000000000000000000000000610fed9190612748565b9050919050565b60055481565b6000611007600654611663565b620f42406d04ee2d6d415b85acef81000000008461102591906127cf565b61102f91906127cf565b611039919061279e565b9050919050565b6000603c82426110509190612829565b61105a919061279e565b9050919050565b600060486cffffffff000000000000000000600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546001900416908060020a82049150509050919050565b6000608c73fffff00000000000000000000000000000000000600102831660019004908060020a82049150509050919050565b60008060008060008061110e87611b0b565b945061111b600654611663565b935061112860065461167f565b925061113560065461167f565b61113d61177c565b6111479190612829565b90506111538482610b60565b9150620f42406d04ee2d6d415b85acef810000000061117291906127cf565b828661117e91906127cf565b611188919061279e565b95505050505050919050565b60008060008060006111a461177c565b93506111b160065461167f565b846111bc9190612829565b925060008314156111d4576000945050505050611271565b6111df600654611663565b91506111eb8284610b60565b905060006006819055506fffffffffffffffffffffffffffffffff81166006600082825417925050819055506080849060020a026006600082825417925050819055508183857fa0717e54e02bd9829db5e6e998aec0ae9de796b8d150a3cc46a92ab869697755846040516112609190612711565b60405180910390a460019450505050505b90565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060008060008060008060008060006112b1611b63565b995060006001028a14156112d25760009a5050505050505050505050611426565b6112db8a6116b7565b97506001886112ea9190612748565b90506112f588610f94565b91506112ff611194565b5061130b600654611663565b945061131682611040565b9250600083111561134b576d04ee2d6d415b85acef810000000061133a86856116cb565b611344919061279e565b9350611368565b6d04ee2d6d415b85acef810000000085611365919061279e565b93505b61137760008560045484611c82565b985060078990806001815401808255809150506001900390600052602060002001600090919091909150556113ab8a610e61565b965060008714156113c6576113bf8a611ce3565b95506113e0565b6113d28760045461098c565b95506113de8689611ed6565b505b7f55d243082e019fce4009ccea5368b92e436c17586a1e793c7deda16df4e5d6758160405161140f9190612711565b60405180910390a160019a50505050505050505050505b90565b60028054611436906128e2565b80601f0160208091040260200160405190810160405280929190818152602001828054611462906128e2565b80156114af5780601f10611484576101008083540402835291602001916114af565b820191906000526020600020905b81548152906001019060200180831161149257829003601f168201915b505050505081565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461151257600080fd5b6001600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b600060206cffffffffffffffffff00000000600102831660019004908060020a82049150509050919050565b60008060006115ac611298565b506115b633610c17565b506115c084610ffa565b91506115cd338684611810565b90508473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8660405161162c9190612711565b60405180910390a3809250505092915050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60006fffffffffffffffffffffffffffffffff82169050919050565b600060807fffffffffffffffffffffffffffffffff000000000000000000000000000000008316908060020a82049150509050919050565b600063ffffffff8260019004169050919050565b6000806000620f424091506d04ee2d6d415b85acef81000000007f0000000000000000000000000000000000000000000000000000000000000000611710919061279e565b905060005b8481101561175757620f4240828461172d91906127cf565b611737919061279e565b836117429190612748565b9250808061174f90612914565b915050611715565b50620f4240858361176891906127cf565b611772919061279e565b9250505092915050565b600060017f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000426117cd9190612829565b6117d7919061279e565b6117e19190612748565b905090565b7f000000000000000000000000000000000000000000000000000000000000000081565b60065481565b60008061181d858461200c565b5061182884846118a2565b5061183161177c565b9050600554831015801561184d57508061184a86611061565b14155b801561188557508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b15611896576118948582612153565b505b60019150509392505050565b600080600080600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460019004905060008514156119035760009350505050611a0e565b61190c86611b0b565b9250848361191a9190612748565b91508273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161161198a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611981906126f1565b60405180910390fd5b7f0fffffffffffffffffffffffffffffffffffffffffffff0000000000000000008116905068ffffffffffffffffff82168117905080600102600860008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600193505050505b92915050565b60008060076001600780549050611a2b9190612829565b81548110611a62577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001546001900490507fffffffffffffffffffffffffffffffffffffff000000000000000000ffffffff8116905060206004549060020a02811790508060010260076001600780549050611abe9190612829565b81548110611af5577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200181905550600191505090565b600068ffffffffffffffffff600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460019004169050919050565b600080600060076001600780549050611b7c9190612829565b81548110611bb3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015491503073ffffffffffffffffffffffffffffffffffffffff1663e80952956040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040160206040518083038186803b158015611c2257600080fd5b505afa158015611c36573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c5a91906124a4565b9050611c65826116b7565b8111611c7957600060010292505050611c7f565b81925050505b90565b600080608c620fffff86169060020a02600102811790506068640fffffffff87169060020a0260010281179050602068ffffffffffffffffff85169060020a026001028117905063ffffffff83166001028117905080915050949350505050565b6000806000806000611cf486611573565b9350620f42407f000000000000000000000000000000000000000000000000000000000000000085611d2691906127cf565b611d30919061279e565b91507f0000000000000000000000000000000000000000000000000000000000000000620f424083611d6291906127cf565b611d6c919061279e565b905083811015611e8457611d7f866116b7565b92507ffffffffffffffffffffffffffffff000000000ffffffffffffffffffffffffff6001026007600185611db49190612829565b81548110611deb577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001600082825416925050819055507f80000000000000000000000000000000000001000000000000000000000000006001026007600185611e359190612829565b81548110611e6c577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001600082825417925050819055505b611ec9600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166d04ee2d6d415b85acef810000000084611ec4919061279e565b6118a2565b5081945050505050919050565b6000806000841415611eec576000915050612006565b7f80000000000000000000000000000000000000000000000000000000000000006001026007600185611f1f9190612829565b81548110611f56577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200160008282541792505081905550611fc66007600185611f7f9190612829565b81548110611fb6577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200154611573565b9050611fff600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168583611ffa9190612829565b6118a2565b5060019150505b92915050565b600080600080600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600190049050600085141561206d576000935050505061214d565b61207686611b0b565b9250848310156120bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120b2906126d1565b60405180910390fd5b84836120c79190612829565b91507f0fffffffffffffffffffffffffffffffffffffffffffff0000000000000000008116905068ffffffffffffffffff82168117905080600102600860008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600193505050505b92915050565b60007fffffffffffffffffffffffffffffffffffffff00000000ffffffffffffffffff600102600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825416925050819055506048829060020a02600102600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254179250508190555061222461222f565b506001905092915050565b600080600080600760016007805490506122499190612829565b81548110612280577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549250600161229884610e61565b6122a29190612748565b9050826001900491507ffffffffffffffffffffffffffffff000000000ffffffffffffffffffffffffff821691506068640fffffffff82169060020a028217915081600102600760016007805490506122fb9190612829565b81548110612332577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001819055506001935050505090565b600081359050612359816129fb565b92915050565b60008135905061236e81612a12565b92915050565b60008135905061238381612a29565b92915050565b60008151905061239881612a29565b92915050565b6000602082840312156123b057600080fd5b60006123be8482850161234a565b91505092915050565b6000806000606084860312156123dc57600080fd5b60006123ea8682870161234a565b93505060206123fb8682870161234a565b925050604061240c86828701612374565b9150509250925092565b6000806040838503121561242957600080fd5b60006124378582860161234a565b925050602061244885828601612374565b9150509250929050565b60006020828403121561246457600080fd5b60006124728482850161235f565b91505092915050565b60006020828403121561248d57600080fd5b600061249b84828501612374565b91505092915050565b6000602082840312156124b657600080fd5b60006124c484828501612389565b91505092915050565b600080604083850312156124e057600080fd5b60006124ee85828601612374565b92505060206124ff85828601612374565b9150509250929050565b6125128161285d565b82525050565b6125218161286f565b82525050565b6125308161287b565b82525050565b60006125418261272c565b61254b8185612737565b935061255b8185602086016128af565b612564816129ea565b840191505092915050565b600061257c601183612737565b91507f4552525f4e554d50415254535f5a45524f0000000000000000000000000000006000830152602082019050919050565b60006125bc600d83612737565b91507f4552525f4f5645525350454e44000000000000000000000000000000000000006000830152602082019050919050565b60006125fc600d83612737565b91507f4552525f574f554c4457524150000000000000000000000000000000000000006000830152602082019050919050565b612638816128a5565b82525050565b60006020820190506126536000830184612509565b92915050565b600060208201905061266e6000830184612518565b92915050565b60006020820190506126896000830184612527565b92915050565b600060208201905081810360008301526126a98184612536565b905092915050565b600060208201905081810360008301526126ca8161256f565b9050919050565b600060208201905081810360008301526126ea816125af565b9050919050565b6000602082019050818103600083015261270a816125ef565b9050919050565b6000602082019050612726600083018461262f565b92915050565b600081519050919050565b600082825260208201905092915050565b6000612753826128a5565b915061275e836128a5565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156127935761279261295d565b5b828201905092915050565b60006127a9826128a5565b91506127b4836128a5565b9250826127c4576127c361298c565b5b828204905092915050565b60006127da826128a5565b91506127e5836128a5565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561281e5761281d61295d565b5b828202905092915050565b6000612834826128a5565b915061283f836128a5565b9250828210156128525761285161295d565b5b828203905092915050565b600061286882612885565b9050919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60005b838110156128cd5780820151818401526020810190506128b2565b838111156128dc576000848401525b50505050565b600060028204905060018216806128fa57607f821691505b6020821081141561290e5761290d6129bb565b5b50919050565b600061291f826128a5565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156129525761295161295d565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b612a048161285d565b8114612a0f57600080fd5b50565b612a1b8161287b565b8114612a2657600080fd5b50565b612a32816128a5565b8114612a3d57600080fd5b5056fea264697066735822122012e9ed085ca83069d0ec935bb2fb378e48d4b9e93ce05314108c6fc2f5f7814b64736f6c63430008000033 \ No newline at end of file diff --git a/python/sarafu_token/data/RedistributedDemurrageToken.json b/python/sarafu_token/data/RedistributedDemurrageToken.json new file mode 100644 index 0000000..5d5f6e7 --- /dev/null +++ b/python/sarafu_token/data/RedistributedDemurrageToken.json @@ -0,0 +1 @@ +[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"_decimals","type":"uint8"},{"internalType":"uint256","name":"_taxLevelMinute","type":"uint256"},{"internalType":"uint256","name":"_periodMinutes","type":"uint256"},{"internalType":"address","name":"_defaultSinkAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"_foo","type":"bytes32"}],"name":"Debug","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_period","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"_periodCount","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"_oldAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_newAmount","type":"uint256"}],"name":"Decayed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_minter","type":"address"},{"indexed":true,"internalType":"address","name":"_beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_period","type":"uint256"}],"name":"Period","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_account","type":"address"},{"indexed":true,"internalType":"uint256","name":"_period","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Redistribution","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"accountPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"actualPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_minter","type":"address"}],"name":"addMinter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"applyDemurrage","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"applyRedistributionOnAccount","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"changePeriod","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"uint256","name":"_period","type":"uint256"}],"name":"decayBy","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_target","type":"uint256"}],"name":"demurrageCycles","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"demurrageModifier","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_periodCount","type":"uint256"}],"name":"getPeriodTimeDelta","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"uint256","name":"_period","type":"uint256"}],"name":"growBy","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minimumParticipantSpend","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_beneficiary","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"mintTo","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"periodDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"periodStart","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"redistributionCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"redistributions","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_numParts","type":"uint256"},{"internalType":"uint256","name":"_sumWhole","type":"uint256"}],"name":"remainder","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"taxLevel","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"toBaseAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_demurrage","type":"uint256"}],"name":"toDemurrageAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"_demurrage","type":"uint256"}],"name":"toDemurragePeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"redistribution","type":"bytes32"}],"name":"toRedistributionDemurrageModifier","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"redistribution","type":"bytes32"}],"name":"toRedistributionParticipants","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"redistribution","type":"bytes32"}],"name":"toRedistributionPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"redistribution","type":"bytes32"}],"name":"toRedistributionSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}] diff --git a/python/sarafu_token/runnable/legacy/deploy.py b/python/sarafu_token/runnable/legacy/deploy.py new file mode 100644 index 0000000..630b12f --- /dev/null +++ b/python/sarafu_token/runnable/legacy/deploy.py @@ -0,0 +1,133 @@ +"""Deploys Sarafu token + +.. moduleauthor:: Louis Holbrook +.. pgp:: 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 + +""" + +# SPDX-License-Identifier: GPL-3.0-or-later + +# standard imports +import sys +import os +import json +import argparse +import logging +import time +from enum import Enum + +# third-party imports +import web3 +from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer +from crypto_dev_signer.keystore import DictKeystore +from crypto_dev_signer.eth.helper import EthTxExecutor + +logging.basicConfig(level=logging.WARNING) +logg = logging.getLogger() + +logging.getLogger('web3').setLevel(logging.WARNING) +logging.getLogger('urllib3').setLevel(logging.WARNING) + +script_dir = os.path.dirname(__file__) +data_dir = os.path.join(script_dir, '..', '..', 'data') + + +argparser = argparse.ArgumentParser() +argparser.add_argument('-p', '--provider', dest='p', default='http://localhost:8545', type=str, help='Web3 provider url (http only)') +argparser.add_argument('-w', action='store_true', help='Wait for the last transaction to be confirmed') +argparser.add_argument('-ww', action='store_true', help='Wait for every transaction to be confirmed') +argparser.add_argument('-e', action='store_true', help='Treat all transactions as essential') +argparser.add_argument('-i', '--chain-spec', dest='i', type=str, default='Ethereum:1', help='Chain specification string') +argparser.add_argument('-y', '--key-file', dest='y', type=str, help='Ethereum keystore file to use for signing') +argparser.add_argument('--name', dest='n', default='Giftable Token', type=str, help='Token name') +argparser.add_argument('--symbol', dest='s', default='GFT', type=str, help='Token symbol') +argparser.add_argument('--decimals', dest='d', default=18, type=int, help='Token decimals') +argparser.add_argument('--minter', action='append', type=str, help='Minter to add') +argparser.add_argument('--sink-address', type=str, help='Sink address (if not set, signer address is used)') +argparser.add_argument('--abi-dir', dest='abi_dir', type=str, default=data_dir, help='Directory containing bytecode and abi (default: {})'.format(data_dir)) + +argparser.add_argument('-v', action='store_true', help='Be verbose') +argparser.add_argument('taxlevel_minute', type=int, help='Tax level per minute in ppm') +argparser.add_argument('period_minutes', type=int, help='Redistribution period, in minutes') +args = argparser.parse_args() + +if args.v: + logg.setLevel(logging.DEBUG) + +block_last = args.w +block_all = args.ww + +w3 = web3.Web3(web3.Web3.HTTPProvider(args.p)) + +signer_address = None +keystore = DictKeystore() +if args.y != None: + logg.debug('loading keystore file {}'.format(args.y)) + signer_address = keystore.import_keystore_file(args.y) + logg.debug('now have key for signer address {}'.format(signer_address)) +signer = EIP155Signer(keystore) + +chain_pair = args.i.split(':') +chain_id = int(chain_pair[1]) + +helper = EthTxExecutor( + w3, + signer_address, + signer, + chain_id, + block=args.ww, + ) +#g = ERC20TxFactory(signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle, chain_id=chain_id) + + +def main(): + + f = open(os.path.join(args.abi_dir, 'RedistributedDemurrageToken.json'), 'r') + abi = json.load(f) + f.close() + + f = open(os.path.join(args.abi_dir, 'RedistributedDemurrageToken.bin'), 'r') + bytecode = f.read() + f.close() + + sink_address = args.sink_address + if sink_address == None: + sink_address = signer_address + + c = w3.eth.contract(abi=abi, bytecode=bytecode) + (tx_hash, rcpt) = helper.sign_and_send( + [ + c.constructor(args.n, args.s, args.d, args.taxlevel_minute, args.period_minutes, sink_address).buildTransaction + ], + force_wait=True, + ) + logg.debug('tx hash {} rcpt {}'.format(tx_hash, rcpt)) + + address = rcpt.contractAddress + logg.debug('token contract mined {} {} {} {}'.format(address, args.n, args.s, args.d, args.taxlevel_minute, args.period_minutes, sink_address)) + c = w3.eth.contract(abi=abi, address=address) + + balance = c.functions.balanceOf(signer_address).call() + logg.info('balance {}: {} {}'.format(signer_address, balance, tx_hash)) + + if args.minter != None: + for a in args.minter: + if a == signer_address: + continue + (tx_hash, rcpt) = helper.sign_and_send( + [ + c.functions.addMinter(a).buildTransaction, + ], + ) + logg.debug('minter add {} {}'.format(a, tx_hash)) + + if block_last: + helper.wait_for() + + print(address) + + sys.exit(0) + + +if __name__ == '__main__': + main() diff --git a/python/setup.cfg b/python/setup.cfg new file mode 100644 index 0000000..b1db9ce --- /dev/null +++ b/python/setup.cfg @@ -0,0 +1,41 @@ +[metadata] +name = sarafu-token +version = 0.0.1a1 +description = ERC20 token with redistributed continual demurrage +author = Louis Holbrook +author_email = dev@holbrook.no +url = https://gitlab.com/grassrootseconomics/sarafu-token +keywords = + ethereum +classifiers = + Programming Language :: Python :: 3 + Operating System :: OS Independent + Development Status :: 3 - Alpha + Environment :: No Input/Output (Daemon) + Intended Audience :: Developers + License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+) + Topic :: Internet + #Topic :: Blockchain :: EVM +license = GPL3 +licence_files = + LICENSE + +[options] +include_package_data = True +python_requires = >= 3.6 +packages = + sarafu_token + sarafu_token.runnable.legacy +install_requires = + chainlib~=0.0.1a7 + crypto-dev-signer~=0.4.13rc2 + web3==5.12.2 + +[options.package_data] +* = + data/RedistributedDemurrageToken.bin + data/RedistributedDemurrageToken.json + +[options.entry_points] +console_scripts = + sarafu-token-deploy = sarafu_faucet.runnable.legacy.deploy:main diff --git a/python/setup.py b/python/setup.py new file mode 100644 index 0000000..16759ec --- /dev/null +++ b/python/setup.py @@ -0,0 +1,10 @@ +from setuptools import setup + +setup( + package_data={ + '': [ + 'data/MintableFactor.bin', + ], + }, + include_package_data=True, + ) diff --git a/solidity/RedistributedDemurrageToken.sol b/solidity/RedistributedDemurrageToken.sol index 59fb6c8..76d25a6 100644 --- a/solidity/RedistributedDemurrageToken.sol +++ b/solidity/RedistributedDemurrageToken.sol @@ -65,7 +65,7 @@ contract RedistributedDemurrageToken { uint256 currentDemurrageAmount; uint256 periodCount; - baseBalance = getBaseBalance(_account); + baseBalance = baseBalanceOf(_account); anchorDemurrageAmount = toDemurrageAmount(demurrageModifier); anchorDemurragePeriod = toDemurragePeriod(demurrageModifier); @@ -77,7 +77,7 @@ contract RedistributedDemurrageToken { } /// Balance unmodified by demurrage - function getBaseBalance(address _account) private view returns (uint256) { + function baseBalanceOf(address _account) public view returns (uint256) { return uint256(account[_account]) & 0xffffffffffffffffff; } @@ -93,7 +93,7 @@ contract RedistributedDemurrageToken { return false; } - oldBalance = getBaseBalance(_account); + oldBalance = baseBalanceOf(_account); newBalance = oldBalance + _delta; require(uint160(newBalance) > uint160(oldBalance), 'ERR_WOULDWRAP'); // revert if increase would result in a wrapped value workAccount &= 0xfffffffffffffffffffffffffffffffffffffffffffff000000000000000000; @@ -114,7 +114,7 @@ contract RedistributedDemurrageToken { return false; } - oldBalance = getBaseBalance(_account); + oldBalance = baseBalanceOf(_account); require(oldBalance >= _delta, 'ERR_OVERSPEND'); // overspend guard newBalance = oldBalance - _delta; workAccount &= 0xfffffffffffffffffffffffffffffffffffffffffffff000000000000000000;