Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
altendky committed May 16, 2024
1 parent 1401d9d commit 4315b6b
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 30 deletions.
2 changes: 2 additions & 0 deletions chia/_tests/wallet/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ async def track_coin_state(*args: Any) -> bool:
msg = bytes([0] * 10001)
AMOUNT = uint64(750000000000)
FEE = uint64(0)
else:
raise Exception(f"Unhandled case: {case!r}")
peak = full_node_api.full_node.blockchain.get_peak()
assert peak is not None
if case == "allow":
Expand Down
3 changes: 3 additions & 0 deletions chia/rpc/wallet_rpc_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,9 @@ async def create_new_wallet(
uint64(request.get("filter_amount", 1)),
name,
)
else:
raise Exception(f"Invalid DAO wallet mode: {mode!r}")

return {
"success": True,
"type": dao_wallet.type(),
Expand Down
3 changes: 3 additions & 0 deletions chia/wallet/cat_wallet/cat_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,9 @@ async def generate_unsigned_spendbundle(
primaries=primaries,
conditions=(*extra_conditions, xch_announcement, announcement),
)
else:
# TODO: what about when they are equal?
raise Exception("Equality not handled")
else:
innersol = self.standard_wallet.make_solution(
primaries=primaries,
Expand Down
3 changes: 3 additions & 0 deletions chia/wallet/dao_wallet/dao_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,9 @@ async def create_proposal_close_spend(
treasury_inner_puzhash = self.dao_info.current_treasury_innerpuz.get_tree_hash()
delegated_solution = Program.to([])

else:
raise Exception(f"Unknown proposal type: {proposal_type!r}")

treasury_solution = Program.to(
[
[proposal_info.current_coin.name(), PROPOSED_PUZ_HASH.as_atom(), 0],
Expand Down
55 changes: 27 additions & 28 deletions chia/wallet/nft_wallet/nft_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1392,40 +1392,39 @@ async def mint_from_did(
# Create the xch spend to fund the minting.
spend_value = sum([coin.amount for coin in xch_coins])
change: uint64 = uint64(spend_value - total_amount)
xch_spends = []
if xch_change_ph is None:
xch_change_ph = await self.standard_wallet.get_new_puzzlehash()
xch_payment = Payment(xch_change_ph, change, [xch_change_ph])

first = True
for xch_coin in xch_coins:
puzzle: Program = await self.standard_wallet.puzzle_for_puzzle_hash(xch_coin.puzzle_hash)
if first:
message_list: List[bytes32] = [c.name() for c in xch_coins]
message_list.append(Coin(xch_coin.name(), xch_payment.puzzle_hash, xch_payment.amount).name())
message: bytes32 = std_hash(b"".join(message_list))
xch_coins_iter = iter(xch_coins)
xch_coin = next(xch_coins_iter)

xch_extra_conditions: Tuple[Condition, ...] = (
AssertCoinAnnouncement(asserted_id=did_coin.name(), asserted_msg=message),
)
if len(xch_coins) > 1:
xch_extra_conditions += (CreateCoinAnnouncement(message),)
message_list: List[bytes32] = [c.name() for c in xch_coins]
message_list.append(Coin(xch_coin.name(), xch_payment.puzzle_hash, xch_payment.amount).name())
message: bytes32 = std_hash(b"".join(message_list))

solution: Program = self.standard_wallet.make_solution(
primaries=[xch_payment],
fee=fee,
conditions=xch_extra_conditions,
)
primary_announcement_hash = AssertCoinAnnouncement(
asserted_id=xch_coin.name(), asserted_msg=message
).msg_calc
# connect this coin assertion to the DID announcement
did_coin_announcement = CreateCoinAnnouncement(message)
first = False
else:
solution = self.standard_wallet.make_solution(
primaries=[], conditions=(AssertCoinAnnouncement(primary_announcement_hash),)
)
xch_extra_conditions: Tuple[Condition, ...] = (
AssertCoinAnnouncement(asserted_id=did_coin.name(), asserted_msg=message),
)
if len(xch_coins) > 1:
xch_extra_conditions += (CreateCoinAnnouncement(message),)

solution: Program = self.standard_wallet.make_solution(
primaries=[xch_payment],
fee=fee,
conditions=xch_extra_conditions,
)
primary_announcement_hash = AssertCoinAnnouncement(asserted_id=xch_coin.name(), asserted_msg=message).msg_calc
# connect this coin assertion to the DID announcement
did_coin_announcement = CreateCoinAnnouncement(message)
puzzle = await self.standard_wallet.puzzle_for_puzzle_hash(xch_coin.puzzle_hash)
xch_spends = [make_spend(xch_coin, puzzle, solution)]

for xch_coin in xch_coins_iter:
puzzle = await self.standard_wallet.puzzle_for_puzzle_hash(xch_coin.puzzle_hash)
solution = self.standard_wallet.make_solution(
primaries=[], conditions=(AssertCoinAnnouncement(primary_announcement_hash),)
)
xch_spends.append(make_spend(xch_coin, puzzle, solution))
xch_spend = SpendBundle(xch_spends, G2Element())

Expand Down
7 changes: 5 additions & 2 deletions chia/wallet/util/debug_spend_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ def debug_spend_bundle(spend_bundle, agg_sig_additional_data=DEFAULT_CONSTANTS.A
for c in condition_programs:
if len(c.vars) == 0:
as_prog = Program.to([c.opcode])
if len(c.vars) == 1:
elif len(c.vars) == 1:
as_prog = Program.to([c.opcode, c.vars[0]])
if len(c.vars) == 2:
elif len(c.vars) == 2:
if c.opcode == ConditionOpcode.CREATE_COIN:
cc = next(
cc
Expand All @@ -136,6 +136,9 @@ def debug_spend_bundle(spend_bundle, agg_sig_additional_data=DEFAULT_CONSTANTS.A
as_prog = Program.to([c.opcode, c.vars[0], c.vars[1]])
else:
as_prog = Program.to([c.opcode, c.vars[0], c.vars[1]])
else:
raise Exception(f"Unexpected number of vars: {len(c.vars)}")

print(f" {disassemble(as_prog)}")
created_coin_announcements.extend(
[coin_name] + _.vars for _ in conditions.get(ConditionOpcode.CREATE_COIN_ANNOUNCEMENT, [])
Expand Down
3 changes: 3 additions & 0 deletions chia/wallet/vc_wallet/cr_cat_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,9 @@ async def _generate_unsigned_spendbundle(
primaries=primaries,
conditions=(*extra_conditions, xch_announcement, announcement),
)
else:
# TODO: what about when they are equal?
raise Exception("Equality not handled")
else:
innersol = self.standard_wallet.make_solution(
primaries=primaries,
Expand Down

0 comments on commit 4315b6b

Please sign in to comment.