From 9533463ef2ac46bee9fcac42a54bc74399e33fc8 Mon Sep 17 00:00:00 2001 From: Geoff Walmsley Date: Fri, 3 May 2024 11:35:11 +0100 Subject: [PATCH] bump chia-blockchain 2.3.0 and minor code fixes --- cdv/cmds/chia_inspect.py | 7 ++++--- cdv/test/__init__.py | 16 +++------------- setup.py | 2 +- .../object_files/spendbundles/spendbundle.json | 2 +- tests/cmds/object_files/spends/spend.json | 2 +- tests/cmds/object_files/spends/spend_2.json | 2 +- 6 files changed, 11 insertions(+), 20 deletions(-) diff --git a/cdv/cmds/chia_inspect.py b/cdv/cmds/chia_inspect.py index 54d3b98..170b539 100644 --- a/cdv/cmds/chia_inspect.py +++ b/cdv/cmds/chia_inspect.py @@ -15,7 +15,7 @@ from chia.types.blockchain_format.program import INFINITE_COST, Program from chia.types.blockchain_format.sized_bytes import bytes32 from chia.types.coin_record import CoinRecord -from chia.types.coin_spend import CoinSpend +from chia.types.coin_spend import CoinSpend, make_spend from chia.types.generator_types import BlockGenerator from chia.types.spend_bundle import SpendBundle from chia.util.byte_types import hexstr_to_bytes @@ -164,6 +164,7 @@ def inspect_any_cmd(ctx: click.Context, objects: Tuple[str]): assert isinstance(obj, Coin) # mypy otherwise complains that obj is a str do_inspect_coin_cmd(ctx, [obj]) elif type(obj) == CoinSpend: # type: ignore[comparison-overlap] + assert isinstance(obj, CoinSpend) do_inspect_coin_spend_cmd(ctx, [obj]) elif type(obj) == SpendBundle: # type: ignore[comparison-overlap] do_inspect_spend_bundle_cmd(ctx, [obj]) @@ -272,7 +273,7 @@ def do_inspect_coin_spend_cmd( # If they specified the coin components if (not kwargs["coin"]) and all([kwargs["parent_id"], kwargs["puzzle_hash"], kwargs["amount"]]): coin_spend_objs: List[CoinSpend] = [ - CoinSpend( + make_spend( Coin( bytes32.from_hexstr(kwargs["parent_id"]), bytes32.from_hexstr(kwargs["puzzle_hash"]), @@ -285,7 +286,7 @@ def do_inspect_coin_spend_cmd( # If they specifed a coin object to parse elif kwargs["coin"]: coin_spend_objs = [ - CoinSpend( + make_spend( do_inspect_coin_cmd(ctx, [kwargs["coin"]], print_results=False)[0], parse_program(kwargs["puzzle_reveal"]), parse_program(kwargs["solution"]), diff --git a/cdv/test/__init__.py b/cdv/test/__init__.py index 6d2875d..4087f70 100644 --- a/cdv/test/__init__.py +++ b/cdv/test/__init__.py @@ -14,7 +14,7 @@ from chia.types.blockchain_format.program import Program from chia.types.blockchain_format.sized_bytes import bytes32 from chia.types.coin_record import CoinRecord -from chia.types.coin_spend import CoinSpend +from chia.types.coin_spend import CoinSpend, make_spend from chia.types.spend_bundle import SpendBundle from chia.util.condition_tools import ConditionOpcode from chia.util.hash import std_hash @@ -455,13 +455,7 @@ async def launch_smart_coin(self, source: Program, **kwargs) -> Optional[CoinWra ) spend_bundle = SpendBundle( - [ - CoinSpend( - found_coin.coin, # Coin to spend - self.puzzle, # Puzzle used for found_coin - solution, # The solution to the puzzle locking found_coin - ) - ], + [make_spend(found_coin.coin, self.puzzle, solution)], signature, ) pushed: Dict[str, Union[str, List[Coin]]] = await self.parent.push_tx(spend_bundle) @@ -535,11 +529,7 @@ async def spend_coin(self, coin: CoinWrapper, pushtx: bool = True, **kwargs) -> delegated_puzzle_solution = Program.to(kwargs["args"]) solution = delegated_puzzle_solution - solution_for_coin = CoinSpend( - coin.coin, - coin.puzzle(), - solution, - ) + solution_for_coin = make_spend(coin.coin, coin.puzzle(), solution) # The reason this use of sign_coin_spends exists is that it correctly handles # the signing for non-standard coins. I don't fully understand the difference but diff --git a/setup.py b/setup.py index 3bc1f0c..d6282f0 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ "pytest-asyncio", "pytimeparse", "anyio", - "chia-blockchain==2.2.1", + "chia-blockchain==2.3.0", ] dev_dependencies = [ diff --git a/tests/cmds/object_files/spendbundles/spendbundle.json b/tests/cmds/object_files/spendbundles/spendbundle.json index e1f569f..642b894 100644 --- a/tests/cmds/object_files/spendbundles/spendbundle.json +++ b/tests/cmds/object_files/spendbundles/spendbundle.json @@ -5,7 +5,7 @@ "parent_coin_info": "0x0000000000000000000000000000000000000000000000000000000000000000", "puzzle_hash": "0x0000000000000000000000000000000000000000000000000000000000000000"}, "puzzle_reveal": "0x01", - "solution": "80"} + "solution": "0x80"} ], "aggregated_signature": "c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" } diff --git a/tests/cmds/object_files/spends/spend.json b/tests/cmds/object_files/spends/spend.json index f44bf9d..29f151b 100644 --- a/tests/cmds/object_files/spends/spend.json +++ b/tests/cmds/object_files/spends/spend.json @@ -2,4 +2,4 @@ "parent_coin_info": "0x0000000000000000000000000000000000000000000000000000000000000000", "puzzle_hash": "0x0000000000000000000000000000000000000000000000000000000000000000"}, "puzzle_reveal": "0x01", - "solution": "ffff32ffb080df54b2a616f5c79baaed254134ae5dfc6e24e2d8e1165b251601ceb67b1886db50aacf946eb20f00adc303e7534dd0ff2480ffff32ffb080df54b2a616f5c79baaed254134ae5dfc6e24e2d8e1165b251601ceb67b1886db50aacf946eb20f00adc303e7534dd0ff248080"} + "solution": "0xffff32ffb080df54b2a616f5c79baaed254134ae5dfc6e24e2d8e1165b251601ceb67b1886db50aacf946eb20f00adc303e7534dd0ff2480ffff32ffb080df54b2a616f5c79baaed254134ae5dfc6e24e2d8e1165b251601ceb67b1886db50aacf946eb20f00adc303e7534dd0ff248080"} diff --git a/tests/cmds/object_files/spends/spend_2.json b/tests/cmds/object_files/spends/spend_2.json index a97d7b7..ec705e4 100644 --- a/tests/cmds/object_files/spends/spend_2.json +++ b/tests/cmds/object_files/spends/spend_2.json @@ -2,4 +2,4 @@ "parent_coin_info": "0x0000000000000000000000000000000000000000000000000000000000000001", "puzzle_hash": "0x0000000000000000000000000000000000000000000000000000000000000000"}, "puzzle_reveal": "0x01", - "solution": "ffff32ffb080df54b2a616f5c79baaed254134ae5dfc6e24e2d8e1165b251601ceb67b1886db50aacf946eb20f00adc303e7534dd0ff248080"} + "solution": "0xffff32ffb080df54b2a616f5c79baaed254134ae5dfc6e24e2d8e1165b251601ceb67b1886db50aacf946eb20f00adc303e7534dd0ff248080"}