Module libra.jsonrpc

This package provides a client for connecting to Libra JSON-RPC Service API

Create a client connect to Libra Testnet and calls get_metadata API:


>>> from libra import jsonrpc, testnet
>>> client = jsonrpc.Client(testnet.JSON_RPC_URL)
>>> client.get_metadata()
version: 3300304
timestamp: 1601492912847973
chain_id: 2

See Libra JSON-RPC API SPEC for more details

Expand source code
# Copyright (c) The Libra Core Contributors
# SPDX-License-Identifier: Apache-2.0

""" This package provides a client for connecting to Libra JSON-RPC Service API

Create a client connect to Libra Testnet and calls get_metadata API:

```python3

>>> from libra import jsonrpc, testnet
>>> client = jsonrpc.Client(testnet.JSON_RPC_URL)
>>> client.get_metadata()
version: 3300304
timestamp: 1601492912847973
chain_id: 2

```

See [Libra JSON-RPC API SPEC](https://github.com/libra/libra/blob/master/json-rpc/json-rpc-spec.md) for more details

"""

from .client import (
    Client,
    State,
    Retry,
    RequestStrategy,
    RequestWithBackups,
    # Exceptions
    JsonRpcError,
    NetworkError,
    InvalidServerResponse,
    StaleResponseError,
    TransactionHashMismatchError,
    TransactionExecutionFailed,
    TransactionExpired,
    WaitForTransactionTimeout,
    AccountNotFoundError,
)
from .jsonrpc_pb2 import (
    Amount,
    Metadata,
    CurrencyInfo,
    Account,
    AccountRole,
    Transaction,
    TransactionData,
    Script,
    Event,
    EventData,
    VMStatus,
    StateProof,
    AccountStateWithProof,
    AccountStateProof,
)
from .constants import (
    # AccountRole#type field values
    ACCOUNT_ROLE_UNKNOWN,
    ACCOUNT_ROLE_CHILD_VASP,
    ACCOUNT_ROLE_PARENT_VASP,
    ACCOUNT_ROLE_DESIGNATED_DEALER,
    # EventData#type field values
    EVENT_DATA_UNKNOWN,
    EVENT_DATA_BURN,
    EVENT_DATA_CANCEL_BURN,
    EVENT_DATA_MINT,
    EVENT_DATA_TO_LBR_EXCHANGE_RATE_UPDATE,
    EVENT_DATA_PREBURN,
    EVENT_DATA_RECEIVED_PAYMENT,
    EVENT_DATA_SENT_PAYMENT,
    EVENT_DATA_NEW_EPOCH,
    EVENT_DATA_NEW_BLOCK,
    EVENT_DATA_RECEIVED_MINT,
    EVENT_DATA_COMPLIANCE_KEY_ROTATION,
    EVENT_DATA_BASE_URL_ROTATION,
    EVENT_DATA_CREATE_ACCOUNT,
    EVENT_DATA_ADMIN_TRANSACTION,
    # VMStatus#type field values
    VM_STATUS_EXECUTED,
    VM_STATUS_OUT_OF_GAS,
    VM_STATUS_MOVE_ABORT,
    VM_STATUS_EXECUTION_FAILURE,
    VM_STATUS_MISC_ERROR,
    # TransactionData#type field values
    TRANSACTION_DATA_BLOCK_METADATA,
    TRANSACTION_DATA_WRITE_SET,
    TRANSACTION_DATA_USER,
    TRANSACTION_DATA_UNKNOWN,
    # Script#type field values, only set unknown type here,
    # other types, plese see https://github.com/libra/libra/blob/master/language/stdlib/transaction_scripts/doc/transaction_script_documentation.md for all available script names.
    SCRIPT_UNKNOWN,
)

Sub-modules

libra.jsonrpc.client
libra.jsonrpc.constants

Defines constants for enum type values …

libra.jsonrpc.jsonrpc_pb2

Generated protocol buffer code.

Classes

class Account (*args, **kwargs)

A ProtocolMessage

Ancestors

  • google.protobuf.pyext._message.CMessage
  • google.protobuf.message.Message

Class variables

var DESCRIPTOR

Instance variables

var address

Field jsonrpc.Account.address

var authentication_key

Field jsonrpc.Account.authentication_key

var balances

Field jsonrpc.Account.balances

var delegated_key_rotation_capability

Field jsonrpc.Account.delegated_key_rotation_capability

var delegated_withdrawal_capability

Field jsonrpc.Account.delegated_withdrawal_capability

var is_frozen

Field jsonrpc.Account.is_frozen

var received_events_key

Field jsonrpc.Account.received_events_key

var role

Field jsonrpc.Account.role

var sent_events_key

Field jsonrpc.Account.sent_events_key

var sequence_number

Field jsonrpc.Account.sequence_number

class AccountRole (*args, **kwargs)

A ProtocolMessage

Ancestors

  • google.protobuf.pyext._message.CMessage
  • google.protobuf.message.Message

Class variables

var DESCRIPTOR

Instance variables

var base_url

Field jsonrpc.AccountRole.base_url

var base_url_rotation_events_key

Field jsonrpc.AccountRole.base_url_rotation_events_key

var compliance_key

Field jsonrpc.AccountRole.compliance_key

var compliance_key_rotation_events_key

Field jsonrpc.AccountRole.compliance_key_rotation_events_key

var expiration_time

Field jsonrpc.AccountRole.expiration_time

var human_name

Field jsonrpc.AccountRole.human_name

var num_children

Field jsonrpc.AccountRole.num_children

var parent_vasp_address

Field jsonrpc.AccountRole.parent_vasp_address

var preburn_balances

Field jsonrpc.AccountRole.preburn_balances

var received_mint_events_key

Field jsonrpc.AccountRole.received_mint_events_key

var type

Field jsonrpc.AccountRole.type

class AccountStateProof (*args, **kwargs)

A ProtocolMessage

Ancestors

  • google.protobuf.pyext._message.CMessage
  • google.protobuf.message.Message

Class variables

var DESCRIPTOR

Instance variables

var ledger_info_to_transaction_info_proof

Field jsonrpc.AccountStateProof.ledger_info_to_transaction_info_proof

var transaction_info

Field jsonrpc.AccountStateProof.transaction_info

var transaction_info_to_account_proof

Field jsonrpc.AccountStateProof.transaction_info_to_account_proof

class AccountStateWithProof (*args, **kwargs)

A ProtocolMessage

Ancestors

  • google.protobuf.pyext._message.CMessage
  • google.protobuf.message.Message

Class variables

var DESCRIPTOR

Instance variables

var blob

Field jsonrpc.AccountStateWithProof.blob

var proof

Field jsonrpc.AccountStateWithProof.proof

var version

Field jsonrpc.AccountStateWithProof.version

class Amount (*args, **kwargs)

A ProtocolMessage

Ancestors

  • google.protobuf.pyext._message.CMessage
  • google.protobuf.message.Message

Class variables

var DESCRIPTOR

Instance variables

var amount

Field jsonrpc.Amount.amount

var currency

Field jsonrpc.Amount.currency

class CurrencyInfo (*args, **kwargs)

A ProtocolMessage

Ancestors

  • google.protobuf.pyext._message.CMessage
  • google.protobuf.message.Message

Class variables

var DESCRIPTOR

Instance variables

var burn_events_key

Field jsonrpc.CurrencyInfo.burn_events_key

var cancel_burn_events_key

Field jsonrpc.CurrencyInfo.cancel_burn_events_key

var code

Field jsonrpc.CurrencyInfo.code

var exchange_rate_update_events_key

Field jsonrpc.CurrencyInfo.exchange_rate_update_events_key

var fractional_part

Field jsonrpc.CurrencyInfo.fractional_part

var mint_events_key

Field jsonrpc.CurrencyInfo.mint_events_key

var preburn_events_key

Field jsonrpc.CurrencyInfo.preburn_events_key

var scaling_factor

Field jsonrpc.CurrencyInfo.scaling_factor

var to_lbr_exchange_rate

Field jsonrpc.CurrencyInfo.to_lbr_exchange_rate

class Event (*args, **kwargs)

A ProtocolMessage

Ancestors

  • google.protobuf.pyext._message.CMessage
  • google.protobuf.message.Message

Class variables

var DESCRIPTOR

Instance variables

var data

Field jsonrpc.Event.data

var key

Field jsonrpc.Event.key

var sequence_number

Field jsonrpc.Event.sequence_number

var transaction_version

Field jsonrpc.Event.transaction_version

class EventData (*args, **kwargs)

A ProtocolMessage

Ancestors

  • google.protobuf.pyext._message.CMessage
  • google.protobuf.message.Message

Class variables

var DESCRIPTOR

Instance variables

var amount

Field jsonrpc.EventData.amount

var committed_timestamp_secs

Field jsonrpc.EventData.committed_timestamp_secs

var created_address

Field jsonrpc.EventData.created_address

var currency_code

Field jsonrpc.EventData.currency_code

var destination_address

Field jsonrpc.EventData.destination_address

var epoch

Field jsonrpc.EventData.epoch

var metadata

Field jsonrpc.EventData.metadata

var new_base_url

Field jsonrpc.EventData.new_base_url

var new_compliance_public_key

Field jsonrpc.EventData.new_compliance_public_key

var new_to_lbr_exchange_rate

Field jsonrpc.EventData.new_to_lbr_exchange_rate

var preburn_address

Field jsonrpc.EventData.preburn_address

var proposed_time

Field jsonrpc.EventData.proposed_time

var proposer

Field jsonrpc.EventData.proposer

var receiver

Field jsonrpc.EventData.receiver

var role_id

Field jsonrpc.EventData.role_id

var round

Field jsonrpc.EventData.round

var sender

Field jsonrpc.EventData.sender

var time_rotated_seconds

Field jsonrpc.EventData.time_rotated_seconds

var type

Field jsonrpc.EventData.type

class Metadata (*args, **kwargs)

A ProtocolMessage

Ancestors

  • google.protobuf.pyext._message.CMessage
  • google.protobuf.message.Message

Class variables

var DESCRIPTOR

Instance variables

var chain_id

Field jsonrpc.Metadata.chain_id

var libra_version

Field jsonrpc.Metadata.libra_version

var module_publishing_allowed

Field jsonrpc.Metadata.module_publishing_allowed

var script_hash_allow_list

Field jsonrpc.Metadata.script_hash_allow_list

var timestamp

Field jsonrpc.Metadata.timestamp

var version

Field jsonrpc.Metadata.version

class Script (*args, **kwargs)

A ProtocolMessage

Ancestors

  • google.protobuf.pyext._message.CMessage
  • google.protobuf.message.Message

Class variables

var DESCRIPTOR

Instance variables

var amount

Field jsonrpc.Script.amount

var arguments

Field jsonrpc.Script.arguments

var code

Field jsonrpc.Script.code

var currency

Field jsonrpc.Script.currency

var metadata

Field jsonrpc.Script.metadata

var metadata_signature

Field jsonrpc.Script.metadata_signature

var receiver

Field jsonrpc.Script.receiver

var type

Field jsonrpc.Script.type

var type_arguments

Field jsonrpc.Script.type_arguments

class StateProof (*args, **kwargs)

A ProtocolMessage

Ancestors

  • google.protobuf.pyext._message.CMessage
  • google.protobuf.message.Message

Class variables

var DESCRIPTOR

Instance variables

var epoch_change_proof

Field jsonrpc.StateProof.epoch_change_proof

var ledger_consistency_proof

Field jsonrpc.StateProof.ledger_consistency_proof

var ledger_info_with_signatures

Field jsonrpc.StateProof.ledger_info_with_signatures

class Transaction (*args, **kwargs)

A ProtocolMessage

Ancestors

  • google.protobuf.pyext._message.CMessage
  • google.protobuf.message.Message

Class variables

var DESCRIPTOR

Instance variables

var bytes

Field jsonrpc.Transaction.bytes

var events

Field jsonrpc.Transaction.events

var gas_used

Field jsonrpc.Transaction.gas_used

var hash

Field jsonrpc.Transaction.hash

var transaction

Field jsonrpc.Transaction.transaction

var version

Field jsonrpc.Transaction.version

var vm_status

Field jsonrpc.Transaction.vm_status

class TransactionData (*args, **kwargs)

A ProtocolMessage

Ancestors

  • google.protobuf.pyext._message.CMessage
  • google.protobuf.message.Message

Class variables

var DESCRIPTOR

Instance variables

var chain_id

Field jsonrpc.TransactionData.chain_id

var expiration_timestamp_secs

Field jsonrpc.TransactionData.expiration_timestamp_secs

var gas_currency

Field jsonrpc.TransactionData.gas_currency

var gas_unit_price

Field jsonrpc.TransactionData.gas_unit_price

var max_gas_amount

Field jsonrpc.TransactionData.max_gas_amount

var public_key

Field jsonrpc.TransactionData.public_key

var script

Field jsonrpc.TransactionData.script

var script_bytes

Field jsonrpc.TransactionData.script_bytes

var script_hash

Field jsonrpc.TransactionData.script_hash

var sender

Field jsonrpc.TransactionData.sender

var sequence_number

Field jsonrpc.TransactionData.sequence_number

var signature

Field jsonrpc.TransactionData.signature

var signature_scheme

Field jsonrpc.TransactionData.signature_scheme

var timestamp_usecs

Field jsonrpc.TransactionData.timestamp_usecs

var type

Field jsonrpc.TransactionData.type

class VMStatus (*args, **kwargs)

A ProtocolMessage

Ancestors

  • google.protobuf.pyext._message.CMessage
  • google.protobuf.message.Message

Class variables

var DESCRIPTOR

Instance variables

var abort_code

Field jsonrpc.VMStatus.abort_code

var code_offset

Field jsonrpc.VMStatus.code_offset

var explanation

Field jsonrpc.VMStatus.explanation

var function_index

Field jsonrpc.VMStatus.function_index

var location

Field jsonrpc.VMStatus.location

var type

Field jsonrpc.VMStatus.type