algokit-utils 5.0.0a3__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.
Files changed (337) hide show
  1. algokit_abi/__init__.py +9 -0
  2. algokit_abi/_arc32_to_arc56.py +242 -0
  3. algokit_abi/_arc56_serde.py +161 -0
  4. algokit_abi/abi.py +667 -0
  5. algokit_abi/arc32.py +210 -0
  6. algokit_abi/arc56.py +821 -0
  7. algokit_abi/py.typed +0 -0
  8. algokit_algo25/__init__.py +38 -0
  9. algokit_algo25/_encoding.py +46 -0
  10. algokit_algo25/_wordlist.py +2065 -0
  11. algokit_algo25/exceptions.py +29 -0
  12. algokit_algo25/mnemonic.py +128 -0
  13. algokit_algo25/py.typed +0 -0
  14. algokit_algod_client/__init__.py +10 -0
  15. algokit_algod_client/client.py +1585 -0
  16. algokit_algod_client/config.py +36 -0
  17. algokit_algod_client/exceptions.py +59 -0
  18. algokit_algod_client/models/__init__.py +229 -0
  19. algokit_algod_client/models/_account.py +150 -0
  20. algokit_algod_client/models/_account_application_response.py +25 -0
  21. algokit_algod_client/models/_account_asset_response.py +25 -0
  22. algokit_algod_client/models/_account_participation.py +53 -0
  23. algokit_algod_client/models/_account_state_delta.py +30 -0
  24. algokit_algod_client/models/_allocations_for_genesis_file.py +23 -0
  25. algokit_algod_client/models/_allocations_for_genesis_file_state_model.py +42 -0
  26. algokit_algod_client/models/_application.py +23 -0
  27. algokit_algod_client/models/_application_initial_states.py +37 -0
  28. algokit_algod_client/models/_application_kvstorage.py +29 -0
  29. algokit_algod_client/models/_application_local_state.py +33 -0
  30. algokit_algod_client/models/_application_params.py +63 -0
  31. algokit_algod_client/models/_application_state_operation.py +41 -0
  32. algokit_algod_client/models/_application_state_schema.py +22 -0
  33. algokit_algod_client/models/_asset.py +23 -0
  34. algokit_algod_client/models/_asset_holding.py +29 -0
  35. algokit_algod_client/models/_asset_params.py +102 -0
  36. algokit_algod_client/models/_avm_key_value.py +28 -0
  37. algokit_algod_client/models/_avm_value.py +32 -0
  38. algokit_algod_client/models/_block.py +363 -0
  39. algokit_algod_client/models/_block_hash_response.py +14 -0
  40. algokit_algod_client/models/_block_txids_response.py +14 -0
  41. algokit_algod_client/models/_box.py +36 -0
  42. algokit_algod_client/models/_box_descriptor.py +24 -0
  43. algokit_algod_client/models/_boxes_response.py +21 -0
  44. algokit_algod_client/models/_build_version_contains_the_current_algod_build_version_information.py +34 -0
  45. algokit_algod_client/models/_compile_response.py +24 -0
  46. algokit_algod_client/models/_disassemble_response.py +14 -0
  47. algokit_algod_client/models/_error_response.py +22 -0
  48. algokit_algod_client/models/_eval_delta.py +32 -0
  49. algokit_algod_client/models/_eval_delta_key_value.py +28 -0
  50. algokit_algod_client/models/_genesis_file_in_json.py +53 -0
  51. algokit_algod_client/models/_get_block_time_stamp_offset_response.py +14 -0
  52. algokit_algod_client/models/_get_sync_round_response.py +14 -0
  53. algokit_algod_client/models/_ledger_state_delta.py +389 -0
  54. algokit_algod_client/models/_light_block_header_proof.py +32 -0
  55. algokit_algod_client/models/_node_status_response.py +118 -0
  56. algokit_algod_client/models/_pending_transaction_response.py +91 -0
  57. algokit_algod_client/models/_pending_transactions_response.py +29 -0
  58. algokit_algod_client/models/_post_transactions_response.py +14 -0
  59. algokit_algod_client/models/_scratch_change.py +23 -0
  60. algokit_algod_client/models/_serde_helpers.py +241 -0
  61. algokit_algod_client/models/_simulate_initial_states.py +25 -0
  62. algokit_algod_client/models/_simulate_request.py +54 -0
  63. algokit_algod_client/models/_simulate_request_transaction_group.py +25 -0
  64. algokit_algod_client/models/_simulate_response.py +44 -0
  65. algokit_algod_client/models/_simulate_trace_config.py +30 -0
  66. algokit_algod_client/models/_simulate_transaction_group_result.py +46 -0
  67. algokit_algod_client/models/_simulate_transaction_result.py +41 -0
  68. algokit_algod_client/models/_simulate_unnamed_resources_accessed.py +64 -0
  69. algokit_algod_client/models/_simulation_eval_overrides.py +40 -0
  70. algokit_algod_client/models/_simulation_opcode_trace_unit.py +55 -0
  71. algokit_algod_client/models/_simulation_transaction_exec_trace.py +82 -0
  72. algokit_algod_client/models/_source_map.py +30 -0
  73. algokit_algod_client/models/_state_delta.py +6 -0
  74. algokit_algod_client/models/_state_proof.py +28 -0
  75. algokit_algod_client/models/_state_proof_message.py +44 -0
  76. algokit_algod_client/models/_supply_response.py +26 -0
  77. algokit_algod_client/models/_teal_key_value.py +28 -0
  78. algokit_algod_client/models/_teal_key_value_store.py +6 -0
  79. algokit_algod_client/models/_teal_value.py +32 -0
  80. algokit_algod_client/models/_transaction_group_ledger_state_deltas_for_round_response.py +21 -0
  81. algokit_algod_client/models/_transaction_parameters_response.py +45 -0
  82. algokit_algod_client/models/_transaction_proof.py +44 -0
  83. algokit_algod_client/models/_version_contains_the_current_algod_version.py +38 -0
  84. algokit_algod_client/models/suggested_params.py +42 -0
  85. algokit_algod_client/py.typed +1 -0
  86. algokit_algod_client/types.py +7 -0
  87. algokit_algosdk/__init__.py +38 -0
  88. algokit_algosdk/account.py +32 -0
  89. algokit_algosdk/app_access.py +228 -0
  90. algokit_algosdk/box_reference.py +100 -0
  91. algokit_algosdk/constants.py +147 -0
  92. algokit_algosdk/encoding.py +89 -0
  93. algokit_algosdk/error.py +180 -0
  94. algokit_algosdk/logic.py +61 -0
  95. algokit_algosdk/logicsig.py +218 -0
  96. algokit_algosdk/mnemonic.py +216 -0
  97. algokit_algosdk/multisig.py +161 -0
  98. algokit_algosdk/py.typed +0 -0
  99. algokit_algosdk/transaction.py +596 -0
  100. algokit_algosdk/wordlist.py +2054 -0
  101. algokit_common/__init__.py +50 -0
  102. algokit_common/address.py +34 -0
  103. algokit_common/constants.py +47 -0
  104. algokit_common/hashing.py +25 -0
  105. algokit_common/py.typed +0 -0
  106. algokit_common/serde/__init__.py +40 -0
  107. algokit_common/serde/_core.py +610 -0
  108. algokit_common/serde/_primitives.py +135 -0
  109. algokit_common/source_map.py +158 -0
  110. algokit_indexer_client/__init__.py +10 -0
  111. algokit_indexer_client/client.py +1456 -0
  112. algokit_indexer_client/config.py +36 -0
  113. algokit_indexer_client/exceptions.py +59 -0
  114. algokit_indexer_client/models/__init__.py +148 -0
  115. algokit_indexer_client/models/_account.py +161 -0
  116. algokit_indexer_client/models/_account_participation.py +53 -0
  117. algokit_indexer_client/models/_account_response.py +19 -0
  118. algokit_indexer_client/models/_account_state_delta.py +29 -0
  119. algokit_indexer_client/models/_accounts_response.py +29 -0
  120. algokit_indexer_client/models/_application.py +35 -0
  121. algokit_indexer_client/models/_application_local_state.py +45 -0
  122. algokit_indexer_client/models/_application_local_states_response.py +29 -0
  123. algokit_indexer_client/models/_application_log_data.py +28 -0
  124. algokit_indexer_client/models/_application_logs_response.py +33 -0
  125. algokit_indexer_client/models/_application_params.py +62 -0
  126. algokit_indexer_client/models/_application_response.py +20 -0
  127. algokit_indexer_client/models/_application_state_schema.py +22 -0
  128. algokit_indexer_client/models/_applications_response.py +29 -0
  129. algokit_indexer_client/models/_asset.py +35 -0
  130. algokit_indexer_client/models/_asset_balances_response.py +29 -0
  131. algokit_indexer_client/models/_asset_holding.py +41 -0
  132. algokit_indexer_client/models/_asset_holdings_response.py +29 -0
  133. algokit_indexer_client/models/_asset_params.py +102 -0
  134. algokit_indexer_client/models/_asset_response.py +19 -0
  135. algokit_indexer_client/models/_assets_response.py +29 -0
  136. algokit_indexer_client/models/_block.py +150 -0
  137. algokit_indexer_client/models/_block_headers_response.py +29 -0
  138. algokit_indexer_client/models/_block_rewards.py +38 -0
  139. algokit_indexer_client/models/_block_upgrade_state.py +34 -0
  140. algokit_indexer_client/models/_block_upgrade_vote.py +26 -0
  141. algokit_indexer_client/models/_box.py +36 -0
  142. algokit_indexer_client/models/_box_descriptor.py +24 -0
  143. algokit_indexer_client/models/_box_reference.py +28 -0
  144. algokit_indexer_client/models/_boxes_response.py +29 -0
  145. algokit_indexer_client/models/_error_response.py +18 -0
  146. algokit_indexer_client/models/_eval_delta.py +32 -0
  147. algokit_indexer_client/models/_eval_delta_key_value.py +28 -0
  148. algokit_indexer_client/models/_hash_factory.py +14 -0
  149. algokit_indexer_client/models/_hb_proof_fields.py +57 -0
  150. algokit_indexer_client/models/_health_check.py +42 -0
  151. algokit_indexer_client/models/_holding_ref.py +23 -0
  152. algokit_indexer_client/models/_indexer_state_proof_message.py +40 -0
  153. algokit_indexer_client/models/_locals_ref.py +23 -0
  154. algokit_indexer_client/models/_merkle_array_proof.py +29 -0
  155. algokit_indexer_client/models/_mini_asset_holding.py +38 -0
  156. algokit_indexer_client/models/_on_completion.py +25 -0
  157. algokit_indexer_client/models/_participation_updates.py +22 -0
  158. algokit_indexer_client/models/_resource_ref.py +42 -0
  159. algokit_indexer_client/models/_serde_helpers.py +241 -0
  160. algokit_indexer_client/models/_state_delta.py +6 -0
  161. algokit_indexer_client/models/_state_proof_fields.py +57 -0
  162. algokit_indexer_client/models/_state_proof_participant.py +20 -0
  163. algokit_indexer_client/models/_state_proof_reveal.py +25 -0
  164. algokit_indexer_client/models/_state_proof_sig_slot.py +20 -0
  165. algokit_indexer_client/models/_state_proof_signature.py +37 -0
  166. algokit_indexer_client/models/_state_proof_tracking.py +32 -0
  167. algokit_indexer_client/models/_state_proof_verifier.py +24 -0
  168. algokit_indexer_client/models/_state_schema.py +25 -0
  169. algokit_indexer_client/models/_teal_key_value.py +28 -0
  170. algokit_indexer_client/models/_teal_key_value_store.py +6 -0
  171. algokit_indexer_client/models/_teal_value.py +32 -0
  172. algokit_indexer_client/models/_transaction.py +213 -0
  173. algokit_indexer_client/models/_transaction_application.py +105 -0
  174. algokit_indexer_client/models/_transaction_asset_config.py +31 -0
  175. algokit_indexer_client/models/_transaction_asset_freeze.py +29 -0
  176. algokit_indexer_client/models/_transaction_asset_transfer.py +41 -0
  177. algokit_indexer_client/models/_transaction_heartbeat.py +52 -0
  178. algokit_indexer_client/models/_transaction_keyreg.py +59 -0
  179. algokit_indexer_client/models/_transaction_payment.py +33 -0
  180. algokit_indexer_client/models/_transaction_response.py +19 -0
  181. algokit_indexer_client/models/_transaction_signature.py +35 -0
  182. algokit_indexer_client/models/_transaction_signature_logicsig.py +59 -0
  183. algokit_indexer_client/models/_transaction_signature_multisig.py +36 -0
  184. algokit_indexer_client/models/_transaction_signature_multisig_subsignature.py +28 -0
  185. algokit_indexer_client/models/_transaction_state_proof.py +32 -0
  186. algokit_indexer_client/models/_transactions_response.py +29 -0
  187. algokit_indexer_client/py.typed +1 -0
  188. algokit_indexer_client/types.py +7 -0
  189. algokit_kmd_client/__init__.py +10 -0
  190. algokit_kmd_client/client.py +1240 -0
  191. algokit_kmd_client/config.py +36 -0
  192. algokit_kmd_client/exceptions.py +59 -0
  193. algokit_kmd_client/models/__init__.py +112 -0
  194. algokit_kmd_client/models/_classical_signatures.py +4 -0
  195. algokit_kmd_client/models/_create_wallet_request.py +30 -0
  196. algokit_kmd_client/models/_create_wallet_response.py +19 -0
  197. algokit_kmd_client/models/_delete_key_request.py +27 -0
  198. algokit_kmd_client/models/_delete_multisig_request.py +27 -0
  199. algokit_kmd_client/models/_digest_represents_a32_byte_value_holding_the256_bit_hash_digest.py +4 -0
  200. algokit_kmd_client/models/_ed25519_public_key.py +4 -0
  201. algokit_kmd_client/models/_export_key_request.py +27 -0
  202. algokit_kmd_client/models/_export_key_response.py +24 -0
  203. algokit_kmd_client/models/_export_master_key_request.py +22 -0
  204. algokit_kmd_client/models/_export_master_key_response.py +18 -0
  205. algokit_kmd_client/models/_export_multisig_request.py +23 -0
  206. algokit_kmd_client/models/_export_multisig_response.py +26 -0
  207. algokit_kmd_client/models/_generate_key_request.py +18 -0
  208. algokit_kmd_client/models/_generate_key_response.py +19 -0
  209. algokit_kmd_client/models/_import_key_request.py +28 -0
  210. algokit_kmd_client/models/_import_key_response.py +19 -0
  211. algokit_kmd_client/models/_import_multisig_request.py +30 -0
  212. algokit_kmd_client/models/_import_multisig_response.py +19 -0
  213. algokit_kmd_client/models/_init_wallet_handle_token_request.py +22 -0
  214. algokit_kmd_client/models/_init_wallet_handle_token_response.py +18 -0
  215. algokit_kmd_client/models/_list_keys_request.py +18 -0
  216. algokit_kmd_client/models/_list_keys_response.py +18 -0
  217. algokit_kmd_client/models/_list_multisig_request.py +18 -0
  218. algokit_kmd_client/models/_list_multisig_response.py +18 -0
  219. algokit_kmd_client/models/_list_wallets_request.py +11 -0
  220. algokit_kmd_client/models/_list_wallets_response.py +25 -0
  221. algokit_kmd_client/models/_master_derivation_key.py +4 -0
  222. algokit_kmd_client/models/_multisig_sig.py +33 -0
  223. algokit_kmd_client/models/_multisig_subsig.py +23 -0
  224. algokit_kmd_client/models/_public_key.py +4 -0
  225. algokit_kmd_client/models/_release_wallet_handle_token_request.py +18 -0
  226. algokit_kmd_client/models/_rename_wallet_request.py +26 -0
  227. algokit_kmd_client/models/_rename_wallet_response.py +19 -0
  228. algokit_kmd_client/models/_renew_wallet_handle_token_request.py +18 -0
  229. algokit_kmd_client/models/_renew_wallet_handle_token_response.py +19 -0
  230. algokit_kmd_client/models/_serde_helpers.py +241 -0
  231. algokit_kmd_client/models/_sign_multisig_response.py +24 -0
  232. algokit_kmd_client/models/_sign_multisig_txn_request.py +45 -0
  233. algokit_kmd_client/models/_sign_program_multisig_request.py +50 -0
  234. algokit_kmd_client/models/_sign_program_multisig_response.py +24 -0
  235. algokit_kmd_client/models/_sign_program_request.py +37 -0
  236. algokit_kmd_client/models/_sign_program_response.py +24 -0
  237. algokit_kmd_client/models/_sign_transaction_response.py +24 -0
  238. algokit_kmd_client/models/_sign_txn_request.py +36 -0
  239. algokit_kmd_client/models/_signature.py +4 -0
  240. algokit_kmd_client/models/_tx_type.py +4 -0
  241. algokit_kmd_client/models/_versions_request.py +11 -0
  242. algokit_kmd_client/models/_versions_response.py +19 -0
  243. algokit_kmd_client/models/_wallet.py +38 -0
  244. algokit_kmd_client/models/_wallet_handle.py +24 -0
  245. algokit_kmd_client/models/_wallet_info_request.py +18 -0
  246. algokit_kmd_client/models/_wallet_info_response.py +19 -0
  247. algokit_kmd_client/py.typed +1 -0
  248. algokit_kmd_client/types.py +7 -0
  249. algokit_transact/__init__.py +190 -0
  250. algokit_transact/codec/__init__.py +0 -0
  251. algokit_transact/codec/msgpack.py +11 -0
  252. algokit_transact/codec/serde.py +7 -0
  253. algokit_transact/codec/signed.py +57 -0
  254. algokit_transact/codec/transaction.py +65 -0
  255. algokit_transact/exceptions.py +17 -0
  256. algokit_transact/logicsig.py +220 -0
  257. algokit_transact/models/__init__.py +0 -0
  258. algokit_transact/models/app_call.py +447 -0
  259. algokit_transact/models/asset_config.py +19 -0
  260. algokit_transact/models/asset_freeze.py +11 -0
  261. algokit_transact/models/asset_transfer.py +13 -0
  262. algokit_transact/models/common.py +17 -0
  263. algokit_transact/models/heartbeat.py +21 -0
  264. algokit_transact/models/key_registration.py +14 -0
  265. algokit_transact/models/payment.py +14 -0
  266. algokit_transact/models/signed_transaction.py +21 -0
  267. algokit_transact/models/state_proof.py +150 -0
  268. algokit_transact/models/transaction.py +88 -0
  269. algokit_transact/multisig.py +93 -0
  270. algokit_transact/ops/__init__.py +0 -0
  271. algokit_transact/ops/fees.py +47 -0
  272. algokit_transact/ops/group.py +28 -0
  273. algokit_transact/ops/ids.py +14 -0
  274. algokit_transact/ops/validate.py +503 -0
  275. algokit_transact/py.typed +0 -0
  276. algokit_transact/signer.py +195 -0
  277. algokit_transact/signing/__init__.py +0 -0
  278. algokit_transact/signing/logic_signature.py +19 -0
  279. algokit_transact/signing/multisig.py +84 -0
  280. algokit_transact/signing/types.py +39 -0
  281. algokit_transact/signing/validation.py +63 -0
  282. algokit_utils/__init__.py +23 -0
  283. algokit_utils/_debugging.py +304 -0
  284. algokit_utils/accounts/__init__.py +2 -0
  285. algokit_utils/accounts/account_manager.py +1051 -0
  286. algokit_utils/accounts/kmd_account_manager.py +206 -0
  287. algokit_utils/algo25.py +46 -0
  288. algokit_utils/algorand.py +383 -0
  289. algokit_utils/applications/__init__.py +7 -0
  290. algokit_utils/applications/abi.py +280 -0
  291. algokit_utils/applications/app_client.py +2193 -0
  292. algokit_utils/applications/app_deployer.py +788 -0
  293. algokit_utils/applications/app_factory.py +1140 -0
  294. algokit_utils/applications/app_manager.py +575 -0
  295. algokit_utils/applications/app_spec/__init__.py +6 -0
  296. algokit_utils/applications/enums.py +40 -0
  297. algokit_utils/assets/__init__.py +1 -0
  298. algokit_utils/assets/asset_manager.py +344 -0
  299. algokit_utils/clients/__init__.py +41 -0
  300. algokit_utils/clients/client_manager.py +756 -0
  301. algokit_utils/clients/dispenser_api_client.py +212 -0
  302. algokit_utils/common.py +40 -0
  303. algokit_utils/config.py +159 -0
  304. algokit_utils/errors/__init__.py +1 -0
  305. algokit_utils/errors/logic_error.py +160 -0
  306. algokit_utils/models/__init__.py +7 -0
  307. algokit_utils/models/account.py +12 -0
  308. algokit_utils/models/amount.py +198 -0
  309. algokit_utils/models/application.py +90 -0
  310. algokit_utils/models/network.py +29 -0
  311. algokit_utils/models/simulate.py +7 -0
  312. algokit_utils/models/state.py +53 -0
  313. algokit_utils/models/transaction.py +49 -0
  314. algokit_utils/protocols/__init__.py +3 -0
  315. algokit_utils/protocols/account.py +11 -0
  316. algokit_utils/protocols/signer.py +17 -0
  317. algokit_utils/protocols/typed_clients.py +110 -0
  318. algokit_utils/py.typed +0 -0
  319. algokit_utils/transact.py +195 -0
  320. algokit_utils/transactions/__init__.py +3 -0
  321. algokit_utils/transactions/builders/__init__.py +67 -0
  322. algokit_utils/transactions/builders/app.py +248 -0
  323. algokit_utils/transactions/builders/asset.py +256 -0
  324. algokit_utils/transactions/builders/common.py +263 -0
  325. algokit_utils/transactions/builders/keyreg.py +103 -0
  326. algokit_utils/transactions/builders/method_call.py +380 -0
  327. algokit_utils/transactions/builders/payment.py +43 -0
  328. algokit_utils/transactions/composer_resources.py +409 -0
  329. algokit_utils/transactions/fee_coverage.py +79 -0
  330. algokit_utils/transactions/helpers.py +9 -0
  331. algokit_utils/transactions/transaction_composer.py +1574 -0
  332. algokit_utils/transactions/transaction_creator.py +699 -0
  333. algokit_utils/transactions/transaction_sender.py +1240 -0
  334. algokit_utils/transactions/types.py +262 -0
  335. algokit_utils-5.0.0a3.dist-info/METADATA +105 -0
  336. algokit_utils-5.0.0a3.dist-info/RECORD +337 -0
  337. algokit_utils-5.0.0a3.dist-info/WHEEL +4 -0
@@ -0,0 +1,198 @@
1
+ from decimal import Decimal
2
+ from functools import total_ordering
3
+ from typing import overload
4
+
5
+ from typing_extensions import Self
6
+
7
+ from algokit_common import MICROALGOS_TO_ALGOS_RATIO
8
+
9
+ __all__ = ["ALGORAND_MIN_TX_FEE", "AlgoAmount", "algo", "micro_algo", "transaction_fees"]
10
+
11
+
12
+ @total_ordering
13
+ class AlgoAmount:
14
+ """Wrapper class to ensure safe, explicit conversion between µAlgo, Algo and numbers.
15
+
16
+ :example:
17
+ >>> amount = AlgoAmount(algo=1)
18
+ >>> amount = AlgoAmount.from_algo(1)
19
+ >>> amount = AlgoAmount(micro_algo=1_000_000)
20
+ >>> amount = AlgoAmount.from_micro_algo(1_000_000)
21
+ """
22
+
23
+ @overload
24
+ def __init__(self, *, micro_algo: int) -> None: ...
25
+
26
+ @overload
27
+ def __init__(self, *, algo: int | Decimal) -> None: ...
28
+
29
+ def __init__(
30
+ self,
31
+ *,
32
+ micro_algo: int | None = None,
33
+ algo: int | Decimal | None = None,
34
+ ):
35
+ if micro_algo is None and algo is None:
36
+ raise ValueError("No amount provided")
37
+
38
+ if micro_algo is not None:
39
+ self.amount_in_micro_algo = int(micro_algo)
40
+ elif algo is not None:
41
+ self.amount_in_micro_algo = int(algo * MICROALGOS_TO_ALGOS_RATIO)
42
+ else:
43
+ raise ValueError("Invalid amount provided")
44
+
45
+ @property
46
+ def micro_algo(self) -> int:
47
+ """Return the amount as a number in µAlgo.
48
+
49
+ :returns: The amount in µAlgo.
50
+ """
51
+ return self.amount_in_micro_algo
52
+
53
+ @property
54
+ def algo(self) -> Decimal:
55
+ """Return the amount as a number in Algo.
56
+
57
+ :returns: The amount in Algo.
58
+ """
59
+ return Decimal(self.amount_in_micro_algo) / Decimal(MICROALGOS_TO_ALGOS_RATIO)
60
+
61
+ @staticmethod
62
+ def from_algo(amount: int | Decimal) -> "AlgoAmount":
63
+ """Create an AlgoAmount object representing the given number of Algo.
64
+
65
+ :param amount: The amount in Algo.
66
+ :returns: An AlgoAmount instance.
67
+
68
+ :example:
69
+ >>> amount = AlgoAmount.from_algo(1)
70
+ """
71
+ return AlgoAmount(algo=amount)
72
+
73
+ @staticmethod
74
+ def from_micro_algo(amount: int) -> "AlgoAmount":
75
+ """Create an AlgoAmount object representing the given number of µAlgo.
76
+
77
+ :param amount: The amount in µAlgo.
78
+ :returns: An AlgoAmount instance.
79
+
80
+ :example:
81
+ >>> amount = AlgoAmount.from_micro_algo(1_000_000)
82
+ """
83
+ return AlgoAmount(micro_algo=amount)
84
+
85
+ def _coerce_micro_algos(self, other: object, op: str, *, allow_int: bool = False) -> int:
86
+ if isinstance(other, AlgoAmount):
87
+ return other.micro_algo
88
+ if allow_int and isinstance(other, int):
89
+ return int(other)
90
+ raise TypeError(f"Unsupported operand type(s) for {op}: 'AlgoAmount' and '{type(other).__name__}'")
91
+
92
+ def _coerce_int_scalar(self, other: object, op: str) -> int:
93
+ if isinstance(other, int):
94
+ return int(other)
95
+ raise TypeError(f"Unsupported operand type(s) for {op}: 'AlgoAmount' and '{type(other).__name__}'")
96
+
97
+ def __str__(self) -> str:
98
+ return f"{self.micro_algo:,} µALGO"
99
+
100
+ def __int__(self) -> int:
101
+ return self.micro_algo
102
+
103
+ def __add__(self, other: object) -> "AlgoAmount":
104
+ total_micro_algos = self.micro_algo + self._coerce_micro_algos(other, "+", allow_int=True)
105
+ return AlgoAmount.from_micro_algo(total_micro_algos)
106
+
107
+ def __radd__(self, other: object) -> "AlgoAmount":
108
+ return self.__add__(other)
109
+
110
+ def __iadd__(self, other: object) -> Self:
111
+ self.amount_in_micro_algo += self._coerce_micro_algos(other, "+", allow_int=True)
112
+ return self
113
+
114
+ def __eq__(self, other: object) -> bool:
115
+ try:
116
+ return self.amount_in_micro_algo == self._coerce_micro_algos(other, "==", allow_int=True)
117
+ except TypeError:
118
+ return False
119
+
120
+ def __lt__(self, other: object) -> bool:
121
+ other_micro_algos = self._coerce_micro_algos(other, "<", allow_int=True)
122
+ return self.amount_in_micro_algo < other_micro_algos
123
+
124
+ def __sub__(self, other: object) -> "AlgoAmount":
125
+ total_micro_algos = self.micro_algo - self._coerce_micro_algos(other, "-", allow_int=True)
126
+ return AlgoAmount.from_micro_algo(total_micro_algos)
127
+
128
+ def __rsub__(self, other: object) -> "AlgoAmount":
129
+ total_micro_algos = self._coerce_micro_algos(other, "-", allow_int=True) - self.micro_algo
130
+ return AlgoAmount.from_micro_algo(total_micro_algos)
131
+
132
+ def __isub__(self, other: object) -> Self:
133
+ self.amount_in_micro_algo -= self._coerce_micro_algos(other, "-", allow_int=True)
134
+ return self
135
+
136
+ def __mul__(self, other: object) -> "AlgoAmount":
137
+ factor = self._coerce_int_scalar(other, "*")
138
+ return AlgoAmount.from_micro_algo(self.micro_algo * factor)
139
+
140
+ def __rmul__(self, other: object) -> "AlgoAmount":
141
+ return self.__mul__(other)
142
+
143
+ def __truediv__(self, other: object) -> "AlgoAmount":
144
+ divisor = self._coerce_int_scalar(other, "/")
145
+ if divisor == 0:
146
+ raise ZeroDivisionError("division by zero")
147
+ return AlgoAmount.from_micro_algo(self.micro_algo // divisor)
148
+
149
+ def __rtruediv__(self, other: object) -> Decimal:
150
+ numerator = self._coerce_int_scalar(other, "/")
151
+ if self.micro_algo == 0:
152
+ raise ZeroDivisionError("division by zero")
153
+ return Decimal(numerator) / Decimal(self.micro_algo)
154
+
155
+ def __floordiv__(self, other: object) -> "AlgoAmount":
156
+ divisor = self._coerce_int_scalar(other, "//")
157
+ if divisor == 0:
158
+ raise ZeroDivisionError("division by zero")
159
+ return AlgoAmount.from_micro_algo(self.micro_algo // divisor)
160
+
161
+ def __rfloordiv__(self, other: object) -> Decimal:
162
+ numerator = self._coerce_int_scalar(other, "//")
163
+ if self.micro_algo == 0:
164
+ raise ZeroDivisionError("division by zero")
165
+ return Decimal(numerator // self.micro_algo)
166
+
167
+
168
+ # Helper functions
169
+ def algo(algo: int) -> "AlgoAmount":
170
+ """Create an AlgoAmount object representing the given number of Algo.
171
+
172
+ :param algo: The number of Algo to create an AlgoAmount object for.
173
+ :return: An AlgoAmount object representing the given number of Algo.
174
+ """
175
+ return AlgoAmount.from_algo(algo)
176
+
177
+
178
+ def micro_algo(micro_algo: int) -> "AlgoAmount":
179
+ """Create an AlgoAmount object representing the given number of µAlgo.
180
+
181
+ :param micro_algo: The number of µAlgo to create an AlgoAmount object for.
182
+ :return: An AlgoAmount object representing the given number of µAlgo.
183
+ """
184
+ return AlgoAmount.from_micro_algo(micro_algo)
185
+
186
+
187
+ ALGORAND_MIN_TX_FEE = micro_algo(1_000)
188
+
189
+
190
+ def transaction_fees(number_of_transactions: int) -> "AlgoAmount":
191
+ """Calculate the total transaction fees for a given number of transactions.
192
+
193
+ :param number_of_transactions: The number of transactions to calculate the fees for.
194
+ :return: The total transaction fees.
195
+ """
196
+
197
+ total_micro_algos = number_of_transactions * ALGORAND_MIN_TX_FEE.micro_algo
198
+ return AlgoAmount.from_micro_algo(total_micro_algos)
@@ -0,0 +1,90 @@
1
+ from dataclasses import dataclass
2
+ from typing import TYPE_CHECKING
3
+
4
+ from algokit_common import ProgramSourceMap
5
+
6
+ if TYPE_CHECKING:
7
+ pass
8
+
9
+ __all__ = [
10
+ "AppCompilationResult",
11
+ "AppInformation",
12
+ "AppSourceMaps",
13
+ "AppState",
14
+ "CompiledTeal",
15
+ ]
16
+
17
+
18
+ @dataclass(kw_only=True, frozen=True)
19
+ class AppState:
20
+ key_raw: bytes
21
+ """The key of the state as raw bytes"""
22
+ key_base64: str
23
+ """The key of the state"""
24
+ value_raw: bytes | None
25
+ """The value of the state as raw bytes"""
26
+ value_base64: str | None
27
+ """The value of the state as base64 encoded string"""
28
+ value: str | int
29
+ """The value of the state as a string or integer"""
30
+
31
+
32
+ @dataclass(kw_only=True, frozen=True)
33
+ class AppInformation:
34
+ app_id: int
35
+ """The ID of the application"""
36
+ app_address: str
37
+ """The address of the application"""
38
+ approval_program: bytes
39
+ """The approval program"""
40
+ clear_state_program: bytes
41
+ """The clear state program"""
42
+ creator: str
43
+ """The creator of the application"""
44
+ global_state: dict[str, AppState]
45
+ """The global state of the application"""
46
+ local_ints: int
47
+ """The number of local ints"""
48
+ local_byte_slices: int
49
+ """The number of local byte slices"""
50
+ global_ints: int
51
+ """The number of global ints"""
52
+ global_byte_slices: int
53
+ """The number of global byte slices"""
54
+ extra_program_pages: int | None
55
+ """The number of extra program pages"""
56
+
57
+
58
+ @dataclass(kw_only=True, frozen=True)
59
+ class CompiledTeal:
60
+ """The compiled teal code"""
61
+
62
+ teal: str
63
+ """The teal code"""
64
+ compiled: str
65
+ """The compiled teal code"""
66
+ compiled_hash: str
67
+ """The compiled hash"""
68
+ compiled_base64_to_bytes: bytes
69
+ """The compiled base64 to bytes"""
70
+ source_map: ProgramSourceMap | None
71
+
72
+
73
+ @dataclass(kw_only=True, frozen=True)
74
+ class AppCompilationResult:
75
+ """The compiled teal code"""
76
+
77
+ compiled_approval: CompiledTeal
78
+ """The compiled approval program"""
79
+ compiled_clear: CompiledTeal
80
+ """The compiled clear state program"""
81
+
82
+
83
+ @dataclass(kw_only=True, frozen=True)
84
+ class AppSourceMaps:
85
+ """The source maps for the application"""
86
+
87
+ approval_source_map: ProgramSourceMap | None = None
88
+ """The source map for the approval program"""
89
+ clear_source_map: ProgramSourceMap | None = None
90
+ """The source map for the clear state program"""
@@ -0,0 +1,29 @@
1
+ import dataclasses
2
+
3
+ __all__ = [
4
+ "AlgoClientConfigs",
5
+ "AlgoClientNetworkConfig",
6
+ ]
7
+
8
+
9
+ @dataclasses.dataclass
10
+ class AlgoClientNetworkConfig:
11
+ """Connection details for connecting to an {py:class}`algokit_algod_client.AlgodClient` or
12
+ {py:class}`algokit_indexer_client.IndexerClient` instance."""
13
+
14
+ server: str
15
+ """URL for the service e.g. `http://localhost` or `https://testnet-api.algonode.cloud`"""
16
+ token: str | None = None
17
+ """API Token to authenticate with the service e.g '4001' or '8980'"""
18
+ port: str | int | None = None
19
+
20
+ def full_url(self) -> str:
21
+ """Returns the full URL for the service"""
22
+ return f"{self.server.rstrip('/')}{f':{self.port}' if self.port else ''}"
23
+
24
+
25
+ @dataclasses.dataclass
26
+ class AlgoClientConfigs:
27
+ algod_config: AlgoClientNetworkConfig
28
+ indexer_config: AlgoClientNetworkConfig | None
29
+ kmd_config: AlgoClientNetworkConfig | None
@@ -0,0 +1,7 @@
1
+ # Re-export SimulateTransactionResult from algod client for simulation traces.
2
+ # Previously this module defined a custom SimulationTrace wrapper class, but
3
+ # now we use the algod client type directly for cross-language consistency.
4
+
5
+ from algokit_algod_client.models import SimulateTransactionResult
6
+
7
+ __all__ = ["SimulateTransactionResult"]
@@ -0,0 +1,53 @@
1
+ from collections.abc import Mapping
2
+ from dataclasses import dataclass
3
+ from enum import IntEnum
4
+ from typing import TypeAlias
5
+
6
+ from algokit_transact import BoxReference as AlgoKitTransactBoxReference
7
+ from algokit_transact.signer import AddressWithTransactionSigner
8
+
9
+ __all__ = [
10
+ "BoxIdentifier",
11
+ "BoxName",
12
+ "BoxReference",
13
+ "BoxValue",
14
+ "DataTypeFlag",
15
+ "TealTemplateParams",
16
+ ]
17
+
18
+
19
+ @dataclass(kw_only=True, frozen=True)
20
+ class BoxName:
21
+ """The name of the box"""
22
+
23
+ name: str
24
+ """The name of the box as a string.
25
+ If the name can't be decoded from UTF-8, the string representation of the bytes is returned instead."""
26
+ name_raw: bytes
27
+ """The name of the box as raw bytes"""
28
+ name_base64: str
29
+ """The name of the box as a base64 encoded string"""
30
+
31
+
32
+ @dataclass(kw_only=True, frozen=True)
33
+ class BoxValue:
34
+ """The value of the box"""
35
+
36
+ name: BoxName
37
+ """The name of the box"""
38
+ value: bytes
39
+ """The value of the box as raw bytes"""
40
+
41
+
42
+ class DataTypeFlag(IntEnum):
43
+ BYTES = 1
44
+ UINT = 2
45
+
46
+
47
+ TealTemplateParams: TypeAlias = Mapping[str, str | int | bytes] | dict[str, str | int | bytes]
48
+
49
+
50
+ BoxIdentifier: TypeAlias = str | bytes | AddressWithTransactionSigner
51
+
52
+
53
+ BoxReference = AlgoKitTransactBoxReference
@@ -0,0 +1,49 @@
1
+ from typing import Any, Literal, TypedDict
2
+
3
+ __all__ = [
4
+ "Arc2TransactionNote",
5
+ "BaseArc2Note",
6
+ "JsonFormatArc2Note",
7
+ "SendParams",
8
+ "StringFormatArc2Note",
9
+ "TransactionNote",
10
+ "TransactionNoteData",
11
+ ]
12
+
13
+
14
+ # Define specific types for different formats
15
+ class BaseArc2Note(TypedDict):
16
+ """Base ARC-0002 transaction note structure"""
17
+
18
+ dapp_name: str
19
+
20
+
21
+ class StringFormatArc2Note(BaseArc2Note):
22
+ """ARC-0002 note for string-based formats (m/b/u)"""
23
+
24
+ format: Literal["m", "b", "u"]
25
+ data: str
26
+
27
+
28
+ class JsonFormatArc2Note(BaseArc2Note):
29
+ """ARC-0002 note for JSON format"""
30
+
31
+ format: Literal["j"]
32
+ data: str | dict[str, Any] | list[Any] | int | None
33
+
34
+
35
+ # Combined type for all valid ARC-0002 notes
36
+ # See: https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0002.md
37
+ Arc2TransactionNote = StringFormatArc2Note | JsonFormatArc2Note
38
+
39
+ TransactionNoteData = str | None | int | list[Any] | dict[str, Any]
40
+ TransactionNote = bytes | TransactionNoteData | Arc2TransactionNote
41
+
42
+
43
+ class SendParams(TypedDict, total=False):
44
+ """Parameters for sending a transaction"""
45
+
46
+ max_rounds_to_wait: int | None
47
+ suppress_log: bool | None
48
+ populate_app_call_resources: bool | None
49
+ cover_app_call_inner_transaction_fees: bool | None
@@ -0,0 +1,3 @@
1
+ from algokit_utils.protocols.account import * # noqa: F403
2
+ from algokit_utils.protocols.signer import * # noqa: F403
3
+ from algokit_utils.protocols.typed_clients import * # noqa: F403
@@ -0,0 +1,11 @@
1
+ """Account protocols - re-exported for convenience."""
2
+
3
+ from algokit_utils.transact import (
4
+ AddressWithSigners,
5
+ AddressWithTransactionSigner,
6
+ )
7
+
8
+ __all__ = [
9
+ "AddressWithSigners",
10
+ "AddressWithTransactionSigner",
11
+ ]
@@ -0,0 +1,17 @@
1
+ """Signer type aliases - re-exported for convenience."""
2
+
3
+ from algokit_utils.transact import (
4
+ BytesSigner,
5
+ DelegatedLsigSigner,
6
+ MxBytesSigner,
7
+ ProgramDataSigner,
8
+ TransactionSigner,
9
+ )
10
+
11
+ __all__ = [
12
+ "BytesSigner",
13
+ "DelegatedLsigSigner",
14
+ "MxBytesSigner",
15
+ "ProgramDataSigner",
16
+ "TransactionSigner",
17
+ ]
@@ -0,0 +1,110 @@
1
+ from typing import TYPE_CHECKING, Any, Generic, Protocol, TypeVar
2
+
3
+ from typing_extensions import Self
4
+
5
+ from algokit_common import ProgramSourceMap
6
+ from algokit_utils.protocols.signer import TransactionSigner
7
+
8
+ if TYPE_CHECKING:
9
+ from algokit_utils.algorand import AlgorandClient
10
+ from algokit_utils.applications.app_client import (
11
+ AppClientBareCallCreateParams,
12
+ AppClientBareCallParams,
13
+ AppClientCompilationParams,
14
+ BaseAppClientMethodCallParams,
15
+ )
16
+ from algokit_utils.applications.app_deployer import (
17
+ ApplicationLookup,
18
+ OnSchemaBreak,
19
+ OnUpdate,
20
+ )
21
+ from algokit_utils.applications.app_factory import AppFactoryDeployResult
22
+ from algokit_utils.models import SendParams
23
+
24
+ __all__ = [
25
+ "TypedAppClientProtocol",
26
+ "TypedAppFactoryProtocol",
27
+ ]
28
+
29
+
30
+ class TypedAppClientProtocol(Protocol):
31
+ """App Client protocol"""
32
+
33
+ @classmethod
34
+ def from_creator_and_name(
35
+ cls,
36
+ *,
37
+ creator_address: str,
38
+ app_name: str,
39
+ default_sender: str | None = None,
40
+ default_signer: TransactionSigner | None = None,
41
+ ignore_cache: bool | None = None,
42
+ app_lookup_cache: "ApplicationLookup | None" = None,
43
+ algorand: "AlgorandClient",
44
+ ) -> Self: ...
45
+
46
+ @classmethod
47
+ def from_network(
48
+ cls,
49
+ *,
50
+ app_name: str | None = None,
51
+ default_sender: str | None = None,
52
+ default_signer: TransactionSigner | None = None,
53
+ approval_source_map: ProgramSourceMap | None = None,
54
+ clear_source_map: ProgramSourceMap | None = None,
55
+ algorand: "AlgorandClient",
56
+ ) -> Self: ...
57
+
58
+ def __init__(
59
+ self,
60
+ *,
61
+ app_id: int,
62
+ app_name: str | None = None,
63
+ default_sender: str | None = None,
64
+ default_signer: TransactionSigner | None = None,
65
+ algorand: "AlgorandClient",
66
+ approval_source_map: ProgramSourceMap | None = None,
67
+ clear_source_map: ProgramSourceMap | None = None,
68
+ ) -> None: ...
69
+
70
+
71
+ CreateParamsT = TypeVar( # noqa: PLC0105
72
+ "CreateParamsT",
73
+ bound="BaseAppClientMethodCallParams | AppClientBareCallCreateParams | None",
74
+ contravariant=True,
75
+ )
76
+ UpdateParamsT = TypeVar( # noqa: PLC0105
77
+ "UpdateParamsT",
78
+ bound="BaseAppClientMethodCallParams | AppClientBareCallParams | None",
79
+ contravariant=True,
80
+ )
81
+ DeleteParamsT = TypeVar( # noqa: PLC0105
82
+ "DeleteParamsT",
83
+ bound="BaseAppClientMethodCallParams | AppClientBareCallParams | None",
84
+ contravariant=True,
85
+ )
86
+
87
+
88
+ class TypedAppFactoryProtocol(Protocol, Generic[CreateParamsT, UpdateParamsT, DeleteParamsT]):
89
+ """App factory protocol"""
90
+
91
+ def __init__(
92
+ self,
93
+ algorand: "AlgorandClient",
94
+ **kwargs: Any,
95
+ ) -> None: ...
96
+
97
+ def deploy(
98
+ self,
99
+ *,
100
+ on_update: "OnUpdate | None" = None,
101
+ on_schema_break: "OnSchemaBreak | None" = None,
102
+ create_params: CreateParamsT | None = None,
103
+ update_params: UpdateParamsT | None = None,
104
+ delete_params: DeleteParamsT | None = None,
105
+ existing_deployments: "ApplicationLookup | None" = None,
106
+ ignore_cache: bool = False,
107
+ app_name: str | None = None,
108
+ send_params: "SendParams | None" = None,
109
+ compilation_params: "AppClientCompilationParams | None" = None,
110
+ ) -> tuple[TypedAppClientProtocol, "AppFactoryDeployResult"]: ...
algokit_utils/py.typed ADDED
File without changes