def make_solution( self, condition_dic: Dict[ConditionOpcode, List[ConditionWithArgs]]) -> Program: ret = [] for con_list in condition_dic.values(): for cvp in con_list: if cvp.opcode == ConditionOpcode.CREATE_COIN: ret.append( make_create_coin_condition(cvp.vars[0], cvp.vars[1])) if cvp.opcode == ConditionOpcode.CREATE_COIN_ANNOUNCEMENT: ret.append(make_create_coin_announcement(cvp.vars[0])) if cvp.opcode == ConditionOpcode.CREATE_PUZZLE_ANNOUNCEMENT: ret.append(make_create_puzzle_announcement(cvp.vars[0])) if cvp.opcode == ConditionOpcode.AGG_SIG_UNSAFE: ret.append(make_assert_aggsig_condition(cvp.vars[0])) if cvp.opcode == ConditionOpcode.ASSERT_COIN_ANNOUNCEMENT: ret.append(make_assert_coin_announcement(cvp.vars[0])) if cvp.opcode == ConditionOpcode.ASSERT_PUZZLE_ANNOUNCEMENT: ret.append(make_assert_puzzle_announcement(cvp.vars[0])) if cvp.opcode == ConditionOpcode.ASSERT_SECONDS_ABSOLUTE: ret.append( make_assert_absolute_seconds_exceeds_condition( cvp.vars[0])) if cvp.opcode == ConditionOpcode.ASSERT_SECONDS_RELATIVE: ret.append( make_assert_relative_seconds_exceeds_condition( cvp.vars[0])) if cvp.opcode == ConditionOpcode.ASSERT_MY_COIN_ID: ret.append(make_assert_my_coin_id_condition(cvp.vars[0])) if cvp.opcode == ConditionOpcode.ASSERT_HEIGHT_ABSOLUTE: ret.append( make_assert_absolute_height_exceeds_condition( cvp.vars[0])) if cvp.opcode == ConditionOpcode.ASSERT_HEIGHT_RELATIVE: ret.append( make_assert_relative_height_exceeds_condition( cvp.vars[0])) if cvp.opcode == ConditionOpcode.RESERVE_FEE: ret.append(make_reserve_fee_condition(cvp.vars[0])) if cvp.opcode == ConditionOpcode.ASSERT_MY_PARENT_ID: ret.append(make_assert_my_parent_id(cvp.vars[0])) if cvp.opcode == ConditionOpcode.ASSERT_MY_PUZZLEHASH: ret.append(make_assert_my_puzzlehash(cvp.vars[0])) if cvp.opcode == ConditionOpcode.ASSERT_MY_AMOUNT: ret.append(make_assert_my_amount(cvp.vars[0])) return solution_for_conditions(Program.to(ret))
def make_solution( self, primaries: Optional[List[Dict[str, Any]]] = None, min_time=0, me=None, coin_announcements=None, coin_announcements_to_assert=None, puzzle_announcements=None, puzzle_announcements_to_assert=None, fee=0, ) -> Program: assert fee >= 0 condition_list = [] if primaries: for primary in primaries: condition_list.append( make_create_coin_condition(primary["puzzlehash"], primary["amount"])) if min_time > 0: condition_list.append( make_assert_absolute_seconds_exceeds_condition(min_time)) if me: condition_list.append(make_assert_my_coin_id_condition(me["id"])) if fee: condition_list.append(make_reserve_fee_condition(fee)) if coin_announcements: for announcement in coin_announcements: condition_list.append( make_create_coin_announcement(announcement)) if coin_announcements_to_assert: for announcement_hash in coin_announcements_to_assert: condition_list.append( make_assert_coin_announcement(announcement_hash)) if puzzle_announcements: for announcement in puzzle_announcements: condition_list.append( make_create_puzzle_announcement(announcement)) if puzzle_announcements_to_assert: for announcement_hash in puzzle_announcements_to_assert: condition_list.append( make_assert_puzzle_announcement(announcement_hash)) return solution_for_conditions(condition_list)