Skip to content

Commit

Permalink
feat(pg): Sick Foundry plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-goldman authored and RPate97 committed Jun 16, 2023
1 parent da73f3e commit b6d1f76
Show file tree
Hide file tree
Showing 126 changed files with 7,415 additions and 5,362 deletions.
9 changes: 9 additions & 0 deletions .changeset/thick-llamas-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@chugsplash/contracts': minor
'@chugsplash/executor': minor
'@chugsplash/plugins': minor
'@chugsplash/core': minor
'@chugsplash/demo': minor
---

Overhaul Foundry Integration
7 changes: 0 additions & 7 deletions .gitmodules

This file was deleted.

20 changes: 8 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ChugSplash

A declarative and deterministic framework for deploying and upgrading smart contracts. Available for both Hardhat and Foundry.
A declarative and deterministic framework for deploying smart contracts. Available for both Hardhat and Foundry.

Powers the [ChugSplash Managed Service](https://www.chugsplash.io).

Expand All @@ -12,20 +12,18 @@ If you want to use ChugSplash in production, ask a question, or request a featur

### ChugSplash Core Protocol
The Core Protocol includes smart contracts as well as Hardhat and Foundry plugins. All of the code is MIT licensed and is located inside this repository.
- Define deployments and upgrades [declaratively](https://github.com/chugsplash/chugsplash/blob/develop/docs/chugsplash-file.md#layout-of-a-chugsplash-file) in a single file, inspired by [Terraform](https://www.terraform.io/).
- Define deployments [declaratively](https://github.com/chugsplash/chugsplash/blob/develop/docs/chugsplash-file.md#layout-of-a-chugsplash-file) in a single file, inspired by [Terraform](https://www.terraform.io/).
- Deployments are fully atomic, deterministic, and idempotent. Deployments cannot be halted for any reason and are finalized in a single transaction.
- Removes the need for initializer functions in your upgradeable contracts
- Built-in storage layout safety checker
- Deploys contracts at consistent addresses across networks using `CREATE2`
- Keep track of contract dependencies using simple template syntax (i.e. `{{ MyContract }}`).
- Generates deployment artifacts in the same format as hardhat-deploy
- Compatible with contracts deployed using the [OpenZeppelin Hardhat Upgrades API](https://docs.openzeppelin.com/upgrades-plugins/1.x/api-hardhat-upgrades) including both Transparent and UUPS proxies.

### [ChugSplash Managed Service](https://www.chugsplash.io)
The ChugSplash Managed Service is an optional product built on top of the ChugSplash Core Protocol designed to provide more advanced DevOps functionality for smart contract development teams.
- Manage projects, contracts, and deployments in a UI
- Approve deployments/upgrades with a single transaction through the UI
- Easy CI integration. Gaslessly propose upgrades to your contracts from your CI process. Upgrades are executed after your approval.
- Gaslessly propose deployments from your CI process
- Approve deployments with a single transaction through the UI
- Deployments are trustlessly executed by our hosted backend
- Automatic Etherscan verification

## Getting Started
Expand All @@ -34,18 +32,16 @@ The ChugSplash Managed Service is an optional product built on top of the ChugSp
[Get started with ChugSplash for Foundry](https://github.com/chugsplash/chugsplash/blob/develop/docs/foundry/getting-started.md)

### Hardhat
[Get started with ChugSplash for Hardhat](https://github.com/chugsplash/chugsplash/blob/develop/docs/hardhat/setup-project.md)
[Get started with ChugSplash for Hardhat](https://github.com/chugsplash/chugsplash/blob/develop/docs/hardhat/getting-started.md)

## Documentation

- [ChugSplash File](https://github.com/chugsplash/chugsplash/blob/develop/docs/chugsplash-file.md): Detailed explanation of the file where you define your deployments and upgrades.
- [Variables Reference](https://github.com/chugsplash/chugsplash/blob/develop/docs/variables.md): Reference describing how to assign values to every variable type in a ChugSplash config file.
- [Using ChugSplash on Live Networks](https://github.com/chugsplash/chugsplash/blob/develop/docs/live-network.md): Instructions for using ChugSplash to deploy or upgrade a project on a live network.
- [Integrating with CI](https://github.com/chugsplash/chugsplash/blob/develop/docs/ci-integration.md): Walkthrough of how to setup ChugSplash deployments in your CI process using GitHub actions.
- [Special Variable Definitions](https://github.com/chugsplash/chugsplash/blob/develop/docs/special-var-defs.md): Explains how to define contract references in your ChugSplash config file, and how to preserve the values of variables during an upgrade.
- Integrating with CI for [Hardhat](https://github.com/chugsplash/chugsplash/blob/develop/docs/hardhat/ci-integration.md) and [Foundry](https://github.com/chugsplash/chugsplash/blob/develop/docs/hardhat/ci-integration.md): Walkthrough of how to setup ChugSplash deployments in your CI process using GitHub actions.
- [Special Variable Definitions](https://github.com/chugsplash/chugsplash/blob/develop/docs/special-var-defs.md): Explains how to define contract references in your ChugSplash config file.
- [Immutable Variables](https://github.com/chugsplash/chugsplash/blob/develop/docs/immutable-variables.md): How to define immutable variables with ChugSplash.
- [Storage Layout Safety Checker](https://github.com/chugsplash/chugsplash/blob/develop/docs/storage-checker.md): Explains the type of storage layout errors that ChugSplash automatically detects.
- [Importing Contracts from the OpenZeppelin Hardhat Upgrades API](https://github.com/chugsplash/chugsplash/blob/develop/docs/import-openzeppelin.md): Upgrade your existing OpenZeppelin proxies using ChugSplash.
- [How ChugSplash Works](https://github.com/chugsplash/chugsplash/blob/develop/docs/how-chugsplash-works.md). A deep dive into the ChugSplash Core Protocol.

## Supported Networks
Expand Down
34 changes: 14 additions & 20 deletions docs/foundry/api-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,19 @@ This document is a work in progress.
## Table of Contents

- [Deploy](#Deploy)
- [Register](#Register)
- [Propose](#Propose)
- [List Projects](#List-Projects)
- [Transfer Proxy](#Transfer-Proxy)
- [Get Address](#Get-Address)

## Deploy
Performs a complete deployment or upgrade of a ChugSplash config file.

## Register
Todo

## Propose
Todo

## Cancel
Todo

## List Projects
Todo

## Transfer Proxy
Todo
Performs a complete deployment of a ChugSplash config file against the specified rpc url.
```
deploy('./chugsplash.config.ts', 'http://localhost:8545');
deploy('./chugsplash.config.ts', vm.rpcUrl("anvil"));
```

## Get Address
Fetches a contract address using the config, the contracts reference name, and an optional salt. Note that this function will only work if the config and contract were deployed previously in the same script.

```
getAddress('./chugsplash.config.ts', 'TestContract');
getAddress('./chugsplash.config.ts', 'TestContract', 1)
```
63 changes: 63 additions & 0 deletions docs/foundry/ci-integration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Using ChugSplash in CI with Foundry and ChugSplash Managed

This is a basic guide on how to integrate ChugSplash into your CI process using GitHub actions to trigger a deployment
on goerli whenever you push a change to the main branch of your repo. If you are using a different CI platform, this guide
will still be approximately accurate, but the exact configuration of the CI provider may be different. This guide is tailored to Foundry users, if you are using Hardhat then you should check out the [Hardhat version of this guide](https://github.com/chugsplash/chugsplash/blob/develop/docs/hardhat/ci-integration.md).


## Create a Github Actions Folder
`mkdir -p .github/workflows`

## Create a new workflow deploy.yml
`touch .github/workflows/deploy.yml`

## Paste in the following action template
```
name: Deploy Contracts
env:
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
IPFS_PROJECT_ID: ${{ secrets.IPFS_PROJECT_ID }}
IPFS_API_KEY_SECRET: ${{ secrets.IPFS_API_KEY_SECRET }}
CHUGSPLASH_API_KEY: ${{ secrets.CHUGSPLASH_API_KEY }}
RPC_GOERLI: ${{ secrets.RPC_GOERLI }}
on:
push:
branches:
- main
jobs:
chugsplash-propose:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn install
- run: npx chugsplash propose --config-path <path to ChugSplash config> --network goerli
```

The key part of this is the `propose` command which is what initiates the deployment using ChugSplash. If you are using a different CI provider, you'll just need to ensure this command is properly run.

Note that in this example, we've also included an Alchemy API key and installed the projects dependencies using yarn. These may be different for your project depending one what node provider you are using and your chosen package manager.

## Update your foundry.toml file
In this example, we're using the alias `goerli` for the network argument. So we must also define an rpc endpoint alias in our foundry.toml for `goerli`:
```
[rpc_endpoints]
goerli = "${RPC_GOERLI}"
```

Anytime you propose a deployment to a new network, you'll need to use a network alias defined in your foundry.toml file. [Learn more about configuring rpc endpoints in foundry.](https://book.getfoundry.sh/reference/config/testing?highlight=rpc_endpoint#rpc_endpoints)

Note: At this time, ChugSplash Managed only supports Goerli and Optimism Goerli. If you would like support for different networks please let us know in the Discord.

## Add the required secret repository variables to you Github Actions settings
* `RPC_GOERLI` An RPC url to access Goerli. You can get this from [Alchemy](https://www.alchemy.com/), or another node provider.
* `PRIVATE_KEY`: The private key of an EOA you'd like to use to trigger deployments. This must be the same as the one you used to register the organization, and should be set as the default account in your hardhat config file.
* `IPFS_PROJECT_ID` and `IPFS_API_KEY_SECRET`: IPFS credentials. These must be from [Infura](https://app.infura.io/).
* `CHUGSPLASH_API_KEY`: Find this on the ChugSplash dashboard after registering your organization.

## Make sure your Org Id is correct
You'll find your ChugSplash organization Id on the ChugSplash dashboard of the website. You'll want to copy it and make sure that you are using it in your ChugSplash config file.

## Test your integration
Test out your integration by pushing to main to trigger a deployment. You should see your project show up on the website shortly
and be able to fund and approve it for deployment. If you run into any issues integrating your project with ChugSplash, please
feel free to ask questions in the Discord: https://discord.gg/HefaZbcvaK.
Loading

0 comments on commit b6d1f76

Please sign in to comment.