Skip to content

Commit

Permalink
Merge branch 'main' into ft_community
Browse files Browse the repository at this point in the history
  • Loading branch information
mubarak23 authored Oct 6, 2024
2 parents 20c1198 + 195e539 commit d8dc1aa
Show file tree
Hide file tree
Showing 23 changed files with 2,079 additions and 37 deletions.
1 change: 0 additions & 1 deletion Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ alexandria_bytes = { git = "https://github.com/keep-starknet-strange/alexandria.
[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"

Expand Down
8 changes: 8 additions & 0 deletions src/base/constants/errors.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,12 @@ pub mod Errors {
pub const NOT_MEMBER: felt252 = 'Karst: Not a Community Member';
pub const NOT_TOKEN_OWNER: felt252 = 'Karst: Not a Token Owner';
pub const TOKEN_DOES_NOT_EXIST: felt252 = 'Karst: Token does not exist';
pub const SELF_TIPPING: felt252 = 'Karst: self-tip forbidden!';
pub const SELF_TRANSFER: felt252 = 'Karst: self-transfer forbidden!';
pub const SELF_REQUEST: felt252 = 'Karst: self-request forbidden!';
pub const INVALID_EXPIRATION_STAMP: felt252 = 'Karst: invalid expiration stamp';
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 INVALID_JOLT_RECIPIENT: felt252 = 'Karst: not request recipient!';
}
86 changes: 86 additions & 0 deletions src/base/constants/types.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,89 @@ pub enum CommunityType {
Standard,
Business
}

#[derive(Debug, Drop, Serde, starknet::Store, Clone)]
pub struct Upvote {
pub publication_id: u256,
pub transaction_executor: ContractAddress,
pub block_timestamp: u64,
}

#[derive(Debug, Drop, Serde, starknet::Store, Clone)]
pub struct Downvote {
pub publication_id: u256,
pub transaction_executor: ContractAddress,
pub block_timestamp: u64,
}

// *************************************************************************
// FOLLOW
// *************************************************************************
// /**
// * @notice A struct containing token follow-related data.
// *
// * @param followed_profile_address The ID of the profile being followed.
// * @param follower_profile_address The ID of the profile following.
// * @param followTimestamp The timestamp of the current follow, if a profile is using the token to
// follow.
// * @param block_status true if follower is blocked, false otherwise
// */
#[derive(Drop, Serde, starknet::Store)]
pub struct FollowData {
pub followed_profile_address: ContractAddress,
pub follower_profile_address: ContractAddress,
pub follow_timestamp: u64,
pub block_status: bool,
}

// *************************************************************************
// JOLT
// *************************************************************************
#[derive(Drop, Serde, starknet::Store)]
pub struct JoltData {
pub jolt_id: u256,
pub jolt_type: JoltType,
pub sender: ContractAddress,
pub recipient: ContractAddress,
pub memo: ByteArray,
pub amount: u256,
pub status: JoltStatus,
pub expiration_stamp: u64,
pub block_timestamp: u64,
pub erc20_contract_address: ContractAddress
}

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

#[derive(Drop, Serde, starknet::Store)]
pub struct RenewalData {
pub renewal_iterations: u256,
pub renewal_amount: u256,
pub erc20_contract_address: ContractAddress
}

#[derive(Drop, Serde, starknet::Store, PartialEq)]
pub enum JoltType {
Tip,
Transfer,
Subscription,
Request
}

#[derive(Drop, Serde, starknet::Store, PartialEq)]
pub enum JoltStatus {
PENDING,
SUCCESSFUL,
EXPIRED,
REJECTED,
FAILED
}
5 changes: 5 additions & 0 deletions src/interfaces.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub mod IKarstNFT;
pub mod IERC721;
pub mod IERC20;
pub mod IRegistry;
pub mod IProfile;
pub mod IFollowNFT;
Expand All @@ -11,3 +12,7 @@ pub mod ICommunity;
pub mod ICollectNFT;
pub mod ICommunityNft;

pub mod IJolt;
pub mod ICollectNFT;
pub mod IUpgradeable;

20 changes: 20 additions & 0 deletions src/interfaces/IERC20.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use starknet::ContractAddress;

// *************************************************************************
// IERC20
// *************************************************************************
#[starknet::interface]
pub trait IERC20<TState> {
fn total_supply(self: @TState) -> u256;
fn balance_of(self: @TState, account: ContractAddress) -> u256;
fn allowance(self: @TState, owner: ContractAddress, spender: ContractAddress) -> u256;
fn transfer(ref self: TState, recipient: ContractAddress, amount: u256) -> bool;
fn transfer_from(
ref self: TState, sender: ContractAddress, recipient: ContractAddress, amount: u256
) -> bool;
fn approve(ref self: TState, spender: ContractAddress, amount: u256) -> bool;

fn name(self: @TState) -> ByteArray;
fn symbol(self: @TState) -> ByteArray;
fn decimals(self: @TState) -> u8;
}
19 changes: 19 additions & 0 deletions src/interfaces/IJolt.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use starknet::ContractAddress;
use karst::base::constants::types::{JoltParams, JoltData, RenewalData};

#[starknet::interface]
pub trait IJolt<TState> {
// *************************************************************************
// EXTERNALS
// *************************************************************************
fn jolt(ref self: TState, jolt_params: JoltParams) -> u256;
fn auto_renew(ref self: TState, profile: ContractAddress, jolt_id: u256) -> bool;
fn fulfill_request(ref self: TState, jolt_id: u256) -> bool;
fn set_fee_address(ref self: TState, _fee_address: ContractAddress);
// *************************************************************************
// GETTERS
// *************************************************************************
fn get_jolt(self: @TState, jolt_id: u256) -> JoltData;
fn get_renewal_data(self: @TState, profile: ContractAddress, jolt_id: u256) -> RenewalData;
fn get_fee_address(self: @TState) -> ContractAddress;
}
9 changes: 9 additions & 0 deletions src/interfaces/IUpgradeable.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// *************************************************************************
// UPGRADEABLE INTERFACE
// *************************************************************************
use starknet::ClassHash;

#[starknet::interface]
pub trait IUpgradeable<TContractState> {
fn upgrade(ref self: TContractState, new_class_hash: ClassHash);
}
1 change: 1 addition & 0 deletions src/jolt.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod jolt;
Loading

0 comments on commit d8dc1aa

Please sign in to comment.