generated from evan-gray/multichain-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b530862
Showing
36 changed files
with
3,761 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Custom Dictionary Words | ||
Aptos | ||
Devnet | ||
Ruleset | ||
Rulesets | ||
Solana |
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,45 @@ | ||
name: evm | ||
|
||
on: pull_request | ||
|
||
env: | ||
FOUNDRY_PROFILE: ci | ||
|
||
jobs: | ||
check: | ||
strategy: | ||
fail-fast: true | ||
|
||
name: Foundry project | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: evm | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
|
||
- name: Show Forge version | ||
run: | | ||
forge --version | ||
- name: Run Forge fmt | ||
run: | | ||
forge fmt --check | ||
id: fmt | ||
|
||
- name: Run Forge build | ||
run: | | ||
forge build --sizes | ||
id: build | ||
|
||
- name: Run Forge tests | ||
run: | | ||
forge test -vvv | ||
id: test |
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,26 @@ | ||
name: format | ||
on: pull_request | ||
jobs: | ||
prettier: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20 | ||
cache: "npm" | ||
cache-dependency-path: "package-lock.json" | ||
- run: npm ci | ||
- run: npx prettier --check . | ||
spellcheck: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
# Pinned version of the v6 tag, which is a lightweight and hence mutable tag | ||
- uses: streetsidesoftware/cspell-action@214db1e3138f326d33b7a6a51c92852e89ab0618 | ||
with: | ||
# For now, only lint markdown files | ||
files: "**/*.md" | ||
inline: warning | ||
# Only check files in the PR or push | ||
incremental_files_only: 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,33 @@ | ||
name: svm | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
name: Anchor Test | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: svm | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Get solana version | ||
id: solana | ||
run: | | ||
SOLANA_VERSION="$(awk '/solana_version =/ { print substr($3, 2, length($3)-2) }' Anchor.toml)" | ||
echo "::set-output name=version::${SOLANA_VERSION}" | ||
- name: Get anchor version | ||
id: anchor | ||
run: | | ||
ANCHOR_VERSION="$(awk '/anchor_version =/ { print substr($3, 2, length($3)-2) }' Anchor.toml)" | ||
echo "::set-output name=version::${ANCHOR_VERSION}" | ||
- uses: evan-gray/anchor-test@24c04ecece7b484fa1218bab4318818b36436005 | ||
with: | ||
anchor-version: "${{steps.anchor.outputs.version}}" | ||
solana-cli-version: "${{steps.solana.outputs.version}}" | ||
working-directory: "svm" | ||
|
||
- run: cargo fmt --check --all | ||
- run: cargo clippy | ||
- run: cargo test |
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 @@ | ||
node_modules/ |
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,3 @@ | ||
[submodule "evm/lib/forge-std"] | ||
path = evm/lib/forge-std | ||
url = https://github.com/foundry-rs/forge-std |
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,3 @@ | ||
evm/cache/ | ||
evm/lib/ | ||
evm/out/ |
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,14 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. | ||
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp | ||
|
||
// List of extensions which should be recommended for users of this workspace. | ||
"recommendations": [ | ||
"esbenp.prettier-vscode", | ||
"JuanBlanco.solidity", | ||
"rust-lang.rust-analyzer", | ||
"streetsidesoftware.code-spell-checker" | ||
], | ||
// List of extensions recommended by VS Code that should not be recommended for users of this workspace. | ||
"unwantedRecommendations": [] | ||
} |
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,9 @@ | ||
{ | ||
"editor.formatOnSave": true, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"files.insertFinalNewline": true, | ||
"[solidity]": { | ||
"editor.defaultFormatter": "JuanBlanco.solidity" | ||
}, | ||
"solidity.formatter": "forge" | ||
} |
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,13 @@ | ||
Copyright 2022 Wormhole Project Contributors | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
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,85 @@ | ||
# Multi-Chain Template | ||
|
||
## Overview | ||
|
||
This repository serves as a template monorepo for developing on multiple blockchains. The goal is to provide the generally recommended starting setups for each runtime along with pre-configured CI. | ||
|
||
## Runtime Support | ||
|
||
- [x] [EVM](https://ethereum.org/en/developers/docs/evm/) | ||
- [x] [SVM](https://solana.com/developers/evm-to-svm/smart-contracts) | ||
- [ ] [Sui Move](https://sui.io/move) | ||
- [ ] [Aptos Move](https://aptos.dev/en/build/smart-contracts) | ||
|
||
## Developer Dependencies | ||
|
||
### Miscellaneous | ||
|
||
- [Node.js](https://nodejs.org/en/download/package-manager) | ||
|
||
Run `npm ci` at the root of this repo to install Prettier. | ||
|
||
### EVM | ||
|
||
- [Foundry](https://book.getfoundry.sh/getting-started/installation) | ||
|
||
### SVM | ||
|
||
- [Rust 1.75.0](https://www.rust-lang.org/tools/install) | ||
- [Solana 1.18.17](https://solana.com/docs/intro/installation) | ||
- [Yarn](https://yarnpkg.com/getting-started/install) | ||
- [Anchor 0.30.1](https://www.anchor-lang.com/docs/installation) | ||
|
||
Required versions are defined in [./svm/rust-toolchain.toml](./svm/rust-toolchain.toml) and [./svm/Anchor.toml](./svm/Anchor.toml) | ||
|
||
## Recommended VSCode Settings | ||
|
||
Recommended VSCode settings and extensions have been included as workspace settings in this repository (`.vscode`). | ||
|
||
This includes: | ||
|
||
- Foundry's [forge formatting](https://book.getfoundry.sh/config/vscode#3-formatter) | ||
- [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) | ||
- This should work after running `npm ci` at the root of this repo. | ||
|
||
Additional, related settings may be required based on your use. | ||
|
||
## Recommended GitHub Settings | ||
|
||
### General | ||
|
||
- Default branch: `main` | ||
- *Dis*allow merge commits | ||
- Always suggest updating pull request branches | ||
- Automatically delete head branches | ||
|
||
### Rules / Rulesets | ||
|
||
- Ruleset Name: Require PRs | ||
- Enforcement status: Active | ||
- Target branches / Add target: Include default branch | ||
- Branch rules | ||
- Restrict deletions | ||
- Require linear history | ||
- Require a pull request before merging | ||
- Required approvals: 1 (or more/less depending on your number of contributors) | ||
- Dismiss stale pull request approvals when new commits are pushed | ||
- Require review from Code Owners | ||
- Require approval of the most recent reviewable push | ||
- Require conversation resolution before merging | ||
- Require status checks to pass | ||
- Require branches to be up to date before merging | ||
- Add checks | ||
- Anchor Test | ||
- Foundry project | ||
- prettier | ||
- spellcheck | ||
- Block force pushes | ||
- Restrictions [Enterprise Only] | ||
- Restrict commit metadata | ||
- Add restriction | ||
- Applies to: Commit message | ||
- Requirement: Must match a given regex pattern | ||
- Matching pattern: | ||
- `^(ci|evm|svm|readme){1}(\([\w\-\.]+\))?(!)?: ([\w ])+([\s\S]*)` for file/folder prefixes | ||
- or `^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\w\-\.]+\))?(!)?: ([\w ])+([\s\S]*)` to [enforce conventional commits](https://docs.github.com/en/enterprise-cloud@latest/organizations/managing-organization-settings/creating-rulesets-for-repositories-in-your-organization#enforce-conventional-commits) |
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,15 @@ | ||
{ | ||
"version": "0.2", | ||
"ignorePaths": [], | ||
"dictionaryDefinitions": [ | ||
{ | ||
"name": "custom-dictionary", | ||
"path": "./.cspell/custom-dictionary.txt", | ||
"addWords": true | ||
} | ||
], | ||
"dictionaries": ["custom-dictionary"], | ||
"words": [], | ||
"ignoreWords": [], | ||
"import": [] | ||
} |
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,14 @@ | ||
# Compiler files | ||
cache/ | ||
out/ | ||
|
||
# Ignores development broadcast logs | ||
!/broadcast | ||
/broadcast/*/31337/ | ||
/broadcast/**/dry-run/ | ||
|
||
# Docs | ||
docs/ | ||
|
||
# Dotenv file | ||
.env |
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,66 @@ | ||
## Foundry | ||
|
||
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.** | ||
|
||
Foundry consists of: | ||
|
||
- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools). | ||
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data. | ||
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network. | ||
- **Chisel**: Fast, utilitarian, and verbose solidity REPL. | ||
|
||
## Documentation | ||
|
||
https://book.getfoundry.sh/ | ||
|
||
## Usage | ||
|
||
### Build | ||
|
||
```shell | ||
$ forge build | ||
``` | ||
|
||
### Test | ||
|
||
```shell | ||
$ forge test | ||
``` | ||
|
||
### Format | ||
|
||
```shell | ||
$ forge fmt | ||
``` | ||
|
||
### Gas Snapshots | ||
|
||
```shell | ||
$ forge snapshot | ||
``` | ||
|
||
### Anvil | ||
|
||
```shell | ||
$ anvil | ||
``` | ||
|
||
### Deploy | ||
|
||
```shell | ||
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key> | ||
``` | ||
|
||
### Cast | ||
|
||
```shell | ||
$ cast <subcommand> | ||
``` | ||
|
||
### Help | ||
|
||
```shell | ||
$ forge --help | ||
$ anvil --help | ||
$ cast --help | ||
``` |
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,6 @@ | ||
[profile.default] | ||
src = "src" | ||
out = "out" | ||
libs = ["lib"] | ||
|
||
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options |
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 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity ^0.8.13; | ||
|
||
import {Script, console} from "forge-std/Script.sol"; | ||
|
||
contract CounterScript is Script { | ||
function setUp() public {} | ||
|
||
function run() public { | ||
vm.broadcast(); | ||
} | ||
} |
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,14 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity ^0.8.13; | ||
|
||
contract Counter { | ||
uint256 public number; | ||
|
||
function setNumber(uint256 newNumber) public { | ||
number = newNumber; | ||
} | ||
|
||
function increment() public { | ||
number++; | ||
} | ||
} |
Oops, something went wrong.