algokit-utils 3.0.0b10__py3-none-any.whl → 3.0.0b11__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of algokit-utils might be problematic. Click here for more details.

@@ -10,12 +10,10 @@ from algokit_utils._legacy_v2._transfer import TransferParameters, transfer
10
10
  from algokit_utils._legacy_v2.account import get_dispenser_account
11
11
  from algokit_utils._legacy_v2.models import Account
12
12
  from algokit_utils._legacy_v2.network_clients import is_testnet
13
- from algokit_utils.clients.dispenser_api_client import (
14
- DispenserAssetName,
15
- TestNetDispenserApiClient,
16
- )
13
+ from algokit_utils.clients.dispenser_api_client import TestNetDispenserApiClient
17
14
 
18
15
 
16
+ @deprecated("Use `algorand.account.ensure_funded()` instead")
19
17
  @dataclass(kw_only=True)
20
18
  class EnsureBalanceParameters:
21
19
  """Parameters for ensuring an account has a minimum number of µALGOs"""
@@ -86,9 +84,7 @@ def _calculate_fund_amount(
86
84
  def _fund_using_dispenser_api(
87
85
  dispenser_client: TestNetDispenserApiClient, address_to_fund: str, fund_amount_micro_algos: int
88
86
  ) -> EnsureFundedResponse | None:
89
- response = dispenser_client.fund(
90
- address=address_to_fund, amount=fund_amount_micro_algos, asset_id=DispenserAssetName.ALGO
91
- )
87
+ response = dispenser_client.fund(address=address_to_fund, amount=fund_amount_micro_algos)
92
88
 
93
89
  return EnsureFundedResponse(transaction_id=response.tx_id, amount=response.amount)
94
90
 
@@ -17,6 +17,7 @@ __all__ = ["TransferAssetParameters", "TransferParameters", "transfer", "transfe
17
17
  logger = logging.getLogger(__name__)
18
18
 
19
19
 
20
+ @deprecated("Send transactions via `algorand.{send|create_transaction}.{txn_type}()` instead")
20
21
  @dataclasses.dataclass(kw_only=True)
21
22
  class TransferParametersBase:
22
23
  """Parameters for transferring µALGOs between accounts.
@@ -39,6 +40,7 @@ class TransferParametersBase:
39
40
  max_fee_micro_algos: int | None = None
40
41
 
41
42
 
43
+ @deprecated("Use `algorand.send.payment(...)` / `algorand.create_transaction.payment(...)` instead")
42
44
  @dataclasses.dataclass(kw_only=True)
43
45
  class TransferParameters(TransferParametersBase):
44
46
  """Parameters for transferring µALGOs between accounts"""
@@ -46,6 +48,7 @@ class TransferParameters(TransferParametersBase):
46
48
  micro_algos: int
47
49
 
48
50
 
51
+ @deprecated("Use `algorand.send.asset_transfer(...)` / `algorand.create_transaction.asset_transfer(...)` instead")
49
52
  @dataclasses.dataclass(kw_only=True)
50
53
  class TransferAssetParameters(TransferParametersBase):
51
54
  """Parameters for transferring assets between accounts.
@@ -79,7 +82,7 @@ def _check_fee(transaction: PaymentTxn | AssetTransferTxn, max_fee: int | None)
79
82
  )
80
83
 
81
84
 
82
- @deprecated("Use the `TransactionComposer` abstraction instead to construct appropriate transfer transactions")
85
+ @deprecated("Use `algorand.send.payment(...)` / `algorand.create_transaction.payment(...)` instead")
83
86
  def transfer(client: "AlgodClient", parameters: TransferParameters) -> PaymentTxn:
84
87
  """Transfer µALGOs between accounts"""
85
88
 
@@ -100,7 +103,7 @@ def transfer(client: "AlgodClient", parameters: TransferParameters) -> PaymentTx
100
103
  return result
101
104
 
102
105
 
103
- @deprecated("Use the `TransactionComposer` abstraction instead to construct appropriate transfer transactions")
106
+ @deprecated("Use `algorand.send.asset_transfer(...)` / `algorand.create_transaction.asset_transfer(...)` instead")
104
107
  def transfer_asset(client: "AlgodClient", parameters: TransferAssetParameters) -> AssetTransferTxn:
105
108
  """Transfer assets between accounts"""
106
109
 
@@ -41,7 +41,9 @@ def get_account_from_mnemonic(mnemonic: str) -> Account:
41
41
  return Account(private_key=private_key, address=address)
42
42
 
43
43
 
44
- @deprecated("Use `algorand.account.from_kmd()` instead. Example: " "`account = algorand.account.from_kmd(name)`")
44
+ @deprecated(
45
+ "Use `algorand.account.kmd.get_or_create_wallet_account(name, fund_with)` or `KMDAccountManager(clientManager).get_or_create_wallet_account(name, fund_with)` instead"
46
+ )
45
47
  def create_kmd_wallet_account(kmd_client: "KMDClient", name: str) -> Account:
46
48
  """Creates a wallet with specified name"""
47
49
  wallet_id = kmd_client.create_wallet(name, "")["id"]
@@ -56,8 +58,7 @@ def create_kmd_wallet_account(kmd_client: "KMDClient", name: str) -> Account:
56
58
 
57
59
 
58
60
  @deprecated(
59
- "Use `algorand.account.from_kmd()` instead. Example: "
60
- "`account = algorand.account.from_kmd(name, fund_with=AlgoAmount.from_algo(1000))`"
61
+ "Use `algorand.account.kmd.get_or_create_wallet_account(name, fund_with)` or `KMDAccountManager(clientManager).get_or_create_wallet_account(name, fund_with)` instead"
61
62
  )
62
63
  def get_or_create_kmd_wallet_account(
63
64
  client: "AlgodClient", name: str, fund_with_algos: float = 1000, kmd_client: "KMDClient | None" = None
@@ -100,8 +101,7 @@ def _is_default_account(account: dict[str, Any]) -> bool:
100
101
 
101
102
 
102
103
  @deprecated(
103
- "Use `algorand.account.from_kmd()` instead. Example: "
104
- "`account = algorand.account.from_kmd('unencrypted-default-wallet', lambda a: a['status'] != 'Offline' and a['amount'] > 1_000_000_000)`"
104
+ "Use `algorand.account.localnet_dispenser()` or `algorand.account.from_kmd('unencrypted-default-wallet', lambda a: a['status'] != 'Offline' and a['amount'] > 1_000_000_000)`"
105
105
  )
106
106
  def get_localnet_default_account(client: "AlgodClient") -> Account:
107
107
  """Returns the default Account in a LocalNet instance"""
@@ -175,7 +175,7 @@ def _parse_note(metadata_b64: str | None) -> AppDeployMetaData | None:
175
175
  return None
176
176
 
177
177
 
178
- @deprecated("Use algorand.appDeployer.get_creator_apps_by_name() instead. ")
178
+ @deprecated("Use algorand.app_deployer.get_creator_apps_by_name() instead. ")
179
179
  def get_creator_apps(indexer: "IndexerClient", creator_account: Account | str) -> AppLookup:
180
180
  """Returns a mapping of Application names to {py:class}`AppMetaData` for all Applications created by specified
181
181
  creator that have a transaction note containing {py:class}`AppDeployMetaData`
@@ -41,14 +41,14 @@ class AlgoClientConfigs:
41
41
  kmd_config: AlgoClientConfig | None
42
42
 
43
43
 
44
- @deprecated("Use AlgorandClient.client.algod")
44
+ @deprecated("Use `ClientManager.get_default_localnet_config(config)` instead")
45
45
  def get_default_localnet_config(config: Literal["algod", "indexer", "kmd"]) -> AlgoClientConfig:
46
46
  """Returns the client configuration to point to the default LocalNet"""
47
47
  port = {"algod": 4001, "indexer": 8980, "kmd": 4002}[config]
48
48
  return AlgoClientConfig(server=f"http://localhost:{port}", token="a" * 64)
49
49
 
50
50
 
51
- @deprecated("Use AlgorandClient.testnet() or AlgorandClient.mainnet() instead")
51
+ @deprecated("Use `ClientManager.get_algonode_config(network, config)` instead")
52
52
  def get_algonode_config(
53
53
  network: Literal["testnet", "mainnet"], config: Literal["algod", "indexer"], token: str
54
54
  ) -> AlgoClientConfig:
@@ -59,7 +59,9 @@ def get_algonode_config(
59
59
  )
60
60
 
61
61
 
62
- @deprecated("Use AlgorandClient.from_environment() instead.")
62
+ @deprecated(
63
+ "Use `ClientManager.get_algod_client(config)` or `ClientManager.get_algod_client_from_environment()` instead."
64
+ )
63
65
  def get_algod_client(config: AlgoClientConfig | None = None) -> AlgodClient:
64
66
  """Returns an {py:class}`algosdk.v2client.algod.AlgodClient` from `config` or environment
65
67
 
@@ -69,7 +71,7 @@ def get_algod_client(config: AlgoClientConfig | None = None) -> AlgodClient:
69
71
  return AlgodClient(config.token, config.server, headers)
70
72
 
71
73
 
72
- @deprecated("Use AlgorandClient.default_localnet().kmd instead")
74
+ @deprecated("Use `ClientManager.get_kmd_client(config)` or `ClientManager.get_kmd_client_from_environment()` instead.")
73
75
  def get_kmd_client(config: AlgoClientConfig | None = None) -> KMDClient:
74
76
  """Returns an {py:class}`algosdk.kmd.KMDClient` from `config` or environment
75
77
 
@@ -78,7 +80,9 @@ def get_kmd_client(config: AlgoClientConfig | None = None) -> KMDClient:
78
80
  return KMDClient(config.token, config.server)
79
81
 
80
82
 
81
- @deprecated("Use AlgorandClient.client.from_environment().indexer instead")
83
+ @deprecated(
84
+ "Use `ClientManager.get_indexer_client(config)` or `ClientManager.get_indexer_client_from_environment()` instead."
85
+ )
82
86
  def get_indexer_client(config: AlgoClientConfig | None = None) -> IndexerClient:
83
87
  """Returns an {py:class}`algosdk.v2client.indexer.IndexerClient` from `config` or environment.
84
88
 
@@ -109,7 +113,7 @@ def is_testnet(client: AlgodClient) -> bool:
109
113
  return params.gen in ["testnet-v1.0", "testnet-v1", "testnet"]
110
114
 
111
115
 
112
- @deprecated("Use AlgorandClient.default_localnet().kmd instead")
116
+ @deprecated("Use `ClientManager.get_kmd_client(config)` or `ClientManager.get_kmd_client_from_environment()` instead.")
113
117
  def get_kmd_client_from_algod_client(client: AlgodClient) -> KMDClient:
114
118
  """Returns an {py:class}`algosdk.kmd.KMDClient` from supplied `client`
115
119
 
@@ -12,7 +12,7 @@ from typing_extensions import Self
12
12
 
13
13
  from algokit_utils.accounts.kmd_account_manager import KmdAccountManager
14
14
  from algokit_utils.clients.client_manager import ClientManager
15
- from algokit_utils.clients.dispenser_api_client import DispenserAssetName, TestNetDispenserApiClient
15
+ from algokit_utils.clients.dispenser_api_client import TestNetDispenserApiClient
16
16
  from algokit_utils.config import config
17
17
  from algokit_utils.models.account import (
18
18
  DISPENSER_ACCOUNT_NAME,
@@ -49,7 +49,9 @@ class _CommonEnsureFundedParams:
49
49
  """
50
50
 
51
51
  transaction_id: str
52
+ """The transaction ID of the funded transaction"""
52
53
  amount_funded: AlgoAmount
54
+ """The amount of Algos funded"""
53
55
 
54
56
 
55
57
  @dataclass(frozen=True, kw_only=True)
@@ -72,69 +74,68 @@ class AccountInformation:
72
74
  Information about an Algorand account's current status, balance and other properties.
73
75
 
74
76
  See `https://developer.algorand.org/docs/rest-apis/algod/#account` for detailed field descriptions.
75
-
76
- :ivar str address: The account's address
77
- :ivar AlgoAmount amount: The account's current balance
78
- :ivar AlgoAmount amount_without_pending_rewards: The account's balance without the pending rewards
79
- :ivar AlgoAmount min_balance: The account's minimum required balance
80
- :ivar AlgoAmount pending_rewards: The amount of pending rewards
81
- :ivar AlgoAmount rewards: The amount of rewards earned
82
- :ivar int round: The round for which this information is relevant
83
- :ivar str status: The account's status (e.g., 'Offline', 'Online')
84
- :ivar int|None total_apps_opted_in: Number of applications this account has opted into
85
- :ivar int|None total_assets_opted_in: Number of assets this account has opted into
86
- :ivar int|None total_box_bytes: Total number of box bytes used by this account
87
- :ivar int|None total_boxes: Total number of boxes used by this account
88
- :ivar int|None total_created_apps: Number of applications created by this account
89
- :ivar int|None total_created_assets: Number of assets created by this account
90
- :ivar list[dict]|None apps_local_state: Local state of applications this account has opted into
91
- :ivar int|None apps_total_extra_pages: Number of extra pages allocated to applications
92
- :ivar dict|None apps_total_schema: Total schema for all applications
93
- :ivar list[dict]|None assets: Assets held by this account
94
- :ivar str|None auth_addr: If rekeyed, the authorized address
95
- :ivar int|None closed_at_round: Round when this account was closed
96
- :ivar list[dict]|None created_apps: Applications created by this account
97
- :ivar list[dict]|None created_assets: Assets created by this account
98
- :ivar int|None created_at_round: Round when this account was created
99
- :ivar bool|None deleted: Whether this account is deleted
100
- :ivar bool|None incentive_eligible: Whether this account is eligible for incentives
101
- :ivar int|None last_heartbeat: Last heartbeat round for this account
102
- :ivar int|None last_proposed: Last round this account proposed a block
103
- :ivar dict|None participation: Participation information for this account
104
- :ivar int|None reward_base: Base reward for this account
105
- :ivar str|None sig_type: Signature type for this account
106
77
  """
107
78
 
108
79
  address: str
80
+ """The account's address"""
109
81
  amount: AlgoAmount
82
+ """The account's current balance"""
110
83
  amount_without_pending_rewards: AlgoAmount
84
+ """The account's balance without the pending rewards"""
111
85
  min_balance: AlgoAmount
86
+ """The account's minimum required balance"""
112
87
  pending_rewards: AlgoAmount
88
+ """The amount of pending rewards"""
113
89
  rewards: AlgoAmount
90
+ """The amount of rewards earned"""
114
91
  round: int
92
+ """The round for which this information is relevant"""
115
93
  status: str
94
+ """The account's status (e.g., 'Offline', 'Online')"""
116
95
  total_apps_opted_in: int | None = None
96
+ """Number of applications this account has opted into"""
117
97
  total_assets_opted_in: int | None = None
98
+ """Number of assets this account has opted into"""
118
99
  total_box_bytes: int | None = None
100
+ """Total number of box bytes used by this account"""
119
101
  total_boxes: int | None = None
102
+ """Total number of boxes used by this account"""
120
103
  total_created_apps: int | None = None
104
+ """Number of applications created by this account"""
121
105
  total_created_assets: int | None = None
106
+ """Number of assets created by this account"""
122
107
  apps_local_state: list[dict] | None = None
108
+ """Local state of applications this account has opted into"""
123
109
  apps_total_extra_pages: int | None = None
110
+ """Number of extra pages allocated to applications"""
124
111
  apps_total_schema: dict | None = None
112
+ """Total schema for all applications"""
125
113
  assets: list[dict] | None = None
114
+ """Assets held by this account"""
126
115
  auth_addr: str | None = None
116
+ """If rekeyed, the authorized address"""
127
117
  closed_at_round: int | None = None
118
+ """Round when this account was closed"""
128
119
  created_apps: list[dict] | None = None
120
+ """Applications created by this account"""
129
121
  created_assets: list[dict] | None = None
122
+ """Assets created by this account"""
130
123
  created_at_round: int | None = None
124
+ """Round when this account was created"""
131
125
  deleted: bool | None = None
126
+ """Whether this account is deleted"""
132
127
  incentive_eligible: bool | None = None
128
+ """Whether this account is eligible for incentives"""
133
129
  last_heartbeat: int | None = None
130
+ """Last heartbeat round for this account"""
134
131
  last_proposed: int | None = None
132
+ """Last round this account proposed a block"""
135
133
  participation: dict | None = None
134
+ """Participation information for this account"""
136
135
  reward_base: int | None = None
136
+ """Base reward for this account"""
137
137
  sig_type: str | None = None
138
+ """Signature type for this account"""
138
139
 
139
140
 
140
141
  class AccountManager:
@@ -158,6 +159,13 @@ class AccountManager:
158
159
 
159
160
  @property
160
161
  def kmd(self) -> KmdAccountManager:
162
+ """
163
+ KMD account manager that allows you to easily get and create accounts using KMD.
164
+
165
+ :return KmdAccountManager: The 'KmdAccountManager' instance
166
+ :example:
167
+ >>> kmd_manager = account_manager.kmd
168
+ """
161
169
  return self._kmd_account_manager
162
170
 
163
171
  def set_default_signer(self, signer: TransactionSigner | TransactionSignerAccountProtocol) -> Self:
@@ -172,10 +180,7 @@ class AccountManager:
172
180
 
173
181
  :example:
174
182
  >>> signer_account = account_manager.random()
175
- >>> account_manager.set_default_signer(signer_account.signer)
176
- >>> # When signing a transaction, if there is no signer registered for the sender
177
- >>> # then the default signer will be used
178
- >>> signer = account_manager.get_signer("{SENDERADDRESS}")
183
+ >>> account_manager.set_default_signer(signer_account)
179
184
  """
180
185
  self._default_signer = signer if isinstance(signer, TransactionSigner) else signer.signer
181
186
  return self
@@ -201,6 +206,9 @@ class AccountManager:
201
206
  :param another_account_manager: The `AccountManager` to merge into this one
202
207
  :param overwrite_existing: Whether to overwrite existing signers in this manager
203
208
  :returns: The `AccountManager` instance for method chaining
209
+
210
+ :example:
211
+ >>> accountManager2.set_signers(accountManager1)
204
212
  """
205
213
  self._accounts = (
206
214
  {**self._accounts, **another_account_manager._accounts} # noqa: SLF001
@@ -417,7 +425,7 @@ class AccountManager:
417
425
  :returns: A logic signature account wrapper
418
426
 
419
427
  :example:
420
- >>> account = account.logic_sig(program, [new Uint8Array(3, ...)])
428
+ >>> account = account.logicsig(program, [new Uint8Array(3, ...)])
421
429
  """
422
430
  return self._register_logicsig(program, args)
423
431
 
@@ -540,22 +548,22 @@ class AccountManager:
540
548
 
541
549
  :example:
542
550
  >>> # Basic example (with string addresses):
543
- >>> algorand.account.rekey_account({account: "ACCOUNTADDRESS", rekey_to: "NEWADDRESS"})
551
+ >>> algorand.account.rekey_account("ACCOUNTADDRESS", "NEWADDRESS")
544
552
  >>> # Basic example (with signer accounts):
545
- >>> algorand.account.rekey_account({account: account1, rekey_to: newSignerAccount})
553
+ >>> algorand.account.rekey_account(account1, newSignerAccount)
546
554
  >>> # Advanced example:
547
- >>> algorand.account.rekey_account({
548
- ... account: "ACCOUNTADDRESS",
549
- ... rekey_to: "NEWADDRESS",
550
- ... lease: 'lease',
551
- ... note: 'note',
552
- ... first_valid_round: 1000,
553
- ... validity_window: 10,
554
- ... extra_fee: AlgoAmount.from_micro_algo(1000),
555
- ... static_fee: AlgoAmount.from_micro_algo(1000),
556
- ... max_fee: AlgoAmount.from_micro_algo(3000),
557
- ... suppress_log: True,
558
- ... })
555
+ >>> algorand.account.rekey_account(
556
+ ... account="ACCOUNTADDRESS",
557
+ ... rekey_to="NEWADDRESS",
558
+ ... lease='lease',
559
+ ... note='note',
560
+ ... first_valid_round=1000,
561
+ ... validity_window=10,
562
+ ... extra_fee=AlgoAmount.from_micro_algo(1000),
563
+ ... static_fee=AlgoAmount.from_micro_algo(1000),
564
+ ... max_fee=AlgoAmount.from_micro_algo(3000),
565
+ ... suppress_log=True,
566
+ ... )
559
567
  """
560
568
  sender_address = self._get_address(account)
561
569
  rekey_address = self._get_address(rekey_to)
@@ -640,13 +648,13 @@ class AccountManager:
640
648
 
641
649
  :example:
642
650
  >>> # Basic example:
643
- >>> algorand.account.ensure_funded("ACCOUNTADDRESS", "DISPENSERADDRESS", algokit.algo(1))
651
+ >>> algorand.account.ensure_funded("ACCOUNTADDRESS", "DISPENSERADDRESS", AlgoAmount.from_algo(1))
644
652
  >>> # With configuration:
645
653
  >>> algorand.account.ensure_funded(
646
654
  ... "ACCOUNTADDRESS",
647
655
  ... "DISPENSERADDRESS",
648
- ... algokit.algo(1),
649
- ... min_funding_increment=algokit.algo(2),
656
+ ... AlgoAmount.from_algo(1),
657
+ ... min_funding_increment=AlgoAmount.from_algo(2),
650
658
  ... fee=AlgoAmount.from_micro_algo(1000),
651
659
  ... suppress_log=True
652
660
  ... )
@@ -746,12 +754,12 @@ class AccountManager:
746
754
 
747
755
  :example:
748
756
  >>> # Basic example:
749
- >>> algorand.account.ensure_funded_from_environment("ACCOUNTADDRESS", algokit.algo(1))
757
+ >>> algorand.account.ensure_funded_from_environment("ACCOUNTADDRESS", AlgoAmount.from_algo(1))
750
758
  >>> # With configuration:
751
759
  >>> algorand.account.ensure_funded_from_environment(
752
760
  ... "ACCOUNTADDRESS",
753
- ... algokit.algo(1),
754
- ... min_funding_increment=algokit.algo(2),
761
+ ... AlgoAmount.from_algo(1),
762
+ ... min_funding_increment=AlgoAmount.from_algo(2),
755
763
  ... fee=AlgoAmount.from_micro_algo(1000),
756
764
  ... suppress_log=True
757
765
  ... )
@@ -825,17 +833,17 @@ class AccountManager:
825
833
 
826
834
  :example:
827
835
  >>> # Basic example:
828
- >>> algorand.account.ensure_funded_from_testnet_dispenser_api(
836
+ >>> account_manager.ensure_funded_from_testnet_dispenser_api(
829
837
  ... "ACCOUNTADDRESS",
830
838
  ... algorand.client.get_testnet_dispenser_from_environment(),
831
- ... algokit.algo(1)
839
+ ... AlgoAmount.from_algo(1)
832
840
  ... )
833
841
  >>> # With configuration:
834
- >>> algorand.account.ensure_funded_from_testnet_dispenser_api(
842
+ >>> account_manager.ensure_funded_from_testnet_dispenser_api(
835
843
  ... "ACCOUNTADDRESS",
836
844
  ... algorand.client.get_testnet_dispenser_from_environment(),
837
- ... algokit.algo(1),
838
- ... min_funding_increment=algokit.algo(2)
845
+ ... AlgoAmount.from_algo(1),
846
+ ... min_funding_increment=AlgoAmount.from_algo(2)
839
847
  ... )
840
848
  """
841
849
  account_to_fund = self._get_address(account_to_fund)
@@ -848,11 +856,7 @@ class AccountManager:
848
856
  if not amount_funded:
849
857
  return None
850
858
 
851
- result = dispenser_client.fund(
852
- address=account_to_fund,
853
- amount=amount_funded.micro_algo,
854
- asset_id=DispenserAssetName.ALGO,
855
- )
859
+ result = dispenser_client.fund(address=account_to_fund, amount=amount_funded.micro_algo)
856
860
 
857
861
  return EnsureFundedFromTestnetDispenserApiResult(
858
862
  transaction_id=result.tx_id,