Skip to content

Commit

Permalink
chore: Remove deprecated request functions (attempt 2) (#581)
Browse files Browse the repository at this point in the history
* Remove deprecated functions

* Fix isort

---------

Co-authored-by: Caleb Kniffen <ckniffen@ripple.com>
  • Loading branch information
JST5000 and ckniffen committed Jul 5, 2023
1 parent 424db2d commit 150ab30
Show file tree
Hide file tree
Showing 11 changed files with 3 additions and 338 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Removed Sequence from Wallet class
- Core keypairs generate seed must take in hexstring instead of bytestring
- Core keypairs formatting for ED25519 is now padded with zeros if length of keystring is less than 64
- Removed deprecated request wrappers (the preferred method is to directly do client.request instead)

## [[Unreleased]]
### Fixed:
Expand Down
10 changes: 1 addition & 9 deletions xrpl/account/__init__.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
"""Methods for interacting with XRPL accounts."""
from xrpl.account.main import (
does_account_exist,
get_account_info,
get_account_root,
get_balance,
get_next_valid_seq_number,
)
from xrpl.account.transaction_history import (
get_account_payment_transactions,
get_account_transactions,
get_latest_transaction,
)
from xrpl.account.transaction_history import get_latest_transaction

__all__ = [
"get_next_valid_seq_number",
"get_balance",
"get_account_root",
"get_account_info",
"get_account_payment_transactions",
"get_account_transactions",
"does_account_exist",
"get_latest_transaction",
]
30 changes: 0 additions & 30 deletions xrpl/account/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
import asyncio
from typing import Dict, Union

from deprecated.sphinx import deprecated

from xrpl.asyncio.account import main
from xrpl.clients.sync_client import SyncClient
from xrpl.models.response import Response


def does_account_exist(
Expand Down Expand Up @@ -91,30 +88,3 @@ def get_account_root(
The AccountRoot dictionary for the address.
"""
return asyncio.run(main.get_account_root(address, client, ledger_index))


@deprecated(
reason="Sending an AccountInfo request directly is just as easy to use.",
version="1.8.0",
)
def get_account_info(
address: str, client: SyncClient, ledger_index: Union[str, int] = "validated"
) -> Response: # pragma: no cover
"""
Query the ledger for account info of given address.
Args:
address: the account to query.
client: the network client used to make network calls.
ledger_index: The ledger index to use for the request. Must be an integer
ledger value or "current" (the current working version), "closed" (for the
closed-and-proposed version), or "validated" (the most recent version
validated by consensus). The default is "validated".
Returns:
The account info for the address.
Raises:
XRPLRequestFailureException: if the rippled API call fails.
"""
return asyncio.run(main.get_account_info(address, client, ledger_index))
56 changes: 0 additions & 56 deletions xrpl/account/transaction_history.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
"""High-level methods to obtain information about account transaction history."""
import asyncio
from typing import Any, Dict, List

from deprecated.sphinx import deprecated

from xrpl.asyncio.account import transaction_history
from xrpl.clients.sync_client import SyncClient
Expand All @@ -24,56 +21,3 @@ def get_latest_transaction(account: str, client: SyncClient) -> Response:
XRPLRequestFailureException: if the transaction fails.
"""
return asyncio.run(transaction_history.get_latest_transaction(account, client))


@deprecated(
reason="Sending an AccountTx request directly allows you to page through all "
"results and is just as easy to use.",
version="1.6.0",
)
def get_account_transactions(
address: str, client: SyncClient
) -> List[Dict[str, Any]]: # pragma: no cover
"""
Query the ledger for a list of transactions that involved a given account.
To access more than just the first page of results, use the :class:`AccountTx`
request directly.
Args:
address: the account to query.
client: the network client used to make network calls.
Returns:
The most recent transaction history for the address. For the full history,
page through the :class:`AccountTx` request directly.
Raises:
XRPLRequestFailureException: if the transaction fails.
"""
return asyncio.run(transaction_history.get_account_transactions(address, client))


@deprecated(
reason="Sending an AccountTx request directly and filtering for payments allows "
"you to page through all results and is just as easy to use.",
version="1.8.0",
)
def get_account_payment_transactions(
address: str, client: SyncClient
) -> List[Dict[str, Any]]: # pragma: no cover
"""
Query the ledger for a list of payment transactions that involved a given account.
To access more than just the first page of results, use the :class:`AccountTx`
request directly then filter for transactions with a "Payment" TransactionType.
Args:
address: the account to query.
client: the network client used to make network calls.
Returns:
The first page of payment transaction history for the address. For the full
history, page through the :class:`AccountTx` request directly.
"""
return asyncio.run(
transaction_history.get_account_payment_transactions(address, client)
)
10 changes: 1 addition & 9 deletions xrpl/asyncio/account/__init__.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
"""Async methods for interacting with XRPL accounts."""
from xrpl.asyncio.account.main import (
does_account_exist,
get_account_info,
get_account_root,
get_balance,
get_next_valid_seq_number,
)
from xrpl.asyncio.account.transaction_history import (
get_account_payment_transactions,
get_account_transactions,
get_latest_transaction,
)
from xrpl.asyncio.account.transaction_history import get_latest_transaction

__all__ = [
"get_next_valid_seq_number",
"get_balance",
"get_account_root",
"get_account_info",
"get_account_payment_transactions",
"get_account_transactions",
"does_account_exist",
"get_latest_transaction",
]
53 changes: 0 additions & 53 deletions xrpl/asyncio/account/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

from typing import Dict, Union, cast

from deprecated.sphinx import deprecated

from xrpl.asyncio.clients import Client, XRPLRequestFailureException
from xrpl.constants import XRPLException
from xrpl.core.addresscodec import is_valid_xaddress, xaddress_to_classic_address
from xrpl.models.requests import AccountInfo
from xrpl.models.response import Response


async def does_account_exist(
Expand Down Expand Up @@ -121,52 +117,3 @@ async def get_account_root(
raise XRPLRequestFailureException(account_info.result)

return cast(Dict[str, Union[int, str]], account_info.result["account_data"])


@deprecated(
reason="Sending an AccountInfo request directly is just as easy to use.",
version="1.8.0",
)
async def get_account_info(
address: str, client: Client, ledger_index: Union[str, int] = "validated"
) -> Response: # pragma: no cover
"""
Query the ledger for account info of given address.
Args:
address: the account to query.
client: the network client used to make network calls.
ledger_index: The ledger index to use for the request. Must be an integer
ledger value or "current" (the current working version), "closed" (for the
closed-and-proposed version), or "validated" (the most recent version
validated by consensus). The default is "validated".
Returns:
The account info for the address.
Raises:
XRPLException: If the ledger_index value is invalid.
XRPLRequestFailureException: if the rippled API call fails.
"""
if is_valid_xaddress(address):
address, _, _ = xaddress_to_classic_address(address)

if isinstance(ledger_index, str) and ledger_index not in {
"validated",
"current",
"closed",
}:
raise XRPLException(
"`ledger_index` is not valid - must be an `int` or one of {'validated', "
"'current', 'closed'}."
)
response = await client._request_impl(
AccountInfo(
account=address,
ledger_index=ledger_index,
)
)
if response.is_successful():
return response

raise XRPLRequestFailureException(response.result)
64 changes: 0 additions & 64 deletions xrpl/asyncio/account/transaction_history.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
"""High-level methods to obtain information about account transaction history."""
from typing import Any, Dict, List, cast

from deprecated.sphinx import deprecated

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 Expand Up @@ -32,63 +28,3 @@ async def get_latest_transaction(account: str, client: Client) -> Response:
if not response.is_successful():
raise XRPLRequestFailureException(response.result)
return response


@deprecated(
reason="Sending an AccountTx request directly allows you to page through all "
"results and is just as easy to use.",
version="1.6.0",
)
async def get_account_transactions(
address: str,
client: Client,
) -> List[Dict[str, Any]]: # pragma: no cover
"""
Query the ledger for a list of transactions that involved a given account.
To access more than just the first page of results, use the :class:`AccountTx`
request directly.
Args:
address: the account to query.
client: the network client used to make network calls.
Returns:
The most recent transaction history for the address. For the full history,
page through the :class:`AccountTx` request directly.
Raises:
XRPLRequestFailureException: if the transaction fails.
"""
if is_valid_xaddress(address):
address, _, _ = xaddress_to_classic_address(address)
request = AccountTx(account=address)
response = await client._request_impl(request)
if not response.is_successful():
raise XRPLRequestFailureException(response.result)
return cast(List[Dict[str, Any]], response.result["transactions"])


@deprecated(
reason="Sending an AccountTx request directly and filtering for payments allows "
"you to page through all results and is just as easy to use.",
version="1.8.0",
)
async def get_account_payment_transactions(
address: str,
client: Client,
) -> List[Dict[str, Any]]: # pragma: no cover
"""
Query the ledger for a list of payment transactions that involved a given account.
To access more than just the first page of results, use the :class:`AccountTx`
request directly then filter for transactions with a "Payment" TransactionType.
Args:
address: the account to query.
client: the network client used to make network calls.
Returns:
The first page of payment transaction history for the address. For the full
history, page through the :class:`AccountTx` request directly.
"""
all_transactions = await get_account_transactions(address, client)
return [tx for tx in all_transactions if tx["tx"]["TransactionType"] == "Payment"]
2 changes: 0 additions & 2 deletions xrpl/asyncio/transaction/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Async methods for working with transactions on the XRP Ledger."""
from xrpl.asyncio.transaction.ledger import get_transaction_from_hash
from xrpl.asyncio.transaction.main import (
autofill,
autofill_and_sign,
Expand All @@ -21,7 +20,6 @@
__all__ = [
"autofill",
"autofill_and_sign",
"get_transaction_from_hash",
"safe_sign_transaction",
"safe_sign_and_autofill_transaction",
"safe_sign_and_submit_transaction",
Expand Down
57 changes: 0 additions & 57 deletions xrpl/asyncio/transaction/ledger.py

This file was deleted.

2 changes: 0 additions & 2 deletions xrpl/transaction/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
XRPLReliableSubmissionException,
transaction_json_to_binary_codec_form,
)
from xrpl.transaction.ledger import get_transaction_from_hash
from xrpl.transaction.main import (
autofill,
autofill_and_sign,
Expand All @@ -24,7 +23,6 @@
__all__ = [
"autofill",
"autofill_and_sign",
"get_transaction_from_hash",
"safe_sign_transaction",
"safe_sign_and_autofill_transaction",
"safe_sign_and_submit_transaction",
Expand Down
Loading

0 comments on commit 150ab30

Please sign in to comment.