merge master

This commit is contained in:
2020-12-01 10:39:01 +01:00
27 changed files with 757 additions and 125 deletions

View File

@@ -1,4 +1,3 @@
{
"4": "0x76e069b47b79442657eaf0555a32c6b16fa1b8b4",
"69041181": "0x6Ad8CDF71C3E2AaD2712964097b475184a0dfDeF"
"4": "0x76e069b47b79442657eaf0555a32c6b16fa1b8b4"
}

View File

@@ -1,4 +1,3 @@
{
"4": "0xc34edf7d11b7f8433d597f0bb0697acdff55ef14",
"69041181": "0x356685A0d9d66d6e5dA80f50EC206Af8009C8b6F"
"4": "0xc34edf7d11b7f8433d597f0bb0697acdff55ef14"
}

View File

@@ -5,7 +5,7 @@ class Acl extends Base {
hasPermission (fromAddress, contractAddress, roleID, params = null) {
let roleHash = EthersUtils.keccak256(EthersUtils.toUtf8Bytes(roleID));
return this.functions.hasPermission(
return this.hasPermission(
fromAddress,
contractAddress,
roleHash,

View File

@@ -1,10 +1,13 @@
const deprecate = require('../utils/deprecate');
class Base {
constructor (contract) {
this.contract = contract;
}
get functions () {
return this.contract.functions;
deprecate('The property `functions` is deprecated. contract functions are now directly defined on the ethers contract object. https://github.com/ethers-io/ethers.js/issues/920#issuecomment-650836642');
return this.contract;
}
get address () {

View File

@@ -4,33 +4,33 @@ const deprecate = require('../utils/deprecate');
class Contribution extends Record {
get count () {
return this.functions.contributionsCount();
return this.contract.contributionsCount();
}
getById (id) {
return this.functions.getContribution(id)
return this.contract.getContribution(id)
.then(data => {
return this.ipfs.catAndMerge(data, ContributionSerializer.deserialize);
});
}
getData (id) {
return this.functions.getContribution(id);
return this.contract.getContribution(id);
}
getByContributorId (contributorId) {
return this.functions.getContributorAddressById(contributorId)
return this.contract.getContributorAddressById(contributorId)
.then(address => this.getByContributorAddress(address));
}
getByContributorAddress (address) {
return this.functions.balanceOf(address)
return this.contract.balanceOf(address)
.then(async (balance) => {
const count = balance.toNumber();
const contributions = [];
for (let index = 0; index < count; index++) {
const id = await this.functions.tokenOfOwnerByIndex(address, index);
const id = await this.contract.tokenOfOwnerByIndex(address, index);
const contribution = await this.getById(id);
contributions.push(contribution);
}
@@ -58,7 +58,7 @@ class Contribution extends Record {
ipfsHashAttr.hashSize,
];
return this.functions.add(...contribution, callOptions);
return this.contract.add(...contribution, callOptions);
});
}

View File

@@ -4,19 +4,20 @@ const formatKredits = require('../utils/format-kredits');
class Contributor extends Record {
get count () {
return this.functions.contributorsCount();
return this.contract.contributorsCount();
}
getById (id) {
return this.functions.getContributorById(id)
.then(data => {
return this.contract.getContributorById(id)
.then(contractData => {
let data = {...contractData};
data.balanceInt = formatKredits(data.balance);
return this.ipfs.catAndMerge(data, ContributorSerializer.deserialize);
});
}
getData (id) {
return this.functions.getContributorById(id);
return this.contract.getContributorById(id);
}
filterByAccount (search) {
@@ -61,7 +62,7 @@ class Contributor extends Record {
ipfsHashAttr.hashSize,
];
return this.functions.addContributor(...contributor, callOptions);
return this.contract.addContributor(...contributor, callOptions);
});
}
@@ -78,7 +79,7 @@ class Contributor extends Record {
return this.ipfs
.add(jsonStr)
.then(ipfsHashAttr => {
return this.functions.updateContributorProfileHash(
return this.contract.updateContributorProfileHash(
contributorId,
ipfsHashAttr.hashDigest,
ipfsHashAttr.hashFunction,

View File

@@ -11,9 +11,9 @@ class Kernel extends Base {
getApp (appName) {
if (appName === 'Acl') {
return this.functions.acl();
return this.contract.acl();
}
return this.functions.getApp(KERNEL_APP_ADDR_NAMESPACE, this.appNamehash(appName));
return this.contract.getApp(KERNEL_APP_ADDR_NAMESPACE, this.appNamehash(appName));
}
appNamehash (appName) {

View File

@@ -4,11 +4,11 @@ const deprecate = require('../utils/deprecate');
class Proposal extends Record {
get count () {
return this.functions.proposalsCount();
return this.contract.proposalsCount();
}
getById (id) {
return this.functions.getProposal(id)
return this.contract.getProposal(id)
.then(data => {
return this.ipfs.catAndMerge(data, ContributionSerializer.deserialize);
});
@@ -33,7 +33,7 @@ class Proposal extends Record {
ipfsHashAttr.hashSize,
];
return this.functions.addProposal(...proposal, callOptions);
return this.contract.addProposal(...proposal, callOptions);
});
}

View File

@@ -30,11 +30,11 @@ class KreditsKit {
appIdFor (contractName) {
// see appIds in KreditsKit.sol for more details
const knownContracts = ['Contribution', 'Contributor', 'Proposal', 'Reimbursement', 'Token'];
return this.contract.functions.appIds(knownContracts.indexOf(contractName));
return this.contract.appIds(knownContracts.indexOf(contractName));
}
newDAO (options = {}) {
return this.contract.functions.newInstance(options).then(transaction => {
return this.contract.newInstance(options).then(transaction => {
return transaction.wait().then(result => {
const deployEvent = result.events.find(e => e.event === 'DeployInstance');
return {

View File

@@ -11,7 +11,8 @@ class IPFS {
this._ipfsAPI = ipfsClient(config);
}
catAndMerge (data, deserialize) {
catAndMerge (contractData, deserialize) {
let data = {...contractData}; // data from ethers.js is not extensible. this copy the attributes in a new object
// if no hash details are found simply return the data; nothing to merge
if (!data.hashSize || data.hashSize === 0) {
return data;