Skip to content

Commit

Permalink
fix: deprecate is_sandbox and get_sandbox_default_account (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-makerx authored Mar 29, 2023
1 parent c73cd62 commit ad23e57
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/algokit_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
get_kmd_wallet_account,
get_localnet_default_account,
get_or_create_kmd_wallet_account,
get_sandbox_default_account,
)
from algokit_utils.application_client import (
ABICallArgs,
Expand Down Expand Up @@ -63,13 +64,15 @@
get_indexer_client,
get_kmd_client_from_algod_client,
is_localnet,
is_sandbox,
)

__all__ = [
"create_kmd_wallet_account",
"get_account_from_mnemonic",
"get_or_create_kmd_wallet_account",
"get_localnet_default_account",
"get_sandbox_default_account",
"get_dispenser_account",
"get_kmd_wallet_account",
"get_account",
Expand Down Expand Up @@ -120,6 +123,7 @@
"get_indexer_client",
"get_kmd_client_from_algod_client",
"is_localnet",
"is_sandbox",
"TransferParameters",
"transfer",
]
9 changes: 9 additions & 0 deletions src/algokit_utils/account.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import os
import warnings
from collections.abc import Callable
from typing import Any

Expand All @@ -14,6 +15,7 @@
from algokit_utils.network_clients import get_kmd_client_from_algod_client, is_localnet

__all__ = [
"create_kmd_wallet_account",
"get_account_from_mnemonic",
"get_or_create_kmd_wallet_account",
"get_localnet_default_account",
Expand Down Expand Up @@ -85,6 +87,13 @@ def _is_default_account(account: dict[str, Any]) -> bool:
return bool(account["status"] != "Offline" and account["amount"] > 1_000_000_000)


def get_sandbox_default_account(client: AlgodClient) -> Account:
warnings.warn(
"get_sandbox_default_account is deprecated, please use get_localnet_default_account instead", DeprecationWarning
)
return get_localnet_default_account(client)


def get_localnet_default_account(client: AlgodClient) -> Account:
"""Returns the default Account in a LocalNet instance"""
if not is_localnet(client):
Expand Down
2 changes: 2 additions & 0 deletions src/algokit_utils/application_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
__all__ = [
"ABICallArgs",
"ABICallArgsDict",
"ABICreateCallArgs",
"ABICreateCallArgsDict",
"ApplicationClient",
"CommonCallParameters",
"CommonCallParametersDict",
Expand Down
6 changes: 6 additions & 0 deletions src/algokit_utils/network_clients.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import dataclasses
import os
import warnings
from urllib import parse

from algosdk.kmd import KMDClient
Expand Down Expand Up @@ -45,6 +46,11 @@ def is_localnet(client: AlgodClient) -> bool:
return params.gen in ["devnet-v1", "sandnet-v1"]


def is_sandbox(client: AlgodClient) -> bool:
warnings.warn("is_sandbox is deprecated, please use is_localnet instead", DeprecationWarning)
return is_localnet(client)


def get_kmd_client_from_algod_client(client: AlgodClient) -> KMDClient:
"""Returns and SDK KMDClient using the same address as provided AlgodClient, but on port specified by
KMD_PORT environment variable, or 4092 by default"""
Expand Down

1 comment on commit ad23e57

@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_utils
   _transfer.py46296%45–46
   account.py871286%58–62, 91–94, 100, 113, 137, 140, 184
   application_client.py6308986%66, 192, 208, 232, 247, 252, 272, 289, 300–302, 314, 391, 396, 398, 400, 583, 592, 601, 651, 659, 668, 712, 720, 729, 773, 781, 790, 817, 843, 851, 860, 902, 910, 919, 979, 994, 1012–1015, 1019, 1031–1032, 1036, 1057, 1097, 1105, 1141, 1177–1183, 1187–1192, 1194, 1250, 1257, 1280, 1350, 1409–1416, 1432, 1437–1447, 1453, 1459, 1466–1469, 1493–1498, 1518–1521, 1535
   application_specification.py892572%75, 78–87, 100, 108, 116, 158, 174, 196–205, 209
   deploy.py2522092%124, 158, 162–163, 194, 270, 274, 280–288, 299–302, 320, 399, 443–445
   logic_error.py35197%29
   network_clients.py51590%50–51, 74, 77–78
TOTAL121715487% 

Tests Skipped Failures Errors Time
96 0 💤 0 ❌ 0 🔥 1m 6s ⏱️

Please sign in to comment.