Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt to pyth-sdk-solana interface change in Anchor example #91

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/sol-anchor-contract/Anchor.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[programs.devnet]
example_sol_anchor_contract = "Fwn1fCmbjd8d95hxY9NUUr5Xa7D13khveMnmCUFdd3ah"
example_sol_anchor_contract = "9azQ2ePzPvMPQgHric53kdSNmwjVM5KijDE4ANFCE9D4"

[provider]
cluster = "devnet"
Expand Down
2 changes: 1 addition & 1 deletion examples/sol-anchor-contract/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ We assume that you have installed `anchor`, `npm` and `yarn`.

# Install the client dependencies and invoke this program
> anchor run install
> anchor run invoke
> anchor run test
```
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use anchor_lang::prelude::*;
use solana_program::account_info::AccountInfo;
use pyth_sdk_solana::load_price_feed_from_account_info;

declare_id!("Fwn1fCmbjd8d95hxY9NUUr5Xa7D13khveMnmCUFdd3ah");
declare_id!("9azQ2ePzPvMPQgHric53kdSNmwjVM5KijDE4ANFCE9D4");

#[account]
pub struct AdminConfig {
Expand Down Expand Up @@ -54,7 +54,9 @@ pub mod example_sol_anchor_contract {
// https://docs.pyth.network/consume-data/best-practices
let feed1 = load_price_feed_from_account_info(pyth_loan_account)
.map_err(|_x| error!(ErrorCode::PythError))?;
let result1 = feed1.get_current_price()
let current_timestamp1 = Clock::get()?.unix_timestamp;
let result1 = feed1
.get_price_no_older_than(current_timestamp1, 60)
.ok_or(ErrorCode::PythOffline)?;
let loan_max_price = result1
.price
Expand All @@ -75,7 +77,9 @@ pub mod example_sol_anchor_contract {
// https://docs.pyth.network/consume-data/best-practices
let feed2 = load_price_feed_from_account_info(pyth_collateral_account)
.map_err(|_x| error!(ErrorCode::PythError))?;
let result2 = feed2.get_current_price()
let current_timestamp2 = Clock::get()?.unix_timestamp;
let result2 = feed2
.get_price_no_older_than(current_timestamp2, 60)
.ok_or(ErrorCode::PythOffline)?;
let collateral_min_price = result2
.price
Expand Down
2 changes: 1 addition & 1 deletion examples/sol-anchor-contract/scripts/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ try {
try {
assert(programId.equals(programKey.publicKey));
} catch (error) {
throw new Error("Please make sure you have the same program address inAnchor.toml and program_address.json");
throw new Error("Please make sure you have the same program address in Anchor.toml and program_address.json");
}

it("Initialize the config.", async () => {
Expand Down