Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-gray authored Oct 15, 2024
0 parents commit b530862
Show file tree
Hide file tree
Showing 36 changed files with 3,761 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .cspell/custom-dictionary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Custom Dictionary Words
Aptos
Devnet
Ruleset
Rulesets
Solana
45 changes: 45 additions & 0 deletions .github/workflows/evm.yml
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
26 changes: 26 additions & 0 deletions .github/workflows/format.yml
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
33 changes: 33 additions & 0 deletions .github/workflows/svm.yml
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
3 changes: 3 additions & 0 deletions .gitmodules
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
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
evm/cache/
evm/lib/
evm/out/
14 changes: 14 additions & 0 deletions .vscode/extensions.json
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": []
}
9 changes: 9 additions & 0 deletions .vscode/settings.json
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"
}
13 changes: 13 additions & 0 deletions LICENSE
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.
85 changes: 85 additions & 0 deletions README.md
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)
15 changes: 15 additions & 0 deletions cspell.json
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": []
}
14 changes: 14 additions & 0 deletions evm/.gitignore
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
66 changes: 66 additions & 0 deletions evm/README.md
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
```
6 changes: 6 additions & 0 deletions evm/foundry.toml
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
1 change: 1 addition & 0 deletions evm/lib/forge-std
Submodule forge-std added at 1714be
12 changes: 12 additions & 0 deletions evm/script/Counter.s.sol
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();
}
}
14 changes: 14 additions & 0 deletions evm/src/Counter.sol
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++;
}
}
Loading

0 comments on commit b530862

Please sign in to comment.