agora package¶
Subpackages¶
- agora.cache package
- agora.client package
- agora.model package
- Submodules
- agora.model.account module
- agora.model.creation module
- agora.model.earn module
- agora.model.invoice module
- agora.model.memo module
- agora.model.payment module
- agora.model.result module
- agora.model.transaction module
- agora.model.transaction_type module
- agora.model.utils module
- Module contents
- agora.retry package
- agora.solana package
- agora.webhook package
Submodules¶
agora.error module¶
-
exception
agora.error.AccountExistsError(message='')[source]¶ Bases:
agora.error.ErrorRaised when trying to create an account that already exists.
-
exception
agora.error.AccountNotFoundError(message='', tx_id=None)[source]¶ Bases:
agora.error.TransactionErrorRaised when an account could not be found.
-
exception
agora.error.AlreadyPaidError(message='')[source]¶ Bases:
agora.error.ErrorRaised when an invoice has already been paid.
-
exception
agora.error.AlreadySubmittedError(message='', tx_id=None)[source]¶ Bases:
agora.error.TransactionErrorIndicates that the transaction was already submitted.
If the client is retrying a submission due to a transient failure, then this can occur if the submission in a previous attempt was successful. Otherwise, it may indicate that the transaction is indistinguishable from a previous transaction (i.e. same block hash, sender, dest, and amount), and the client should use a different recent blockhash and try again.
-
exception
agora.error.BadNonceError(message='', tx_id=None)[source]¶ Bases:
agora.error.TransactionErrorRaised when a transaction contains an invalid nonce.
-
exception
agora.error.BlockchainVersionError(message='')[source]¶ Bases:
agora.error.ErrorRaised when Agora indicates that the current blockchain version is not supported.
-
exception
agora.error.InsufficientBalanceError(message='', tx_id=None)[source]¶ Bases:
agora.error.TransactionErrorRaised when an account has an insufficient balance for a submitted transaction.
-
exception
agora.error.InvalidSignatureError(message='', tx_id=None)[source]¶ Bases:
agora.error.TransactionErrorRaised when the submitted transaction is either missing signatures or contains unused ones.
-
exception
agora.error.InvoiceError(errors, *args, **kwargs)[source]¶ Bases:
agora.error.ErrorRaised when there was an issue with a provided invoice.
-
class
agora.error.InvoiceErrorReason(value)[source]¶ Bases:
enum.IntEnumAn enumeration.
-
ALREADY_PAID= 1¶
-
SKU_NOT_FOUND= 3¶
-
UNKNOWN= 0¶
-
WRONG_DESTINATION= 2¶
-
-
exception
agora.error.NoSubsidizerError(message='')[source]¶ Bases:
agora.error.ErrorRaised when no subsidizer was provided for a transaction. This occurs if no subsidizer was made available by the Agora service and none was provided by the method caller.
-
exception
agora.error.NoTokenAccountsError(message='')[source]¶ Bases:
agora.error.ErrorIndicates that no token accounts were resolved for the requested account ID.
-
exception
agora.error.OperationInvoiceError(op_index, reason)[source]¶ Bases:
agora.error.Error
-
exception
agora.error.PayerRequiredError(message='')[source]¶ Bases:
agora.error.ErrorRaised when a transaction is missing a signature from its funder. This can occur if the service does not have a subsidizer configured, or if it refuses to subsidize this specific transaction. The latter case can occur during rate limiting situations. In this case, the client may either try at a later time, or attempt to fund the transaction using a different account.
-
exception
agora.error.SkuNotFoundError(message='')[source]¶ Bases:
agora.error.ErrorRaised when an invoice contains a SKU that could not be found.
-
exception
agora.error.TransactionError(message='', tx_id=None)[source]¶ Bases:
agora.error.ErrorBase error for transaction submission errors.
- Parameters:
tx_id (
Optional[bytes]) – The id of the transaction, if available.
-
class
agora.error.TransactionErrors(tx_error=None, op_errors=None, payment_errors=None)[source]¶ Bases:
objectContains the details of a failed transaction.
- Parameters:
tx_error (
Optional[Error]) – (optional) AErrorobject. If present, the transaction failed. Otherwise, it was successful.op_errors (
Optional[List[Optional[Error]]]) – (optional) A list of optionalErrorobjects. Each error corresponds to an operation in the submitted transaction. If present, the length of this list will match the number of operations submitted. If the value corresponding to a specific operation is None, it does not indicate that the operation succeeded, only that it was not the reason that the transaction failed.
-
static
from_solana_tx(tx, tx_error, tx_id)[source]¶ - Return type:
Optional[TransactionErrors]
-
static
from_stellar_tx(env, tx_error, tx_id)[source]¶ - Return type:
Optional[TransactionErrors]
-
exception
agora.error.TransactionNotFoundError(message='')[source]¶ Bases:
agora.error.ErrorRaised when no transaction data for a specified transaction could be found.
-
exception
agora.error.TransactionRejectedError(message='')[source]¶ Bases:
agora.error.ErrorRaised when the submitted transaction was rejected by a configured webhook.
-
exception
agora.error.UnsupportedMethodError(message='')[source]¶ Bases:
agora.error.ErrorRaised when a method is not supported in the current environment.
-
exception
agora.error.UnsupportedVersionError(message='')[source]¶ Bases:
agora.error.ErrorRaised when an unsupported version of Kin is used
-
exception
agora.error.WebhookRequestError(status_code, response_body='')[source]¶ Bases:
agora.error.ErrorShould be raised to return an error to Agora from a webhook.
- Parameters:
status_code (
int) – The status code to respond with.response_body (
str) – The response body to respond with.
-
exception
agora.error.WrongDestinationError(message='')[source]¶ Bases:
agora.error.ErrorRaised when a transaction was rejected by the app webhook for having a wrong destination.
agora.keys module¶
-
class
agora.keys.PrivateKey(private_key)[source]¶ Bases:
objectPrivateKey is a blockchain-agnostic representation of an ed25519 private key.
- Parameters:
private_key (
bytes) – The private key, in raw bytes.
-
classmethod
from_base58(seed)[source]¶ Decodes the provided base58-encoded seed and returns a PrivateKey object.
- Parameters:
seed (
str) – the base58-encoded seed- Return type:
- Returns:
a PrivateKey object.
-
classmethod
from_string(seed)[source]¶ Parses the provided Stellar-encoded seed and returns a Private Key.
- Parameters:
seed (
str) – A Stellar-encoded seed- Return type:
- Returns:
A PrivateKey object.
-
classmethod
random()[source]¶ Returns a Private Key derived from a randomly generated seed.
- Returns:
A PrivateKey object.
-
property
raw¶ Returns the raw bytes of the private key.
- Return type:
bytes- Returns:
bytes
-
sign(data)[source]¶ Sign the provided data.
- Parameters:
data (
bytes) – The data to sign.- Return type:
bytes- Returns:
The signature.
-
property
stellar_seed¶ Returns the Stellar-encoded seed, as a string.
- Return type:
str- Returns:
The Stellar-encoded string representation of the private key.
-
class
agora.keys.PublicKey(public_key)[source]¶ Bases:
objectPublicKey is a blockchain-agnostic representation of an ed25519 public key.
- Parameters:
public_key (
bytes) – The public key, in raw bytes.
-
classmethod
from_base58(address)[source]¶ Decodes the provided base58-encoded public address and returns a PublicKey object.
- Parameters:
address (
str) – the base58 encoded public address- Return type:
- Returns:
a PublicKey object.
-
classmethod
from_string(address)[source]¶ Parses the provided Stellar-encoded address and returns a PublicKey.
- Parameters:
address (
str) – A Stellar-encoded address- Return type:
- Returns:
A PublicKey object.
-
property
raw¶ Returns the raw bytes of the public key.
- Return type:
bytes- Returns:
bytes
-
property
stellar_address¶ Returns the Stellar-encoded address, as a string.
- Return type:
str- Returns:
The Stellar-encoded string representation of the public key.
agora.utils module¶
-
agora.utils.kin_to_quarks(kin)[source]¶ Converts a string kin amount to quarks. If the provided Kin amount contains more than 5 decimal places (i.e. it contains an inexact number of quarks), additional decimal places will be ignored.
For example, passing in a value of “0.000009” will result in a value of 0 quarks being returned.
- Parameters:
kin (
str) – A string Kin amount.- Return type:
int- Returns:
An integer quark amount.
-
agora.utils.partition(l, size)[source]¶ Partition the provided list into a list of sub-lists of the provided size. The last sub-list may be smaller if the length of the originally provided list is not evenly divisible by size.
- Parameters:
l – the list to partition
size – the size of each sub-list
- Returns:
a list of sub-lists