pythnet_sdk/
lib.rs

1pub mod accumulators;
2pub mod error;
3pub mod hashers;
4pub mod messages;
5pub mod wire;
6pub mod wormhole;
7
8#[cfg(feature = "test-utils")]
9pub mod test_utils;
10
11pub(crate) type Pubkey = [u8; 32];
12
13/// Official Message Buffer Program Id
14/// pubkey!("7Vbmv1jt4vyuqBZcpYPpnVhrqVe5e6ZPb6JxDcffRHUM");
15pub const MESSAGE_BUFFER_PID: Pubkey = [
16    96, 121, 180, 39, 141, 35, 152, 85, 128, 70, 147, 124, 128, 196, 115, 241, 86, 159, 207, 148,
17    39, 234, 137, 86, 178, 4, 238, 48, 102, 178, 128, 18,
18];
19
20/// Pubkey::find_program_address(&[b"emitter"], &sysvar::accumulator::id());
21/// pubkey!("G9LV2mp9ua1znRAfYwZz5cPiJMAbo1T6mbjdQsDZuMJg");
22pub const ACCUMULATOR_EMITTER_ADDRESS: Pubkey = [
23    225, 1, 250, 237, 172, 88, 81, 227, 43, 155, 35, 181, 249, 65, 26, 140, 43, 172, 74, 174, 62,
24    212, 221, 123, 129, 29, 209, 167, 46, 164, 170, 113,
25];
26
27/// Official Program IDs and Addresses on Pythnet
28pub mod pythnet {
29    use super::Pubkey;
30    /// Official Wormhole Program Address on Pythnet
31    /// pubkey!("H3fxXJ86ADW2PNuDDmZJg6mzTtPxkYCpNuQUTgmJ7AjU");
32    pub const WORMHOLE_PID: Pubkey = [
33        238, 106, 51, 154, 165, 236, 145, 158, 20, 176, 156, 210, 101, 132, 136, 107, 95, 235, 248,
34        189, 230, 34, 185, 117, 208, 26, 214, 142, 191, 11, 208, 35,
35    ];
36
37    /// Pubkey::find_program_address(&[b"Sequence", &emitter_pda_key.to_bytes()], &WORMHOLE_PID);
38    /// pubkey!("8MuVR15V86sSELdpW4UYTyx7WTXRARF1Bj7GJHgTJP3K");
39    pub const ACCUMULATOR_SEQUENCE_ADDR: Pubkey = [
40        109, 92, 198, 114, 10, 119, 5, 31, 13, 197, 193, 195, 132, 17, 12, 3, 77, 111, 158, 247,
41        194, 137, 236, 50, 8, 185, 1, 61, 85, 94, 54, 198,
42    ];
43
44    /// Official Pyth Oracle Program Id on Pythnet
45    /// pubkey!("FsJ3A3u2vn5cTVofAjvy6y5kwABJAqYWpe4975bi2epH");
46    pub const PYTH_PID: Pubkey = [
47        220, 229, 235, 225, 228, 156, 59, 159, 17, 76, 181, 84, 76, 80, 169, 158, 192, 214, 146,
48        214, 63, 86, 121, 90, 224, 41, 172, 131, 217, 234, 139, 226,
49    ];
50}
51
52#[cfg(test)]
53pub(crate) mod tests {
54    use super::*;
55
56    #[test]
57    fn test_pubkeys() {
58        use solana_sdk::{pubkey, pubkey::Pubkey};
59
60        let accumulator_emitter_address = pubkey!("G9LV2mp9ua1znRAfYwZz5cPiJMAbo1T6mbjdQsDZuMJg");
61        assert_eq!(
62            ACCUMULATOR_EMITTER_ADDRESS,
63            accumulator_emitter_address.to_bytes()
64        );
65
66        let pythnet_wormhole_pid = pubkey!("H3fxXJ86ADW2PNuDDmZJg6mzTtPxkYCpNuQUTgmJ7AjU");
67        let (pythnet_accumulator_sequence_address, _) = Pubkey::find_program_address(
68            &[b"Sequence", accumulator_emitter_address.as_ref()],
69            &pythnet_wormhole_pid,
70        );
71
72        assert_eq!(pythnet::WORMHOLE_PID, pythnet_wormhole_pid.to_bytes());
73        assert_eq!(
74            pythnet::ACCUMULATOR_SEQUENCE_ADDR,
75            pythnet_accumulator_sequence_address.to_bytes()
76        );
77
78        let pythtest_wormhole_pid = pubkey!("EUrRARh92Cdc54xrDn6qzaqjA77NRrCcfbr8kPwoTL4z");
79        let pythtest_wormhole_pid_bytes: [u8; 32] = [
80            200, 74, 124, 198, 226, 194, 215, 62, 43, 98, 207, 184, 167, 181, 175, 174, 254, 192,
81            204, 37, 26, 45, 137, 21, 180, 83, 228, 241, 198, 180, 129, 67,
82        ];
83        assert_eq!(
84            pythtest_wormhole_pid_bytes,
85            pythtest_wormhole_pid.to_bytes()
86        );
87
88        let expected_pythtest_accumulator_sequence_addr =
89            pubkey!("Ao4tQp1ouW9w73CE34npzSDjgPG5FGz8KmoSauzCwuh7");
90        let (pythtest_accumulator_sequence_address, _) = Pubkey::find_program_address(
91            &[b"Sequence", accumulator_emitter_address.as_ref()],
92            &pythtest_wormhole_pid,
93        );
94
95        let pythtest_accumulator_sequence_address_bytes: [u8; 32] = [
96            145, 134, 75, 61, 141, 252, 86, 178, 3, 223, 183, 153, 46, 227, 25, 201, 125, 199, 176,
97            254, 164, 55, 141, 20, 218, 150, 11, 104, 109, 137, 13, 166,
98        ];
99
100        assert_eq!(
101            expected_pythtest_accumulator_sequence_addr,
102            pythtest_accumulator_sequence_address
103        );
104
105        assert_eq!(
106            pythtest_accumulator_sequence_address_bytes,
107            pythtest_accumulator_sequence_address.to_bytes()
108        );
109
110        let message_buffer_program = pubkey!("7Vbmv1jt4vyuqBZcpYPpnVhrqVe5e6ZPb6JxDcffRHUM");
111        assert_eq!(MESSAGE_BUFFER_PID, message_buffer_program.to_bytes());
112    }
113}