Skip to content

feat: send payment transaction with algokit core #159

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

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

CiottiGiorgio
Copy link
Member

(draft) PR to use AlgoKit Core when dealing with a Payment transaction in utils.

Companion PR of algorandfoundation/algokit-utils-ts#393

@CiottiGiorgio
Copy link
Member Author

At this point, the local AlgoKit Core this is using is from algorandfoundation/algokit-core#81

@CiottiGiorgio CiottiGiorgio changed the title WIP: Send and wait payment transaction with algokit core Send payment transaction with algokit core May 15, 2025
Copy link
Contributor

@aorumbayev aorumbayev left a comment

Choose a reason for hiding this comment

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

some minor comments, would also be keen to see how it behaves in CI, would be interesting to compare execution time for tests on version with and without these changes. I think you need to patch merge conflict first to have workflows executed

@CiottiGiorgio CiottiGiorgio changed the title Send payment transaction with algokit core feat: send payment transaction with algokit core May 16, 2025
@CiottiGiorgio
Copy link
Member Author

At this point, I have added the ability for utils to send all transactions through the generated API client. I had initially aimed for just payments but I got carried away and did it for everything.
Also, the header update is a dirty trick for now while I understand how to use the api key correctly.

@aorumbayev
Copy link
Contributor

aorumbayev commented May 22, 2025

@CiottiGiorgio i noticed tests are failing in resource packing suite. The root cause is due to the fact that now calls are done via our oas client, while it throws similar errors from algod its a different exception, you'd need to adjust error handling in logic_error.py, to ensure regex searches over entire error string

    match = re.search(LOGIC_ERROR, error_str, re.DOTALL) # add re.DOTALL, and change re.match to re.search

and the exception handlers would also need to catch the error class from new oas client

under transaction_composer.py's send method

  except algosdk.error.AlgodHTTPError as e:
            raise Exception(f"Transaction failed: {e}") from e

should handle the algokit_algod_api.exceptions.BadRequestException as well

@aorumbayev
Copy link
Contributor

@CiottiGiorgio looks like you need to do poetry update setuptools to fix pip audit step. The non pypi package might need to be excluded explicitly as well (if you run it locally you can confirm if its a warning or treated as an error as well)

@CiottiGiorgio CiottiGiorgio force-pushed the feat/algokit-core-payment branch from b3d7b99 to 481f712 Compare May 29, 2025 11:30
import algosdk.transaction


def build_payment_with_core(
Copy link
Contributor

@neilcampbell neilcampbell May 29, 2025

Choose a reason for hiding this comment

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

This logic has been updated in utils-ts to also perform fee calculations via algokit-transact. See algorandfoundation/algokit-utils-ts#407

Copy link
Contributor

Choose a reason for hiding this comment

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

Updated to use assign_fee from ak-core

…g core algod client even though at this point tests are only using the non-experimental version of this package
@CiottiGiorgio
Copy link
Member Author

CiottiGiorgio commented May 30, 2025

At this point I think this PR is mostly good to go minus:

  • fee estimation should be done with core
  • more care in evaluating whether the core can send all transactions instead of just payments
  • the failing tests are due to the latest localnet where the node returns something different wrt boxes

I'll point out that I've explicitly told poetry to test the non-experimental version of this package in CI/CD and that I've also silenced a lot of mypy/ruff errors in the bridge code relating to how the signatures are untyped (since algosdk signatures are also untyped, I thought this was ok).
The experimental version on this package still passes the same tests that the non-experimental version passes (minus the ones that are at the moment related to the new algod box API).

Copy link

github-actions bot commented Jun 2, 2025

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/algokit_utils
   _debugging.py1411887%21, 40–42, 45, 54, 62, 81, 87, 96, 110–114, 133, 141–143
   account.py330%1–12
   algorand.py981585%64–65, 79–80, 110–111, 125–127, 138–139, 299, 322, 338, 357
   application_client.py330%1–11
   application_specification.py770%1–39
   config.py782963%23, 30–34, 73–74, 90, 95, 100, 111–116, 140–156
   deploy.py330%1–10
   logic_error.py330%1–10
src/algokit_utils/_legacy_v2
   _ensure_funded.py72199%96
   _transfer.py72396%14, 77–78
   account.py931386%15–18, 71–75, 109, 126, 156, 159, 203
   application_client.py5377786%56–57, 176, 181, 210, 320, 325–326, 328, 330, 799, 814, 832–835, 929, 969, 981, 994, 1036, 1096–1102, 1106–1111, 1113, 1149, 1156, 1269, 1305, 1319, 1357–1359, 1361, 1371–1428, 1439–1444, 1464–1467
   asset.py80495%24–27
   common.py13192%13
   deploy.py4072295%32–35, 170, 174–175, 193, 249, 339–340, 361, 395, 406–414, 429, 437, 593–594, 618
   network_clients.py73593%79–80, 105–106, 139
src/algokit_utils/accounts
   account_manager.py2554084%167, 183–184, 211–216, 295–305, 322, 339–344, 391–393, 422, 461, 481–485, 498, 557, 578, 735, 841, 920, 925, 940–941, 964
   kmd_account_manager.py731086%47–53, 94, 150, 157
src/algokit_utils/applications
   abi.py1397149%14, 75, 111, 117, 119, 121, 125–126, 141–160, 176, 179–185, 201–214, 227–239, 254–265
   app_client.py74221471%66–74, 133, 141, 328–331, 334, 337, 340, 343, 355–358, 361, 364, 367, 370, 382, 391, 400, 403–470, 483–541, 565–567, 584–587, 595–598, 606–609, 617–620, 628–631, 642–645, 658, 754–757, 791, 803, 815, 827, 839, 854, 869, 879, 889, 899, 909, 919, 956–969, 985, 1002, 1019, 1036, 1057, 1078, 1168, 1364, 1428–1429, 1478, 1480, 1486, 1539–1547, 1580–1583, 1586–1589, 1610, 1658, 1721–1723, 1736–1743, 1788, 1805, 1807, 1810, 1814, 1961, 1972–1973, 2001, 2011–2013, 2016–2038, 2048, 2057–2072, 2077–2082
   app_deployer.py2373784%96, 270, 277, 287–292, 295–299, 375–376, 587, 599–613, 625, 630–633, 642, 656, 663, 670, 699, 710–751
   app_factory.py2712790%430, 451, 460, 652, 662, 712, 944, 958–963, 974–975, 1008, 1046, 1064–1065, 1108, 1116–1129
   app_manager.py2231892%258, 279–280, 350–351, 396–401, 433, 457–458, 488, 516–519, 551, 560
src/algokit_utils/applications/app_spec
   arc32.py95892%198–207
   arc56.py5783294%71, 171, 292, 308–309, 379, 399–401, 453, 462, 464, 736, 750, 909, 911, 944–955, 968, 970–971, 987
src/algokit_utils/assets
   asset_manager.py1281291%282–283, 292, 298–322, 332
src/algokit_utils/clients
   _algokit_core_bridge.py21195%11
   client_manager.py1825570%25–27, 80–87, 112, 124, 149–151, 211, 222–225, 250, 289, 324–329, 364–366, 399, 416, 438, 483–486, 526–529, 570–573, 610–613, 635–660, 698, 711, 723
   dispenser_api_client.py961288%134–135, 139–142, 198–200, 219–221
src/algokit_utils/errors
   logic_error.py561180%14, 105–121
src/algokit_utils/models
   account.py921584%32, 34, 80–81, 128, 136, 144, 168–175, 188, 196, 209, 217
   amount.py1061784%35, 42, 88, 98, 104, 112, 117–119, 126, 131–133, 140, 147, 160, 166
   application.py66198%8
   state.py41588%61, 65–68
   transaction.py51394%66, 86, 91
src/algokit_utils/protocols
   account.py11282%17, 22
   typed_clients.py24483%12–24
src/algokit_utils/transactions
   _algokit_core_bridge.py16194%32
   transaction_composer.py111511390%38–45, 578, 623, 626, 631, 635–646, 678, 719, 786, 793, 815, 854, 951–980, 1009, 1027–1029, 1035–1050, 1055, 1063, 1065, 1067, 1083, 1089, 1127, 1135, 1148, 1244, 1294, 1743–1744, 1783–1784, 1825, 1867, 1878, 2048, 2051, 2070, 2075, 2099–2101, 2138–2174, 2181–2188, 2271, 2332, 2336, 2467, 2469–2470, 2520–2521
   transaction_creator.py75791%394, 427, 482, 520, 557, 590, 688
   transaction_sender.py1611094%99, 268, 311–312, 710–715, 720–721, 886
TOTAL676793386% 

Tests Skipped Failures Errors Time
405 0 💤 0 ❌ 0 🔥 4m 1s ⏱️

@CiottiGiorgio
Copy link
Member Author

Algod recently rolled back the changes on the box api, thereby restoring the tests involved with it. Still missing the changes related to fee estimation done on core.

@aorumbayev
Copy link
Contributor

@CiottiGiorgio i think a good final smoke test would be to pick a few algokit repos relying of utils like subscriber py (i think it leverages it mostly in unit tests), generator py, algokit cli and run their test suites with the new wheel

@lempira
Copy link
Contributor

lempira commented Jun 5, 2025

@CiottiGiorgio I think a good final smoke test would be to pick a few algokit repos relying on utils like subscriber py (I think it leverages it mostly in unit tests), generator py, algokit cli, and run their test suites with the new wheel

@aorumbayev, I checked subscriber, client-gen, and algokit-cli test using the new whl and they all passed.

@lempira lempira marked this pull request as ready for review June 6, 2025 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants