Skip to content

Commit

Permalink
chore: add tip and transfer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Darlington02 committed Oct 4, 2024
1 parent c184474 commit 200f2b0
Show file tree
Hide file tree
Showing 12 changed files with 519 additions and 217 deletions.
6 changes: 0 additions & 6 deletions Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ version = "0.1.0"
dependencies = [
"alexandria_bytes",
"openzeppelin",
"pragma_lib",
"snforge_std",
"token_bound_accounts",
]
Expand Down Expand Up @@ -166,11 +165,6 @@ name = "openzeppelin_utils"
version = "0.17.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.17.0#bf5d02c25c989ccc24f3ab42ec649617d3f21289"

[[package]]
name = "pragma_lib"
version = "1.0.0"
source = "git+https://github.com/astraly-labs/pragma-lib#86d7ccdc15b349b8b48d9796fc8464c947bea6e1"

[[package]]
name = "snforge_scarb_plugin"
version = "0.31.0"
Expand Down
4 changes: 1 addition & 3 deletions Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ starknet = "2.8.2"
openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.17.0" }
token_bound_accounts= { git = "https://github.com/Starknet-Africa-Edu/TBA", tag = "v0.3.0" }
alexandria_bytes = { git = "https://github.com/keep-starknet-strange/alexandria.git" }
pragma_lib = { git = "https://github.com/astraly-labs/pragma-lib" }

[dev-dependencies]
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.31.0" }


[sncast.default]
url= "https://starknet-sepolia.public.blastapi.io"

[[target.starknet-contract]]
casm = true
build-external-contracts = ["token_bound_accounts::presets::account::Account"]
allowed-libfuncs-list.name = "experimental"
allowed-libfuncs-list.name = "experimental"
1 change: 0 additions & 1 deletion src/base/constants.cairo
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
pub mod errors;
pub mod types;
pub mod contract_addresses;
15 changes: 0 additions & 15 deletions src/base/constants/contract_addresses.cairo

This file was deleted.

2 changes: 0 additions & 2 deletions src/base/constants/errors.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ pub mod Errors {
pub const SELF_FOLLOWING: felt252 = 'Karst: self follow is forbidden';
pub const ALREADY_REACTED: felt252 = 'Karst: already react to post!';
pub const SELF_TIPPING: felt252 = 'Karst: self-tip forbidden!';
pub const MAX_TIPPING: felt252 = 'Karst: exceeds max tipping!';
pub const SELF_TRANSFER: felt252 = 'Karst: self-transfer forbidden!';
pub const SELF_REQUEST: felt252 = 'Karst: self-request forbidden!';
pub const INSUFFICIENT_ALLOWANCE: felt252 = 'Karst: insufficient allowance!';
pub const AUTO_RENEW_DURATION_ENDED: felt252 = 'Karst: auto renew ended!';
pub const INVALID_JOLT: felt252 = 'Karst: invalid jolt!';
pub const EXPIRED_JOLT: felt252 = 'Karst: jolt is expired!';
pub const INVALID_JOLT_RECIPIENT: felt252 = 'Karst: not request recipient!';
}
19 changes: 5 additions & 14 deletions src/base/constants/types.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -177,29 +177,28 @@ pub struct FollowData {
// JOLT
// *************************************************************************
#[derive(Drop, Serde, starknet::Store)]
pub struct joltData {
pub struct JoltData {
pub jolt_id: u256,
pub jolt_type: JoltType,
pub sender: ContractAddress,
pub recipient: ContractAddress,
pub memo: ByteArray,
pub amount: u256,
pub amount_in_usd: u256,
pub currency: JoltCurrency,
pub status: JoltStatus,
pub expiration_stamp: u64,
pub block_timestamp: u64
pub block_timestamp: u64,
pub erc20_contract_address: ContractAddress
}

#[derive(Drop, Serde)]
pub struct joltParams {
pub struct JoltParams {
pub jolt_type: JoltType,
pub recipient: ContractAddress,
pub memo: ByteArray,
pub amount: u256,
pub currency: JoltCurrency,
pub expiration_stamp: u64,
pub auto_renewal: (bool, u256),
pub erc20_contract_address: ContractAddress,
}

#[derive(Drop, Serde, starknet::Store)]
Expand All @@ -209,14 +208,6 @@ pub struct RenewalData {
pub erc20_contract_address: ContractAddress
}

#[derive(Drop, Serde, starknet::Store, PartialEq)]
pub enum JoltCurrency {
USDT,
USDC,
ETH,
STRK
}

#[derive(Drop, Serde, starknet::Store, PartialEq)]
pub enum JoltType {
Tip,
Expand Down
7 changes: 3 additions & 4 deletions src/interfaces/IJolt.cairo
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
use starknet::ContractAddress;
use karst::base::constants::types::{joltParams, joltData};
use karst::base::constants::types::{JoltParams, JoltData};

#[starknet::interface]
pub trait IJolt<TState> {
// *************************************************************************
// EXTERNALS
// *************************************************************************
fn jolt(ref self: TState, jolt_params: joltParams) -> u256;
fn jolt(ref self: TState, jolt_params: JoltParams) -> u256;
fn set_fee_address(ref self: TState, _fee_address: ContractAddress);
fn auto_renew(ref self: TState, profile: ContractAddress, renewal_id: u256) -> bool;
fn fullfill_request(ref self: TState, jolt_id: u256, sender: ContractAddress) -> bool;
// *************************************************************************
// GETTERS
// *************************************************************************
fn get_jolt(self: @TState, jolt_id: u256) -> joltData;
fn total_jolts_received(self: @TState, profile: ContractAddress) -> u256;
fn get_jolt(self: @TState, jolt_id: u256) -> JoltData;
fn get_fee_address(self: @TState) -> ContractAddress;
}
Loading

0 comments on commit 200f2b0

Please sign in to comment.