11import json
22from typing import List
3+ from pkg_resources import resource_filename
34
45
56class Registry :
@@ -19,7 +20,7 @@ def load_all_contracts(self) -> List[dict]:
1920 Return addresses and ABIs of all the known contracts
2021 """
2122 try :
22- with open ('celo_sdk/ registry_contracts.json' ) as json_file :
23+ with open (resource_filename ( 'celo_sdk' , ' registry_contracts.json') ) as json_file :
2324 contracts_data = json .load (json_file )
2425 result = []
2526 for k , v in contracts_data .items ():
@@ -48,7 +49,7 @@ def load_contract_by_name(self, contract_name: str, contract_address: str = None
4849 try :
4950 account_contract_address = self .registry .functions .getAddressForString (
5051 contract_name ).call () if contract_address == None else contract_address
51- with open ('celo_sdk/ registry_contracts.json' ) as json_file :
52+ with open (resource_filename ( 'celo_sdk' , ' registry_contracts.json') ) as json_file :
5253 contracts_data = json .load (json_file )
5354 return {"address" : account_contract_address , "abi" : contracts_data [contract_name ]["ABI" ]}
5455 except KeyError :
@@ -63,7 +64,7 @@ def set_registry(self):
6364 Set Registry contract object
6465 """
6566 try :
66- with open ('celo_sdk/ registry_contracts.json' ) as json_file :
67+ with open (resource_filename ( 'celo_sdk' , ' registry_contracts.json') ) as json_file :
6768 contracts_data = json .load (json_file )
6869 registry = self .web3 .eth .contract (
6970 contracts_data ["Registry" ]["Address" ], abi = contracts_data ["Registry" ]["ABI" ])
0 commit comments