Skip to content

Commit

Permalink
Use a global dict map between network_id and URL
Browse files Browse the repository at this point in the history
  • Loading branch information
ckeshava committed Jul 8, 2024
1 parent 3881c7b commit 0839082
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions xrpl/asyncio/wallet/wallet_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
_DEV_FAUCET_URL: Final[str] = "https://faucet.devnet.rippletest.net/accounts"

_TIMEOUT_SECONDS: Final[int] = 40
_MAP_NETWORK_ID_TO_URL: Dict[int, str] = {1: _TEST_FAUCET_URL, 2: _DEV_FAUCET_URL}


class XRPLFaucetException(XRPLException):
Expand Down Expand Up @@ -177,10 +178,8 @@ def get_faucet_url(network_id: int) -> str:
XRPLFaucetException: if the provided network_id does not correspond to testnet
or devnet.
"""
map_network_id_to_url: Dict[int, str] = {1: _TEST_FAUCET_URL, 2: _DEV_FAUCET_URL}

if network_id in map_network_id_to_url:
return map_network_id_to_url[network_id]
if network_id in _MAP_NETWORK_ID_TO_URL:
return _MAP_NETWORK_ID_TO_URL[network_id]

# corresponds to sidechain-net2 network
if network_id == 262:
Expand All @@ -195,7 +194,9 @@ def get_faucet_url(network_id: int) -> str:

# this line is unreachable. Custom devnets must specify a faucet_host input
raise XRPLFaucetException(
"The NetworkID of the provided network ( " + str(network_id) + ") does not have a known faucet."
"The NetworkID of the provided network ( "
+ str(network_id)
+ ") does not have a known faucet."
)


Expand Down

0 comments on commit 0839082

Please sign in to comment.