Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add feature RPC #719

Merged
merged 7 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [[Unreleased]]
- Add support for the DeliverMax field in Payment transactions

### Added
- Support for the DeliverMax field in Payment transactions
mvadari marked this conversation as resolved.
Show resolved Hide resolved
- Support for the `feature` RPC

## [2.6.0] - 2024-06-03

Expand Down
29 changes: 29 additions & 0 deletions tests/integration/reqs/test_feature.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from tests.integration.integration_test_case import IntegrationTestCase
from tests.integration.it_utils import test_async_and_sync
from xrpl.models.requests import Feature

AMM_AMENDMENT = "8CC0774A3BF66D1D22E76BBDA8E8A232E6B6313834301B3B23E8601196AE6455"


class TestFeature(IntegrationTestCase):
@test_async_and_sync(globals())
async def test_basic_functionality(self, client):
response = await client.request(Feature())
features = response.result["features"]

ckeshava marked this conversation as resolved.
Show resolved Hide resolved
self.assertIn(AMM_AMENDMENT, features)
feature_info = features[AMM_AMENDMENT]
self.assertEqual(feature_info["name"], "AMM")
self.assertTrue(isinstance(feature_info["enabled"], bool))
self.assertEqual(feature_info["supported"], True)
mvadari marked this conversation as resolved.
Show resolved Hide resolved

@test_async_and_sync(globals())
async def test_single_feature(self, client):
response = await client.request(Feature(feature=AMM_AMENDMENT))
features = response.result

self.assertIn(AMM_AMENDMENT, features)
feature_info = features[AMM_AMENDMENT]
self.assertEqual(feature_info["name"], "AMM")
self.assertTrue(isinstance(feature_info["enabled"], bool))
self.assertEqual(feature_info["supported"], True)
3 changes: 3 additions & 0 deletions xrpl/models/requests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Request models."""

from xrpl.models.auth_account import AuthAccount
from xrpl.models.path import PathStep
from xrpl.models.requests.account_channels import AccountChannels
Expand All @@ -14,6 +15,7 @@
from xrpl.models.requests.channel_authorize import ChannelAuthorize
from xrpl.models.requests.channel_verify import ChannelVerify
from xrpl.models.requests.deposit_authorized import DepositAuthorized
from xrpl.models.requests.feature import Feature
from xrpl.models.requests.fee import Fee
from xrpl.models.requests.gateway_balances import GatewayBalances
from xrpl.models.requests.generic_request import GenericRequest
Expand Down Expand Up @@ -65,6 +67,7 @@
"ChannelAuthorize",
"ChannelVerify",
"DepositAuthorized",
"Feature",
"Fee",
"GatewayBalances",
"GenericRequest",
Expand Down
22 changes: 22 additions & 0 deletions xrpl/models/requests/feature.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""This request gets information about a network's amendments."""

from __future__ import annotations

from dataclasses import dataclass, field
from typing import Optional

from xrpl.models.requests.request import Request, RequestMethod
from xrpl.models.utils import KW_ONLY_DATACLASS, require_kwargs_on_init


@require_kwargs_on_init
@dataclass(frozen=True, **KW_ONLY_DATACLASS)
class Feature(Request):
"""The `feature` method gets information about a network's amendments."""

feature: Optional[str] = None
"""
The hex-encoded feature hash.
"""

method: RequestMethod = field(default=RequestMethod.FEATURE, init=False)
2 changes: 2 additions & 0 deletions xrpl/models/requests/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ class RequestMethod(str, Enum):
NFT_INFO = "nft_info" # clio only
NFT_HISTORY = "nft_history" # clio only
NFTS_BY_ISSUER = "nfts_by_issuer" # clio only

ckeshava marked this conversation as resolved.
Show resolved Hide resolved
# subscription methods
SUBSCRIBE = "subscribe"
UNSUBSCRIBE = "unsubscribe"

# server info methods
FEATURE = "feature"
FEE = "fee"
MANIFEST = "manifest"
SERVER_DEFINITIONS = "server_definitions"
Expand Down
Loading