Commit Graph

3 Commits

Author SHA1 Message Date
r4bbit 65059087af
refactor: don't revert deployment on non-existant configs
At this point, the contracts that need to be deployed do not require
chain specific configurations. The ones provided for local test nodes
are used in tests that don't represent the production deployment.

Hence, there's little point in reverting the deployment if there's no
config for a specific chain.

This commit also moves the `deployer` assignment to the beginning of the
constructor, ensuring that it's set when configs are created.
2023-09-22 08:21:19 +02:00
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
r4bbit c2f500c2e5
refactor: move project to foundry template and introduce tests
This commit does a couple of things:

- moves the project to our foundry template structure and workflows
- removes hardhat usage and dependencies
- removes unused contracts
- ports existing JS tests to foundry tests
- adds additional tests for `CommunityERC20` contract
- Introduces deploy scripts written in solidity which are also covered
  by tests

The projects can now be build and tests with:

```
$ forge build
```

```
$ forge test
```

Test deployments can be done via

```
$ forge script script/DeployOwnerToken.sol
```
2023-09-08 12:36:20 +02:00