diff --git a/README.md b/README.md index 58a4d1e..690f553 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,8 @@ You will need the following things properly installed on your computer. ## Running / Development -* `ember serve` + +* `ember serve` - by default kredits-web connects to the Ethreum Kovan network * Visit your app at [http://localhost:4200](http://localhost:4200). * Visit your tests at [http://localhost:4200/tests](http://localhost:4200/tests). @@ -89,8 +90,8 @@ Get your local Ethereum development node running. With IPFS and Ethereum/ganache running, you can now start this Ember app. - * `npm link kredits-contracts` - link the local `kredits-contracts` package (it will become `kredits-contracts` soon) - * `npm start` + * `npm link kredits-contracts` - link the local `kredits-contracts` package + * `npm run start:local` - NETWORK_ID=100 and WEB3_PROVIDER_URL=http://localhost:7545 must be set for local settings #### IPFS diff --git a/app/services/kredits.js b/app/services/kredits.js index ca1e74a..15ed22a 100644 --- a/app/services/kredits.js +++ b/app/services/kredits.js @@ -38,34 +38,38 @@ export default Service.extend({ ); ethProvider.listAccounts().then((accounts) => { this.set('currentUserAccounts', accounts); - resolve(ethProvider); + const ethSigner = accounts.length === 0 ? null : ethProvider.getSigner(); + resolve({ + ethProvider, + ethSigner + }); }); } else { console.debug('[kredits] Creating new instance from npm module class'); networkId = parseInt(config.contractMetadata.networkId); + console.debug(`[kredits] networkId=${networkId} providerURL: ${config.web3ProviderUrl}`); ethProvider = new ethers.providers.JsonRpcProvider( config.web3ProviderUrl, { chainId: networkId } ); - resolve(ethProvider); + resolve({ + ethProvider: ethProvider, + ethSigner: null + }); } }); }, setup() { - return this.getEthProvider().then((ethProvider) => { - let ethSigner; + return this.getEthProvider().then((providerAndSigner) => { - if (ethProvider.getSigner) { - ethSigner = ethProvider.getSigner(); - } - - let kredits = new Kredits(ethProvider, ethSigner); + let kredits = new Kredits(providerAndSigner.ethProvider, providerAndSigner.ethSigner, { + ipfsConfig: config.ipfs + }); return kredits .init() .then((kredits) => { this.set('kredits', kredits); - if (this.currentUserAccounts && this.currentUserAccounts.length > 0) { this.getCurrentUser.then((contributorData) => { this.set('currentUser', contributorData); diff --git a/config/environment.js b/config/environment.js index 1ecf71b..dd5d644 100644 --- a/config/environment.js +++ b/config/environment.js @@ -37,7 +37,7 @@ module.exports = function(environment) { contractMetadata: { networkId: '42' }, - web3ProviderUrl: 'https://parity.kosmos.org:8545', + web3ProviderUrl: 'https://kovan.infura.io/keUVk6OMaAvpmRF3m57n', ipfs: { host: 'ipfs.kosmos.org', @@ -52,8 +52,8 @@ module.exports = function(environment) { // ENV.APP.LOG_TRANSITIONS = true; // ENV.APP.LOG_TRANSITIONS_INTERNAL = true; // ENV.APP.LOG_VIEW_LOOKUPS = true; - ENV.contractMetadata['networkId'] = '100'; - ENV.web3ProviderUrl = 'http://localhost:7545'; + ENV.contractMetadata['networkId'] = '42'; + ENV.web3ProviderUrl = 'https://kovan.infura.io/keUVk6OMaAvpmRF3m57n'; ENV.ipfs = { host: 'localhost', diff --git a/package-lock.json b/package-lock.json index 86cf939..d90c201 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13484,7 +13484,9 @@ } }, "kredits-contracts": { - "version": "github:67P/kredits-contracts#8a7abba4861b8a3a73449693a8bd226bdecae553", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/kredits-contracts/-/kredits-contracts-3.0.1.tgz", + "integrity": "sha512-QF8j0Wu3/XTzlas4u2bmLgsCchouQH+sxM1ewnA4X16FmlbguMJfVPPnIrlX2ptmVUOXMOU+9zKy9SQquJjjqg==", "dev": true, "requires": { "ethers": "3.0.15", diff --git a/package.json b/package.json index aded6d8..1eef56d 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "scripts": { "lint:js": "eslint ./*.js app config lib server tests", "start": "ember serve", - "kovan": "NETWORK_ID=42 ember serve", + "start:local": "NETWORK_ID=100 WEB3_PROVIDER_URL=http://localhost:7545 ember s", "test": "ember test", "build": "ember build", "build-prod": "ember build --environment production", @@ -51,7 +51,7 @@ "eslint-plugin-ember": "^5.0.0", "ethers": "3.0.15", "kosmos-schemas": "^1.1.2", - "kredits-contracts": "github:67P/kredits-contracts", + "kredits-contracts": "^3.x", "loader.js": "^4.2.3", "tv4": "^1.3.0" },