-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #256 from privacy-scaling-explorations/feature/con…
…tracts feat(contracts): add maci-platform-contracts boilerplate
- Loading branch information
Showing
22 changed files
with
1,289 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Contracts | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
|
||
env: | ||
NEXT_PUBLIC_CHAIN_NAME: ${{ vars.NEXT_PUBLIC_CHAIN_NAME }} | ||
NEXT_PUBLIC_ADMIN_ADDRESS: ${{ vars.NEXT_PUBLIC_ADMIN_ADDRESS }} | ||
NEXT_PUBLIC_APPROVAL_SCHEMA: ${{ vars.NEXT_PUBLIC_APPROVAL_SCHEMA }} | ||
NEXT_PUBLIC_METADATA_SCHEMA: ${{ vars.NEXT_PUBLIC_METADATA_SCHEMA }} | ||
NEXT_PUBLIC_ROUND_ID: ${{ vars.NEXT_PUBLIC_ROUND_ID }} | ||
NEXT_PUBLIC_SKIP_APPROVED_VOTER_CHECK: false | ||
NEXT_PUBLIC_MACI_ADDRESS: ${{ vars.NEXT_PUBLIC_MACI_ADDRESS }} | ||
NEXT_PUBLIC_TALLY_URL: ${{ vars.NEXT_PUBLIC_TALLY_URL }} | ||
NEXT_PUBLIC_WALLETCONNECT_ID: ${{ secrets.NEXT_PUBLIC_WALLETCONNECT_ID }} | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-22.04 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: pnpm/action-setup@v4 | ||
with: | ||
version: 9 | ||
|
||
- name: Use Node.js 20 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: "pnpm" | ||
|
||
- name: Install | ||
run: | | ||
pnpm install --frozen-lockfile --prefer-offline | ||
- name: Build | ||
run: | | ||
pnpm run build | ||
- name: Test | ||
run: pnpm run test | ||
working-directory: packages/contracts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"**/*.{ts,js,tsx,jsx}": ["prettier --ignore-unknown --write", "eslint --fix"], | ||
"**/*.sol": ["prettier --ignore-unknown --write", "solhint --fix --noPrompt"], | ||
"*": ["prettier --ignore-unknown --write"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
build/ | ||
dist/ | ||
artifacts/ | ||
cache/ | ||
typechain-types/ | ||
.next/ | ||
node_modules/ | ||
coverage/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": "solhint:recommended", | ||
"rules": { | ||
"avoid-suicide": "error", | ||
"avoid-sha3": "warn", | ||
"max-line-length": ["warn", 120], | ||
"quotes": ["error", "double"], | ||
"func-visibility": ["error", { "ignoreConstructors": true }], | ||
"state-visibility": "error", | ||
"immutable-vars-naming": ["warn", { "immutablesAsConstants": false }] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
MNEMONIC= | ||
# api key for eth mainnet etherscan | ||
ETH_ETHERSCAN_API_KEY= | ||
# api key for optimism mainnet etherscan | ||
OPTIMISM_ETHERSCAN_API_KEY= | ||
# api key for scroll etherscan | ||
SCROLL_ETHERSCAN_API_KEY= | ||
# api key for base etherscan | ||
BASE_ETHERSCAN_API_KEY= | ||
# api key for arbitrum etherscan | ||
ARB_ETHERSCAN_API_KEY= | ||
# RPC url to talk to optimism mainnet | ||
SEPOLIA_RPC_URL= | ||
# RPC url to talk to optimism sepolia | ||
OP_SEPOLIA_RPC_URL= | ||
# RPC url to talk to scroll mainnet | ||
SCROLL_RPC_URL= | ||
# RPC url to talk to scroll sepolia | ||
SCROLL_SEPOLIA_RPC_URL= | ||
# Forking url for testing | ||
FORKING_URL= | ||
# Gas price to use for transactions | ||
GAS_PRICE= | ||
# Block number to fork from | ||
FORKING_BLOCK_NUM= | ||
# Hardhat logging level (true/false) | ||
HARDHAT_LOGGING= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const path = require("path"); | ||
|
||
module.exports = { | ||
root: true, | ||
extends: ["../../.eslintrc.js"], | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
project: path.resolve(__dirname, "./tsconfig.json"), | ||
sourceType: "module", | ||
typescript: true, | ||
ecmaVersion: 2022, | ||
experimentalDecorators: true, | ||
requireConfigFile: false, | ||
ecmaFeatures: { | ||
classes: true, | ||
impliedStrict: true, | ||
}, | ||
warnOnUnsupportedTypeScriptVersion: true, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
docs | ||
.env | ||
deploy-config.json | ||
deployed-contracts.json | ||
cache | ||
artifacts | ||
typechain-types | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
tests | ||
build/tests | ||
.etherlime-store | ||
solc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# `maci-platform-contracts` | ||
|
||
[![Actions Status][contracts-actions-badge]][contracts-actions-link] | ||
|
||
This submodule contains all the Ethereum contracts and tests for MACI Platform. | ||
|
||
[contracts-actions-badge]: https://github.com/privacy-scaling-explorations/maci/actions/workflows/contracts-build.yml/badge.svg | ||
[contracts-actions-link]: https://github.com/privacy-scaling-explorations/maci/actions?query=workflow%3Acontracts |
48 changes: 48 additions & 0 deletions
48
packages/contracts/contracts/interfaces/IRecipientRegistry.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
/// @title IRecipientRegistry | ||
/// @notice An interface for a recipient registry | ||
interface IRecipientRegistry { | ||
/// @notice A struct representing a recipient | ||
struct Recipient { | ||
// recipient metadata url | ||
bytes32 metadataUrl; | ||
// recipient address | ||
address recipient; | ||
} | ||
|
||
/// @notice Get a registry metadata url | ||
/// @return The metadata url in bytes32 format | ||
function getRegistryMetadataUrl() external view returns (bytes32); | ||
|
||
/// @notice Add a recipient | ||
/// @param recipient The recipient data | ||
/// @return The index of the recipient | ||
function addRecipient(Recipient calldata recipient) external returns (uint256); | ||
|
||
/// @notice Remove a recipient | ||
/// @param index The index of the recipient | ||
function removeRecipient(uint256 index) external; | ||
|
||
/// @notice Change a recipient | ||
/// @param index The index of the recipient | ||
function changeRecipient(uint256 index, Recipient calldata recipient) external view; | ||
|
||
/// @notice Get a recipient | ||
/// @param index The index of the recipient | ||
/// @return The address of the recipient and metadata url or id | ||
function getRecipient(uint256 index) external view returns (Recipient memory); | ||
|
||
/// @notice Get the max number of recipients | ||
/// @return The max number of recipients | ||
function maxRecipients() external view returns (uint256); | ||
|
||
/// @notice Set the max number of recipients | ||
/// @return The max number of recipients | ||
function setMaxRecipients(uint256 maxRecipients) external returns (uint256); | ||
|
||
/// @notice Get the number of recipients | ||
/// @return The number of recipients | ||
function getRecipientCount() external view returns (uint256); | ||
} |
Oops, something went wrong.