Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ProtocolHandler #1524

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/cairo-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: cairo-CI

on:
push:
branches:
- main
pull_request:
branches:
- "*"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

concurrency:
group: cairo-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions: read-all

jobs:
paths-filter:
runs-on: ubuntu-latest
outputs:
protocol_handler: ${{ steps.filter.outputs.protocol_handler }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
protocol_handler:
- 'cairo/protocol_handler/**'

tests-unit:
runs-on: ubuntu-latest
needs: paths-filter
if: needs.paths-filter.outputs.protocol_handler == 'true'
steps:
- uses: actions/checkout@v4
- uses: foundry-rs/setup-snfoundry@v3
- uses: software-mansion/setup-scarb@v1
with:
tool-versions: ./cairo/protocol_handler/.tool-versions

- name: Run tests
run: cd cairo/protocol_handler && scarb test
2 changes: 2 additions & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ lint:
- cairo/token
- cairo/utils
- cairo/kakarot-ssj/crates
- cairo/protocol_handler
- cairo/snforge_utils
- linters: [ALL]
paths:
- logs*
Expand Down
4 changes: 0 additions & 4 deletions cairo/kakarot-ssj/Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ dependencies = [
[[package]]
name = "snforge_utils"
version = "0.1.0"
dependencies = [
"evm",
"snforge_std",
]

[[package]]
name = "utils"
Expand Down
2 changes: 1 addition & 1 deletion cairo/kakarot-ssj/crates/contracts/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ name = "contracts"
[dev-dependencies]
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.31.0" }
assert_macros = "2.8.2"
snforge_utils = { path = "../snforge_utils" }
snforge_utils = { path = "../../../snforge_utils" }

[scripts]
test = "snforge test --max-n-steps 4294967295"
Expand Down
2 changes: 1 addition & 1 deletion cairo/kakarot-ssj/crates/evm/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ garaga = { git = "https://github.com/keep-starknet-strange/garaga.git" }

[dev-dependencies]
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.31.0" }
snforge_utils = { path = "../snforge_utils" }
snforge_utils = { path = "../../../snforge_utils" }
assert_macros = "2.8.2"

[tool]
Expand Down
1 change: 1 addition & 0 deletions cairo/protocol_handler/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target
2 changes: 2 additions & 0 deletions cairo/protocol_handler/.tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
scarb 2.8.3
starknet-foundry 0.31.0
130 changes: 130 additions & 0 deletions cairo/protocol_handler/Scarb.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Code generated by scarb DO NOT EDIT.
version = 1

[[package]]
name = "openzeppelin"
version = "0.17.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.17.0#bf5d02c25c989ccc24f3ab42ec649617d3f21289"
dependencies = [
"openzeppelin_access",
"openzeppelin_account",
"openzeppelin_finance",
"openzeppelin_governance",
"openzeppelin_introspection",
"openzeppelin_merkle_tree",
"openzeppelin_presets",
"openzeppelin_security",
"openzeppelin_token",
"openzeppelin_upgrades",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_access"
version = "0.17.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.17.0#bf5d02c25c989ccc24f3ab42ec649617d3f21289"
dependencies = [
"openzeppelin_introspection",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_account"
version = "0.17.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.17.0#bf5d02c25c989ccc24f3ab42ec649617d3f21289"
dependencies = [
"openzeppelin_introspection",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_finance"
version = "0.17.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.17.0#bf5d02c25c989ccc24f3ab42ec649617d3f21289"
dependencies = [
"openzeppelin_access",
"openzeppelin_token",
]

[[package]]
name = "openzeppelin_governance"
version = "0.17.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.17.0#bf5d02c25c989ccc24f3ab42ec649617d3f21289"
dependencies = [
"openzeppelin_access",
"openzeppelin_introspection",
]

[[package]]
name = "openzeppelin_introspection"
version = "0.17.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.17.0#bf5d02c25c989ccc24f3ab42ec649617d3f21289"

[[package]]
name = "openzeppelin_merkle_tree"
version = "0.17.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.17.0#bf5d02c25c989ccc24f3ab42ec649617d3f21289"

[[package]]
name = "openzeppelin_presets"
version = "0.17.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.17.0#bf5d02c25c989ccc24f3ab42ec649617d3f21289"
dependencies = [
"openzeppelin_access",
"openzeppelin_account",
"openzeppelin_finance",
"openzeppelin_introspection",
"openzeppelin_token",
"openzeppelin_upgrades",
]

[[package]]
name = "openzeppelin_security"
version = "0.17.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.17.0#bf5d02c25c989ccc24f3ab42ec649617d3f21289"

[[package]]
name = "openzeppelin_token"
version = "0.17.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.17.0#bf5d02c25c989ccc24f3ab42ec649617d3f21289"
dependencies = [
"openzeppelin_account",
"openzeppelin_governance",
"openzeppelin_introspection",
]

[[package]]
name = "openzeppelin_upgrades"
version = "0.17.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.17.0#bf5d02c25c989ccc24f3ab42ec649617d3f21289"

[[package]]
name = "openzeppelin_utils"
version = "0.17.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.17.0#bf5d02c25c989ccc24f3ab42ec649617d3f21289"

[[package]]
name = "protocol_handler"
version = "0.1.0"
dependencies = [
"openzeppelin",
"snforge_std",
"snforge_utils",
]

[[package]]
name = "snforge_scarb_plugin"
version = "0.31.0"
source = "git+https://github.com/foundry-rs/starknet-foundry.git?tag=v0.31.0#72ea785ca354e9e506de3e5d687da9fb2c1b3c67"

[[package]]
name = "snforge_std"
version = "0.31.0"
source = "git+https://github.com/foundry-rs/starknet-foundry.git?tag=v0.31.0#72ea785ca354e9e506de3e5d687da9fb2c1b3c67"
dependencies = [
"snforge_scarb_plugin",
]

[[package]]
name = "snforge_utils"
version = "0.1.0"
21 changes: 21 additions & 0 deletions cairo/protocol_handler/Scarb.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "protocol_handler"
version = "0.1.0"
edition = "2024_07"

# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html

[dependencies]
starknet = "2.8.2"
openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.17.0" }

[dev-dependencies]
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.31.0" }
snforge_utils = { path = "../snforge_utils" }

[[target.starknet-contract]]
casm = true
casm-add-pythonic-hints = true

[scripts]
test = "snforge test"
10 changes: 10 additions & 0 deletions cairo/protocol_handler/src/kakarot_interface.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use starknet::{ContractAddress, ClassHash};

#[starknet::interface]
pub trait IKakarot<TContractState> {
fn upgrade(ref self: TContractState, new_class_hash: ClassHash);
fn transfer_ownership(ref self: TContractState, new_owner: ContractAddress);
fn pause(ref self: TContractState);
fn unpause(ref self: TContractState);
fn set_base_fee(ref self: TContractState, new_base_fee: felt252);
}
6 changes: 6 additions & 0 deletions cairo/protocol_handler/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mod protocol_handler;
pub use protocol_handler::{
ProtocolHandler, IProtocolHandlerDispatcher, IProtocolHandlerDispatcherTrait,
IProtocolHandlerSafeDispatcher, IProtocolHandlerSafeDispatcherTrait
};
mod kakarot_interface;
Loading
Loading