Use latest node.js LTS on Travis CI #99
+38
-16
@@ -33,20 +33,10 @@ export default Service.extend({
|
||||
// this is called in the routes beforeModel(). So it is initialized before everything else
|
||||
// and we can rely on the ethProvider and the potential currentUserAccounts to be available
|
||||
getEthProvider: function() {
|
||||
return new RSVP.Promise((resolve) => {
|
||||
let ethProvider;
|
||||
if (typeof window.web3 !== 'undefined') {
|
||||
console.debug('[kredits] Using user-provided instance, e.g. from Mist browser or Metamask');
|
||||
ethProvider = new ethers.providers.Web3Provider(window.web3.currentProvider);
|
||||
ethProvider.listAccounts().then((accounts) => {
|
||||
this.set('currentUserAccounts', accounts);
|
||||
const ethSigner = accounts.length === 0 ? null : ethProvider.getSigner();
|
||||
resolve({
|
||||
ethProvider,
|
||||
ethSigner
|
||||
});
|
||||
});
|
||||
} else {
|
||||
let ethProvider;
|
||||
|
||||
return new RSVP.Promise(async (resolve) => {
|
||||
function instantiateWithoutAccount () {
|
||||
console.debug('[kredits] Creating new instance from npm module class');
|
||||
console.debug(`[kredits] providerURL: ${config.web3ProviderUrl}`);
|
||||
ethProvider = new ethers.providers.JsonRpcProvider(config.web3ProviderUrl);
|
||||
@@ -55,6 +45,39 @@ export default Service.extend({
|
||||
ethSigner: null
|
||||
});
|
||||
}
|
||||
|
||||
function instantiateWithAccount (web3, context) {
|
||||
console.debug('[kredits] Using user-provided instance, e.g. from Mist browser or Metamask');
|
||||
ethProvider = new ethers.providers.Web3Provider(web3.currentProvider);
|
||||
ethProvider.listAccounts().then(accounts => {
|
||||
context.set('currentUserAccounts', accounts);
|
||||
const ethSigner = accounts.length === 0 ? null : ethProvider.getSigner();
|
||||
resolve({
|
||||
ethProvider,
|
||||
ethSigner
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (window.ethereum) {
|
||||
window.web3 = new window.Web3(window.ethereum);
|
||||
try {
|
||||
// Request account access if needed
|
||||
await window.ethereum.enable();
|
||||
// Acccounts now exposed
|
||||
instantiateWithAccount(window.web3, this);
|
||||
} catch (error) {
|
||||
instantiateWithoutAccount();
|
||||
}
|
||||
}
|
||||
// Legacy dapp browsers...
|
||||
else if (window.web3) {
|
||||
instantiateWithAccount(window.web3, this);
|
||||
}
|
||||
// Non-dapp browsers...
|
||||
else {
|
||||
instantiateWithoutAccount();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@@ -148,7 +171,6 @@ export default Service.extend({
|
||||
return this.kredits.Contributor
|
||||
.functions.getContributorIdByAddress(this.get('currentUserAccounts.firstObject'))
|
||||
.then((id) => {
|
||||
id = id.toNumber();
|
||||
// check if the user is a contributor or not
|
||||
if (id === 0) {
|
||||
return RSVP.resolve();
|
||||
@@ -211,7 +233,7 @@ export default Service.extend({
|
||||
|
||||
this.contributors
|
||||
.findBy('id', contributorId.toString())
|
||||
.incrementProperty('balance', amount.toNumber());
|
||||
.incrementProperty('balance', amount);
|
||||
},
|
||||
|
||||
handleTransfer(from, to, value) {
|
||||
|
||||
@@ -35,7 +35,7 @@ module.exports = function(environment) {
|
||||
]
|
||||
},
|
||||
|
||||
web3ProviderUrl: 'https://kovan.infura.io/keUVk6OMaAvpmRF3m57n',
|
||||
web3ProviderUrl: 'https://rinkeby.infura.io/v3/d4f788b7a6584f7db2fc3c268d4d09e9',
|
||||
|
||||
ipfs: {
|
||||
host: 'ipfs.kosmos.org',
|
||||
@@ -50,7 +50,7 @@ module.exports = function(environment) {
|
||||
// ENV.APP.LOG_TRANSITIONS = true;
|
||||
// ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
|
||||
// ENV.APP.LOG_VIEW_LOOKUPS = true;
|
||||
ENV.web3ProviderUrl = 'https://kovan.infura.io/keUVk6OMaAvpmRF3m57n';
|
||||
ENV.web3ProviderUrl = 'https://rinkeby.infura.io/v3/d4f788b7a6584f7db2fc3c268d4d09e9';
|
||||
|
||||
ENV.ipfs = {
|
||||
host: 'localhost',
|
||||
|
||||
Reference in New Issue
Block a user