@reality.eth/contracts 3.0.7 → 3.0.10

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.
@@ -1,3 +1,6 @@
1
+ /*
2
+ Set the token address, it shouldn't be 0x000000000000000000000000000000000000800A
3
+ */
1
4
 
2
5
  import { utils, Wallet } from "zksync-web3";
3
6
  import * as ethers from "ethers";
@@ -17,7 +20,7 @@ export default async function (hre: HardhatRuntimeEnvironment) {
17
20
 
18
21
  // Create deployer object and load the artifact of the contract we want to deploy.
19
22
  const deployer = new Deployer(hre, wallet);
20
- const artifact = await deployer.loadArtifact("RealityETH_ERC20_v3_0");
23
+ const artifact = await deployer.loadArtifact("RealityETH_v3_0");
21
24
 
22
25
  /*
23
26
  // Deposit some funds to L2 in order to be able to perform L2 transactions.
@@ -38,6 +41,7 @@ export default async function (hre: HardhatRuntimeEnvironment) {
38
41
  const contractAddress = realityContract.address;
39
42
  console.log(`${artifact.contractName} was deployed to ${contractAddress}`);
40
43
 
44
+ /*
41
45
  // Edit the greeting of the contract
42
46
  const token = "0x000000000000000000000000000000000000800A"
43
47
  const setTokenHandle = await realityContract.setToken(token);
@@ -49,5 +53,6 @@ export default async function (hre: HardhatRuntimeEnvironment) {
49
53
  } else {
50
54
  console.error(`Contract said something unexpected: ${tokenFromContract}`);
51
55
  }
56
+ */
52
57
  }
53
58
 
@@ -0,0 +1,56 @@
1
+ /*
2
+ Set the token address, it shouldn't be 0x000000000000000000000000000000000000800A
3
+ */
4
+
5
+ import { utils, Wallet } from "zksync-web3";
6
+ import * as ethers from "ethers";
7
+ import { HardhatRuntimeEnvironment } from "hardhat/types";
8
+ import { Deployer } from "@matterlabs/hardhat-zksync-deploy";
9
+ const fs = require('fs');
10
+
11
+ // An example of a deploy script that will deploy and call a simple contract.
12
+ export default async function (hre: HardhatRuntimeEnvironment) {
13
+ console.log(`Running deploy script for the reality.eth contract`);
14
+
15
+ const key_file = '/home/ed/secrets/zksync_goerli.sec';
16
+ const priv = fs.readFileSync(key_file, 'utf8').replace(/\n$/, "");
17
+
18
+ // Initialize the wallet.
19
+ const wallet = new Wallet(priv);
20
+
21
+ // Create deployer object and load the artifact of the contract we want to deploy.
22
+ const deployer = new Deployer(hre, wallet);
23
+ const artifact = await deployer.loadArtifact("RealityETH_ERC20_v3_0");
24
+
25
+ /*
26
+ // Deposit some funds to L2 in order to be able to perform L2 transactions.
27
+ const depositAmount = ethers.utils.parseEther("0.00001");
28
+ const depositHandle = await deployer.zkWallet.deposit({
29
+ to: deployer.zkWallet.address,
30
+ token: utils.ETH_ADDRESS,
31
+ amount: depositAmount,
32
+ });
33
+ // Wait until the deposit is processed on zkSync
34
+ await depositHandle.wait();
35
+ */
36
+
37
+ // Deploy this contract. The returned object will be of a `Contract` type, similarly to ones in `ethers`.
38
+ const realityContract = await deployer.deploy(artifact, []);
39
+
40
+ // Show the contract info.
41
+ const contractAddress = realityContract.address;
42
+ console.log(`${artifact.contractName} was deployed to ${contractAddress}`);
43
+
44
+ // Edit the greeting of the contract
45
+ const token = "0x000000000000000000000000000000000000800A"
46
+ const setTokenHandle = await realityContract.setToken(token);
47
+ await setTokenHandle.wait();
48
+
49
+ const tokenFromContract = await realityContract.token();
50
+ if (tokenFromContract == token) {
51
+ console.log(`Contract greets us with ${token}!`);
52
+ } else {
53
+ console.error(`Contract said something unexpected: ${tokenFromContract}`);
54
+ }
55
+ }
56
+
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@reality.eth/contracts",
3
- "version": "3.0.7",
3
+ "version": "3.0.10",
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": "90c0439e77228028629bd5433698b2022b3f7eb6",
33
+ "gitHead": "eb91a74ab4008aad90abffe25e0f6d0d1e5e68af",
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://xdai.poanetwork.dev',
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
- abi = JSON.parse(fs.readFileSync(project_base + '/abi/solc-0.8.6/'+contract_name+'.abi.json'));
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
@@ -5,6 +5,7 @@
5
5
  "1": true,
6
6
  "4": true,
7
7
  "42": true,
8
+ "280": true,
8
9
  "1337702": true
9
10
  }
10
11
  }
@@ -0,0 +1,7 @@
1
+ {
2
+ "decimals": 18,
3
+ "small_number": 1000000000000000000,
4
+ "erc20_chains": {
5
+ "4": "0x01be23585060835e02b77ef475b0cc51aa1e0709"
6
+ }
7
+ }
@@ -1,8 +0,0 @@
1
- {
2
- "address": "0x7955DFA097Cd5474b2773dFe85F1988014d85C01",
3
- "block": 444697,
4
- "token_address": "0x000000000000000000000000000000000000800A",
5
- "notes": null,
6
- "arbitrators": {
7
- }
8
- }
package/tokens/WETH.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "decimals": 18,
3
- "small_number": 10000000000000000,
4
- "erc20_chains": {
5
- "280": "0x000000000000000000000000000000000000800a"
6
- }
7
- }