enable staking
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 37s Details

This commit is contained in:
Ladd Hoffman 2024-04-30 17:53:57 -05:00
parent 4e9ebfa7c3
commit 62741ead01
3 changed files with 23 additions and 7 deletions

View File

@ -1,16 +1,13 @@
const ethers = require('ethers');
const { getClient } = require('../matrix-bot');
const { matrixUserToAuthorAddress } = require('../util/db');
const write = require('../util/forum/write');
const { dao, getProvider } = require('../util/contracts');
const { dao } = require('../util/contracts');
const {
ETH_NETWORK,
ETH_PRIVATE_KEY,
} = process.env;
const wallet = new ethers.Wallet(ETH_PRIVATE_KEY, getProvider());
const wallet = require('../util/wallet');
const addPostWithRetry = async (authors, hash, citations, retryDelay = 5000) => {
try {

View File

@ -3,6 +3,7 @@ const Promise = require('bluebird');
const { dao } = require('../util/contracts');
const read = require('../util/forum/read');
const gateByProposal = require('../util/gate-by-proposal');
const wallet = require('../util/wallet');
const {
ENABLE_STAKING,
@ -49,8 +50,15 @@ const start = async () => {
if (!enableStaking) {
return;
}
console.log(`WOULD STAKE ${inFavor ? 'in favor of' : 'against'} pool ${poolIndex}`);
// TODO: Stake half of available reputation
// Stake all available reputation
console.log(`STAKING ${inFavor ? 'in favor of' : 'against'} pool ${poolIndex}`);
const currentRep = await dao.balanceOf(wallet.getAddress());
try {
await dao.stakeOnValidationPool(poolIndex, currentRep, inFavor);
} catch (e) {
// Maybe the end time passed?
console.error(`STAKING ${inFavor ? 'in favor of' : 'against'} pool ${poolIndex} failed, reason: ${e.reason}`);
}
});
};

View File

@ -0,0 +1,11 @@
const ethers = require('ethers');
const { getProvider } = require('./contracts');
const {
ETH_PRIVATE_KEY,
} = process.env;
const wallet = new ethers.Wallet(ETH_PRIVATE_KEY, getProvider());
module.exports = wallet;