Skip to content

Commit

Permalink
#17
Browse files Browse the repository at this point in the history
  • Loading branch information
khaeljy committed Jan 4, 2024
1 parent ad5ad7d commit d9ec293
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/account/account.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ mod Account {
use starknet::account::Call;
use starknet::{get_tx_info, ContractAddress, contract_address_const};

use swappy::account::error::AccountError;

component!(path: AccountComponent, storage: account, event: AccountEvent);
component!(path: SRC5Component, storage: src5, event: SRC5Event);

Expand Down Expand Up @@ -68,14 +70,13 @@ mod Account {
loop {
match calls.pop_front() {
Option::Some(call) => {

// TODO: Add whitelist for contracts allowed and selectors
assert(
call
.to == contract_address_const::<
0x0097ab8a6dc7760a687caaffa7101611b20babda533ce40b3cac94fb1926355e
>(),
'UNAUTHORIZED CONTRACT'
AccountError::UNAUTHORIZED_CONTRACT
);
},
Option::None(_) => { break (); },
Expand Down
8 changes: 3 additions & 5 deletions src/account/error.cairo
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
mod AccountError { // const INVALID_CALLER: felt252 = 'Account: invalid caller';
// const INVALID_TX_VERSION: felt252 = 'Account: invalid tx version';
// const INVALID_SIGNATURE: felt252 = 'Account: invalid signature';
// const UNAUTHORIZED: felt252 = 'Account: unauthorized';
// const POSITION_NOT_FOUND: felt252 = 'Account: position not found';
mod AccountError {
const UNAUTHORIZED_CONTRACT: felt252 = 'Account: unauthorized contract';
const UNAUTHORIZED_SELECTOR: felt252 = 'Account: unauthorized selector';
}
18 changes: 18 additions & 0 deletions src/router/jedi_swap_router.cairo
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
use starknet::{get_caller_address, ContractAddress};


#[starknet::interface]
trait IJediSwapRouter<ContractState> {
fn swap_exact_tokens_for_tokens(
ref self: ContractState,
amount_in: u256,
amount_out_min: u256,
path: Span<ContractAddress>,
to: ContractAddress,
deadline: u32
);
}

#[starknet::contract]
mod JediSwapRouter {
// *************************************************************************
// IMPORTS
// *************************************************************************

// Core lib imports.
use swappy::router::jedi_swap_router::IJediSwapRouterDispatcherTrait;
use core::zeroable::Zeroable;
use starknet::{get_caller_address, ContractAddress};

Expand Down Expand Up @@ -98,6 +114,8 @@ mod JediSwapRouter {
let router_address = self.router_address.read();
assert(router_address.is_non_zero(), RouterError::ROUTER_ADDRESS_UNDEFINED);

// super::IJediSwapRouterDispatcher { contract_address: router_address }
// .swap_exact_tokens_for_tokens(amount_in, amount_out_min, path, to, deadline);
// TODO : Call router address swap_exact_tokens_for_tokens
// Until JediSwap is updated to Cairo 1, panic with 'NOT_IMPLEMENTED'
panic_with_felt252('NOT_IMPLEMENTED');
Expand Down

0 comments on commit d9ec293

Please sign in to comment.