Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mvadari committed Jun 15, 2022
1 parent 8e56a99 commit 2d601b9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 58 deletions.
3 changes: 0 additions & 3 deletions xrpl/models/transactions/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ def _key_to_tx_json(key: str) -> str:
def _value_to_tx_json(value: XRPL_VALUE_TYPE) -> XRPL_VALUE_TYPE:
# IssuedCurrencyAmount and PathStep are special cases and should not be snake cased
# and only contain primitive members
if XChainProofSig.is_dict_of_model(value):
assert isinstance(value, dict)
return {key: key_value for key, key_value in value.items()}
if any([model.is_dict_of_model(value) for model in _LOWER_CASE_MODELS]):
assert isinstance(value, dict)
return {key: _value_to_tx_json(key_value) for key, key_value in value.items()}
Expand Down
56 changes: 1 addition & 55 deletions xrpl/models/xchain_claim_proof.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from __future__ import annotations

from dataclasses import dataclass
from typing import Any, Dict, List, Type, cast
from typing import List

from xrpl.models.base_model import BaseModel
from xrpl.models.required import REQUIRED
Expand All @@ -26,60 +26,6 @@ class XChainProofSig(BaseModel):

signing_key: str = REQUIRED # type: ignore

@classmethod
def is_dict_of_model(cls: Type[XChainProofSig], dictionary: Any) -> bool:
"""
Returns True if the input dictionary was derived by the `to_dict`
method of an instance of this class. In other words, True if this is
a dictionary representation of an instance of this class.
NOTE: does not account for model inheritance, IE will only return True
if dictionary represents an instance of this class, but not if
dictionary represents an instance of a subclass of this class.
Args:
dictionary: The dictionary to check.
Returns:
True if dictionary is a dict representation of an instance of this
class.
"""
return (
isinstance(dictionary, dict)
and "xchain_proof_sig" in dictionary
and super().is_dict_of_model(dictionary["xchain_proof_sig"])
)

@classmethod
def from_dict(cls: Type[XChainProofSig], value: Dict[str, Any]) -> XChainProofSig:
"""
Construct a new XChainProofSig from a dictionary of parameters.
Args:
value: The value to construct the XChainProofSig from.
Returns:
A new XChainProofSig object, constructed using the given parameters.
Raises:
XRPLModelException: If the dictionary provided is invalid.
"""
if "xchain_proof_sig" not in value:
return cast(XChainProofSig, super(XChainProofSig, cls).from_dict(value))
return cast(
XChainProofSig,
super(XChainProofSig, cls).from_dict(value["xchain_proof_sig"]),
)

def to_dict(self: XChainProofSig) -> Dict[str, Any]:
"""
Returns the dictionary representation of a XChainProofSig.
Returns:
The dictionary representation of a XChainProofSig.
"""
return {"xchain_proof_sig": super().to_dict()}


@require_kwargs_on_init
@dataclass(frozen=True)
Expand Down

0 comments on commit 2d601b9

Please sign in to comment.