Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding foundry for contract testing | hardhat will remain for integration testing #41

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/forge-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: contracts - build -> forge test
on:
push:
branches:
- main
- release
pull_request:
branches:
- "**"
jobs:
tests:
concurrency: ci-forge-${{ github.head_ref || github.run_id }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 1

- uses: pnpm/action-setup@v2
with:
version: 7

- uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'pnpm'

- name: Install dependencies
run: |
pnpm install

- name: Compile contracts
run: |
pnpm compile:forge

- name: Test contracts
run: |
pnpm test:forge
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: package/contracts - Build -> Test
name: contracts - build -> hardhat test
on:
push:
branches:
Expand All @@ -9,7 +9,7 @@ on:
- "**"
jobs:
tests:
concurrency: ci-contract-${{ github.head_ref || github.run_id }}
concurrency: ci-hardhat-${{ github.head_ref || github.run_id }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -30,11 +30,11 @@ jobs:
run: |
pnpm install

- name: Compile contract
- name: Compile contracts
run: |
pnpm compile

- name: Test contract
- name: Test contracts
run: |
pnpm test

Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,10 @@ cache
artifacts
abis/

# ZK files
artifacts-zk
cache-zk

# Foundry files
cache_forge
out
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/openzeppelin/openzeppelin-contracts
[submodule "lib/openzeppelin-contracts-upgradeable"]
path = lib/openzeppelin-contracts-upgradeable
url = https://github.com/openzeppelin/openzeppelin-contracts-upgradeable
121 changes: 121 additions & 0 deletions .openzeppelin/unknown-31337.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
"manifestVersion": "3.2",
"admin": {
"address": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
"txHash": "0x09d44217b17330ef52c8a926109dc5d2d7889d585c35d4292c1144d9eb0cb127"
},
"proxies": [
{
"address": "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0",
"txHash": "0x9c3b1d7995acf6e470837b4854c7a7d6512a63e8debddbd3a0ccde8c42a8d0f6",
"kind": "transparent"
},
{
"address": "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
"txHash": "0x09fba1a236bd732501ad964a14d56d475bf1c3f94d6eade85e52e76663dc2acb",
"kind": "transparent"
}
],
"impls": {
"777deeff9d03cd6e376d1feca8a0c01b6bf75339df9cacbb788c98f548a864e6": {
"address": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
"txHash": "0xaaacc8bc323f5464db105d38a56c91716e95ad35a889149f1fece93f4d032c04",
"layout": {
"solcVersion": "0.8.17",
"storage": [
{
"label": "_initialized",
"offset": 0,
"slot": "0",
"type": "t_uint8",
"contract": "Initializable",
"src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol:63",
"retypedFrom": "bool"
},
{
"label": "_initializing",
"offset": 1,
"slot": "0",
"type": "t_bool",
"contract": "Initializable",
"src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol:68"
},
{
"label": "__gap",
"offset": 0,
"slot": "1",
"type": "t_array(t_uint256)50_storage",
"contract": "ContextUpgradeable",
"src": "lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol:36"
},
{
"label": "_owner",
"offset": 0,
"slot": "51",
"type": "t_address",
"contract": "OwnableUpgradeable",
"src": "lib/openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol:22"
},
{
"label": "__gap",
"offset": 0,
"slot": "52",
"type": "t_array(t_uint256)49_storage",
"contract": "OwnableUpgradeable",
"src": "lib/openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol:94"
},
{
"label": "protocolTreasury",
"offset": 0,
"slot": "101",
"type": "t_address_payable",
"contract": "AlloSettings",
"src": "contracts/settings/AlloSettings.sol:16"
},
{
"label": "protocolFeePercentage",
"offset": 20,
"slot": "101",
"type": "t_uint24",
"contract": "AlloSettings",
"src": "contracts/settings/AlloSettings.sol:20"
}
],
"types": {
"t_address": {
"label": "address",
"numberOfBytes": "20"
},
"t_address_payable": {
"label": "address payable",
"numberOfBytes": "20"
},
"t_array(t_uint256)49_storage": {
"label": "uint256[49]",
"numberOfBytes": "1568"
},
"t_array(t_uint256)50_storage": {
"label": "uint256[50]",
"numberOfBytes": "1600"
},
"t_bool": {
"label": "bool",
"numberOfBytes": "1"
},
"t_uint24": {
"label": "uint24",
"numberOfBytes": "3"
},
"t_uint256": {
"label": "uint256",
"numberOfBytes": "32"
},
"t_uint8": {
"label": "uint8",
"numberOfBytes": "1"
}
}
}
}
}
}
15 changes: 13 additions & 2 deletions contracts/projectRegistry/ProjectRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "../utils/MetaPtr.sol";
import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import { MetaPtr } from "../utils/MetaPtr.sol";

error Unauthorized();

/**
* @title ProjectRegistry
Expand Down Expand Up @@ -67,6 +69,7 @@ contract ProjectRegistry is Initializable {
* @dev In future deploys of the implementation, an higher version should be passed to reinitializer
*/
function initialize() public reinitializer(1) {
// solhint-disable-previous-line no-empty-blocks
}

// External functions
Expand All @@ -88,6 +91,14 @@ contract ProjectRegistry is Initializable {
emit MetadataUpdated(projectID, metadata);
}

/**
* @notice Returns a project
* @param projectID the project id to retrieve
*/
function getProject(uint256 projectID) external view returns (Project memory) {
return projects[projectID];
}

/**
thelostone-mc marked this conversation as resolved.
Show resolved Hide resolved
* @notice Updates Metadata for singe project
* @param projectID ID of previously created project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function renounceOwnership() external nonpayable



*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.*
*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.*


### transferOwnership
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function renounceOwnership() external nonpayable



*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.*
*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.*


### transferOwnership
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,28 @@ function createProject(MetaPtr metadata) external nonpayable
|---|---|---|
| metadata | MetaPtr | undefined |

### getProject

```solidity
function getProject(uint256 projectID) external view returns (struct ProjectRegistry.Project)
```

Returns a project



#### Parameters

| Name | Type | Description |
|---|---|---|
| projectID | uint256 | the project id to retrieve |

#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | ProjectRegistry.Project | undefined |

### getProjectOwners

```solidity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function renounceOwnership() external nonpayable



*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.*
*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.*


### roundImplementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function renounceOwnership() external nonpayable



*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.*
*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.*


### transferOwnership
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function renounceOwnership() external nonpayable



*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.*
*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.*


### transferOwnership
Expand Down
Loading