Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
adrena-orex committed Aug 20, 2024
1 parent 37c636c commit 9f62166
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions programs/thread/src/instructions/thread_kickoff.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
use std::{
collections::hash_map::DefaultHasher,
hash::{Hash, Hasher},
str::FromStr,
};

use anchor_lang::prelude::*;
use chrono::DateTime;
use pyth_solana_receiver_sdk::price_update::PriceUpdateV2;
use sablier_cron::Schedule;
use sablier_network_program::state::{Worker, WorkerAccount};
use sablier_utils::thread::Trigger;
use std::{
collections::hash_map::DefaultHasher,
hash::{Hash, Hasher},
str::FromStr,
};

use crate::{constants::*, errors::*, state::*};

Expand Down Expand Up @@ -210,20 +211,8 @@ pub fn handler(ctx: Context<ThreadKickoff>) -> Result<()> {
SablierError::TriggerConditionFailed
);
const STALENESS_THRESHOLD: u64 = 60; // staleness threshold in seconds

// Do not work idk why
// let price_update =
// PriceUpdateV2::try_deserialize(&mut account_info.data.borrow().as_ref())?;

let data: &[u8] = &account_info.data.borrow()[8..];
let price_update_maybe: std::result::Result<PriceUpdateV2, std::io::Error> =
AnchorDeserialize::try_from_slice(data);

if price_update_maybe.is_err() {
return Err(SablierError::InvalidOracleAccount.into());
}

let price_update = price_update_maybe.unwrap();
let price_update =
PriceUpdateV2::try_deserialize(&mut account_info.data.borrow().as_ref())?;

let current_price = price_update.get_price_no_older_than(
&Clock::get()?,
Expand Down

0 comments on commit 9f62166

Please sign in to comment.