45 Commits

Author SHA1 Message Date
Follow the white rabbit
2ad8e11513
Merge pull request #38 from status-im/fix/set-featured-communities
fix: reset featured community index when necessary
2023-05-22 17:14:03 +02:00
Patryk Osmaczko
c2a6d204c7 chore: expose votes from FeaturedVotingContract 2023-05-18 12:40:08 +02:00
r4bbit
974ec940d1 fix: ensure cooldownPeriod check is done correctly
The `FeaturedVotingContract` comes with a check in `initializeVoting()`
that aims to ensure that the community that the voting is being
initialized for, has not been featured previously for #n votings.

This is denoted as the `cooldownPeriod`. If `cooldownPeriod = 1`, this
means there needs to be at least one voting which doesn't include the
community in question, that came *after* the voting that did.

The internal `_isInCooldownPeriod()` check has a bug which will return
false positives for any communiy that has been featured before,
regardless of `cooldownPeriod`s value.

When iterating previous votings, the contract actually needs to start
with the last one and iterate downwards, however it does the opposite so
it will never reach the correct votings to check.

This commit fixes the check and adds two tests to cover the case
accordingly.
2023-05-18 11:21:08 +02:00
r4bbit
b232346f7e
fix: reset featured community index when necessary
The `setFeaturedCommunities()` function in `Directory` contract
overrides the entire list of previously featured communities by design.

However, it does not reset the `featuredCommunitiesIdx` map which
results in the `isCommunityFeatured()` function to return false
positives.

This commit resets the map accordingly and adds assertions to the
existing tests for overriding featured communities.

Things to note:

- The bug being fixed is rather low-severity, but I think we should
  still ensure correctness of all contract functions
- The change will increase gas costs of `setFeaturedCommunities()`, but
  again, I think this fix should still land for correctness-sake

Here are some GAS profiles for `setFeaturedCommunities`

```
| contracts/Directory.sol:Directory contract              |                 |       |        |         |         |
|---------------------------------------------------------|-----------------|-------|--------|---------|---------|
| Deployment Cost                                         | Deployment Size |       |        |         |         |
| 753957                                                  | 3797            |       |        |         |         |
| Function Name                                           | min             | avg   | median | max     | # calls |
|---------------------------------------------------------|-----------------|-------|--------|---------|---------|
|                                                         |                 |       |        |         |         |
| COMMUNITY COUNT: 1                                      |                 |       |        |         |         |
| setFeaturedCommunities (INIT, IDX RESET: NO)            | 71162           | 71162 | 71162  | 71162   | 1       |
| setFeaturedCommunities (INIT, IDX RESET: YES)           | 71294           | 71294 | 71294  | 71294   | 1       |
| setFeaturedCommunities (OVERRIDE, IDX RESET: NO)        | 52476           | 61819 | 61819  | 71162   | 2       |
| setFeaturedCommunities (OVERRIDE, IDX RESET: YES)       | 53348           | 62321 | 62321  | 71294   | 2       |
|                                                         |                 |       |        |         |         |
| COMMUNITY COUNT: 3                                      |                 |       |        |         |         |
| setFeaturedCommunities (INIT, IDX RESET: NO)            | 163640          | 163640 | 163640 | 163640 | 1       |
| setFeaturedCommunities (INIT, IDX RESET: YES)           | 163772          | 163772 | 163772 | 163772 | 1       |
| setFeaturedCommunities (OVERRIDE, IDX RESET: NO)        | 106352          | 134996 | 134996 | 163640 | 2       |
| setFeaturedCommunities (OVERRIDE, IDX RESET: YES)       | 126354          | 145063 | 145063 | 163772 | 2       |
|                                                         |                 |        |        |        |         |
| COMMUNITY COUNT: 5                                      |                 |        |        |        |         |
| setFeaturedCommunities (INIT, IDX RESET: NO)            | 256118          | 256118 | 256118 | 256118 | 1       |
| setFeaturedCommunities (INIT, IDX RESET: YES)           | 256250          | 256250 | 256250 | 256250 | 1       |
| setFeaturedCommunities (OVERRIDE, IDX RESET: NO)        | 195427          | 225772 | 225772 | 256118 | 2       |
| setFeaturedCommunities (OVERRIDE, IDX RESET: YES)       | 199360          | 227805 | 227805 | 256250 | 2       |
```
2023-05-16 09:41:38 +02:00
Patryk Osmaczko
a47ff64a11 chore: tweak deployment parameters before first release
closes: #28
2023-05-05 19:45:39 +02:00
Patryk Osmaczko
58ad1d36ef feat: add FeaturedVotingContract
closes: #17
2023-05-04 10:20:57 +02:00
Patryk Osmaczko
9b79b03166 feat: extend Directory contract with featured communities
closes: #18
2023-05-04 10:20:57 +02:00
Pavel
e0fb725ce5
Upgrade @usedapp/core, fix Waku initialization & fix environment config (#22)
* update clean scripts

* add dev scripts to packages/contracts

* upgrade to latest @usedapp/core

* make config explicit

* move contracts to constants

* fix config imports

* fix and simplify waku initialization

* use correct dapp config

* fix errors
2023-05-02 14:53:34 +02:00
Patryk Osmaczko
a4164dbe11 feat(VotingContract): add verification period
closes: #5
2023-03-23 20:44:56 +01:00
Patryk Osmaczko
135084aaf4 refactor(VotingContract/tests): use typed room checks 2023-03-23 20:44:56 +01:00
Patryk Osmaczko
f7579494bd feat(VotingContract): make voting length configurable 2023-03-21 22:13:40 +01:00
Patryk Osmaczko
a7d7736f34 verify balances at finalization
closes: #6
2023-03-21 22:13:40 +01:00
Patryk Osmaczko
03cd1915c8 refactor(VotingContract): rename public APIs 2023-03-21 22:13:40 +01:00
Patryk Osmaczko
f090cce552 refactor(VotingContract): use more precise naming for mappings 2023-03-21 22:13:40 +01:00
Patryk Osmaczko
5cc0f21e07 refactor(VotingContract): improve votingRooms indexing 2023-03-21 22:13:40 +01:00
Patryk Osmaczko
396aa6d8a7 refactor(VotingContract): remove needless storage 2023-03-21 22:13:40 +01:00
Patryk Osmaczko
48a273443e chore: update solidity version 2023-03-21 22:13:40 +01:00
Patryk Osmaczko
adafe3ad7d chore: migrate deploy scripts to hardhat 2023-03-21 22:13:40 +01:00
Patryk Osmaczko
6f23feab16 chore: migrate contracts to hardhat 2023-03-20 10:06:09 +01:00
Felicio Mununga
5b257aeafe
Fix usage of ts-node/esm and mocha (#12)
* revert lockfile

* revert deps

* update webpack

* update mocha

* update ts-node

* add core-js

* update js-waku

* add rimraf

* set ts-node and typescript versions

* update ts-node in contracts

* update ts-node in dapp

* update typescript in contracts

* update typescript in dapp

* extend tsconfig files

* remove ts-node/register from .mocharc

* fix @usedapp/core import

* fix `VotingContract.sol` lint errors

* set `exit` config
2023-03-15 19:22:19 +01:00
Patryk Osmaczko
346db8edd7 fix: lint 2023-03-06 21:36:24 +01:00
Szymon Szlachtowicz
c5e897214b
Fix cast votes (#192) 2021-09-03 09:14:46 +02:00
Szymon Szlachtowicz
253715de89
Fix test timeout (#190) 2021-09-02 11:25:42 +02:00
Szymon Szlachtowicz
9d8eb1d021
Introduce voting history to contract (#189) 2021-09-02 10:23:47 +02:00
Szymon Szlachtowicz
5c38980d4b
Use EIP712 for feature (#188) 2021-08-31 15:46:55 +02:00
Szymon Szlachtowicz
69d10145fa
Use EIP712 (#186) 2021-08-27 14:53:14 +02:00
Szymon Szlachtowicz
1b8affde5a
Refactor smart contracts and fix useDapp (#185) 2021-08-26 18:57:05 +02:00
Szymon Szlachtowicz
2b6440fc8f
Bump useDApp version (#179) 2021-08-04 15:47:10 +02:00
Szymon Szlachtowicz
8e88d925d8
Refactor deploy (#174) 2021-07-30 12:37:00 +02:00
Szymon Szlachtowicz
bdb8c4464f
Add token verification (#173) 2021-07-30 12:28:45 +02:00
Maria Rushkova
e6bbcf5072
Mobile removal flow (#159) 2021-07-27 11:38:43 +02:00
Szymon Szlachtowicz
e24e34fd04
Rename MockContract (#131) 2021-07-19 12:16:25 +02:00
Szymon Szlachtowicz
f666e5b661
Add initial amount to voting (#116) 2021-07-14 12:18:00 +02:00
Szymon Szlachtowicz
b8612779bb
Show notification list (#114) 2021-07-14 11:46:02 +02:00
Szymon Szlachtowicz
01710ff198
Use directory contract (#105) 2021-07-13 12:18:44 +02:00
Szymon Szlachtowicz
fd45e6a1d5
Fix tests (#104) 2021-07-12 16:39:32 +02:00
Szymon Szlachtowicz
f2bdc3abf5
Make voting use directory (#103) 2021-07-12 15:17:32 +02:00
Szymon Szlachtowicz
28a623216d
Introduce directory contract (#102) 2021-07-09 08:42:49 +02:00
Szymon Szlachtowicz
961d0a92f0
Fix contract tests (#93) 2021-07-07 10:30:19 +02:00
Szymon Szlachtowicz
167c34a42a
Fix getCommunityVoting (#89) 2021-07-06 15:34:48 +02:00
Szymon Szlachtowicz
cbd319db3f
Add getCommunityVoting (#88) 2021-07-06 14:55:13 +02:00
Szymon Szlachtowicz
b30c03289f
Improve contract tests (#83) 2021-07-06 13:59:28 +02:00
Szymon Szlachtowicz
59be0ec826
Add waku voting (#57) 2021-06-28 13:43:22 +02:00
Szymon Szlachtowicz
f8e3bb605e
Mock contract (#45)
* Mock contract

* refactor code

* Add event to vote cast

* Add list of voters

* Add deploy
2021-06-23 23:33:25 +02:00
Szymon Szlachtowicz
4421d1666a
Introduce monorepo (#40)
* Introduce monorepo

* Introduce mock contract

* Add readme

Co-authored-by: Szymon Szlachtowicz <szymon.szlachtowicz@Szymons-MacBook-Pro.local>
2021-06-17 13:33:35 +02:00