Skip to content

Commit

Permalink
added headers for contracts in lib
Browse files Browse the repository at this point in the history
  • Loading branch information
ametel01 committed Aug 10, 2024
1 parent 71aba86 commit 5668062
Show file tree
Hide file tree
Showing 3 changed files with 189 additions and 0 deletions.
77 changes: 77 additions & 0 deletions cairo/src/contracts/token/libs/fast_token_router.cairo
Original file line number Diff line number Diff line change
@@ -1 +1,78 @@
#[starknet::interface]
pub trait IFastTokenRouter<TState> {
fn initialize(ref self: TState);
fn fill_fast_transfer(
ref self: TState,
recipient: u256,
amount: u256,
fast_fee: u256,
origin: u32,
fast_transfer_id: u256
);
fn fast_transfer_remote(
ref self: TState, destination: u32, recipient: u256, amount_or_id: u256, fast_fee: u256
) -> u256;
}

#[starknet::contract]
pub mod FastTokenRouter {
#[storage]
struct Storage {}

fn constructor() {}

impl FastTokenRouterImpl of super::IFastTokenRouter<ContractState> {
fn initialize(ref self: ContractState) {}

fn fill_fast_transfer(
ref self: ContractState,
recipient: u256,
amount: u256,
fast_fee: u256,
origin: u32,
fast_transfer_id: u256
) {}

fn fast_transfer_remote(
ref self: ContractState,
destination: u32,
recipient: u256,
amount_or_id: u256,
fast_fee: u256
) -> u256 {
0
}
}

#[generate_trait]
impl InternalImpl of InternalTrait {
fn handle(self: @ContractState, origin: u32, message: u256) {}

fn fast_transfer_to(ref self: ContractState, recipient: u256, amount: u256) {}

fn fast_recieve_from(ref self: ContractState, sender: u256, amount: u256) {}

fn get_token_recipient(
self: @ContractState, recipient: u256, amount: u256, origin: u32, metadata: u256
) -> u256 {
0
}

fn get_fast_transfers_key(
self: @ContractState,
origin: u32,
fast_transfer_id: u256,
amount: u256,
fast_fee: u256,
recipient: u256
) -> u256 {
0
}

fn fast_transfer_from_sender(
ref self: ContractState, amount: u256, fast_fee: u256, fast_transfer_id: u256
) -> u256 {
0
}
}
}
21 changes: 21 additions & 0 deletions cairo/src/contracts/token/libs/token_message.cairo
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
pub mod TokenMessage {
pub fn format(recipient: felt252, amount: u256, metadata: u256) -> u256 {
0
}

pub fn recipient(message: felt252) -> u256 {
0
}

pub fn amount(message: felt252) -> u256 {
0
}

pub fn token_id(message: felt252) -> u256 {
amount(message)
}

pub fn metadata(message: felt252) -> u256 {
0
}
}

91 changes: 91 additions & 0 deletions cairo/src/contracts/token/libs/token_router.cairo
Original file line number Diff line number Diff line change
@@ -1 +1,92 @@
#[starknet::interface]
pub trait ITokenRouter<TState> {
fn initialize(ref self: TState);
fn transfer_remote(
self: @TState, destination: u32, recipient: Array<u8>, amount_or_id: u256
) -> u256;
fn transfer_remote_with_hook(
self: @TState,
destination: u32,
// TODO: make this fixed size once we switch to 2.7.0
recipient: Array<u8>,
amount_or_id: u256,
hook_metadata: u256,
hook: u256
) -> u256;
fn balance_of(self: @TState, account: u256) -> u256;
}

#[starknet::component]
pub mod TokenRouter {
use starknet::ContractAddress;
#[storage]
struct Storage {}

fn constructor() {}

impl TokenRouterImpl<
TContractState, +HasComponent<TContractState>,
> of super::ITokenRouter<ComponentState<TContractState>> {
fn initialize(ref self: ComponentState<TContractState>) {}

fn transfer_remote(
self: @ComponentState<TContractState>,
destination: u32,
// TODO: make this fixed size once we switch to 2.7.0
recipient: Array<u8>,
amount_or_id: u256
) -> u256 {
0
}

fn transfer_remote_with_hook(
self: @ComponentState<TContractState>,
destination: u32,
// TODO: make this fixed size once we switch to 2.7.0
recipient: Array<u8>,
amount_or_id: u256,
hook_metadata: u256,
hook: u256
) -> u256 {
0
}

fn balance_of(self: @ComponentState<TContractState>, account: u256) -> u256 {
0
}
}

#[generate_trait]
impl InternalImpl<
TContractState, +HasComponent<TContractState>
> of InternalTrait<TContractState> {
fn _transfer_remote(
ref self: ComponentState<TContractState>,
destination: u32,
// TODO: make this fixed size once we switch to 2.7.0
recipient: Array<u8>,
amount_or_id: u256,
value: u256,
hook_metadata: Option<Array<u8>>,
hook: Option<ContractAddress>
) -> u256 {
0
}

fn _transfer_from_sender(
ref self: ComponentState<TContractState>, amount_or_id: u256
) -> u256 {
0
}

fn _handle(ref self: ComponentState<TContractState>, origin: u32, message: u256) {}

fn _transfer_to(
ref self: ComponentState<TContractState>,
recipient: ContractAddress,
amount_or_id: u256,
metadata: Array<u8>
) {}
}
}

0 comments on commit 5668062

Please sign in to comment.