Smart contracts for access control and token gated Status communities.
Go to file
r4bbit 4be8613d6e
feat: implement `CommunityTokenDeployer` contract (#2)
This commit introduces the `CommunityTokenDeployer` contract discussed
in https://github.com/status-im/status-desktop/issues/11954.

The idea is that, instead of having accounts deploy `OwnerToken` and
`MasterToken` directly, they'd use a deployer contract instead, which
maintains a registry of known `OwnerToken` addresses, mapped to Status
community addresses.

The following changes have been made:

It was, and still is, a requirement that both, `OwnerToken` and
`MasterToken` are deployed within a single transaction, so that when
something goes wrong, we don't end up in an inconsistent state.

That's why `OwnerToken` used to instantiated `MasterToken` and required
all of its constructor arguments as well.

Unfortunately, this resulted in compilation issues in the context of the
newly introduce deployer contract, where there are too many function
arguments.

Because we now delegate deployment to a dedicated contract, we can
instantiate both `OwnerToken` and `MasterToken` in a single transaction,
without having `OwnerToken` being responsible to instantiate
`MasterToken`.

This fixes the compilation issues and simplifies the constructor of
`OwnerToken`.

The new `CommunityTokenDeployer` contract is now responsble for
deploying the aforementioned tokens and ensures that they are deployed
within a single transaction.

To deploy an `OwnerToken` and `MasterToken` accounts can now call
`CommunityDeloyerToken.deploy(TokenConfig, TokenConfig,
DeploymentSignature)`.

The `DeploymentSignature` uses `EIP712` structured type hash data to let
the contract verify that the deployer is allowed to deploy the contracts
on behalf of a community account.
2023-09-19 11:39:55 +02:00
.github refactor: move project to foundry template and introduce tests 2023-09-08 12:36:20 +02:00
contracts feat: implement `CommunityTokenDeployer` contract (#2) 2023-09-19 11:39:55 +02:00
lib refactor: move project to foundry template and introduce tests 2023-09-08 12:36:20 +02:00
script feat: implement `CommunityTokenDeployer` contract (#2) 2023-09-19 11:39:55 +02:00
specs refactor: move project to foundry template and introduce tests 2023-09-08 12:36:20 +02:00
test feat: implement `CommunityTokenDeployer` contract (#2) 2023-09-19 11:39:55 +02:00
.editorconfig refactor: move project to foundry template and introduce tests 2023-09-08 12:36:20 +02:00
.env.example refactor: move project to foundry template and introduce tests 2023-09-08 12:36:20 +02:00
.gas-snapshot feat: implement `CommunityTokenDeployer` contract (#2) 2023-09-19 11:39:55 +02:00
.gitattributes refactor: move project to foundry template and introduce tests 2023-09-08 12:36:20 +02:00
.gitignore refactor: move project to foundry template and introduce tests 2023-09-08 12:36:20 +02:00
.gitmodules refactor: move project to foundry template and introduce tests 2023-09-08 12:36:20 +02:00
.prettierignore refactor: move project to foundry template and introduce tests 2023-09-08 12:36:20 +02:00
.solhint.json refactor: move project to foundry template and introduce tests 2023-09-08 12:36:20 +02:00
PROPERTIES.md refactor: move project to foundry template and introduce tests 2023-09-08 12:36:20 +02:00
README.md refactor: move project to foundry template and introduce tests 2023-09-08 12:36:20 +02:00
codecov.yml refactor: move project to foundry template and introduce tests 2023-09-08 12:36:20 +02:00
foundry.toml refactor: move project to foundry template and introduce tests 2023-09-08 12:36:20 +02:00
package.json refactor: move project to foundry template and introduce tests 2023-09-08 12:36:20 +02:00
pnpm-lock.yaml refactor: move project to foundry template and introduce tests 2023-09-08 12:36:20 +02:00
prettierrc.yml refactor: move project to foundry template and introduce tests 2023-09-08 12:36:20 +02:00
remappings.txt refactor: move project to foundry template and introduce tests 2023-09-08 12:36:20 +02:00
slither.config.json refactor: move project to foundry template and introduce tests 2023-09-08 12:36:20 +02:00
specs.sh feat: implement `CommunityTokenDeployer` contract (#2) 2023-09-19 11:39:55 +02:00

README.md

Communities Contracts Github Actions Foundry

Usage

This is a list of the most frequently needed commands.

Build

Build the contracts:

$ forge build

Clean

Delete the build artifacts and cache directories:

$ forge clean

Compile

Compile the contracts:

$ forge build

Coverage

Get a test coverage report:

$ forge coverage

Deploy

Deploy to Anvil:

$ forge script script/DeployOwnerToken.s.sol --broadcast --fork-url http://localhost:8545

For this script to work, you need to have a MNEMONIC environment variable set to a valid BIP39 mnemonic.

For instructions on how to deploy to a testnet or mainnet, check out the Solidity Scripting tutorial.

Format

Format the contracts:

$ forge fmt

Gas Usage

Get a gas report:

$ forge test --gas-report

Lint

Lint the contracts:

$ pnpm lint

Test

Run the tests:

$ forge test