Skip to content

Commit

Permalink
fix: expose algosdk lsig, multisig object instances in account wrappe…
Browse files Browse the repository at this point in the history
…rs (#138)

* fix: expose algosdk lsig, multisig object instances in account wrappers

* ci: fix poetry export for poetry v2

* fix: assume default schema values if not provided during appCreate call

* refactor: further simplify internal LogicSigAccount implementation
  • Loading branch information
aorumbayev authored Feb 12, 2025
1 parent 7a2559f commit 24b2d19
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 50 deletions.
2 changes: 2 additions & 0 deletions .github/actions/setup-poetry/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ runs:
- if: ${{ runner.os == 'macOS' && runner.arch == 'ARM64' }}
run: |
pip install poetry
pip install poetry-plugin-export
shell: bash

# NOTE: Below commands currently causes a faulty behaviour in pipx where
Expand All @@ -24,6 +25,7 @@ runs:
- if: ${{ runner.os != 'macOS' || runner.arch != 'ARM64' }}
run: |
pipx install poetry ${{ runner.os == 'macOS' && '--python "$Python_ROOT_DIR/bin/python"' || '' }}
pipx inject poetry poetry-plugin-export
shell: bash

- name: Get full Python version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ Tracks and returns an Algorand account with private key loaded from the given KM
... )
```

#### logicsig(program: bytes, args: list[bytes] | None = None) → algokit_utils.models.account.LogicSigAccount
#### logicsig(program: bytes, args: list[bytes] | None = None) → [algokit_utils.models.account.LogicSigAccount](../../models/account/index.md#algokit_utils.models.account.LogicSigAccount)

Tracks and returns an account that represents a logic signature.

Expand Down
40 changes: 40 additions & 0 deletions docs/markdown/autoapi/algokit_utils/models/account/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
| [`SigningAccount`](#algokit_utils.models.account.SigningAccount) | Holds the private key and address for an account. |
| [`MultisigMetadata`](#algokit_utils.models.account.MultisigMetadata) | Metadata for a multisig account. |
| [`MultiSigAccount`](#algokit_utils.models.account.MultiSigAccount) | Account wrapper that supports partial or full multisig signing. |
| [`LogicSigAccount`](#algokit_utils.models.account.LogicSigAccount) | Account wrapper that supports logic sig signing. |

## Module Contents

Expand Down Expand Up @@ -82,6 +83,13 @@ Provides functionality to manage and sign transactions for a multisig account.
* **multisig_params** – The parameters for the multisig account
* **signing_accounts** – The list of accounts that can sign

#### *property* multisig *: algosdk.transaction.Multisig*

Get the underlying algosdk.transaction.Multisig object instance.

* **Returns:**
The algosdk.transaction.Multisig object instance

#### *property* params *: [MultisigMetadata](#algokit_utils.models.account.MultisigMetadata)*

Get the parameters for the multisig account.
Expand Down Expand Up @@ -118,3 +126,35 @@ Sign the given transaction with all present signers.
**transaction** – Either a transaction object or a raw, partially signed transaction
* **Returns:**
The transaction signed by the present signers

### *class* algokit_utils.models.account.LogicSigAccount(program: bytes, args: list[bytes] | None)

Account wrapper that supports logic sig signing.

Provides functionality to manage and sign transactions for a logic sig account.

#### *property* lsig *: algosdk.transaction.LogicSigAccount*

Get the underlying algosdk.transaction.LogicSigAccount object instance.

* **Returns:**
The algosdk.transaction.LogicSigAccount object instance

#### *property* address *: str*

Get the address of the logic sig account.

If the LogicSig is delegated to another account, this will return the address of that account.

If the LogicSig is not delegated to another account, this will return an escrow address that is the hash of
the LogicSig’s program code.

* **Returns:**
The logic sig account address

#### *property* signer *: algosdk.atomic_transaction_composer.LogicSigTransactionSigner*

Get the transaction signer for this multisig account.

* **Returns:**
The multisig transaction signer
6 changes: 3 additions & 3 deletions docs/markdown/capabilities/account.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The following conform to `TransactionSignerAccountProtocol`:

- [`TransactionSignerAccount`](../autoapi/algokit_utils/models/account/index.md#algokit_utils.models.account.TransactionSignerAccount) - a basic transaction signer account that holds an address and a signer conforming to `TransactionSignerAccountProtocol`
- [`SigningAccount`](../autoapi/algokit_utils/models/account/index.md#algokit_utils.models.account.SigningAccount) - an abstraction that used to be available under `Account` in previous versions of AlgoKit Utils. Renamed for consistency with equivalent `ts` version. Holds private key and conforms to `TransactionSignerAccountProtocol`
- `LogicSigAccount` - a wrapper class around `algosdk` logicsig abstractions conforming to `TransactionSignerAccountProtocol`
- [`LogicSigAccount`](../autoapi/algokit_utils/models/account/index.md#algokit_utils.models.account.LogicSigAccount) - a wrapper class around `algosdk` logicsig abstractions conforming to `TransactionSignerAccountProtocol`
- `MultisigAccount` - a wrapper class around `algosdk` multisig abstractions conforming to `TransactionSignerAccountProtocol`

## Registering a signer
Expand Down Expand Up @@ -89,8 +89,8 @@ While `TransactionSignerAccount` is the main class used to represent an account

- [`TransactionSignerAccount`](../autoapi/algokit_utils/models/account/index.md#algokit_utils.models.account.TransactionSignerAccount) - A default class conforming to `TransactionSignerAccountProtocol` that holds an address and a signer
- [`SigningAccount`](../autoapi/algokit_utils/models/account/index.md#algokit_utils.models.account.SigningAccount) - An abstraction around `algosdk.Account` that supports rekeyed accounts
- `LogicSigAccount` - An in-built algosdk `algosdk.LogicSigAccount` object
- `MultisigAccount` - An abstraction around `algosdk.MultisigMetadata`, `algosdk.makeMultiSigAccountTransactionSigner`, `algosdk.multisigAddress`, `algosdk.signMultisigTransaction` and `algosdk.appendSignMultisigTransaction` that supports multisig accounts with one or more signers present
- [`LogicSigAccount`](../autoapi/algokit_utils/models/account/index.md#algokit_utils.models.account.LogicSigAccount) - An abstraction around `algosdk.LogicSigAccount` and `algosdk.LogicSig` that supports logic sig signing. Exposes access to the underlying algosdk `algosdk.transaction.LogicSigAccount` object instance via `lsig` property.
- `MultisigAccount` - An abstraction around `algosdk.MultisigMetadata`, `algosdk.makeMultiSigAccountTransactionSigner`, `algosdk.multisigAddress`, `algosdk.signMultisigTransaction` and `algosdk.appendSignMultisigTransaction` that supports multisig accounts with one or more signers present. Exposes access to the underlying algosdk `algosdk.transaction.Multisig` object instance via `multisig` property.

### Dispenser

Expand Down
4 changes: 2 additions & 2 deletions docs/source/capabilities/account.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ While `TransactionSignerAccount` is the main class used to represent an account

- {py:obj}`TransactionSignerAccount <algokit_utils.models.account.TransactionSignerAccount>` - A default class conforming to `TransactionSignerAccountProtocol` that holds an address and a signer
- {py:obj}`SigningAccount <algokit_utils.models.account.SigningAccount>` - An abstraction around `algosdk.Account` that supports rekeyed accounts
- {py:obj}`LogicSigAccount <algokit_utils.models.account.LogicSigAccount>` - An in-built algosdk `algosdk.LogicSigAccount` object
- {py:obj}`MultisigAccount <algokit_utils.models.account.MultisigAccount>` - An abstraction around `algosdk.MultisigMetadata`, `algosdk.makeMultiSigAccountTransactionSigner`, `algosdk.multisigAddress`, `algosdk.signMultisigTransaction` and `algosdk.appendSignMultisigTransaction` that supports multisig accounts with one or more signers present
- {py:obj}`LogicSigAccount <algokit_utils.models.account.LogicSigAccount>` - An abstraction around `algosdk.LogicSigAccount` and `algosdk.LogicSig` that supports logic sig signing. Exposes access to the underlying algosdk `algosdk.transaction.LogicSigAccount` object instance via `lsig` property.
- {py:obj}`MultisigAccount <algokit_utils.models.account.MultisigAccount>` - An abstraction around `algosdk.MultisigMetadata`, `algosdk.makeMultiSigAccountTransactionSigner`, `algosdk.multisigAddress`, `algosdk.signMultisigTransaction` and `algosdk.appendSignMultisigTransaction` that supports multisig accounts with one or more signers present. Exposes access to the underlying algosdk `algosdk.transaction.Multisig` object instance via `multisig` property.

### Dispenser

Expand Down
62 changes: 33 additions & 29 deletions poetry.lock

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

3 changes: 1 addition & 2 deletions src/algokit_utils/accounts/account_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from algosdk import mnemonic
from algosdk.atomic_transaction_composer import TransactionSigner
from algosdk.mnemonic import to_private_key
from algosdk.transaction import LogicSigAccount as AlgosdkLogicSigAccount
from algosdk.transaction import SuggestedParams
from typing_extensions import Self

Expand Down Expand Up @@ -313,7 +312,7 @@ def _register_logicsig(self, program: bytes, args: list[bytes] | None = None) ->
:param args: The (binary) arguments to pass into the logic signature
:returns: The registered AlgosdkLogicSigAccount instance
"""
logic_sig = LogicSigAccount(AlgosdkLogicSigAccount(program, args))
logic_sig = LogicSigAccount(program, args)
self._accounts[logic_sig.address] = logic_sig
return logic_sig

Expand Down
Loading

1 comment on commit 24b2d19

@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
   _debugging.py1411887%21, 40–42, 45, 54, 62, 81, 87, 96, 110–114, 133, 141–143
   account.py330%1–12
   algorand.py981585%62–63, 74–75, 95–96, 108–110, 119–120, 214, 234, 247, 263
   application_client.py330%1–11
   application_specification.py770%1–39
   config.py782173%23, 30–34, 73–74, 90, 95, 100, 111–116, 141, 144–146, 149, 151
   deploy.py330%1–10
   logic_error.py330%1–10
src/algokit_utils/_legacy_v2
   _ensure_funded.py71199%100
   _transfer.py70396%14, 75–76
   account.py931386%15–18, 70–74, 109, 126, 156, 159, 203
   application_client.py5377786%56–57, 176, 181, 210, 322, 327–328, 330, 332, 801, 816, 834–837, 931, 971, 983, 996, 1038, 1098–1104, 1108–1113, 1115, 1151, 1158, 1271, 1307, 1321, 1359–1361, 1363, 1373–1430, 1441–1446, 1466–1469
   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%77–78, 101–102, 135
src/algokit_utils/accounts
   account_manager.py2123384%161, 180–181, 205–210, 228–229, 246, 263–268, 315–317, 346, 385, 405–409, 422, 481, 502, 659, 765, 844, 849, 868–869, 892
   kmd_account_manager.py741086%49–55, 96, 152, 159
src/algokit_utils/applications
   abi.py1327146%14, 77, 113, 119, 121, 123, 127–128, 143–162, 178, 181–187, 203–216, 229–241, 256–267
   app_client.py70221470%66–74, 133, 141, 335–338, 341, 344, 347, 350, 362–365, 368, 371, 374, 377, 389, 398, 407, 410–477, 490–548, 572–574, 591–594, 602–605, 613–616, 624–627, 635–638, 649–652, 665, 761–764, 798, 810, 822, 834, 846, 861, 876, 886, 896, 906, 916, 926, 963–976, 992, 1009, 1026, 1043, 1064, 1085, 1175, 1343, 1390–1391, 1422, 1424, 1430, 1475–1483, 1516–1519, 1522–1525, 1546, 1594, 1657–1659, 1672–1679, 1720, 1737, 1739, 1742, 1746, 1873, 1884–1885, 1908, 1918–1920, 1923–1945, 1955, 1964–1979, 1984–1989
   app_deployer.py2143584%98, 196, 203, 213–218, 221–225, 297–298, 507, 516–519, 532, 537, 543, 552–557, 564, 578, 589–630
   app_factory.py2662790%351, 361, 364, 508, 516, 528, 677, 691–696, 702–703, 721, 746, 757–758, 794, 802–816
   app_manager.py2181693%226, 285–286, 318–323, 349, 367–368, 398, 419–422, 445, 454
src/algokit_utils/applications/app_spec
   arc32.py95892%198–207
   arc56.py4703692%72–74, 183, 318, 336–337, 415, 437–439, 495, 504, 506, 574, 769, 779, 783, 943, 945, 978–989, 1002, 1004–1005, 1021
src/algokit_utils/assets
   asset_manager.py1061289%266–267, 276, 282–306, 316
src/algokit_utils/clients
   client_manager.py1735469%24–26, 74–81, 95, 127–129, 185, 196–199, 224, 263, 298–303, 338–340, 373, 390, 412, 446–449, 482–485, 519–522, 552–555, 573–598, 628, 637, 645
   dispenser_api_client.py841286%129–130, 134–137, 172–174, 193–195
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.py42198%8
   state.py36586%51, 55–58
   transaction.py51394%66, 86, 91
src/algokit_utils/protocols
   account.py11282%17, 22
   typed_clients.py24483%12–24
src/algokit_utils/transactions
   transaction_composer.py95412887%34–41, 622, 625, 630, 634–645, 677, 718, 785, 792, 814, 847, 910–973, 1002, 1020–1022, 1028–1043, 1048, 1056, 1058, 1060, 1076, 1082, 1117–1124, 1127–1134, 1145, 1239, 1289, 1538–1539, 1578–1579, 1620, 1831, 1834, 1853, 1858, 1882–1884, 1921–1957, 1964–1971, 2112, 2116, 2247, 2249–2250, 2300–2301
   transaction_creator.py75791%116, 121, 126, 131, 136, 141, 156
   transaction_sender.py1481093%88, 243, 286–287, 431–436, 441–442, 487
TOTAL624993085% 

Tests Skipped Failures Errors Time
401 0 💤 0 ❌ 0 🔥 3m 1s ⏱️

Please sign in to comment.