-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/karnotxyz/starknet_bridge
- Loading branch information
Showing
16 changed files
with
437 additions
and
52 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
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
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#[starknet::contract] | ||
mod messaging_malicious { | ||
use piltover::messaging::interface::IMessaging; | ||
use starknet::ContractAddress; | ||
|
||
|
||
#[storage] | ||
struct Storage {} | ||
|
||
|
||
#[abi(embed_v0)] | ||
impl MessagingImpl of IMessaging<ContractState> { | ||
fn send_message_to_appchain( | ||
ref self: ContractState, | ||
to_address: ContractAddress, | ||
selector: felt252, | ||
payload: Span<felt252> | ||
) -> (felt252, felt252) { | ||
(0, 0) | ||
} | ||
|
||
fn consume_message_from_appchain( | ||
ref self: ContractState, from_address: ContractAddress, payload: Span<felt252> | ||
) -> felt252 { | ||
0 | ||
} | ||
|
||
fn sn_to_appchain_messages(self: @ContractState, message_hash: felt252) -> felt252 { | ||
0 | ||
} | ||
|
||
fn appchain_to_sn_messages(self: @ContractState, message_hash: felt252) -> felt252 { | ||
0 | ||
} | ||
|
||
fn start_message_cancellation( | ||
ref self: ContractState, | ||
to_address: ContractAddress, | ||
selector: felt252, | ||
payload: Span<felt252>, | ||
nonce: felt252, | ||
) -> felt252 { | ||
0 | ||
} | ||
|
||
fn cancel_message( | ||
ref self: ContractState, | ||
to_address: ContractAddress, | ||
selector: felt252, | ||
payload: Span<felt252>, | ||
nonce: felt252, | ||
) -> felt252 { | ||
0 | ||
} | ||
} | ||
} |
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,80 @@ | ||
use starknet::ContractAddress; | ||
|
||
#[starknet::interface] | ||
pub trait IMockWithdrawalLimit<TState> { | ||
fn toggle_withdrawal_limit_for_token( | ||
ref self: TState, token: ContractAddress, is_applied: bool | ||
); | ||
fn consume_quota(ref self: TState, token: ContractAddress, amount: u256); | ||
fn write_daily_withdrawal_limit_pct(ref self: TState, limit_percent: u8); | ||
fn get_daily_withdrawal_limit_pct(self: @TState) -> u8; | ||
} | ||
|
||
#[starknet::contract] | ||
pub mod withdrawal_limit_mock { | ||
use starknet_bridge::withdrawal_limit::component::WithdrawalLimitComponent::InternalTrait; | ||
use starknet_bridge::withdrawal_limit::{ | ||
component::WithdrawalLimitComponent, | ||
interface::{IWithdrawalLimitDispatcher, IWithdrawalLimitDispatcherTrait, IWithdrawalLimit} | ||
}; | ||
use starknet_bridge::bridge::interface::IWithdrawalLimitStatus; | ||
use starknet::ContractAddress; | ||
|
||
|
||
component!(path: WithdrawalLimitComponent, storage: withdrawal, event: WithdrawalEvent); | ||
|
||
// WithdrawalLimit | ||
#[abi(embed_v0)] | ||
impl WithdrawalLimitImpl = | ||
WithdrawalLimitComponent::WithdrawalLimitImpl<ContractState>; | ||
impl WithdrawalLimitInternal = WithdrawalLimitComponent::InternalImpl<ContractState>; | ||
|
||
|
||
#[storage] | ||
struct Storage { | ||
limits: LegacyMap<ContractAddress, bool>, | ||
#[substorage(v0)] | ||
withdrawal: WithdrawalLimitComponent::Storage, | ||
} | ||
|
||
#[event] | ||
#[derive(Drop, starknet::Event)] | ||
pub enum Event { | ||
#[flat] | ||
WithdrawalEvent: WithdrawalLimitComponent::Event, | ||
} | ||
|
||
#[constructor] | ||
pub fn constructor(ref self: ContractState) { | ||
self.withdrawal.initialize(5); | ||
} | ||
|
||
|
||
#[abi(embed_v0)] | ||
impl MockWithdrawalLimitImpl of super::IMockWithdrawalLimit<ContractState> { | ||
fn toggle_withdrawal_limit_for_token( | ||
ref self: ContractState, token: ContractAddress, is_applied: bool | ||
) { | ||
self.limits.write(token, is_applied); | ||
} | ||
|
||
fn consume_quota(ref self: ContractState, token: ContractAddress, amount: u256) { | ||
self.withdrawal.consume_withdrawal_quota(token, amount); | ||
} | ||
|
||
fn write_daily_withdrawal_limit_pct(ref self: ContractState, limit_percent: u8) { | ||
self.withdrawal.write_daily_withdrawal_limit_pct(limit_percent); | ||
} | ||
|
||
fn get_daily_withdrawal_limit_pct(self: @ContractState) -> u8 { | ||
self.withdrawal.daily_withdrawal_limit_pct.read() | ||
} | ||
} | ||
|
||
#[abi(embed_v0)] | ||
impl WithdrawalLimitStatusImpl of IWithdrawalLimitStatus<ContractState> { | ||
fn is_withdrawal_limit_applied(self: @ContractState, token: ContractAddress) -> bool { | ||
self.limits.read(token) | ||
} | ||
} | ||
} |
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
Oops, something went wrong.