@@ -6,7 +6,7 @@ import Service from '@ember/service';
|
|||||||
import EmberObject from '@ember/object';
|
import EmberObject from '@ember/object';
|
||||||
import { computed } from '@ember/object';
|
import { computed } from '@ember/object';
|
||||||
import { alias, notEmpty } from '@ember/object/computed';
|
import { alias, notEmpty } from '@ember/object/computed';
|
||||||
import { isEmpty } from '@ember/utils';
|
import { isEmpty, isPresent } from '@ember/utils';
|
||||||
|
|
||||||
import groupBy from 'kredits-web/utils/group-by';
|
import groupBy from 'kredits-web/utils/group-by';
|
||||||
import formatKredits from 'kredits-web/utils/format-kredits';
|
import formatKredits from 'kredits-web/utils/format-kredits';
|
||||||
@@ -99,10 +99,16 @@ export default Service.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function instantiateWithAccount (web3Provider, context) {
|
async function instantiateWithAccount (web3Provider, context) {
|
||||||
// TODO check if network is rinkeby
|
|
||||||
console.debug('[kredits] Using user-provided instance, e.g. from Mist browser or Metamask');
|
console.debug('[kredits] Using user-provided instance, e.g. from Mist browser or Metamask');
|
||||||
ethProvider = new ethers.providers.Web3Provider(web3Provider);
|
ethProvider = new ethers.providers.Web3Provider(web3Provider);
|
||||||
// const network = await ethProvider.getNetwork();
|
|
||||||
|
const network = await ethProvider.getNetwork();
|
||||||
|
if (isPresent(config.web3RequiredNetwork) &&
|
||||||
|
network.name !== config.web3RequiredNetwork) {
|
||||||
|
window.alert(`Please switch your Ethereum wallet to the "${config.web3RequiredNetwork}" network before connecting your account.`);
|
||||||
|
return instantiateWithoutAccount();
|
||||||
|
}
|
||||||
|
|
||||||
ethProvider.listAccounts().then(accounts => {
|
ethProvider.listAccounts().then(accounts => {
|
||||||
context.set('currentUserAccounts', accounts);
|
context.set('currentUserAccounts', accounts);
|
||||||
const ethSigner = accounts.length === 0 ? null : ethProvider.getSigner();
|
const ethSigner = accounts.length === 0 ? null : ethProvider.getSigner();
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ module.exports = function(environment) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
web3ProviderUrl: 'https://rinkeby.infura.io/v3/d4f788b7a6584f7db2fc3c268d4d09e9',
|
web3ProviderUrl: 'https://rinkeby.infura.io/v3/d4f788b7a6584f7db2fc3c268d4d09e9',
|
||||||
|
web3RequiredNetwork: 'rinkeby',
|
||||||
|
|
||||||
githubConnectUrl: 'https://hal8000.chat.kosmos.org/kredits/signup/connect/github',
|
githubConnectUrl: 'https://hal8000.chat.kosmos.org/kredits/signup/connect/github',
|
||||||
githubSignupUrl: 'https://hal8000.chat.kosmos.org/kredits/signup/github',
|
githubSignupUrl: 'https://hal8000.chat.kosmos.org/kredits/signup/github',
|
||||||
@@ -81,6 +82,7 @@ module.exports = function(environment) {
|
|||||||
|
|
||||||
if (process.env.WEB3_PROVIDER_URL) {
|
if (process.env.WEB3_PROVIDER_URL) {
|
||||||
ENV.web3ProviderUrl = process.env.WEB3_PROVIDER_URL;
|
ENV.web3ProviderUrl = process.env.WEB3_PROVIDER_URL;
|
||||||
|
ENV.web3RequiredNetwork = null;
|
||||||
}
|
}
|
||||||
if (process.env.KREDITS_DAO_ADDRESS) {
|
if (process.env.KREDITS_DAO_ADDRESS) {
|
||||||
ENV.kreditsKernelAddress = process.env.KREDITS_DAO_ADDRESS;
|
ENV.kreditsKernelAddress = process.env.KREDITS_DAO_ADDRESS;
|
||||||
|
|||||||
Reference in New Issue
Block a user