Merge branch 'main' of github.com:switchboard-xyz/switchboard-v2

This commit is contained in:
Jackson Jessup 2022-12-01 12:04:47 -05:00
commit c851aa35e4
6 changed files with 50 additions and 20 deletions

View File

@ -1,17 +1,17 @@
{
"name": "@switchboard-xyz/switchboard-v2",
"version": "0.0.165",
"version": "0.0.169",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@switchboard-xyz/switchboard-v2",
"version": "0.0.165",
"version": "0.0.169",
"license": "MIT",
"dependencies": {
"@project-serum/anchor": "^0.25.0",
"@solana/spl-governance": "^0.0.34",
"@solana/spl-token": "^0.3.6",
"@solana/spl-token-v3": "npm:@solana/spl-token@0.3.6",
"@solana/web3.js": "^1.66.2",
"@switchboard-xyz/common": "^2.1.7",
"big.js": "^6.2.1",
@ -184,7 +184,8 @@
},
"node_modules/@solana/buffer-layout-utils": {
"version": "0.2.0",
"license": "Apache-2.0",
"resolved": "https://registry.npmjs.org/@solana/buffer-layout-utils/-/buffer-layout-utils-0.2.0.tgz",
"integrity": "sha512-szG4sxgJGktbuZYDg2FfNmkMi0DYQoVjN2h7ta1W1hPrwzarcFLBq9UpX1UjNXsNpT9dn+chgprtWGioUAr4/g==",
"dependencies": {
"@solana/buffer-layout": "^4.0.0",
"@solana/web3.js": "^1.32.0",
@ -257,7 +258,8 @@
"version": "0.15.5",
"license": "MIT"
},
"node_modules/@solana/spl-token": {
"node_modules/@solana/spl-token-v3": {
"name": "@solana/spl-token",
"version": "0.3.6",
"resolved": "https://registry.npmjs.org/@solana/spl-token/-/spl-token-0.3.6.tgz",
"integrity": "sha512-P9pTXjDIRvVbjr3J0mCnSamYqLnICeds7IoH1/Ro2R9OBuOHdp5pqKZoscfZ3UYrgnCWUc1bc9M2m/YPHjw+1g==",
@ -273,7 +275,7 @@
"@solana/web3.js": "^1.47.4"
}
},
"node_modules/@solana/spl-token/node_modules/buffer": {
"node_modules/@solana/spl-token-v3/node_modules/buffer": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
"integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",
@ -2089,6 +2091,8 @@
},
"@solana/buffer-layout-utils": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/@solana/buffer-layout-utils/-/buffer-layout-utils-0.2.0.tgz",
"integrity": "sha512-szG4sxgJGktbuZYDg2FfNmkMi0DYQoVjN2h7ta1W1hPrwzarcFLBq9UpX1UjNXsNpT9dn+chgprtWGioUAr4/g==",
"requires": {
"@solana/buffer-layout": "^4.0.0",
"@solana/web3.js": "^1.32.0",
@ -2133,8 +2137,8 @@
}
}
},
"@solana/spl-token": {
"version": "0.3.6",
"@solana/spl-token-v3": {
"version": "npm:@solana/spl-token@0.3.6",
"resolved": "https://registry.npmjs.org/@solana/spl-token/-/spl-token-0.3.6.tgz",
"integrity": "sha512-P9pTXjDIRvVbjr3J0mCnSamYqLnICeds7IoH1/Ro2R9OBuOHdp5pqKZoscfZ3UYrgnCWUc1bc9M2m/YPHjw+1g==",
"requires": {

View File

@ -1,6 +1,6 @@
{
"name": "@switchboard-xyz/switchboard-v2",
"version": "0.0.167",
"version": "0.0.171",
"license": "MIT",
"author": "mitch@switchboard.xyz",
"description": "API wrapper for intergating with the Switchboardv2 program",
@ -46,7 +46,7 @@
"dependencies": {
"@project-serum/anchor": "^0.25.0",
"@solana/spl-governance": "^0.0.34",
"@solana/spl-token": "^0.3.6",
"@solana/spl-token-v3": "npm:@solana/spl-token@0.3.6",
"@solana/web3.js": "^1.66.2",
"@switchboard-xyz/common": "^2.1.7",
"big.js": "^6.2.1",

View File

@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
import * as anchor from "@project-serum/anchor";
import * as spl from "@solana/spl-token";
import * as spl from "@solana/spl-token-v3";
import {
AccountInfo,
AccountMeta,

View File

@ -1,6 +1,6 @@
[package]
name = "switchboard-v2"
version = "0.1.16"
version = "0.1.17"
edition = "2021"
description = "A Rust library to interact with Switchboard V2 accounts."
readme = "README.md"
@ -22,10 +22,10 @@ cpi = ["no-entrypoint"]
devnet = []
[dependencies]
anchor-lang = "0.25.0"
anchor-spl = "0.25.0"
rust_decimal = { version = "1.18.0" }
solana-program = "~1.10.29"
anchor-lang = { git = "https://github.com/coral-xyz/anchor.git", rev = "66e4295fe0d2cc2456055bea50e8d227492bdbad" }
anchor-spl = { git = "https://github.com/coral-xyz/anchor.git", rev = "66e4295fe0d2cc2456055bea50e8d227492bdbad" }
rust_decimal = "1.26.0"
solana-program = "1.10"
bytemuck = "1.7.2"
superslice = "1"
spl-token = "3.3.1"
spl-token = "3.5"

View File

@ -175,6 +175,34 @@ impl AggregatorAccountData {
bytemuck::from_bytes(&data[8..std::mem::size_of::<AggregatorAccountData>() + 8])
}))
}
/// Returns the deserialized Switchboard Aggregator account
///
/// # Arguments
///
/// * `data` - A Solana AccountInfo's data buffer
///
/// # Examples
///
/// ```ignore
/// use switchboard_v2::AggregatorAccountData;
///
/// let data_feed = AggregatorAccountData::new(feed_account_info.try_borrow_data()?)?;
/// ```
pub fn new_from_bytes(data: &[u8]) -> anchor_lang::Result<&AggregatorAccountData> {
if data.len() < AggregatorAccountData::discriminator().len() {
return Err(ErrorCode::AccountDiscriminatorNotFound.into());
}
let mut disc_bytes = [0u8; 8];
disc_bytes.copy_from_slice(&data[..8]);
if disc_bytes != AggregatorAccountData::discriminator() {
return Err(ErrorCode::AccountDiscriminatorMismatch.into());
}
Ok(bytemuck::from_bytes(&data[8..std::mem::size_of::<AggregatorAccountData>() + 8]))
}
/// If sufficient oracle responses, returns the latest on-chain result in SwitchboardDecimal format
///
/// # Examples

View File

@ -101,9 +101,7 @@ impl BufferRelayerAccountData {
}
}
impl Discriminator for BufferRelayerAccountData {
fn discriminator() -> [u8; 8] {
[50, 35, 51, 115, 169, 219, 158, 52]
}
const DISCRIMINATOR: [u8; 8] = [50, 35, 51, 115, 169, 219, 158, 52];
}
impl Owner for BufferRelayerAccountData {
fn owner() -> solana_program::pubkey::Pubkey {