Skip to content

Commit 8f28930

Browse files
authored
feat(solana) : rust sdk (#1303)
* Continue * Use this * Try error conversion * Stop moving * Fix bug * Try another version * Another sdk update * Clarify errors * Errors * Add errors * Docs * More unit tests * Another unit test
1 parent 552f8c8 commit 8f28930

File tree

6 files changed

+454
-14
lines changed

6 files changed

+454
-14
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

target_chains/solana/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

target_chains/solana/pyth_solana_receiver_state/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ name = "pyth_solana_receiver_state"
1010

1111
[dependencies]
1212
anchor-lang = ">=0.28.0"
13+
hex = "*"
1314
pythnet-sdk = { path = "../../../pythnet/pythnet_sdk"}
1415
solana-program = "*"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
use anchor_lang::error_code;
2+
3+
#[error_code]
4+
#[derive(PartialEq)]
5+
pub enum GetPriceError {
6+
#[msg("This price feed update's age exceeds the requested maximum age")]
7+
PriceTooOld = 10000, // Big number to avoid conflicts with the SDK user's program error codes
8+
#[msg("The price feed update doesn't match the requested feed id")]
9+
MismatchedFeedId,
10+
#[msg("This price feed update has a lower verification level than the one requested")]
11+
InsufficientVerificationLevel,
12+
#[msg("Feed id must be 32 Bytes, that's 64 hex characters or 66 with a 0x prefix")]
13+
FeedIdMustBe32Bytes,
14+
#[msg("Feed id contains non-hex characters")]
15+
FeedIdNonHexCharacter,
16+
}
17+
18+
#[macro_export]
19+
macro_rules! check {
20+
($cond:expr, $err:expr) => {
21+
if !$cond {
22+
return Err($err);
23+
}
24+
};
25+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use anchor_lang::declare_id;
22

33
pub mod config;
4+
pub mod error;
45
pub mod price_update;
56

67
declare_id!("rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ");

0 commit comments

Comments
 (0)