update to anchor28

This commit is contained in:
Conner Gallagher 2023-06-26 13:43:17 -06:00
parent dc90cf456f
commit 289eac2cb6
22 changed files with 847 additions and 496 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
[package]
name = "switchboard-solana"
version = "0.5.3"
version = "0.6.0"
edition = "2021"
description = "A Rust library to interact with Switchboard accounts."
readme = "README.md"
@ -21,23 +21,19 @@ no-entrypoint = []
cpi = ["no-entrypoint"]
[dependencies]
anchor-spl = "=0.26.0"
solana-program = ">= 1.13.5, < 1.14.19"
anchor-spl = "=0.28.0"
solana-program = ">= 1.16, < 1.17"
rust_decimal = "^1"
bytemuck = "^1"
superslice = "1"
# These may not be needed, anchor27 keeps complaining
winnow = "=0.4.1"
toml_edit = "=0.19.8"
toml_datetime = "=0.6.1"
[target.'cfg(target_os = "solana")'.dependencies]
switchboard-common = { version = "0.5.3" }
anchor-lang = { version = "=0.26.0" }
anchor-lang = { version = "=0.28.0" }
[target.'cfg(not(target_os = "solana"))'.dependencies]
switchboard-common = { version = "0.5.3", features = ["sgx"] }
anchor-client = { version = "=0.26.0" }
anchor-client = { version = "=0.28.0" }
bincode = { version = "^1" }
sgx-quote = { version = "0.1.0" }
cron = { version = "0.12.0" }

View File

@ -31,7 +31,7 @@ impl From<u32> for SwitchboardAttestationPermission {
}
}
#[zero_copy]
#[zero_copy(unsafe)]
#[repr(packed)]
#[derive(Debug)]
pub struct AttestationPermissionAccountData {

View File

@ -5,7 +5,7 @@ use std::cell::Ref;
use crate::SWITCHBOARD_ATTESTATION_PROGRAM_ID;
#[zero_copy]
#[zero_copy(unsafe)]
#[repr(packed)]
pub struct AttestationQueueAccountData {
/// The address of the authority which is permitted to add/remove allowed enclave measurements.

View File

@ -4,7 +4,7 @@ use bytemuck::{Pod, Zeroable};
use crate::SWITCHBOARD_ATTESTATION_PROGRAM_ID;
#[zero_copy]
#[zero_copy(unsafe)]
#[repr(packed)]
#[derive(Debug)]
pub struct AttestationProgramState {

View File

@ -40,7 +40,7 @@ impl From<u8> for VerificationStatus {
}
}
#[zero_copy]
#[zero_copy(unsafe)]
#[repr(packed)]
#[derive(Debug)]
pub struct EnclaveAccountData {

View File

@ -39,7 +39,7 @@ impl From<u8> for FunctionStatus {
}
}
}
#[zero_copy]
#[zero_copy(unsafe)]
#[repr(packed)]
#[derive(Debug, PartialEq)]
pub struct FunctionAccountData {

View File

@ -27,7 +27,7 @@ use std::convert::{From, TryInto};
// }
// }
#[zero_copy]
#[zero_copy(unsafe)]
#[repr(packed)]
#[derive(Default, Debug, Eq, PartialEq, AnchorDeserialize)]
pub struct SwitchboardDecimal {

View File

@ -3,7 +3,7 @@ use crate::prelude::*;
use rust_decimal::Decimal;
use std::cell::Ref;
#[zero_copy]
#[zero_copy(unsafe)]
#[repr(packed)]
#[derive(Default, Debug, PartialEq, Eq)]
pub struct Hash {
@ -11,7 +11,7 @@ pub struct Hash {
pub data: [u8; 32],
}
#[zero_copy]
#[zero_copy(unsafe)]
#[repr(packed)]
#[derive(Default, PartialEq, Eq)]
pub struct AggregatorRound {
@ -53,8 +53,8 @@ pub enum AggregatorResolutionMode {
ModeSlidingResolution = 1,
}
// #[zero_copy]
#[account(zero_copy)]
// #[zero_copy(unsafe)]
#[account(zero_copy(unsafe))]
#[repr(packed)]
#[derive(PartialEq)]
pub struct AggregatorAccountData {

View File

@ -1,7 +1,6 @@
#![allow(unaligned_references)]
use crate::prelude::*;
#[derive(AnchorDeserialize, Default, Debug)]
#[account]
pub struct BufferRelayerAccountData {
/// Name of the buffer account to store on-chain.
pub name: [u8; 32],
@ -27,8 +26,7 @@ pub struct BufferRelayerAccountData {
pub result: Vec<u8>,
}
#[zero_copy]
#[derive(Default, Debug, AnchorSerialize, AnchorDeserialize)]
#[derive(Default, Clone, AnchorSerialize, AnchorDeserialize)]
pub struct BufferRelayerRound {
/// Number of successful responses.
pub num_success: u32,
@ -98,11 +96,3 @@ impl BufferRelayerAccountData {
Ok(())
}
}
impl Discriminator for BufferRelayerAccountData {
const DISCRIMINATOR: [u8; 8] = [50, 35, 51, 115, 169, 219, 158, 52];
}
impl Owner for BufferRelayerAccountData {
fn owner() -> Pubkey {
SWITCHBOARD_PROGRAM_ID
}
}

View File

@ -1,7 +1,7 @@
use crate::prelude::*;
use bytemuck::{Pod, Zeroable};
#[zero_copy]
#[zero_copy(unsafe)]
#[derive(Default)]
#[repr(packed)]
pub struct CrankRow {
@ -13,7 +13,7 @@ pub struct CrankRow {
unsafe impl Pod for CrankRow {}
unsafe impl Zeroable for CrankRow {}
#[account(zero_copy)]
#[account(zero_copy(unsafe))]
#[repr(packed)]
pub struct CrankAccountData {
/// Name of the crank to store on-chain.

View File

@ -3,7 +3,7 @@
use crate::prelude::*;
use bytemuck::{Pod, Zeroable};
#[zero_copy]
#[zero_copy(unsafe)]
#[repr(packed)]
pub struct AccountMetaZC {
pub pubkey: Pubkey,
@ -11,7 +11,7 @@ pub struct AccountMetaZC {
pub is_writable: bool,
}
#[zero_copy]
#[zero_copy(unsafe)]
#[repr(packed)]
#[derive(AnchorSerialize, AnchorDeserialize)]
pub struct AccountMetaBorsh {
@ -20,7 +20,7 @@ pub struct AccountMetaBorsh {
pub is_writable: bool,
}
#[zero_copy]
#[zero_copy(unsafe)]
#[repr(packed)]
pub struct CallbackZC {
/// The program ID of the callback program being invoked.
@ -50,7 +50,7 @@ pub struct Callback {
pub ix_data: Vec<u8>,
}
#[zero_copy]
#[zero_copy(unsafe)]
#[repr(packed)]
pub struct VrfRound {
/// The alpha bytes used to calculate the VRF proof.
@ -102,7 +102,7 @@ impl std::fmt::Display for VrfStatus {
}
}
#[zero_copy]
#[zero_copy(unsafe)]
#[repr(packed)]
pub struct EcvrfProofZC {
pub Gamma: EdwardsPointZC, // RistrettoPoint
@ -118,7 +118,7 @@ impl Default for EcvrfProofZC {
/// The `Scalar` struct holds an integer \\(s < 2\^{255} \\) which
/// represents an element of \\(\mathbb Z / \ell\\).
#[allow(dead_code)]
#[zero_copy]
#[zero_copy(unsafe)]
#[repr(packed)]
pub struct Scalar {
/// `bytes` is a little-endian byte encoding of an integer representing a scalar modulo the
@ -159,7 +159,7 @@ pub struct FieldElement51(pub(crate) [u64; 5]);
unsafe impl Pod for FieldElement51 {}
unsafe impl Zeroable for FieldElement51 {}
#[zero_copy]
#[zero_copy(unsafe)]
#[repr(packed)]
pub struct FieldElementZC {
pub(crate) bytes: [u64; 5],
@ -198,7 +198,7 @@ pub struct CompletedPoint {
pub Z: FieldElement51,
pub T: FieldElement51,
}
#[zero_copy]
#[zero_copy(unsafe)]
#[repr(packed)]
pub struct CompletedPointZC {
pub X: FieldElementZC,
@ -244,7 +244,7 @@ pub struct EdwardsPoint {
pub(crate) T: FieldElement51,
}
#[allow(dead_code)]
#[zero_copy]
#[zero_copy(unsafe)]
#[repr(packed)]
pub struct EdwardsPointZC {
pub(crate) X: FieldElementZC,
@ -272,7 +272,7 @@ pub struct ProjectivePoint {
pub Y: FieldElement51,
pub Z: FieldElement51,
}
#[zero_copy]
#[zero_copy(unsafe)]
#[repr(packed)]
pub struct ProjectivePointZC {
pub(crate) X: FieldElementZC,
@ -305,7 +305,7 @@ impl Into<ProjectivePoint> for ProjectivePointZC {
}
}
#[zero_copy]
#[zero_copy(unsafe)]
#[repr(packed)]
pub struct EcvrfIntermediate {
pub r: FieldElementZC,
@ -318,7 +318,7 @@ unsafe impl Pod for EcvrfIntermediate {}
unsafe impl Zeroable for EcvrfIntermediate {}
#[allow(non_snake_case)]
#[zero_copy]
#[zero_copy(unsafe)]
#[repr(packed)]
pub struct VrfBuilder {
/// The OracleAccountData that is producing the randomness.

View File

@ -4,7 +4,7 @@ use bytemuck::{Pod, Zeroable};
use std::cell::Ref;
use superslice::*;
#[zero_copy]
#[zero_copy(unsafe)]
#[derive(Default)]
#[repr(packed)]
pub struct AggregatorHistoryRow {

View File

@ -1,6 +1,6 @@
use crate::prelude::*;
#[account(zero_copy)]
#[account(zero_copy(unsafe))]
#[repr(packed)]
pub struct LeaseAccountData {
/// Public key of the token account holding the lease contract funds until rewarded to oracles for successfully processing updates

View File

@ -10,7 +10,7 @@ pub enum OracleResponseType {
TypeNoResponse,
}
#[zero_copy]
#[zero_copy(unsafe)]
#[derive(Default)]
#[repr(packed)]
pub struct OracleMetrics {
@ -34,7 +34,7 @@ pub struct OracleMetrics {
pub total_late_response: u128,
}
#[account(zero_copy)]
#[account(zero_copy(unsafe))]
#[repr(packed)]
pub struct OracleAccountData {
/// Name of the oracle to store on-chain.

View File

@ -10,7 +10,7 @@ pub enum SwitchboardPermission {
PermitVrfRequests = 1 << 2,
}
#[account(zero_copy)]
#[account(zero_copy(unsafe))]
#[repr(packed)]
pub struct PermissionAccountData {
/// The authority that is allowed to set permissions for this account.

View File

@ -3,7 +3,7 @@ use crate::prelude::*;
use bytemuck::try_cast_slice_mut;
use std::cell::Ref;
#[account(zero_copy)]
#[account(zero_copy(unsafe))]
#[repr(packed)]
pub struct OracleQueueAccountData {
/// Name of the queue to store on-chain.

View File

@ -1,6 +1,6 @@
use crate::prelude::*;
#[account(zero_copy)]
#[account(zero_copy(unsafe))]
#[repr(packed)]
pub struct SbState {
/// The account authority permitted to make account changes.

View File

@ -1,6 +1,6 @@
use crate::prelude::*;
#[zero_copy]
#[zero_copy(unsafe)]
#[derive(Default)]
#[repr(packed)]
pub struct SlidingWindowElement {
@ -10,7 +10,7 @@ pub struct SlidingWindowElement {
pub timestamp: i64,
}
#[account(zero_copy)]
#[account(zero_copy(unsafe))]
#[repr(packed)]
pub struct SlidingResultAccountData {
pub data: [SlidingWindowElement; 16],

View File

@ -7,7 +7,7 @@ use std::cell::Ref;
// VrfSetCallback
// VrfClose
#[account(zero_copy)]
#[account(zero_copy(unsafe))]
#[repr(packed)]
pub struct VrfAccountData {
/// The current status of the VRF account.

View File

@ -3,7 +3,7 @@ use crate::cfg_client;
use crate::prelude::*;
use std::cell::Ref;
#[account(zero_copy)]
#[account(zero_copy(unsafe))]
#[repr(packed)]
pub struct VrfLiteAccountData {
/// The bump used to derive the SbState account.

View File

@ -15,7 +15,7 @@ pub struct VrfPoolRow {
}
#[repr(packed)]
#[account(zero_copy)]
#[account(zero_copy(unsafe))]
pub struct VrfPoolAccountData {
/// ACCOUNTS
pub authority: Pubkey, // authority can never be changed or else vrf accounts are useless