Skip to content

Commit

Permalink
wallet: Hint puzzle_utils.py (Chia-Network#15422)
Browse files Browse the repository at this point in the history
  • Loading branch information
xdustinface authored Jun 6, 2023
1 parent ebc5f3c commit b2cbea8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
16 changes: 9 additions & 7 deletions chia/wallet/puzzles/puzzle_utils.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
from __future__ import annotations

from typing import List
from typing import Any, List

from chia.types.blockchain_format.sized_bytes import bytes32
from chia.types.condition_opcodes import ConditionOpcode
from chia.util.ints import uint64


def make_create_coin_condition(puzzle_hash, amount, memos: List[bytes]) -> List:
def make_create_coin_condition(puzzle_hash: bytes32, amount: uint64, memos: List[bytes]) -> List[Any]:
condition = [ConditionOpcode.CREATE_COIN, puzzle_hash, amount]
if len(memos) > 0:
condition.append(memos)
return condition


def make_reserve_fee_condition(fee):
def make_reserve_fee_condition(fee: uint64) -> List[Any]:
return [ConditionOpcode.RESERVE_FEE, fee]


def make_assert_coin_announcement(announcement_hash):
def make_assert_coin_announcement(announcement_hash: bytes32) -> List[bytes]:
return [ConditionOpcode.ASSERT_COIN_ANNOUNCEMENT, announcement_hash]


def make_assert_puzzle_announcement(announcement_hash):
def make_assert_puzzle_announcement(announcement_hash: bytes32) -> List[bytes]:
return [ConditionOpcode.ASSERT_PUZZLE_ANNOUNCEMENT, announcement_hash]


def make_create_coin_announcement(message):
def make_create_coin_announcement(message: bytes) -> List[bytes]:
return [ConditionOpcode.CREATE_COIN_ANNOUNCEMENT, message]


def make_create_puzzle_announcement(message):
def make_create_puzzle_announcement(message: bytes) -> List[bytes]:
return [ConditionOpcode.CREATE_PUZZLE_ANNOUNCEMENT, message]
1 change: 0 additions & 1 deletion mypy-exclusions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ chia.wallet.puzzles.p2_delegated_puzzle_or_hidden_puzzle
chia.wallet.puzzles.p2_m_of_n_delegate_direct
chia.wallet.puzzles.p2_puzzle_hash
chia.wallet.puzzles.prefarm.spend_prefarm
chia.wallet.puzzles.puzzle_utils
chia.wallet.puzzles.singleton_top_layer
chia.wallet.puzzles.tails
chia.wallet.trading.trade_store
Expand Down
3 changes: 2 additions & 1 deletion tests/clvm/test_puzzles.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from chia.types.coin_spend import CoinSpend
from chia.types.spend_bundle import SpendBundle
from chia.util.hash import std_hash
from chia.util.ints import uint64
from chia.wallet.puzzles import (
p2_conditions,
p2_delegated_conditions,
Expand Down Expand Up @@ -101,7 +102,7 @@ def default_payments_and_conditions(
(throwaway_puzzle_hash(initial_index + 1, key_lookup), initial_index * 10),
(throwaway_puzzle_hash(initial_index + 2, key_lookup), (initial_index + 1) * 10),
]
conditions = Program.to([make_create_coin_condition(ph, amount, []) for ph, amount in payments])
conditions = Program.to([make_create_coin_condition(ph, uint64(amount), []) for ph, amount in payments])
return payments, conditions


Expand Down

0 comments on commit b2cbea8

Please sign in to comment.