commit 4400240b3e70886afb30528fe225c968a08fbb9d
parent 0b76e366b5e632a73a39855720225177dd444820
Author: nolash <dev@holbrook.no>
Date: Tue, 29 Dec 2020 17:33:00 +0100
Simplify new implementation
Diffstat:
5 files changed, 79 insertions(+), 49 deletions(-)
diff --git a/solidity/AddressDeclarator.bin b/solidity/AddressDeclarator.bin
@@ -1 +1 @@
-60806040523480156200001157600080fd5b5060405162001030380380620010308339818101604052810190620000379190620004a9565b60005b8151811015620000ae57620000973383838151811062000083577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151620000b660201b60201c565b508080620000a59062000565565b9150506200003a565b50506200062b565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050600073ffffffffffffffffffffffffffffffffffffffff168160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156200034457338160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600380549050908060018154018082558091505060019003906000526020600020016000909190919091505560038190806001815401808255809150506001900390600052602060002090600202016000909190919091506000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001820181600101908054620002e99291906200037a565b505050600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008154809291906200033e9062000565565b91905055505b80600101839080600181540180825580915050600190039060005260206000200160009091909190915055600191505092915050565b828054828255906000526020600020908101928215620003be5760005260206000209182015b82811115620003bd578254825591600101919060010190620003a0565b5b509050620003cd9190620003d1565b5090565b5b80821115620003ec576000816000905550600101620003d2565b5090565b600062000407620004018462000522565b620004ee565b905080838252602082019050828560208602820111156200042757600080fd5b60005b858110156200045b578162000440888262000492565b8452602084019350602083019250506001810190506200042a565b5050509392505050565b600082601f8301126200047757600080fd5b815162000489848260208601620003f0565b91505092915050565b600081519050620004a38162000611565b92915050565b600060208284031215620004bc57600080fd5b600082015167ffffffffffffffff811115620004d757600080fd5b620004e58482850162000465565b91505092915050565b6000604051905081810181811067ffffffffffffffff82111715620005185762000517620005e2565b5b8060405250919050565b600067ffffffffffffffff82111562000540576200053f620005e2565b5b602082029050602081019050919050565b6000819050919050565b6000819050919050565b600062000572826200055b565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415620005a857620005a7620005b3565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6200061c8162000551565b81146200062857600080fd5b50565b6109f5806200063b6000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80634cf94740146100515780638c661b3614610081578063ae47ece0146100b1578063d0e95db1146100e1575b600080fd5b61006b60048036038101906100669190610716565b610111565b6040516100789190610804565b60405180910390f35b61009b6004803603810190610096919061069e565b610212565b6040516100a8919061081f565b60405180910390f35b6100cb60048036038101906100c691906106da565b6102f0565b6040516100d89190610841565b60405180910390f35b6100fb60048036038101906100f69190610675565b6105af565b604051610108919061085c565b60405180910390f35b60008060008060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020848154811061018c577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549150600382815481106101d3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020906002020190508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169250505092915050565b60606000600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050806001018054806020026020016040519081016040528092919081815260200182805480156102e257602002820191906000526020600020905b8154815260200190600101908083116102ce575b505050505091505092915050565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050600073ffffffffffffffffffffffffffffffffffffffff168160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141561057957338160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600380549050908060018154018082558091505060019003906000526020600020016000909190919091505560038190806001815401808255809150506001900390600052602060002090600202016000909190919091506000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060018201816001019080546105209291906105c7565b505050600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919061057390610902565b91905055505b80600101839080600181540180825580915050600190039060005260206000200160009091909190915055600191505092915050565b60016020528060005260406000206000915090505481565b8280548282559060005260206000209081019282156106085760005260206000209182015b828111156106075782548255916001019190600101906105ec565b5b5090506106159190610619565b5090565b5b8082111561063257600081600090555060010161061a565b5090565b6000813590506106458161097a565b92915050565b60008135905061065a81610991565b92915050565b60008135905061066f816109a8565b92915050565b60006020828403121561068757600080fd5b600061069584828501610636565b91505092915050565b600080604083850312156106b157600080fd5b60006106bf85828601610636565b92505060206106d085828601610636565b9150509250929050565b600080604083850312156106ed57600080fd5b60006106fb85828601610636565b925050602061070c8582860161064b565b9150509250929050565b6000806040838503121561072957600080fd5b600061073785828601610636565b925050602061074885828601610660565b9150509250929050565b600061075e83836107e6565b60208301905092915050565b610773816108b0565b82525050565b600061078482610887565b61078e818561089f565b935061079983610877565b8060005b838110156107ca5781516107b18882610752565b97506107bc83610892565b92505060018101905061079d565b5085935050505092915050565b6107e0816108c2565b82525050565b6107ef816108ce565b82525050565b6107fe816108f8565b82525050565b6000602082019050610819600083018461076a565b92915050565b600060208201905081810360008301526108398184610779565b905092915050565b600060208201905061085660008301846107d7565b92915050565b600060208201905061087160008301846107f5565b92915050565b6000819050602082019050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b60006108bb826108d8565b9050919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600061090d826108f8565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156109405761093f61094b565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b610983816108b0565b811461098e57600080fd5b50565b61099a816108ce565b81146109a557600080fd5b50565b6109b1816108f8565b81146109bc57600080fd5b5056fea2646970667358221220018b89b5374b244917beb3e68f94598e291bafd107b142f944885782690e4ab264736f6c63430008000033
-\ No newline at end of file
+60806040523480156200001157600080fd5b50604051620018bc380380620018bc833981810160405281019062000037919062000677565b6060336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600381908060018154018082558091505060019003906000526020600020016000909190919091509080519060200190620000b6929190620005ef565b5060036001600380549050620000cd91906200079e565b8154811062000105577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001434090806001815401808255809150506001900390600052602060002001600090919091909150556200014933836200015260201b60201c565b50505062000923565b600080606060006200016b33876200031360201b60201c565b92506001600084815260200190815260200160002054905060008114156200026c57600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020339080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506003829080600181540180825580915050600190039060005260206000200160009091909190915090805190602001906200026a929190620005ef565b505b60016003805490506200028091906200079e565b905080600160008581526020019081526020016000208190555060038181548110620002d5577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020018590806001815401808255809150506001900390600052602060002001600090919091909150556001935050505092915050565b6000806000602867ffffffffffffffff8111156200035a577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156200038d5781602001600182028036833780820191505090505b509050600085604051602001620003a59190620006f5565b604051602081830303815290604052905060005b60148110156200048757818181518110620003fd577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602001015160f81c60f81b83828151811062000442577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080806200047e9062000857565b915050620003b9565b50846040516020016200049b9190620006f5565b604051602081830303815290604052905060005b60148110156200058b57818181518110620004f3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602001015160f81c60f81b836014836200050e919062000741565b8151811062000546577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508080620005829062000857565b915050620004af565b506002826040516200059e919062000712565b602060405180830381855afa158015620005bc573d6000803e3d6000fd5b5050506040513d601f19601f82011682018060405250810190620005e1919062000677565b925082935050505092915050565b8280548282559060005260206000209081019282156200062e579160200282015b828111156200062d57825182559160200191906001019062000610565b5b5090506200063d919062000641565b5090565b5b808211156200065c57600081600090555060010162000642565b5090565b600081519050620006718162000909565b92915050565b6000602082840312156200068a57600080fd5b60006200069a8482850162000660565b91505092915050565b620006b8620006b282620007d9565b620008a5565b82525050565b6000620006cb826200072b565b620006d7818562000736565b9350620006e981856020860162000821565b80840191505092915050565b6000620007038284620006a3565b60148201915081905092915050565b6000620007208284620006be565b915081905092915050565b600081519050919050565b600081905092915050565b60006200074e8262000817565b91506200075b8362000817565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115620007935762000792620008cd565b5b828201905092915050565b6000620007ab8262000817565b9150620007b88362000817565b925082821015620007ce57620007cd620008cd565b5b828203905092915050565b6000620007e682620007f7565b9050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60005b838110156200084157808201518184015260208101905062000824565b8381111562000851576000848401525b50505050565b6000620008648262000817565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156200089a5762000899620008cd565b5b600182019050919050565b6000620008b282620008b9565b9050919050565b6000620008c682620008fc565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008160601b9050919050565b6200091481620007ed565b81146200092057600080fd5b50565b610f8980620009336000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c80638da5cb5b1161005b5780638da5cb5b14610127578063ae47ece014610145578063d0e95db114610175578063ff7496b4146101a557610088565b806301ffc9a71461008d5780634cf94740146100bd578063880ad0af146100ed5780638c661b36146100f7575b600080fd5b6100a760048036038101906100a29190610a25565b6101d5565b6040516100b49190610c42565b60405180910390f35b6100d760048036038101906100d291906109c0565b6101dc565b6040516100e49190610c05565b60405180910390f35b6100f561022a565b005b610111600480360381019061010c9190610948565b610265565b60405161011e9190610c20565b60405180910390f35b61012f610329565b60405161013c9190610c05565b60405180910390f35b61015f600480360381019061015a9190610984565b61034d565b60405161016c9190610c42565b60405180910390f35b61018f600480360381019061018a919061091f565b610500565b60405161019c9190610c98565b60405180910390f35b6101bf60048036038101906101ba9190610a4e565b61054c565b6040516101cc9190610c5d565b60405180910390f35b6000919050565b600260205281600052604060002081815481106101f857600080fd5b906000526020600020016000915091509054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025c90610c78565b60405180910390fd5b60606000806102748585610589565b915060016000838152602001908152602001600020549050600381815481106102c6577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200180548060200260200160405190810160405280929190818152602001828054801561031a57602002820191906000526020600020905b815481526020019060010190808311610306575b50505050509250505092915050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000806060600061035e3387610589565b925060016000848152602001908152602001600020549050600081141561045c57600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020339080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060038290806001815401808255809150506001900390600052602060002001600090919091909150908051906020019061045a92919061084c565b505b600160038054905061046e9190610d69565b9050806001600085815260200190815260200160002081905550600381815481106104c2577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020018590806001815401808255809150506001900390600052602060002001600090919091909150556001935050505092915050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805490509050919050565b6003828154811061055c57600080fd5b90600052602060002001818154811061057457600080fd5b90600052602060002001600091509150505481565b6000806000602867ffffffffffffffff8111156105cf577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156106015781602001600182028036833780820191505090505b5090506000856040516020016106179190610bd3565b604051602081830303815290604052905060005b60148110156106f35781818151811061066d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602001015160f81c60f81b8382815181106106b1577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080806106eb90610e4e565b91505061062b565b50846040516020016107059190610bd3565b604051602081830303815290604052905060005b60148110156107ed5781818151811061075b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602001015160f81c60f81b836014836107749190610d13565b815181106107ab577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080806107e590610e4e565b915050610719565b506002826040516107fe9190610bee565b602060405180830381855afa15801561081b573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525081019061083e91906109fc565b925082935050505092915050565b828054828255906000526020600020908101928215610888579160200282015b8281111561088757825182559160200191906001019061086c565b5b5090506108959190610899565b5090565b5b808211156108b257600081600090555060010161089a565b5090565b6000813590506108c581610ef7565b92915050565b6000813590506108da81610f0e565b92915050565b6000815190506108ef81610f0e565b92915050565b60008135905061090481610f25565b92915050565b60008135905061091981610f3c565b92915050565b60006020828403121561093157600080fd5b600061093f848285016108b6565b91505092915050565b6000806040838503121561095b57600080fd5b6000610969858286016108b6565b925050602061097a858286016108b6565b9150509250929050565b6000806040838503121561099757600080fd5b60006109a5858286016108b6565b92505060206109b6858286016108cb565b9150509250929050565b600080604083850312156109d357600080fd5b60006109e1858286016108b6565b92505060206109f28582860161090a565b9150509250929050565b600060208284031215610a0e57600080fd5b6000610a1c848285016108e0565b91505092915050565b600060208284031215610a3757600080fd5b6000610a45848285016108f5565b91505092915050565b60008060408385031215610a6157600080fd5b6000610a6f8582860161090a565b9250506020610a808582860161090a565b9150509250929050565b6000610a968383610b35565b60208301905092915050565b610aab81610d9d565b82525050565b610ac2610abd82610d9d565b610e97565b82525050565b6000610ad382610cc3565b610add8185610ce6565b9350610ae883610cb3565b8060005b83811015610b19578151610b008882610a8a565b9750610b0b83610cd9565b925050600181019050610aec565b5085935050505092915050565b610b2f81610daf565b82525050565b610b3e81610dbb565b82525050565b610b4d81610dbb565b82525050565b6000610b5e82610cce565b610b688185610cf7565b9350610b78818560208601610e1b565b80840191505092915050565b6000610b91601783610d02565b91507f6f776e65722063616e6e6f74206265206368616e6765640000000000000000006000830152602082019050919050565b610bcd81610e11565b82525050565b6000610bdf8284610ab1565b60148201915081905092915050565b6000610bfa8284610b53565b915081905092915050565b6000602082019050610c1a6000830184610aa2565b92915050565b60006020820190508181036000830152610c3a8184610ac8565b905092915050565b6000602082019050610c576000830184610b26565b92915050565b6000602082019050610c726000830184610b44565b92915050565b60006020820190508181036000830152610c9181610b84565b9050919050565b6000602082019050610cad6000830184610bc4565b92915050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b6000610d1e82610e11565b9150610d2983610e11565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610d5e57610d5d610ebb565b5b828201905092915050565b6000610d7482610e11565b9150610d7f83610e11565b925082821015610d9257610d91610ebb565b5b828203905092915050565b6000610da882610df1565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60005b83811015610e39578082015181840152602081019050610e1e565b83811115610e48576000848401525b50505050565b6000610e5982610e11565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415610e8c57610e8b610ebb565b5b600182019050919050565b6000610ea282610ea9565b9050919050565b6000610eb482610eea565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008160601b9050919050565b610f0081610d9d565b8114610f0b57600080fd5b50565b610f1781610dbb565b8114610f2257600080fd5b50565b610f2e81610dc5565b8114610f3957600080fd5b50565b610f4581610e11565b8114610f5057600080fd5b5056fea2646970667358221220429e476bedf8f13891c550510f5e51ab149e9d63dcc86b1cd521655378704b2864736f6c63430008000033
+\ No newline at end of file
diff --git a/solidity/AddressDeclarator.json b/solidity/AddressDeclarator.json
@@ -1 +1 @@
-[{"inputs":[{"internalType":"bytes32[]","name":"_descriptions","type":"bytes32[]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"},{"internalType":"bytes32","name":"_proof","type":"bytes32"}],"name":"addDeclaration","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_declarator","type":"address"},{"internalType":"address","name":"_target","type":"address"}],"name":"declaration","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_target","type":"address"},{"internalType":"uint256","name":"_idx","type":"uint256"}],"name":"declarator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"declaratorCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
+[{"inputs":[{"internalType":"bytes32","name":"_initialDescription","type":"bytes32"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"},{"internalType":"bytes32","name":"_proof","type":"bytes32"}],"name":"addDeclaration","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"contents","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_declarator","type":"address"},{"internalType":"address","name":"_subject","type":"address"}],"name":"declaration","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"declarator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"}],"name":"declaratorCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceID","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]
diff --git a/solidity/AddressDeclarator.sol b/solidity/AddressDeclarator.sol
@@ -4,48 +4,74 @@ pragma solidity >=0.6.12;
contract AddressDeclarator {
- mapping( bytes32 => uint256[] )
- //mapping( address => uint256[] ) declaratorItemsIndex;
- //mapping( address => uint256 ) public declaratorCount;
- //mapping( address => mapping ( address => declaratorItem ) ) declarationByDeclaratorIndex;
- bytes32[][] contents;
-
-// constructor(bytes32[] memory _descriptions) {
-// for (uint i; i < _descriptions.length; i++) {
-// addDeclaration(msg.sender, _descriptions[i]);
-// }
-// }
-//
-// function addDeclaration(address _subject, bytes32 _proof) public returns ( bool ) {
-// declaratorItem storage item;
-//
-// item = declarationByDeclaratorIndex[msg.sender][_subject];
-// if (item.signer == address(0)) {
-// item.signer = msg.sender;
-// declaratorItemsIndex[_subject].push(declaratorItems.length);
-// declaratorItems.push(item);
-// declaratorCount[_subject]++;
-// }
-// item.content.push(_proof);
-//
-// return true;
-// }
-//
-// function declarator(address _target, uint256 _idx) public view returns ( address ) {
-// uint256 idx;
-// declaratorItem storage item;
-//
-// idx = declaratorItemsIndex[_target][_idx];
-// item = declaratorItems[idx];
-//
-// return item.signer;
-// }
-//
-// function declaration(address _declarator, address _target) public view returns ( bytes32[] memory ) {
-// declaratorItem storage item;
-//
-// item = declarationByDeclaratorIndex[_declarator][_target];
-//
-// return item.content;
-// }
+ // EIP 173
+ address public owner;
+
+ mapping( bytes32 => uint256 ) declarations;
+ mapping( address => address[] ) public declarator;
+ bytes32[][] public contents;
+
+ constructor(bytes32 _initialDescription) {
+ bytes32[] memory foundation;
+
+ owner = msg.sender;
+ contents.push(foundation);
+ contents[contents.length-1].push(blockhash(block.number));
+
+ addDeclaration(msg.sender, _initialDescription);
+ }
+
+ // EIP 172
+ function transferOwnership() public {
+ revert("owner cannot be changed");
+ }
+
+ // EIP-165
+ function supportsInterface(bytes4 interfaceID) public view returns ( bool ) {
+ return false;
+ }
+
+ function toReference(address _declarator, address _subject) private pure returns ( bytes32 ) {
+ bytes32 k;
+ bytes memory signMaterial = new bytes(40);
+ bytes memory addrBytes = abi.encodePacked(_declarator);
+ for (uint256 i = 0; i < 20; i++) {
+ signMaterial[i] = addrBytes[i];
+ }
+ addrBytes = abi.encodePacked(_subject);
+ for (uint256 i = 0; i < 20; i++) {
+ signMaterial[i+20] = addrBytes[i];
+ }
+ k = sha256(signMaterial);
+ return k;
+ }
+
+ function declaratorCount(address _subject) public view returns ( uint256 ) {
+ return declarator[_subject].length;
+ }
+
+ function addDeclaration(address _subject, bytes32 _proof) public returns ( bool ) {
+ bytes32 k;
+ bytes32[] memory declarationContents;
+ uint256 declarationsIndex;
+ k = toReference(msg.sender, _subject);
+ declarationsIndex = declarations[k];
+ if (declarationsIndex == 0) { // This also works for the constructor :)
+ declarator[_subject].push(msg.sender);
+ contents.push(declarationContents); //= contents[declarationsIndex],
+ }
+ declarationsIndex = contents.length-1;
+ declarations[k] = declarationsIndex;
+ contents[declarationsIndex].push(_proof);
+
+ return true;
+ }
+
+ function declaration(address _declarator, address _subject) public view returns ( bytes32[] memory ) {
+ bytes32 k;
+ uint256 i;
+ k = toReference(_declarator, _subject);
+ i = declarations[k];
+ return contents[i];
+ }
}
diff --git a/solidity/Makefile b/solidity/Makefile
@@ -3,6 +3,11 @@ all:
solc AddressDeclarator.sol --bin | awk 'NR>3' > AddressDeclarator.bin
truncate -s -1 AddressDeclarator.bin
+old:
+ solc TokenEndorser.sol --abi | awk 'NR>3' > TokenEndorser.json
+ solc TokenEndorser.sol --bin | awk 'NR>3' > TokenEndorser.bin
+ truncate -s -1 TokenEndorser.bin
+
test: all
python test.py
diff --git a/solidity/test.py b/solidity/test.py
@@ -39,7 +39,7 @@ declarations = [
]
# Deployment is a self-signed declaration
-tx_hash = c.constructor(declarations[0]).transact({'from': w3.eth.accounts[0]})
+tx_hash = c.constructor(declarations[0][0]).transact({'from': w3.eth.accounts[0]})
r = w3.eth.getTransactionReceipt(tx_hash)
logg.debug('contract {}'.format(r.contractAddress))
@@ -53,7 +53,6 @@ assert r == w3.eth.accounts[0]
r = c.functions.declaration(w3.eth.accounts[0], w3.eth.accounts[0]).call()
assert r[0].hex() == declarations[0][0][2:]
-assert r[1].hex() == declarations[0][1][2:]
# Add first declaration for 0 by 2