Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

Commit e5ade6c

Browse files
0xNeshijulio4
andauthored
Feature: L1 <> L2 messaging with Token Bridge example (#253)
* Add token bridge scaffold * Create L2 bridge * Add tests for L2 bridge * Add solidity bridge contract * rename consumeMessage->consumeWithdrawal & initiateWithdrawal->bridgeToL2 + implement consumeWithdrawal * Rename initiate_withdrawal->bridge_to_l1 * make TokenBridge work + add tests * Add ability to set l2bridge post deployment * Add ability to set l1bridge and token post deployment to cairo * Add getters + pass governor in ctor * Split uint256 amount to low/high before bridging to L2 * TokenBridge: remove token from ctor + token ops limited to bridge * Move starknet contracts to lib * leave source to orig strk mess local * make l2 handler selector customizable * manually set token and l1 bridge address in STRK * MintableTokenMock: OnlyBridge->Unauthorized * Strk: set token post-ctor + add missing mock token * add comments to contract.cairo * Remove cache and out from solidity * move ./cairo contents to root folder * mintableToken->token * Remove redundant l1_bridge felt252 init in tests * mocks.cairo->mintable_token_mock.cairo * Update the .md file * remove TokenBridge @author tag * Update edition to point to workspace * Prepare release 2.8.2 (#257) * dep: fix patch to latest shikijs for cairo hl * fix(app): correct sidebar placement * fix(app): responsive content centering * fix(app): responsive content centering * doc: branch guidelines * fix(app): top section nav links * fix(app): correct sidebar placement * fix(app): responsive content centering * fix(app): responsive content centering * Update issue templates, Close #273 close #273 * add missing edition to CONTRITUTING > adding new cairo program * remove src/SUMMARY * fix typos * fix typos target in CONTRIBUTING example * fix test path to MintableTokenMock * revert changes to pnpm-lock * remove openzeppelin dep * fix fmt errors in tests * fix fmt errors contract.cairo * remove redundant comma --------- Co-authored-by: Julio <[email protected]>
1 parent f50bfe4 commit e5ade6c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+29078
-1
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Be sure to check for typos with `typos`:
8484

8585
```bash
8686
cargo install typos-cli
87-
typos src/
87+
typos pages/
8888
```
8989

9090
## Adding a new Cairo program
@@ -101,6 +101,7 @@ Here's the required `Scarb.toml` configuration for **Starknet Foundry**:
101101
[package]
102102
name = "pkg_name"
103103
version.workspace = true
104+
edition.workspace = true
104105

105106
# Specify that this can be used as a dependency in another scarb project:
106107
[lib]
@@ -135,6 +136,7 @@ Here's the required `Scarb.toml` configuration for **cairo-test**:
135136
[package]
136137
name = "pkg_name"
137138
version.workspace = true
139+
edition.workspace = true
138140

139141
# Specify that this can be used as a dependency in another scarb project:
140142
[lib]

Scarb.lock

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,17 @@ version = "0.1.0"
133133
name = "hash_trait"
134134
version = "0.1.0"
135135

136+
[[package]]
137+
name = "interfaces_traits"
138+
version = "0.1.0"
139+
140+
[[package]]
141+
name = "l1_l2_token_bridge"
142+
version = "0.1.0"
143+
dependencies = [
144+
"snforge_std",
145+
]
146+
136147
[[package]]
137148
name = "library_calls"
138149
version = "0.1.0"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
target
2+
.snfoundry_cache/
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[package]
2+
name = "l1_l2_token_bridge"
3+
version.workspace = true
4+
edition.workspace = true
5+
6+
[dependencies]
7+
starknet.workspace = true
8+
9+
[dev-dependencies]
10+
assert_macros.workspace = true
11+
snforge_std.workspace = true
12+
13+
[scripts]
14+
test.workspace = true
15+
16+
[[target.starknet-contract]]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cache
2+
out
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
## Foundry
2+
3+
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**
4+
5+
Foundry consists of:
6+
7+
- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
8+
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
9+
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
10+
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.
11+
12+
## Documentation
13+
14+
https://book.getfoundry.sh/
15+
16+
## Usage
17+
18+
### Build
19+
20+
```shell
21+
$ forge build
22+
```
23+
24+
### Test
25+
26+
```shell
27+
$ forge test
28+
```
29+
30+
### Format
31+
32+
```shell
33+
$ forge fmt
34+
```
35+
36+
### Gas Snapshots
37+
38+
```shell
39+
$ forge snapshot
40+
```
41+
42+
### Anvil
43+
44+
```shell
45+
$ anvil
46+
```
47+
48+
### Deploy
49+
50+
```shell
51+
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
52+
```
53+
54+
### Cast
55+
56+
```shell
57+
$ cast <subcommand>
58+
```
59+
60+
### Help
61+
62+
```shell
63+
$ forge --help
64+
$ anvil --help
65+
$ cast --help
66+
```
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[profile.default]
2+
src = "src"
3+
out = "out"
4+
libs = ["lib"]
5+
6+
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
7+
remappings = ["starknet/=lib/starknet/"]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/Vm.sol linguist-generated
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: CI
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- master
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Install Foundry
17+
uses: foundry-rs/foundry-toolchain@v1
18+
with:
19+
version: nightly
20+
21+
- name: Print forge version
22+
run: forge --version
23+
24+
# Backwards compatibility checks:
25+
# - the oldest and newest version of each supported minor version
26+
# - versions with specific issues
27+
- name: Check compatibility with latest
28+
if: always()
29+
run: |
30+
output=$(forge build --skip test)
31+
if echo "$output" | grep -q "Warning"; then
32+
echo "$output"
33+
exit 1
34+
fi
35+
36+
- name: Check compatibility with 0.8.0
37+
if: always()
38+
run: |
39+
output=$(forge build --skip test --use solc:0.8.0)
40+
if echo "$output" | grep -q "Warning"; then
41+
echo "$output"
42+
exit 1
43+
fi
44+
45+
- name: Check compatibility with 0.7.6
46+
if: always()
47+
run: |
48+
output=$(forge build --skip test --use solc:0.7.6)
49+
if echo "$output" | grep -q "Warning"; then
50+
echo "$output"
51+
exit 1
52+
fi
53+
54+
- name: Check compatibility with 0.7.0
55+
if: always()
56+
run: |
57+
output=$(forge build --skip test --use solc:0.7.0)
58+
if echo "$output" | grep -q "Warning"; then
59+
echo "$output"
60+
exit 1
61+
fi
62+
63+
- name: Check compatibility with 0.6.12
64+
if: always()
65+
run: |
66+
output=$(forge build --skip test --use solc:0.6.12)
67+
if echo "$output" | grep -q "Warning"; then
68+
echo "$output"
69+
exit 1
70+
fi
71+
72+
- name: Check compatibility with 0.6.2
73+
if: always()
74+
run: |
75+
output=$(forge build --skip test --use solc:0.6.2)
76+
if echo "$output" | grep -q "Warning"; then
77+
echo "$output"
78+
exit 1
79+
fi
80+
81+
# via-ir compilation time checks.
82+
- name: Measure compilation time of Test with 0.8.17 --via-ir
83+
if: always()
84+
run: forge build --skip test --contracts test/compilation/CompilationTest.sol --use solc:0.8.17 --via-ir
85+
86+
- name: Measure compilation time of TestBase with 0.8.17 --via-ir
87+
if: always()
88+
run: forge build --skip test --contracts test/compilation/CompilationTestBase.sol --use solc:0.8.17 --via-ir
89+
90+
- name: Measure compilation time of Script with 0.8.17 --via-ir
91+
if: always()
92+
run: forge build --skip test --contracts test/compilation/CompilationScript.sol --use solc:0.8.17 --via-ir
93+
94+
- name: Measure compilation time of ScriptBase with 0.8.17 --via-ir
95+
if: always()
96+
run: forge build --skip test --contracts test/compilation/CompilationScriptBase.sol --use solc:0.8.17 --via-ir
97+
98+
test:
99+
runs-on: ubuntu-latest
100+
steps:
101+
- uses: actions/checkout@v4
102+
103+
- name: Install Foundry
104+
uses: foundry-rs/foundry-toolchain@v1
105+
with:
106+
version: nightly
107+
108+
- name: Print forge version
109+
run: forge --version
110+
111+
- name: Run tests
112+
run: forge test -vvv
113+
114+
fmt:
115+
runs-on: ubuntu-latest
116+
steps:
117+
- uses: actions/checkout@v4
118+
119+
- name: Install Foundry
120+
uses: foundry-rs/foundry-toolchain@v1
121+
with:
122+
version: nightly
123+
124+
- name: Print forge version
125+
run: forge --version
126+
127+
- name: Check formatting
128+
run: forge fmt --check
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Sync Release Branch
2+
3+
on:
4+
release:
5+
types:
6+
- created
7+
8+
jobs:
9+
sync-release-branch:
10+
runs-on: ubuntu-latest
11+
if: startsWith(github.event.release.tag_name, 'v1')
12+
steps:
13+
- name: Check out the repo
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
ref: v1
18+
19+
# The email is derived from the bots user id,
20+
# found here: https://api.github.com/users/github-actions%5Bbot%5D
21+
- name: Configure Git
22+
run: |
23+
git config user.name github-actions[bot]
24+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
25+
26+
- name: Sync Release Branch
27+
run: |
28+
git fetch --tags
29+
git checkout v1
30+
git reset --hard ${GITHUB_REF}
31+
git push --force

0 commit comments

Comments
 (0)