Adjust API for new ethers v5 API
see issue for details: https://github.com/ethers-io/ethers.js/issues/920#issuecomment-650836642
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"4": "0x76e069b47b79442657eaf0555a32c6b16fa1b8b4",
|
||||
"18335577": "0xeE10a87d8D758B563E301F5C5d029bDD21166DCC"
|
||||
"18335577": "0xeE10a87d8D758B563E301F5C5d029bDD21166DCC",
|
||||
"63732251": "0x644F88812006C631a08f786E484A21e652Bb69cc"
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"4": "0xc34edf7d11b7f8433d597f0bb0697acdff55ef14",
|
||||
"18335577": "0x29E33B66108fa2DC3a018f3DdE41D295eB0922D5"
|
||||
"18335577": "0x29E33B66108fa2DC3a018f3DdE41D295eB0922D5",
|
||||
"63732251": "0xd604112A1b9E3D83414694C778b49e664e59c19e"
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@ 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)
|
||||
return this.contract.getContributorById(id)
|
||||
.then(contractData => {
|
||||
let data = {...contractData};
|
||||
data.balanceInt = formatKredits(data.balance);
|
||||
@@ -17,7 +17,7 @@ class Contributor extends Record {
|
||||
}
|
||||
|
||||
getData (id) {
|
||||
return this.functions.getContributorById(id);
|
||||
return this.contract.getContributorById(id);
|
||||
}
|
||||
|
||||
filterByAccount (search) {
|
||||
@@ -62,7 +62,7 @@ class Contributor extends Record {
|
||||
ipfsHashAttr.hashSize,
|
||||
];
|
||||
|
||||
return this.functions.addContributor(...contributor, callOptions);
|
||||
return this.contract.addContributor(...contributor, callOptions);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -79,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,
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ class Kredits {
|
||||
this.addresses['Kernel'] = this.addresses['Kernel'] || DaoAddresses[network.chainId.toString()];
|
||||
let addressPromises = contractsToLoad.map((contractName) => {
|
||||
return this.Kernel.getApp(contractName).then((address) => {
|
||||
this.addresses[contractName] = address[0]; // we get an array from the getApp response
|
||||
this.addresses[contractName] = address;
|
||||
}).catch((error) => {
|
||||
throw new Error(`Failed to get address for ${contractName} from DAO at ${this.Kernel.contract.address}
|
||||
- ${error.message}`
|
||||
|
||||
@@ -30,11 +30,11 @@ class KreditsKit {
|
||||
appIdFor (contractName) {
|
||||
// see appIds in KreditsKit.sol for more details
|
||||
const knownContracts = ['Contribution', 'Contributor', 'Proposal', '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 {
|
||||
|
||||
Reference in New Issue
Block a user