generated from keep-starknet-strange/alexandria
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* gc -m "feat: implement eoa balance" * feat: add test * feat: update internal of exec_balance * refactor: refactoring balance to not call * refactor: delete kakarot_core_native_token * chore: fmt * refactor: put openzeppelin into its own crate * refactor: rename core contracts * refactor: clean up and implement comments from pr review * refactor: use contract_address_const more * Update crates/evm/src/instructions/environmental_information.cairo Co-authored-by: Mathieu <[email protected]> * Update crates/evm/src/instructions/environmental_information.cairo Co-authored-by: Mathieu <[email protected]> * fix: fix pr comment --------- Co-authored-by: Mathieu <[email protected]>
- Loading branch information
Showing
26 changed files
with
722 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
crates/core_contracts/Scarb.toml → crates/contracts/Scarb.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
[package] | ||
name = "core_contracts" | ||
name = "contracts" | ||
version = "0.1.0" | ||
|
||
# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html | ||
|
||
[dependencies] | ||
starknet.workspace = true | ||
evm = { path = "../evm" } | ||
openzeppelin = { path = "../openzeppelin" } | ||
|
||
[tool.fmt] | ||
sort-module-level-items = true |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
mod interface; | ||
mod kakarot; | ||
|
||
use kakarot::{KakarotCore, ContractAccountStorage}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
use contracts::kakarot_core::ContractAccountStorage; | ||
use starknet::{ContractAddress, EthAddress, ClassHash}; | ||
|
||
#[starknet::interface] | ||
trait IKakarotCore<TContractState> { | ||
/// Sets the native token, this token will be considered the native coin in the Ethereum sense | ||
fn set_native_token(ref self: TContractState, native_token: ContractAddress); | ||
|
||
/// Gets the native token used by the Kakarot smart contract | ||
fn native_token(self: @TContractState) -> ContractAddress; | ||
|
||
/// Sets the deploy fee for an EOA | ||
/// Currently, the Kakarot RPC can trigger an EOA deployment, | ||
/// and optimistically fund it. | ||
/// Then, the KakarotCore smart contract is able to levy this fee retroactively from the EOA | ||
/// And reimburse the RPC's smart wallet. | ||
fn set_deploy_fee(ref self: TContractState, deploy_fee: u128); | ||
|
||
/// Get the deploy fee | ||
fn deploy_fee(self: @TContractState) -> u128; | ||
|
||
/// Deterministically computes a Starknet address for an given EVM address | ||
/// The address is computed as the Starknet address corresponding to the deployment of an EOA, | ||
/// Using its EVM address as salt, and KakarotCore as deployer. | ||
fn compute_starknet_address(self: @TContractState, evm_address: EthAddress) -> ContractAddress; | ||
|
||
/// Checks into KakarotCore storage if an EOA has been deployed for a | ||
/// particular EVM address and if so, returns its corresponding Starknet Address. | ||
/// Otherwise, returns 0 | ||
fn eoa_starknet_address(self: @TContractState, evm_address: EthAddress) -> ContractAddress; | ||
|
||
/// Gets the storage associated to a contract account | ||
fn contract_account_storage( | ||
self: @TContractState, evm_address: EthAddress | ||
) -> ContractAccountStorage; | ||
|
||
/// Deploys an EOA for a particular EVM address | ||
fn deploy_eoa(ref self: TContractState, evm_address: EthAddress) -> ContractAddress; | ||
|
||
/// View entrypoint into the EVM | ||
/// Performs view calls into the blockchain | ||
/// It cannot modify the state of the chain | ||
fn eth_call( | ||
self: @TContractState, | ||
from: EthAddress, | ||
to: EthAddress, | ||
gas_limit: u128, | ||
gas_price: u128, | ||
value: u128, | ||
data: Span<u8> | ||
) -> Span<u8>; | ||
|
||
/// Transaction entrypoint into the EVM | ||
/// Executes an EVM transaction and possibly modifies the state | ||
fn eth_send_transaction( | ||
ref self: TContractState, | ||
to: EthAddress, | ||
gas_limit: u128, | ||
gas_price: u128, | ||
value: u128, | ||
data: Span<u8> | ||
) -> Span<u8>; | ||
|
||
/// Upgrade the KakarotCore smart contract | ||
/// Using replace_class_syscall | ||
fn upgrade(ref self: TContractState, new_class_hash: ClassHash); | ||
} | ||
|
||
#[starknet::interface] | ||
trait IExtendedKakarotCore<TContractState> { | ||
/// Sets the native token, this token will be considered the native coin in the Ethereum sense | ||
fn set_native_token(ref self: TContractState, native_token: ContractAddress); | ||
|
||
/// Gets the native token used by the Kakarot smart contract | ||
fn native_token(self: @TContractState) -> ContractAddress; | ||
|
||
/// Sets the deploy fee for an EOA | ||
/// Currently, the Kakarot RPC can trigger an EOA deployment, | ||
/// and optimistically fund it. | ||
/// Then, the KakarotCore smart contract is able to levy this fee retroactively from the EOA | ||
/// And reimburse the RPC's smart wallet. | ||
fn set_deploy_fee(ref self: TContractState, deploy_fee: u128); | ||
|
||
/// Get the deploy fee | ||
fn deploy_fee(self: @TContractState) -> u128; | ||
|
||
/// Deterministically computes a Starknet address for an given EVM address | ||
/// The address is computed as the Starknet address corresponding to the deployment of an EOA, | ||
/// Using its EVM address as salt, and KakarotCore as deployer. | ||
fn compute_starknet_address(self: @TContractState, evm_address: EthAddress) -> ContractAddress; | ||
|
||
/// Checks into KakarotCore storage if an EOA has been deployed for a | ||
/// particular EVM address and if so, returns its corresponding Starknet Address | ||
fn eoa_starknet_address(self: @TContractState, evm_address: EthAddress) -> ContractAddress; | ||
|
||
|
||
/// Gets the storage associated to a contract account | ||
fn contract_account_storage( | ||
self: @TContractState, evm_address: EthAddress | ||
) -> ContractAccountStorage; | ||
|
||
/// Deploys an EOA for a particular EVM address | ||
fn deploy_eoa(ref self: TContractState, evm_address: EthAddress) -> ContractAddress; | ||
|
||
/// View entrypoint into the EVM | ||
/// Performs view calls into the blockchain | ||
/// It cannot modify the state of the chain | ||
fn eth_call( | ||
self: @TContractState, | ||
from: EthAddress, | ||
to: EthAddress, | ||
gas_limit: u128, | ||
gas_price: u128, | ||
value: u128, | ||
data: Span<u8> | ||
) -> Span<u8>; | ||
|
||
/// Transaction entrypoint into the EVM | ||
/// Executes an EVM transaction and possibly modifies the state | ||
fn eth_send_transaction( | ||
ref self: TContractState, | ||
to: EthAddress, | ||
gas_limit: u128, | ||
gas_price: u128, | ||
value: u128, | ||
data: Span<u8> | ||
) -> Span<u8>; | ||
|
||
/// Upgrade the KakarotCore smart contract | ||
/// Using replace_class_syscall | ||
fn upgrade(ref self: TContractState, new_class_hash: ClassHash); | ||
|
||
fn owner(self: @TContractState) -> ContractAddress; | ||
fn transfer_ownership(ref self: TContractState, new_owner: ContractAddress); | ||
fn renounce_ownership(ref self: TContractState); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
Oops, something went wrong.