Skip to content

Commit

Permalink
cairo0 new syscall pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Okm165 committed Feb 6, 2025
1 parent 09b6e11 commit 2b0a4c6
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use types::cairo::{

use crate::{traits, SyscallResult, WriteResponseResult};

pub const CONTRACT_ADDRESS: Felt252 = Felt252::from_hex_unchecked("0x616e795f74797065"); // 'any_type' in hex
pub const CONTRACT_ADDRESS: Felt252 = Felt252::from_hex_unchecked("0x6172626974726172795F74797065"); // 'arbitrary_type' in hex

#[derive(Debug, Default, Serialize, Deserialize, Clone)]
pub struct ArbitraryTypeCallContractHandler;
Expand Down
2 changes: 1 addition & 1 deletion examples/hdp_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@
"0x20680017fff7ffd",
"0x7d",
"0x480680017fff8000",
"0x616e795f74797065",
"0x6172626974726172795f74797065",
"0xa0680017fff8004",
"0xe",
"0x4824800180047ffe",
Expand Down
4 changes: 2 additions & 2 deletions examples/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[starknet::contract]
mod example {
use hdp_cairo::{HDP, evm::storage::{StorageImpl}, any_type::any_type};
use hdp_cairo::{HDP, evm::storage::{StorageImpl}, arbitrary_type::arbitrary_type};
use hdp_cairo::debug::{print_array};

#[storage]
Expand All @@ -27,7 +27,7 @@ mod example {
s.serialize(ref s_obj_serialized);
print_array(s_obj_serialized);

let d: AnyTypeOutput = any_type(s);
let d: AnyTypeOutput = arbitrary_type(s);

let mut d_obj_serialized = array![];
d.serialize(ref d_obj_serialized);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use starknet::syscalls::call_contract_syscall;
use starknet::SyscallResultTrait;

const ANY_TYPE_CONTRACT_ADDRESS: felt252 = 'any_type';
const ARBITRARY_TYPE_CONTRACT_ADDRESS: felt252 = 'arbitrary_type';

pub fn any_type<S, +core::serde::Serde<S>, +Drop<S>, D, +core::serde::Serde<D>>(obj: S) -> D {
pub fn arbitrary_type<S, +core::serde::Serde<S>, +Drop<S>, D, +core::serde::Serde<D>>(obj: S) -> D {
let mut obj_serialized = array![];
obj.serialize(ref obj_serialized);

let mut ret = call_contract_syscall(
ANY_TYPE_CONTRACT_ADDRESS.try_into().unwrap(), 0, obj_serialized.span(),
ARBITRARY_TYPE_CONTRACT_ADDRESS.try_into().unwrap(), 0, obj_serialized.span(),
)
.unwrap_syscall();

Expand Down
2 changes: 1 addition & 1 deletion hdp_cairo/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod any_type;
pub mod arbitrary_type;
pub mod debug;
pub mod evm;
pub mod starknet;
Expand Down
5 changes: 5 additions & 0 deletions src/contract_bootloader/execute_syscalls.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ func execute_call_contract{
return ();
}

// arbitrary_type Contract does not need to be executed
if (request.contract_address == 'arbitrary_type') {
return ();
}

let layout = chain_id_to_layout(request.calldata_start[2]);
let output_ptr = response.retdata_start;

Expand Down

0 comments on commit 2b0a4c6

Please sign in to comment.