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