Skip to content

Commit

Permalink
feat(onchain): tx approval
Browse files Browse the repository at this point in the history
  • Loading branch information
0xLucqs committed Mar 20, 2024
1 parent caea9ae commit bdc488b
Show file tree
Hide file tree
Showing 4 changed files with 409 additions and 2 deletions.
21 changes: 19 additions & 2 deletions onchain/src/contracts/account.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@ mod Account {
use openzeppelin::account::AccountComponent;
use openzeppelin::account::interface::ISRC6;
use openzeppelin::introspection::src5::SRC5Component;
use starknet::ContractAddress;
use starknet::account::Call;

use vault::spending_limit::weekly_limit::WeeklyLimitComponent;
use vault::spending_limit::weekly_limit::interface::IWeeklyLimit;
use vault::tx_approval::tx_approval::TransactionApprovalComponent;
use vault::whitelist::whitelist::WhitelistComponent;

component!(path: AccountComponent, storage: account, event: AccountEvent);
component!(path: SRC5Component, storage: src5, event: SRC5Event);
component!(
path: TransactionApprovalComponent,
storage: transaction_approval,
event: TransactionApprovalEvent
);
component!(path: WeeklyLimitComponent, storage: weekly_limit, event: WeeklyLimitEvent);
component!(path: WhitelistComponent, storage: whitelist, event: WhitelistEvent);

Expand All @@ -37,6 +43,10 @@ mod Account {
impl WhitelistClassHashEntrypointInternalImpl =
WhitelistComponent::WhitelistClassHashEntrypointImpl<ContractState>;

// Transaction approval
impl TransactionApprovalInternalImpl =
TransactionApprovalComponent::InternalImpl<ContractState>;

// SRC5
#[abi(embed_v0)]
impl SRC5Impl = SRC5Component::SRC5Impl<ContractState>;
Expand All @@ -48,6 +58,8 @@ mod Account {
#[substorage(v0)]
src5: SRC5Component::Storage,
#[substorage(v0)]
transaction_approval: TransactionApprovalComponent::Storage,
#[substorage(v0)]
weekly_limit: WeeklyLimitComponent::Storage,
#[substorage(v0)]
whitelist: WhitelistComponent::Storage,
Expand All @@ -61,6 +73,8 @@ mod Account {
#[flat]
SRC5Event: SRC5Component::Event,
#[flat]
TransactionApprovalEvent: TransactionApprovalComponent::Event,
#[flat]
WeeklyLimitEvent: WeeklyLimitComponent::Event,
#[flat]
WhitelistEvent: WhitelistComponent::Event,
Expand All @@ -71,8 +85,11 @@ mod Account {
//

#[constructor]
fn constructor(ref self: ContractState, public_key: felt252, limit: u256) {
fn constructor(
ref self: ContractState, public_key: felt252, admin: ContractAddress, limit: u256
) {
self.account.initializer(:public_key);
self.transaction_approval.initializer(:admin);
self.weekly_limit.initializer(:limit);
}

Expand Down
1 change: 1 addition & 0 deletions onchain/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ pub mod spending_limit;

#[cfg(test)]
mod tests;
pub mod tx_approval;
pub mod whitelist;
1 change: 1 addition & 0 deletions onchain/src/tx_approval.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod tx_approval;
Loading

0 comments on commit bdc488b

Please sign in to comment.