event-msg

Simple, embedded news post vehicle for EVM smart contracts
Log | Files | Refs

commit a76c4bfa16a5ebaa2e4c337ae87cfc74e34e3b1a
parent ef3ded9835d5bd1f04ec79da3de815d6730dfd2d
Author: lash <dev@holbrook.no>
Date:   Fri, 17 Feb 2023 23:25:00 +0000

Add uri accessor method for prefix

Diffstat:
Mpython/eth_event_msg/__init__.py | 4++--
Mpython/eth_event_msg/data/Msg.bin | 4++--
Mpython/eth_event_msg/data/Msg.json | 2+-
Mpython/tests/test_basic.py | 6+++---
Msolidity/Msg.sol | 41++++++++++++++++++++++++++++++++++++-----
5 files changed, 44 insertions(+), 13 deletions(-)

diff --git a/python/eth_event_msg/__init__.py b/python/eth_event_msg/__init__.py @@ -93,7 +93,7 @@ class EventMsg(TxFactory): @classmethod - def parse_token_spec(self, v): + def parse_to_hash(self, v): v = strip_0x(v) l = int(v[64:128], 16) logg.debug('llll {} {}'.format(l, v[64:128])) @@ -106,4 +106,4 @@ class EventMsg(TxFactory): v = strip_0x(v) l = int(v[64:128], 16) r = v[128:128+(l*2)] - return r + return bytes.fromhex(r).decode('utf-8') diff --git a/python/eth_event_msg/data/Msg.bin b/python/eth_event_msg/data/Msg.bin @@ -1 +1 @@ -60806040523480156200001157600080fd5b5062000065602060126040518060400160405280600681526020017f736861323536000000000000000000000000000000000000000000000000000081525062000086640100000000026401000000009004565b620000806012620003aa640100000000026401000000009004565b6200080e565b6000600160ff166002541614620000d4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620000cb9062000502565b60405180910390fd5b606081905060108151111562000121576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620001189062000574565b60405180910390fd5b6200012b6200043b565b6000600790505b60008160ff16106200018f5760006008826200014f9190620005d2565b60ff1660ff9060020a029050600086821667ffffffffffffffff1611156200017857506200018f565b8180620001859062000618565b9250505062000132565b6001816200019e919062000646565b826020019060ff16908160ff16815250506008816007620001c0919062000682565b620001cc9190620005d2565b60ff168567ffffffffffffffff169060020a02780100000000000000000000000000000000000000000000000002826080019077ffffffffffffffffffffffffffffffffffffffffffffffff1916908177ffffffffffffffffffffffffffffffffffffffffffffffff1916815250508251826040019060ff16908160ff1681525050826200025a906200072c565b82606001906fffffffffffffffffffffffffffffffff191690816fffffffffffffffffffffffffffffffff19168152505085826000019060ff16908160ff1681525050816000808767ffffffffffffffff16815260200190815260200160002060008201518160000160006101000a81548160ff021916908360ff16021790555060208201518160000160016101000a81548160ff021916908360ff16021790555060408201518160000160026101000a81548160ff021916908360ff16021790555060608201518160000160036101000a8154816fffffffffffffffffffffffffffffffff02191690837001000000000000000000000000000000009004021790555060808201518160000160136101000a81548167ffffffffffffffff0219169083780100000000000000000000000000000000000000000000000090040217905550905050505050505050565b6000600160ff166002541614620003f8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620003ef90620007ec565b60405180910390fd5b6000806000838152602001908152602001600020905060008160000160009054906101000a900460ff1660ff16116200043057600080fd5b816001819055505050565b6040518060a00160405280600060ff168152602001600060ff168152602001600060ff16815260200160006fffffffffffffffffffffffffffffffff19168152602001600077ffffffffffffffffffffffffffffffffffffffffffffffff191681525090565b600082825260208201905092915050565b7f4552525f5345414c5f434f4445434c4953540000000000000000000000000000600082015250565b6000620004ea601283620004a1565b9150620004f782620004b2565b602082019050919050565b600060208201905081810360008301526200051d81620004db565b9050919050565b7f4552525f5052454649585f544f4f5f4c4f4e4700000000000000000000000000600082015250565b60006200055c601383620004a1565b9150620005698262000524565b602082019050919050565b600060208201905081810360008301526200058f816200054d565b9050919050565b600060ff82169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000620005df8262000596565b9150620005ec8362000596565b9250828202620005fc8162000596565b9150808214620006115762000610620005a3565b5b5092915050565b6000620006258262000596565b9150600082036200063b576200063a620005a3565b5b600182039050919050565b6000620006538262000596565b9150620006608362000596565b9250828201905060ff8111156200067c576200067b620005a3565b5b92915050565b60006200068f8262000596565b91506200069c8362000596565b9250828203905060ff811115620006b857620006b7620005a3565b5b92915050565b600081519050919050565b6000819050602082019050919050565b60007fffffffffffffffffffffffffffffffff0000000000000000000000000000000082169050919050565b6000620007138251620006d9565b80915050919050565b60008160020a8302905092915050565b60006200073982620006be565b826200074584620006c9565b9050620007528162000705565b925060108210156200079557620007907fffffffffffffffffffffffffffffffff00000000000000000000000000000000836010036008026200071c565b831692505b5050919050565b7f4552525f5345414c5f434f444543000000000000000000000000000000000000600082015250565b6000620007d4600e83620004a1565b9150620007e1826200079c565b602082019050919050565b600060208201905081810360008301526200080781620007c5565b9050919050565b611727806200081e6000396000f3fe608060405234801561001057600080fd5b50600436106100b0576000357c01000000000000000000000000000000000000000000000000000000009004806386fe212d1161008357806386fe212d146101515780639a7c5e9f14610181578063ad0dec2f1461019d578063b238d603146101cd578063ccc094c214610201576100b0565b806318cbbcfc146100b55780632c1758c1146100d357806331a5995d14610103578063779ab66714610121575b600080fd5b6100bd61021d565b6040516100ca9190610c95565b60405180910390f35b6100ed60048036038101906100e89190610cf0565b610222565b6040516100fa9190610d38565b60405180910390f35b61010b610255565b6040516101189190610c95565b60405180910390f35b61013b60048036038101906101369190610e99565b61025b565b6040516101489190610f61565b60405180910390f35b61016b60048036038101906101669190610cf0565b610421565b6040516101789190610c95565b60405180910390f35b61019b60048036038101906101969190610cf0565b610508565b005b6101b760048036038101906101b29190610e99565b610595565b6040516101c49190610fd8565b60405180910390f35b6101e760048036038101906101e29190610cf0565b61086b565b6040516101f895949392919061108c565b60405180910390f35b61021b600480360381019061021691906111ec565b61090a565b005b600381565b60006003821061023157600080fd5b60008203610246576003600254149050610250565b8160025483161490505b919050565b60025481565b6060600060606000806000600154815260200190815260200160002092508260000160029054906101000a900460ff1660ff16905060018161029d919061128a565b67ffffffffffffffff8111156102b6576102b5610d6e565b5b6040519080825280601f01601f1916602001820160405280156102e85781602001600182028036833780820191505090505b50915060005b818110156103a2578360000160039054906101000a900470010000000000000000000000000000000002816010811061032a576103296112be565b5b1a7f0100000000000000000000000000000000000000000000000000000000000000028382815181106103605761035f6112be565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350808061039a906112ed565b9150506102ee565b50603a7f01000000000000000000000000000000000000000000000000000000000000000282600184516103d69190611335565b815181106103e7576103e66112be565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350819350505050919050565b600060108210610466576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161045d906113b5565b60405180910390fd5b60006002548316146104ad576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104a490611421565b60405180910390fd5b8160026000828254179250508190555060036002541415157f6b7e2e653f93b645d4ed7292d6429f96637084363e477c8aaea1a43ed13c284e6002546040516104f69190610c95565b60405180910390a26002549050919050565b6000600160ff166002541614610553576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161054a9061148d565b60405180910390fd5b6000806000838152602001908152602001600020905060008160000160009054906101000a900460ff1660ff161161058a57600080fd5b816001819055505050565b606060006060600080600154815260200190815260200160002091508160000160019054906101000a900460ff1660ff168260000160009054906101000a900460ff1660ff1685516105e7919061128a565b6105f1919061128a565b67ffffffffffffffff81111561060a57610609610d6e565b5b6040519080825280601f01601f19166020018201604052801561063c5781602001600182028036833780820191505090505b50905060005b8260000160019054906101000a900460ff1660ff16811015610712578260000160139054906101000a9004780100000000000000000000000000000000000000000000000002816008811061069a576106996112be565b5b1a7f0100000000000000000000000000000000000000000000000000000000000000028282815181106106d0576106cf6112be565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350808061070a906112ed565b915050610642565b8260000160009054906101000a900460ff167f010000000000000000000000000000000000000000000000000000000000000002828281518110610759576107586112be565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508080610793906112ed565b91505060005b855181101561085f578581815181106107b5576107b46112be565b5b60200101517f010000000000000000000000000000000000000000000000000000000000000090047f01000000000000000000000000000000000000000000000000000000000000000283828461080c919061128a565b8151811061081d5761081c6112be565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508080610857906112ed565b915050610799565b50819350505050919050565b60006020528060005260406000206000915090508060000160009054906101000a900460ff16908060000160019054906101000a900460ff16908060000160029054906101000a900460ff16908060000160039054906101000a900470010000000000000000000000000000000002908060000160139054906101000a9004780100000000000000000000000000000000000000000000000002905085565b6000600160ff166002541614610955576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161094c906114f9565b60405180910390fd5b606081905060108151111561099f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161099690611565565b60405180910390fd5b6109a7610c16565b6000600790505b60008160ff1610610a035760006008826109c89190611585565b60ff1660ff9060020a029050600086821667ffffffffffffffff1611156109ef5750610a03565b81806109fa906115c2565b925050506109ae565b600181610a1091906115eb565b826020019060ff16908160ff16815250506008816007610a309190611620565b610a3a9190611585565b60ff168567ffffffffffffffff169060020a02780100000000000000000000000000000000000000000000000002826080019077ffffffffffffffffffffffffffffffffffffffffffffffff1916908177ffffffffffffffffffffffffffffffffffffffffffffffff1916815250508251826040019060ff16908160ff168152505082610ac69061168a565b82606001906fffffffffffffffffffffffffffffffff191690816fffffffffffffffffffffffffffffffff19168152505085826000019060ff16908160ff1681525050816000808767ffffffffffffffff16815260200190815260200160002060008201518160000160006101000a81548160ff021916908360ff16021790555060208201518160000160016101000a81548160ff021916908360ff16021790555060408201518160000160026101000a81548160ff021916908360ff16021790555060608201518160000160036101000a8154816fffffffffffffffffffffffffffffffff02191690837001000000000000000000000000000000009004021790555060808201518160000160136101000a81548167ffffffffffffffff0219169083780100000000000000000000000000000000000000000000000090040217905550905050505050505050565b6040518060a00160405280600060ff168152602001600060ff168152602001600060ff16815260200160006fffffffffffffffffffffffffffffffff19168152602001600077ffffffffffffffffffffffffffffffffffffffffffffffff191681525090565b6000819050919050565b610c8f81610c7c565b82525050565b6000602082019050610caa6000830184610c86565b92915050565b6000604051905090565b600080fd5b600080fd5b610ccd81610c7c565b8114610cd857600080fd5b50565b600081359050610cea81610cc4565b92915050565b600060208284031215610d0657610d05610cba565b5b6000610d1484828501610cdb565b91505092915050565b60008115159050919050565b610d3281610d1d565b82525050565b6000602082019050610d4d6000830184610d29565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610da682610d5d565b810181811067ffffffffffffffff82111715610dc557610dc4610d6e565b5b80604052505050565b6000610dd8610cb0565b9050610de48282610d9d565b919050565b600067ffffffffffffffff821115610e0457610e03610d6e565b5b610e0d82610d5d565b9050602081019050919050565b82818337600083830152505050565b6000610e3c610e3784610de9565b610dce565b905082815260208101848484011115610e5857610e57610d58565b5b610e63848285610e1a565b509392505050565b600082601f830112610e8057610e7f610d53565b5b8135610e90848260208601610e29565b91505092915050565b600060208284031215610eaf57610eae610cba565b5b600082013567ffffffffffffffff811115610ecd57610ecc610cbf565b5b610ed984828501610e6b565b91505092915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610f1c578082015181840152602081019050610f01565b60008484015250505050565b6000610f3382610ee2565b610f3d8185610eed565b9350610f4d818560208601610efe565b610f5681610d5d565b840191505092915050565b60006020820190508181036000830152610f7b8184610f28565b905092915050565b600081519050919050565b600082825260208201905092915050565b6000610faa82610f83565b610fb48185610f8e565b9350610fc4818560208601610efe565b610fcd81610d5d565b840191505092915050565b60006020820190508181036000830152610ff28184610f9f565b905092915050565b600060ff82169050919050565b61101081610ffa565b82525050565b60007fffffffffffffffffffffffffffffffff0000000000000000000000000000000082169050919050565b61104b81611016565b82525050565b60007fffffffffffffffff00000000000000000000000000000000000000000000000082169050919050565b61108681611051565b82525050565b600060a0820190506110a16000830188611007565b6110ae6020830187611007565b6110bb6040830186611007565b6110c86060830185611042565b6110d5608083018461107d565b9695505050505050565b6110e881610ffa565b81146110f357600080fd5b50565b600081359050611105816110df565b92915050565b600067ffffffffffffffff82169050919050565b6111288161110b565b811461113357600080fd5b50565b6000813590506111458161111f565b92915050565b600067ffffffffffffffff82111561116657611165610d6e565b5b61116f82610d5d565b9050602081019050919050565b600061118f61118a8461114b565b610dce565b9050828152602081018484840111156111ab576111aa610d58565b5b6111b6848285610e1a565b509392505050565b600082601f8301126111d3576111d2610d53565b5b81356111e384826020860161117c565b91505092915050565b60008060006060848603121561120557611204610cba565b5b6000611213868287016110f6565b935050602061122486828701611136565b925050604084013567ffffffffffffffff81111561124557611244610cbf565b5b611251868287016111be565b9150509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061129582610c7c565b91506112a083610c7c565b92508282019050808211156112b8576112b761125b565b5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006112f882610c7c565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361132a5761132961125b565b5b600182019050919050565b600061134082610c7c565b915061134b83610c7c565b92508282039050818111156113635761136261125b565b5b92915050565b7f4552525f494e56414c49445f5354415445000000000000000000000000000000600082015250565b600061139f601183610eed565b91506113aa82611369565b602082019050919050565b600060208201905081810360008301526113ce81611392565b9050919050565b7f4552525f414c52454144595f4c4f434b45440000000000000000000000000000600082015250565b600061140b601283610eed565b9150611416826113d5565b602082019050919050565b6000602082019050818103600083015261143a816113fe565b9050919050565b7f4552525f5345414c5f434f444543000000000000000000000000000000000000600082015250565b6000611477600e83610eed565b915061148282611441565b602082019050919050565b600060208201905081810360008301526114a68161146a565b9050919050565b7f4552525f5345414c5f434f4445434c4953540000000000000000000000000000600082015250565b60006114e3601283610eed565b91506114ee826114ad565b602082019050919050565b60006020820190508181036000830152611512816114d6565b9050919050565b7f4552525f5052454649585f544f4f5f4c4f4e4700000000000000000000000000600082015250565b600061154f601383610eed565b915061155a82611519565b602082019050919050565b6000602082019050818103600083015261157e81611542565b9050919050565b600061159082610ffa565b915061159b83610ffa565b92508282026115a981610ffa565b91508082146115bb576115ba61125b565b5b5092915050565b60006115cd82610ffa565b9150600082036115e0576115df61125b565b5b600182039050919050565b60006115f682610ffa565b915061160183610ffa565b9250828201905060ff81111561161a5761161961125b565b5b92915050565b600061162b82610ffa565b915061163683610ffa565b9250828203905060ff81111561164f5761164e61125b565b5b92915050565b6000819050602082019050919050565b60006116718251611016565b80915050919050565b60008160020a8302905092915050565b600061169582610f83565b8261169f84611655565b90506116aa81611665565b925060108210156116ea576116e57fffffffffffffffffffffffffffffffff000000000000000000000000000000008360100360080261167a565b831692505b505091905056fea2646970667358221220c68d69e7d53370b3d4ba76b2af0ab8ac1c3772de400a3f1869f3577fc644aa4d64736f6c63430008110033 -\ No newline at end of file +60806040523480156200001157600080fd5b5062000065602060126040518060400160405280600681526020017f736861323536000000000000000000000000000000000000000000000000000081525062000086640100000000026401000000009004565b620000806012620003aa640100000000026401000000009004565b6200080e565b6000600160ff166002541614620000d4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620000cb9062000502565b60405180910390fd5b606081905060108151111562000121576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620001189062000574565b60405180910390fd5b6200012b6200043b565b6000600790505b60008160ff16106200018f5760006008826200014f9190620005d2565b60ff1660ff9060020a029050600086821667ffffffffffffffff1611156200017857506200018f565b8180620001859062000618565b9250505062000132565b6001816200019e919062000646565b826020019060ff16908160ff16815250506008816007620001c0919062000682565b620001cc9190620005d2565b60ff168567ffffffffffffffff169060020a02780100000000000000000000000000000000000000000000000002826080019077ffffffffffffffffffffffffffffffffffffffffffffffff1916908177ffffffffffffffffffffffffffffffffffffffffffffffff1916815250508251826040019060ff16908160ff1681525050826200025a906200072c565b82606001906fffffffffffffffffffffffffffffffff191690816fffffffffffffffffffffffffffffffff19168152505085826000019060ff16908160ff1681525050816000808767ffffffffffffffff16815260200190815260200160002060008201518160000160006101000a81548160ff021916908360ff16021790555060208201518160000160016101000a81548160ff021916908360ff16021790555060408201518160000160026101000a81548160ff021916908360ff16021790555060608201518160000160036101000a8154816fffffffffffffffffffffffffffffffff02191690837001000000000000000000000000000000009004021790555060808201518160000160136101000a81548167ffffffffffffffff0219169083780100000000000000000000000000000000000000000000000090040217905550905050505050505050565b6000600160ff166002541614620003f8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620003ef90620007ec565b60405180910390fd5b6000806000838152602001908152602001600020905060008160000160009054906101000a900460ff1660ff16116200043057600080fd5b816001819055505050565b6040518060a00160405280600060ff168152602001600060ff168152602001600060ff16815260200160006fffffffffffffffffffffffffffffffff19168152602001600077ffffffffffffffffffffffffffffffffffffffffffffffff191681525090565b600082825260208201905092915050565b7f4552525f5345414c5f434f4445434c4953540000000000000000000000000000600082015250565b6000620004ea601283620004a1565b9150620004f782620004b2565b602082019050919050565b600060208201905081810360008301526200051d81620004db565b9050919050565b7f4552525f5052454649585f544f4f5f4c4f4e4700000000000000000000000000600082015250565b60006200055c601383620004a1565b9150620005698262000524565b602082019050919050565b600060208201905081810360008301526200058f816200054d565b9050919050565b600060ff82169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000620005df8262000596565b9150620005ec8362000596565b9250828202620005fc8162000596565b9150808214620006115762000610620005a3565b5b5092915050565b6000620006258262000596565b9150600082036200063b576200063a620005a3565b5b600182039050919050565b6000620006538262000596565b9150620006608362000596565b9250828201905060ff8111156200067c576200067b620005a3565b5b92915050565b60006200068f8262000596565b91506200069c8362000596565b9250828203905060ff811115620006b857620006b7620005a3565b5b92915050565b600081519050919050565b6000819050602082019050919050565b60007fffffffffffffffffffffffffffffffff0000000000000000000000000000000082169050919050565b6000620007138251620006d9565b80915050919050565b60008160020a8302905092915050565b60006200073982620006be565b826200074584620006c9565b9050620007528162000705565b925060108210156200079557620007907fffffffffffffffffffffffffffffffff00000000000000000000000000000000836010036008026200071c565b831692505b5050919050565b7f4552525f5345414c5f434f444543000000000000000000000000000000000000600082015250565b6000620007d4600e83620004a1565b9150620007e1826200079c565b602082019050919050565b600060208201905081810360008301526200080781620007c5565b9050919050565b611c0d806200081e6000396000f3fe608060405234801561001057600080fd5b50600436106100bb576000357c0100000000000000000000000000000000000000000000000000000000900480639a7c5e9f116100835780639a7c5e9f1461018c578063ad0dec2f146101a8578063b238d603146101d8578063c5bec6fc1461020c578063ccc094c21461023c576100bb565b806318cbbcfc146100c05780632c1758c1146100de57806331a5995d1461010e578063779ab6671461012c57806386fe212d1461015c575b600080fd5b6100c8610258565b6040516100d5919061116d565b60405180910390f35b6100f860048036038101906100f391906111c8565b61025d565b6040516101059190611210565b60405180910390f35b610116610290565b604051610123919061116d565b60405180910390f35b61014660048036038101906101419190611371565b610296565b6040516101539190611439565b60405180910390f35b610176600480360381019061017191906111c8565b610540565b604051610183919061116d565b60405180910390f35b6101a660048036038101906101a191906111c8565b610627565b005b6101c260048036038101906101bd9190611371565b6106b4565b6040516101cf91906114b0565b60405180910390f35b6101f260048036038101906101ed91906111c8565b61098a565b604051610203959493929190611564565b60405180910390f35b61022660048036038101906102219190611371565b610a29565b60405161023391906114b0565b60405180910390f35b610256600480360381019061025191906116c4565b610de2565b005b600381565b60006003821061026c57600080fd5b6000820361028157600360025414905061028b565b8160025483161490505b919050565b60025481565b6060600060608060006102a886610a29565b9150600080600154815260200190815260200160002093508360000160029054906101000a900460ff1660ff16905060018251826102e69190611762565b6102f09190611762565b67ffffffffffffffff81111561030957610308611246565b5b6040519080825280601f01601f19166020018201604052801561033b5781602001600182028036833780820191505090505b50925060005b818110156103f5578460000160039054906101000a900470010000000000000000000000000000000002816010811061037d5761037c611796565b5b1a7f0100000000000000000000000000000000000000000000000000000000000000028482815181106103b3576103b2611796565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080806103ed906117c5565b915050610341565b50603a7f01000000000000000000000000000000000000000000000000000000000000000283828151811061042d5761042c611796565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508080610467906117c5565b91505060005b82518110156105335782818151811061048957610488611796565b5b60200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000028482846104e09190611762565b815181106104f1576104f0611796565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350808061052b906117c5565b91505061046d565b5082945050505050919050565b600060108210610585576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161057c90611859565b60405180910390fd5b60006002548316146105cc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105c3906118c5565b60405180910390fd5b8160026000828254179250508190555060036002541415157f6b7e2e653f93b645d4ed7292d6429f96637084363e477c8aaea1a43ed13c284e600254604051610615919061116d565b60405180910390a26002549050919050565b6000600160ff166002541614610672576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161066990611931565b60405180910390fd5b6000806000838152602001908152602001600020905060008160000160009054906101000a900460ff1660ff16116106a957600080fd5b816001819055505050565b606060006060600080600154815260200190815260200160002091508160000160019054906101000a900460ff1660ff168260000160009054906101000a900460ff1660ff1685516107069190611762565b6107109190611762565b67ffffffffffffffff81111561072957610728611246565b5b6040519080825280601f01601f19166020018201604052801561075b5781602001600182028036833780820191505090505b50905060005b8260000160019054906101000a900460ff1660ff16811015610831578260000160139054906101000a900478010000000000000000000000000000000000000000000000000281600881106107b9576107b8611796565b5b1a7f0100000000000000000000000000000000000000000000000000000000000000028282815181106107ef576107ee611796565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508080610829906117c5565b915050610761565b8260000160009054906101000a900460ff167f01000000000000000000000000000000000000000000000000000000000000000282828151811061087857610877611796565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080806108b2906117c5565b91505060005b855181101561097e578581815181106108d4576108d3611796565b5b60200101517f010000000000000000000000000000000000000000000000000000000000000090047f01000000000000000000000000000000000000000000000000000000000000000283828461092b9190611762565b8151811061093c5761093b611796565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508080610976906117c5565b9150506108b8565b50819350505050919050565b60006020528060005260406000206000915090508060000160009054906101000a900460ff16908060000160019054906101000a900460ff16908060000160029054906101000a900460ff16908060000160039054906101000a900470010000000000000000000000000000000002908060000160139054906101000a9004780100000000000000000000000000000000000000000000000002905085565b60608060008060028551610a3d9190611951565b67ffffffffffffffff811115610a5657610a55611246565b5b6040519080825280601f01601f191660200182016040528015610a885781602001600182028036833780820191505090505b5092506000905060005b6020811015610dd657600460f0878381518110610ab257610ab1611796565b5b60200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027f010000000000000000000000000000000000000000000000000000000000000090041660ff16908060020a82049150509250600a8360ff161015610bb157603083610b489190611993565b7f010000000000000000000000000000000000000000000000000000000000000002848381518110610b7d57610b7c611796565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350610c23565b605783610bbe9190611993565b7f010000000000000000000000000000000000000000000000000000000000000002848381518110610bf357610bf2611796565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053505b600f868281518110610c3857610c37611796565b5b60200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027f01000000000000000000000000000000000000000000000000000000000000009004169250600a8360ff161015610d3657603083610cc19190611993565b7f01000000000000000000000000000000000000000000000000000000000000000284600184610cf19190611762565b81518110610d0257610d01611796565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350610db4565b605783610d439190611993565b7f01000000000000000000000000000000000000000000000000000000000000000284600184610d739190611762565b81518110610d8457610d83611796565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053505b600282610dc19190611762565b91508080610dce906117c5565b915050610a92565b50829350505050919050565b6000600160ff166002541614610e2d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e2490611a14565b60405180910390fd5b6060819050601081511115610e77576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e6e90611a80565b60405180910390fd5b610e7f6110ee565b6000600790505b60008160ff1610610edb576000600882610ea09190611aa0565b60ff1660ff9060020a029050600086821667ffffffffffffffff161115610ec75750610edb565b8180610ed290611add565b92505050610e86565b600181610ee89190611993565b826020019060ff16908160ff16815250506008816007610f089190611b06565b610f129190611aa0565b60ff168567ffffffffffffffff169060020a02780100000000000000000000000000000000000000000000000002826080019077ffffffffffffffffffffffffffffffffffffffffffffffff1916908177ffffffffffffffffffffffffffffffffffffffffffffffff1916815250508251826040019060ff16908160ff168152505082610f9e90611b70565b82606001906fffffffffffffffffffffffffffffffff191690816fffffffffffffffffffffffffffffffff19168152505085826000019060ff16908160ff1681525050816000808767ffffffffffffffff16815260200190815260200160002060008201518160000160006101000a81548160ff021916908360ff16021790555060208201518160000160016101000a81548160ff021916908360ff16021790555060408201518160000160026101000a81548160ff021916908360ff16021790555060608201518160000160036101000a8154816fffffffffffffffffffffffffffffffff02191690837001000000000000000000000000000000009004021790555060808201518160000160136101000a81548167ffffffffffffffff0219169083780100000000000000000000000000000000000000000000000090040217905550905050505050505050565b6040518060a00160405280600060ff168152602001600060ff168152602001600060ff16815260200160006fffffffffffffffffffffffffffffffff19168152602001600077ffffffffffffffffffffffffffffffffffffffffffffffff191681525090565b6000819050919050565b61116781611154565b82525050565b6000602082019050611182600083018461115e565b92915050565b6000604051905090565b600080fd5b600080fd5b6111a581611154565b81146111b057600080fd5b50565b6000813590506111c28161119c565b92915050565b6000602082840312156111de576111dd611192565b5b60006111ec848285016111b3565b91505092915050565b60008115159050919050565b61120a816111f5565b82525050565b60006020820190506112256000830184611201565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61127e82611235565b810181811067ffffffffffffffff8211171561129d5761129c611246565b5b80604052505050565b60006112b0611188565b90506112bc8282611275565b919050565b600067ffffffffffffffff8211156112dc576112db611246565b5b6112e582611235565b9050602081019050919050565b82818337600083830152505050565b600061131461130f846112c1565b6112a6565b9050828152602081018484840111156113305761132f611230565b5b61133b8482856112f2565b509392505050565b600082601f8301126113585761135761122b565b5b8135611368848260208601611301565b91505092915050565b60006020828403121561138757611386611192565b5b600082013567ffffffffffffffff8111156113a5576113a4611197565b5b6113b184828501611343565b91505092915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156113f45780820151818401526020810190506113d9565b60008484015250505050565b600061140b826113ba565b61141581856113c5565b93506114258185602086016113d6565b61142e81611235565b840191505092915050565b600060208201905081810360008301526114538184611400565b905092915050565b600081519050919050565b600082825260208201905092915050565b60006114828261145b565b61148c8185611466565b935061149c8185602086016113d6565b6114a581611235565b840191505092915050565b600060208201905081810360008301526114ca8184611477565b905092915050565b600060ff82169050919050565b6114e8816114d2565b82525050565b60007fffffffffffffffffffffffffffffffff0000000000000000000000000000000082169050919050565b611523816114ee565b82525050565b60007fffffffffffffffff00000000000000000000000000000000000000000000000082169050919050565b61155e81611529565b82525050565b600060a08201905061157960008301886114df565b61158660208301876114df565b61159360408301866114df565b6115a0606083018561151a565b6115ad6080830184611555565b9695505050505050565b6115c0816114d2565b81146115cb57600080fd5b50565b6000813590506115dd816115b7565b92915050565b600067ffffffffffffffff82169050919050565b611600816115e3565b811461160b57600080fd5b50565b60008135905061161d816115f7565b92915050565b600067ffffffffffffffff82111561163e5761163d611246565b5b61164782611235565b9050602081019050919050565b600061166761166284611623565b6112a6565b90508281526020810184848401111561168357611682611230565b5b61168e8482856112f2565b509392505050565b600082601f8301126116ab576116aa61122b565b5b81356116bb848260208601611654565b91505092915050565b6000806000606084860312156116dd576116dc611192565b5b60006116eb868287016115ce565b93505060206116fc8682870161160e565b925050604084013567ffffffffffffffff81111561171d5761171c611197565b5b61172986828701611696565b9150509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061176d82611154565b915061177883611154565b92508282019050808211156117905761178f611733565b5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006117d082611154565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361180257611801611733565b5b600182019050919050565b7f4552525f494e56414c49445f5354415445000000000000000000000000000000600082015250565b60006118436011836113c5565b915061184e8261180d565b602082019050919050565b6000602082019050818103600083015261187281611836565b9050919050565b7f4552525f414c52454144595f4c4f434b45440000000000000000000000000000600082015250565b60006118af6012836113c5565b91506118ba82611879565b602082019050919050565b600060208201905081810360008301526118de816118a2565b9050919050565b7f4552525f5345414c5f434f444543000000000000000000000000000000000000600082015250565b600061191b600e836113c5565b9150611926826118e5565b602082019050919050565b6000602082019050818103600083015261194a8161190e565b9050919050565b600061195c82611154565b915061196783611154565b925082820261197581611154565b9150828204841483151761198c5761198b611733565b5b5092915050565b600061199e826114d2565b91506119a9836114d2565b9250828201905060ff8111156119c2576119c1611733565b5b92915050565b7f4552525f5345414c5f434f4445434c4953540000000000000000000000000000600082015250565b60006119fe6012836113c5565b9150611a09826119c8565b602082019050919050565b60006020820190508181036000830152611a2d816119f1565b9050919050565b7f4552525f5052454649585f544f4f5f4c4f4e4700000000000000000000000000600082015250565b6000611a6a6013836113c5565b9150611a7582611a34565b602082019050919050565b60006020820190508181036000830152611a9981611a5d565b9050919050565b6000611aab826114d2565b9150611ab6836114d2565b9250828202611ac4816114d2565b9150808214611ad657611ad5611733565b5b5092915050565b6000611ae8826114d2565b915060008203611afb57611afa611733565b5b600182039050919050565b6000611b11826114d2565b9150611b1c836114d2565b9250828203905060ff811115611b3557611b34611733565b5b92915050565b6000819050602082019050919050565b6000611b5782516114ee565b80915050919050565b60008160020a8302905092915050565b6000611b7b8261145b565b82611b8584611b3b565b9050611b9081611b4b565b92506010821015611bd057611bcb7fffffffffffffffffffffffffffffffff0000000000000000000000000000000083601003600802611b60565b831692505b505091905056fea2646970667358221220c40dc545351de8e204643c8ec0b06d9a24e411aea9dcefa0ae864583db7331b264736f6c63430008110033 +\ No newline at end of file diff --git a/python/eth_event_msg/data/Msg.json b/python/eth_event_msg/data/Msg.json @@ -1 +1 @@ -[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bool","name":"_final","type":"bool"},{"indexed":false,"internalType":"uint256","name":"_sealState","type":"uint256"}],"name":"SealStateChange","type":"event"},{"inputs":[{"internalType":"uint8","name":"_length","type":"uint8"},{"internalType":"uint64","name":"_codecId","type":"uint64"},{"internalType":"string","name":"_uriPrefix","type":"string"}],"name":"addCodec","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_state","type":"uint256"}],"name":"isSealed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSealState","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"multiCodecs","outputs":[{"internalType":"uint8","name":"l","type":"uint8"},{"internalType":"uint8","name":"codecRLength","type":"uint8"},{"internalType":"uint8","name":"prefixRLength","type":"uint8"},{"internalType":"bytes16","name":"prefix","type":"bytes16"},{"internalType":"bytes8","name":"codec","type":"bytes8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_state","type":"uint256"}],"name":"seal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sealState","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_codec","type":"uint256"}],"name":"setMsgCodec","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"_digest","type":"bytes"}],"name":"toHash","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"_digest","type":"bytes"}],"name":"toUri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}] +[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bool","name":"_final","type":"bool"},{"indexed":false,"internalType":"uint256","name":"_sealState","type":"uint256"}],"name":"SealStateChange","type":"event"},{"inputs":[{"internalType":"uint8","name":"_length","type":"uint8"},{"internalType":"uint64","name":"_codecId","type":"uint64"},{"internalType":"string","name":"_uriPrefix","type":"string"}],"name":"addCodec","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_state","type":"uint256"}],"name":"isSealed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSealState","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"multiCodecs","outputs":[{"internalType":"uint8","name":"l","type":"uint8"},{"internalType":"uint8","name":"codecRLength","type":"uint8"},{"internalType":"uint8","name":"prefixRLength","type":"uint8"},{"internalType":"bytes16","name":"prefix","type":"bytes16"},{"internalType":"bytes8","name":"codec","type":"bytes8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_state","type":"uint256"}],"name":"seal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sealState","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_codec","type":"uint256"}],"name":"setMsgCodec","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"_digest","type":"bytes"}],"name":"toHash","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"toHex","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes","name":"_digest","type":"bytes"}],"name":"toUri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}] diff --git a/python/tests/test_basic.py b/python/tests/test_basic.py @@ -42,7 +42,7 @@ class Test(EthTesterCase): c = EventMsg(self.chain_spec) #, signer=self.signer, nonce_oracle=nonce_oracle) o = c.to_hash(self.address, hash_of_foo, sender_address=self.accounts[0]) r = self.conn.do(o) - mh = c.parse_token_spec(r) + mh = c.parse_to_hash(r) self.assertEqual(mh[:4], '1220') self.assertEqual(mh[4:68], hash_of_foo) @@ -52,8 +52,8 @@ class Test(EthTesterCase): c = EventMsg(self.chain_spec) #, signer=self.signer, nonce_oracle=nonce_oracle) o = c.to_uri(self.address, hash_of_foo, sender_address=self.accounts[0]) r = self.conn.do(o) - mh = c.parse_token_spec(r) - print(bytes.fromhex(mh).decode('utf-8')) + mh = c.parse_to_uri(r) + self.assertEqual(mh, 'sha256:' + hash_of_foo) if __name__ == '__main__': diff --git a/solidity/Msg.sol b/solidity/Msg.sol @@ -103,17 +103,48 @@ contract Msg { MultiHash storage m; bytes memory codecString; + bytes memory digestHex; uint256 l; - + + digestHex = toHex(_digest); m = multiCodecs[msgCodec]; l = m.prefixRLength; - codecString = new bytes(l+1); - for (uint256 i; i < l; i++) { + codecString = new bytes(l + digestHex.length + 1); + for (uint256 i = 0; i < l; i++) { codecString[i] = m.prefix[i]; } - codecString[codecString.length - 1] = 0x3a; + codecString[l] = 0x3a; + l++; + + for (uint256 i = 0; i < digestHex.length; i++) { + codecString[l+i] = digestHex[i]; + } return string(codecString); } - + + function toHex(bytes memory _data) public pure returns(bytes memory) { + bytes memory out; + uint8 t; + uint256 c; + + out = new bytes(_data.length * 2); + c = 0; + for (uint256 i = 0; i < 32; i++) { + t = (uint8(_data[i]) & 0xf0) >> 4; + if (t < 10) { + out[c] = bytes1(t + 0x30); + } else { + out[c] = bytes1(t + 0x57); + } + t = uint8(_data[i]) & 0x0f; + if (t < 10) { + out[c+1] = bytes1(t + 0x30); + } else { + out[c+1] = bytes1(t + 0x57); + } + c += 2; + } + return out; + } }