Skip to content
This repository was archived by the owner on Dec 3, 2024. It is now read-only.

Commit

Permalink
setting up forge project
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Lam committed Feb 7, 2024
1 parent 48b55b4 commit 9bc9ef7
Show file tree
Hide file tree
Showing 21 changed files with 547 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: Bug report
about: Create a report to help us improve
title: '[Bug]: '
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior.

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Logs**
If applicable, please include the relevant logs that indicate a problem.

**Operating System**
Which OS you used to reveal the bug.

**Additional context**
Add any other context about the problem here.

**To best protect the Avalanche community security bugs should be reported in accordance to our [Security Policy](../../SECURITY.md)**
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: Feature specification
about: Discussion on design and implementation of new features for teleporter-token-bridge.
title: ""
labels: enhancement
assignees: ""
---

**Context and scope**
Include a short description of the context and scope of the suggested feature.
Include goals the change will accomplish if relevant.

**Discussion and alternatives**
Include a description of the changes to be made to the code along with alternatives
that were considered, including pro/con analysis where relevant.

**Open questions**
Questions that are still being discussed.
7 changes: 7 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Why this should be merged

## How this works

## How this was tested

## How is this documented
41 changes: 41 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Linter

on:
push:
branches:
- main
pull_request:
branches:
- "*"

jobs:
solhint:
runs-on: ubuntu-20.04
steps:
- name: Checkout teleporter
uses: actions/checkout@v4

- name: Install solhint
run: |
npm install solhint -g
solhint --version
- name: Run Lint
run: ./scripts/lint.sh --sol-lint

format-solidity:
runs-on: ubuntu-20.04
timeout-minutes: 10
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Foundry
run: ./scripts/install_foundry.sh

- name: Check Solidity Formatting
run: |
export PATH=$PATH:$HOME/.foundry/bin
./scripts/lint.sh --sol-format-check
28 changes: 28 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Tests

on:
push:
branches:
- main
pull_request:
branches:
- "*"

jobs:
solidity-unit-tests:
runs-on: ubuntu-20.04
timeout-minutes: 10
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Foundry
run: ./scripts/install_foundry.sh

- name: Run unit tests
run: |
export PATH=$PATH:$HOME/.foundry/bin
cd contracts/
forge test -vvv
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Forge output files
out/
cache/
target/
bin/
Cargo.lock

# IDE configurations
.vscode*
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "contracts/lib/forge-std"]
path = contracts/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "contracts/lib/teleporter"]
path = contracts/lib/teleporter
url = https://github.com/ava-labs/teleporter
66 changes: 66 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
Copyright (C) 2024, Ava Labs, Inc. All rights reserved.

Ecosystem License
Version: 1.1

Subject to the terms herein, Ava Labs, Inc. (**“Ava Labs”**) hereby grants you
a limited, royalty-free, worldwide, non-sublicensable, non-transferable,
non-exclusive license to use, copy, modify, create derivative works based on,
and redistribute the Software, in source code, binary, or any other form,
including any modifications or derivative works of the Software (collectively,
**“Licensed Software”**), in each case subject to this Ecosystem License
(**“License”**).

This License applies to all copies, modifications, derivative works, and any
other form or usage of the Licensed Software. You will include and display
this License, without modification, with all uses of the Licensed Software,
regardless of form.

You will use the Licensed Software solely (i) in connection with the Avalanche
Public Blockchain platform, having a NetworkID of 1 (Mainnet) or 5 (Fuji), and
associated blockchains, comprised exclusively of the Avalanche X-Chain,
C-Chain, P-Chain and any subnets linked to the P-Chain (“Avalanche Authorized
Platform”) or (ii) for non-production, testing or research purposes within the
Avalanche ecosystem, in each case, without any commercial application
(“Non-Commercial Use”); provided that this License does not permit use of the
Licensed Software in connection with (a) any forks of the Avalanche Authorized
Platform or (b) in any manner not operationally connected to the Avalanche
Authorized Platform other than, for the avoidance of doubt, the limited
exception for Non-Commercial Use. Ava Labs may publicly announce changes or
additions to the Avalanche Authorized Platform, which may expand or modify
usage of the Licensed Software. Upon such announcement, the Avalanche
Authorized Platform will be deemed to be the then-current iteration of such
platform.

You hereby acknowledge and agree to the terms set forth at
www.avalabs.org/important-notice.

If you use the Licensed Software in violation of this License, this License
will automatically terminate and Ava Labs reserves all rights to seek any
remedy for such violation.

Except for uses explicitly permitted in this License, Ava Labs retains all
rights in the Licensed Software, including without limitation the ability to
modify it.

Except as required or explicitly permitted by this License, you will not use
any Ava Labs names, logos, or trademarks without Ava Labs’ prior written
consent.

You may use this License for software other than the “Licensed Software”
specified above, as long as the only change to this License is the definition
of the term “Licensed Software.”

The Licensed Software may reference third party components. You acknowledge
and agree that these third party components may be governed by a separate
license or terms and that you will comply with them.

**TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE LICENSED SOFTWARE IS PROVIDED
ON AN “AS IS” BASIS, AND AVA LABS EXPRESSLY DISCLAIMS AND EXCLUDES ALL
REPRESENTATIONS, WARRANTIES AND OTHER TERMS AND CONDITIONS, WHETHER EXPRESS OR
IMPLIED, INCLUDING WITHOUT LIMITATION BY OPERATION OF LAW OR BY CUSTOM,
STATUTE OR OTHERWISE, AND INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED WARRANTY,
TERM, OR CONDITION OF NON-INFRINGEMENT, MERCHANTABILITY, TITLE, OR FITNESS FOR
PARTICULAR PURPOSE. YOU USE THE LICENSED SOFTWARE AT YOUR OWN RISK. AVA LABS
EXPRESSLY DISCLAIMS ALL LIABILITY (INCLUDING FOR ALL DIRECT, CONSEQUENTIAL OR
OTHER DAMAGES OR LOSSES) RELATED TO ANY USE OF THE LICENSED SOFTWARE.**
17 changes: 17 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Security Policy

Avalanche takes the security of the platform and of its users very seriously. We and our community recognize the critical role of external security researchers and developers and welcome responsible disclosures. Valid reports will be eligible for a reward (terms and conditions apply).

## Reporting a Vulnerability

**Please do not file a public ticket** mentioning the vulnerability. To disclose a vulnerability submit it through our [Bug Bounty Program](https://hackenproof.com/avalanche).

Vulnerabilities must be disclosed to us privately with reasonable time to respond, and avoid compromise of other users and accounts, or loss of funds that are not your own. We do not reward spam or social engineering vulnerabilities.

Do not test for or validate any security issues in the live Avalanche networks (Mainnet and Fuji testnet), confirm all exploits in a local private testnet.

Please refer to the [Bug Bounty Page](https://hackenproof.com/avalanche) for the most up-to-date program rules and scope.

## Supported Versions

Please use the most recently released version to perform testing and to validate security issues.
66 changes: 66 additions & 0 deletions contracts/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
```
27 changes: 27 additions & 0 deletions contracts/foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[profile.default]
src = "src"
out = "out"
libs = ["lib"]
solc_version = '0.8.18'

[fmt]
line_length = 100
tab_width = 4
bracket_spacing = false
int_types = 'preserve'
multiline_func_header = 'params_first'
quote_style = 'double'
number_underscores = 'thousands'
override_spacing = true
wrap_comments = false

# Add the following to your VSCode settings to enable automatic formatting.
# {
# "editor.formatOnSave": true,
# "[solidity]": {
# "editor.defaultFormatter": "JuanBlanco.solidity"
# },
# "solidity.formatter": "forge",
# }

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
1 change: 1 addition & 0 deletions contracts/lib/forge-std
Submodule forge-std added at ae570f
1 change: 1 addition & 0 deletions contracts/lib/teleporter
Submodule teleporter added at bedf79
12 changes: 12 additions & 0 deletions contracts/script/Counter.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Script, console2} from "forge-std/Script.sol";

contract CounterScript is Script {
function setUp() public {}

function run() public {
vm.broadcast();
}
}
35 changes: 35 additions & 0 deletions contracts/src/.solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"extends": "solhint:recommended",
"rules": {
"compiler-version": ["error", "0.8.18"],
"no-unused-vars": "error",
"func-visibility": [
"error",
{
"ignoreConstructors": true
}
],
"private-vars-leading-underscore": [
"warn",
{
"strict": true
}
],
"reason-string": [
"warn",
{
"maxLength": 75
}
],
"custom-errors": "off",
"ordering": "error",
"immutable-vars-naming": [
"warn",
{
"immutablesAsConstants": false
}
],
"func-named-parameters": ["error", 5],
"one-contract-per-file": "off"
}
}
Empty file added contracts/src/.solhintignore
Empty file.
14 changes: 14 additions & 0 deletions contracts/src/Counter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.18;

contract Counter {
uint256 public number;

function setNumber(uint256 newNumber) public {
number = newNumber;
}

function increment() public {
number++;
}
}
Loading

0 comments on commit 9bc9ef7

Please sign in to comment.