16
16
from program_admin import instructions as pyth_program
17
17
from program_admin .keys import load_keypair
18
18
from program_admin .parsing import parse_account
19
- from program_admin .publisher_program_instructions import (
20
- config_account_pubkey as publisher_program_config_account_pubkey ,
19
+ from program_admin .price_store_instructions import (
20
+ config_account_pubkey as price_store_config_account_pubkey ,
21
21
)
22
- from program_admin .publisher_program_instructions import (
22
+ from program_admin .price_store_instructions import (
23
23
create_buffer_account ,
24
+ initialize_price_store ,
24
25
initialize_publisher_config ,
25
- initialize_publisher_program ,
26
26
publisher_config_account_pubkey ,
27
27
)
28
28
from program_admin .types import (
@@ -65,7 +65,7 @@ class ProgramAdmin:
65
65
rpc_endpoint : str
66
66
key_dir : Path
67
67
program_key : PublicKey
68
- publisher_program_key : Optional [PublicKey ]
68
+ price_store_key : Optional [PublicKey ]
69
69
authority_permission_account : Optional [PythAuthorityPermissionAccount ]
70
70
_mapping_accounts : Dict [PublicKey , PythMappingAccount ]
71
71
_product_accounts : Dict [PublicKey , PythProductAccount ]
@@ -76,17 +76,15 @@ def __init__(
76
76
network : Network ,
77
77
key_dir : str ,
78
78
program_key : str ,
79
- publisher_program_key : Optional [str ],
79
+ price_store_key : Optional [str ],
80
80
commitment : Literal ["confirmed" , "finalized" ],
81
81
rpc_endpoint : str = "" ,
82
82
):
83
83
self .network = network
84
84
self .rpc_endpoint = rpc_endpoint or RPC_ENDPOINTS [network ]
85
85
self .key_dir = Path (key_dir )
86
86
self .program_key = PublicKey (program_key )
87
- self .publisher_program_key = (
88
- PublicKey (publisher_program_key ) if publisher_program_key else None
89
- )
87
+ self .price_store_key = PublicKey (price_store_key ) if price_store_key else None
90
88
self .commitment = Commitment (commitment )
91
89
self .authority_permission_account = None
92
90
self ._mapping_accounts : Dict [PublicKey , PythMappingAccount ] = {}
@@ -317,19 +315,19 @@ async def sync(
317
315
318
316
# Sync publisher program
319
317
(
320
- publisher_program_instructions ,
321
- publisher_program_signers ,
322
- ) = await self .sync_publisher_program (ref_publishers )
318
+ price_store_instructions ,
319
+ price_store_signers ,
320
+ ) = await self .sync_price_store (ref_publishers )
323
321
324
322
logger .debug (
325
- f"Syncing publisher program - { len (publisher_program_instructions )} instructions"
323
+ f"Syncing price store program - { len (price_store_instructions )} instructions"
326
324
)
327
325
328
- if publisher_program_instructions :
329
- instructions .extend (publisher_program_instructions )
326
+ if price_store_instructions :
327
+ instructions .extend (price_store_instructions )
330
328
if send_transactions :
331
329
await self .send_transaction (
332
- publisher_program_instructions , publisher_program_signers
330
+ price_store_instructions , price_store_signers
333
331
)
334
332
335
333
# Sync publishers
@@ -690,46 +688,44 @@ async def resize_price_accounts_v2(
690
688
if send_transactions :
691
689
await self .send_transaction (instructions , signers )
692
690
693
- async def sync_publisher_program (
691
+ async def sync_price_store (
694
692
self , ref_publishers : ReferencePublishers
695
693
) -> Tuple [List [TransactionInstruction ], List [Keypair ]]:
696
- if self .publisher_program_key is None :
694
+ if self .price_store_key is None :
697
695
return [], []
698
696
699
697
instructions = []
700
698
701
699
authority = load_keypair ("funding" , key_dir = self .key_dir )
702
700
703
- publisher_program_config = publisher_program_config_account_pubkey (
704
- self .publisher_program_key
705
- )
701
+ price_store_config = price_store_config_account_pubkey (self .price_store_key )
706
702
707
- # Initialize the publisher program config if it does not exist
708
- if not (await account_exists (self .rpc_endpoint , publisher_program_config )):
709
- initialize_publisher_program_instruction = initialize_publisher_program (
710
- self .publisher_program_key , authority .public_key
703
+ # Initialize the price store program config if it does not exist
704
+ if not (await account_exists (self .rpc_endpoint , price_store_config )):
705
+ initialize_price_store_instruction = initialize_price_store (
706
+ self .price_store_key , authority .public_key
711
707
)
712
- instructions .append (initialize_publisher_program_instruction )
708
+ instructions .append (initialize_price_store_instruction )
713
709
714
710
# Initialize publisher config accounts for new publishers
715
711
for publisher in ref_publishers ["keys" ].values ():
716
712
publisher_config_account = publisher_config_account_pubkey (
717
- publisher , self .publisher_program_key
713
+ publisher , self .price_store_key
718
714
)
719
715
720
716
if not (await account_exists (self .rpc_endpoint , publisher_config_account )):
721
717
size = 100048 # This size is for a buffer supporting 5000 price updates
722
718
lamports = await self .fetch_minimum_balance (size )
723
719
buffer_account , create_buffer_instruction = create_buffer_account (
724
- self .publisher_program_key ,
720
+ self .price_store_key ,
725
721
authority .public_key ,
726
722
publisher ,
727
723
size ,
728
724
lamports ,
729
725
)
730
726
731
727
initialize_publisher_config_instruction = initialize_publisher_config (
732
- self .publisher_program_key ,
728
+ self .price_store_key ,
733
729
publisher ,
734
730
authority .public_key ,
735
731
buffer_account ,
0 commit comments