agora package

Subpackages

Submodules

agora.error module

exception agora.error.AccountExistsError(message='')[source]

Bases: agora.error.Error

Raised when trying to create an account that already exists.

exception agora.error.AccountNotFoundError(message='', tx_id=None)[source]

Bases: agora.error.TransactionError

Raised when an account could not be found.

exception agora.error.AlreadyPaidError(message='')[source]

Bases: agora.error.Error

Raised when an invoice has already been paid.

exception agora.error.AlreadySubmittedError(message='', tx_id=None)[source]

Bases: agora.error.TransactionError

Indicates 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.TransactionError

Raised when a transaction contains an invalid nonce.

exception agora.error.BlockchainVersionError(message='')[source]

Bases: agora.error.Error

Raised when Agora indicates that the current blockchain version is not supported.

exception agora.error.Error(message='')[source]

Bases: Exception

Base error for Agora SDK errors.

exception agora.error.InsufficientBalanceError(message='', tx_id=None)[source]

Bases: agora.error.TransactionError

Raised when an account has an insufficient balance for a submitted transaction.

exception agora.error.InvalidSignatureError(message='', tx_id=None)[source]

Bases: agora.error.TransactionError

Raised when the submitted transaction is either missing signatures or contains unused ones.

exception agora.error.InvoiceError(errors, *args, **kwargs)[source]

Bases: agora.error.Error

Raised when there was an issue with a provided invoice.

class agora.error.InvoiceErrorReason(value)[source]

Bases: enum.IntEnum

An enumeration.

ALREADY_PAID = 1
SKU_NOT_FOUND = 3
UNKNOWN = 0
WRONG_DESTINATION = 2
classmethod from_proto(proto)[source]
Return type:

InvoiceErrorReason

to_lowercase()[source]
exception agora.error.NoSubsidizerError(message='')[source]

Bases: agora.error.Error

Raised 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.Error

Indicates that no token accounts were resolved for the requested account ID.

exception agora.error.OperationInvoiceError(op_index, reason)[source]

Bases: agora.error.Error

to_json()[source]
Return type:

dict

exception agora.error.PayerRequiredError(message='')[source]

Bases: agora.error.Error

Raised 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.Error

Raised when an invoice contains a SKU that could not be found.

exception agora.error.TransactionError(message='', tx_id=None)[source]

Bases: agora.error.Error

Base 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: object

Contains the details of a failed transaction.

Parameters:
  • tx_error (Optional[Error]) – (optional) A Error object. If present, the transaction failed. Otherwise, it was successful.

  • op_errors (Optional[List[Optional[Error]]]) – (optional) A list of optional Error objects. 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.Error

Raised when no transaction data for a specified transaction could be found.

exception agora.error.TransactionRejectedError(message='')[source]

Bases: agora.error.Error

Raised when the submitted transaction was rejected by a configured webhook.

exception agora.error.UnsupportedMethodError(message='')[source]

Bases: agora.error.Error

Raised when a method is not supported in the current environment.

exception agora.error.UnsupportedVersionError(message='')[source]

Bases: agora.error.Error

Raised when an unsupported version of Kin is used

exception agora.error.WebhookRequestError(status_code, response_body='')[source]

Bases: agora.error.Error

Should 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.Error

Raised when a transaction was rejected by the app webhook for having a wrong destination.

agora.error.error_from_proto(tx_error, tx_id)[source]
Return type:

Optional[Error]

agora.error.invoice_error_from_proto(invoice_error)[source]
Return type:

Error

agora.keys module

class agora.keys.PrivateKey(private_key)[source]

Bases: object

PrivateKey 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:

PrivateKey

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:

PrivateKey

Returns:

A PrivateKey object.

property public_key

Returns a PublicKey object corresponding to this private key.

Return type:

PublicKey

Returns:

a PublicKey

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.

to_base58()[source]

Returns the base58-encoded form of the seed.

Return type:

str

Returns:

the string base58-encoded seed.

class agora.keys.PublicKey(public_key)[source]

Bases: object

PublicKey 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:

PublicKey

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:

PublicKey

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.

to_base58()[source]

Returns the base58-encoded form of this public key.

Return type:

str

Returns:

the string base58-encoded public key

verify(data, signature)[source]

Verify the provided data and signature match this keypair’s public key. :type data: bytes :param data: The data that was signed. :type signature: bytes :param signature: The signature.

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

agora.utils.quarks_to_kin(quarks)[source]

Converts an integer quark amount into a string Kin amount.

Parameters:

quarks (int) – An amount, in quarks.

Return type:

str

Returns:

A string Kin amount.

agora.utils.user_agent(version)[source]
Return type:

Tuple[str, str]

agora.version module

Module contents