Skip to content

Commit

Permalink
Randomness tier subscription (#90)
Browse files Browse the repository at this point in the history
* feat: upgradeable contract

* feat: prenium management

* feat: randomness fee management

* fix: example randomness types

* fix: issues in randomness contract

* fix: uncomment code

* ✨ mock oracle

* 🐛 camel case abi

* feat: balance management tests

* fix: residuals

* feat: out of gas verification

* fix: tests

* feat: fetch all out of gas requests

* fix: fmt

* feat: more tests

* fix: fmt

* remove comments

* feat: spell ignore

* feat: withdraw + error management

* fix: decimal adjustment

* fix: remove unused function

* feat: admin management

---------

Co-authored-by: 0xevolve <[email protected]>
  • Loading branch information
JordyRo1 and EvolveArt authored Nov 23, 2023
1 parent 6dd43d1 commit 94e79ee
Show file tree
Hide file tree
Showing 7 changed files with 761 additions and 88 deletions.
1 change: 1 addition & 0 deletions .codespellignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requestor
2 changes: 1 addition & 1 deletion Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ alexandria_storage = { git = "https://github.com/keep-starknet-strange/alexandri
alexandria_data_structures = { git = "https://github.com/keep-starknet-strange/alexandria.git", rev = "46c8d8ab9e3bfb68b70a29b3246f809cd8bf70e4" }
alexandria_sorting = { git = "https://github.com/keep-starknet-strange/alexandria.git", rev = "46c8d8ab9e3bfb68b70a29b3246f809cd8bf70e4" }
cubit = { git = "https://github.com/influenceth/cubit", rev = "2ccb2536dffa3f15ebd38b755c1be65fde1eab0c" }

openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.7.0" }
starknet = "2.2.0"

[[target.starknet-contract]]
Expand Down
1 change: 1 addition & 0 deletions src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ mod operations {
}
mod oracle {
mod oracle;
mod mock_oracle;
}
mod publisher_registry {
mod publisher_registry;
Expand Down
37 changes: 37 additions & 0 deletions src/oracle/mock_oracle.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use pragma::entry::structs::{DataType, PragmaPricesResponse};

#[starknet::interface]
trait IOracle<TContractState> {
fn get_data_median(self: @TContractState, data_type: DataType) -> PragmaPricesResponse;
}

#[starknet::contract]
mod MockOracle {
use starknet::{get_block_timestamp};
use super::{IOracle, PragmaPricesResponse, DataType};
use option::OptionTrait;

#[storage]
struct Storage {}

#[constructor]
fn constructor(ref self: ContractState) {
return ();
}

#[external(v0)]
impl IOracleImpl of IOracle<ContractState> {
/// @notice Returns a fixed mocked price of 1000 USD
fn get_data_median(self: @ContractState, data_type: DataType) -> PragmaPricesResponse {
let timestamp = get_block_timestamp();
PragmaPricesResponse {
price: 100000000000,
decimals: 8,
last_updated_timestamp: timestamp,
num_sources_aggregated: 5,
expiration_timestamp: Option::None,
}
}
}
}

4 changes: 2 additions & 2 deletions src/randomness/example_randomness.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ trait IExampleRandomness<TContractState> {
ref self: TContractState,
seed: u64,
callback_address: ContractAddress,
callback_gas_limit: u64,
callback_gas_limit: u128,
publish_delay: u64,
num_words: u64
);
Expand Down Expand Up @@ -49,7 +49,7 @@ mod ExampleRandomness {
ref self: ContractState,
seed: u64,
callback_address: ContractAddress,
callback_gas_limit: u64,
callback_gas_limit: u128,
publish_delay: u64,
num_words: u64
) {
Expand Down
Loading

0 comments on commit 94e79ee

Please sign in to comment.