-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
32 additions
and
48 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,4 +1,3 @@ | ||
pub(crate) mod dict_access; | ||
pub(crate) mod new_syscalls; | ||
pub(crate) mod structs; | ||
pub(crate) mod traits; |
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,21 +1,25 @@ | ||
use cairo_type_derive::FieldOffsetGetters; | ||
use crate::cairo_types::traits::CairoType; | ||
use cairo_type_derive::{CairoType, FieldOffsetGetters}; | ||
use cairo_vm::types::relocatable::Relocatable; | ||
use cairo_vm::vm::errors::memory_errors::MemoryError; | ||
use cairo_vm::vm::vm_core::VirtualMachine; | ||
use cairo_vm::Felt252; | ||
|
||
#[allow(unused)] | ||
#[derive(FieldOffsetGetters)] | ||
#[derive(FieldOffsetGetters, CairoType)] | ||
pub struct CallContractRequest { | ||
// The address of the L2 contract to call. | ||
contract_address: Felt252, | ||
pub contract_address: Felt252, | ||
// The selector of the function to call. | ||
selector: Felt252, | ||
pub selector: Felt252, | ||
// The calldata. | ||
calldata_start: Felt252, | ||
calldata_end: Felt252, | ||
pub calldata_start: Felt252, | ||
pub calldata_end: Felt252, | ||
} | ||
|
||
#[allow(unused)] | ||
#[derive(FieldOffsetGetters)] | ||
#[derive(FieldOffsetGetters, CairoType)] | ||
pub struct CallContractResponse { | ||
retdata_start: Felt252, | ||
retdata_end: Felt252, | ||
pub retdata_start: Felt252, | ||
pub retdata_end: Felt252, | ||
} |
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
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,26 +1,36 @@ | ||
use super::utils::{SyscallHandler, SyscallResult, WriteResponseResult}; | ||
use crate::cairo_types::new_syscalls::{CallContractRequest, CallContractResponse}; | ||
use cairo_vm::{types::relocatable::Relocatable, vm::vm_core::VirtualMachine}; | ||
use crate::cairo_types::{ | ||
new_syscalls::{CallContractRequest, CallContractResponse}, | ||
traits::CairoType, | ||
}; | ||
use cairo_vm::{types::relocatable::Relocatable, vm::vm_core::VirtualMachine, Felt252}; | ||
|
||
pub struct CallContractHandler; | ||
|
||
impl SyscallHandler for CallContractHandler { | ||
type Request = CallContractRequest; | ||
type Response = CallContractResponse; | ||
|
||
fn read_request(_vm: &VirtualMachine, _ptr: &mut Relocatable) -> SyscallResult<Self::Request> { | ||
todo!() | ||
fn read_request(vm: &VirtualMachine, ptr: &mut Relocatable) -> SyscallResult<Self::Request> { | ||
let ret = Self::Request::from_memory(vm, *ptr)?; | ||
*ptr = (*ptr + Self::Request::cairo_size())?; | ||
Ok(ret) | ||
} | ||
|
||
fn execute(_request: Self::Request, _vm: &mut VirtualMachine) -> SyscallResult<Self::Response> { | ||
todo!() | ||
Ok(Self::Response { | ||
retdata_start: Felt252::from(6_u32), | ||
retdata_end: Felt252::from(9_u32), | ||
}) | ||
} | ||
|
||
fn write_response( | ||
_response: Self::Response, | ||
_vm: &mut VirtualMachine, | ||
_ptr: &mut Relocatable, | ||
response: Self::Response, | ||
vm: &mut VirtualMachine, | ||
ptr: &mut Relocatable, | ||
) -> WriteResponseResult { | ||
todo!() | ||
response.to_memory(vm, *ptr)?; | ||
*ptr = (*ptr + Self::Response::cairo_size())?; | ||
Ok(()) | ||
} | ||
} |