diff --git a/scripts/deploy.js b/scripts/deploy.js index 19cf35d..ef12eb1 100644 --- a/scripts/deploy.js +++ b/scripts/deploy.js @@ -4,7 +4,7 @@ const fs = require('fs'); const R = require('ramda'); const chalk = require('chalk'); const { network, arbitratorContract, arbitrableContract, arbitrationFee, arbitratorAddress } = require('../constants'); -const networks = require('../src/utils/networks.js'); +const networks = require('../src/utils/networks.json'); const abiEncodeArgs = (deployed, contractArgs) => { if (!contractArgs || !deployed || !R.hasPath(['interface', 'deploy'], deployed)) return ''; diff --git a/src/contracts/Arbitrator.ts b/src/contracts/Arbitrator.ts index bc3900d..1ead398 100644 --- a/src/contracts/Arbitrator.ts +++ b/src/contracts/Arbitrator.ts @@ -3,7 +3,7 @@ import { Contract } from '@ethersproject/contracts'; import { BigNumber } from '@ethersproject/bignumber'; import { formatEther } from '@ethersproject/units'; import { Logger } from '@ethersproject/logger'; -import networks from '../utils/networks'; +import networks from '../utils/networks.json'; import data from '../abis/AutoAppealableArbitrator.json'; import { JsonRpcProvider } from '@ethersproject/providers'; diff --git a/src/contracts/SafientMain.ts b/src/contracts/SafientMain.ts index af5edc4..d34c6d4 100644 --- a/src/contracts/SafientMain.ts +++ b/src/contracts/SafientMain.ts @@ -14,7 +14,8 @@ import { BigNumber } from '@ethersproject/bignumber'; import { formatEther, parseEther } from '@ethersproject/units'; import { Logger } from '@ethersproject/logger'; import { Bytes } from 'ethers'; -import networks from '../utils/networks'; +import networks from '../utils/networks.json'; +import {getNetworkUrl} from "../utils/networks" import data from '../abis/SafientMain.json'; /** @@ -55,7 +56,8 @@ export class SafientMain { const network = Object.values(networks).find((network) => chainId === network.chainId); - this.provider = new JsonRpcProvider(network?.url) + const networkUrl = getNetworkUrl(chainId) + this.provider = new JsonRpcProvider(networkUrl) network !== undefined && network.addresses.SafientMain !== '' ? (this.safientMainAddress = network.addresses.SafientMain) diff --git a/src/utils/networks.js b/src/utils/networks.js index 3c8b707..7c7743b 100644 --- a/src/utils/networks.js +++ b/src/utils/networks.js @@ -3,54 +3,31 @@ dotenv.config() const networks = { - "localhost": { - "chainId": 31337, - "url": "http://localhost:8545", - "addresses": { - "AutoAppealableArbitrator": "0x5FbDB2315678afecb367f032d93F642f64180aa3", - "SafientMain": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512" - } + localhost: { + chainId: 31337, + url: 'http://localhost:8545', }, - "mainnet": { - "chainId": 1, - "url": `https://mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`, - "addresses": { - "AutoAppealableArbitrator": "", - "SafientMain": "" - } + mainnet: { + chainId: 1, + url: `https://mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`, }, - "rinkeby": { - "chainId": 4, - "url": "", - "addresses": { - "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", - "SafientMain": "0x2fF492C5D9d071a2bed17e30418aF128f22e42fA" - } + kovan: { + chainId: 42, + url: `https://kovan.infura.io/v3/${process.env.INFURA_API_KEY}`, + }, - "kovan": { - "chainId": 42, - "url": `https://kovan.infura.io/v3/${process.env.INFURA_API_KEY}`, - "addresses": { - "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", - "SafientMain": "0xF88915c8762aB973b64086221cDFd20Ec104F732" - } + polygontestnet: { + chainId: 80001, + url: 'https://matic-mumbai.chainstacklabs.com', }, - "ropsten": { - "chainId": 3, - "url": "", - "addresses": { - "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", - "SafientMain": "0xC0B0591Eac7887F443cef0f28BB818E454eD6637" - } + polygon : { + chainId: 137, + url: 'https://matic-mumbai.chainstacklabs.com', + }, - "polygontestnet": { - "chainId": 80001, - "url": `https://matic-mumbai.chainstacklabs.com`, - "addresses": { - "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", - "SafientMain": "0xccA53824ce8944a3cB7b21139bd177DEEe6e27C0" - } - } } -module.exports = networks \ No newline at end of file +export const getNetworkUrl = (chainId) => { + const network = Object.values(networks).find(network => chainId === network.chainId); + return network.url +} \ No newline at end of file diff --git a/src/utils/networks.json b/src/utils/networks.json index 40d766b..8bcb64c 100644 --- a/src/utils/networks.json +++ b/src/utils/networks.json @@ -1,15 +1,13 @@ { "localhost": { "chainId": 31337, - "url": "http://localhost:8545", "addresses": { - "AutoAppealableArbitrator": "0x5FbDB2315678afecb367f032d93F642f64180aa3", - "SafientMain": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512" + "AutoAppealableArbitrator": "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9", + "SafientMain": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9" } }, "mainnet": { "chainId": 1, - "url": "https://mainnet.infura.io/v3/undefined", "addresses": { "AutoAppealableArbitrator": "", "SafientMain": "" @@ -17,7 +15,6 @@ }, "rinkeby": { "chainId": 4, - "url": "", "addresses": { "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", "SafientMain": "0x2fF492C5D9d071a2bed17e30418aF128f22e42fA" @@ -25,7 +22,6 @@ }, "kovan": { "chainId": 42, - "url": "https://kovan.infura.io/v3/undefined", "addresses": { "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", "SafientMain": "0xF88915c8762aB973b64086221cDFd20Ec104F732" @@ -33,7 +29,6 @@ }, "ropsten": { "chainId": 3, - "url": "", "addresses": { "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", "SafientMain": "0xC0B0591Eac7887F443cef0f28BB818E454eD6637" @@ -41,7 +36,6 @@ }, "polygontestnet": { "chainId": 80001, - "url": "https://matic-mumbai.chainstacklabs.com", "addresses": { "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", "SafientMain": "0xccA53824ce8944a3cB7b21139bd177DEEe6e27C0"