WIP auto staking legislative process

This commit is contained in:
Ladd Hoffman 2024-04-09 05:09:27 -05:00
parent c6546b56f1
commit 7b720c7325
1 changed files with 38 additions and 1 deletions

View File

@ -1,8 +1,10 @@
const { ethers } = require('hardhat');
const { execSync } = require('child_process');
const { getContractAddressByNetworkName } = require('./contract-config');
const readFromApi = require('./util/read-from-api');
const network = process.env.HARDHAT_NETWORK;
let currentVersionProposalId;
let dao;
let work1;
@ -11,6 +13,22 @@ let account;
let validationPools;
let reputation;
let posts;
let proposalsContract;
let proposals;
const getCurrentVersion = () => {
const currentCommit = execSync('git rev-parse HEAD');
return currentCommit.toString();
};
const fetchCurrentVersionProposal = async () => {
const p = await proposalsContract.
};
const getLatestVersion = () => {
const latestVersion = 'TBD';
return latestVersion;
};
const fetchReputation = async () => {
reputation = await dao.balanceOf(account);
@ -57,6 +75,22 @@ const fetchValidationPools = async () => {
await Promise.all(promises);
};
const fetchProposal = async (proposalIndex) => {
const proposal = await proposalsContract.proposals(proposalIndex);
proposals[proposalIndex] = proposal;
};
const fetchProposals = async () => {
const count = await proposalsContract.proposalCount();
console.log(`proposal count: ${count}`);
const promises = [];
proposals = [];
for (let i = 0; i < count; i += 1) {
promises.push(fetchProposal(i));
}
await Promise.all(promises);
};
const initialize = async () => {
const getContract = (name) => ethers.getContractAt(
name,
@ -65,12 +99,14 @@ const initialize = async () => {
dao = await getContract('DAO');
work1 = await getContract('Work1');
onboarding = await getContract('Onboarding');
proposalsContract = await getContract('Proposals');
[account] = await ethers.getSigners();
const address = await account.getAddress();
console.log(`account: ${address}`);
posts = [];
await fetchReputation();
await fetchValidationPools();
await fetchProposals();
};
const poolIsActive = (pool) => {
@ -121,7 +157,6 @@ const conditionalStake = async (pool, amountToStake) => {
// We could consider automatic followup staking,
// as a convenience if you decide early to favor a proposal
} else {
console.log('Unrecognized sender %s', pool.sender);
await stake(pool, amountToStake, false);
}
};
@ -144,6 +179,8 @@ const printPool = (pool) => {
};
async function main() {
console.log('Current version:', getCurrentVersion());
await initialize();
validationPools.forEach(printPool);