Prepare for kredits-contracts update
Also updates ethers.js to v4.x
This commit is contained in:
parent
bfaf26cc9a
commit
b38e6faf8a
15
index.js
15
index.js
@ -27,7 +27,7 @@ module.exports = async function(robot) {
|
||||
|
||||
let wallet;
|
||||
try {
|
||||
wallet = await ethers.Wallet.fromEncryptedWallet(walletJson, process.env.KREDITS_WALLET_PASSWORD);
|
||||
wallet = await ethers.Wallet.fromEncryptedJson(walletJson, process.env.KREDITS_WALLET_PASSWORD);
|
||||
} catch(error) {
|
||||
robot.logger.warn('[hubot-kredits] Could not load wallet:', error);
|
||||
process.exit(1);
|
||||
@ -37,7 +37,7 @@ module.exports = async function(robot) {
|
||||
// Ethereum provider/node setup
|
||||
//
|
||||
|
||||
const ethProvider = new ethers.providers.JsonRpcProvider(providerUrl, {chainId: networkId});
|
||||
const ethProvider = new ethers.providers.JsonRpcProvider(providerUrl);
|
||||
ethProvider.signer = wallet;
|
||||
wallet.provider = ethProvider;
|
||||
|
||||
@ -47,13 +47,14 @@ module.exports = async function(robot) {
|
||||
|
||||
let kredits;
|
||||
try {
|
||||
kredits = await Kredits.setup(ethProvider, wallet, ipfsConfig);
|
||||
kredits = await new Kredits(ethProvider, wallet, ipfsConfig).init();
|
||||
} catch(error) {
|
||||
robot.logger.warn('[hubot-kredits] Could not set up kredits:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
const Contributor = kredits.Contributor;
|
||||
const Operator = kredits.Operator;
|
||||
const Proposal = kredits.Proposal;
|
||||
const Contribution = kredits.Contribution;
|
||||
|
||||
robot.logger.info('[hubot-kredits] Wallet address: ' + wallet.address);
|
||||
|
||||
@ -87,7 +88,7 @@ module.exports = async function(robot) {
|
||||
});
|
||||
|
||||
robot.respond(/list open proposals/i, res => {
|
||||
Operator.all().then((proposals) => {
|
||||
Proposal.all().then((proposals) => {
|
||||
proposals.forEach((proposal) => {
|
||||
if (!proposal.executed) {
|
||||
Contributor.getById(proposal.contributorId).then((contributor) => {
|
||||
@ -111,13 +112,13 @@ module.exports = async function(robot) {
|
||||
robot.logger.debug(`[hubot-kredits] Watching events from block ${nextBlock} onward`);
|
||||
ethProvider.resetEventsBlock(nextBlock);
|
||||
|
||||
Operator.on('ProposalCreated', handleProposalCreated);
|
||||
Proposal.on('ProposalCreated', handleProposalCreated);
|
||||
});
|
||||
}
|
||||
|
||||
function handleProposalCreated(proposalId, creatorAccount, contributorId, amount) {
|
||||
Contributor.getById(contributorId).then((contributor) => {
|
||||
Operator.getById(proposalId).then((proposal) => {
|
||||
Proposal.getById(proposalId).then((proposal) => {
|
||||
robot.logger.debug(`[hubot-kredits] Proposal created (${proposal.description})`);
|
||||
// messageRoom(`Let's give ${contributor.name} some kredits for ${proposal.url} (${proposal.description}): https://kredits.kosmos.org`);
|
||||
});
|
||||
|
@ -16,7 +16,8 @@ module.exports = async function(robot, kredits) {
|
||||
}
|
||||
|
||||
const Contributor = kredits.Contributor;
|
||||
const Operator = kredits.Operator;
|
||||
const Proposal = kredits.Proposal;
|
||||
const Contribution = kredits.Contribution;
|
||||
|
||||
function getContributorByGithubUser(username) {
|
||||
return Contributor.all().then(contributors => {
|
||||
@ -45,7 +46,7 @@ module.exports = async function(robot, kredits) {
|
||||
kind: 'dev'
|
||||
};
|
||||
|
||||
return Operator.addProposal(contributionAttr).catch(error => {
|
||||
return Proposal.addProposal(contributionAttr).catch(error => {
|
||||
robot.logger.error(`[hubot-kredits] Error:`, error);
|
||||
messageRoom(`I wanted to propose giving kredits to GitHub user ${githubUser} for ${url}, but I cannot find their info. Please add them as a contributor: https://kredits.kosmos.org`);
|
||||
});
|
||||
|
@ -13,7 +13,8 @@ module.exports = async function(robot, kredits) {
|
||||
robot.logger.debug('[hubot-kredits] Loading MediaWiki integration...')
|
||||
|
||||
const Contributor = kredits.Contributor;
|
||||
const Operator = kredits.Operator;
|
||||
const Proposal = kredits.Proposal;
|
||||
const Contribution = kredits.Contribution;
|
||||
|
||||
const wikiURL = process.env.KREDITS_MEDIAWIKI_URL;
|
||||
const apiURL = wikiURL + 'api.php';
|
||||
|
802
package-lock.json
generated
802
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -10,7 +10,7 @@
|
||||
"create-wallet": "scripts/create-wallet.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"ethers": "^3.0.15",
|
||||
"ethers": "^4.0.27",
|
||||
"group-array": "^0.3.3",
|
||||
"kosmos-schemas": "^1.1.2",
|
||||
"node-cron": "^1.2.1",
|
||||
|
Loading…
x
Reference in New Issue
Block a user