0.3.2
This commit is contained in:
parent
d4c46e3db9
commit
aeaf1f6c0d
|
@ -3613,7 +3613,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "switchboard-solana"
|
||||
version = "0.3.1"
|
||||
version = "0.3.2"
|
||||
dependencies = [
|
||||
"anchor-lang",
|
||||
"anchor-spl",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "switchboard-solana"
|
||||
version = "0.3.1"
|
||||
version = "0.3.2"
|
||||
edition = "2021"
|
||||
description = "A Rust library to interact with Switchboard accounts."
|
||||
readme = "README.md"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{QuoteAccountData, SWITCHBOARD_ATTESTATION_PROGRAM_ID};
|
||||
use crate::{cfg_client, QuoteAccountData, SWITCHBOARD_ATTESTATION_PROGRAM_ID};
|
||||
use anchor_lang::prelude::*;
|
||||
use anchor_lang::{Discriminator, Owner, ZeroCopy};
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
|
@ -161,8 +161,7 @@ impl FunctionAccountData {
|
|||
format!("{}:{}", self.get_container(), self.get_version())
|
||||
}
|
||||
|
||||
#[cfg(feature = "client")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "client")))]
|
||||
cfg_client! {
|
||||
pub fn get_schedule(&self) -> Option<cron::Schedule> {
|
||||
if self.schedule[0] == 0 {
|
||||
return None;
|
||||
|
@ -175,8 +174,6 @@ impl FunctionAccountData {
|
|||
Some(schedule.unwrap_or(every_second.clone()))
|
||||
}
|
||||
|
||||
#[cfg(feature = "client")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "client")))]
|
||||
pub fn get_last_execution_datetime(&self) -> chrono::DateTime<chrono::Utc> {
|
||||
chrono::DateTime::from_utc(
|
||||
chrono::NaiveDateTime::from_timestamp_opt(self.last_execution_timestamp, 0).unwrap(),
|
||||
|
@ -184,8 +181,6 @@ impl FunctionAccountData {
|
|||
)
|
||||
}
|
||||
|
||||
#[cfg(feature = "client")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "client")))]
|
||||
pub fn should_execute(&self, now: chrono::DateTime<chrono::Utc>) -> bool {
|
||||
let schedule = self.get_schedule();
|
||||
if schedule.is_none() {
|
||||
|
@ -203,8 +198,7 @@ impl FunctionAccountData {
|
|||
true
|
||||
}
|
||||
|
||||
#[cfg(feature = "client")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "client")))]
|
||||
|
||||
pub fn next_execution_timestamp(&self) -> Option<chrono::DateTime<chrono::Utc>> {
|
||||
let schedule = self.get_schedule();
|
||||
if schedule.is_none() {
|
||||
|
@ -214,8 +208,6 @@ impl FunctionAccountData {
|
|||
schedule.unwrap().after(&dt).next()
|
||||
}
|
||||
|
||||
#[cfg(feature = "client")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "client")))]
|
||||
pub async fn fetch(
|
||||
client: &solana_client::rpc_client::RpcClient,
|
||||
pubkey: Pubkey,
|
||||
|
@ -223,3 +215,4 @@ impl FunctionAccountData {
|
|||
crate::client::load_account(client, pubkey).await
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#![cfg_attr(doc_cfg, feature(doc_cfg))]
|
||||
#![allow(clippy::result_large_err)]
|
||||
use anchor_lang::prelude::*;
|
||||
use anchor_lang::solana_program::pubkey;
|
||||
|
@ -12,27 +13,17 @@ pub use attestation_program::*;
|
|||
//
|
||||
// This module is not intended to be part of the public API. In general, any
|
||||
// `doc(hidden)` code is not part of the public and stable API.
|
||||
// #[macro_use]
|
||||
// #[doc(hidden)]
|
||||
// pub mod macros;
|
||||
#[macro_use]
|
||||
#[doc(hidden)]
|
||||
pub mod macros;
|
||||
|
||||
#[cfg(feature = "client")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "client")))]
|
||||
#[cfg(not(target_os = "solana"))]
|
||||
cfg_client! {
|
||||
pub mod client;
|
||||
#[cfg(feature = "client")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "client")))]
|
||||
#[cfg(not(target_os = "solana"))]
|
||||
pub use client::*;
|
||||
|
||||
#[cfg(feature = "client")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "client")))]
|
||||
#[cfg(not(target_os = "solana"))]
|
||||
pub mod sgx;
|
||||
#[cfg(feature = "client")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "client")))]
|
||||
#[cfg(not(target_os = "solana"))]
|
||||
pub use sgx::*;
|
||||
}
|
||||
|
||||
/// Seed used to derive the SbState PDA.
|
||||
pub const STATE_SEED: &[u8] = b"STATE";
|
||||
|
|
|
@ -1,28 +1,15 @@
|
|||
macro_rules! cfg_solana {
|
||||
($($item:item)*) => {
|
||||
$(
|
||||
#[cfg(target_os = "solana")]
|
||||
$item
|
||||
)*
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! cfg_not_solana {
|
||||
($($item:item)*) => {
|
||||
$( #[cfg(not(target_os = "solana"))] $item )*
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! cfg_client {
|
||||
($($item:item)*) => {
|
||||
$(
|
||||
#[cfg(feature = "client")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "client")))]
|
||||
#[cfg_attr(doc_cfg, doc(cfg(feature = "client")))]
|
||||
$item
|
||||
)*
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! cfg_not_client {
|
||||
($($item:item)*) => {
|
||||
$( #[cfg(not(feature = "client"))] $item )*
|
||||
|
|
|
@ -279,8 +279,7 @@ impl AggregatorAccountData {
|
|||
Ok(Clock::get()?.unix_timestamp < self.expiration)
|
||||
}
|
||||
|
||||
#[cfg(feature = "client")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "client")))]
|
||||
cfg_client! {
|
||||
pub async fn fetch(
|
||||
client: &solana_client::rpc_client::RpcClient,
|
||||
pubkey: Pubkey,
|
||||
|
@ -288,6 +287,7 @@ impl AggregatorAccountData {
|
|||
crate::client::load_account(client, pubkey).await
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
|
Loading…
Reference in New Issue