cleanup
This commit is contained in:
@@ -101,9 +101,7 @@ export default Ember.Controller.extend({
|
|||||||
_handleProposalVoted(proposalId, voter, totalVotes) {
|
_handleProposalVoted(proposalId, voter, totalVotes) {
|
||||||
this.get('model.proposals')
|
this.get('model.proposals')
|
||||||
.findBy('id', proposalId.toNumber())
|
.findBy('id', proposalId.toNumber())
|
||||||
.setProperties({
|
.setProperties({ 'votesCount': totalVotes });
|
||||||
'votesCount', totalVotes
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_handleTransfer(data) {
|
_handleTransfer(data) {
|
||||||
|
|||||||
@@ -39,14 +39,14 @@ export default Service.extend({
|
|||||||
let web3Provider;
|
let web3Provider;
|
||||||
if (typeof window.web3 !== 'undefined') {
|
if (typeof window.web3 !== 'undefined') {
|
||||||
debug('[kredits] Using user-provided instance, e.g. from Mist browser or Metamask');
|
debug('[kredits] Using user-provided instance, e.g. from Mist browser or Metamask');
|
||||||
let networkId = parseInt(web3.version.network);
|
let networkId = parseInt(window.web3.version.network);
|
||||||
web3Provider = new ethers.providers.Web3Provider(web3.currentProvider, {chainId: networkId});
|
web3Provider = new ethers.providers.Web3Provider(window.web3.currentProvider, {chainId: networkId});
|
||||||
this.set('web3Provided', true);
|
this.set('web3Provided', true);
|
||||||
} else {
|
} else {
|
||||||
debug('[kredits] Creating new instance from npm module class');
|
debug('[kredits] Creating new instance from npm module class');
|
||||||
let providerUrl = localStorage.getItem('config:web3ProviderUrl') || config.web3ProviderUrl;
|
let providerUrl = localStorage.getItem('config:web3ProviderUrl') || config.web3ProviderUrl;
|
||||||
let networkId = web3.version.network;
|
let networkId = config.contractMetadata.networkId;
|
||||||
web3Provider = new ethers.providers.JsonRpcProvider(providerUrl, {chainId: network});
|
web3Provider = new ethers.providers.JsonRpcProvider(providerUrl, {chainId: networkId});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.set('web3Provider', web3Provider);
|
this.set('web3Provider', web3Provider);
|
||||||
@@ -60,7 +60,7 @@ export default Service.extend({
|
|||||||
currentUserAccounts: function() {
|
currentUserAccounts: function() {
|
||||||
// TODO: listAccounts returns now a promise
|
// TODO: listAccounts returns now a promise
|
||||||
return [];
|
return [];
|
||||||
return ethers.listAccounts();
|
//return ethers.listAccounts();
|
||||||
// return (this.get('web3Provided') && this.get('web3').eth.accounts) || [];
|
// return (this.get('web3Provided') && this.get('web3').eth.accounts) || [];
|
||||||
}.property('web3Provided', 'web3'),
|
}.property('web3Provided', 'web3'),
|
||||||
|
|
||||||
@@ -100,8 +100,8 @@ export default Service.extend({
|
|||||||
let isCurrentUser = this.get('currentUserAccounts').includes(address);
|
let isCurrentUser = this.get('currentUserAccounts').includes(address);
|
||||||
let profileHash = this.getMultihashFromBytes32({
|
let profileHash = this.getMultihashFromBytes32({
|
||||||
digest,
|
digest,
|
||||||
hashFunction: hashFunction.toNumber(),
|
hashFunction: hashFunction,
|
||||||
size: size.toNumber()
|
size: size
|
||||||
});
|
});
|
||||||
return this.get('tokenContract')
|
return this.get('tokenContract')
|
||||||
.then((contract) => contract.balanceOf(address))
|
.then((contract) => contract.balanceOf(address))
|
||||||
@@ -143,7 +143,7 @@ export default Service.extend({
|
|||||||
return this.get('kreditsContract')
|
return this.get('kreditsContract')
|
||||||
.then((contract) => contract.proposals(i))
|
.then((contract) => contract.proposals(i))
|
||||||
.then(p => {
|
.then(p => {
|
||||||
let ipfsHash = this.getMultihashFromBytes32({ digest: p.ipfsHash, hashFunction: p.hashFunction, size: p.hashSize });
|
let contributionIpfsHash = this.getMultihashFromBytes32({ digest: p.ipfsHash, hashFunction: p.hashFunction, size: p.hashSize });
|
||||||
|
|
||||||
let proposal = Proposal.create({
|
let proposal = Proposal.create({
|
||||||
id : i,
|
id : i,
|
||||||
|
|||||||
Reference in New Issue
Block a user