-
Notifications
You must be signed in to change notification settings - Fork 758
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add string types of cairo v2.4.0
- Loading branch information
1 parent
9d73582
commit a8a73c1
Showing
17 changed files
with
6,878 additions
and
13 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
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 | ||
} | ||
} | ||
} |
Oops, something went wrong.