mirror of
git://holbrook.no/eth-address-index
synced 2026-05-27 13:37:56 +02:00
Implement external signer
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1,4 +1,4 @@
|
||||
pragma solidity >=0.6.12;
|
||||
pragma solidity >0.6.11;
|
||||
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
@@ -13,7 +13,7 @@ contract AddressDeclarator {
|
||||
mapping( address => address[] ) declaratorReverse;
|
||||
bytes32[][] public contents;
|
||||
|
||||
constructor(bytes32 _initialDescription) {
|
||||
constructor(bytes32 _initialDescription) public {
|
||||
bytes32[] memory foundation;
|
||||
|
||||
owner = msg.sender;
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
SOLC = /usr/bin/solc
|
||||
|
||||
all:
|
||||
solc AddressDeclarator.sol --abi | awk 'NR>3' > AddressDeclarator.json
|
||||
solc AddressDeclarator.sol --bin | awk 'NR>3' > AddressDeclarator.bin
|
||||
$(SOLC) AddressDeclarator.sol --abi --evm-version byzantium | awk 'NR>3' > AddressDeclarator.json
|
||||
$(SOLC) AddressDeclarator.sol --bin --evm-version byzantium | awk 'NR>3' > AddressDeclarator.bin
|
||||
truncate -s -1 AddressDeclarator.bin
|
||||
solc TokenUniqueSymbolIndex.sol --abi | awk 'NR>3' > TokenUniqueSymbolIndex.json
|
||||
solc TokenUniqueSymbolIndex.sol --bin | awk 'NR>3' > TokenUniqueSymbolIndex.bin
|
||||
$(SOLC) TokenUniqueSymbolIndex.sol --abi --evm-version byzantium | awk 'NR>3' > TokenUniqueSymbolIndex.json
|
||||
$(SOLC) TokenUniqueSymbolIndex.sol --bin --evm-version byzantium | awk 'NR>3' > TokenUniqueSymbolIndex.bin
|
||||
truncate -s -1 TokenUniqueSymbolIndex.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
|
||||
python test_tokenindex.py
|
||||
|
||||
install: all
|
||||
cp -v AddressDeclarator.{json,bin} ../python/eth_address_declarator/data/
|
||||
cp -v TokenUniqueSymbolIndex.{json,bin} ../python/eth_token_index/data/
|
||||
|
||||
.PHONY: test
|
||||
.PHONY: test install
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
||||
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_token","type":"address"},{"indexed":true,"internalType":"address","name":"_adder","type":"address"},{"indexed":true,"internalType":"uint256","name":"_index","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"_data","type":"bytes32"}],"name":"EndorsementAdded","type":"event"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"bytes32","name":"_data","type":"bytes32"}],"name":"add","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"endorsement","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"endorser","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"endorserTokenCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"tokenSymbolIndex","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokens","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
|
||||
@@ -1,59 +0,0 @@
|
||||
pragma solidity >=0.6.12;
|
||||
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
contract TokenEndorsement {
|
||||
|
||||
uint256 count;
|
||||
mapping ( bytes32 => bytes32 ) public endorsement;
|
||||
mapping ( address => uint256 ) public tokenIndex;
|
||||
mapping ( address => uint256[] ) public endorser;
|
||||
mapping ( address => uint256 ) public endorserTokenCount;
|
||||
mapping ( string => address ) public tokenSymbolIndex;
|
||||
address[] public tokens;
|
||||
|
||||
event EndorsementAdded(address indexed _token, address indexed _adder, uint256 indexed _index, bytes32 _data);
|
||||
|
||||
constructor() {
|
||||
count = 1;
|
||||
tokens.push(address(0x0));
|
||||
}
|
||||
|
||||
function register(address _token) private returns (bool) {
|
||||
if (tokenIndex[_token] > 0) {
|
||||
return false;
|
||||
}
|
||||
(bool _ok, bytes memory _r) = _token.call(abi.encodeWithSignature('symbol()'));
|
||||
require(_ok);
|
||||
|
||||
string memory token_symbol = abi.decode(_r, (string));
|
||||
require(tokenSymbolIndex[token_symbol] == address(0));
|
||||
|
||||
tokens.push(_token);
|
||||
tokenIndex[_token] = count;
|
||||
tokenSymbolIndex[token_symbol] = _token;
|
||||
count++;
|
||||
return true;
|
||||
}
|
||||
|
||||
function add(address _token, bytes32 _data) public returns (bool) {
|
||||
register(_token);
|
||||
bytes32 k;
|
||||
bytes memory signMaterial = new bytes(40);
|
||||
bytes memory addrBytes = abi.encodePacked(_token);
|
||||
for (uint256 i = 0; i < 20; i++) {
|
||||
signMaterial[i] = addrBytes[i];
|
||||
}
|
||||
addrBytes = abi.encodePacked(msg.sender);
|
||||
for (uint256 i = 0; i < 20; i++) {
|
||||
signMaterial[i+20] = addrBytes[i];
|
||||
}
|
||||
k = sha256(signMaterial);
|
||||
require(endorsement[k] == bytes32(0x00));
|
||||
endorsement[k] = _data;
|
||||
endorser[msg.sender].push(tokenIndex[_token]);
|
||||
endorserTokenCount[msg.sender]++;
|
||||
emit EndorsementAdded(_token, msg.sender, count, _data);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -1,4 +1,4 @@
|
||||
pragma solidity >=0.6.12;
|
||||
pragma solidity >0.6.11;
|
||||
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
@@ -10,7 +10,7 @@ contract TokenUniqueSymbolIndex {
|
||||
mapping ( bytes32 => uint256 ) public registry;
|
||||
address[] tokens;
|
||||
|
||||
constructor() {
|
||||
constructor() public {
|
||||
owner = msg.sender;
|
||||
tokens.push(address(0));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user