Skip to content
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

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

Merged
merged 4 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading