File tree Expand file tree Collapse file tree 3 files changed +58
-3
lines changed
programs/pyth-solana-receiver/src Expand file tree Collapse file tree 3 files changed +58
-3
lines changed Original file line number Diff line number Diff line change @@ -44,4 +44,12 @@ pub enum Action {
44
44
about = "Initialize a wormhole receiver contract by sequentially replaying the guardian set updates"
45
45
) ]
46
46
InitializeWormholeReceiver { } ,
47
+ InitializePythReceiver {
48
+ #[ clap( short = 'f' , long, help = "Fee in lmaports" ) ]
49
+ fee : u64 ,
50
+ #[ clap( short = 'e' , long, parse( try_from_str = Pubkey :: from_str) , help = "Source emitter" ) ]
51
+ emitter : Pubkey ,
52
+ #[ clap( short = 'c' , long, help = "Source chain" ) ]
53
+ chain : u16 ,
54
+ } ,
47
55
}
Original file line number Diff line number Diff line change 1
1
#![ deny( warnings) ]
2
2
3
+
3
4
pub mod cli;
4
5
use {
5
6
anchor_client:: anchor_lang:: {
13
14
Action ,
14
15
Cli ,
15
16
} ,
17
+ pyth_solana_receiver:: state:: config:: DataSource ,
16
18
pythnet_sdk:: wire:: v1:: {
17
19
AccumulatorUpdateData ,
18
20
MerklePriceUpdate ,
@@ -125,8 +127,40 @@ fn main() -> Result<()> {
125
127
false ,
126
128
) ?;
127
129
}
128
- }
130
+ Action :: InitializePythReceiver {
131
+ fee,
132
+ emitter,
133
+ chain,
134
+ } => {
135
+ let rpc_client = RpcClient :: new ( url) ;
136
+ let payer =
137
+ read_keypair_file ( & * shellexpand:: tilde ( & keypair) ) . expect ( "Keypair not found" ) ;
129
138
139
+ let initialize_pyth_receiver_accounts =
140
+ pyth_solana_receiver:: accounts:: Initialize :: populate ( & payer. pubkey ( ) )
141
+ . to_account_metas ( None ) ;
142
+ let initialize_pyth_receiver_instruction = Instruction {
143
+ program_id : pyth_solana_receiver:: ID ,
144
+ accounts : initialize_pyth_receiver_accounts,
145
+ data : pyth_solana_receiver:: instruction:: Initialize {
146
+ initial_config : pyth_solana_receiver:: state:: config:: Config {
147
+ governance_authority : payer. pubkey ( ) ,
148
+ target_governance_authority : None ,
149
+ wormhole,
150
+ valid_data_sources : vec ! [ DataSource { chain, emitter } ] ,
151
+ single_update_fee_in_lamports : fee,
152
+ } ,
153
+ }
154
+ . data ( ) ,
155
+ } ;
156
+
157
+ process_transaction (
158
+ & rpc_client,
159
+ vec ! [ initialize_pyth_receiver_instruction] ,
160
+ & vec ! [ & payer] ,
161
+ ) ?;
162
+ }
163
+ }
130
164
Ok ( ( ) )
131
165
}
132
166
Original file line number Diff line number Diff line change 1
- use state:: config:: Config ;
1
+ use {
2
+ anchor_lang:: system_program,
3
+ state:: config:: Config ,
4
+ } ;
2
5
3
6
pub mod error;
4
7
pub mod state;
26
29
} ,
27
30
} ;
28
31
29
- declare_id ! ( "DvPfMBZJJwKgJsv2WJA8bFwUMn8nFd5Xpioc6foC3rse " ) ;
32
+ declare_id ! ( "rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ " ) ;
30
33
31
34
#[ program]
32
35
pub mod pyth_solana_receiver {
@@ -207,6 +210,16 @@ pub struct PostUpdates<'info> {
207
210
pub posted_vaa : UncheckedAccount < ' info > ,
208
211
}
209
212
213
+ impl crate :: accounts:: Initialize {
214
+ pub fn populate ( payer : & Pubkey ) -> Self {
215
+ let config = Pubkey :: find_program_address ( & [ CONFIG_SEED . as_ref ( ) ] , & crate :: ID ) . 0 ;
216
+ crate :: accounts:: Initialize {
217
+ payer : * payer,
218
+ config,
219
+ system_program : system_program:: ID ,
220
+ }
221
+ }
222
+ }
210
223
211
224
impl crate :: accounts:: PostUpdates {
212
225
pub fn populate ( payer : & Pubkey , posted_vaa : & Pubkey ) -> Self {
You can’t perform that action at this time.
0 commit comments