Update kredits-contracts and ethers.js
This uses the new ethers.js 4.x API which is required by the new kredits-contracts. Also Operator is now Proposal in the new kredits-contracts wrapper
This commit is contained in:
+8
-15
@@ -39,11 +39,7 @@ export default Service.extend({
|
|||||||
let networkId;
|
let networkId;
|
||||||
if (typeof window.web3 !== 'undefined') {
|
if (typeof window.web3 !== 'undefined') {
|
||||||
console.debug('[kredits] Using user-provided instance, e.g. from Mist browser or Metamask');
|
console.debug('[kredits] Using user-provided instance, e.g. from Mist browser or Metamask');
|
||||||
networkId = parseInt(window.web3.version.network);
|
ethProvider = new ethers.providers.Web3Provider(window.web3.currentProvider);
|
||||||
ethProvider = new ethers.providers.Web3Provider(
|
|
||||||
window.web3.currentProvider,
|
|
||||||
{ chainId: networkId }
|
|
||||||
);
|
|
||||||
ethProvider.listAccounts().then((accounts) => {
|
ethProvider.listAccounts().then((accounts) => {
|
||||||
this.set('currentUserAccounts', accounts);
|
this.set('currentUserAccounts', accounts);
|
||||||
const ethSigner = accounts.length === 0 ? null : ethProvider.getSigner();
|
const ethSigner = accounts.length === 0 ? null : ethProvider.getSigner();
|
||||||
@@ -56,10 +52,7 @@ export default Service.extend({
|
|||||||
console.debug('[kredits] Creating new instance from npm module class');
|
console.debug('[kredits] Creating new instance from npm module class');
|
||||||
networkId = parseInt(config.contractMetadata.networkId);
|
networkId = parseInt(config.contractMetadata.networkId);
|
||||||
console.debug(`[kredits] networkId=${networkId} providerURL: ${config.web3ProviderUrl}`);
|
console.debug(`[kredits] networkId=${networkId} providerURL: ${config.web3ProviderUrl}`);
|
||||||
ethProvider = new ethers.providers.JsonRpcProvider(
|
ethProvider = new ethers.providers.JsonRpcProvider(config.web3ProviderUrl);
|
||||||
config.web3ProviderUrl,
|
|
||||||
{ chainId: networkId }
|
|
||||||
);
|
|
||||||
resolve({
|
resolve({
|
||||||
ethProvider: ethProvider,
|
ethProvider: ethProvider,
|
||||||
ethSigner: null
|
ethSigner: null
|
||||||
@@ -121,7 +114,7 @@ export default Service.extend({
|
|||||||
addProposal(attributes) {
|
addProposal(attributes) {
|
||||||
console.debug('[kredits] add proposal', attributes);
|
console.debug('[kredits] add proposal', attributes);
|
||||||
|
|
||||||
return this.kredits.Operator.addProposal(attributes)
|
return this.kredits.Proposal.addProposal(attributes)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
console.debug('[kredits] add proposal response', data);
|
console.debug('[kredits] add proposal response', data);
|
||||||
attributes.contributor = this.contributors.findBy('id', attributes.contributorId);
|
attributes.contributor = this.contributors.findBy('id', attributes.contributorId);
|
||||||
@@ -130,7 +123,7 @@ export default Service.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getProposals() {
|
getProposals() {
|
||||||
return this.kredits.Operator.all()
|
return this.kredits.Proposal.all()
|
||||||
.then((proposals) => {
|
.then((proposals) => {
|
||||||
return proposals.map((proposal) => {
|
return proposals.map((proposal) => {
|
||||||
proposal.contributor = this.contributors.findBy('id', proposal.contributorId.toString());
|
proposal.contributor = this.contributors.findBy('id', proposal.contributorId.toString());
|
||||||
@@ -142,7 +135,7 @@ export default Service.extend({
|
|||||||
vote(proposalId) {
|
vote(proposalId) {
|
||||||
console.debug('[kredits] vote for', proposalId);
|
console.debug('[kredits] vote for', proposalId);
|
||||||
|
|
||||||
return this.kredits.Operator.functions.vote(proposalId)
|
return this.kredits.Proposal.functions.vote(proposalId)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
console.debug('[kredits] vote response', data);
|
console.debug('[kredits] vote response', data);
|
||||||
return data;
|
return data;
|
||||||
@@ -172,8 +165,8 @@ export default Service.extend({
|
|||||||
|
|
||||||
// Contract events
|
// Contract events
|
||||||
addContractEventHandlers() {
|
addContractEventHandlers() {
|
||||||
// Operator events
|
// Proposal events
|
||||||
this.kredits.Operator
|
this.kredits.Proposal
|
||||||
.on('ProposalCreated', this.handleProposalCreated.bind(this))
|
.on('ProposalCreated', this.handleProposalCreated.bind(this))
|
||||||
.on('ProposalVoted', this.handleProposalVoted.bind(this))
|
.on('ProposalVoted', this.handleProposalVoted.bind(this))
|
||||||
.on('ProposalExecuted', this.handleProposalExecuted.bind(this));
|
.on('ProposalExecuted', this.handleProposalExecuted.bind(this));
|
||||||
@@ -191,7 +184,7 @@ export default Service.extend({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.kredits.Operator.getById(proposalId)
|
this.kredits.Proposal.getById(proposalId)
|
||||||
.then((proposal) => {
|
.then((proposal) => {
|
||||||
proposal.contributor = this.contributors.findBy('id', proposal.contributorId.toString());
|
proposal.contributor = this.contributors.findBy('id', proposal.contributorId.toString());
|
||||||
this.proposals.pushObject(Proposal.create(proposal));
|
this.proposals.pushObject(Proposal.create(proposal));
|
||||||
|
|||||||
@@ -52,7 +52,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.contractMetadata['networkId'] = '42';
|
|
||||||
ENV.web3ProviderUrl = 'https://kovan.infura.io/keUVk6OMaAvpmRF3m57n';
|
ENV.web3ProviderUrl = 'https://kovan.infura.io/keUVk6OMaAvpmRF3m57n';
|
||||||
|
|
||||||
ENV.ipfs = {
|
ENV.ipfs = {
|
||||||
@@ -78,9 +77,6 @@ module.exports = function(environment) {
|
|||||||
// here you can enable a production-specific feature
|
// here you can enable a production-specific feature
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.env.NETWORK_ID) {
|
|
||||||
ENV.contractMetadata['networkId'] = process.env.NETWORK_ID;
|
|
||||||
}
|
|
||||||
if (process.env.WEB3_PROVIDER_URL) {
|
if (process.env.WEB3_PROVIDER_URL) {
|
||||||
ENV.web3ProviderUrl = process.env.WEB3_PROVIDER_URL;
|
ENV.web3ProviderUrl = process.env.WEB3_PROVIDER_URL;
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+5922
-5886
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -15,7 +15,7 @@
|
|||||||
"lint:js": "eslint .",
|
"lint:js": "eslint .",
|
||||||
"start": "ember serve",
|
"start": "ember serve",
|
||||||
"test": "ember test",
|
"test": "ember test",
|
||||||
"start:local": "NETWORK_ID=100 WEB3_PROVIDER_URL=http://localhost:7545 ember s",
|
"start:local": "WEB3_PROVIDER_URL=http://localhost:7545 ember s",
|
||||||
"build": "ember build",
|
"build": "ember build",
|
||||||
"build-prod": "ember build --environment production",
|
"build-prod": "ember build --environment production",
|
||||||
"update-version-file": "bash scripts/update-version-file.sh",
|
"update-version-file": "bash scripts/update-version-file.sh",
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
"ember-source": "~3.8.0",
|
"ember-source": "~3.8.0",
|
||||||
"ember-truth-helpers": "github:jmurphyau/ember-truth-helpers#31a14373a31f1f82c77537720549b47a95c28e5f",
|
"ember-truth-helpers": "github:jmurphyau/ember-truth-helpers#31a14373a31f1f82c77537720549b47a95c28e5f",
|
||||||
"eslint-plugin-ember": "^5.2.0",
|
"eslint-plugin-ember": "^5.2.0",
|
||||||
"ethers": "3.0.15",
|
"ethers": "^4.0.27",
|
||||||
"kosmos-schemas": "^1.1.2",
|
"kosmos-schemas": "^1.1.2",
|
||||||
"kredits-contracts": "^3.x",
|
"kredits-contracts": "^3.x",
|
||||||
"loader.js": "^4.7.0",
|
"loader.js": "^4.7.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user