commit 33f193afb1c129bb2ef5c99c39ce9e2a68c85f98
parent 1d7721421534dc655dc22710445976b5b509438b
Author: lash <dev@holbrook.no>
Date: Tue, 30 May 2023 13:16:24 +0100
Add writer, owner, share/consume distinction
Diffstat:
6 files changed, 100 insertions(+), 24 deletions(-)
diff --git a/python/evm_booking/booking.py b/python/evm_booking/booking.py
@@ -80,15 +80,27 @@ class Booking(TxFactory):
return Booking.__bytecode
- def reserve(self, contract_address, sender_address, offset, count, share=False, tx_format=TxFormat.JSONRPC, id_generator=None):
+ def consume(self, contract_address, sender_address, offset, count, tx_format=TxFormat.JSONRPC, id_generator=None):
enc = ABIContractEncoder()
- enc.method('reserve')
+ enc.method('consume')
+ enc.typ(ABIContractType.UINT256)
+ enc.typ(ABIContractType.UINT256)
+ enc.uint256(offset)
+ enc.uint256(count)
+ data = add_0x(enc.get())
+ tx = self.template(sender_address, contract_address, use_nonce=True)
+ tx = self.set_code(tx, data)
+ tx = self.finalize(tx, tx_format, id_generator=id_generator)
+ return tx
+
+
+ def share(self, contract_address, sender_address, offset, count, tx_format=TxFormat.JSONRPC, id_generator=None):
+ enc = ABIContractEncoder()
+ enc.method('share')
enc.typ(ABIContractType.UINT256)
enc.typ(ABIContractType.UINT256)
- enc.typ(ABIContractType.BOOLEAN)
enc.uint256(offset)
enc.uint256(count)
- enc.uint256(share)
data = add_0x(enc.get())
tx = self.template(sender_address, contract_address, use_nonce=True)
tx = self.set_code(tx, data)
diff --git a/python/evm_booking/data/Booking.bin b/python/evm_booking/data/Booking.bin
@@ -1 +1 @@
-60806040523480156200001157600080fd5b5060405162001c1038038062001c10833981810160405281019062000037919062000393565b60008111801562000058575070010000000000000000000000000000000081105b6200009a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000091906200043b565b60405180910390fd5b620000a4620002cc565b620000be826200022f640100000000026401000000009004565b9050600181600060028110620000d957620000d86200045d565b5b6020020151620000ea9190620004bb565b67ffffffffffffffff811115620001065762000105620004f6565b5b6040519080825280601f01601f191660200182016040528015620001395781602001600182028036833780820191505090505b50600190816200014a91906200076c565b506001816000600281106200016457620001636200045d565b5b6020020151620001759190620004bb565b67ffffffffffffffff811115620001915762000190620004f6565b5b6040519080825280601f01601f191660200182016040528015620001c45781602001600182028036833780820191505090505b5060029081620001d591906200076c565b5081600381905550600354600481905550826000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505050620009cd565b62000239620002cc565b600062000245620002cc565b600160086001866200025891906200085d565b620002649190620008d6565b6200027091906200094a565b915081816000600281106200028a57620002896200045d565b5b602002018181525050600884620002a2919062000995565b81600160028110620002b957620002b86200045d565b5b6020020181815250508092505050919050565b6040518060400160405280600290602082028036833780820191505090505090565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006200032082620002f3565b9050919050565b620003328162000313565b81146200033e57600080fd5b50565b600081519050620003528162000327565b92915050565b6000819050919050565b6200036d8162000358565b81146200037957600080fd5b50565b6000815190506200038d8162000362565b92915050565b60008060408385031215620003ad57620003ac620002ee565b5b6000620003bd8582860162000341565b9250506020620003d0858286016200037c565b9150509250929050565b600082825260208201905092915050565b7f4552525f4e4f4e53454e53450000000000000000000000000000000000000000600082015250565b600062000423600c83620003da565b91506200043082620003eb565b602082019050919050565b60006020820190508181036000830152620004568162000414565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000620004c88262000358565b9150620004d58362000358565b9250828201905080821115620004f057620004ef6200048c565b5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806200057857607f821691505b6020821081036200058e576200058d62000530565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b60008160020a8302905092915050565b600060088302620005fb7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82620005b9565b620006078683620005b9565b95508019841693508086168417925050509392505050565b6000819050919050565b60006200064a620006446200063e8462000358565b6200061f565b62000358565b9050919050565b6000819050919050565b620006668362000629565b6200067e620006758262000651565b848454620005c9565b825550505050565b600090565b6200069562000686565b620006a28184846200065b565b505050565b5b81811015620006ca57620006be6000826200068b565b600181019050620006a8565b5050565b601f8211156200071957620006e38162000594565b620006ee84620005a9565b81016020851015620006fe578190505b620007166200070d85620005a9565b830182620006a7565b50505b505050565b60008160020a8304905092915050565b600062000741600019846008026200071e565b1980831691505092915050565b60006200075c83836200072e565b9150826002028217905092915050565b620007778262000525565b67ffffffffffffffff811115620007935762000792620004f6565b5b6200079f82546200055f565b620007ac828285620006ce565b600060209050601f831160018114620007e45760008415620007cf578287015190505b620007db85826200074e565b8655506200084b565b601f198416620007f48662000594565b60005b828110156200081e57848901518255600182019150602085019450602081019050620007f7565b868310156200083e57848901516200083a601f8916826200072e565b8355505b6001600288020188555050505b505050505050565b6000819050919050565b60006200086a8262000853565b9150620008778362000853565b9250828203905081811260008412168282136000851215161715620008a157620008a06200048c565b5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000620008e38262000853565b9150620008f08362000853565b925082620009035762000902620008a7565b5b600160000383147f8000000000000000000000000000000000000000000000000000000000000000831416156200093f576200093e6200048c565b5b828205905092915050565b6000620009578262000853565b9150620009648362000853565b9250828201905082811215600083121683821260008412151617156200098f576200098e6200048c565b5b92915050565b6000620009a28262000358565b9150620009af8362000358565b925082620009c257620009c1620008a7565b5b828206905092915050565b61123380620009dd6000396000f3fe608060405234801561001057600080fd5b5060043610610074576000357c01000000000000000000000000000000000000000000000000000000009004806318160ddd146100795780635cfc1a51146100975780637f03864b146100b5578063a245d9b9146100d3578063f340fa01146100ef575b600080fd5b61008161011f565b60405161008e9190610a1a565b60405180910390f35b61009f610125565b6040516100ac9190610a1a565b60405180910390f35b6100bd61012b565b6040516100ca9190610a1a565b60405180910390f35b6100ed60048036038101906100e89190610a9e565b610131565b005b61010960048036038101906101049190610b4f565b610525565b6040516101169190610b95565b60405180910390f35b60045481565b60035481565b60055481565b60008211610174576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161016b90610c0d565b60405180910390fd5b61017c6109df565b60008061018886610838565b92508260006002811061019e5761019d610c2d565b5b60200201519150826001600281106101b9576101b8610c2d565b5b602002015160ff1660019060020a02905060005b8581101561051c5760006003541161021a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161021190610ca8565b60405180910390fd5b61022483836108c3565b610263576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025a90610d14565b60405180910390fd5b84156103a35781600284815461027890610d63565b811061028757610286610c2d565b5b8154600116156102a65790600052602060002090602091828204019190065b9054901a7f0100000000000000000000000000000000000000000000000000000000000000027f01000000000000000000000000000000000000000000000000000000000000009004177f010000000000000000000000000000000000000000000000000000000000000002600284815461032090610d63565b811061032f5761032e610c2d565b5b81546001161561034e5790600052602060002090602091828204019190065b601f036101000a81548160ff021916907f0100000000000000000000000000000000000000000000000000000000000000840402179055506005600081548092919061039990610dc3565b91905055506104c1565b8160018481546103b290610d63565b81106103c1576103c0610c2d565b5b8154600116156103e05790600052602060002090602091828204019190065b9054901a7f0100000000000000000000000000000000000000000000000000000000000000027f01000000000000000000000000000000000000000000000000000000000000009004177f010000000000000000000000000000000000000000000000000000000000000002600184815461045a90610d63565b811061046957610468610c2d565b5b8154600116156104885790600052602060002090602091828204019190065b601f036101000a81548160ff021916907f0100000000000000000000000000000000000000000000000000000000000000840402179055505b60808260ff16036104e35782806104d790610dc3565b935050600191506104f1565b60018260ff169060020a0291505b6003600081548092919061050490610e0b565b9190505550808061051490610dc3565b9150506101cd565b50505050505050565b6000806000806000806060600454945060045485101561057a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161057190610e80565b60405180910390fd5b600454856105889190610ecf565b9550856005546105989190610f00565b9350600660008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205484036105ef5760009650505050505050610833565b600660008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548461063a9190610f42565b9250600660008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548411156107e55760008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168830856040516024016106cf93929190610ff3565b6040516020818303038152906040527f23b872dd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610759919061109b565b6000604051808303816000865af19150503d8060008114610796576040519150601f19603f3d011682016040523d82523d6000602084013e61079b565b606091505b508092508193505050816107e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107db906110fe565b60405180910390fd5b5b83600660008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508296505050505050505b919050565b6108406109df565b600061084a6109df565b6001600860018661085b9190610f42565b610865919061111e565b61086f9190611188565b9150818160006002811061088657610885610c2d565b5b60200201818152505060088461089c91906111cc565b816001600281106108b0576108af610c2d565b5b6020020181815250508092505050919050565b6000808260028581546108d590610d63565b81106108e4576108e3610c2d565b5b8154600116156109035790600052602060002090602091828204019190065b9054901a7f0100000000000000000000000000000000000000000000000000000000000000027f01000000000000000000000000000000000000000000000000000000000000009004600186815461095a90610d63565b811061096957610968610c2d565b5b8154600116156109885790600052602060002090602091828204019190065b9054901a7f0100000000000000000000000000000000000000000000000000000000000000027f01000000000000000000000000000000000000000000000000000000000000009004171660ff1614905092915050565b6040518060400160405280600290602082028036833780820191505090505090565b6000819050919050565b610a1481610a01565b82525050565b6000602082019050610a2f6000830184610a0b565b92915050565b600080fd5b610a4381610a01565b8114610a4e57600080fd5b50565b600081359050610a6081610a3a565b92915050565b60008115159050919050565b610a7b81610a66565b8114610a8657600080fd5b50565b600081359050610a9881610a72565b92915050565b600080600060608486031215610ab757610ab6610a35565b5b6000610ac586828701610a51565b9350506020610ad686828701610a51565b9250506040610ae786828701610a89565b9150509250925092565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610b1c82610af1565b9050919050565b610b2c81610b11565b8114610b3757600080fd5b50565b600081359050610b4981610b23565b92915050565b600060208284031215610b6557610b64610a35565b5b6000610b7384828501610b3a565b91505092915050565b6000819050919050565b610b8f81610b7c565b82525050565b6000602082019050610baa6000830184610b86565b92915050565b600082825260208201905092915050565b7f4552525f5a45524f434f554e5400000000000000000000000000000000000000600082015250565b6000610bf7600d83610bb0565b9150610c0282610bc1565b602082019050919050565b60006020820190508181036000830152610c2681610bea565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4552525f43415041434954590000000000000000000000000000000000000000600082015250565b6000610c92600c83610bb0565b9150610c9d82610c5c565b602082019050919050565b60006020820190508181036000830152610cc181610c85565b9050919050565b7f4552525f434f4c4c4953494f4e00000000000000000000000000000000000000600082015250565b6000610cfe600d83610bb0565b9150610d0982610cc8565b602082019050919050565b60006020820190508181036000830152610d2d81610cf1565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680610d7b57607f821691505b602082108103610d8e57610d8d610d34565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610dce82610a01565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203610e0057610dff610d94565b5b600182019050919050565b6000610e1682610a01565b915060008203610e2957610e28610d94565b5b600182039050919050565b7f4552525f535550504c595f554e444552464c4f57000000000000000000000000600082015250565b6000610e6a601483610bb0565b9150610e7582610e34565b602082019050919050565b60006020820190508181036000830152610e9981610e5d565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000610eda82610a01565b9150610ee583610a01565b925082610ef557610ef4610ea0565b5b828204905092915050565b6000610f0b82610a01565b9150610f1683610a01565b9250828202610f2481610a01565b91508282048414831517610f3b57610f3a610d94565b5b5092915050565b6000610f4d82610b7c565b9150610f5883610b7c565b9250828203905081811260008412168282136000851215161715610f7f57610f7e610d94565b5b92915050565b610f8e81610b11565b82525050565b6000819050919050565b6000610fb9610fb4610faf84610af1565b610f94565b610af1565b9050919050565b6000610fcb82610f9e565b9050919050565b6000610fdd82610fc0565b9050919050565b610fed81610fd2565b82525050565b60006060820190506110086000830186610f85565b6110156020830185610fe4565b6110226040830184610a0b565b949350505050565b600081519050919050565b600081905092915050565b60005b8381101561105e578082015181840152602081019050611043565b60008484015250505050565b60006110758261102a565b61107f8185611035565b935061108f818560208601611040565b80840191505092915050565b60006110a7828461106a565b915081905092915050565b7f4552525f544f4b454e0000000000000000000000000000000000000000000000600082015250565b60006110e8600983610bb0565b91506110f3826110b2565b602082019050919050565b60006020820190508181036000830152611117816110db565b9050919050565b600061112982610b7c565b915061113483610b7c565b92508261114457611143610ea0565b5b600160000383147f80000000000000000000000000000000000000000000000000000000000000008314161561117d5761117c610d94565b5b828205905092915050565b600061119382610b7c565b915061119e83610b7c565b9250828201905082811215600083121683821260008412151617156111c6576111c5610d94565b5b92915050565b60006111d782610a01565b91506111e283610a01565b9250826111f2576111f1610ea0565b5b82820690509291505056fea26469706673582212204c3235554c7ee7b14310bf4d04a8591ac9457c32261b979be65c0a6c7b5141d864736f6c63430008130033
-\ No newline at end of file
+60806040523480156200001157600080fd5b50604051620021e3380380620021e38339818101604052810190620000379190620003d4565b60008111801562000058575070010000000000000000000000000000000081105b6200009a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000091906200047c565b60405180910390fd5b620000a46200030d565b620000be8262000270640100000000026401000000009004565b9050600181600060028110620000d957620000d86200049e565b5b6020020151620000ea9190620004fc565b67ffffffffffffffff81111562000106576200010562000537565b5b6040519080825280601f01601f191660200182016040528015620001395781602001600182028036833780820191505090505b50600290816200014a9190620007ad565b506001816000600281106200016457620001636200049e565b5b6020020151620001759190620004fc565b67ffffffffffffffff81111562000191576200019062000537565b5b6040519080825280601f01601f191660200182016040528015620001c45781602001600182028036833780820191505090505b5060039081620001d59190620007ad565b508160048190555060045460058190555082600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505062000a0e565b6200027a6200030d565b6000620002866200030d565b600160086001866200029991906200089e565b620002a5919062000917565b620002b191906200098b565b91508181600060028110620002cb57620002ca6200049e565b5b602002018181525050600884620002e39190620009d6565b81600160028110620002fa57620002f96200049e565b5b6020020181815250508092505050919050565b6040518060400160405280600290602082028036833780820191505090505090565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620003618262000334565b9050919050565b620003738162000354565b81146200037f57600080fd5b50565b600081519050620003938162000368565b92915050565b6000819050919050565b620003ae8162000399565b8114620003ba57600080fd5b50565b600081519050620003ce81620003a3565b92915050565b60008060408385031215620003ee57620003ed6200032f565b5b6000620003fe8582860162000382565b92505060206200041185828601620003bd565b9150509250929050565b600082825260208201905092915050565b7f4552525f4e4f4e53454e53450000000000000000000000000000000000000000600082015250565b600062000464600c836200041b565b915062000471826200042c565b602082019050919050565b60006020820190508181036000830152620004978162000455565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000620005098262000399565b9150620005168362000399565b9250828201905080821115620005315762000530620004cd565b5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680620005b957607f821691505b602082108103620005cf57620005ce62000571565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b60008160020a8302905092915050565b6000600883026200063c7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82620005fa565b620006488683620005fa565b95508019841693508086168417925050509392505050565b6000819050919050565b60006200068b620006856200067f8462000399565b62000660565b62000399565b9050919050565b6000819050919050565b620006a7836200066a565b620006bf620006b68262000692565b8484546200060a565b825550505050565b600090565b620006d6620006c7565b620006e38184846200069c565b505050565b5b818110156200070b57620006ff600082620006cc565b600181019050620006e9565b5050565b601f8211156200075a576200072481620005d5565b6200072f84620005ea565b810160208510156200073f578190505b620007576200074e85620005ea565b830182620006e8565b50505b505050565b60008160020a8304905092915050565b600062000782600019846008026200075f565b1980831691505092915050565b60006200079d83836200076f565b9150826002028217905092915050565b620007b88262000566565b67ffffffffffffffff811115620007d457620007d362000537565b5b620007e08254620005a0565b620007ed8282856200070f565b600060209050601f83116001811462000825576000841562000810578287015190505b6200081c85826200078f565b8655506200088c565b601f1984166200083586620005d5565b60005b828110156200085f5784890151825560018201915060208501945060208101905062000838565b868310156200087f57848901516200087b601f8916826200076f565b8355505b6001600288020188555050505b505050505050565b6000819050919050565b6000620008ab8262000894565b9150620008b88362000894565b9250828203905081811260008412168282136000851215161715620008e257620008e1620004cd565b5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000620009248262000894565b9150620009318362000894565b925082620009445762000943620008e8565b5b600160000383147f80000000000000000000000000000000000000000000000000000000000000008314161562000980576200097f620004cd565b5b828205905092915050565b6000620009988262000894565b9150620009a58362000894565b925082820190508281121560008312168382126000841215161715620009d057620009cf620004cd565b5b92915050565b6000620009e38262000399565b9150620009f08362000399565b92508262000a035762000a02620008e8565b5b828206905092915050565b6117c58062000a1e6000396000f3fe608060405234801561001057600080fd5b50600436106100c6576000357c0100000000000000000000000000000000000000000000000000000000900480637f03864b1161008e5780637f03864b146101835780638da5cb5b146101a1578063da2824a8146101bf578063de34d544146101ef578063f340fa011461020b578063fc0c546a1461023b576100c6565b806318160ddd146100cb5780632b29ba23146100e95780634eeea7ad146101195780635356dddc146101355780635cfc1a5114610165575b600080fd5b6100d3610259565b6040516100e09190610f21565b60405180910390f35b61010360048036038101906100fe9190610f9f565b61025f565b6040516101109190610fe7565b60405180910390f35b610133600480360381019061012e919061102e565b61030b565b005b61014f600480360381019061014a9190610f9f565b61031b565b60405161015c9190610fe7565b60405180910390f35b61016d610443565b60405161017a9190610f21565b60405180910390f35b61018b610449565b6040516101989190610f21565b60405180910390f35b6101a961044f565b6040516101b6919061107d565b60405180910390f35b6101d960048036038101906101d49190610f9f565b610473565b6040516101e69190610fe7565b60405180910390f35b6102096004803603810190610204919061102e565b610565565b005b61022560048036038101906102209190610f9f565b6105bd565b60405161023291906110b1565b60405180910390f35b6102436108b1565b604051610250919061107d565b60405180910390f35b60055481565b6000600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680610304575060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b9050919050565b610317828260006108d7565b5050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806103a357508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b6103e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103d990611129565b60405180910390fd5b6000600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b60045481565b60065481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610504576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104fb90611129565b60405180910390fd5b6001600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b61056e3361025f565b6105ad576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105a490611129565b60405180910390fd5b6105b9828260016108d7565b5050565b60008060008060606000806105d0610ccb565b9550600760008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054860361062757600096505050505050506108ac565b600760008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054866106729190611178565b9450600760008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548611156106c6578791503090506106fb565b3091508790507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff856106f891906111bb565b94505b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1682828760405160240161074993929190611233565b6040516020818303038152906040527f23b872dd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516107d391906112db565b6000604051808303816000865af19150503d8060008114610810576040519150601f19603f3d011682016040523d82523d6000602084013e610815565b606091505b5080945081955050508361085e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108559061133e565b60405180910390fd5b85600760008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508496505050505050505b919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000821161091a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610911906113aa565b60405180910390fd5b610922610ee6565b60008061092e86610d3f565b925082600060028110610944576109436113ca565b5b602002015191508260016002811061095f5761095e6113ca565b5b602002015160ff1660019060020a02905060005b85811015610cc2576000600454116109c0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109b790611445565b60405180910390fd5b6109ca8383610dca565b610a09576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a00906114b1565b60405180910390fd5b8415610b4957816003848154610a1e90611500565b8110610a2d57610a2c6113ca565b5b815460011615610a4c5790600052602060002090602091828204019190065b9054901a7f0100000000000000000000000000000000000000000000000000000000000000027f01000000000000000000000000000000000000000000000000000000000000009004177f0100000000000000000000000000000000000000000000000000000000000000026003848154610ac690611500565b8110610ad557610ad46113ca565b5b815460011615610af45790600052602060002090602091828204019190065b601f036101000a81548160ff021916907f01000000000000000000000000000000000000000000000000000000000000008404021790555060066000815480929190610b3f90611531565b9190505550610c67565b816002848154610b5890611500565b8110610b6757610b666113ca565b5b815460011615610b865790600052602060002090602091828204019190065b9054901a7f0100000000000000000000000000000000000000000000000000000000000000027f01000000000000000000000000000000000000000000000000000000000000009004177f0100000000000000000000000000000000000000000000000000000000000000026002848154610c0090611500565b8110610c0f57610c0e6113ca565b5b815460011615610c2e5790600052602060002090602091828204019190065b601f036101000a81548160ff021916907f0100000000000000000000000000000000000000000000000000000000000000840402179055505b60808260ff1603610c89578280610c7d90611531565b93505060019150610c97565b60018260ff169060020a0291505b60046000815480929190610caa90611579565b91905055508080610cba90611531565b915050610973565b50505050505050565b60008060006005549150600554821015610d1a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d11906115ee565b60405180910390fd5b60055482610d28919061163d565b905080600654610d38919061166e565b9250505090565b610d47610ee6565b6000610d51610ee6565b60016008600186610d629190611178565b610d6c91906116b0565b610d76919061171a565b91508181600060028110610d8d57610d8c6113ca565b5b602002018181525050600884610da3919061175e565b81600160028110610db757610db66113ca565b5b6020020181815250508092505050919050565b600080826003858154610ddc90611500565b8110610deb57610dea6113ca565b5b815460011615610e0a5790600052602060002090602091828204019190065b9054901a7f0100000000000000000000000000000000000000000000000000000000000000027f010000000000000000000000000000000000000000000000000000000000000090046002868154610e6190611500565b8110610e7057610e6f6113ca565b5b815460011615610e8f5790600052602060002090602091828204019190065b9054901a7f0100000000000000000000000000000000000000000000000000000000000000027f01000000000000000000000000000000000000000000000000000000000000009004171660ff1614905092915050565b6040518060400160405280600290602082028036833780820191505090505090565b6000819050919050565b610f1b81610f08565b82525050565b6000602082019050610f366000830184610f12565b92915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610f6c82610f41565b9050919050565b610f7c81610f61565b8114610f8757600080fd5b50565b600081359050610f9981610f73565b92915050565b600060208284031215610fb557610fb4610f3c565b5b6000610fc384828501610f8a565b91505092915050565b60008115159050919050565b610fe181610fcc565b82525050565b6000602082019050610ffc6000830184610fd8565b92915050565b61100b81610f08565b811461101657600080fd5b50565b60008135905061102881611002565b92915050565b6000806040838503121561104557611044610f3c565b5b600061105385828601611019565b925050602061106485828601611019565b9150509250929050565b61107781610f61565b82525050565b6000602082019050611092600083018461106e565b92915050565b6000819050919050565b6110ab81611098565b82525050565b60006020820190506110c660008301846110a2565b92915050565b600082825260208201905092915050565b7f4552525f41585800000000000000000000000000000000000000000000000000600082015250565b60006111136007836110cc565b915061111e826110dd565b602082019050919050565b6000602082019050818103600083015261114281611106565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061118382611098565b915061118e83611098565b92508282039050818112600084121682821360008512151617156111b5576111b4611149565b5b92915050565b60006111c682611098565b91506111d183611098565b92508282026111df81611098565b91507f8000000000000000000000000000000000000000000000000000000000000000841460008412161561121757611216611149565b5b828205841483151761122c5761122b611149565b5b5092915050565b6000606082019050611248600083018661106e565b611255602083018561106e565b6112626040830184610f12565b949350505050565b600081519050919050565b600081905092915050565b60005b8381101561129e578082015181840152602081019050611283565b60008484015250505050565b60006112b58261126a565b6112bf8185611275565b93506112cf818560208601611280565b80840191505092915050565b60006112e782846112aa565b915081905092915050565b7f4552525f544f4b454e0000000000000000000000000000000000000000000000600082015250565b60006113286009836110cc565b9150611333826112f2565b602082019050919050565b600060208201905081810360008301526113578161131b565b9050919050565b7f4552525f5a45524f434f554e5400000000000000000000000000000000000000600082015250565b6000611394600d836110cc565b915061139f8261135e565b602082019050919050565b600060208201905081810360008301526113c381611387565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4552525f43415041434954590000000000000000000000000000000000000000600082015250565b600061142f600c836110cc565b915061143a826113f9565b602082019050919050565b6000602082019050818103600083015261145e81611422565b9050919050565b7f4552525f434f4c4c4953494f4e00000000000000000000000000000000000000600082015250565b600061149b600d836110cc565b91506114a682611465565b602082019050919050565b600060208201905081810360008301526114ca8161148e565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061151857607f821691505b60208210810361152b5761152a6114d1565b5b50919050565b600061153c82610f08565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361156e5761156d611149565b5b600182019050919050565b600061158482610f08565b91506000820361159757611596611149565b5b600182039050919050565b7f4552525f535550504c595f554e444552464c4f57000000000000000000000000600082015250565b60006115d86014836110cc565b91506115e3826115a2565b602082019050919050565b60006020820190508181036000830152611607816115cb565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061164882610f08565b915061165383610f08565b9250826116635761166261160e565b5b828204905092915050565b600061167982610f08565b915061168483610f08565b925082820261169281610f08565b915082820484148315176116a9576116a8611149565b5b5092915050565b60006116bb82611098565b91506116c683611098565b9250826116d6576116d561160e565b5b600160000383147f80000000000000000000000000000000000000000000000000000000000000008314161561170f5761170e611149565b5b828205905092915050565b600061172582611098565b915061173083611098565b92508282019050828112156000831216838212600084121516171561175857611757611149565b5b92915050565b600061176982610f08565b915061177483610f08565b9250826117845761178361160e565b5b82820690509291505056fea2646970667358221220110af0d571b85125c2c35704c00faaa57dc53b09be15506cff0c06a0ee10009b64736f6c63430008130033
+\ No newline at end of file
diff --git a/python/evm_booking/data/Booking.json b/python/evm_booking/data/Booking.json
@@ -1 +1 @@
-[{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_resolution","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"capacity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"}],"name":"deposit","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_offset","type":"uint256"},{"internalType":"uint256","name":"_count","type":"uint256"},{"internalType":"bool","name":"_share","type":"bool"}],"name":"reserve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"shareCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
+[{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_resolution","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"_writer","type":"address"}],"name":"addWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"capacity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_offset","type":"uint256"},{"internalType":"uint256","name":"_count","type":"uint256"}],"name":"consume","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"}],"name":"deposit","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_writer","type":"address"}],"name":"isWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_writer","type":"address"}],"name":"removeWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_offset","type":"uint256"},{"internalType":"uint256","name":"_count","type":"uint256"}],"name":"share","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"shareCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
diff --git a/python/evm_booking/data/Booking.metadata.json b/python/evm_booking/data/Booking.metadata.json
@@ -1 +1 @@
-{"compiler":{"version":"0.8.19+commit.7dd6d404"},"language":"Solidity","output":{"abi":[{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_resolution","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"capacity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"}],"name":"deposit","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_offset","type":"uint256"},{"internalType":"uint256","name":"_count","type":"uint256"},{"internalType":"bool","name":"_share","type":"bool"}],"name":"reserve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"shareCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"compilationTarget":{"Booking.sol":"ERC20Book"},"evmVersion":"byzantium","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":false,"runs":200},"remappings":[]},"sources":{"Booking.sol":{"keccak256":"0x439456bfa397c21c94aa8e81d2a8de3da2b214bef4e2f7fce4bd1a111bcd1772","license":"AGPL-3.0-or-later","urls":["bzz-raw://99160c677979c67558187fec67d804feba55b96dca88e5442dc4b1d762d83e0f","dweb:/ipfs/QmUttGDQshuz2wotNmq6CLzAHamugoUe8SdqEBQ3Z9opxF"]}},"version":1}
+{"compiler":{"version":"0.8.19+commit.7dd6d404"},"language":"Solidity","output":{"abi":[{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_resolution","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"_writer","type":"address"}],"name":"addWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"capacity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_offset","type":"uint256"},{"internalType":"uint256","name":"_count","type":"uint256"}],"name":"consume","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"}],"name":"deposit","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_writer","type":"address"}],"name":"isWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_writer","type":"address"}],"name":"removeWriter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_offset","type":"uint256"},{"internalType":"uint256","name":"_count","type":"uint256"}],"name":"share","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"shareCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"compilationTarget":{"Booking.sol":"ERC20Book"},"evmVersion":"byzantium","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":false,"runs":200},"remappings":[]},"sources":{"Booking.sol":{"keccak256":"0x4152e634c5044c520efcbefa3ebcd9b95b9421227187d305b894b1993a359c94","license":"AGPL-3.0-or-later","urls":["bzz-raw://ff1e29d8b9349d5d5aef435e8651ab3fc8726fde0550e26bbd07c5fe182def4f","dweb:/ipfs/QmeFy1UVropbbdbGr21MbtCju9YG9Ue3DhHNTq8oknqbaL"]}},"version":1}
diff --git a/python/tests/test_base.py b/python/tests/test_base.py
@@ -22,34 +22,53 @@ class TestBookingBase(TestBooking):
super(TestBookingBase, self).setUp()
self.publish()
+
def test_base(self):
nonce_oracle = RPCNonceOracle(self.accounts[0], conn=self.rpc)
c = Booking(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
- (tx_hash_hex, o) = c.reserve(self.address, self.accounts[0], 42, 13)
+ (tx_hash_hex, o) = c.consume(self.address, self.accounts[0], 42, 13)
self.rpc.do(o)
o = receipt(tx_hash_hex)
r = self.rpc.do(o)
self.assertEqual(r['status'], 1)
- (tx_hash_hex, o) = c.reserve(self.address, self.accounts[0], 42, 1)
+ (tx_hash_hex, o) = c.consume(self.address, self.accounts[0], 42, 1)
self.rpc.do(o)
o = receipt(tx_hash_hex)
r = self.rpc.do(o)
self.assertEqual(r['status'], 0)
- (tx_hash_hex, o) = c.reserve(self.address, self.accounts[0], 42+13-1, 1)
+ (tx_hash_hex, o) = c.consume(self.address, self.accounts[0], 42+13-1, 1)
self.rpc.do(o)
o = receipt(tx_hash_hex)
r = self.rpc.do(o)
self.assertEqual(r['status'], 0)
- (tx_hash_hex, o) = c.reserve(self.address, self.accounts[0], 41, 1)
+ (tx_hash_hex, o) = c.consume(self.address, self.accounts[0], 41, 1)
+ self.rpc.do(o)
+ o = receipt(tx_hash_hex)
+ r = self.rpc.do(o)
+ self.assertEqual(r['status'], 1)
+
+ (tx_hash_hex, o) = c.consume(self.address, self.accounts[0], 42+13, 1)
self.rpc.do(o)
o = receipt(tx_hash_hex)
r = self.rpc.do(o)
self.assertEqual(r['status'], 1)
- (tx_hash_hex, o) = c.reserve(self.address, self.accounts[0], 42+13, 1)
+
+ def test_axx(self):
+ nonce_oracle = RPCNonceOracle(self.alice, conn=self.rpc)
+ c = Booking(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
+ (tx_hash_hex, o) = c.share(self.address, self.alice, 42, 13)
+ self.rpc.do(o)
+ o = receipt(tx_hash_hex)
+ r = self.rpc.do(o)
+ self.assertEqual(r['status'], 0)
+
+ nonce_oracle = RPCNonceOracle(self.accounts[0], conn=self.rpc)
+ c = Booking(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
+ (tx_hash_hex, o) = c.share(self.address, self.accounts[0], 42, 13)
self.rpc.do(o)
o = receipt(tx_hash_hex)
r = self.rpc.do(o)
diff --git a/solidity/Booking.sol b/solidity/Booking.sol
@@ -7,13 +7,16 @@ pragma solidity ^0.8.0;
contract ERC20Book {
- address token;
+ // Implements ERC173
+ address public owner;
+ address public token;
bytes slots;
bytes sharedSlots;
uint256 public capacity;
uint256 public totalSupply;
uint256 public shareCount;
mapping ( address => uint256 ) shares;
+ mapping ( address => bool ) writers;
constructor (address _token, uint256 _resolution) {
require(_resolution > 0 && _resolution < (1 << 128), "ERR_NONSENSE");
@@ -25,35 +28,68 @@ contract ERC20Book {
capacity = _resolution;
totalSupply = capacity;
token = _token;
+ owner = msg.sender;
+ }
+
+ // Implements Writer
+ function addWriter(address _writer) public returns (bool) {
+ require(msg.sender == owner, "ERR_AXX");
+ writers[_writer] = true;
+ return true;
+ }
+
+ // Implements Writer
+ function removeWriter(address _writer) public returns (bool) {
+ require(msg.sender == owner || msg.sender == _writer, "ERR_AXX");
+ writers[_writer] = false;
+ return true;
+ }
+
+ // Implements Writer
+ function isWriter(address _writer) public view returns (bool) {
+ return writers[_writer] || _writer == owner;
}
function deposit(address _spender) public returns (int256) {
- uint256 l_unit;
- uint256 l_supply;
uint256 l_limit;
int256 l_value;
bool r;
bytes memory v;
-
- l_supply = totalSupply;
- require(l_supply >= totalSupply, "ERR_SUPPLY_UNDERFLOW");
+ address l_sender;
+ address l_receiver;
- l_unit = l_supply / totalSupply;
- l_limit = shareCount * l_unit;
+ l_limit = shareLimit();
if (l_limit == shares[_spender]) {
return 0;
}
l_value = int256(l_limit) - int256(shares[_spender]);
if (l_limit > shares[_spender]) {
- (r, v) = token.call(abi.encodeWithSignature('transferFrom(address,address,uint256)', _spender, this, uint256(l_value)));
- require(r, "ERR_TOKEN");
+ l_sender = _spender;
+ l_receiver = address(this);
+ } else {
+ l_sender = address(this);
+ l_receiver = _spender;
+ l_value *= -1;
}
+ (r, v) = token.call(abi.encodeWithSignature('transferFrom(address,address,uint256)', l_sender, l_receiver, uint256(l_value)));
+ require(r, "ERR_TOKEN");
+
shares[_spender] = l_limit;
return l_value;
}
+ function shareLimit() internal view returns(uint256) {
+ uint256 l_supply;
+ uint256 l_unit;
+
+ l_supply = totalSupply;
+ require(l_supply >= totalSupply, "ERR_SUPPLY_UNDERFLOW");
+ l_unit = l_supply / totalSupply;
+ return shareCount * l_unit;
+ }
+
function tokenSupply() internal returns (uint256) {
bool r;
bytes memory v;
@@ -66,8 +102,17 @@ contract ERC20Book {
return l_supply;
}
+ function consume(uint256 _offset, uint256 _count) public {
+ reserve(_offset, _count, false);
+ }
+
+ function share(uint256 _offset, uint256 _count) public {
+ require(isWriter(msg.sender), "ERR_AXX");
+ reserve(_offset, _count, true);
+ }
+
// improve by comparing word by word
- function reserve(uint256 _offset, uint256 _count, bool _share) public {
+ function reserve(uint256 _offset, uint256 _count, bool _share) internal {
require(_count > 0, "ERR_ZEROCOUNT");
uint256[2] memory c;
uint256 cy;