Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lucas/something #11

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions onchain/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ version = "0.1.0"
starknet = ">=2.5.3"
openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts", branch = "main" }

[tool.fmt]
sort-module-level-items = true

[[target.starknet-contract]]
sierra = true
casm = true
30 changes: 12 additions & 18 deletions onchain/src/contracts/account.cairo
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#[starknet::contract(account)]
mod Account {
use starknet::account::Call;
use openzeppelin::account::AccountComponent;
use openzeppelin::introspection::src5::SRC5Component;
use openzeppelin::account::interface::ISRC6;
use openzeppelin::introspection::src5::SRC5Component;
use starknet::account::Call;

use vault::spending_limit::daily_limit::DailyLimitComponent;
use vault::spending_limit::daily_limit::interface::IDailyLimit;
use vault::spending_limit::weekly_limit::WeeklyLimitComponent;
use vault::spending_limit::weekly_limit::interface::IWeeklyLimit;

component!(path: AccountComponent, storage: account, event: AccountEvent);
component!(path: SRC5Component, storage: src5, event: SRC5Event);
component!(path: DailyLimitComponent, storage: daily_limit, event: DailyLimitEvent);
component!(path: WeeklyLimitComponent, storage: weekly_limit, event: WeeklyLimitEvent);

// Account
#[abi(embed_v0)]
Expand All @@ -19,12 +19,10 @@ mod Account {
impl PublicKeyCamelImpl = AccountComponent::PublicKeyCamelImpl<ContractState>;
#[abi(embed_v0)]
impl DeclarerImpl = AccountComponent::DeclarerImpl<ContractState>;
#[abi(embed_v0)]
impl DeployableImpl = AccountComponent::DeployableImpl<ContractState>;
impl AccountInternalImpl = AccountComponent::InternalImpl<ContractState>;

// Daily Limit
impl DailyLimitInternalImpl = DailyLimitComponent::InternalImpl<ContractState>;
impl WeeklyLimitInternalImpl = WeeklyLimitComponent::InternalImpl<ContractState>;

// SRC5
#[abi(embed_v0)]
Expand All @@ -37,7 +35,7 @@ mod Account {
#[substorage(v0)]
src5: SRC5Component::Storage,
#[substorage(v0)]
daily_limit: DailyLimitComponent::Storage,
weekly_limit: WeeklyLimitComponent::Storage,
}

#[event]
Expand All @@ -48,7 +46,7 @@ mod Account {
#[flat]
SRC5Event: SRC5Component::Event,
#[flat]
DailyLimitEvent: DailyLimitComponent::Event,
WeeklyLimitEvent: WeeklyLimitComponent::Event,
}

//
Expand All @@ -58,7 +56,7 @@ mod Account {
#[constructor]
fn constructor(ref self: ContractState, public_key: felt252, limit: u256) {
self.account.initializer(:public_key);
self.daily_limit.initializer(:limit);
self.weekly_limit.initializer(:limit);
}

//
Expand Down Expand Up @@ -89,13 +87,9 @@ mod Account {
//

#[abi(embed_v0)]
impl DailyLimit of IDailyLimit<ContractState> {
fn get_daily_limit(self: @ContractState) -> u256 {
self.daily_limit.get_daily_limit()
}

fn set_daily_limit(ref self: ContractState, new_limit: u256) {
self.daily_limit.set_daily_limit(:new_limit);
impl WeeklyLimit of IWeeklyLimit<ContractState> {
fn get_weekly_limit(self: @ContractState) -> u256 {
self.weekly_limit.get_weekly_limit()
}
}
}
2 changes: 1 addition & 1 deletion onchain/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub mod spending_limit;
mod contracts;
pub mod spending_limit;

#[cfg(test)]
mod tests;
2 changes: 1 addition & 1 deletion onchain/src/spending_limit.cairo
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pub mod daily_limit;
pub mod weekly_limit;
5 changes: 0 additions & 5 deletions onchain/src/spending_limit/daily_limit.cairo

This file was deleted.

152 changes: 0 additions & 152 deletions onchain/src/spending_limit/daily_limit/daily_limit.cairo

This file was deleted.

8 changes: 0 additions & 8 deletions onchain/src/spending_limit/daily_limit/interface.cairo

This file was deleted.

5 changes: 5 additions & 0 deletions onchain/src/spending_limit/weekly_limit.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub mod interface;
pub mod weekly_limit;
use interface::{IWeeklyLimitDispatcher, IWeeklyLimitDispatcherTrait};

use weekly_limit::WeeklyLimitComponent;
6 changes: 6 additions & 0 deletions onchain/src/spending_limit/weekly_limit/interface.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use starknet::account::Call;

#[starknet::interface]
trait IWeeklyLimit<TState> {
fn get_weekly_limit(self: @TState) -> u256;
}
Loading
Loading