commit
290d91a887
11
src/App.js
11
src/App.js
|
@ -10,6 +10,7 @@ import addressGenerator from './addressGenerator'
|
||||||
import JSzip from 'jszip';
|
import JSzip from 'jszip';
|
||||||
import FileSaver from 'file-saver';
|
import FileSaver from 'file-saver';
|
||||||
import { constants } from './constants';
|
import { constants } from './constants';
|
||||||
|
import networkAddresses from './addresses';
|
||||||
|
|
||||||
function generateElement(msg){
|
function generateElement(msg){
|
||||||
let errorNode = document.createElement("div");
|
let errorNode = document.createElement("div");
|
||||||
|
@ -46,12 +47,16 @@ class App extends Component {
|
||||||
}
|
}
|
||||||
this.keysManager = null;
|
this.keysManager = null;
|
||||||
getWeb3().then(async (web3Config) => {
|
getWeb3().then(async (web3Config) => {
|
||||||
this.setState({web3Config})
|
return networkAddresses(web3Config)
|
||||||
this.keysManager = new KeysManager()
|
}).then(async (config) => {
|
||||||
|
const {web3Config, addresses} = config;
|
||||||
|
this.keysManager = new KeysManager();
|
||||||
await this.keysManager.init({
|
await this.keysManager.init({
|
||||||
web3: web3Config.web3Instance,
|
web3: web3Config.web3Instance,
|
||||||
netId: web3Config.netId
|
netId: web3Config.netId,
|
||||||
|
addresses,
|
||||||
});
|
});
|
||||||
|
this.setState({web3Config})
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
if(error.msg){
|
if(error.msg){
|
||||||
this.setState({isDisabledBtn: true});
|
this.setState({isDisabledBtn: true});
|
||||||
|
|
|
@ -5,40 +5,29 @@ import helpers from "./helpers";
|
||||||
// "KEYS_MANAGER_ADDRESS": "0x3ef32bb244016ad9af8c8f45398511e7e551b581"
|
// "KEYS_MANAGER_ADDRESS": "0x3ef32bb244016ad9af8c8f45398511e7e551b581"
|
||||||
//}
|
//}
|
||||||
|
|
||||||
let SOKOL_ADDRESSES = {};
|
export default (web3Config) => {
|
||||||
let CORE_ADDRESSES = {};
|
let branch;
|
||||||
|
|
||||||
function getContractsAddresses(branch) {
|
switch (web3Config.netId) {
|
||||||
let addr = helpers.addressesURL(branch);
|
|
||||||
fetch(helpers.addressesURL(branch)).then(function(response) {
|
|
||||||
return response.json();
|
|
||||||
}).then(function(contracts) {
|
|
||||||
switch (branch) {
|
|
||||||
case 'core':
|
|
||||||
CORE_ADDRESSES = contracts;
|
|
||||||
break;
|
|
||||||
case 'sokol':
|
|
||||||
SOKOL_ADDRESSES = contracts;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
CORE_ADDRESSES = contracts;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}).catch(function(err) {
|
|
||||||
helpers.wrongRepoAlert(addr);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getContractsAddresses('core');
|
|
||||||
getContractsAddresses('sokol');
|
|
||||||
|
|
||||||
export default (netId) => {
|
|
||||||
switch (netId) {
|
|
||||||
case '77':
|
case '77':
|
||||||
return SOKOL_ADDRESSES
|
branch = 'sokol'
|
||||||
|
break;
|
||||||
case '99':
|
case '99':
|
||||||
return CORE_ADDRESSES
|
branch = 'core'
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return CORE_ADDRESSES
|
branch = 'core'
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
fetch(helpers.addressesURL(branch)).then((response) => {
|
||||||
|
response.json().then((json) => {
|
||||||
|
resolve({addresses: json, web3Config});
|
||||||
|
})
|
||||||
|
}).catch(function(err) {
|
||||||
|
let addr = helpers.addressesURL(branch);
|
||||||
|
helpers.wrongRepoAlert(addr);
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
import Web3 from 'web3';
|
import Web3 from 'web3';
|
||||||
import addressGenerator from './addressGenerator';
|
import addressGenerator from './addressGenerator';
|
||||||
import networkAddresses from './addresses';
|
|
||||||
import helpers from "./helpers";
|
import helpers from "./helpers";
|
||||||
|
|
||||||
export default class KeysManager {
|
export default class KeysManager {
|
||||||
async init({web3, netId}){
|
async init({web3, netId, addresses}){
|
||||||
this.web3_10 = new Web3(web3.currentProvider);
|
this.web3_10 = new Web3(web3.currentProvider);
|
||||||
const {KEYS_MANAGER_ADDRESS} = networkAddresses(netId);
|
const {KEYS_MANAGER_ADDRESS} = addresses;
|
||||||
console.log('Keys Manager ', KEYS_MANAGER_ADDRESS);
|
console.log('Keys Manager ', KEYS_MANAGER_ADDRESS);
|
||||||
const branch = helpers.getBranch(netId);
|
const branch = helpers.getBranch(netId);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue