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

Merged
merged 28 commits into from
Jun 6, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
32432d9
chore: installing local python ffi package
CiottiGiorgio May 13, 2025
f15e32e
feat: using AlgoKit Core to build a payment transaction
CiottiGiorgio May 14, 2025
2700fbc
chore: addressed review comment on bridge core module visibility
CiottiGiorgio May 16, 2025
33a53ee
Merge branch 'main' into feat/algokit-core-payment
CiottiGiorgio May 16, 2025
064c069
chore: adding locally built algod client
CiottiGiorgio May 16, 2025
13e06d4
chore: rename payment_through_core -> build_payment_with_core
CiottiGiorgio May 19, 2025
5be8767
fix: keep the user min fee if set
CiottiGiorgio May 19, 2025
ae54d01
chore: update algod client
CiottiGiorgio May 19, 2025
0362cf9
chore: use algokit core from GH releases
CiottiGiorgio May 20, 2025
7dc168a
chore: use algod generated client from local filesystem because of a …
CiottiGiorgio May 20, 2025
40c674b
feat: using AlgodApi OpenAPI generated client to send transactions to…
CiottiGiorgio May 20, 2025
efac078
chore: adding the released version of python algokit algod client
CiottiGiorgio May 22, 2025
2ec3993
fix: introducing tagged releases for the integration with algokit-core
CiottiGiorgio May 27, 2025
89b9d89
chore: using the locally built version for now while we wait for CICD…
CiottiGiorgio May 28, 2025
b7b0f00
chore: using algolkit algod client from a package repo
CiottiGiorgio May 29, 2025
9c47442
wip: optional deps group as feature flag & adherence to new client's …
CiottiGiorgio May 29, 2025
67940f4
fix: correctly re-throw the exception
CiottiGiorgio May 29, 2025
b054765
chore: format
CiottiGiorgio May 29, 2025
73b97b0
chore: excluding experimental group form CI/CD
CiottiGiorgio May 29, 2025
481f712
chore: poetry update setuptools
CiottiGiorgio May 29, 2025
24c2a25
chore: ignore untyped stuff that replicates algosdk
CiottiGiorgio May 29, 2025
cb19b84
chore: removing redundant exception check
CiottiGiorgio May 29, 2025
eb82ba9
chore: poetry run format
CiottiGiorgio May 29, 2025
d64633d
chore: fix mypy and linting issues
CiottiGiorgio May 29, 2025
1f57a16
chore: remove redundant docstring
CiottiGiorgio May 29, 2025
add1bde
chore: allow the test to accept more than one log in case we are usin…
CiottiGiorgio May 30, 2025
c87d458
chore: updated to lates algokit core deps
lempira Jun 5, 2025
231395a
feat: calculated fee using assign_fee from core
lempira Jun 5, 2025
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
24 changes: 21 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ python = "^3.10"
py-algorand-sdk = "^2.4.0"
httpx = ">=0.23.1,<=0.28.1"
typing-extensions = ">=4.6.0"
algokit-transact = {path = "../../RustroverProjects/algokit-core/target/wheels/algokit_transact-0.1.0-py3-none-manylinux_2_34_x86_64.whl"}

[tool.poetry.group.dev.dependencies]
pytest = "^8"
Expand Down
46 changes: 46 additions & 0 deletions src/algokit_utils/transactions/algokit_core_bridge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import base64

import algokit_transact
import algosdk.transaction


def payment_through_core(
sender,
sp,
receiver,
amt,
close_remainder_to=None,
note=None,
lease=None,
rekey_to=None,
) -> algosdk.transaction.PaymentTxn:
txn = algokit_transact.Transaction(
transaction_type=algokit_transact.TransactionType.PAYMENT,
sender=algokit_transact.address_from_string(sender),
# The correct fee will be calculated later based on suggested params and estimated size of the transaction.
fee=sp.fee,
first_valid=sp.first,
last_valid=sp.last,
genesis_hash=base64.b64decode(sp.gh),
genesis_id=sp.gen,
note=note,
lease=lease,
rekey_to=algokit_transact.address_from_string(rekey_to) if rekey_to else None,
payment=algokit_transact.PaymentTransactionFields(
receiver=algokit_transact.address_from_string(receiver),
amount=amt,
close_remainder_to=algokit_transact.address_from_string(close_remainder_to) if close_remainder_to else None,
),
)

size = algokit_transact.estimate_transaction_size(txn)
final_fee: int
if sp.flat_fee:
final_fee = sp.fee
else:
final_fee = max(algosdk.constants.MIN_TXN_FEE, sp.flat_fee * size)
txn.fee = final_fee

return algosdk.encoding.msgpack_decode(
base64.b64encode(algokit_transact.encode_transaction_raw(txn)).decode("utf-8")
)
3 changes: 2 additions & 1 deletion src/algokit_utils/transactions/transaction_composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from algokit_utils.models.state import BoxIdentifier, BoxReference
from algokit_utils.models.transaction import SendParams, TransactionWrapper
from algokit_utils.protocols.account import TransactionSignerAccountProtocol
from algokit_utils.transactions.algokit_core_bridge import payment_through_core

if TYPE_CHECKING:
from collections.abc import Callable
Expand Down Expand Up @@ -2251,7 +2252,7 @@ def _build_payment(
"close_remainder_to": params.close_remainder_to,
}

return self._common_txn_build_step(lambda x: algosdk.transaction.PaymentTxn(**x), params, txn_params)
return self._common_txn_build_step(lambda x: payment_through_core(**x), params, txn_params)

def _build_asset_create(
self, params: AssetCreateParams, suggested_params: algosdk.transaction.SuggestedParams
Expand Down