algopy_testing.context_helpers.ledger_context
Module Contents
Section titled “Module Contents”Classes
Section titled “Classes”LedgerContext | Context for managing the ledger state. |
|---|
class LedgerContext
Section titled “class LedgerContext”Context for managing the ledger state.
get_account(address: str) → algopy.Account
Section titled “get_account(address: str) → algopy.Account”Get an account by address.
Args: : address (str): The account address.
Returns: : algopy.Account: The account object.
account_is_funded(account: algopy.Account | str) → bool
Section titled “account_is_funded(account: algopy.Account | str) → bool”Check if an account has funds.
Args: : address (str): The account address.
Returns: : bool: True if the account has an algo balance > 0, False otherwise.
update_account(account: algopy.Account | str, **account_fields: Unpack[AccountFields]) → None
Section titled “update_account(account: algopy.Account | str, **account_fields: Unpack[AccountFields]) → None”Update account fields.
Args:
: account: The account.
**account_fields: The fields to update.
update_asset_holdings(asset: algopy.Asset | algopy.UInt64 | int, account: algopy.Account | str, balance: algopy.UInt64 | int | None = None, frozen: bool | None = None) → None
Section titled “update_asset_holdings(asset: algopy.Asset | algopy.UInt64 | int, account: algopy.Account | str, balance: algopy.UInt64 | int | None = None, frozen: bool | None = None) → None”Update asset holdings for account, only specified values will be updated.
Account will also be opted-in to asset
get_asset(asset_id: algopy.UInt64 | int) → algopy.Asset
Section titled “get_asset(asset_id: algopy.UInt64 | int) → algopy.Asset”Get an asset by ID.
Args: : asset_id (algopy.UInt64 | int): The asset ID.
Returns: : algopy.Asset: The asset object.
Raises: : ValueError: If the asset is not found.
asset_exists(asset: algopy.Asset | algopy.UInt64 | int) → bool
Section titled “asset_exists(asset: algopy.Asset | algopy.UInt64 | int) → bool”Check if an asset exists.
Args: : asset_id (algopy.UInt64 | int): The asset ID.
Returns: : bool: True if the asset exists, False otherwise.
update_asset(asset: algopy.Asset | algopy.UInt64 | int, **asset_fields: Unpack[AssetFields]) → None
Section titled “update_asset(asset: algopy.Asset | algopy.UInt64 | int, **asset_fields: Unpack[AssetFields]) → None”Update asset fields.
Args:
: asset_id (int): The asset ID.
**asset_fields: The fields to update.
Raises: : ValueError: If the asset is not found.
get_app(app_id: algopy.Contract | algopy.Application | algopy.UInt64 | int) → algopy.Application
Section titled “get_app(app_id: algopy.Contract | algopy.Application | algopy.UInt64 | int) → algopy.Application”Get an application by ID, contract or app reference.
Args: : int, auto extracts id from contract or app reference.
Returns: : algopy.Application: The application object.
app_exists(app: algopy.Application | algopy.UInt64 | int) → bool
Section titled “app_exists(app: algopy.Application | algopy.UInt64 | int) → bool”Check if an application exists.
Args: : app: The application to check.
Returns: : bool: True if the application exists, False otherwise.
update_app(app: algopy.Application | algopy.UInt64 | int, **application_fields: Unpack[ApplicationFields]) → None
Section titled “update_app(app: algopy.Application | algopy.UInt64 | int, **application_fields: Unpack[ApplicationFields]) → None”Update application fields.
Args:
: app: The application to update.
**application_fields: The fields to update.
get_global_state(app: algopy.Contract | algopy.Application | algopy.UInt64 | int, key: bytes | algopy.Bytes) → int | bytes
Section titled “get_global_state(app: algopy.Contract | algopy.Application | algopy.UInt64 | int, key: bytes | algopy.Bytes) → int | bytes”Get global state for an application.
Args: : app: The application identifier. key: The state key.
Returns: : int | bytes: The state value.
set_global_state(app: algopy.Contract | algopy.Application | algopy.UInt64 | int, key: bytes | algopy.Bytes, value: algopy.Bytes | algopy.UInt64 | int | bytes | None) → None
Section titled “set_global_state(app: algopy.Contract | algopy.Application | algopy.UInt64 | int, key: bytes | algopy.Bytes, value: algopy.Bytes | algopy.UInt64 | int | bytes | None) → None”Set global state for an application.
Args: : app: The application identifier. key: The state key. value: The state value.
get_local_state(app: algopy.Contract | algopy.Application | algopy.UInt64 | int, account: algopy.Account | str, key: algopy.Bytes | bytes) → int | bytes
Section titled “get_local_state(app: algopy.Contract | algopy.Application | algopy.UInt64 | int, account: algopy.Account | str, key: algopy.Bytes | bytes) → int | bytes”Get local state for an application and account.
Args: : app: The application identifier. account: The account identifier. key: The state key.
Returns: : int | bytes: The state value.
set_local_state(app: algopy.Contract | algopy.Application | algopy.UInt64 | int, account: algopy.Account | str, key: algopy.Bytes | bytes, value: algopy.Bytes | algopy.UInt64 | int | bytes | None) → None
Section titled “set_local_state(app: algopy.Contract | algopy.Application | algopy.UInt64 | int, account: algopy.Account | str, key: algopy.Bytes | bytes, value: algopy.Bytes | algopy.UInt64 | int | bytes | None) → None”Set local state for an application and account.
Args: : app: The application identifier. account: The account identifier. key: The state key. value: The state value.
get_box(app: algopy.Contract | algopy.Application | algopy.UInt64 | int, key: algopy.Bytes | bytes) → bytes
Section titled “get_box(app: algopy.Contract | algopy.Application | algopy.UInt64 | int, key: algopy.Bytes | bytes) → bytes”Get box content for an application.
Args: : app: The application identifier. key: The box key.
Returns: : bytes: The box content.
set_box(app: algopy.Contract | algopy.Application | algopy.UInt64 | int, key: algopy.Bytes | bytes, value: algopy.Bytes | bytes) → None
Section titled “set_box(app: algopy.Contract | algopy.Application | algopy.UInt64 | int, key: algopy.Bytes | bytes, value: algopy.Bytes | bytes) → None”Set box content for an application.
Args: : app: The application identifier. key: The box key. value: The box content.
delete_box(app: algopy.Contract | algopy.Application | algopy.UInt64 | int, key: algopy.Bytes | bytes) → bool
Section titled “delete_box(app: algopy.Contract | algopy.Application | algopy.UInt64 | int, key: algopy.Bytes | bytes) → bool”Delete a box for an application.
Args: : app: The application identifier. key: The box key.
Returns: : bool: True if the box was deleted, False if it didn’t exist.
box_exists(app: algopy.Contract | algopy.Application | algopy.UInt64 | int, key: algopy.Bytes | bytes) → bool
Section titled “box_exists(app: algopy.Contract | algopy.Application | algopy.UInt64 | int, key: algopy.Bytes | bytes) → bool”Check if a box exists for an application.
Args: : app: The application identifier. key: The box key.
Returns: : bool: True if the box exists, False otherwise.
set_block(index: int, seed: algopy.UInt64 | int, timestamp: algopy.UInt64 | int, bonus: algopy.UInt64 | int = 0, branch: algopy.Bytes | bytes = b”, fee_sink: algopy.Account | str = ZERO_ADDRESS, fees_collected: algopy.UInt64 | int = 0, proposer: algopy.Account | str = ZERO_ADDRESS, proposer_payout: algopy.UInt64 | int = 0, protocol: algopy.Bytes | bytes = b”, txn_counter: algopy.UInt64 | int = 0) → None
Section titled “set_block(index: int, seed: algopy.UInt64 | int, timestamp: algopy.UInt64 | int, bonus: algopy.UInt64 | int = 0, branch: algopy.Bytes | bytes = b”, fee_sink: algopy.Account | str = ZERO_ADDRESS, fees_collected: algopy.UInt64 | int = 0, proposer: algopy.Account | str = ZERO_ADDRESS, proposer_payout: algopy.UInt64 | int = 0, protocol: algopy.Bytes | bytes = b”, txn_counter: algopy.UInt64 | int = 0) → None”Set block content.
Args: : index (int): The block index. seed (algopy.UInt64 | int): The block seed. timestamp (algopy.UInt64 | int): The block timestamp. bonus (algopy.UInt64 | int): The block bonus. branch (algopy.Bytes | bytes): The block branch. fee_sink (algopy.Account | str): The block fee sink. fees_collected (algopy.UInt64 | int): The fess collected. proposer (algopy.Account | str): The block proposer. proposer_payout (algopy.UInt64 | int): The block proposer payout. protocol (algopy.Bytes | bytes): The block protocol. txn_counter (algopy.UInt64 | int): The block transaction counter.
get_block_content(index: int, key: str) → int | bytes | str
Section titled “get_block_content(index: int, key: str) → int | bytes | str”Get block content.
Args: : index (int): The block index. key (str): The content key.
Returns: : int: The block content value.
Raises: : ValueError: If the block content is not found.
patch_global_fields(**global_fields: Unpack[GlobalFields]) → None
Section titled “patch_global_fields(**global_fields: Unpack[GlobalFields]) → None”Patch global fields.
Args: : ``` **
<br/>global_fields: The fields to patch.
Raises:: ValueError: If invalid fields are provided.
</div>