@reality.eth/contracts 3.0.12 → 3.0.15

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,6 +1,6 @@
1
1
  {
2
2
  "address": "0x6F80C5cBCF9FbC2dA2F0675E56A5900BB70Df72f",
3
- "block": 7313547,
3
+ "block": 7313546,
4
4
  "notes": null,
5
5
  "arbitrators": {}
6
6
  }
@@ -0,0 +1,6 @@
1
+ {
2
+ "address": "0x92115220C28e78312cCe86f3d1dE652CFBD0357A",
3
+ "block": 27425354,
4
+ "notes": null,
5
+ "arbitrators": {}
6
+ }
@@ -72,6 +72,12 @@
72
72
  "explorerURL": "https://zksync2-testnet.zkscan.io",
73
73
  "network_name": "zkSync2-testnet"
74
74
  },
75
+ "80001": {
76
+ "hostedRPC": "https://rpc.ankr.com/polygon_mumbai",
77
+ "graphURL": "https://api.thegraph.com/subgraphs/name/realityeth/realityeth-mumbai",
78
+ "explorerURL": "https://mumbai.polygonscan.com",
79
+ "network_name": "mumbai"
80
+ },
75
81
  "43114": {
76
82
  "explorerURL": "https://cchain.explorer.avax.network/",
77
83
  "graphURL": "https://api.thegraph.com/subgraphs/name/realityeth/realityeth-ava",
@@ -317,6 +317,26 @@
317
317
  "https://cchain.explorer.avax.network/"
318
318
  ]
319
319
  },
320
+ "80001": {
321
+ "chainId": "0x13881",
322
+ "chainName": "Mumbai",
323
+ "nativeCurrency": {
324
+ "name": "MATIC",
325
+ "symbol": "MATIC",
326
+ "decimals": 18
327
+ },
328
+ "network_name": "mumbai",
329
+ "rpcUrls": [
330
+ "https://matic-mumbai.chainstacklabs.com",
331
+ "https://rpc-mumbai.maticvigil.com",
332
+ "https://matic-testnet-archive-rpc.bwarelabs.com"
333
+ ],
334
+ "hostedRPC": "https://rpc.ankr.com/polygon_mumbai",
335
+ "graphURL": "https://api.thegraph.com/subgraphs/name/realityeth/realityeth-mumbai",
336
+ "blockExplorerUrls": [
337
+ "https://mumbai.polygonscan.com"
338
+ ]
339
+ },
320
340
  "421611": {
321
341
  "chainId": "0x66eeb",
322
342
  "chainName": "Arbitrum Rinkeby",
@@ -122,16 +122,6 @@
122
122
  }
123
123
  }
124
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
- },
135
125
  "TRST": {
136
126
  "Arbitrator": {
137
127
  "address": "0xa682C58333F4959cbF728c2a871548E3D8978Fa2",
@@ -153,7 +143,7 @@
153
143
  "ETH": {
154
144
  "RealityETH-3.0": {
155
145
  "address": "0x6F80C5cBCF9FbC2dA2F0675E56A5900BB70Df72f",
156
- "block": 7313547,
146
+ "block": 7313546,
157
147
  "notes": null,
158
148
  "arbitrators": {}
159
149
  }
@@ -424,6 +414,16 @@
424
414
  }
425
415
  }
426
416
  },
417
+ "80001": {
418
+ "MATIC": {
419
+ "RealityETH-3.0": {
420
+ "address": "0x92115220C28e78312cCe86f3d1dE652CFBD0357A",
421
+ "block": 27425354,
422
+ "notes": null,
423
+ "arbitrators": {}
424
+ }
425
+ }
426
+ },
427
427
  "421611": {
428
428
  "ARETH": {
429
429
  "Arbitrator": {
@@ -44,7 +44,8 @@
44
44
  "decimals": 18,
45
45
  "small_number": 1000000000000000000,
46
46
  "native_chains": {
47
- "137": true
47
+ "137": true,
48
+ "80001": true
48
49
  }
49
50
  },
50
51
  "OETH": {
@@ -99,13 +100,6 @@
99
100
  "100": "0x9C58BAcC331c9aa871AFD802DB6379a98e80CEdb"
100
101
  }
101
102
  },
102
- "LINK": {
103
- "decimals": 18,
104
- "small_number": 1000000000000000000,
105
- "erc20_chains": {
106
- "4": "0x01be23585060835e02b77ef475b0cc51aa1e0709"
107
- }
108
- },
109
103
  "POLK": {
110
104
  "decimals": 18,
111
105
  "small_number": 1000000000000000000,
package/index.js CHANGED
@@ -1,7 +1,26 @@
1
- const all_config = require('./generated/contracts.json');
2
- const token_info = require('./generated/tokens.json');
1
+ let all_config = require('./generated/contracts.json');
2
+ let token_info = require('./generated/tokens.json');
3
3
  const chain_info = require('./generated/chains.json');
4
4
  const template_config = require('./config/templates.json');
5
+ const factory_config = require('./generated/factories.json');
6
+
7
+ function populateImports(imported_contracts, chain_id) {
8
+ for(var ctr in imported_contracts) {
9
+ let to_imp = imported_contracts[ctr];
10
+ to_imp.realityETH= ctr;
11
+ const imp = tokenAndContractConfigFromFactory(to_imp, chain_id);
12
+ const token = imp.token.ticker;
13
+ if (!all_config[chain_id][token]) {
14
+ all_config[chain_id][token] = {};
15
+ }
16
+ const ver = imp.contract.version_number;
17
+ all_config[chain_id][token][ver] = imp.contract;
18
+
19
+ if (!token_info[token]) {
20
+ token_info[token] = imp.token;
21
+ }
22
+ }
23
+ }
5
24
 
6
25
  function realityETHInstance(config) {
7
26
  const abis = {
@@ -35,7 +54,7 @@ function arbitratorInstance(chain_id) {
35
54
  function erc20Instance(config) {
36
55
  const abi = require('./abi/solc-0.4.25/ERC20.abi.json');
37
56
  if (!config.token_address) {
38
- console.log('config', config);
57
+ // console.log('config', config);
39
58
  throw new Error("token address for erc20 instance not found");
40
59
  return null;
41
60
  }
@@ -165,7 +184,7 @@ function isChainSupported(chain_id) {
165
184
  function walletAddParameters(chain_id) {
166
185
  var params = ['chainId', 'chainName', 'nativeCurrency', 'rpcUrls', 'blockExplorerUrls']
167
186
  var ret = {};
168
- console.log('looking for config for chain', chain_id);
187
+ // console.log('looking for config for chain', chain_id);
169
188
  var config = chain_info[""+chain_id];
170
189
  for (var i=0; i<params.length; i++) {
171
190
  var item = params[i];
@@ -209,6 +228,93 @@ function versionHasFeature(vernum, feature_name) {
209
228
  }
210
229
  }
211
230
 
231
+ function factoryConfigForAddress(address, chain_id) {
232
+
233
+ for(var cid in factory_config) {
234
+ if (chain_id && cid != chain_id) {
235
+ continue;
236
+ }
237
+ for(var ver in factory_config[cid]) {
238
+ const config = factory_config[cid][ver];
239
+ if (address.toLowerCase() == config.address.toLowerCase()) {
240
+ return config;
241
+ }
242
+ }
243
+ }
244
+ return null;
245
+
246
+ }
247
+
248
+ function configForAddress(addr, chain_id) {
249
+ for(var cid in all_config) {
250
+ if (chain_id && cid != chain_id) {
251
+ continue;
252
+ }
253
+ for(var ticker in all_config[cid]) {
254
+ for(var ver in all_config[cid][ticker]) {
255
+ const config = all_config[cid][ticker][ver];
256
+ if (addr.toLowerCase() == config.address.toLowerCase()) {
257
+ if (!config.arbitrators) {
258
+ config.arbitrators = [];
259
+ }
260
+ const [contract_name, contract_version] = ver.split('-');
261
+ config.version_number = ver;
262
+ config.chain_id = cid;
263
+ config.contract_name = contract_name;
264
+ config.contract_version = contract_version;
265
+ return config;
266
+ }
267
+ }
268
+ }
269
+ }
270
+ return null;
271
+
272
+ }
273
+
274
+ function factoryList(chain_id) {
275
+ if (!factory_config[chain_id]) {
276
+ return {};
277
+ }
278
+ return factory_config[chain_id];
279
+ }
280
+
281
+ function tokenAndContractConfigFromFactory(factory_data, chain_id) {
282
+ // Get the library for the factory
283
+ const factory_config = factoryConfigForAddress(factory_data.factory, chain_id);
284
+
285
+ const template_orig = configForAddress(factory_config.library_address, chain_id);
286
+ let template = {};
287
+ for (let k in template_orig) {
288
+ template[k] = template_orig[k];
289
+ }
290
+
291
+ if (!template) {
292
+ console.log('no template found for', factory_data, factory_config, chain_id);
293
+ return null;
294
+ }
295
+
296
+ template.address = factory_data.realityETH;
297
+ template.block = parseInt(factory_data.createdBlock);
298
+ template.token_address = factory_data.token_address;
299
+ template.token_ticker = factory_data.token_symbol;
300
+
301
+ const erc20_chains_val = {};
302
+ erc20_chains_val[chain_id] = factory_data.token_address;
303
+
304
+ return {
305
+ 'token': {
306
+ 'ticker': factory_data.token_symbol,
307
+ 'decimals': factory_data.token_decimals,
308
+ 'is_native': false,
309
+ 'small_number': 1000000000000000000,
310
+ 'erc20_chains': erc20_chains_val
311
+ },
312
+ 'contract': template
313
+ }
314
+
315
+ }
316
+
317
+
212
318
  module.exports.realityETHConfig = realityETHConfig;
213
319
  module.exports.realityETHConfigs = realityETHConfigs;
214
320
  module.exports.realityETHInstance = realityETHInstance;
@@ -222,3 +328,7 @@ module.exports.templateConfig = templateConfig;
222
328
  module.exports.defaultTokenForChain = defaultTokenForChain;
223
329
  module.exports.versionHasFeature = versionHasFeature;
224
330
  module.exports.isChainSupported = isChainSupported;
331
+ module.exports.factoryList = factoryList;
332
+ module.exports.tokenAndContractConfigFromFactory = tokenAndContractConfigFromFactory;
333
+ module.exports.configForAddress = configForAddress;
334
+ module.exports.populateImports = populateImports;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reality.eth/contracts",
3
- "version": "3.0.12",
3
+ "version": "3.0.15",
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",
@@ -30,7 +30,7 @@
30
30
  "url": "https://github.com/RealityETH/monorepo/issues"
31
31
  },
32
32
  "homepage": "https://reality.eth.link",
33
- "gitHead": "f9933bfbc17dd8a796e0c3200acc4bd098e9aaaf",
33
+ "gitHead": "4601364942fcc90d5f93f10f53e3934c7e772d46",
34
34
  "dependencies": {
35
35
  "ethers": "^5.6.8"
36
36
  }
package/scripts/deploy.js CHANGED
@@ -11,13 +11,14 @@ const deployed_at = null;
11
11
  var undef;
12
12
 
13
13
  const defaultConfigs = {
14
- // maxFeePerGas: 61000000000,
15
- // maxPriorityFeePerGas: 1000000000,
14
+ //maxFeePerGas: 610000000000,
15
+ //maxPriorityFeePerGas: 10000000000,
16
16
  //gasPrice: 70000000000
17
+ // gasPrice: 10000000000,
17
18
  // gasPrice: 10000, // optimism 1000000,
18
19
  /// gasPrice: 5000000000,
19
20
  // gasLimit: 6000000, // optimism 4500000
20
- // gasLimit: 4500000,
21
+ gasLimit: 4500000,
21
22
  //etherscanApiKey: 'TPA4BFDDIH8Q7YBQ4JMGN6WDDRRPAV6G34'
22
23
  // gasLimit: 155734867 // arbitrum
23
24
  }
@@ -43,6 +44,7 @@ const chains = {
43
44
  'cheapeth': 777,
44
45
  'xdai': 100,
45
46
  'polygon': 137,
47
+ 'mumbai': 80001,
46
48
  'ava': 43114,
47
49
  'arbitrum': 42161,
48
50
  'arbitrum-rinkeby': 421611,
@@ -62,6 +64,7 @@ const non_infura_chains = {
62
64
  'kovan-optimistic': 'https://kovan.optimism.io',
63
65
  'optimism': 'https://mainnet.optimism.io',
64
66
  'kintsugi': 'https://rpc.kintsugi.themerge.dev',
67
+ 'mumbai': 'https://matic-mumbai.chainstacklabs.com',
65
68
  }
66
69
 
67
70
  function constructContractTemplate(contract_name) {
package/tokens/MATIC.json CHANGED
@@ -2,6 +2,7 @@
2
2
  "decimals": 18,
3
3
  "small_number": 1000000000000000000,
4
4
  "native_chains": {
5
- "137": true
5
+ "137": true,
6
+ "80001": true
6
7
  }
7
8
  }
@@ -1,8 +0,0 @@
1
- {
2
- "address": "0x4a38a9EdE2f997E97Cac2D7BF8e002Ec20d2c2Ca",
3
- "block": 11107294,
4
- "token_address": "0x01be23585060835e02b77ef475b0cc51aa1e0709",
5
- "notes": null,
6
- "arbitrators": {},
7
- "factory_address": "0x9e862794f4f80386185b9d3baa532668e988c530"
8
- }
package/tokens/LINK.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "decimals": 18,
3
- "small_number": 1000000000000000000,
4
- "erc20_chains": {
5
- "4": "0x01be23585060835e02b77ef475b0cc51aa1e0709"
6
- }
7
- }