Skip to content

Commit dab04d6

Browse files
authored
[pythnet-sdk]: fix addresses & programIds in pythnet-sdk (#808)
* fix(pythnet-sdk): fix addresses & programIds in pythnet-sdk * fix(pythnet-sdk): pin solana dev-dependency versions, fix visibility
1 parent 1902dba commit dab04d6

File tree

2 files changed

+92
-22
lines changed

2 files changed

+92
-22
lines changed

pythnet/pythnet_sdk/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ edition = "2021"
88

99
[lib]
1010
crate-type = ["lib"]
11-
name = "solana_pyth"
11+
name = "pythnet_sdk"
1212

1313
[dependencies]
1414
bincode = "1.3.1"
@@ -26,8 +26,8 @@ wormhole-sdk = { git = "https://github.com/wormhole-foundation/wormhole" }
2626
base64 = "0.21.0"
2727
rand = "0.7.0"
2828
serde_json = "1.0.96"
29-
solana-client = { path = "../client" }
30-
solana-sdk = { path = "../sdk" }
29+
solana-client = "=1.13.6"
30+
solana-sdk = "=1.13.6"
3131
proptest = "1.1.0"
3232

3333
[package.metadata.docs.rs]

pythnet/pythnet_sdk/src/lib.rs

Lines changed: 89 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,100 @@ pub mod wormhole;
66
pub(crate) type Pubkey = [u8; 32];
77
pub(crate) type PriceId = Pubkey;
88

9+
/// Official Message Buffer Program Id
10+
/// pubkey!("Vbmv1jt4vyuqBZcpYPpnVhrqVe5e6ZPb6JxDcffRHUM");
11+
const MESSAGE_BUFFER_PID: Pubkey = [
12+
7, 83, 149, 9, 30, 102, 77, 194, 50, 151, 133, 40, 118, 10, 93, 152, 174, 44, 244, 56, 27, 47,
13+
234, 218, 173, 153, 254, 48, 102, 178, 128, 18,
14+
];
15+
916
/// Pubkey::find_program_address(&[b"emitter"], &sysvar::accumulator::id());
1017
/// pubkey!("G9LV2mp9ua1znRAfYwZz5cPiJMAbo1T6mbjdQsDZuMJg");
11-
pub const ACCUMULATOR_EMITTER_ADDR: Pubkey = [
18+
const ACCUMULATOR_EMITTER_ADDRESS: Pubkey = [
1219
225, 1, 250, 237, 172, 88, 81, 227, 43, 155, 35, 181, 249, 65, 26, 140, 43, 172, 74, 174, 62,
1320
212, 221, 123, 129, 29, 209, 167, 46, 164, 170, 113,
1421
];
1522

16-
/// Pubkey::find_program_address(&[b"Sequence", &emitter_pda_key.to_bytes()], &WORMHOLE_PID);
17-
/// pubkey!("HiqU8jiyUoFbRjf4YFAKRFWq5NZykEYC6mWhXXnoszJR");
18-
pub const ACCUMULATOR_SEQUENCE_ADDR: Pubkey = [
19-
248, 114, 155, 82, 154, 159, 139, 78, 187, 144, 5, 110, 22, 123, 227, 191, 18, 224, 118, 212,
20-
39, 87, 137, 86, 88, 211, 220, 104, 229, 255, 139, 70,
21-
];
23+
/// Official Program IDs and Addresses on Pythnet
24+
pub mod pythnet {
25+
use super::Pubkey;
26+
/// Official Wormhole Program Address on Pythnet
27+
/// pubkey!("H3fxXJ86ADW2PNuDDmZJg6mzTtPxkYCpNuQUTgmJ7AjU");
28+
pub const WORMHOLE_PID: Pubkey = [
29+
238, 106, 51, 154, 165, 236, 145, 158, 20, 176, 156, 210, 101, 132, 136, 107, 95, 235, 248,
30+
189, 230, 34, 185, 117, 208, 26, 214, 142, 191, 11, 208, 35,
31+
];
2232

23-
/// Official Pyth Program Address
24-
/// pubkey!("FsJ3A3u2vn5cTVofAjvy6y5kwABJAqYWpe4975bi2epH");
25-
pub const PYTH_PID: Pubkey = [
26-
220, 229, 235, 225, 228, 156, 59, 159, 17, 76, 181, 84, 76, 80, 169, 158, 192, 214, 146, 214,
27-
63, 86, 121, 90, 224, 41, 172, 131, 217, 234, 139, 226,
28-
];
33+
/// Pubkey::find_program_address(&[b"Sequence", &emitter_pda_key.to_bytes()], &WORMHOLE_PID);
34+
/// pubkey!("HiqU8jiyUoFbRjf4YFAKRFWq5NZykEYC6mWhXXnoszJR");
35+
pub const ACCUMULATOR_SEQUENCE_ADDR: Pubkey = [
36+
109, 92, 198, 114, 10, 119, 5, 31, 13, 197, 193, 195, 132, 17, 12, 3, 77, 111, 158, 247,
37+
194, 137, 236, 50, 8, 185, 1, 61, 85, 94, 54, 198,
38+
];
2939

30-
/// Official Wormhole Program Address
31-
/// pubkey!("worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth");
32-
pub const WORMHOLE_PID: Pubkey = [
33-
224, 165, 137, 164, 26, 85, 251, 214, 108, 82, 164, 117, 242, 217, 42, 109, 61, 201, 180, 116,
34-
113, 20, 203, 154, 248, 37, 169, 139, 84, 93, 60, 224,
35-
];
40+
/// Official Pyth Oracle Program Id on Pythnet
41+
/// pubkey!("FsJ3A3u2vn5cTVofAjvy6y5kwABJAqYWpe4975bi2epH");
42+
pub const PYTH_PID: Pubkey = [
43+
220, 229, 235, 225, 228, 156, 59, 159, 17, 76, 181, 84, 76, 80, 169, 158, 192, 214, 146,
44+
214, 63, 86, 121, 90, 224, 41, 172, 131, 217, 234, 139, 226,
45+
];
46+
}
47+
48+
#[cfg(test)]
49+
pub(crate) mod tests {
50+
use super::*;
51+
52+
#[test]
53+
fn test_pubkeys() {
54+
use solana_sdk::{
55+
pubkey,
56+
pubkey::Pubkey,
57+
};
58+
59+
let accumulator_emitter_address = pubkey!("G9LV2mp9ua1znRAfYwZz5cPiJMAbo1T6mbjdQsDZuMJg");
60+
assert_eq!(
61+
ACCUMULATOR_EMITTER_ADDRESS,
62+
accumulator_emitter_address.to_bytes()
63+
);
64+
65+
let pythnet_wormhole_pid = pubkey!("H3fxXJ86ADW2PNuDDmZJg6mzTtPxkYCpNuQUTgmJ7AjU");
66+
let (pythnet_accumulator_sequence_address, _) = Pubkey::find_program_address(
67+
&[b"Sequence", accumulator_emitter_address.as_ref()],
68+
&pythnet_wormhole_pid,
69+
);
70+
71+
assert_eq!(pythnet::WORMHOLE_PID, pythnet_wormhole_pid.to_bytes());
72+
assert_eq!(
73+
pythnet::ACCUMULATOR_SEQUENCE_ADDR,
74+
pythnet_accumulator_sequence_address.to_bytes()
75+
);
76+
77+
let pythtest_wormhole_pid = pubkey!("EUrRARh92Cdc54xrDn6qzaqjA77NRrCcfbr8kPwoTL4z");
78+
let pythtest_wormhole_pid_bytes: [u8; 32] = [
79+
200, 74, 124, 198, 226, 194, 215, 62, 43, 98, 207, 184, 167, 181, 175, 174, 254, 192,
80+
204, 37, 26, 45, 137, 21, 180, 83, 228, 241, 198, 180, 129, 67,
81+
];
82+
let (pythtest_accumulator_sequence_address, _) = Pubkey::find_program_address(
83+
&[b"Sequence", accumulator_emitter_address.as_ref()],
84+
&pythtest_wormhole_pid,
85+
);
86+
87+
let pythtest_accumulator_sequence_address_bytes: [u8; 32] = [
88+
145, 134, 75, 61, 141, 252, 86, 178, 3, 223, 183, 153, 46, 227, 25, 201, 125, 199, 176,
89+
254, 164, 55, 141, 20, 218, 150, 11, 104, 109, 137, 13, 166,
90+
];
91+
92+
assert_eq!(
93+
pythtest_wormhole_pid_bytes,
94+
pythtest_wormhole_pid.to_bytes()
95+
);
96+
97+
assert_eq!(
98+
pythtest_accumulator_sequence_address_bytes,
99+
pythtest_accumulator_sequence_address.to_bytes()
100+
);
101+
102+
let message_buffer_program = pubkey!("Vbmv1jt4vyuqBZcpYPpnVhrqVe5e6ZPb6JxDcffRHUM");
103+
assert_eq!(MESSAGE_BUFFER_PID, message_buffer_program.to_bytes());
104+
}
105+
}

0 commit comments

Comments
 (0)