Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ece573ab3c |
+10
-6
@@ -3,6 +3,7 @@ import Web3 from 'npm:web3';
|
||||
import config from 'kredits-web/config/environment';
|
||||
import Contributor from 'kredits-web/models/contributor';
|
||||
import Proposal from 'kredits-web/models/proposal';
|
||||
import kreditsContracts from 'npm:kredits-contracts';
|
||||
|
||||
export default Ember.Service.extend({
|
||||
|
||||
@@ -10,7 +11,7 @@ export default Ember.Service.extend({
|
||||
web3Provided: false, // Web3 provided (using Mist Browser, Metamask et al.)
|
||||
|
||||
web3: function() {
|
||||
if (Ember.isPresent(this.get('web3Instance'))) {
|
||||
if (this.get('web3Instance')) {
|
||||
return this.get('web3Instance');
|
||||
}
|
||||
|
||||
@@ -22,7 +23,7 @@ export default Ember.Service.extend({
|
||||
this.set('web3Provided', true);
|
||||
} else {
|
||||
Ember.Logger.debug('[kredits] Creating new instance from npm module class');
|
||||
let provider = new Web3.providers.HttpProvider("http://139.59.248.169:8545");
|
||||
let provider = new Web3.providers.HttpProvider(config.web3ProviderUrl);
|
||||
web3Instance = new Web3(provider);
|
||||
}
|
||||
|
||||
@@ -33,11 +34,14 @@ export default Ember.Service.extend({
|
||||
}.property('web3Instance'),
|
||||
|
||||
kreditsContract: function() {
|
||||
// TODO cache this
|
||||
let contract = this.get('web3')
|
||||
.eth.contract(config.kreditsContract.ABI)
|
||||
.at(config.kreditsContract.address);
|
||||
if (this.get('kreditsContractInstance')) {
|
||||
return this.get('kreditsContractInstance');
|
||||
}
|
||||
|
||||
let contract = kreditsContracts(this.get('web3'))['Kredits'];
|
||||
|
||||
window.Kredits = contract;
|
||||
this.set('kreditsContractInstance', contract);
|
||||
return contract;
|
||||
}.property('web3'),
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
/* jshint node: true */
|
||||
let contracts = require('../vendor/contract-abis');
|
||||
|
||||
module.exports = function(environment) {
|
||||
var ENV = {
|
||||
modulePrefix: 'kredits-web',
|
||||
@@ -21,15 +19,11 @@ module.exports = function(environment) {
|
||||
APP: {
|
||||
// Here you can pass flags/options to your application instance
|
||||
// when it is created
|
||||
},
|
||||
|
||||
kreditsContract: {
|
||||
ABI: contracts['Kredits'].abi
|
||||
}
|
||||
};
|
||||
|
||||
if (environment === 'development') {
|
||||
ENV.kreditsContract.address = '0x9C68Af50e97f5605402B4C01e7aB836ed7145e8B';
|
||||
ENV.web3ProviderUrl = "http://139.59.248.169:8545";
|
||||
// ENV.APP.LOG_RESOLVER = true;
|
||||
// ENV.APP.LOG_ACTIVE_GENERATION = true;
|
||||
// ENV.APP.LOG_TRANSITIONS = true;
|
||||
|
||||
+2
-1
@@ -36,7 +36,8 @@
|
||||
"ember-load-initializers": "^0.5.1",
|
||||
"ember-resolver": "^2.0.3",
|
||||
"loader.js": "^4.0.10",
|
||||
"web3": "^0.18.2"
|
||||
"web3": "^0.18.2",
|
||||
"kredits-contracts": "67P/kredits-contracts"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.12.0"
|
||||
|
||||
Vendored
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user