agora.model package¶
Submodules¶
agora.model.account module¶
-
class
agora.model.account.AccountInfo(account_id, balance=None, owner=None, close_authority=None)[source]¶ Bases:
objectThe information of a Kin account.
- Parameters:
account_id (
PublicKey) – The ID of the account.balance (
Optional[int]) – The balance of the account, in quarks. Included only if account info was requested.owner (
Optional[PublicKey]) – The owner of the account, included only if it is a token account.close_authority (
Optional[PublicKey]) – The close authority of the account, included only if it is a token account.
agora.model.creation module¶
agora.model.earn module¶
-
class
agora.model.earn.Earn(destination, quarks, invoice=None)[source]¶ Bases:
objectThe
Earnobject, which represents an earn payment that will get submitted.
-
class
agora.model.earn.EarnBatch(sender, earns, memo=None, subsidizer=None, dedupe_id=None)[source]¶ Bases:
objectThe
EarnBatchobject, which represents a batch of Earn payments coming from a single sender.- Parameters:
sender (
PrivateKey) – ThePrivateKeyof the sendermemo (
Optional[str]) – (optional) The memo to include in the transaction. If set, none of the invoices included in earns will be applied.subsidizer (
Optional[PrivateKey]) – (optional) The subsidizer to use for the create account transaction. The subsidizer will be used as the payer of the transaction.dedupe_id (
Optional[bytes]) – (optional) The dedupe ID to use for the transaction submission. If included, Agora will verify that no transaction was previously submitted the same dedupe ID before submitting the transaction to the blockchain.
agora.model.invoice module¶
-
class
agora.model.invoice.Invoice(items)[source]¶ Bases:
objectThe :class: Invoice <Invoice> object, which represents a transaction invoice for a single payment.
-
class
agora.model.invoice.InvoiceList(invoices)[source]¶ Bases:
objectThe
InvoiceListobject, which is a list of invoices associated with a transaction.
-
class
agora.model.invoice.LineItem(title, amount, description='', sku=None)[source]¶ Bases:
objectThe
LineItemobject, which represents a line item in an invoice.- Parameters:
title (
str) – The title of the line item.amount (
int) – The amount, in quarks.description (
Optional[str]) – (optional) A description of the line item.sku (
Optional[bytes]) – (optional) A SKU associated with the line item.
agora.model.memo module¶
-
class
agora.model.memo.AgoraMemo(val)[source]¶ Bases:
objectImplements the Agora memo specification as defined in github.com/kinecosystem/agora-api.
- Parameters:
val (
bytearray) – the raw memo bytearray.
-
foreign_key()[source]¶ Returns the foreign key of the memo.
- Return type:
bytes- Returns:
the foreign key
-
classmethod
from_base_memo(m, strict=False)[source]¶ Instantiates and returns an
AgoraMemoobject from aMemo, provided it is a valid (or strictly valid) Agora memo.
-
is_valid()[source]¶ Returns whether or not the memo is valid.
It should be noted that there are no guarantees if the memo is valid, only if the memo is invalid. That is, this function may return false positives.
Stricter validation can be done via
AgoraMemo.is_valid_strict(). However,AgoraMemo.is_valid_strict()is not as forward compatible.- Return type:
bool- Returns:
A bool indicating whether the memo is valid
-
is_valid_strict()[source]¶ Returns whether or not the memo is valid checking against this implementation’s supported version.
It should be noted that there are no guarantees if the memo is valid, only if the memo is invalid. That is, this function may return false positives.
- Return type:
bool- Returns:
A bool indicating whether the memo is strictly valid
-
classmethod
new(version, tx_type, app_index, foreign_key)[source]¶ Returns an Agora memo containing the provided properties.
- Parameters:
version (
int) – The memo encoding versiontx_type (
TransactionType) – TheTransactionTypeof the transactionapp_index (
int) – The index of the app the transaction relates toforeign_key (
bytes) – An identifier in an auxiliary service that contains additional data about what the transaction was for
- Return type:
- Returns:
an
AgoraMemoobject
-
tx_type()[source]¶ Returns the
TransactionTypeof this memo.- Return type:
- Returns:
-
tx_type_raw()[source]¶ Returns the transaction type of the memo, even if is unsupported by this implementation. It should only be used as a fallback if the raw value is needed when
agora.memo.AgoraMemo.transaction_type.py()yields TransactionType.UNKNOWN.- Return type:
int- Returns:
the int value of the memo transaction type
agora.model.payment module¶
-
class
agora.model.payment.Payment(sender, destination, tx_type, quarks, invoice=None, memo=None, subsidizer=None, dedupe_id=None)[source]¶ Bases:
objectThe
Paymentobject, which represents a payment that will get submitted.- Parameters:
sender (
PrivateKey) – ThePrivateKeyof the account from which funds will be sent.destination (
PublicKey) – ThePublicKeyof the account to which funds will be sent.tx_type (
TransactionType) – TheTransactionTypeof this payment.quarks (
int) – The amount being sent.invoice (
Optional[Invoice]) – (optional) AnInvoiceto associate with this payment. Only one of invoice or memo should be set.memo (
Optional[str]) – (optional) The text memo to include with the transaction. Only one of invoice or memo should be set.subsidizer (
Optional[PrivateKey]) – (optional) The subsidizer to use for the create account transaction. The subsidizer will be used as the payer of the transaction.dedupe_id (
Optional[bytes]) – (optional) The dedupe ID to use for the transaction submission. If included, Agora will verify that no transaction was previously submitted the same dedupe ID before submitting the transaction to the blockchain.
-
class
agora.model.payment.ReadOnlyPayment(sender, destination, tx_type, quarks, invoice=None, memo=None)[source]¶ Bases:
objectThe
ReadOnlyPaymentobject, which represents a payment that was retrieved from history.- Parameters:
destination (
PublicKey) – ThePublicKeyof the destination account.tx_type (
TransactionType) – The type of this payment.quarks (
int) – The amount of the payment.invoice (
Optional[Invoice]) – (optional) TheInvoiceassociated with this payment. Only one of invoice or memo will be set.memo (
Optional[str]) – (optional) The text memo associated with this transaction. Only one of invoice or memo will be set.
agora.model.result module¶
-
class
agora.model.result.EarnBatchResult(tx_id, tx_error=None, earn_errors=None)[source]¶ Bases:
objectThe
BatchEarnResultobject, which contains the results of a submitted earn batch.- Parameters:
tx_id (
bytes) – The id of the transaction that was submitted for the earn batch.tx_error (
Optional[Error]) – (optional) An Error indicating why an earn batch failed. If tx_error is defined, the transaction failed.earn_errors (
Optional[List[EarnError]]) – (optional) A List of any available earn-specific error information. May or may not be set if tx_error is set.
agora.model.transaction module¶
-
class
agora.model.transaction.TransactionData(tx_id, transaction_state, payments=None, error=None)[source]¶ Bases:
objectThe
TransactionDataobject, which contains information about the payments in a transaction.- Parameters:
tx_id (
bytes) – Either a 32-byte transaction hash, or a 64-byte transaction signature.payments (
Optional[List[ReadOnlyPayment]]) – (optional) A list ofReadOnlyPaymentobjects.error (
Optional[TransactionErrors]) – (optional)) ATransactionErrorobject that contains extra details about why a transaction failed. If present, it indicates that the transaction failed.
agora.model.transaction_type module¶
agora.model.utils module¶
-
agora.model.utils.parse_transaction(tx, invoice_list=None)[source]¶ Parses payments and creations from a Solana transaction.
- Parameters:
tx (
Transaction) – The transaction.invoice_list (
Optional[InvoiceList]) – (optional) A protobuf invoice list associated with the transaction.
- Return type:
Tuple[List[Creation],List[ReadOnlyPayment]]- Returns:
A Tuple containing a List of
ReadOnlyPaymentobjects and a List ofCreationobjects.
Module contents¶
-
class
agora.model.AccountInfo(account_id, balance=None, owner=None, close_authority=None)[source]¶ Bases:
objectThe information of a Kin account.
- Parameters:
account_id (
PublicKey) – The ID of the account.balance (
Optional[int]) – The balance of the account, in quarks. Included only if account info was requested.owner (
Optional[PublicKey]) – The owner of the account, included only if it is a token account.close_authority (
Optional[PublicKey]) – The close authority of the account, included only if it is a token account.
-
class
agora.model.AgoraMemo(val)[source]¶ Bases:
objectImplements the Agora memo specification as defined in github.com/kinecosystem/agora-api.
- Parameters:
val (
bytearray) – the raw memo bytearray.
-
foreign_key()[source]¶ Returns the foreign key of the memo.
- Return type:
bytes- Returns:
the foreign key
-
classmethod
from_base_memo(m, strict=False)[source]¶ Instantiates and returns an
AgoraMemoobject from aMemo, provided it is a valid (or strictly valid) Agora memo.
-
is_valid()[source]¶ Returns whether or not the memo is valid.
It should be noted that there are no guarantees if the memo is valid, only if the memo is invalid. That is, this function may return false positives.
Stricter validation can be done via
AgoraMemo.is_valid_strict(). However,AgoraMemo.is_valid_strict()is not as forward compatible.- Return type:
bool- Returns:
A bool indicating whether the memo is valid
-
is_valid_strict()[source]¶ Returns whether or not the memo is valid checking against this implementation’s supported version.
It should be noted that there are no guarantees if the memo is valid, only if the memo is invalid. That is, this function may return false positives.
- Return type:
bool- Returns:
A bool indicating whether the memo is strictly valid
-
classmethod
new(version, tx_type, app_index, foreign_key)[source]¶ Returns an Agora memo containing the provided properties.
- Parameters:
version (
int) – The memo encoding versiontx_type (
TransactionType) – TheTransactionTypeof the transactionapp_index (
int) – The index of the app the transaction relates toforeign_key (
bytes) – An identifier in an auxiliary service that contains additional data about what the transaction was for
- Return type:
- Returns:
an
AgoraMemoobject
-
tx_type()[source]¶ Returns the
TransactionTypeof this memo.- Return type:
- Returns:
-
tx_type_raw()[source]¶ Returns the transaction type of the memo, even if is unsupported by this implementation. It should only be used as a fallback if the raw value is needed when
agora.memo.AgoraMemo.transaction_type.py()yields TransactionType.UNKNOWN.- Return type:
int- Returns:
the int value of the memo transaction type
-
class
agora.model.Creation(owner, address)[source]¶ Bases:
objectThe
Creationobject, which represents a token account creation.
-
class
agora.model.Earn(destination, quarks, invoice=None)[source]¶ Bases:
objectThe
Earnobject, which represents an earn payment that will get submitted.
-
class
agora.model.EarnBatch(sender, earns, memo=None, subsidizer=None, dedupe_id=None)[source]¶ Bases:
objectThe
EarnBatchobject, which represents a batch of Earn payments coming from a single sender.- Parameters:
sender (
PrivateKey) – ThePrivateKeyof the sendermemo (
Optional[str]) – (optional) The memo to include in the transaction. If set, none of the invoices included in earns will be applied.subsidizer (
Optional[PrivateKey]) – (optional) The subsidizer to use for the create account transaction. The subsidizer will be used as the payer of the transaction.dedupe_id (
Optional[bytes]) – (optional) The dedupe ID to use for the transaction submission. If included, Agora will verify that no transaction was previously submitted the same dedupe ID before submitting the transaction to the blockchain.
-
class
agora.model.EarnBatchResult(tx_id, tx_error=None, earn_errors=None)[source]¶ Bases:
objectThe
BatchEarnResultobject, which contains the results of a submitted earn batch.- Parameters:
tx_id (
bytes) – The id of the transaction that was submitted for the earn batch.tx_error (
Optional[Error]) – (optional) An Error indicating why an earn batch failed. If tx_error is defined, the transaction failed.earn_errors (
Optional[List[EarnError]]) – (optional) A List of any available earn-specific error information. May or may not be set if tx_error is set.
-
class
agora.model.EarnError(earn_index, error)[source]¶ Bases:
objectThe
EarnErrorobject contains earn-specific details about why a submitted earn batch failed- Parameters:
earn_index (
int) – The index of the earn the error pertains toerror (
Error) – The error
-
class
agora.model.Invoice(items)[source]¶ Bases:
objectThe :class: Invoice <Invoice> object, which represents a transaction invoice for a single payment.
-
class
agora.model.InvoiceList(invoices)[source]¶ Bases:
objectThe
InvoiceListobject, which is a list of invoices associated with a transaction.
-
class
agora.model.LineItem(title, amount, description='', sku=None)[source]¶ Bases:
objectThe
LineItemobject, which represents a line item in an invoice.- Parameters:
title (
str) – The title of the line item.amount (
int) – The amount, in quarks.description (
Optional[str]) – (optional) A description of the line item.sku (
Optional[bytes]) – (optional) A SKU associated with the line item.
-
class
agora.model.Payment(sender, destination, tx_type, quarks, invoice=None, memo=None, subsidizer=None, dedupe_id=None)[source]¶ Bases:
objectThe
Paymentobject, which represents a payment that will get submitted.- Parameters:
sender (
PrivateKey) – ThePrivateKeyof the account from which funds will be sent.destination (
PublicKey) – ThePublicKeyof the account to which funds will be sent.tx_type (
TransactionType) – TheTransactionTypeof this payment.quarks (
int) – The amount being sent.invoice (
Optional[Invoice]) – (optional) AnInvoiceto associate with this payment. Only one of invoice or memo should be set.memo (
Optional[str]) – (optional) The text memo to include with the transaction. Only one of invoice or memo should be set.subsidizer (
Optional[PrivateKey]) – (optional) The subsidizer to use for the create account transaction. The subsidizer will be used as the payer of the transaction.dedupe_id (
Optional[bytes]) – (optional) The dedupe ID to use for the transaction submission. If included, Agora will verify that no transaction was previously submitted the same dedupe ID before submitting the transaction to the blockchain.
-
class
agora.model.ReadOnlyPayment(sender, destination, tx_type, quarks, invoice=None, memo=None)[source]¶ Bases:
objectThe
ReadOnlyPaymentobject, which represents a payment that was retrieved from history.- Parameters:
destination (
PublicKey) – ThePublicKeyof the destination account.tx_type (
TransactionType) – The type of this payment.quarks (
int) – The amount of the payment.invoice (
Optional[Invoice]) – (optional) TheInvoiceassociated with this payment. Only one of invoice or memo will be set.memo (
Optional[str]) – (optional) The text memo associated with this transaction. Only one of invoice or memo will be set.
-
class
agora.model.TransactionData(tx_id, transaction_state, payments=None, error=None)[source]¶ Bases:
objectThe
TransactionDataobject, which contains information about the payments in a transaction.- Parameters:
tx_id (
bytes) – Either a 32-byte transaction hash, or a 64-byte transaction signature.payments (
Optional[List[ReadOnlyPayment]]) – (optional) A list ofReadOnlyPaymentobjects.error (
Optional[TransactionErrors]) – (optional)) ATransactionErrorobject that contains extra details about why a transaction failed. If present, it indicates that the transaction failed.
-
class
agora.model.TransactionState(value)[source]¶ Bases:
enum.IntEnumAn enumeration.
-
FAILED= 2¶
-
PENDING= 3¶
-
SUCCESS= 1¶
-
UNKNOWN= 0¶
-
-
class
agora.model.TransactionType(value)[source]¶ Bases:
enum.IntEnumThe type of a transaction.
-
EARN= 1¶
-
NONE= 0¶
-
P2P= 3¶
-
SPEND= 2¶
-
UNKNOWN= -1¶
-
-
agora.model.parse_transaction(tx, invoice_list=None)[source]¶ Parses payments and creations from a Solana transaction.
- Parameters:
tx (
Transaction) – The transaction.invoice_list (
Optional[InvoiceList]) – (optional) A protobuf invoice list associated with the transaction.
- Return type:
Tuple[List[Creation],List[ReadOnlyPayment]]- Returns:
A Tuple containing a List of
ReadOnlyPaymentobjects and a List ofCreationobjects.