Compute and reuse launcher_id (#17360)

Compute and reuse launcher_id.
This commit is contained in:
Amine Khaldi 2024-01-20 03:51:37 +01:00 committed by GitHub
parent 4ec439f789
commit 2c502dea95
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -50,12 +50,13 @@ def launcher_conditions_and_spend_bundle(
) -> Tuple[bytes32, List[Program], SpendBundle]:
launcher_puzzle_hash = launcher_puzzle.get_tree_hash()
launcher_coin = Coin(parent_coin_id, launcher_puzzle_hash, launcher_amount)
launcher_id = launcher_coin.name()
singleton_full_puzzle = SINGLETON_MOD.curry(
SINGLETON_MOD_HASH, launcher_coin.name(), launcher_puzzle_hash, initial_singleton_inner_puzzle
SINGLETON_MOD_HASH, launcher_id, launcher_puzzle_hash, initial_singleton_inner_puzzle
)
singleton_full_puzzle_hash = singleton_full_puzzle.get_tree_hash()
message_program = Program.to([singleton_full_puzzle_hash, launcher_amount, metadata])
expected_announcement = Announcement(launcher_coin.name(), message_program.get_tree_hash())
expected_announcement = Announcement(launcher_id, message_program.get_tree_hash())
expected_conditions = []
expected_conditions.append(
Program.to(
@ -70,7 +71,7 @@ def launcher_conditions_and_spend_bundle(
launcher_solution = Program.to([singleton_full_puzzle_hash, launcher_amount, metadata])
coin_spend = make_spend(launcher_coin, launcher_puzzle, launcher_solution)
spend_bundle = SpendBundle([coin_spend], G2Element())
return launcher_coin.name(), expected_conditions, spend_bundle
return launcher_id, expected_conditions, spend_bundle
def singleton_puzzle(launcher_id: Program, launcher_puzzle_hash: bytes32, inner_puzzle: Program) -> Program: