Skip to content

Commit

Permalink
chore: Fix pyth sdk (#59)
Browse files Browse the repository at this point in the history
* chore: Fix pyth sdk

* Fix lints
  • Loading branch information
Aursen authored Sep 3, 2024
1 parent fe7157d commit 89fd035
Show file tree
Hide file tree
Showing 13 changed files with 205 additions and 94 deletions.
72 changes: 2 additions & 70 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ anchor-spl = "=0.29.0"
anyhow = "1.0"
base64 = "~0.21"
bincode = "1.3"
borsh = "0.10.3"
bytemuck = "1.17.1"
bzip2 = "0.4"
cargo_metadata = "=0.18.1"
Expand All @@ -40,7 +41,6 @@ indicatif = "0.17"
log = "0.4"
nom = "~7"
proc-macro2 = "1.0"
pyth-solana-receiver-sdk = "0.3.1"
quote = "1.0"
rayon = "1.10.0"
regex = "1.10.6"
Expand Down
1 change: 0 additions & 1 deletion plugin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ sablier-thread-program = { workspace = true, features = ["no-entrypoint"] }
sablier-webhook-program = { workspace = true, features = ["no-entrypoint"] }
sablier-utils.workspace = true
log.workspace = true
pyth-solana-receiver-sdk.workspace = true
reqwest.workspace = true
solana-account-decoder.workspace = true
solana-client.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions plugin/src/builders/thread_exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use anchor_lang::{InstructionData, ToAccountMetas};
use log::info;
use sablier_network_program::state::Worker;
use sablier_thread_program::state::{Trigger, VersionedThread};
use sablier_utils::thread::PAYER_PUBKEY;
use sablier_utils::{pyth::get_oracle_key, thread::PAYER_PUBKEY};
use solana_account_decoder::UiAccountEncoding;
use solana_client::{
nonblocking::rpc_client::RpcClient,
Expand All @@ -21,7 +21,7 @@ use solana_sdk::{
transaction::Transaction,
};

use crate::{error::PluginError, utils::get_oracle_key};
use crate::error::PluginError;

/// Max byte size of a serialized transaction.
static TRANSACTION_MESSAGE_SIZE_LIMIT: usize = 1_232;
Expand Down
4 changes: 2 additions & 2 deletions plugin/src/events.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anchor_lang::{AccountDeserialize, Discriminator};
use pyth_solana_receiver_sdk::price_update::{PriceFeedMessage, PriceUpdateV2};
use sablier_thread_program::state::{Thread, VersionedThread};
use sablier_utils::pyth::{self, PriceFeedMessage, PriceUpdateV2};
use sablier_webhook_program::state::Webhook;
use solana_geyser_plugin_interface::geyser_plugin_interface::ReplicaAccountInfoVersions;
use solana_sdk::{clock::Clock, pubkey::Pubkey, sysvar};
Expand Down Expand Up @@ -59,7 +59,7 @@ fn parse_event(
}
}

if owner == pyth_solana_receiver_sdk::ID {
if owner == pyth::ID {
return Ok(Some(AccountUpdateEvent::PriceFeed {
price_feed: PriceUpdateV2::try_deserialize(&mut data)?.price_message,
}));
Expand Down
4 changes: 2 additions & 2 deletions plugin/src/observers/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use std::{

use chrono::DateTime;
use log::info;
use pyth_solana_receiver_sdk::price_update::PriceFeedMessage;
use sablier_cron::Schedule;
use sablier_thread_program::state::{Equality, Trigger, TriggerContext, VersionedThread};
use sablier_utils::pyth::{get_oracle_key, PriceFeedMessage};
use solana_program::{clock::Clock, pubkey::Pubkey};

use crate::{error::PluginError, observers::state::PythThread, utils::get_oracle_key};
use crate::{error::PluginError, observers::state::PythThread};

use super::state::{
AccountThreads, Clocks, CronThreads, EpochThreads, NowThreads, PythThreads, SlotThreads,
Expand Down
10 changes: 0 additions & 10 deletions plugin/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
use pyth_solana_receiver_sdk::price_update::FeedId;
use solana_program::pubkey::Pubkey;
use solana_sdk::signature::{read_keypair_file, Keypair};

pub fn get_oracle_key(shard_id: u16, feed_id: FeedId) -> Pubkey {
let (pubkey, _) = Pubkey::find_program_address(
&[&shard_id.to_be_bytes(), &feed_id],
&pyth_solana_receiver_sdk::PYTH_PUSH_ORACLE_ID,
);
pubkey
}

pub fn read_or_new_keypair(keypath: Option<String>) -> Keypair {
match keypath {
Some(keypath) => read_keypair_file(keypath).unwrap(),
Expand Down
1 change: 0 additions & 1 deletion programs/thread/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ chrono = { workspace = true, features = ["alloc"] }
sablier-cron.workspace = true
sablier-network-program = { features = ["cpi"], workspace = true }
sablier-utils.workspace = true
pyth-solana-receiver-sdk.workspace = true
version.workspace = true
8 changes: 5 additions & 3 deletions programs/thread/src/instructions/thread_kickoff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ use std::{

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 sablier_utils::{
pyth::{self, PriceUpdateV2},
thread::Trigger,
};

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

Expand Down Expand Up @@ -207,7 +209,7 @@ pub fn handler(ctx: Context<ThreadKickoff>) -> Result<()> {
Some(account_info) => {
require_keys_eq!(
*account_info.owner,
pyth_solana_receiver_sdk::ID,
pyth::ID,
SablierError::TriggerConditionFailed
);
const STALENESS_THRESHOLD: u64 = 60; // staleness threshold in seconds
Expand Down
3 changes: 2 additions & 1 deletion utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ name = "sablier_utils"
[dependencies]
anchor-lang.workspace = true
base64.workspace = true
borsh.workspace = true
serde = { workspace = true, features = ["derive"] }
static-pubkey.workspace = true
sablier-macros.workspace = true
pyth-solana-receiver-sdk.workspace = true
solana-program.workspace = true

[dev-dependencies]
solana-sdk.workspace = true
1 change: 1 addition & 0 deletions utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub mod account;
pub mod explorer;
pub mod pubkey;
pub mod pyth;
pub mod space;
pub mod thread;

Expand Down
Loading

0 comments on commit 89fd035

Please sign in to comment.