Make web3 provider URL configurable; default to infura #9

Merged
bumi merged 2 commits from configurable-provider into master 2017-05-13 15:06:34 +00:00
2 changed files with 15 additions and 15 deletions
+2 -2
View File
@@ -77,7 +77,7 @@ export default Ember.Service.extend({
this.getValueFromContract('kreditsContract', 'contributorAddresses', i).then(address => { this.getValueFromContract('kreditsContract', 'contributorAddresses', i).then(address => {
this.getValueFromContract('kreditsContract', 'contributors', address).then(person => { this.getValueFromContract('kreditsContract', 'contributors', address).then(person => {
this.getValueFromContract('tokenContract', 'balanceOf', address).then(balance => { this.getValueFromContract('tokenContract', 'balanceOf', address).then(balance => {
console.debug('person', person); Ember.Logger.debug('person', person);
let contributor = Contributor.create({ let contributor = Contributor.create({
address: address, address: address,
github_username: person[1], github_username: person[1],
@@ -166,7 +166,7 @@ export default Ember.Service.extend({
return new Ember.RSVP.Promise((resolve, reject) => { return new Ember.RSVP.Promise((resolve, reject) => {
this.get('ipfs').storeFile(contributor.serialize()).then(ipfsHash => { this.get('ipfs').storeFile(contributor.serialize()).then(ipfsHash => {
contributor.set('ipfsHash', ipfsHash); contributor.set('ipfsHash', ipfsHash);
console.debug('ADD', address, name, ipfsHash, isCore, id); Ember.Logger.debug('ADD', address, name, ipfsHash, isCore, id);
this.get('kreditsContract').addContributor(address, name, ipfsHash, isCore, id, (err, data) => { this.get('kreditsContract').addContributor(address, name, ipfsHash, isCore, id, (err, data) => {
if (err) { reject(err); } if (err) { reject(err); }
Ember.Logger.debug('[kredits] add contributor response', data); Ember.Logger.debug('[kredits] add contributor response', data);
+13 -13
View File
@@ -29,15 +29,24 @@ module.exports = function(environment) {
}] }]
] ]
}, },
contractMetadata: {},
web3ProviderUrl: "https://parity.kosmos.org:8545",
ethereumChain: "testnet",
ipfs: { ipfs: {
host: 'localhost', host: 'localhost',
port: '5001', port: '5001',
protocol: 'http' protocol: 'http'
} }
}; };
if (process.env.KREDITS_CONTRACT_ADDR) {
ENV.contractMetadata['Kredits'] = { address: process.env.KREDITS_CONTRACT_ADDR };
}
if (process.env.TOKEN_CONTRACT_ADDR) {
raucao commented 2017-05-12 15:46:19 +00:00 (Migrated from github.com)
Review

We use config files in Ember, so it's clear what is being built. Otherwise you end up with a build that completely hides where its config comes from.

Edit: loldidntread. Anyway, we shouldn't add even more env vars and use normal config options for all of them (as well as the addresses from the contracts module).

We use config files in Ember, so it's clear what is being built. Otherwise you end up with a build that completely hides where its config comes from. Edit: loldidntread. Anyway, we shouldn't add even more env vars and use normal config options for all of them (as well as the addresses from the contracts module).
bumi commented 2017-05-12 15:48:09 +00:00 (Migrated from github.com)
Review

I see. what is the best option to set local dev configuration options? (like for example here the contract addresses?)

I see. what is the best option to set local dev configuration options? (like for example here the contract addresses?)
raucao commented 2017-05-12 15:58:22 +00:00 (Migrated from github.com)
Review

I guess this works for now. Would be nice to use environment-specific configs soon.

I guess this works for now. Would be nice to use environment-specific configs soon.
bumi commented 2017-05-12 16:15:19 +00:00 (Migrated from github.com)
Review

yep. I only see those used for configs that must not be in the repo / only for the current machine.

so defaulting to parity.kosmos.org:8545 and this PR is ok?

yep. I only see those used for configs that must not be in the repo / only for the current machine. so defaulting to parity.kosmos.org:8545 and this PR is ok?
raucao commented 2017-05-12 16:35:44 +00:00 (Migrated from github.com)
Review

Yer.

Yer.
ENV.contractMetadata['Token'] = { address: process.env.TOKEN_CONTRACT_ADDR };
}
if (process.env.WEB3_PROVIDER_URL) {
ENV.web3ProviderUrl = process.env.WEB3_PROVIDER_URL;
} else {
ENV.web3ProviderUrl = 'https://parity.kosmos.org:8545';
}
if (environment === 'development') { if (environment === 'development') {
// ENV.APP.LOG_RESOLVER = true; // ENV.APP.LOG_RESOLVER = true;
@@ -45,14 +54,6 @@ module.exports = function(environment) {
// ENV.APP.LOG_TRANSITIONS = true; // ENV.APP.LOG_TRANSITIONS = true;
// ENV.APP.LOG_TRANSITIONS_INTERNAL = true; // ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
// ENV.APP.LOG_VIEW_LOOKUPS = true; // ENV.APP.LOG_VIEW_LOOKUPS = true;
ENV.ethereumChain = 'dev';
ENV.contractMetadata = {};
if (process.env.KREDITS_CONTRACT_ADDR) {
ENV.contractMetadata['Kredits'] = { address: process.env.KREDITS_CONTRACT_ADDR };
}
if (process.env.TOKEN_CONTRACT_ADDR) {
ENV.contractMetadata['Token'] = { address: process.env.TOKEN_CONTRACT_ADDR };
}
} }
if (environment === 'test') { if (environment === 'test') {
@@ -67,8 +68,7 @@ module.exports = function(environment) {
} }
if (environment === 'production') { if (environment === 'production') {
ENV.ethereumChain = 'testnet'; // production conifig
ENV.web3ProviderUrl = 'https://ropsten.infura.io';
} }
return ENV; return ENV;