Skip to content

Commit

Permalink
Merge 917fadf into e4c5b9e
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Dec 19, 2023
2 parents e4c5b9e + 917fadf commit 3efca0d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
12 changes: 6 additions & 6 deletions chia/types/spend_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ def debug(self, agg_sig_additional_data: bytes = DEFAULT_CONSTANTS.AGG_SIG_ME_AD
# Some API still expects this name. For now, we accept both names.
#
# TODO: continue this deprecation. Eventually, all code below here should be removed.
# 1. set `exclude_modern_keys` to `False` (and manually set to `True` where necessary)
# 2. set `include_legacy_keys` to `False` (and manually set to `False` where necessary)
# 3. remove all references to `include_legacy_keys=True`
# 4. remove all code below this point
# 1. [x] set `exclude_modern_keys` to `False` (and manually set to `True` where necessary)
# 2. [ ] set `include_legacy_keys` to `False` (and manually set to `False` where necessary)
# 3. [ ] remove all references to `include_legacy_keys=True`
# 4. [ ] remove all code below this point

@classmethod
def from_json_dict(cls, json_dict: Dict[str, Any]) -> SpendBundle:
Expand All @@ -78,10 +78,10 @@ def from_json_dict(cls, json_dict: Dict[str, Any]) -> SpendBundle:
)
warnings.warn("`coin_solutions` is now `coin_spends` in `SpendBundle.from_json_dict`")
else:
raise ValueError("JSON contains both `coin_solutions` and `coin_spends`, just use `coin_spends`")
warnings.warn("JSON contains both `coin_solutions` and `coin_spends`, just use `coin_spends`")
return streamable_from_dict(cls, json_dict)

def to_json_dict(self, include_legacy_keys: bool = True, exclude_modern_keys: bool = True) -> Dict[str, Any]:
def to_json_dict(self, include_legacy_keys: bool = True, exclude_modern_keys: bool = False) -> Dict[str, Any]:
if include_legacy_keys is False and exclude_modern_keys is True:
raise ValueError("`coin_spends` not included in legacy or modern outputs")
d = recurse_jsonify(self)
Expand Down
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ markers =
testpaths = tests
filterwarnings =
error
ignore:JSON contains both `coin_solutions` and `coin_spends`, just use `coin_spends`
ignore:ssl_context is deprecated:DeprecationWarning
ignore:Implicitly cleaning up:ResourceWarning
ignore:unclosed <socket\.socket:ResourceWarning
Expand Down
2 changes: 1 addition & 1 deletion tests/core/custom_types/test_spend_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_round_trip(self):

def test_dont_use_both_legacy_and_modern(self):
json_1 = BLANK_SPEND_BUNDLE.to_json_dict(include_legacy_keys=True, exclude_modern_keys=False)
with self.assertRaises(ValueError):
with pytest.warns(UserWarning):
SpendBundle.from_json_dict(json_1)


Expand Down

0 comments on commit 3efca0d

Please sign in to comment.