-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d4ffab
commit 4d80dca
Showing
10 changed files
with
556 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ pub mod IHandleRegistry; | |
pub mod IHub; | ||
pub mod IJolt; | ||
pub mod ICollectNFT; | ||
pub mod IUpgradeable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
use starknet::ContractAddress; | ||
use karst::base::constants::types::{JoltParams, JoltData}; | ||
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 set_fee_address(ref self: TState, _fee_address: ContractAddress); | ||
fn auto_renew(ref self: TState, profile: ContractAddress, renewal_id: u256) -> bool; | ||
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod registry; | ||
pub mod interfaces; | ||
pub mod ERC20; | ||
pub mod jolt_upgrade; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod IComposable; | ||
pub mod IJoltUpgrade; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use karst::base::constants::types::{JoltParams}; | ||
|
||
#[starknet::interface] | ||
pub trait IJoltUpgrade<TState> { | ||
// ************************************************************************* | ||
// EXTERNALS | ||
// ************************************************************************* | ||
fn jolt(ref self: TState, jolt_params: JoltParams) -> u256; | ||
// ************************************************************************* | ||
// GETTERS | ||
// ************************************************************************* | ||
fn version(self: @TState) -> u256; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#[starknet::contract] | ||
pub mod JoltUpgrade { | ||
// ************************************************************************* | ||
// IMPORTS | ||
// ************************************************************************* | ||
use core::hash::HashStateTrait; | ||
use core::pedersen::PedersenTrait; | ||
use starknet::get_tx_info; | ||
use karst::base::{constants::types::{JoltParams}}; | ||
use karst::mocks::interfaces::IJoltUpgrade::IJoltUpgrade; | ||
|
||
// ************************************************************************* | ||
// STORAGE | ||
// ************************************************************************* | ||
#[storage] | ||
struct Storage {} | ||
|
||
// ************************************************************************* | ||
// EVENTS | ||
// ************************************************************************* | ||
#[event] | ||
#[derive(Drop, starknet::Event)] | ||
pub enum Event {} | ||
|
||
|
||
// ************************************************************************* | ||
// EXTERNALS | ||
// ************************************************************************* | ||
#[abi(embed_v0)] | ||
impl JoltImpl of IJoltUpgrade<ContractState> { | ||
fn jolt(ref self: ContractState, jolt_params: JoltParams) -> u256 { | ||
let tx_info = get_tx_info().unbox(); | ||
|
||
// generate jolt_id | ||
let jolt_hash = PedersenTrait::new(0) | ||
.update(jolt_params.recipient.into()) | ||
.update(jolt_params.amount.low.into()) | ||
.update(jolt_params.amount.high.into()) | ||
.update(tx_info.nonce) | ||
.update(4) | ||
.finalize(); | ||
|
||
let jolt_id: u256 = jolt_hash.try_into().unwrap(); | ||
|
||
return jolt_id; | ||
} | ||
|
||
fn version(self: @ContractState) -> u256 { | ||
2 | ||
} | ||
} | ||
} |
Oops, something went wrong.