File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change 1212from pycardano .exception import TransactionFailedException
1313from pycardano .hash import SCRIPT_HASH_SIZE , DatumHash , ScriptHash
1414from pycardano .nativescript import NativeScript
15- from pycardano .network import Network
15+ from pycardano .network import Network , BLOCKFROST_URLS
1616from pycardano .plutus import ExecutionUnits , PlutusV1Script , PlutusV2Script
1717from pycardano .serialization import RawCBOR
1818from pycardano .transaction import (
@@ -46,11 +46,7 @@ class BlockFrostChainContext(ChainContext):
4646 def __init__ (self , project_id : str , network : Network = Network .TESTNET ):
4747 self ._network = network
4848 self ._project_id = project_id
49- self ._base_url = (
50- ApiUrls .testnet .value
51- if self .network == Network .TESTNET
52- else ApiUrls .mainnet .value
53- )
49+ self ._base_url = BLOCKFROST_URLS [network ]
5450 self .api = BlockFrostApi (project_id = self ._project_id , base_url = self ._base_url )
5551 self ._epoch_info = self .api .epoch_latest ()
5652 self ._epoch = None
Original file line number Diff line number Diff line change @@ -16,10 +16,20 @@ class Network(CBORSerializable, Enum):
1616
1717 TESTNET = 0
1818 MAINNET = 1
19+ PREVIEW = 2
20+ PREPROD = 3
1921
2022 def to_primitive (self ) -> int :
2123 return self .value
2224
2325 @classmethod
2426 def from_primitive (cls , value : int ) -> Network :
2527 return cls (value )
28+
29+
30+ BLOCKFROST_URLS = {
31+ Network .MAINNET : "https://cardano-mainnet.blockfrost.io/api" ,
32+ Network .TESTNET : "https://cardano-testnet.blockfrost.io/api" ,
33+ Network .PREVIEW : "https://cardano-preview.blockfrost.io/api" ,
34+ Network .PREPROD : "https://cardano-preprod.blockfrost.io/api" ,
35+ }
You can’t perform that action at this time.
0 commit comments