Skip to content

Commit

Permalink
feat: add oo interface + bump 2.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
EvolveArt committed Dec 24, 2024
1 parent ee1f3f7 commit cf9c4cc
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
scarb 2.9.1
scarb 2.9.2
109 changes: 109 additions & 0 deletions Scarb.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,115 @@
# Code generated by scarb DO NOT EDIT.
version = 1

[[package]]
name = "openzeppelin"
version = "0.20.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git#7b4ff769c4d09f0eb247f95121c2c6c995bdf9b3"
dependencies = [
"openzeppelin_access",
"openzeppelin_account",
"openzeppelin_finance",
"openzeppelin_governance",
"openzeppelin_introspection",
"openzeppelin_merkle_tree",
"openzeppelin_presets",
"openzeppelin_security",
"openzeppelin_token",
"openzeppelin_upgrades",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_access"
version = "0.20.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git#7b4ff769c4d09f0eb247f95121c2c6c995bdf9b3"
dependencies = [
"openzeppelin_introspection",
]

[[package]]
name = "openzeppelin_account"
version = "0.20.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git#7b4ff769c4d09f0eb247f95121c2c6c995bdf9b3"
dependencies = [
"openzeppelin_introspection",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_finance"
version = "0.20.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git#7b4ff769c4d09f0eb247f95121c2c6c995bdf9b3"
dependencies = [
"openzeppelin_access",
"openzeppelin_token",
]

[[package]]
name = "openzeppelin_governance"
version = "0.20.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git#7b4ff769c4d09f0eb247f95121c2c6c995bdf9b3"
dependencies = [
"openzeppelin_access",
"openzeppelin_account",
"openzeppelin_introspection",
"openzeppelin_token",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_introspection"
version = "0.20.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git#7b4ff769c4d09f0eb247f95121c2c6c995bdf9b3"

[[package]]
name = "openzeppelin_merkle_tree"
version = "0.20.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git#7b4ff769c4d09f0eb247f95121c2c6c995bdf9b3"

[[package]]
name = "openzeppelin_presets"
version = "0.20.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git#7b4ff769c4d09f0eb247f95121c2c6c995bdf9b3"
dependencies = [
"openzeppelin_access",
"openzeppelin_account",
"openzeppelin_finance",
"openzeppelin_introspection",
"openzeppelin_token",
"openzeppelin_upgrades",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_security"
version = "0.20.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git#7b4ff769c4d09f0eb247f95121c2c6c995bdf9b3"

[[package]]
name = "openzeppelin_token"
version = "0.20.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git#7b4ff769c4d09f0eb247f95121c2c6c995bdf9b3"
dependencies = [
"openzeppelin_access",
"openzeppelin_account",
"openzeppelin_introspection",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_upgrades"
version = "0.20.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git#7b4ff769c4d09f0eb247f95121c2c6c995bdf9b3"

[[package]]
name = "openzeppelin_utils"
version = "0.20.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git#7b4ff769c4d09f0eb247f95121c2c6c995bdf9b3"

[[package]]
name = "pragma_lib"
version = "1.0.0"
dependencies = [
"openzeppelin",
]
3 changes: 2 additions & 1 deletion Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ homepage = "https://github.com/astraly-labs/pragma-oracle/tree/main"
[lib]

[dependencies]
starknet = "2.9.1"
starknet = "2.9.2"
openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git"}
50 changes: 49 additions & 1 deletion src/abi.cairo
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use starknet::{ContractAddress, ClassHash};
use pragma_lib::types::{
DataType, AggregationMode, Currency, Pair, PossibleEntries, Checkpoint, SimpleDataType,
PragmaPricesResponse, YieldPoint, FutureKeyStatus, RequestStatus, OptionsFeedData,
PragmaPricesResponse, YieldPoint, FutureKeyStatus, RequestStatus, OptionsFeedData, Assertion
};
use openzeppelin::token::erc20::interface::ERC20ABIDispatcher;

#[starknet::interface]
trait IPragmaABI<TContractState> {
Expand Down Expand Up @@ -238,3 +239,50 @@ trait IRandomness<TContractState> {
fn get_admin_address(self: @TContractState,) -> ContractAddress;
fn set_admin_address(ref self: TContractState, new_admin_address: ContractAddress);
}

#[starknet::interface]
pub trait IOptimisticOracle<TContractState> {
fn assert_truth_with_defaults(
ref self: TContractState, claim: ByteArray, asserter: ContractAddress
) -> felt252;

fn assert_truth(
ref self: TContractState,
claim: ByteArray,
asserter: ContractAddress,
callback_recipient: ContractAddress,
escalation_manager: ContractAddress,
liveness: u64,
currency: ERC20ABIDispatcher,
bond: u256,
identifier: felt252,
domain_id: u256
) -> felt252;

fn dispute_assertion(
ref self: TContractState, assertion_id: felt252, disputer: ContractAddress
);

fn settle_assertion(ref self: TContractState, assertion_id: felt252);

fn get_minimum_bond(self: @TContractState, currency: ContractAddress) -> u256;

fn stamp_assertion(self: @TContractState, assertion_id: felt252) -> ByteArray;

fn default_identifier(self: @TContractState,) -> felt252;

fn get_assertion(self: @TContractState, assertion_id: felt252) -> Assertion;

fn sync_params(ref self: TContractState, identifier: felt252, currency: ContractAddress);

fn settle_and_get_assertion_result(ref self: TContractState, assertion_id: felt252) -> bool;

fn get_assertion_result(self: @TContractState, assertion_id: felt252) -> bool;

fn set_admin_properties(
ref self: TContractState,
default_currency: ContractAddress,
default_liveness: u64,
burned_bond_percentage: u256
);
}
26 changes: 26 additions & 0 deletions src/types.cairo
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use starknet::{ContractAddress, ClassHash};
use openzeppelin::token::erc20::interface::ERC20ABIDispatcher;

#[derive(Serde, Drop, Copy, PartialEq, starknet::Store)]
enum RequestStatus {
Expand Down Expand Up @@ -176,3 +177,28 @@ enum AggregationMode {
ConversionRate,
Error: (),
}

#[derive(starknet::Store, Drop, Serde, Copy)]
pub struct EscalationManagerSettings {
pub arbitrate_via_escalation_manager: bool,
pub discard_oracle: bool,
pub validate_disputers: bool,
pub asserting_caller: ContractAddress,
pub escalation_manager: ContractAddress,
}

#[derive(starknet::Store, Drop, Serde, Copy)]
pub struct Assertion {
pub escalation_manager_settings: EscalationManagerSettings,
pub asserter: ContractAddress,
pub assertion_time: u64,
pub settled: bool,
pub currency: ERC20ABIDispatcher,
pub expiration_time: u64,
pub settlement_resolution: bool,
pub domain_id: u256,
pub identifier: felt252,
pub bond: u256,
pub callback_recipient: ContractAddress,
pub disputer: ContractAddress,
}

0 comments on commit cf9c4cc

Please sign in to comment.