@reality.eth/contracts 3.0.9 → 3.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/abi/solc-0.8.10/RealityETH_ERC20_Factory.abi.json +1 -0
- package/bytecode/RealityETH_ERC20_Factory.bin +1 -0
- package/chains/deployments/4/DAOOS/RealityETH_ERC20-3.0.json +7 -0
- package/chains/deployments/4/LINK/RealityETH_ERC20-3.0.json +8 -0
- package/chains/deployments/5/ETH/RealityETH-3.0.json +6 -0
- package/chains/factories/4/RealityETH_ERC20-3.0.json +5 -0
- package/chains/supported.json +6 -0
- package/development/contracts/IERC20.sol +6 -0
- package/development/contracts/RealityETH_ERC20_Factory.sol +48 -0
- package/flat/RealityETH_ERC20_Factory.sol +140 -0
- package/generated/chains.json +18 -0
- package/generated/contracts.json +27 -0
- package/generated/factories.json +9 -0
- package/generated/tokens.json +8 -0
- package/package.json +3 -3
- package/scripts/deploy.js +65 -5
- package/scripts/generate_factory_json.js +26 -0
- package/tokens/ETH.json +1 -0
- package/tokens/LINK.json +7 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"inputs":[{"internalType":"address","name":"_libraryAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"reality_eth","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":false,"internalType":"string","name":"token_ticker","type":"string"}],"name":"RealityETH_ERC20_deployed","type":"event"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"createInstance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"deployments","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"libraryAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
608060405234801561001057600080fd5b506040516109ff3803806109ff83398101604081905261002f91610054565b600080546001600160a01b0319166001600160a01b0392909216919091179055610084565b60006020828403121561006657600080fd5b81516001600160a01b038116811461007d57600080fd5b9392505050565b61096c806100936000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063316b3739146100465780637726f7761461008b578063b816f513146100a0575b600080fd5b61006f610054366004610780565b6001602052600090815260409020546001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b61009e610099366004610780565b6100b3565b005b60005461006f906001600160a01b031681565b6001600160a01b0381811660009081526001602052604090205416156101455760405162461bcd60e51b815260206004820152603960248201527f54686572652073686f756c64206f6e6c79206265206f6e65206465706c6f796d60448201527f656e74207065722076657273696f6e2070657220746f6b656e00000000000000606482015260840160405180910390fd5b6000816001600160a01b031663313ce5676040518163ffffffff1660e01b81526004016020604051808303816000875af1158015610187573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101ab91906107b0565b90506000826001600160a01b03166395d89b416040518163ffffffff1660e01b81526004016000604051808303816000875af11580156101ef573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526102179190810190610819565b6000805491925090610231906001600160a01b031661072e565b60405163144fa6d760e01b81526001600160a01b0386811660048301529192509082169063144fa6d790602401600060405180830381600087803b15801561027857600080fd5b505af115801561028c573d6000803e3d6000fd5b50506040516383bf460960e01b815260206004820152603f60248201527f7b227469746c65223a20222573222c202274797065223a2022626f6f6c222c2060448201527f2263617465676f7279223a20222573222c20226c616e67223a20222573227d0060648201526001600160a01b03841692506383bf460991506084016020604051808303816000875af115801561032a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061034e91906108c6565b506040516383bf460960e01b815260206004820152604f60248201527f7b227469746c65223a20222573222c202274797065223a202275696e74222c2060448201527f22646563696d616c73223a2031382c202263617465676f7279223a202225732260648201526e2c20226c616e67223a20222573227d60881b60848201526001600160a01b038216906383bf46099060a4016020604051808303816000875af1158015610401573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061042591906108c6565b506040516383bf460960e01b815260206004820152605a60248201527f7b227469746c65223a20222573222c202274797065223a202273696e676c652d60448201527f73656c656374222c20226f7574636f6d6573223a205b25735d2c20226361746560648201527f676f7279223a20222573222c20226c616e67223a20222573227d00000000000060848201526001600160a01b038216906383bf46099060a4016020604051808303816000875af11580156104e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061050a91906108c6565b506040516383bf460960e01b815260206004820152605c60248201527f7b227469746c65223a20222573222c202274797065223a20226d756c7469706c60448201527f652d73656c656374222c20226f7574636f6d6573223a205b25735d2c2022636160648201527f7465676f7279223a20222573222c20226c616e67223a20222573227d0000000060848201526001600160a01b038216906383bf46099060a4016020604051808303816000875af11580156105cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105ef91906108c6565b506040516383bf460960e01b815260206004820152604360248201527f7b227469746c65223a20222573222c202274797065223a20226461746574696d60448201527f65222c202263617465676f7279223a20222573222c20226c616e67223a20222560648201526273227d60e81b60848201526001600160a01b038216906383bf46099060a4016020604051808303816000875af1158015610696573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106ba91906108c6565b506001600160a01b038481166000908152600160205260409081902080546001600160a01b03191692841692909217909155517fbe87db3b58b5f4d26d54d6f8a09bbab3eefdc8879ac48f5e21ccff2a1f50b072906107209083908790879087906108df565b60405180910390a150505050565b6000808260601b9050604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528160148201526e5af43d82803e903d91602b57fd5bf360881b60288201526037816000f0949350505050565b60006020828403121561079257600080fd5b81356001600160a01b03811681146107a957600080fd5b9392505050565b6000602082840312156107c257600080fd5b815160ff811681146107a957600080fd5b634e487b7160e01b600052604160045260246000fd5b60005b838110156108045781810151838201526020016107ec565b83811115610813576000848401525b50505050565b60006020828403121561082b57600080fd5b815167ffffffffffffffff8082111561084357600080fd5b818401915084601f83011261085757600080fd5b815181811115610869576108696107d3565b604051601f8201601f19908116603f01168101908382118183101715610891576108916107d3565b816040528281528760208487010111156108aa57600080fd5b6108bb8360208301602088016107e9565b979650505050505050565b6000602082840312156108d857600080fd5b5051919050565b600060018060a01b03808716835280861660208401525060ff8416604083015260806060830152825180608084015261091f8160a08501602087016107e9565b601f01601f19169190910160a0019594505050505056fea2646970667358221220933f84035753ce79c9cd1b56f21e8499cc54b3a0b7b98dbf0562ea68305d49e764736f6c634300080a0033
|
package/chains/supported.json
CHANGED
|
@@ -17,6 +17,12 @@
|
|
|
17
17
|
"graphURL": "https://api.thegraph.com/subgraphs/name/realityeth/realityeth-rinkeby",
|
|
18
18
|
"network_name": "rinkeby"
|
|
19
19
|
},
|
|
20
|
+
"5": {
|
|
21
|
+
"hostedRPC": "https://eth-goerli.g.alchemy.com/v2/i2jZKhmFBPZYl8YdSHxsZ6viP3PQLwId",
|
|
22
|
+
"explorerURL": "https://goerli.etherscan.io",
|
|
23
|
+
"graphURL": "https://api.thegraph.com/subgraphs/name/realityeth/realityeth-goerli",
|
|
24
|
+
"network_name": "goerli"
|
|
25
|
+
},
|
|
20
26
|
"8": {
|
|
21
27
|
"hostedRPC": "https://rpc.octano.dev",
|
|
22
28
|
"explorerURL": "https://ubqblockexplorer.com/"
|
|
@@ -20,6 +20,12 @@ interface IERC20 {
|
|
|
20
20
|
|
|
21
21
|
function transferFrom(address from, address to, uint256 value) external returns (bool);
|
|
22
22
|
|
|
23
|
+
function decimals() external returns (uint8);
|
|
24
|
+
|
|
25
|
+
function name() external returns (string memory);
|
|
26
|
+
|
|
27
|
+
function symbol() external returns (string memory);
|
|
28
|
+
|
|
23
29
|
event Transfer(address indexed from, address indexed to, uint256 value);
|
|
24
30
|
|
|
25
31
|
event Approval(address indexed owner, address indexed spender, uint256 value);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8.10;
|
|
4
|
+
|
|
5
|
+
import "./IRealityETH_ERC20.sol";
|
|
6
|
+
import "./IERC20.sol";
|
|
7
|
+
|
|
8
|
+
contract RealityETH_ERC20_Factory {
|
|
9
|
+
|
|
10
|
+
address public libraryAddress;
|
|
11
|
+
mapping(address => address) public deployments;
|
|
12
|
+
|
|
13
|
+
event RealityETH_ERC20_deployed (address reality_eth, address token, uint8 decimals, string token_ticker);
|
|
14
|
+
|
|
15
|
+
constructor(address _libraryAddress) {
|
|
16
|
+
libraryAddress = _libraryAddress;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/// @notice Returns the address of a proxy based on the specified address
|
|
20
|
+
/// @dev based on https://github.com/optionality/clone-factory
|
|
21
|
+
function _deployProxy(address _target)
|
|
22
|
+
internal returns (address result) {
|
|
23
|
+
bytes20 targetBytes = bytes20(_target);
|
|
24
|
+
assembly {
|
|
25
|
+
let clone := mload(0x40)
|
|
26
|
+
mstore(clone, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
|
|
27
|
+
mstore(add(clone, 0x14), targetBytes)
|
|
28
|
+
mstore(add(clone, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
|
|
29
|
+
result := create(0, clone, 0x37)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function createInstance(address _token) external {
|
|
34
|
+
require(deployments[_token] == address(0), "There should only be one deployment per version per token");
|
|
35
|
+
uint8 decimals = IERC20(_token).decimals();
|
|
36
|
+
string memory ticker = IERC20(_token).symbol();
|
|
37
|
+
address clone = _deployProxy(libraryAddress);
|
|
38
|
+
IRealityETH_ERC20(clone).setToken(_token);
|
|
39
|
+
IRealityETH_ERC20(clone).createTemplate('{"title": "%s", "type": "bool", "category": "%s", "lang": "%s"}');
|
|
40
|
+
IRealityETH_ERC20(clone).createTemplate('{"title": "%s", "type": "uint", "decimals": 18, "category": "%s", "lang": "%s"}');
|
|
41
|
+
IRealityETH_ERC20(clone).createTemplate('{"title": "%s", "type": "single-select", "outcomes": [%s], "category": "%s", "lang": "%s"}');
|
|
42
|
+
IRealityETH_ERC20(clone).createTemplate('{"title": "%s", "type": "multiple-select", "outcomes": [%s], "category": "%s", "lang": "%s"}');
|
|
43
|
+
IRealityETH_ERC20(clone).createTemplate('{"title": "%s", "type": "datetime", "category": "%s", "lang": "%s"}');
|
|
44
|
+
deployments[_token] = clone;
|
|
45
|
+
emit RealityETH_ERC20_deployed(clone, _token, decimals, ticker);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8.10;
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @title ERC20 interface
|
|
8
|
+
* @dev see https://github.com/ethereum/EIPs/issues/20
|
|
9
|
+
*/
|
|
10
|
+
interface IERC20 {
|
|
11
|
+
function totalSupply() external view returns (uint256);
|
|
12
|
+
|
|
13
|
+
function balanceOf(address who) external view returns (uint256);
|
|
14
|
+
|
|
15
|
+
function allowance(address owner, address spender) external view returns (uint256);
|
|
16
|
+
|
|
17
|
+
function transfer(address to, uint256 value) external returns (bool);
|
|
18
|
+
|
|
19
|
+
function approve(address spender, uint256 value) external returns (bool);
|
|
20
|
+
|
|
21
|
+
function transferFrom(address from, address to, uint256 value) external returns (bool);
|
|
22
|
+
|
|
23
|
+
function decimals() external returns (uint8);
|
|
24
|
+
|
|
25
|
+
function name() external returns (string memory);
|
|
26
|
+
|
|
27
|
+
function symbol() external returns (string memory);
|
|
28
|
+
|
|
29
|
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
|
30
|
+
|
|
31
|
+
event Approval(address indexed owner, address indexed spender, uint256 value);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface IBalanceHolder_ERC20 {
|
|
35
|
+
function withdraw ( ) external;
|
|
36
|
+
function balanceOf ( address ) external view returns ( uint256 );
|
|
37
|
+
function token ( ) external view returns ( IERC20 );
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface IRealityETH_ERC20 is IBalanceHolder_ERC20 {
|
|
41
|
+
event LogAnswerReveal (bytes32 indexed question_id, address indexed user, bytes32 indexed answer_hash, bytes32 answer, uint256 nonce, uint256 bond);
|
|
42
|
+
event LogCancelArbitration (bytes32 indexed question_id);
|
|
43
|
+
event LogClaim (bytes32 indexed question_id, address indexed user, uint256 amount);
|
|
44
|
+
event LogFinalize (bytes32 indexed question_id, bytes32 indexed answer);
|
|
45
|
+
event LogFundAnswerBounty (bytes32 indexed question_id, uint256 bounty_added, uint256 bounty, address indexed user);
|
|
46
|
+
event LogMinimumBond (bytes32 indexed question_id, uint256 min_bond);
|
|
47
|
+
event LogNewAnswer (bytes32 answer, bytes32 indexed question_id, bytes32 history_hash, address indexed user, uint256 bond, uint256 ts, bool is_commitment);
|
|
48
|
+
event LogNewQuestion (bytes32 indexed question_id, address indexed user, uint256 template_id, string question, bytes32 indexed content_hash, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce, uint256 created);
|
|
49
|
+
event LogNewTemplate (uint256 indexed template_id, address indexed user, string question_text);
|
|
50
|
+
event LogNotifyOfArbitrationRequest (bytes32 indexed question_id, address indexed user);
|
|
51
|
+
event LogReopenQuestion (bytes32 indexed question_id, bytes32 indexed reopened_question_id);
|
|
52
|
+
event LogSetQuestionFee (address arbitrator, uint256 amount);
|
|
53
|
+
|
|
54
|
+
function askQuestion (uint256 template_id, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce) external returns (bytes32);
|
|
55
|
+
function askQuestionERC20 (uint256 template_id, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce, uint256 tokens) external returns (bytes32);
|
|
56
|
+
function askQuestionWithMinBondERC20 (uint256 template_id, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce, uint256 min_bond, uint256 tokens) external returns (bytes32);
|
|
57
|
+
function assignWinnerAndSubmitAnswerByArbitrator (bytes32 question_id, bytes32 answer, address payee_if_wrong, bytes32 last_history_hash, bytes32 last_answer_or_commitment_id, address last_answerer) external;
|
|
58
|
+
function cancelArbitration (bytes32 question_id) external;
|
|
59
|
+
function claimMultipleAndWithdrawBalance (bytes32[] calldata question_ids, uint256[] calldata lengths, bytes32[] calldata hist_hashes, address[] calldata addrs, uint256[] calldata bonds, bytes32[] calldata answers) external;
|
|
60
|
+
function claimWinnings (bytes32 question_id, bytes32[] calldata history_hashes, address[] calldata addrs, uint256[] calldata bonds, bytes32[] calldata answers) external;
|
|
61
|
+
function createTemplate (string calldata content) external returns (uint256);
|
|
62
|
+
function createTemplateAndAskQuestion (string calldata content, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce) external returns (bytes32);
|
|
63
|
+
function fundAnswerBountyERC20 (bytes32 question_id, uint256 tokens) external;
|
|
64
|
+
function notifyOfArbitrationRequest (bytes32 question_id, address requester, uint256 max_previous) external;
|
|
65
|
+
function reopenQuestionERC20 (uint256 template_id, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce, uint256 min_bond, bytes32 reopens_question_id, uint256 tokens) external returns (bytes32);
|
|
66
|
+
function setQuestionFee (uint256 fee) external;
|
|
67
|
+
function setToken (address _token) external;
|
|
68
|
+
function submitAnswerByArbitrator (bytes32 question_id, bytes32 answer, address answerer) external;
|
|
69
|
+
function submitAnswerCommitmentERC20 (bytes32 question_id, bytes32 answer_hash, uint256 max_previous, address _answerer, uint256 tokens) external;
|
|
70
|
+
function submitAnswerERC20 (bytes32 question_id, bytes32 answer, uint256 max_previous, uint256 tokens) external;
|
|
71
|
+
function submitAnswerForERC20 (bytes32 question_id, bytes32 answer, uint256 max_previous, address answerer, uint256 tokens) external;
|
|
72
|
+
function submitAnswerReveal (bytes32 question_id, bytes32 answer, uint256 nonce, uint256 bond) external;
|
|
73
|
+
function arbitrator_question_fees (address) external view returns (uint256);
|
|
74
|
+
function commitments (bytes32) external view returns (uint32 reveal_ts, bool is_revealed, bytes32 revealed_answer);
|
|
75
|
+
function getArbitrator (bytes32 question_id) external view returns (address);
|
|
76
|
+
function getBestAnswer (bytes32 question_id) external view returns (bytes32);
|
|
77
|
+
function getBond (bytes32 question_id) external view returns (uint256);
|
|
78
|
+
function getBounty (bytes32 question_id) external view returns (uint256);
|
|
79
|
+
function getContentHash (bytes32 question_id) external view returns (bytes32);
|
|
80
|
+
function getFinalAnswer (bytes32 question_id) external view returns (bytes32);
|
|
81
|
+
function getFinalAnswerIfMatches (bytes32 question_id, bytes32 content_hash, address arbitrator, uint32 min_timeout, uint256 min_bond) external view returns (bytes32);
|
|
82
|
+
function getFinalizeTS (bytes32 question_id) external view returns (uint32);
|
|
83
|
+
function getHistoryHash (bytes32 question_id) external view returns (bytes32);
|
|
84
|
+
function getMinBond (bytes32 question_id) external view returns (uint256);
|
|
85
|
+
function getOpeningTS (bytes32 question_id) external view returns (uint32);
|
|
86
|
+
function getTimeout (bytes32 question_id) external view returns (uint32);
|
|
87
|
+
function isFinalized (bytes32 question_id) external view returns (bool);
|
|
88
|
+
function isPendingArbitration (bytes32 question_id) external view returns (bool);
|
|
89
|
+
function isSettledTooSoon (bytes32 question_id) external view returns (bool);
|
|
90
|
+
function question_claims (bytes32) external view returns (address payee, uint256 last_bond, uint256 queued_funds);
|
|
91
|
+
function questions (bytes32) external view returns (bytes32 content_hash, address arbitrator, uint32 opening_ts, uint32 timeout, uint32 finalize_ts, bool is_pending_arbitration, uint256 bounty, bytes32 best_answer, bytes32 history_hash, uint256 bond, uint256 min_bond);
|
|
92
|
+
function reopened_questions (bytes32) external view returns (bytes32);
|
|
93
|
+
function reopener_questions (bytes32) external view returns (bool);
|
|
94
|
+
function resultFor (bytes32 question_id) external view returns (bytes32);
|
|
95
|
+
function resultForOnceSettled (bytes32 question_id) external view returns (bytes32);
|
|
96
|
+
function template_hashes (uint256) external view returns (bytes32);
|
|
97
|
+
function templates (uint256) external view returns (uint256);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
contract RealityETH_ERC20_Factory {
|
|
101
|
+
|
|
102
|
+
address public libraryAddress;
|
|
103
|
+
mapping(address => address) public deployments;
|
|
104
|
+
|
|
105
|
+
event RealityETH_ERC20_deployed (address reality_eth, address token, uint8 decimals, string token_ticker);
|
|
106
|
+
|
|
107
|
+
constructor(address _libraryAddress) {
|
|
108
|
+
libraryAddress = _libraryAddress;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/// @notice Returns the address of a proxy based on the specified address
|
|
112
|
+
/// @dev based on https://github.com/optionality/clone-factory
|
|
113
|
+
function _deployProxy(address _target)
|
|
114
|
+
internal returns (address result) {
|
|
115
|
+
bytes20 targetBytes = bytes20(_target);
|
|
116
|
+
assembly {
|
|
117
|
+
let clone := mload(0x40)
|
|
118
|
+
mstore(clone, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
|
|
119
|
+
mstore(add(clone, 0x14), targetBytes)
|
|
120
|
+
mstore(add(clone, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
|
|
121
|
+
result := create(0, clone, 0x37)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function createInstance(address _token) external {
|
|
126
|
+
require(deployments[_token] == address(0), "There should only be one deployment per version per token");
|
|
127
|
+
uint8 decimals = IERC20(_token).decimals();
|
|
128
|
+
string memory ticker = IERC20(_token).symbol();
|
|
129
|
+
address clone = _deployProxy(libraryAddress);
|
|
130
|
+
IRealityETH_ERC20(clone).setToken(_token);
|
|
131
|
+
IRealityETH_ERC20(clone).createTemplate('{"title": "%s", "type": "bool", "category": "%s", "lang": "%s"}');
|
|
132
|
+
IRealityETH_ERC20(clone).createTemplate('{"title": "%s", "type": "uint", "decimals": 18, "category": "%s", "lang": "%s"}');
|
|
133
|
+
IRealityETH_ERC20(clone).createTemplate('{"title": "%s", "type": "single-select", "outcomes": [%s], "category": "%s", "lang": "%s"}');
|
|
134
|
+
IRealityETH_ERC20(clone).createTemplate('{"title": "%s", "type": "multiple-select", "outcomes": [%s], "category": "%s", "lang": "%s"}');
|
|
135
|
+
IRealityETH_ERC20(clone).createTemplate('{"title": "%s", "type": "datetime", "category": "%s", "lang": "%s"}');
|
|
136
|
+
deployments[_token] = clone;
|
|
137
|
+
emit RealityETH_ERC20_deployed(clone, _token, decimals, ticker);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
}
|
package/generated/chains.json
CHANGED
|
@@ -50,6 +50,24 @@
|
|
|
50
50
|
"https://rinkeby.etherscan.io"
|
|
51
51
|
]
|
|
52
52
|
},
|
|
53
|
+
"5": {
|
|
54
|
+
"chainId": "0x5",
|
|
55
|
+
"chainName": "Görli",
|
|
56
|
+
"nativeCurrency": {
|
|
57
|
+
"name": "Görli Ether",
|
|
58
|
+
"symbol": "GOR",
|
|
59
|
+
"decimals": 18
|
|
60
|
+
},
|
|
61
|
+
"network_name": "goerli",
|
|
62
|
+
"rpcUrls": [
|
|
63
|
+
"https://rpc.goerli.mudit.blog/"
|
|
64
|
+
],
|
|
65
|
+
"hostedRPC": "https://eth-goerli.g.alchemy.com/v2/i2jZKhmFBPZYl8YdSHxsZ6viP3PQLwId",
|
|
66
|
+
"graphURL": "https://api.thegraph.com/subgraphs/name/realityeth/realityeth-goerli",
|
|
67
|
+
"blockExplorerUrls": [
|
|
68
|
+
"https://goerli.etherscan.io"
|
|
69
|
+
]
|
|
70
|
+
},
|
|
53
71
|
"8": {
|
|
54
72
|
"chainId": "0x8",
|
|
55
73
|
"chainName": "Ubiq",
|
package/generated/contracts.json
CHANGED
|
@@ -81,6 +81,13 @@
|
|
|
81
81
|
"arbitrators": {
|
|
82
82
|
"0x8368d613059dcbdBF909081Bb00190a01b0d5F9D": "daoOS DAO team (rinkeby main)"
|
|
83
83
|
}
|
|
84
|
+
},
|
|
85
|
+
"RealityETH_ERC20-3.0": {
|
|
86
|
+
"address": "0x5e97Dd72812B59cB3166B0D907a9B360493b9971",
|
|
87
|
+
"block": 11107270,
|
|
88
|
+
"token_address": "0x56AE5fd086823d1892BACE27034Eb5531Fcdc3f8",
|
|
89
|
+
"notes": null,
|
|
90
|
+
"arbitrators": {}
|
|
84
91
|
}
|
|
85
92
|
},
|
|
86
93
|
"ETH": {
|
|
@@ -115,6 +122,16 @@
|
|
|
115
122
|
}
|
|
116
123
|
}
|
|
117
124
|
},
|
|
125
|
+
"LINK": {
|
|
126
|
+
"RealityETH_ERC20-3.0": {
|
|
127
|
+
"address": "0x4a38a9EdE2f997E97Cac2D7BF8e002Ec20d2c2Ca",
|
|
128
|
+
"block": 11107294,
|
|
129
|
+
"token_address": "0x01be23585060835e02b77ef475b0cc51aa1e0709",
|
|
130
|
+
"notes": null,
|
|
131
|
+
"arbitrators": {},
|
|
132
|
+
"factory_address": "0x9e862794f4f80386185b9d3baa532668e988c530"
|
|
133
|
+
}
|
|
134
|
+
},
|
|
118
135
|
"TRST": {
|
|
119
136
|
"Arbitrator": {
|
|
120
137
|
"address": "0xa682C58333F4959cbF728c2a871548E3D8978Fa2",
|
|
@@ -132,6 +149,16 @@
|
|
|
132
149
|
}
|
|
133
150
|
}
|
|
134
151
|
},
|
|
152
|
+
"5": {
|
|
153
|
+
"ETH": {
|
|
154
|
+
"RealityETH-3.0": {
|
|
155
|
+
"address": "0x6F80C5cBCF9FbC2dA2F0675E56A5900BB70Df72f",
|
|
156
|
+
"block": 7313547,
|
|
157
|
+
"notes": null,
|
|
158
|
+
"arbitrators": {}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
},
|
|
135
162
|
"8": {
|
|
136
163
|
"UBQ": {
|
|
137
164
|
"Arbitrator": {
|
package/generated/tokens.json
CHANGED
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"native_chains": {
|
|
35
35
|
"1": true,
|
|
36
36
|
"4": true,
|
|
37
|
+
"5": true,
|
|
37
38
|
"42": true,
|
|
38
39
|
"280": true,
|
|
39
40
|
"1337702": true
|
|
@@ -98,6 +99,13 @@
|
|
|
98
99
|
"100": "0x9C58BAcC331c9aa871AFD802DB6379a98e80CEdb"
|
|
99
100
|
}
|
|
100
101
|
},
|
|
102
|
+
"LINK": {
|
|
103
|
+
"decimals": 18,
|
|
104
|
+
"small_number": 1000000000000000000,
|
|
105
|
+
"erc20_chains": {
|
|
106
|
+
"4": "0x01be23585060835e02b77ef475b0cc51aa1e0709"
|
|
107
|
+
}
|
|
108
|
+
},
|
|
101
109
|
"POLK": {
|
|
102
110
|
"decimals": 18,
|
|
103
111
|
"small_number": 1000000000000000000,
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reality.eth/contracts",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.12",
|
|
4
4
|
"description": "Collection of smart contracts for the Realitio fact verification platform",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"generate-chains": "node scripts/generate_chains_json.js",
|
|
7
7
|
"generate-contracts": "node scripts/generate_contract_json.js",
|
|
8
8
|
"generate-tokens": "node scripts/generate_token_json.js",
|
|
9
|
-
"generate": "node scripts/generate_token_json.js && node scripts/generate_chains_json.js && node scripts/generate_contract_json.js"
|
|
9
|
+
"generate": "node scripts/generate_token_json.js && node scripts/generate_chains_json.js && node scripts/generate_contract_json.js && node scripts/generate_factory_json.js"
|
|
10
10
|
},
|
|
11
11
|
"main": "index.js",
|
|
12
12
|
"keywords": [
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"url": "https://github.com/RealityETH/monorepo/issues"
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://reality.eth.link",
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "f9933bfbc17dd8a796e0c3200acc4bd098e9aaaf",
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"ethers": "^5.6.8"
|
|
36
36
|
}
|
package/scripts/deploy.js
CHANGED
|
@@ -15,9 +15,9 @@ const defaultConfigs = {
|
|
|
15
15
|
// maxPriorityFeePerGas: 1000000000,
|
|
16
16
|
//gasPrice: 70000000000
|
|
17
17
|
// gasPrice: 10000, // optimism 1000000,
|
|
18
|
-
gasPrice: 5000000000,
|
|
18
|
+
/// gasPrice: 5000000000,
|
|
19
19
|
// gasLimit: 6000000, // optimism 4500000
|
|
20
|
-
gasLimit: 4500000,
|
|
20
|
+
// gasLimit: 4500000,
|
|
21
21
|
//etherscanApiKey: 'TPA4BFDDIH8Q7YBQ4JMGN6WDDRRPAV6G34'
|
|
22
22
|
// gasLimit: 155734867 // arbitrum
|
|
23
23
|
}
|
|
@@ -50,7 +50,7 @@ const chains = {
|
|
|
50
50
|
'kintsugi': 1337702,
|
|
51
51
|
}
|
|
52
52
|
const non_infura_chains = {
|
|
53
|
-
'xdai': 'https://
|
|
53
|
+
'xdai': 'https://rpc.ankr.com/gnosis',
|
|
54
54
|
'sokol': 'https://sokol.poa.network',
|
|
55
55
|
'bsc': 'https://bsc-dataseed.binance.org',
|
|
56
56
|
'polygon': 'https://rpc-mainnet.maticvigil.com',
|
|
@@ -69,7 +69,11 @@ function constructContractTemplate(contract_name) {
|
|
|
69
69
|
try {
|
|
70
70
|
abi = JSON.parse(fs.readFileSync(project_base + '/abi/solc-0.4.25/'+contract_name+'.abi.json'));
|
|
71
71
|
} catch(e) {
|
|
72
|
-
|
|
72
|
+
try {
|
|
73
|
+
abi = JSON.parse(fs.readFileSync(project_base + '/abi/solc-0.8.6/'+contract_name+'.abi.json'));
|
|
74
|
+
} catch(e) {
|
|
75
|
+
abi = JSON.parse(fs.readFileSync(project_base + '/abi/solc-0.8.10/'+contract_name+'.abi.json'));
|
|
76
|
+
}
|
|
73
77
|
}
|
|
74
78
|
const bytecode = fs.readFileSync(project_base + '/bytecode/'+contract_name+'.bin', 'utf8').replace(/\n/, '');
|
|
75
79
|
//console.log('bytecode', bytecode);
|
|
@@ -82,7 +86,7 @@ function constructContractTemplate(contract_name) {
|
|
|
82
86
|
|
|
83
87
|
function usage_error(msg) {
|
|
84
88
|
msg = msg + "\n";
|
|
85
|
-
msg += "Usage: node deploy.js <RealityETH|Arbitrator|ERC20> <version> <chain_name> <token_name> [<dispute_fee>] [<arbitrator_owner>]";
|
|
89
|
+
msg += "Usage: node deploy.js <RealityETH|Arbitrator|ERC20|Factory> <version> <chain_name> <token_name> [<dispute_fee>] [<arbitrator_owner>]";
|
|
86
90
|
throw msg;
|
|
87
91
|
}
|
|
88
92
|
|
|
@@ -126,6 +130,8 @@ if (task == 'RealityETH') {
|
|
|
126
130
|
deployArbitrator();
|
|
127
131
|
} else if (task == 'ERC20') {
|
|
128
132
|
deployERC20();
|
|
133
|
+
} else if (task == 'Factory') {
|
|
134
|
+
deployFactory();
|
|
129
135
|
}
|
|
130
136
|
|
|
131
137
|
function ensure_chain_directory_exists(chain, token) {
|
|
@@ -136,6 +142,13 @@ function ensure_chain_directory_exists(chain, token) {
|
|
|
136
142
|
recursive: true
|
|
137
143
|
});
|
|
138
144
|
}
|
|
145
|
+
const dir2 = project_base + '/chains/factories/' + chain;
|
|
146
|
+
if (!fs.existsSync(dir2)) {
|
|
147
|
+
console.log('creating directory for factories', chain, dir);
|
|
148
|
+
fs.mkdirSync(dir2, {
|
|
149
|
+
recursive: true
|
|
150
|
+
});
|
|
151
|
+
}
|
|
139
152
|
return true;
|
|
140
153
|
}
|
|
141
154
|
|
|
@@ -145,6 +158,13 @@ function store_deployed_contract(template, chain_id, token_name, out_json) {
|
|
|
145
158
|
console.log('wrote file', file);
|
|
146
159
|
}
|
|
147
160
|
|
|
161
|
+
function store_deployed_factory_contract(template, chain_id, out_json) {
|
|
162
|
+
const file = project_base + '/chains/factories/' + chain_id + '/' + template + '.json';
|
|
163
|
+
fs.writeFileSync(file, JSON.stringify(out_json, null, 4));
|
|
164
|
+
console.log('wrote file', file);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
|
|
148
168
|
function provider_for_chain() {
|
|
149
169
|
if (non_infura_chains[chain]) {
|
|
150
170
|
console.log('Using chain', non_infura_chains[chain]);
|
|
@@ -334,3 +354,43 @@ function deployERC20() {
|
|
|
334
354
|
//result.setToken(result.contractAddress);
|
|
335
355
|
});
|
|
336
356
|
}
|
|
357
|
+
|
|
358
|
+
async function deployFactory() {
|
|
359
|
+
|
|
360
|
+
const config = rc.realityETHConfig(chain_id, token_name, version);
|
|
361
|
+
const lib = config.address;
|
|
362
|
+
|
|
363
|
+
var tmpl = realityETHName();
|
|
364
|
+
|
|
365
|
+
var txt = 'deploying reality.eth factory [library '+lib+']';
|
|
366
|
+
|
|
367
|
+
const provider = provider_for_chain();
|
|
368
|
+
const t = constructContractTemplate('RealityETH_ERC20_Factory');
|
|
369
|
+
const signer = new ethers.Wallet(priv, provider);
|
|
370
|
+
const confac = new ethers.ContractFactory(t.abi, t.bytecode, signer);
|
|
371
|
+
// console.log(signer);
|
|
372
|
+
|
|
373
|
+
txt = txt + ' (from address ' + signer.address + ')';
|
|
374
|
+
console.log(txt);
|
|
375
|
+
|
|
376
|
+
await waitForGas(provider);
|
|
377
|
+
|
|
378
|
+
confac.deploy(lib, defaultConfigs).then(function(result) {
|
|
379
|
+
const txid = result.deployTransaction.hash;
|
|
380
|
+
const address = result.address;
|
|
381
|
+
console.log('storing address', address);
|
|
382
|
+
console.log('deploying at address with tx ', txid);
|
|
383
|
+
result.deployed().then(function(depres) {
|
|
384
|
+
// console.log('depres', depres);
|
|
385
|
+
const settings = {
|
|
386
|
+
"address": address,
|
|
387
|
+
"block": depres.provider._lastBlockNumber,
|
|
388
|
+
"library_address": lib,
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
//console.log('result was', result);
|
|
392
|
+
store_deployed_factory_contract(tmpl, chain_id, settings);
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
});
|
|
396
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const requireGlob = require('require-glob');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
var SEPARATOR_PATTERN = /[\\\/]/;
|
|
6
|
+
|
|
7
|
+
function toCombinedValues(a, b) {
|
|
8
|
+
return a.concat(b);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function toSplitPath(filePath) {
|
|
12
|
+
return filePath.split(SEPARATOR_PATTERN);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function keygen(options, fileObj) {
|
|
16
|
+
var uniquePath = fileObj.path.replace(fileObj.base, '');
|
|
17
|
+
var parsedPath = path.parse(uniquePath);
|
|
18
|
+
|
|
19
|
+
return [parsedPath.dir, parsedPath.name]
|
|
20
|
+
.map(toSplitPath)
|
|
21
|
+
.reduce(toCombinedValues)
|
|
22
|
+
.filter(Boolean);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const all_config = requireGlob.sync('./../chains/factories/*/*.json', {"keygen": keygen});
|
|
26
|
+
fs.writeFileSync(__dirname + '/../generated/factories.json', JSON.stringify(all_config, null, 4));
|
package/tokens/ETH.json
CHANGED