-
Notifications
You must be signed in to change notification settings - Fork 3
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
2 changed files
with
30 additions
and
72 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
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,41 +1,17 @@ | ||
#[starknet::interface] | ||
pub trait IHelloBootloader<TContractState> { | ||
fn main(ref self: TContractState, input: Array<felt252>) -> Array<felt252>; | ||
} | ||
|
||
#[starknet::contract] | ||
mod HelloBootloader { | ||
#[derive(Drop, Serde)] | ||
struct Input { | ||
a: u32, | ||
b: u32, | ||
c: u32, | ||
} | ||
|
||
#[derive(Drop, Serde)] | ||
struct Output { | ||
a_2: u32, | ||
b_2: u32, | ||
c_2: u32, | ||
} | ||
mod Factorial { | ||
use starknet::{ContractAddress, SyscallResult, SyscallResultTrait}; | ||
use starknet::syscalls::call_contract_syscall; | ||
|
||
#[storage] | ||
struct Storage {} | ||
|
||
#[abi(embed_v0)] | ||
impl HelloBootloaderImpl of super::IHelloBootloader<ContractState> { | ||
fn main(ref self: ContractState, input: Array<felt252>) -> Array<felt252> { | ||
let mut input_span = input.span(); | ||
let input = Serde::<Input>::deserialize(ref input_span).unwrap(); | ||
|
||
let a_2 = input.a * input.a; | ||
let b_2 = input.b * input.b; | ||
let c_2 = input.c * input.c; | ||
assert(a_2 + b_2 == c_2, 'invalid value'); | ||
struct Storage{} | ||
|
||
let mut output = array![]; | ||
Output { a_2, b_2, c_2, }.serialize(ref output); | ||
output | ||
} | ||
#[external(v0)] | ||
fn main(ref self: ContractState, address: ContractAddress) -> Span<felt252> { | ||
// call_contract_syscall is modified POC syscall to just return calldata it received | ||
let value: Span<felt252> = call_contract_syscall( | ||
address, 0x1, array![0xa, 0xb, 0xc, 0xe].span(), | ||
).unwrap_syscall(); | ||
value | ||
} | ||
} | ||
} |