diff --git a/src/algokit/cli/common/constants.py b/src/algokit/cli/common/constants.py index 063c67c7..3d997a9e 100644 --- a/src/algokit/cli/common/constants.py +++ b/src/algokit/cli/common/constants.py @@ -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" diff --git a/src/algokit/cli/common/utils.py b/src/algokit/cli/common/utils.py index 2de42b33..c08e4770 100644 --- a/src/algokit/cli/common/utils.py +++ b/src/algokit/cli/common/utils.py @@ -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/", }, } diff --git a/src/algokit/cli/dispenser.py b/src/algokit/cli/dispenser.py index 6d635d4f..2d680ade 100644 --- a/src/algokit/cli/dispenser.py +++ b/src/algokit/cli/dispenser.py @@ -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, @@ -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.") diff --git a/src/algokit/cli/tasks/transfer.py b/src/algokit/cli/tasks/transfer.py index cc0af31e..da50d5f4 100644 --- a/src/algokit/cli/tasks/transfer.py +++ b/src/algokit/cli/tasks/transfer.py @@ -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, @@ -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) diff --git a/src/algokit/cli/tasks/utils.py b/src/algokit/cli/tasks/utils.py index 28df8e79..f8a39203 100644 --- a/src/algokit/cli/tasks/utils.py +++ b/src/algokit/cli/tasks/utils.py @@ -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) """ diff --git a/tests/dispenser/TestFundCommand.test_fund_command_from_alias_successful.approved.txt b/tests/dispenser/TestFundCommand.test_fund_command_from_alias_successful.approved.txt index c4d923b4..2b9f7433 100644 --- a/tests/dispenser/TestFundCommand.test_fund_command_from_alias_successful.approved.txt +++ b/tests/dispenser/TestFundCommand.test_fund_command_from_alias_successful.approved.txt @@ -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 diff --git a/tests/dispenser/TestFundCommand.test_fund_command_success.False.False.approved.txt b/tests/dispenser/TestFundCommand.test_fund_command_success.False.False.approved.txt index c4d923b4..2b9f7433 100644 --- a/tests/dispenser/TestFundCommand.test_fund_command_success.False.False.approved.txt +++ b/tests/dispenser/TestFundCommand.test_fund_command_success.False.False.approved.txt @@ -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 diff --git a/tests/dispenser/TestFundCommand.test_fund_command_success.False.True.approved.txt b/tests/dispenser/TestFundCommand.test_fund_command_success.False.True.approved.txt index 10db3adf..3e83fff4 100644 --- a/tests/dispenser/TestFundCommand.test_fund_command_success.False.True.approved.txt +++ b/tests/dispenser/TestFundCommand.test_fund_command_success.False.True.approved.txt @@ -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 diff --git a/tests/dispenser/TestFundCommand.test_fund_command_success.True.False.approved.txt b/tests/dispenser/TestFundCommand.test_fund_command_success.True.False.approved.txt index f26c31f5..94f59862 100644 --- a/tests/dispenser/TestFundCommand.test_fund_command_success.True.False.approved.txt +++ b/tests/dispenser/TestFundCommand.test_fund_command_success.True.False.approved.txt @@ -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 diff --git a/tests/dispenser/TestFundCommand.test_fund_command_success.True.True.approved.txt b/tests/dispenser/TestFundCommand.test_fund_command_success.True.True.approved.txt index a89cd028..c70d1303 100644 --- a/tests/dispenser/TestFundCommand.test_fund_command_success.True.True.approved.txt +++ b/tests/dispenser/TestFundCommand.test_fund_command_success.True.True.approved.txt @@ -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 diff --git a/tests/generate/test_generate_custom_generate_commands.py b/tests/generate/test_generate_custom_generate_commands.py index 50f07e1e..a6cfb5a8 100644 --- a/tests/generate/test_generate_custom_generate_commands.py +++ b/tests/generate/test_generate_custom_generate_commands.py @@ -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( diff --git a/tests/tasks/test_mint.test_mint_token_successful.address.False.mainnet.approved.txt b/tests/tasks/test_mint.test_mint_token_successful.address.False.mainnet.approved.txt index 4cc2d639..bb919979 100644 --- a/tests/tasks/test_mint.test_mint_token_successful.address.False.mainnet.approved.txt +++ b/tests/tasks/test_mint.test_mint_token_successful.address.False.mainnet.approved.txt @@ -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 diff --git a/tests/tasks/test_mint.test_mint_token_successful.address.False.testnet.approved.txt b/tests/tasks/test_mint.test_mint_token_successful.address.False.testnet.approved.txt index 847966b9..36969875 100644 --- a/tests/tasks/test_mint.test_mint_token_successful.address.False.testnet.approved.txt +++ b/tests/tasks/test_mint.test_mint_token_successful.address.False.testnet.approved.txt @@ -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 diff --git a/tests/tasks/test_mint.test_mint_token_successful.alias.True.mainnet.approved.txt b/tests/tasks/test_mint.test_mint_token_successful.alias.True.mainnet.approved.txt index f017ef9b..c9a5f6a6 100644 --- a/tests/tasks/test_mint.test_mint_token_successful.alias.True.mainnet.approved.txt +++ b/tests/tasks/test_mint.test_mint_token_successful.alias.True.mainnet.approved.txt @@ -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 diff --git a/tests/tasks/test_mint.test_mint_token_successful.alias.True.testnet.approved.txt b/tests/tasks/test_mint.test_mint_token_successful.alias.True.testnet.approved.txt index 61b23dc7..4d9f9acf 100644 --- a/tests/tasks/test_mint.test_mint_token_successful.alias.True.testnet.approved.txt +++ b/tests/tasks/test_mint.test_mint_token_successful.alias.True.testnet.approved.txt @@ -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 diff --git a/tests/tasks/test_transfer.py b/tests/tasks/test_transfer.py index b07679bc..5802dc02 100644 --- a/tests/tasks/test_transfer.py +++ b/tests/tasks/test_transfer.py @@ -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) diff --git a/tests/tasks/test_transfer.test_transfer_algo_from_address_successful.approved.txt b/tests/tasks/test_transfer.test_transfer_algo_from_address_successful.approved.txt index 9e68f39e..c4307805 100644 --- a/tests/tasks/test_transfer.test_transfer_algo_from_address_successful.approved.txt +++ b/tests/tasks/test_transfer.test_transfer_algo_from_address_successful.approved.txt @@ -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/ diff --git a/tests/tasks/test_transfer.test_transfer_algo_from_alias_successful.approved.txt b/tests/tasks/test_transfer.test_transfer_algo_from_alias_successful.approved.txt index 576d66e9..09d8da62 100644 --- a/tests/tasks/test_transfer.test_transfer_algo_from_alias_successful.approved.txt +++ b/tests/tasks/test_transfer.test_transfer_algo_from_alias_successful.approved.txt @@ -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/ diff --git a/tests/tasks/test_transfer.test_transfer_asset_from_address_successful.approved.txt b/tests/tasks/test_transfer.test_transfer_asset_from_address_successful.approved.txt index 9e68f39e..c4307805 100644 --- a/tests/tasks/test_transfer.test_transfer_asset_from_address_successful.approved.txt +++ b/tests/tasks/test_transfer.test_transfer_asset_from_address_successful.approved.txt @@ -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/ diff --git a/tests/tasks/test_transfer.test_transfer_asset_from_address_to_alias_successful.approved.txt b/tests/tasks/test_transfer.test_transfer_asset_from_address_to_alias_successful.approved.txt index 9e68f39e..c4307805 100644 --- a/tests/tasks/test_transfer.test_transfer_asset_from_address_to_alias_successful.approved.txt +++ b/tests/tasks/test_transfer.test_transfer_asset_from_address_to_alias_successful.approved.txt @@ -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/ diff --git a/tests/tasks/test_transfer.test_transfer_asset_from_alias_successful.approved.txt b/tests/tasks/test_transfer.test_transfer_asset_from_alias_successful.approved.txt index 576d66e9..09d8da62 100644 --- a/tests/tasks/test_transfer.test_transfer_asset_from_alias_successful.approved.txt +++ b/tests/tasks/test_transfer.test_transfer_asset_from_alias_successful.approved.txt @@ -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/ diff --git a/tests/tasks/test_transfer.test_transfer_on_mainnet.approved.txt b/tests/tasks/test_transfer.test_transfer_on_mainnet.approved.txt new file mode 100644 index 00000000..ec094547 --- /dev/null +++ b/tests/tasks/test_transfer.test_transfer_on_mainnet.approved.txt @@ -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 diff --git a/tests/tasks/test_transfer.test_transfer_on_testnet.approved.txt b/tests/tasks/test_transfer.test_transfer_on_testnet.approved.txt new file mode 100644 index 00000000..76b5c8b6 --- /dev/null +++ b/tests/tasks/test_transfer.test_transfer_on_testnet.approved.txt @@ -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