Skip to content

Commit 7366090

Browse files
committed
Fix support for "" in PuzzleInfo/Solver
1 parent e2e21c2 commit 7366090

File tree

2 files changed

+64
-30
lines changed

2 files changed

+64
-30
lines changed

chia/_tests/cmds/wallet/test_wallet.py

Lines changed: 63 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from chia.types.signing_mode import SigningMode
3030
from chia.util.bech32m import encode_puzzle_hash
3131
from chia.wallet.conditions import Condition, ConditionValidTimes
32+
from chia.wallet.puzzle_drivers import PuzzleInfo
3233
from chia.wallet.trade_record import TradeRecord
3334
from chia.wallet.trading.offer import Offer
3435
from chia.wallet.trading.trade_status import TradeStatus
@@ -49,6 +50,7 @@
4950
CATSpend,
5051
CATSpendResponse,
5152
ClawbackPuzzleDecoratorOverride,
53+
CreateOfferForIDs,
5254
CreateOfferForIDsResponse,
5355
DeleteUnconfirmedTransactions,
5456
ExtendDerivationIndex,
@@ -79,6 +81,29 @@
7981
)
8082
from chia.wallet.wallet_spend_bundle import WalletSpendBundle
8183

84+
TEMP = PuzzleInfo(
85+
{
86+
"type": "singleton",
87+
"launcher_id": "0x0101010101010101010101010101010101010101010101010101010101010101",
88+
"launcher_ph": "0xeff07522495060c066f66f32acc2a77e3a3e737aca8baea4d1a64ea4cdc13da9",
89+
"also": {
90+
"type": "metadata",
91+
"metadata": "",
92+
"updater_hash": "0x0707070707070707070707070707070707070707070707070707070707070707",
93+
"also": {
94+
"type": "ownership",
95+
"owner": "()",
96+
"transfer_program": {
97+
"type": "royalty transfer program",
98+
"launcher_id": "0x0101010101010101010101010101010101010101010101010101010101010101",
99+
"royalty_address": "0x0303030303030303030303030303030303030303030303030303030303030303",
100+
"royalty_percentage": "1000",
101+
},
102+
},
103+
},
104+
}
105+
)
106+
82107
test_offer_file_path = importlib_resources.files(__name__.rpartition(".")[0]).joinpath("test_offer.toffer")
83108
test_offer_file_bech32 = test_offer_file_path.read_text(encoding="utf-8")
84109
test_offer_id: str = "0xdfb7e8643376820ec995b0bcdb3fc1f764c16b814df5e074631263fcf1e00839"
@@ -763,17 +788,22 @@ def test_make_offer(capsys: object, get_test_cli_clients: tuple[TestRpcClients,
763788
class MakeOfferRpcClient(TestWalletRpcClient):
764789
async def create_offer_for_ids(
765790
self,
766-
offer_dict: dict[uint32, int],
791+
request: CreateOfferForIDs,
767792
tx_config: TXConfig,
768-
driver_dict: Optional[dict[str, Any]] = None,
769-
solver: Optional[dict[str, Any]] = None,
770-
fee: uint64 = uint64(0),
771-
validate_only: bool = False,
793+
extra_conditions: tuple[Condition, ...] = tuple(),
772794
timelock_info: ConditionValidTimes = ConditionValidTimes(),
773795
) -> CreateOfferForIDsResponse:
774796
self.add_to_log(
775797
"create_offer_for_ids",
776-
(offer_dict, tx_config, driver_dict, solver, fee, validate_only, timelock_info),
798+
(
799+
request.offer,
800+
tx_config,
801+
request.driver_dict,
802+
request.solver,
803+
request.fee,
804+
request.validate_only,
805+
timelock_info,
806+
),
777807
)
778808

779809
created_offer = Offer({}, WalletSpendBundle([], G2Element()), {})
@@ -866,35 +896,39 @@ async def create_offer_for_ids(
866896
"create_offer_for_ids": [
867897
(
868898
{
869-
1: -10000000000000,
870-
3: -100000,
871-
"0404040404040404040404040404040404040404040404040404040404040404": -100000,
872-
"0202020202020202020202020202020202020202020202020202020202020202": 10000,
873-
"0101010101010101010101010101010101010101010101010101010101010101": 1,
899+
"1": "-10000000000000",
900+
"3": "-100000",
901+
"0404040404040404040404040404040404040404040404040404040404040404": "-100000",
902+
"0202020202020202020202020202020202020202020202020202020202020202": "10000",
903+
"0101010101010101010101010101010101010101010101010101010101010101": "1",
874904
},
875905
DEFAULT_TX_CONFIG.override(reuse_puzhash=True),
876906
{
877-
"0101010101010101010101010101010101010101010101010101010101010101": {
878-
"type": "singleton",
879-
"launcher_id": "0x0101010101010101010101010101010101010101010101010101010101010101",
880-
"launcher_ph": "0xeff07522495060c066f66f32acc2a77e3a3e737aca8baea4d1a64ea4cdc13da9",
881-
"also": {
882-
"type": "metadata",
883-
"metadata": "",
884-
"updater_hash": "0x0707070707070707070707070707070707070707070707070707070707070707",
907+
bytes32([1] * 32): PuzzleInfo(
908+
{
909+
"type": "singleton",
910+
"launcher_id": "0x0101010101010101010101010101010101010101010101010101010101010101",
911+
"launcher_ph": "0xeff07522495060c066f66f32acc2a77e3a3e737aca8baea4d1a64ea4cdc13da9",
885912
"also": {
886-
"type": "ownership",
887-
"owner": "()",
888-
"transfer_program": {
889-
"type": "royalty transfer program",
890-
"launcher_id": "0x0101010101010101010101010101010101010101010101010101010101010101",
891-
"royalty_address": "0x0303030303030303030303030303030303030303030"
892-
"303030303030303030303",
893-
"royalty_percentage": "1000",
913+
"type": "metadata",
914+
"metadata": "",
915+
"updater_hash": "0x0707070707070707070707070707070707070707070707070707070707070707",
916+
"also": {
917+
"type": "ownership",
918+
"owner": "()",
919+
"transfer_program": {
920+
"type": "royalty transfer program",
921+
"launcher_id": (
922+
"0x0101010101010101010101010101010101010101010101010101010101010101"
923+
),
924+
"royalty_address": "0x0303030303030303030303030303030303030303030"
925+
"303030303030303030303",
926+
"royalty_percentage": "1000",
927+
},
894928
},
895929
},
896-
},
897-
}
930+
}
931+
)
898932
},
899933
None,
900934
500000000000,

chia/wallet/puzzle_drivers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def decode_info_value(cls: Any, value: Any) -> Any:
129129
elif isinstance(value, Program) and value.atom is None:
130130
return value
131131
else:
132-
if value == "()": # special case
132+
if value in {"()", ""}: # special case
133133
return Program.to([])
134134
expression: SExp = assemble(value)
135135
if expression.atom is None:

0 commit comments

Comments
 (0)