Skip to content

Commit

Permalink
chore: switch algoexplorer urls to allo (#375)
Browse files Browse the repository at this point in the history
* chore: switch algoexplorer urls to allo
  • Loading branch information
neilcampbell authored Dec 29, 2023
1 parent 27532ca commit aaddecd
Show file tree
Hide file tree
Showing 23 changed files with 75 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/algokit/cli/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def to_list(cls) -> list[str]:

class ExplorerEntityType(StringEnum):
"""
Used to indicate type of entity when used with `generate_explorer_url` function.
Used to indicate type of entity when used with `get_explorer_url` function.
"""

TRANSACTION = "transaction"
Expand Down
8 changes: 4 additions & 4 deletions src/algokit/cli/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ def get_explorer_url(identifier: str | int, network: str, entity_type: ExplorerE

base_urls: dict[str, dict[str, str]] = {
"testnet": {
ExplorerEntityType.TRANSACTION.value: "https://testnet.algoexplorer.io/tx/",
ExplorerEntityType.TRANSACTION.value: "https://testnet.allo.info/tx/",
ExplorerEntityType.ASSET.value: "https://testnet.explorer.perawallet.app/assets/",
ExplorerEntityType.ADDRESS.value: "https://testnet.algoexplorer.io/address/",
ExplorerEntityType.ADDRESS.value: "https://testnet.allo.info/account/",
},
"mainnet": {
ExplorerEntityType.TRANSACTION.value: "https://algoexplorer.io/tx/",
ExplorerEntityType.TRANSACTION.value: "https://allo.info/tx/",
ExplorerEntityType.ASSET.value: "https://explorer.perawallet.app/assets/",
ExplorerEntityType.ADDRESS.value: "https://algoexplorer.io/address/",
ExplorerEntityType.ADDRESS.value: "https://allo.info/account/",
},
}

Expand Down
7 changes: 5 additions & 2 deletions src/algokit/cli/dispenser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import click

from algokit.cli.common.constants import ExplorerEntityType
from algokit.cli.common.utils import get_explorer_url
from algokit.cli.tasks.utils import get_address
from algokit.core.dispenser import (
DISPENSER_ACCESS_TOKEN_KEY,
Expand Down Expand Up @@ -192,9 +194,10 @@ def fund_command(*, receiver: str, amount: int, whole_units: bool) -> None:
response_body["amount"] / (10**default_asset.decimals) if whole_units else response_body["amount"]
)
asset_description = default_asset.description if whole_units else f"μ{default_asset.description}"
logger.info(
f'Successfully funded {processed_amount} {asset_description}. Browse transaction at https://testnet.algoexplorer.io/tx/{response_body["txID"]}'
txn_url = get_explorer_url(
identifier=response_body["txID"], network="testnet", entity_type=ExplorerEntityType.TRANSACTION
)
logger.info(f"Successfully funded {processed_amount} {asset_description}. Browse transaction at {txn_url}")


@dispenser_group.command("refund", help="Refund ALGOs back to the dispenser wallet address.")
Expand Down
12 changes: 7 additions & 5 deletions src/algokit/cli/tasks/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
transfer as transfer_algos,
)

from algokit.cli.common.constants import AlgorandNetwork
from algokit.cli.common.constants import AlgorandNetwork, ExplorerEntityType
from algokit.cli.common.utils import get_explorer_url
from algokit.cli.tasks.utils import (
get_account_with_private_key,
get_address,
Expand Down Expand Up @@ -115,11 +116,12 @@ def transfer( # noqa: PLR0913
if not txn_response:
raise click.ClickException("Failed to perform transfer")

click.echo(
f"Successfully performed transfer. "
"See details at "
f"https://testnet.algoexplorer.io/tx/{txn_response.get_txid()}" # type: ignore[no-untyped-call]
txn_url = get_explorer_url(
identifier=txn_response.get_txid(), # type: ignore[no-untyped-call]
network=network,
entity_type=ExplorerEntityType.TRANSACTION,
)
click.echo(f"Successfully performed transfer. See details at {txn_url}")

except Exception as err:
logger.debug(err, exc_info=True)
Expand Down
2 changes: 1 addition & 1 deletion src/algokit/cli/tasks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def get_asset_decimals(asset_id: int, algod_client: algosdk.v2client.algod.Algod
Example:
asset_id = 123
algod_client = algosdk.v2client.algod.AlgodClient("https://api.algoexplorer.io", "API_KEY")
algod_client = algosdk.v2client.algod.AlgodClient("https://mainnet-api.algonode.cloud", "API_KEY")
decimals = get_asset_decimals(asset_id, algod_client)
print(decimals)
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
DEBUG: HTTP Request: POST https://snapshottest.dispenser.com/fund/0 "HTTP/1.1 200 OK"
Successfully funded 1000000 μAlgo. Browse transaction at https://testnet.algoexplorer.io/tx/dummy_tx_id
Successfully funded 1000000 μAlgo. Browse transaction at https://testnet.allo.info/tx/dummy_tx_id
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
DEBUG: HTTP Request: POST https://snapshottest.dispenser.com/fund/0 "HTTP/1.1 200 OK"
Successfully funded 1000000 μAlgo. Browse transaction at https://testnet.algoexplorer.io/tx/dummy_tx_id
Successfully funded 1000000 μAlgo. Browse transaction at https://testnet.allo.info/tx/dummy_tx_id
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
DEBUG: Converted algos to microAlgos: 1000000
DEBUG: HTTP Request: POST https://snapshottest.dispenser.com/fund/0 "HTTP/1.1 200 OK"
Successfully funded 1.0 Algo. Browse transaction at https://testnet.algoexplorer.io/tx/dummy_tx_id
Successfully funded 1.0 Algo. Browse transaction at https://testnet.allo.info/tx/dummy_tx_id
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
DEBUG: Using CI access token over keyring credentials
DEBUG: HTTP Request: POST https://snapshottest.dispenser.com/fund/0 "HTTP/1.1 200 OK"
Successfully funded 1000000 μAlgo. Browse transaction at https://testnet.algoexplorer.io/tx/dummy_tx_id
Successfully funded 1000000 μAlgo. Browse transaction at https://testnet.allo.info/tx/dummy_tx_id
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DEBUG: Converted algos to microAlgos: 1000000
DEBUG: Using CI access token over keyring credentials
DEBUG: HTTP Request: POST https://snapshottest.dispenser.com/fund/0 "HTTP/1.1 200 OK"
Successfully funded 1.0 Algo. Browse transaction at https://testnet.algoexplorer.io/tx/dummy_tx_id
Successfully funded 1.0 Algo. Browse transaction at https://testnet.allo.info/tx/dummy_tx_id
2 changes: 1 addition & 1 deletion tests/generate/test_generate_custom_generate_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def test_generate_custom_generate_commands_valid_generator_run(


def test_generate_custom_generate_commands_valid_generator_no_description(
cwd_with_custom_folder: tuple[Path, str]
cwd_with_custom_folder: tuple[Path, str],
) -> None:
cwd, smart_contract_path = cwd_with_custom_folder
(cwd / ALGOKIT_CONFIG).write_text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ DEBUG: Asset config params: {

Successfully minted the asset!
Browse your asset at: https://explorer.perawallet.app/assets/123
Check transaction status at: https://algoexplorer.io/tx/dummy_tx_id
Check transaction status at: https://allo.info/tx/dummy_tx_id
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ DEBUG: Asset config params: {

Successfully minted the asset!
Browse your asset at: https://testnet.explorer.perawallet.app/assets/123
Check transaction status at: https://testnet.algoexplorer.io/tx/dummy_tx_id
Check transaction status at: https://testnet.allo.info/tx/dummy_tx_id
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ DEBUG: Asset config params: {

Successfully minted the asset!
Browse your asset at: https://explorer.perawallet.app/assets/123
Check transaction status at: https://algoexplorer.io/tx/dummy_tx_id
Check transaction status at: https://allo.info/tx/dummy_tx_id
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ DEBUG: Asset config params: {

Successfully minted the asset!
Browse your asset at: https://testnet.explorer.perawallet.app/assets/123
Check transaction status at: https://testnet.algoexplorer.io/tx/dummy_tx_id
Check transaction status at: https://testnet.allo.info/tx/dummy_tx_id
38 changes: 38 additions & 0 deletions tests/tasks/test_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,41 @@ def test_transfer_failed(mocker: MockerFixture, mock_keyring: dict[str, str]) ->
# Assert
assert result.exit_code == 1
verify(result.output)


def test_transfer_on_testnet(mocker: MockerFixture) -> None:
# Arrange
mocker.patch("algokit.cli.tasks.transfer.transfer_algos", return_value=TransactionMock())
mocker.patch("algokit.cli.tasks.transfer.validate_address")
mocker.patch("algokit.cli.tasks.transfer.validate_balance")
dummy_sender_pk, dummy_sender_address = _generate_account()
dummy_receiver_address = _generate_account()[1]

# Act
result = invoke(
f"task transfer -s {dummy_sender_address} -r {dummy_receiver_address} -a 1 -n testnet",
input=_get_mnemonic_from_private_key(dummy_sender_pk),
)

# Assert
assert result.exit_code == 0
verify(result.output)


def test_transfer_on_mainnet(mocker: MockerFixture) -> None:
# Arrange
mocker.patch("algokit.cli.tasks.transfer.transfer_algos", return_value=TransactionMock())
mocker.patch("algokit.cli.tasks.transfer.validate_address")
mocker.patch("algokit.cli.tasks.transfer.validate_balance")
dummy_sender_pk, dummy_sender_address = _generate_account()
dummy_receiver_address = _generate_account()[1]

# Act
result = invoke(
f"task transfer -s {dummy_sender_address} -r {dummy_receiver_address} -a 1 -n mainnet",
input=_get_mnemonic_from_private_key(dummy_sender_pk),
)

# Assert
assert result.exit_code == 0
verify(result.output)
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Enter the mnemonic phrase (25 words separated by whitespace):
Successfully performed transfer. See details at https://testnet.algoexplorer.io/tx/dummy_txid
Successfully performed transfer. See details at https://app.dappflow.org/setnetwork?name=sandbox&redirect=explorer/transaction/dummy_txid/
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Successfully performed transfer. See details at https://testnet.algoexplorer.io/tx/dummy_txid
Successfully performed transfer. See details at https://app.dappflow.org/setnetwork?name=sandbox&redirect=explorer/transaction/dummy_txid/
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Enter the mnemonic phrase (25 words separated by whitespace):
Successfully performed transfer. See details at https://testnet.algoexplorer.io/tx/dummy_txid
Successfully performed transfer. See details at https://app.dappflow.org/setnetwork?name=sandbox&redirect=explorer/transaction/dummy_txid/
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Enter the mnemonic phrase (25 words separated by whitespace):
Successfully performed transfer. See details at https://testnet.algoexplorer.io/tx/dummy_txid
Successfully performed transfer. See details at https://app.dappflow.org/setnetwork?name=sandbox&redirect=explorer/transaction/dummy_txid/
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Successfully performed transfer. See details at https://testnet.algoexplorer.io/tx/dummy_txid
Successfully performed transfer. See details at https://app.dappflow.org/setnetwork?name=sandbox&redirect=explorer/transaction/dummy_txid/
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Enter the mnemonic phrase (25 words separated by whitespace):
Successfully performed transfer. See details at https://allo.info/tx/dummy_txid
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Enter the mnemonic phrase (25 words separated by whitespace):
Successfully performed transfer. See details at https://testnet.allo.info/tx/dummy_txid

1 comment on commit aaddecd

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/algokit
   __init__.py15753%6–13, 17–24, 32–34
   __main__.py220%1–3
src/algokit/cli
   completions.py108298%83, 98
   deploy.py72790%44, 46, 92–94, 158, 182
   dispenser.py121199%77
   doctor.py48394%142–144
   explore.py501276%34–39, 41–46
   generate.py67396%74–75, 140
   goal.py43198%64
   init.py1901692%277–278, 328, 331–333, 344, 388, 414, 454, 463–465, 468–473, 486
   localnet.py1191587%74–78, 111, 123, 138–148, 161, 206, 227–228
src/algokit/cli/common
   utils.py26292%120, 123
src/algokit/cli/tasks
   assets.py821384%65–66, 72, 74–75, 105, 119, 125–126, 132, 134, 136–137
   ipfs.py51884%52, 80, 92, 94–95, 105–107
   mint.py66494%48, 70, 91, 250
   send_transaction.py651085%52–53, 57, 89, 158, 170–174
   sign_transaction.py59886%21, 28–30, 71–72, 109, 123
   transfer.py39392%26, 90, 117
   utils.py994555%26–34, 40–43, 75–76, 100–101, 125–133, 152–162, 209, 258–259, 279–290, 297–299
   vanity_address.py561082%41, 45–48, 112, 114, 121–123
   wallet.py79495%21, 66, 136, 162
src/algokit/core
   bootstrap.py1612485%103–104, 126, 149, 214, 217, 223–237, 246–251
   conf.py54885%10, 24, 28, 36, 38, 71–73
   deploy.py691184%61–64, 73–75, 79, 84, 91–93
   dispenser.py2022687%91, 123–124, 141–149, 191–192, 198–200, 218–219, 259–260, 318, 332–334, 345–346, 356, 369, 384
   doctor.py65789%67–69, 92–94, 134
   generate.py41295%69, 87
   goal.py60395%30–31, 41
   log_handlers.py68790%50–51, 63, 112–116, 125
   proc.py45198%98
   sandbox.py2181892%62, 73–75, 96, 142–149, 160, 456, 472, 497, 505
   typed_client_generation.py80594%55–57, 70, 75
   utils.py56296%36–37
   version_prompt.py72889%26–27, 39, 58–61, 79, 108
src/algokit/core/tasks
   ipfs.py63789%58–64, 140, 144, 146, 152
   nfd.py491373%25, 31, 34–41, 70–72, 99–101
   vanity_address.py903462%49–50, 54, 59–75, 92–108, 128–131
   wallet.py71593%37, 129, 155–157
src/algokit/core/tasks/mint
   mint.py781087%123–133, 187
   models.py901188%50, 52, 57, 71–74, 85–88
TOTAL328337888% 

Tests Skipped Failures Errors Time
388 0 💤 0 ❌ 0 🔥 14.156s ⏱️

Please sign in to comment.