Commit Graph

262 Commits

Author SHA1 Message Date
Felicio Mununga c4952a7b78
f 2024-03-26 15:40:40 +09:00
Felicio Mununga 6a946ba574
update dependencies 2024-03-26 15:33:43 +09:00
Felicio Mununga b3c2c6a768
cherry pick from `review` branch (#111)
* u

(cherry picked from commit 2715ec654d)

* change placeholder for public key

(cherry picked from commit 4b3e56cd6e)

* fix link to etherscan in notification

(cherry picked from commit fdc0663041)

---------

Co-authored-by: Jakub Kotula <520927+jkbktl@users.noreply.github.com>
2024-03-26 12:19:50 +09:00
Felicio Mununga aba2e34255
update config (#110)
* update config

* u

* u
2024-03-25 14:28:27 +09:00
Felicio Mununga 871511249b
use boot and store nodes from `shards.test` (#109)
* use boot and store nodes from `shards.test`

* u

* u

* u

* u
2024-03-18 23:51:20 +09:00
Felicio Mununga 875441b25c
add op sepolia dapp config (#108)
* add op sepolia dapp config

* f

* f
2024-03-07 19:01:51 +09:00
r4bbit 02ebe0a247
chore: add optimism sepolia deployment config (#107) 2024-02-16 08:26:03 +01:00
Felicio Mununga baaa3d0e12
use `@waku/sdk` (#102)
* u target

* u deps

* f

* f
2023-11-16 14:45:16 +01:00
Felicio Mununga 48cfb2ad89
update WakuProvider (#101)
* revert notification changes

* u waku provider

* f NotificationsList

* use NotificationsList for waku state

* c
2023-11-16 14:07:58 +01:00
Felicio Mununga f35371c6cd
check network (#103)
* add check if network is supported

(cherry picked from commit 9762c401fe)

* u

* f

* Apply suggestions from code review

Co-authored-by: Felicio Mununga <felicio@users.noreply.github.com>

---------

Co-authored-by: Jakub Kotula <520927+jkbktl@users.noreply.github.com>
2023-11-16 13:18:15 +01:00
Felicio Mununga bf60b2cc1e
set provider in `readOnlyUrls` (#100) 2023-11-06 20:45:42 +01:00
r4bbit d57f98c394
cleanup(DeploymentConfig): remove unused network configs (#99)
The application is not intended to be deployed on L1 mainnet or testnet,
so we can remove the configuration settings.
2023-11-02 13:21:54 +01:00
Felicio Mununga d5db47c521
config testnet (#98)
* config testnet

* f

(cherry picked from commit 55deba520c)
2023-11-02 13:16:07 +01:00
r4bbit 9dd802726a
chore(README): add deployment goerli OP addresses (#97)
And remove unused L1 goerli deployment addresses
2023-11-02 12:48:46 +01:00
r4bbit a3967fcdf9
chore(DeploymentConfig): add goerli optimism network config (#96) 2023-11-02 12:29:02 +01:00
r4bbit 894162b5d3
fix: adjust remappings and rpc configs (#95)
This slightly adjust the remappings config to be a bit more specific as
otherwise there was an issue with verifying contracts on chain
explorers.

It also enables RPC configs for optimism.
2023-11-02 12:25:15 +01:00
r4bbit 3fb6e1ca19
chore: readme formatting (#78) 2023-11-01 15:51:59 +01:00
Felicio Mununga 56e1316c20
Update contracts.ts (#93)
* Update contracts.ts

* Update config.ts
2023-11-01 12:59:56 +01:00
Jakub Kotula 2ea23bd37d
[FE] Batching functionality (#88) 2023-11-01 12:52:59 +01:00
Patryk Osmaczko afdfe715f5 Partially revert "chore: tweak deployment parameters before first release"
This reverts commit a47ff64a11.

closes: #46
2023-10-30 22:26:51 +01:00
r4bbit af449861d7
feat(Directory): add ownership capabilities to `Directory` (#90) 2023-10-30 16:10:19 +01:00
Felicio Mununga 4f5651871b
61-featured-communities-list-is-wrong (#87)
* u

* a

* u

* f

* Update FeatureModal.tsx
2023-10-30 13:21:28 +01:00
r4bbit 10cfa07bd7
fix(VotingContract): voting rooms are considered active until evaluated (#89)
This commit fixes a bug in the `VotingContract` where any voting room
marked as `finalized` is not considered to be an active voting room,
even though, evaluation is still ongoing.

The fix adds a check that a voting room has to be either not marked as
finalized, or, if it is, it should not be evaluated, to be considered
an active voting room.

It also adds a test that ensures the fix is working as expected.
2023-10-30 12:24:08 +01:00
r4bbit ed5e16e647
chore(DeploymentConfig): add optimism mainnet config (#86)
Closes #83
2023-10-27 20:17:53 +02:00
r4bbit 1e6f46ac8e
test: add some more assertions to tests to make them explicit (#85) 2023-10-27 20:17:05 +02:00
r4bbit aa006ba177
fix(DeployContracts): deploy multicall on local node (#82)
This fixes a bug that multicall isn't available on a local node. This
commit ensures we deploy it.

It also outputs multicall addresses for Goerli and Optimism, as those
will be needed when the app is deployed to production.
2023-10-20 14:14:44 +02:00
r4bbit c8c01b0423
fix: ensure deployscript sets directory contract (#81)
Something that came up during testing:
The deployment script didn't set the directory contract in both, the
voting contract and the featured voting contract, which resulted in
functoin calls to revert because they essentially didn't exist at the
addresses referenced in those contracts.

This commit fixes it by ensuring `setDirectory()` is called for both
voting contracts.
2023-10-17 20:24:52 +02:00
r4bbit 9c804dd06f
refactor(DeployContracts): mint test tokens for local node (#80)
This commit addresses the issue that, when testing the contracts on a
local node, the test (deployer) account does not have any tokens to use
the voting contracts with.

This is fixed by minting tokens as the deployer of the mock SNT
contract.

The commit also adds the expect SNT contract instance as a return value
of the deploy function, ensuring its address is rendered in stdout when
running the script.

Adding it to the returned tuple however caused a "stack too deep" error,
which is why we had to remove one value from the returned tuple.

Since the `DeploymentConfig` contract instance address is irrelevant for actual
deployments, I've removed it from `DeployContracts.run()` and added an
additional function to retrieve it within tests.
2023-10-17 13:28:27 +02:00
r4bbit da2810c1cd
docs: add goerli addresses (#77) 2023-10-04 13:37:58 +02:00
r4bbit 8f864466d4
chore: set production parameters (#74) 2023-10-04 13:27:23 +02:00
r4bbit b77e258670
refactor: use OZs `Ownable2Step` for access control (#73)
Closes #64
2023-10-04 13:23:35 +02:00
r4bbit 7ac15c6dd6
refactor: use minime and require limit when evaluating votes (#72)
This commit introduces a change that has been largely discussed in #65

Generally the idea is the following:

Prior to this commit, the amount of votes to be evaluated is unbounded, meaning we can potentially run out of gas when too many votes have to be evaluated in a single transaction.
To account for that, vote processing has to be batched based on a limit that is provided when the contract is called.
As a result of batching, finalization of votes can happen over multiple transactions which makes checking balances of voters tricky because evaluation happens at different blocks where balances might have changed.
That's why we're also introducing the use of MiniMeToken over standard ERC20 because it allows us to check balances of accounts at certain blocks.
This commit introduces the following changes in both VotingContract and FeaturedVotingContract:

Evaluation of votes now always happens in three places: When a voting is initialized, when votes are casted and when a voting is being finalized.
When initializing a voting or casting votes, the votes are evaluated against the current block, front-ends can therefore show a good estimation of the current vote state.
Only the "new" votes are evaluated, which should equal to the amount of votes being sent.
When finalizaing a vote, all votes are (re)evaluated against the block at which the finalization has started. This means with finalization, all votes are evaluated again to ensure they represent the latest state.
In terms of code this means:

_evaluateVotes() requires and additional limit, as a result of that finializeVoting() and finalizeVotingRoom() require a limit as well. castVotes() derives the limit from the vote amount that's being sent.
2023-10-04 11:18:42 +02:00
r4bbit 70ca29179e
refactor: remove SafeMath (#76)
There's no need for SafeMath in Solidity 0.8.x and up as it comes
with built-in arithmetic checks.

Also, use named imports.
2023-10-04 11:10:48 +02:00
r4bbit 086601d25b
chore: introduce foundry deployment script (#75)
This introduces a foundry based deployment script which is also used in
tests so the deployment itself is tested as well.
2023-10-04 11:05:33 +02:00
r4bbit e6dec47f02
chore: add config files from foundry template (#69)
The ultimate goal will be to move the contracts package into its own repository that's based on our foundry template.
This commit adds foundry template config files and removes legacy
hardhat stuff.
2023-10-04 10:47:40 +02:00
r4bbit 1eb0f5765d chore: remove unused github workflow file 2023-07-19 10:18:49 +02:00
r4bbit 2193899a09 test: enable test that ensures users can't vote for communities in
cooldown period
2023-07-19 10:18:49 +02:00
r4bbit 658d3561e9 test: add test that ensures voting draw is handled 2023-07-19 10:18:49 +02:00
r4bbit 05892d5b91 test: add foundry tests
This reimplements the hardhat testsuite using foundry for faster test
execution and ease of use.

Hardhat tests and configs are kept around on purpose so we can
transition slowly.
2023-07-19 10:18:49 +02:00
r4bbit 5588378629 forge install: openzeppelin-contracts
v4.8.3
2023-07-19 10:18:49 +02:00
r4bbit 670937a9ce chore: forge init 2023-07-19 10:18:49 +02:00
Patryk Osmaczko 7ae7245c6b fix: prevent active voting being counted for cooldown period 2023-07-03 09:58:22 +02:00
Patryk Osmaczko 7836a76929 chore: extend featuredVotingContract test with break ties scenario 2023-06-30 10:23:26 +02:00
Jakub Kotula 420c9b2849
Featured voting (#37)
* initial

* featured

* featured

* votings

* votings

* add log votings

* comment out notification list for now, fix initialize voting

* featured section | voting flow

* changes

* changes

* refactor waku get/send

* verification debug

* temp

* clean up

* clean up

* comment

* fix lodash import

* revert deploy params

* already voted

* fix tests for format time left fn

* fix decode waku feature test

* restrict UI to only one vote

* fix multiple voting system

* fix contract

* update build step

* verbose compilation

* upgrade hardhat

* git revert build

* Revert "verbose compilation"

This reverts commit f5c57dbcbc.

---------

Co-authored-by: Felicio Mununga <felicio@users.noreply.github.com>
2023-06-29 20:07:41 +02:00
Patryk Osmaczko 2c82372b49 chore: remove Status wallet requirement 2023-06-21 15:16:54 +02:00
Patryk Osmaczko dc84f5ba73 chore: provide optimism goerli contracts 2023-06-19 19:18:02 +02:00
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