Compare commits
No commits in common. "1e67f80808c4a4cfd25f2411fc2a329450c2c141" and "7e134495140f2710e1285d450f8efb66c4832e21" have entirely different histories.
1e67f80808
...
7e13449514
|
@ -11,11 +11,10 @@ import Row from 'react-bootstrap/Row';
|
|||
import Col from 'react-bootstrap/Col';
|
||||
import Stack from 'react-bootstrap/Stack';
|
||||
|
||||
import DAOArtifact from 'contract-config/DAO.json';
|
||||
import work1Artifact from 'contract-config/Work1.json';
|
||||
|
||||
import { getContractByChainId } from './contract-config';
|
||||
import Web3Context from './Web3Context';
|
||||
import DAOArtifact from './assets/DAO.json';
|
||||
import work1Artifact from './assets/Work1.json';
|
||||
import AvailabilityStakes from './AvailabilityStakes';
|
||||
import WorkRequests from './WorkRequests';
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,4 @@
|
|||
import contractAddresses from 'contract-config/addresses.json';
|
||||
import contractAddresses from '../../contract-addresses.json';
|
||||
|
||||
const networks = {
|
||||
localhost: '0x539',
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"localhost": {
|
||||
"DAO": "0xee46C48314Db1cd91DfaDc4f2f2cb12DE3B0Ec54",
|
||||
"Work1": "0x37C7d46CC4Ae5a12402811B763998db4248C7069"
|
||||
"DAO": "0x76Dfe9F47f06112a1b78960bf37d87CfbB6D6133",
|
||||
"Work1": "0xd2845aE812Ee42cF024fB4C55c052365792aBd78"
|
||||
},
|
||||
"sepolia": {
|
||||
"DAO": "0x39B7522Ee1A5B13aE5580C40114239D4cE0e7D29",
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,11 +0,0 @@
|
|||
{
|
||||
"name": "contract-config",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
|
@ -22,7 +22,6 @@ struct Stake {
|
|||
struct ValidationPool {
|
||||
uint id;
|
||||
uint postIndex;
|
||||
address sender;
|
||||
mapping(uint => Stake) stakes;
|
||||
uint stakeCount;
|
||||
uint256 fee;
|
||||
|
@ -83,7 +82,6 @@ contract DAO is ERC20("Reputation", "REP") {
|
|||
require(post.author != address(0), "Target post not found");
|
||||
poolIndex = validationPoolCount++;
|
||||
ValidationPool storage pool = validationPools[poolIndex];
|
||||
pool.sender = msg.sender;
|
||||
pool.postIndex = postIndex;
|
||||
pool.fee = msg.value;
|
||||
pool.duration = duration;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
const { ethers } = require('hardhat');
|
||||
const { getContractByNetworkName } = require('./contract-config');
|
||||
|
||||
const network = process.env.HARDHAT_NETWORK;
|
||||
|
||||
let dao;
|
||||
let account;
|
||||
let validationPools;
|
||||
|
@ -31,6 +29,7 @@ const fetchValidationPools = async () => {
|
|||
};
|
||||
|
||||
const initialize = async () => {
|
||||
const network = process.env.HARDHAT_NETWORK;
|
||||
const DAOAddress = getContractByNetworkName(network, 'DAO');
|
||||
dao = await ethers.getContractAt('DAO', DAOAddress);
|
||||
[account] = await ethers.getSigners();
|
||||
|
@ -46,11 +45,6 @@ const poolIsActive = (pool) => {
|
|||
return true;
|
||||
};
|
||||
|
||||
const poolIsValid = (pool) => {
|
||||
const Work1Address = getContractByNetworkName(network, 'Work1');
|
||||
return pool.sender === Work1Address;
|
||||
};
|
||||
|
||||
const stake = async (pool, amount) => {
|
||||
console.log(`staking ${amount} in favor of pool ${pool.id.toString()}`);
|
||||
await dao.stake(pool.id, amount, true);
|
||||
|
@ -77,11 +71,11 @@ async function main() {
|
|||
console.log(`pool ${pool.id.toString()}, status: ${status}`);
|
||||
});
|
||||
|
||||
// Stake half of available reputation on any active, valid pools
|
||||
const activeValidPools = validationPools.filter(poolIsActive).filter(poolIsValid);
|
||||
if (activeValidPools.length && reputation > 0) {
|
||||
const amountPerPool = reputation / BigInt(2) / BigInt(activeValidPools.length);
|
||||
await stakeEach(activeValidPools, amountPerPool);
|
||||
// Stake half of available reputation on any active validation pools
|
||||
const activePools = validationPools.filter(poolIsActive);
|
||||
if (activePools.length && reputation > 0) {
|
||||
const amountPerPool = reputation / BigInt(2) / BigInt(activePools.length);
|
||||
await stakeEach(activePools, amountPerPool);
|
||||
}
|
||||
|
||||
// Listen for new validation pools
|
||||
|
@ -89,15 +83,10 @@ async function main() {
|
|||
console.log(`pool ${poolIndex} started`);
|
||||
await fetchValidationPool(poolIndex);
|
||||
await fetchReputation();
|
||||
const pool = validationPools[poolIndex];
|
||||
|
||||
if (poolIsValid(pool)) {
|
||||
// Stake half of available reputation on this validation pool
|
||||
const amount = reputation / BigInt(2);
|
||||
await stake(poolIndex, amount, true);
|
||||
} else {
|
||||
console.log(`pool sender ${pool.sender} is not recognized`);
|
||||
}
|
||||
const amount = reputation / BigInt(2);
|
||||
await stake(poolIndex, amount, true);
|
||||
});
|
||||
|
||||
dao.on('ValidationPoolResolved', async (poolIndex, votePasses) => {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const contractAddresses = require('contract-config/addresses.json');
|
||||
const contractAddresses = require('../../contract-addresses.json');
|
||||
|
||||
const networks = {
|
||||
localhost: '0x539',
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
const { ethers } = require('hardhat');
|
||||
const fs = require('fs');
|
||||
|
||||
const contractAddresses = require('contract-config/addresses.json');
|
||||
const contractAddresses = require('../../contract-addresses.json');
|
||||
|
||||
const contractAddressesWritePath = '../contract-addresses.json';
|
||||
|
||||
const contractAddressesWritePath = '../contract-config/addresses.json';
|
||||
const network = process.env.HARDHAT_NETWORK;
|
||||
|
||||
async function main() {
|
||||
|
@ -22,9 +23,6 @@ async function main() {
|
|||
|
||||
fs.writeFileSync(contractAddressesWritePath, JSON.stringify(contractAddresses, null, 2));
|
||||
console.log('Wrote file', fs.realpathSync(contractAddressesWritePath));
|
||||
|
||||
fs.copyFileSync('./artifacts/contracts/DAO.sol/DAO.json', '../contract-config/DAO.json');
|
||||
fs.copyFileSync('./artifacts/contracts/Work1.sol/Work1.json', '../contract-config/Work1.json');
|
||||
}
|
||||
|
||||
// We recommend this pattern to be able to use async/await everywhere
|
||||
|
|
|
@ -85,7 +85,6 @@ describe('DAO', () => {
|
|||
expect(pool.duration).to.equal(POOL_DURATION);
|
||||
expect(pool.postIndex).to.equal(0);
|
||||
expect(pool.resolved).to.be.false;
|
||||
expect(pool.sender).to.equal(account1);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -233,9 +233,6 @@ describe('Work1', () => {
|
|||
const post = await dao.posts(1);
|
||||
expect(post.author).to.equal(account1);
|
||||
expect(post.sender).to.equal(work1.target);
|
||||
const pool = await dao.validationPools(1);
|
||||
expect(pool.fee).to.equal(WORK1_PRICE);
|
||||
expect(pool.sender).to.equal(work1.target);
|
||||
});
|
||||
|
||||
it('should be able to submit work disapproval', async () => {
|
||||
|
|
Loading…
Reference in New Issue