algofi_amm
utils
- class algofi_amm.utils.TransactionGroup(transactions)
Bases:
object
- sign_with_private_key(address, private_key)
Signs the transactions with specified private key and saves to class state
- Parameters
address (string) – account address of the user
private_key (string) – private key of user
- sign_with_private_keys(private_keys, is_logic_sig)
Signs the transactions with specified private key and saves to class state
- Parameters
private_keys (string) – private key of user
is_logic_sig (list) – if given “pkey” is a logicsig
- submit(algod, wait=False)
Submits the signed transactions to network using the algod client
- Parameters
algod (
AlgodClient
) – algod clientwait (boolean, optional) – wait for txn to complete, defaults to False
- Returns
dict of transaction id
- Return type
dict
- algofi_amm.utils.format_state(state)
Returns state dict formatted to human-readable strings :param state: dict of state returned by read_local_state or read_global_state :type state: dict :return: dict of state with keys + values formatted from bytes to utf-8 strings :rtype: dict
- algofi_amm.utils.get_account_balances(indexer_client, address, filter_zero_balances=False)
Returns dictionary of global state for a given application
- Parameters
indexer_client (
IndexerClient
) –IndexerClient
object for interacting with networkaddress (str) – an account address
filter_zero_balances (bool, optional) – include assets with zero balance
- Returns
dictionary of balances for given account
- Return type
dict
- algofi_amm.utils.get_application_global_state(indexer_client, application_id, block=None)
Returns dictionary of global state for a given application
- Parameters
indexer_client (
IndexerClient
) –IndexerClient
object for interacting with networkapplication_id (int) – application id
block (int) – block to query historical state from, optional
- Returns
dictionary of global state for given application
- Return type
dict
- algofi_amm.utils.get_application_local_state(indexer_client, address, application_id, block=None)
Returns dictionary of global state for a given application
- Parameters
indexer_client (
IndexerClient
) –IndexerClient
object for interacting with networkaddress (str) – an account address
application_id (int) – application id
block (int) – block to query historical state from, optional
- Returns
dictionary of local state of account for given application
- Return type
dict
- algofi_amm.utils.get_params(algod_client, fee=1000, flat_fee=True)
Returns dictionary of global state for a given application
- Parameters
algod_client (
AlgodClient
) –AlgodClient
object for interacting with networkfee (int, optional) – fee in microalgos
flat_fee (bool, optional) – whether the specified fee is a flat fee
- Returns
SuggestedParams
object for sending transactions- Return type
SuggestedParams
- algofi_amm.utils.get_payment_txn(params, sender, receiver, amount, asset_id=1)
Returns dictionary of global state for a given application
- Parameters
params (
SuggestedParams
) –SuggestedParams
object for interacting with networksender (str) – sender account address
receiver (str) – receiver account address
amount (int) – amount of asset to send
asset_id (int) – asset id if AssetTransferTxn
- Returns
PaymentTxn
orAssetTransferTxn
object for sending an asset- Return type
PaymentTxn
orAssetTransferTxn
- algofi_amm.utils.int_to_bytes(i)
Convert int to bytes
- algofi_amm.utils.send_and_wait(algod_client, stxns)
Send list of signed transactions and wait for completion
- Parameters
algod_client (
AlgodClient
) – algod clientstxns (list) – list of signed transactions
- Returns
dict of transaction information
- Return type
dict
- algofi_amm.utils.sign_and_submit_transactions(client, transactions, signed_transactions, sender, sender_sk)
- algofi_amm.utils.wait_for_confirmation(client, txid)
Waits for a transaction with id txid to complete. Returns dict with transaction information after completion.
- Parameters
client (
AlgodClient
) – algod clienttxid (string) – id of the sent transaction
- Returns
dict of transaction information
- Return type
dict