Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add explorer urls to init and check before print #1033

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions bittensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ def turn_console_off():
__local_entrypoint__ = "127.0.0.1:9944"


# Block Explorers map network to explorer url
## Must all be polkadotjs explorer urls
__network_explorer_map__ = {
'local': "https://explorer.nakamoto.opentensor.ai",
'nakamoto': "https://explorer.nakamoto.opentensor.ai",
'endpoint': "https://explorer.nakamoto.opentensor.ai",
'nobunaga': "https://staging.opentensor.ai",
}

# Avoid collisions with other processes
from .utils.test_utils import get_random_unused_port
mock_subtensor_port = get_random_unused_port()
Expand Down
9 changes: 7 additions & 2 deletions bittensor/_subtensor/subtensor_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1129,8 +1129,13 @@ def transfer(
bittensor.__console__.print(":white_heavy_check_mark: [green]Finalized[/green]")
block_hash = response.block_hash
bittensor.__console__.print("[green]Block Hash: {}[/green]".format( block_hash ))
explorer_url = "https://explorer.nakamoto.opentensor.ai/#/explorer/query/{block_hash}".format( block_hash = block_hash )
bittensor.__console__.print("[green]Explorer Link: {}[/green]".format( explorer_url ))

if self.network in bittensor.__network_explorer_map__:
# Get explorer link if we are on a known network.
explorer_root_url = bittensor.__network_explorer_map__[self.network]
explorer_url = "{root_url}/#/explorer/query/{block_hash}".format( root_url=explorer_root_url, block_hash = block_hash )
Comment on lines +1135 to +1136
Copy link
Contributor

Choose a reason for hiding this comment

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

what about testing this using different network_explorer maps? So we test what we're doing here

bittensor.__console__.print("[green]Explorer Link: {}[/green]".format( explorer_url ))

else:
bittensor.__console__.print(":cross_mark: [red]Failed[/red]: error:{}".format(response.error_message))

Expand Down