Skip to content

Commit

Permalink
feat: ProtocolHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
obatirou committed Oct 21, 2024
1 parent a4c4521 commit 9d804a3
Show file tree
Hide file tree
Showing 10 changed files with 886 additions and 0 deletions.
1 change: 1 addition & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ lint:
- cairo/token
- cairo/utils
- cairo/kakarot-ssj/crates
- cairo/protocol_handler
- linters: [ALL]
paths:
- logs*
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
125 changes: 125 additions & 0 deletions cairo/protocol_handler/Scarb.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# 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",
]

[[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",
]
20 changes: 20 additions & 0 deletions cairo/protocol_handler/Scarb.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "protocol_handler"
version = "0.1.0"
edition = "2023_10"

# 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" }

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

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

#[starknet::interface]
pub trait IKakarot<TContractState> {
//* ------------------------------------------------------------------------ *//
//* ADMIN FUNCTIONS *//
//* ------------------------------------------------------------------------ *//
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);

//* ------------------------------------------------------------------------ *//
//* STORAGE SETTING FUNCTIONS *//
//* ------------------------------------------------------------------------ *//
fn set_native_token(ref self: TContractState, native_token: ContractAddress);
fn set_base_fee(ref self: TContractState, base_fee: u64);
fn set_coinbase(ref self: TContractState, new_coinbase: ContractAddress);
fn set_prev_randao(ref self: TContractState, pre_randao: felt252);
fn set_block_gas_limit(ref self: TContractState, new_block_gas_limit: felt252);
fn set_account_contract_class_hash(ref self: TContractState, new_class_hash: felt252);
fn set_uninitialized_account_class_hash(ref self: TContractState, new_class_hash: felt252);
fn set_authorized_cairo_precompile_caller(
ref self: TContractState, evm_address: ContractAddress, authorized: bool
);
fn set_cairo1_helpers_class_hash(ref self: TContractState, new_class_hash: felt252);
fn upgrade_account(ref self: TContractState, evm_address: ContractAddress, new_class: felt252);
fn set_authorized_pre_eip155_tx(
ref self: TContractState, sender_address: ContractAddress, msg_hash: felt252
);
fn set_l1_messaging_contract_address(
ref self: TContractState, l1_messaging_contract_address: ContractAddress
);
}
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, IProtocolHandler, IProtocolHandlerDispatcher, IProtocolHandlerDispatcherTrait
};

mod kakarot_interface;
Loading

0 comments on commit 9d804a3

Please sign in to comment.