Skip to content

Commit

Permalink
feat: add string types of cairo v2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippeR26 committed Dec 11, 2023
1 parent 9d73582 commit a8a73c1
Show file tree
Hide file tree
Showing 17 changed files with 6,878 additions and 13 deletions.
42 changes: 42 additions & 0 deletions __mocks__/cairo/cairo240/string.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//Cairo 2.4.0

#[starknet::interface]
trait ITestReject<TContractState> {
fn proceed_bytes31(self: @TContractState, str: bytes31) -> bytes31;
fn get_string(self: @TContractState) -> ByteArray;
fn proceed_string(self: @TContractState, mess: ByteArray) -> ByteArray;
}

#[starknet::contract]
mod MyTestReject {
use core::option::OptionTrait;
use core::traits::TryInto;
use core::bytes_31::Bytes31Trait;
use core::byte_array::ByteArrayTrait;
#[storage]
struct Storage {
counter: u8
}

#[external(v0)]
impl TestReject of super::ITestReject<ContractState> {
fn proceed_bytes31(self: @ContractState, str: bytes31) -> bytes31 {
let mut mess: ByteArray = "azertzertrty dfghfghj dfgh dfghazert sdfgsdf ";
mess.append_byte(55_u8);
let mot: felt252 = ' Zorg';
str
}

fn get_string(self: @ContractState) -> ByteArray {
let mut mess: ByteArray = "azertzertrty dfghfghj dfgh dfghazert sdfgsdf ";
mess
}

fn proceed_string(self: @ContractState, mess: ByteArray) -> ByteArray {
let mut res = mess;
let add: ByteArray = " Zorg is back";
res.append(@add);
res
}
}
}
Loading

0 comments on commit a8a73c1

Please sign in to comment.