Skip to content

Commit

Permalink
Merge branch 'main' into model-type-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
mvadari authored Dec 11, 2024
2 parents 95df2fc + c8c634b commit d894086
Show file tree
Hide file tree
Showing 123 changed files with 325 additions and 185 deletions.
28 changes: 28 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
language: "en-US"
reviews:
# Set the profile for reviews. Assertive profile yields more feedback, that may be considered nitpicky.
profile: "chill"
# Approve the review once CodeRabbit's comments are resolved. Note: In GitLab, all discussions must be resolved.
request_changes_workflow: false
# Generate a high level summary of the changes in the PR/MR description.
high_level_summary: false
# Generate a poem in the walkthrough comment.
poem: true
# Post review details on each review. Additionally, post a review status when a review is skipped in certain cases.
review_status: true
# Generate walkthrough in a markdown collapsible section.
collapse_walkthrough: false
# Abort the in-progress review if the pull request is closed or merged.
abort_on_close: true
auto_review:
# Automatic Review | Automatic code review
enabled: true
# Review draft PRs/MRs.
drafts: false
# Ignore reviewing if the title of the pull request contains any of these keywords (case-insensitive).
ignore_title_keywords:
- build(
chat:
# Enable the bot to reply automatically without requiring the user to tag it.
auto_reply: true
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Sphinx configuration for xrpl-py."""

# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
Expand Down
173 changes: 95 additions & 78 deletions poetry.lock

Large diffs are not rendered by default.

16 changes: 7 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,32 @@ include = ["LICENSE"]
packages = [{ include = "xrpl" }]

[tool.poetry.dependencies]
python = "^3.8"
python = ">=3.8.1,<4.0"
base58 = "^2.1.0"
ECPy = "^1.2.5"
typing-extensions = "^4.2.0"
httpx = ">=0.18.1,<0.28.0"
httpx = ">=0.18.1,<0.29.0"
websockets = ">=11,<14"
Deprecated = "^1.2.13"
types-Deprecated = "^1.2.9"
pycryptodome = "^3.16.0"

[tool.poetry.dev-dependencies]
flake8 = "^4.0.1"
black = "23.3.0"
flake8 = "^7.0.0"
black = "24.8.0"
flake8-black = "^0.3.6"
flake8-docstrings = "^1.7.0"
mypy = "^1"
isort = "^5.11.5"
flake8-isort = "^6.0.0"
flake8-annotations = "2.7.0"
flake8-annotations = "^3.1.1"
flake8-absolute-import = "^1.0"
darglint = "^1.5.8"
sphinx-rtd-theme = "^3.0.0"
sphinx-rtd-theme = "^3.0.2"
aiounittest = "^1.4.0"
coverage = "^7.2.7"
Jinja2 = "^3.1.4"
MarkupSafe = "2.1.5"
Sphinx = "^7.1.2"
poethepoet = "^0.29.0"
poethepoet = "^0.30.0"

[tool.isort]
# Make sure that isort's settings line up with black
Expand Down
1 change: 1 addition & 0 deletions snippets/get_transaction.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Example of how we can see a transaction that was validated on the ledger"""

from xrpl.clients import JsonRpcClient
from xrpl.models import Ledger, Tx

Expand Down
1 change: 1 addition & 0 deletions snippets/partial_payment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Example of how to handle partial payments"""

from xrpl.clients import JsonRpcClient
from xrpl.models import (
AccountLines,
Expand Down
1 change: 1 addition & 0 deletions snippets/set_regular_key.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Example of how we can setting a regular key"""

from xrpl.account import get_balance
from xrpl.clients import JsonRpcClient
from xrpl.models import Payment, SetRegularKey
Expand Down
1 change: 1 addition & 0 deletions snippets/submit_payment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Example of how to send a transaction and see its validation response"""

from xrpl.account import get_balance
from xrpl.clients import JsonRpcClient
from xrpl.models import Payment, Tx
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/core/binarycodec/types/test_serialized_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class TestSerializedType(TestCase):
def fixture_test(self, fixture: ValueTest):
"""Run the appropriate test for given fixture case."""
serialized_type: SerializedType = TYPE_MAP[fixture.type]
if type(fixture.test_json) == dict:
if isinstance(fixture.test_json, dict):
json_value = fixture.test_json
else:
json_value = str(fixture.test_json)
Expand Down
1 change: 1 addition & 0 deletions xrpl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""High-level XRPL exports."""

from xrpl import account, clients, core, ledger, models, transaction, utils, wallet
from xrpl.constants import CryptoAlgorithm, XRPLException

Expand Down
1 change: 1 addition & 0 deletions xrpl/account/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Methods for interacting with XRPL accounts."""

from xrpl.account.main import (
does_account_exist,
get_account_root,
Expand Down
1 change: 1 addition & 0 deletions xrpl/account/transaction_history.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""High-level methods to obtain information about account transaction history."""

import asyncio

from xrpl.asyncio.account import transaction_history
Expand Down
1 change: 1 addition & 0 deletions xrpl/asyncio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""High-level XRPL exports for async support."""

from xrpl.asyncio import account, clients, ledger, transaction, wallet

__all__ = ["account", "clients", "ledger", "transaction", "wallet"]
1 change: 1 addition & 0 deletions xrpl/asyncio/account/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Async methods for interacting with XRPL accounts."""

from xrpl.asyncio.account.main import (
does_account_exist,
get_account_root,
Expand Down
1 change: 1 addition & 0 deletions xrpl/asyncio/account/transaction_history.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""High-level methods to obtain information about account transaction history."""

from xrpl.asyncio.clients import Client, XRPLRequestFailureException
from xrpl.core.addresscodec import is_valid_xaddress, xaddress_to_classic_address
from xrpl.models.requests import AccountTx
Expand Down
1 change: 1 addition & 0 deletions xrpl/asyncio/clients/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Asynchronous network clients for interacting with the XRPL."""

from xrpl.asyncio.clients.async_json_rpc_client import AsyncJsonRpcClient
from xrpl.asyncio.clients.async_websocket_client import AsyncWebsocketClient
from xrpl.asyncio.clients.client import Client
Expand Down
1 change: 1 addition & 0 deletions xrpl/asyncio/clients/async_json_rpc_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""An async client for interacting with the rippled JSON RPC."""

from xrpl.asyncio.clients.async_client import AsyncClient
from xrpl.asyncio.clients.json_rpc_base import JsonRpcBase

Expand Down
1 change: 1 addition & 0 deletions xrpl/asyncio/ledger/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Async methods for obtaining information about the status of the XRP Ledger."""

from xrpl.asyncio.ledger.main import (
get_fee,
get_latest_open_ledger_sequence,
Expand Down
1 change: 1 addition & 0 deletions xrpl/asyncio/wallet/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Async methods for working with XRPL wallets."""

from xrpl.asyncio.wallet.wallet_generation import (
XRPLFaucetException,
generate_faucet_wallet,
Expand Down
1 change: 1 addition & 0 deletions xrpl/asyncio/wallet/wallet_generation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Handles wallet generation from a faucet."""

import asyncio
from typing import Optional
from urllib.parse import urlparse, urlunparse
Expand Down
1 change: 1 addition & 0 deletions xrpl/clients/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Synchronous network clients for interacting with the XRPL."""

from xrpl.asyncio.clients.client import Client
from xrpl.asyncio.clients.exceptions import XRPLRequestFailureException
from xrpl.asyncio.clients.utils import (
Expand Down
1 change: 1 addition & 0 deletions xrpl/clients/json_rpc_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A sync client for interacting with the rippled JSON RPC."""

from xrpl.asyncio.clients.json_rpc_base import JsonRpcBase
from xrpl.clients.sync_client import SyncClient

Expand Down
1 change: 1 addition & 0 deletions xrpl/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Collection of public constants for XRPL."""

import re
from decimal import Context
from enum import Enum
Expand Down
1 change: 1 addition & 0 deletions xrpl/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Core codec functions for interacting with the XRPL."""

from xrpl.core import addresscodec, binarycodec, keypairs

__all__ = ["addresscodec", "binarycodec", "keypairs"]
1 change: 1 addition & 0 deletions xrpl/core/addresscodec/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Functions for encoding and decoding XRP Ledger addresses and seeds."""

from xrpl.core.addresscodec.codec import (
SEED_LENGTH,
decode_account_public_key,
Expand Down
4 changes: 2 additions & 2 deletions xrpl/core/addresscodec/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def _encode(bytestring: bytes, prefix: List[int], expected_length: int) -> str:
length.
"""
if expected_length and len(bytestring) != expected_length:
error_message = """unexpected_payload_length: len(bytestring) does not match expected_length.
Ensure that the bytes are a bytestring."""
error_message = """unexpected_payload_length: len(bytestring) does not match
expected_length. Ensure that the bytes are a bytestring."""
raise XRPLAddressCodecException(error_message)
encoded_prefix = bytes(prefix)
payload = encoded_prefix + bytestring
Expand Down
1 change: 1 addition & 0 deletions xrpl/core/addresscodec/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""General XRPL Address Codec Exceptions."""

from xrpl.constants import XRPLException


Expand Down
7 changes: 4 additions & 3 deletions xrpl/core/addresscodec/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""This module contains commonly-used constants."""

from typing_extensions import Final

# The dictionary used for XRPL base58 encodings
XRPL_ALPHABET: Final[
bytes
] = b"rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"
XRPL_ALPHABET: Final[bytes] = (
b"rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"
)
1 change: 1 addition & 0 deletions xrpl/core/binarycodec/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Functions for encoding objects into the XRP Ledger's canonical
binary format and decoding them.
"""

from xrpl.core.binarycodec.exceptions import XRPLBinaryCodecException
from xrpl.core.binarycodec.main import (
decode,
Expand Down
1 change: 1 addition & 0 deletions xrpl/core/binarycodec/binary_wrappers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Wrapper classes around byte buffers used for serialization and deserialization."""

from xrpl.core.binarycodec.binary_wrappers.binary_parser import BinaryParser
from xrpl.core.binarycodec.binary_wrappers.binary_serializer import BinarySerializer

Expand Down
1 change: 1 addition & 0 deletions xrpl/core/binarycodec/definitions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Handles the XRPL type and definition specifics."""

from xrpl.core.binarycodec.definitions.definitions import (
get_field_header_from_name,
get_field_instance,
Expand Down
1 change: 1 addition & 0 deletions xrpl/core/binarycodec/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""General XRPL Binary Codec Exceptions."""

from xrpl.constants import XRPLException


Expand Down
1 change: 1 addition & 0 deletions xrpl/core/binarycodec/types/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Top-level exports for types used in binary_codec."""

from xrpl.core.binarycodec.types.account_id import AccountID
from xrpl.core.binarycodec.types.amount import Amount
from xrpl.core.binarycodec.types.blob import Blob
Expand Down
8 changes: 5 additions & 3 deletions xrpl/core/binarycodec/types/serialized_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ def from_parser( # noqa: D102
cls: Type[Self],
parser: BinaryParser,
# length_hint is Any so that subclasses can choose whether or not to require it.
length_hint: Any,
length_hint: Any, # noqa: ANN401
) -> Self:
pass

@classmethod
@abstractmethod
def from_value(cls: Type[Self], value: Any) -> Self: # noqa: D102
def from_value(cls: Type[Self], value: Any) -> Self: # noqa: D102, ANN401
# Note: Its difficult to specify a concrete type for value parameter because
# child-classes accept a variety of types.
pass

def to_byte_sink(self: Self, bytesink: bytearray) -> None:
Expand All @@ -54,7 +56,7 @@ def __bytes__(self: Self) -> bytes:
"""
return self.buffer

def to_json(self: Self) -> Any:
def to_json(self: Self) -> Any: # noqa: ANN401
"""
Returns the JSON representation of a SerializedType.
Expand Down
4 changes: 2 additions & 2 deletions xrpl/core/binarycodec/types/st_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _handle_xaddress(field: str, xaddress: str) -> Dict[str, Union[str, int]]:
return {field: classic_address}


def _str_to_enum(field: str, value: Any) -> Any:
def _str_to_enum(field: str, value: str) -> Union[str, int]:
# all of these fields have enum values that are used for serialization
# converts the string name to the corresponding enum code
if field == "TransactionType":
Expand All @@ -70,7 +70,7 @@ def _str_to_enum(field: str, value: Any) -> Any:
return value


def _enum_to_str(field: str, value: Any) -> Any:
def _enum_to_str(field: str, value: int) -> Union[str, int]:
# reverse of the above function
if field == "TransactionType":
return get_transaction_type_name(value)
Expand Down
1 change: 1 addition & 0 deletions xrpl/core/keypairs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Low-level functions for creating and using cryptographic keys with the XRP
Ledger.
"""

from xrpl.core.keypairs.exceptions import XRPLKeypairsException
from xrpl.core.keypairs.main import (
derive_classic_address,
Expand Down
1 change: 1 addition & 0 deletions xrpl/core/keypairs/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""XRPL keypair codec exceptions."""

from xrpl.constants import XRPLException


Expand Down
1 change: 1 addition & 0 deletions xrpl/core/keypairs/helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Miscellaneous functions that are private to xrpl.core.keypairs."""

import hashlib

import Crypto.Hash.RIPEMD160 as RIPEMD160
Expand Down
1 change: 1 addition & 0 deletions xrpl/core/keypairs/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Interface for cryptographic key pairs for use with the XRP Ledger."""

from secrets import token_bytes
from typing import Dict, Optional, Tuple, Type, Union

Expand Down
1 change: 1 addition & 0 deletions xrpl/ledger/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Methods for obtaining information about the status of the XRP Ledger."""

from xrpl.ledger.main import (
get_fee,
get_latest_open_ledger_sequence,
Expand Down
1 change: 1 addition & 0 deletions xrpl/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Top-level exports for the models package."""

from xrpl.models import amounts, currencies, requests, transactions
from xrpl.models.amounts import * # noqa: F401, F403
from xrpl.models.auth_account import AuthAccount
Expand Down
1 change: 1 addition & 0 deletions xrpl/models/amounts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
of that currency, and the counterparty (issuer) on the trustline
that holds the value. For XRP, there is no counterparty.
"""

from xrpl.models.amounts.amount import (
Amount,
get_amount_value,
Expand Down
1 change: 1 addition & 0 deletions xrpl/models/amounts/amount.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
counterparty (issuer) on the trustline that holds the value. For XRP, there is no
counterparty.
"""

from typing import Union, cast

from xrpl.models.amounts.issued_currency_amount import IssuedCurrencyAmount
Expand Down
1 change: 1 addition & 0 deletions xrpl/models/auth_account.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Model used in AMMBid transaction."""

from __future__ import annotations

from dataclasses import dataclass
Expand Down
Loading

0 comments on commit d894086

Please sign in to comment.