emit event when post added
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 28s Details

This commit is contained in:
Ladd Hoffman 2024-03-12 18:02:07 -05:00
parent 5b8d6f4fcf
commit 5e981b11aa
5 changed files with 29 additions and 10 deletions

View File

@ -8,12 +8,12 @@ import DAOArtifact from './assets/DAO.json';
const contracts = {
'0x539': { // Hardhat
DAO: '0x8d914D38dD301FC4606f5aa9fEcF8A76389020d3',
Work1: '0x050C420Cc4995B41217Eba1B54B82Fd5687e9139',
DAO: '0x63472674239ffb70618Fae043610917f2d9B781C',
Work1: '0xC62b0b16B3ef06c417BFC4Fb02E0Da06aF5A95Ef',
},
'0xaa36a7': { // Sepolia
DAO: '0x57BDFFf79108E5198dec6268A6BFFD8B62ECfA38',
Work1: '0x6c18eb38b7450F8DaE5A5928A40fcA3952493Ee4',
DAO: '0x8F00038542C87A5eAf18d5938B7723bF2A04A4e4',
Work1: '0x42b79f8d8408c36aD4347ab72f826684440a7a8F',
},
};
@ -87,9 +87,13 @@ function App() {
// setWork1(work1Contract);
setDAO(DAOContract);
DAOContract.events.PostAdded({ fromBlock: 'latest' }).on('data', (event) => {
console.log('event: post added', event);
fetchPosts();
});
DAOContract.events.ValidationPoolInitiated({ fromBlock: 'latest' }).on('data', (event) => {
console.log('event: validation pool initiated', event);
fetchPosts();
fetchValidationPools();
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -57,6 +57,7 @@ contract DAO is ERC20("Reputation", "REP") {
// TODO: Make parameters adjustable
// TODO: Add forum parameters
event PostAdded(uint postIndex);
event ValidationPoolInitiated(uint poolIndex);
event ValidationPoolResolved(uint poolIndex, bool votePasses);
@ -66,6 +67,7 @@ contract DAO is ERC20("Reputation", "REP") {
post.author = author;
post.sender = msg.sender;
post.id = postIndex;
emit PostAdded(postIndex);
}
/// Accept fee to initiate a validation pool

View File

@ -22,7 +22,7 @@ describe('DAO', () => {
describe('Post', () => {
it('should be able to add a post', async () => {
const { dao, account1 } = await loadFixture(deploy);
await dao.addPost(account1);
await expect(dao.addPost(account1)).to.emit(dao, 'PostAdded').withArgs(0);
const post = await dao.posts(0);
expect(post.author).to.equal(account1);
expect(post.sender).to.equal(account1);