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

CHIA-1472 Augment get_mirror_info to accept both types of programs #18637

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 1 addition & 3 deletions chia/data_layer/data_layer_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,9 +808,7 @@ async def coin_added(self, coin: Coin, height: uint32, peer: WSChiaConnection, c
)[0]
parent_spend = await fetch_coin_spend(height, parent_state.coin, peer)
assert parent_spend is not None
launcher_id, urls = get_mirror_info(
parent_spend.puzzle_reveal.to_program(), parent_spend.solution.to_program()
)
launcher_id, urls = get_mirror_info(parent_spend.puzzle_reveal, parent_spend.solution)
# Don't track mirrors with empty url list.
if not urls:
return
Expand Down
9 changes: 6 additions & 3 deletions chia/wallet/db_wallet/db_wallet_puzzles.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Iterator, List, Tuple, Union

from chia.types.blockchain_format.program import Program
from chia.types.blockchain_format.program import INFINITE_COST, Program
from chia.types.blockchain_format.serialized_program import SerializedProgram
from chia.types.blockchain_format.sized_bytes import bytes32
from chia.types.condition_opcodes import ConditionOpcode
Expand Down Expand Up @@ -94,8 +94,11 @@ def create_mirror_puzzle() -> Program:
MIRROR_PUZZLE_HASH = create_mirror_puzzle().get_tree_hash()


def get_mirror_info(parent_puzzle: Program, parent_solution: Program) -> Tuple[bytes32, List[bytes]]:
conditions = parent_puzzle.run(parent_solution)
def get_mirror_info(
parent_puzzle: Union[Program, SerializedProgram], parent_solution: Union[Program, SerializedProgram]
) -> Tuple[bytes32, List[bytes]]:
assert type(parent_puzzle) is type(parent_solution)
_, conditions = parent_puzzle.run_with_cost(INFINITE_COST, parent_solution)
Starttoaster marked this conversation as resolved.
Show resolved Hide resolved
for condition in conditions.as_iter():
if (
condition.first().as_python() == ConditionOpcode.CREATE_COIN
Expand Down
Loading