diff --git a/README.md b/README.md index 34ed7a6..2360e5f 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,12 @@ A monorepo containing APIs, Utils, and examples for Switchboard V2. ### Program Examples -| Package | Description | -| --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | -| [anchor-feed-parser](./programs/anchor-feed-parser) | Anchor example program demonstrating how to deserialize and read an onchain aggregator. | -| [native-feed-parser](./programs/native-feed-parser) | Solana Program Library example demonstrating how to deserialize and read an onchain aggregator. | -| [anchor-vrf-parser](./programs/anchor-vrf-parser) | Anchor example program demonstrating how to deserialize and read an onchain verifiable randomness function (VRF) account. | +| Package | Description | +| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | +| [anchor-feed-parser](./programs/anchor-feed-parser) | Anchor example program demonstrating how to deserialize and read an onchain aggregator account. | +| [native-feed-parser](./programs/native-feed-parser) | Solana Program Library example demonstrating how to deserialize and read an onchain aggregator account. | +| [anchor-vrf-parser](./programs/anchor-vrf-parser) | Anchor example program demonstrating how to deserialize and read an onchain verifiable randomness function (VRF) account. | +| [anchor-buffer-parser](./programs/anchor-buffer-parser) | Anchor example program demonstrating how to deserialize and read an onchain buffer relayer account. | ### Client Examples diff --git a/libraries/rs/README.md b/libraries/rs/README.md index d97188a..5e6c1c5 100644 --- a/libraries/rs/README.md +++ b/libraries/rs/README.md @@ -21,7 +21,7 @@ from a provided data feed AccountInfo. ```rust use anchor_lang::solana_program::clock; use std::convert::TryInto; -use switchboard_v2::{AggregatorAccountData, SWITCHBOARD_V2_DEVNET, SWITCHBOARD_V2_MAINNET}; +use switchboard_v2::{AggregatorAccountData, SwitchboardDecimal, SWITCHBOARD_V2_DEVNET, SWITCHBOARD_V2_MAINNET}; // check feed owner let owner = *aggregator.owner; @@ -39,7 +39,7 @@ let decimal: f64 = feed.get_result()?.try_into()?; feed.check_staleness(clock::Clock::get().unwrap().unix_timestamp, 300)?; // check if feed exceeds a confidence interval of +/i $0.80 -feed.check_confidence_interval(0.80)?; +feed.check_confidence_interval(SwitchboardDecimal::from_f64(0.80))?; ``` ### Aggregator History diff --git a/programs/README.md b/programs/README.md index 05f210a..5ad7589 100644 --- a/programs/README.md +++ b/programs/README.md @@ -1,7 +1,8 @@ ### Sbv2 Program Examples -| Package | Description | -| ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- | -| [anchor-feed-parser](./anchor-feed-parser) | Anchor example program demonstrating how to deserialize and read an onchain aggregator. | -| [native-feed-parser](./native-feed-parser) | Solana Program Library example demonstrating how to deserialize and read an onchain aggregator. | -| [anchor-vrf-parser](./anchor-vrf-parser) | Anchor example program demonstrating how to deserialize and read an onchain verifiable randomness function (VRF) account. | +| Package | Description | +| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | +| [anchor-feed-parser](./anchor-feed-parser) | Anchor example program demonstrating how to deserialize and read an onchain aggregator account. | +| [native-feed-parser](./native-feed-parser) | Solana Program Library example demonstrating how to deserialize and read an onchain aggregator account. | +| [anchor-vrf-parser](./anchor-vrf-parser) | Anchor example program demonstrating how to deserialize and read an onchain verifiable randomness function (VRF) account. | +| [anchor-buffer-parser](./anchor-buffer-parser) | Anchor example program demonstrating how to deserialize and read an onchain buffer relayer account. | diff --git a/programs/anchor-buffer-parser/Cargo.toml b/programs/anchor-buffer-parser/Cargo.toml index d2beec5..66e7527 100644 --- a/programs/anchor-buffer-parser/Cargo.toml +++ b/programs/anchor-buffer-parser/Cargo.toml @@ -16,7 +16,7 @@ cpi = ["no-entrypoint"] default = [] [dependencies] -switchboard-v2 = { path = "../../libraries/rs" } -# switchboard-v2 = "^0.1.11" +# switchboard-v2 = { path = "../../libraries/rs" } +switchboard-v2 = "^0.1.11" anchor-lang = "^0.24.2" solana-program = "~1.9.13" \ No newline at end of file diff --git a/programs/anchor-buffer-parser/tests/anchor-buffer-parser.test.ts b/programs/anchor-buffer-parser/tests/anchor-buffer-parser.test.ts index 26708fb..bb8bd01 100644 --- a/programs/anchor-buffer-parser/tests/anchor-buffer-parser.test.ts +++ b/programs/anchor-buffer-parser/tests/anchor-buffer-parser.test.ts @@ -39,25 +39,12 @@ describe("anchor-buffer-parser test", () => { const payer = (provider.wallet as AnchorWallet).payer; let switchboard: SwitchboardTestContext; - let localnet = false; before(async () => { - // First, attempt to load the switchboard devnet PID - try { - switchboard = await SwitchboardTestContext.loadDevnetQueue( - provider, - "9e8rQPoyVZeGA1mD2BBVqDthbFwircnfLTB5JE6yUFQR" - ); - console.log("devnet detected"); - return; - } catch (error: any) { - console.log(`Error: SBV2 Devnet - ${error.message}`); - } - // If fails, fallback to looking for a local env file + // Attempt to load the env from a local file try { switchboard = await SwitchboardTestContext.loadFromEnv(provider); - localnet = true; - console.log("localnet detected"); + console.log("local env file detected"); return; } catch (error: any) { console.log(`Error: SBV2 Localnet - ${error.message}`); diff --git a/programs/anchor-feed-parser/Cargo.toml b/programs/anchor-feed-parser/Cargo.toml index c346ed6..71fd467 100644 --- a/programs/anchor-feed-parser/Cargo.toml +++ b/programs/anchor-feed-parser/Cargo.toml @@ -16,7 +16,7 @@ cpi = ["no-entrypoint"] default = [] [dependencies] -switchboard-v2 = { path = "../../libraries/rs" } -# switchboard-v2 = "^0.1.11" +# switchboard-v2 = { path = "../../libraries/rs" } +switchboard-v2 = "^0.1.11" anchor-lang = "^0.24.2" solana-program = "~1.9.13" \ No newline at end of file diff --git a/programs/anchor-vrf-parser/Cargo.toml b/programs/anchor-vrf-parser/Cargo.toml index 08abd35..9023b0d 100644 --- a/programs/anchor-vrf-parser/Cargo.toml +++ b/programs/anchor-vrf-parser/Cargo.toml @@ -16,8 +16,8 @@ cpi = ["no-entrypoint"] default = [] [dependencies] -switchboard-v2 = { path = "../../libraries/rs" } -# switchboard-v2 = "^0.1.11" +# switchboard-v2 = { path = "../../libraries/rs" } +switchboard-v2 = "^0.1.11" anchor-lang = "^0.24.2" anchor-spl = "^0.24.2" solana-program = "~1.9.13" diff --git a/programs/anchor-vrf-parser/tests/anchor-vrf-parser.test.ts b/programs/anchor-vrf-parser/tests/anchor-vrf-parser.test.ts index 168f94b..d509d90 100644 --- a/programs/anchor-vrf-parser/tests/anchor-vrf-parser.test.ts +++ b/programs/anchor-vrf-parser/tests/anchor-vrf-parser.test.ts @@ -66,10 +66,7 @@ describe("anchor-vrf-parser test", () => { before(async () => { // First, attempt to load the switchboard devnet PID try { - switchboard = await SwitchboardTestContext.loadDevnetQueue( - provider, - "9e8rQPoyVZeGA1mD2BBVqDthbFwircnfLTB5JE6yUFQR" - ); + switchboard = await SwitchboardTestContext.loadDevnetQueue(provider); console.log("devnet detected"); return; } catch (error: any) {