Merge branch 'main' of github.com:switchboard-xyz/switchboard-v2
This commit is contained in:
commit
c851aa35e4
|
@ -1,17 +1,17 @@
|
||||||
{
|
{
|
||||||
"name": "@switchboard-xyz/switchboard-v2",
|
"name": "@switchboard-xyz/switchboard-v2",
|
||||||
"version": "0.0.165",
|
"version": "0.0.169",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@switchboard-xyz/switchboard-v2",
|
"name": "@switchboard-xyz/switchboard-v2",
|
||||||
"version": "0.0.165",
|
"version": "0.0.169",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@project-serum/anchor": "^0.25.0",
|
"@project-serum/anchor": "^0.25.0",
|
||||||
"@solana/spl-governance": "^0.0.34",
|
"@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",
|
"@solana/web3.js": "^1.66.2",
|
||||||
"@switchboard-xyz/common": "^2.1.7",
|
"@switchboard-xyz/common": "^2.1.7",
|
||||||
"big.js": "^6.2.1",
|
"big.js": "^6.2.1",
|
||||||
|
@ -184,7 +184,8 @@
|
||||||
},
|
},
|
||||||
"node_modules/@solana/buffer-layout-utils": {
|
"node_modules/@solana/buffer-layout-utils": {
|
||||||
"version": "0.2.0",
|
"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": {
|
"dependencies": {
|
||||||
"@solana/buffer-layout": "^4.0.0",
|
"@solana/buffer-layout": "^4.0.0",
|
||||||
"@solana/web3.js": "^1.32.0",
|
"@solana/web3.js": "^1.32.0",
|
||||||
|
@ -257,7 +258,8 @@
|
||||||
"version": "0.15.5",
|
"version": "0.15.5",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@solana/spl-token": {
|
"node_modules/@solana/spl-token-v3": {
|
||||||
|
"name": "@solana/spl-token",
|
||||||
"version": "0.3.6",
|
"version": "0.3.6",
|
||||||
"resolved": "https://registry.npmjs.org/@solana/spl-token/-/spl-token-0.3.6.tgz",
|
"resolved": "https://registry.npmjs.org/@solana/spl-token/-/spl-token-0.3.6.tgz",
|
||||||
"integrity": "sha512-P9pTXjDIRvVbjr3J0mCnSamYqLnICeds7IoH1/Ro2R9OBuOHdp5pqKZoscfZ3UYrgnCWUc1bc9M2m/YPHjw+1g==",
|
"integrity": "sha512-P9pTXjDIRvVbjr3J0mCnSamYqLnICeds7IoH1/Ro2R9OBuOHdp5pqKZoscfZ3UYrgnCWUc1bc9M2m/YPHjw+1g==",
|
||||||
|
@ -273,7 +275,7 @@
|
||||||
"@solana/web3.js": "^1.47.4"
|
"@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",
|
"version": "6.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
|
||||||
"integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",
|
"integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",
|
||||||
|
@ -2089,6 +2091,8 @@
|
||||||
},
|
},
|
||||||
"@solana/buffer-layout-utils": {
|
"@solana/buffer-layout-utils": {
|
||||||
"version": "0.2.0",
|
"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": {
|
"requires": {
|
||||||
"@solana/buffer-layout": "^4.0.0",
|
"@solana/buffer-layout": "^4.0.0",
|
||||||
"@solana/web3.js": "^1.32.0",
|
"@solana/web3.js": "^1.32.0",
|
||||||
|
@ -2133,8 +2137,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@solana/spl-token": {
|
"@solana/spl-token-v3": {
|
||||||
"version": "0.3.6",
|
"version": "npm:@solana/spl-token@0.3.6",
|
||||||
"resolved": "https://registry.npmjs.org/@solana/spl-token/-/spl-token-0.3.6.tgz",
|
"resolved": "https://registry.npmjs.org/@solana/spl-token/-/spl-token-0.3.6.tgz",
|
||||||
"integrity": "sha512-P9pTXjDIRvVbjr3J0mCnSamYqLnICeds7IoH1/Ro2R9OBuOHdp5pqKZoscfZ3UYrgnCWUc1bc9M2m/YPHjw+1g==",
|
"integrity": "sha512-P9pTXjDIRvVbjr3J0mCnSamYqLnICeds7IoH1/Ro2R9OBuOHdp5pqKZoscfZ3UYrgnCWUc1bc9M2m/YPHjw+1g==",
|
||||||
"requires": {
|
"requires": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@switchboard-xyz/switchboard-v2",
|
"name": "@switchboard-xyz/switchboard-v2",
|
||||||
"version": "0.0.167",
|
"version": "0.0.171",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "mitch@switchboard.xyz",
|
"author": "mitch@switchboard.xyz",
|
||||||
"description": "API wrapper for intergating with the Switchboardv2 program",
|
"description": "API wrapper for intergating with the Switchboardv2 program",
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@project-serum/anchor": "^0.25.0",
|
"@project-serum/anchor": "^0.25.0",
|
||||||
"@solana/spl-governance": "^0.0.34",
|
"@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",
|
"@solana/web3.js": "^1.66.2",
|
||||||
"@switchboard-xyz/common": "^2.1.7",
|
"@switchboard-xyz/common": "^2.1.7",
|
||||||
"big.js": "^6.2.1",
|
"big.js": "^6.2.1",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||||
/* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
|
/* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
|
||||||
import * as anchor from "@project-serum/anchor";
|
import * as anchor from "@project-serum/anchor";
|
||||||
import * as spl from "@solana/spl-token";
|
import * as spl from "@solana/spl-token-v3";
|
||||||
import {
|
import {
|
||||||
AccountInfo,
|
AccountInfo,
|
||||||
AccountMeta,
|
AccountMeta,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "switchboard-v2"
|
name = "switchboard-v2"
|
||||||
version = "0.1.16"
|
version = "0.1.17"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "A Rust library to interact with Switchboard V2 accounts."
|
description = "A Rust library to interact with Switchboard V2 accounts."
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
@ -22,10 +22,10 @@ cpi = ["no-entrypoint"]
|
||||||
devnet = []
|
devnet = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anchor-lang = "0.25.0"
|
anchor-lang = { git = "https://github.com/coral-xyz/anchor.git", rev = "66e4295fe0d2cc2456055bea50e8d227492bdbad" }
|
||||||
anchor-spl = "0.25.0"
|
anchor-spl = { git = "https://github.com/coral-xyz/anchor.git", rev = "66e4295fe0d2cc2456055bea50e8d227492bdbad" }
|
||||||
rust_decimal = { version = "1.18.0" }
|
rust_decimal = "1.26.0"
|
||||||
solana-program = "~1.10.29"
|
solana-program = "1.10"
|
||||||
bytemuck = "1.7.2"
|
bytemuck = "1.7.2"
|
||||||
superslice = "1"
|
superslice = "1"
|
||||||
spl-token = "3.3.1"
|
spl-token = "3.5"
|
||||||
|
|
|
@ -175,6 +175,34 @@ impl AggregatorAccountData {
|
||||||
bytemuck::from_bytes(&data[8..std::mem::size_of::<AggregatorAccountData>() + 8])
|
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
|
/// If sufficient oracle responses, returns the latest on-chain result in SwitchboardDecimal format
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
|
|
|
@ -101,9 +101,7 @@ impl BufferRelayerAccountData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Discriminator for BufferRelayerAccountData {
|
impl Discriminator for BufferRelayerAccountData {
|
||||||
fn discriminator() -> [u8; 8] {
|
const DISCRIMINATOR: [u8; 8] = [50, 35, 51, 115, 169, 219, 158, 52];
|
||||||
[50, 35, 51, 115, 169, 219, 158, 52]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
impl Owner for BufferRelayerAccountData {
|
impl Owner for BufferRelayerAccountData {
|
||||||
fn owner() -> solana_program::pubkey::Pubkey {
|
fn owner() -> solana_program::pubkey::Pubkey {
|
||||||
|
|
Loading…
Reference in New Issue