mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2026-08-24 10:05:29 -05:00
[LABS-151] Replace NIL with Program.NIL (#20189)
Replace `NIL` with `Program.NIL`
This commit is contained in:
@@ -10,7 +10,7 @@ from chia_rs.sized_ints import uint16, uint32, uint64
|
||||
|
||||
from chia._tests.cmds.cmd_test_utils import TestRpcClients, TestWalletRpcClient, logType, run_cli_command_and_assert
|
||||
from chia._tests.cmds.wallet.test_consts import FINGERPRINT_ARG, STD_TX, STD_UTX, get_bytes32
|
||||
from chia.types.blockchain_format.program import NIL, Program
|
||||
from chia.types.blockchain_format.program import Program
|
||||
from chia.types.signing_mode import SigningMode
|
||||
from chia.util.bech32m import encode_puzzle_hash
|
||||
from chia.wallet.conditions import Condition, ConditionValidTimes, CreateCoinAnnouncement, CreatePuzzleAnnouncement
|
||||
@@ -42,7 +42,7 @@ test_condition_valid_times: ConditionValidTimes = ConditionValidTimes(min_time=u
|
||||
argnames=["program", "result"],
|
||||
argvalues=[
|
||||
(Program.to(NIL_TREEHASH), True),
|
||||
(NIL, True),
|
||||
(Program.NIL, True),
|
||||
(Program.to(bytes32([1] * 32)), False),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -19,7 +19,7 @@ from chia._tests.environments.wallet import (
|
||||
from chia._tests.util.time_out_assert import time_out_assert, time_out_assert_not_none
|
||||
from chia.simulator.simulator_protocol import ReorgProtocol
|
||||
from chia.types.blockchain_format.coin import Coin, coin_as_list
|
||||
from chia.types.blockchain_format.program import NIL, Program
|
||||
from chia.types.blockchain_format.program import Program
|
||||
from chia.types.coin_spend import make_spend
|
||||
from chia.util.bech32m import encode_puzzle_hash
|
||||
from chia.util.db_wrapper import DBWrapper2
|
||||
@@ -82,7 +82,9 @@ async def mint_cat(
|
||||
1,
|
||||
[
|
||||
CreateCoin(wrapped_inner_puzzle_hash, amount, memos=[inner_puzzle_hash]).to_program(),
|
||||
UnknownCondition(opcode=Program.to(51), args=[NIL, Program.to(-113), tail, NIL]).to_program(),
|
||||
UnknownCondition(
|
||||
opcode=Program.to(51), args=[Program.NIL, Program.to(-113), tail, Program.NIL]
|
||||
).to_program(),
|
||||
],
|
||||
)
|
||||
)
|
||||
@@ -112,7 +114,7 @@ async def mint_cat(
|
||||
cat_addition,
|
||||
tail_hash,
|
||||
eve_inner_puzzle,
|
||||
NIL,
|
||||
Program.NIL,
|
||||
)
|
||||
],
|
||||
)
|
||||
@@ -1411,7 +1413,7 @@ async def test_cat_change_detection(wallet_environments: WalletTestFramework, wa
|
||||
if wallet_type is RCATWallet:
|
||||
inner_puzhash = create_revocation_layer(bytes32.zeros, inner_puzhash).get_tree_hash()
|
||||
puzzlehash_unhardened = construct_cat_puzzle(
|
||||
CAT_MOD, Program.to(None).get_tree_hash(), inner_puzhash
|
||||
CAT_MOD, Program.NIL.get_tree_hash(), inner_puzhash
|
||||
).get_tree_hash_precalc(inner_puzhash)
|
||||
change_derivation = DerivationRecord(
|
||||
uint32(0), puzzlehash_unhardened, pubkey_unhardened, WalletType.CAT, uint32(2), False
|
||||
@@ -1422,7 +1424,7 @@ async def test_cat_change_detection(wallet_environments: WalletTestFramework, wa
|
||||
our_puzzle = await action_scope.get_puzzle(wallet.wallet_state_manager)
|
||||
cat_puzzle = construct_cat_puzzle(
|
||||
CAT_MOD,
|
||||
Program.to(None).get_tree_hash(),
|
||||
Program.NIL.get_tree_hash(),
|
||||
Program.to(1),
|
||||
)
|
||||
addr = encode_puzzle_hash(cat_puzzle.get_tree_hash(), "txch")
|
||||
@@ -1451,7 +1453,7 @@ async def test_cat_change_detection(wallet_environments: WalletTestFramework, wa
|
||||
cat_coin = next(c for c in spend_bundle.additions() if c.amount == cat_amount_0)
|
||||
next_coin = Coin(
|
||||
cat_coin.name(),
|
||||
construct_cat_puzzle(CAT_MOD, Program.to(None).get_tree_hash(), our_puzzle).get_tree_hash(),
|
||||
construct_cat_puzzle(CAT_MOD, Program.NIL.get_tree_hash(), our_puzzle).get_tree_hash(),
|
||||
cat_amount_0,
|
||||
)
|
||||
eve_spend, _ = await wsm.sign_bundle(
|
||||
@@ -1478,7 +1480,7 @@ async def test_cat_change_detection(wallet_environments: WalletTestFramework, wa
|
||||
),
|
||||
make_spend(
|
||||
next_coin,
|
||||
construct_cat_puzzle(CAT_MOD, Program.to(None).get_tree_hash(), our_puzzle),
|
||||
construct_cat_puzzle(CAT_MOD, Program.NIL.get_tree_hash(), our_puzzle),
|
||||
Program.to(
|
||||
[
|
||||
[
|
||||
@@ -1660,7 +1662,7 @@ async def test_cat_melt_balance(wallet_environments: WalletTestFramework) -> Non
|
||||
conditions=(
|
||||
UnknownCondition(
|
||||
opcode=Program.to(51),
|
||||
args=[Program.to(None), Program.to(-113), Program.to(ACS_TAIL), Program.to(None)],
|
||||
args=[Program.NIL, Program.to(-113), Program.to(ACS_TAIL), Program.NIL],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -31,7 +31,7 @@ ACS = Program.fromhex(
|
||||
)
|
||||
ACS_PH = ACS.get_tree_hash()
|
||||
|
||||
NIL_PH = Program.to(None).get_tree_hash()
|
||||
NIL_PH = Program.NIL.get_tree_hash()
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
|
||||
@@ -16,7 +16,6 @@ from chia.wallet.uncurried_puzzle import uncurry_puzzle
|
||||
|
||||
def test_ownership_outer_puzzle() -> None:
|
||||
ACS = Program.to(1)
|
||||
NIL = Program.to([])
|
||||
owner = bytes32.zeros
|
||||
# (mod (current_owner conditions solution)
|
||||
# (list current_owner () conditions)
|
||||
@@ -28,7 +27,7 @@ def test_ownership_outer_puzzle() -> None:
|
||||
)
|
||||
transfer_program_default: Program = puzzle_for_transfer_program(bytes32([1] * 32), bytes32([2] * 32), uint16(5000))
|
||||
ownership_puzzle: Program = puzzle_for_ownership_layer(owner, Program.to(transfer_program), ACS)
|
||||
ownership_puzzle_empty: Program = puzzle_for_ownership_layer(NIL, Program.to(transfer_program), ACS)
|
||||
ownership_puzzle_empty: Program = puzzle_for_ownership_layer(Program.NIL, Program.to(transfer_program), ACS)
|
||||
ownership_puzzle_default: Program = puzzle_for_ownership_layer(owner, transfer_program_default, ACS)
|
||||
ownership_driver: Optional[PuzzleInfo] = match_puzzle(uncurry_puzzle(ownership_puzzle))
|
||||
ownership_driver_empty: Optional[PuzzleInfo] = match_puzzle(uncurry_puzzle(ownership_puzzle_empty))
|
||||
@@ -41,7 +40,7 @@ def test_ownership_outer_puzzle() -> None:
|
||||
assert transfer_program_driver is not None
|
||||
assert ownership_driver.type() == "ownership"
|
||||
assert ownership_driver["owner"] == owner
|
||||
assert ownership_driver_empty["owner"] == NIL
|
||||
assert ownership_driver_empty["owner"] == Program.NIL
|
||||
assert ownership_driver["transfer_program"] == transfer_program
|
||||
assert ownership_driver_default["transfer_program"] == transfer_program_driver
|
||||
assert transfer_program_driver.type() == "royalty transfer program"
|
||||
|
||||
@@ -3130,7 +3130,7 @@ async def test_cat_spend_run_tail(wallet_rpc_environment: WalletRpcTestEnvironme
|
||||
# Send to a CAT with an anyone can spend TAIL
|
||||
async with env.wallet_1.wallet.wallet_state_manager.new_action_scope(DEFAULT_TX_CONFIG, push=True) as action_scope:
|
||||
our_ph = await action_scope.get_puzzle_hash(env.wallet_1.wallet.wallet_state_manager)
|
||||
cat_puzzle: Program = construct_cat_puzzle(CAT_MOD, Program.to(None).get_tree_hash(), Program.to(1))
|
||||
cat_puzzle: Program = construct_cat_puzzle(CAT_MOD, Program.NIL.get_tree_hash(), Program.to(1))
|
||||
addr = encode_puzzle_hash(
|
||||
cat_puzzle.get_tree_hash(),
|
||||
"txch",
|
||||
@@ -3175,7 +3175,7 @@ async def test_cat_spend_run_tail(wallet_rpc_environment: WalletRpcTestEnvironme
|
||||
await farm_transaction(full_node_api, wallet_node, eve_spend)
|
||||
|
||||
# Make sure we have the CAT
|
||||
res = await client.create_wallet_for_existing_cat(Program.to(None).get_tree_hash())
|
||||
res = await client.create_wallet_for_existing_cat(Program.NIL.get_tree_hash())
|
||||
assert res["success"]
|
||||
cat_wallet_id = res["wallet_id"]
|
||||
await time_out_assert(20, get_confirmed_balance, tx_amount, client, cat_wallet_id)
|
||||
|
||||
@@ -285,9 +285,7 @@ class TimelockInfo:
|
||||
],
|
||||
)
|
||||
def test_timelock_parsing(timelock_info: TimelockInfo) -> None:
|
||||
assert timelock_info.parsed_info == parse_timelock_info(
|
||||
[UnknownCondition(Program.to(None), []), *timelock_info.drivers]
|
||||
)
|
||||
assert timelock_info.parsed_info == parse_timelock_info([UnknownCondition(Program.NIL, []), *timelock_info.drivers])
|
||||
assert timelock_info.parsed_info.to_conditions() == (
|
||||
timelock_info.conditions_after if timelock_info.conditions_after is not None else timelock_info.drivers
|
||||
)
|
||||
|
||||
@@ -50,7 +50,7 @@ def test_debug_spend_bundle(capsys: pytest.CaptureFixture[str]) -> None:
|
||||
make_spend(
|
||||
coin_bad_reveal,
|
||||
ACS,
|
||||
Program.to(None),
|
||||
Program.NIL,
|
||||
),
|
||||
make_spend(
|
||||
coin,
|
||||
@@ -60,7 +60,7 @@ def test_debug_spend_bundle(capsys: pytest.CaptureFixture[str]) -> None:
|
||||
make_spend(
|
||||
child_coin,
|
||||
ACS,
|
||||
Program.to(None),
|
||||
Program.NIL,
|
||||
),
|
||||
],
|
||||
sig,
|
||||
|
||||
@@ -135,7 +135,7 @@ async def test_p2dohp_wallet_signer_protocol(wallet_environments: WalletTestFram
|
||||
async with wallet.wallet_state_manager.new_action_scope(wallet_environments.tx_config, push=False) as action_scope:
|
||||
[coin] = await wallet.select_coins(uint64(0), action_scope)
|
||||
puzzle: Program = await wallet.puzzle_for_puzzle_hash(coin.puzzle_hash)
|
||||
delegated_puzzle: Program = Program.to(None)
|
||||
delegated_puzzle: Program = Program.NIL
|
||||
delegated_puzzle_hash: bytes32 = delegated_puzzle.get_tree_hash()
|
||||
solution: Program = Program.to([None, None, None])
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ def test_list_to_binary_tree() -> None:
|
||||
@pytest.mark.parametrize(
|
||||
"serializations",
|
||||
[
|
||||
(tuple(), Program.to(None), []),
|
||||
(tuple(), Program.NIL, []),
|
||||
((bytes32.zeros,), Program.to([bytes32.zeros]), [LineageProofField.PARENT_NAME]),
|
||||
(
|
||||
(bytes32.zeros, bytes32.zeros),
|
||||
@@ -129,7 +129,7 @@ def test_lineage_proof_varargs(serializations: tuple[tuple[Any, ...], Program, l
|
||||
@pytest.mark.parametrize(
|
||||
"serializations",
|
||||
[
|
||||
({}, Program.to(None), []),
|
||||
({}, Program.NIL, []),
|
||||
({"parent_name": bytes32.zeros}, Program.to([bytes32.zeros]), [LineageProofField.PARENT_NAME]),
|
||||
(
|
||||
{"parent_name": bytes32.zeros, "inner_puzzle_hash": bytes32.zeros},
|
||||
|
||||
@@ -22,7 +22,7 @@ from chia.wallet.vc_wallet.cr_cat_drivers import construct_cr_layer
|
||||
|
||||
def test_cat_outer_puzzle() -> None:
|
||||
authorized_providers: list[bytes32] = [bytes32.zeros, bytes32.zeros]
|
||||
proofs_checker: Program = Program.to(None)
|
||||
proofs_checker: Program = Program.NIL
|
||||
ACS: Program = Program.to(1)
|
||||
cr_puzzle: Program = construct_cr_layer(authorized_providers, proofs_checker, ACS)
|
||||
double_cr_puzzle: Program = construct_cr_layer(authorized_providers, proofs_checker, cr_puzzle)
|
||||
|
||||
@@ -117,7 +117,7 @@ async def test_covenant_layer(cost_logger: CostLogger) -> None:
|
||||
inner_puzzle_hash=ACS_PH,
|
||||
amount=uint64(acs_coin.amount),
|
||||
),
|
||||
Program.to(None),
|
||||
Program.NIL,
|
||||
Program.to([[51, covenant_puzzle_hash, acs_coin.amount]]),
|
||||
),
|
||||
),
|
||||
@@ -139,7 +139,7 @@ async def test_covenant_layer(cost_logger: CostLogger) -> None:
|
||||
covenant_puzzle,
|
||||
solve_covenant_layer(
|
||||
LineageProof(parent_name=parent.parent_coin_info, amount=uint64(parent.amount)),
|
||||
Program.to(None),
|
||||
Program.NIL,
|
||||
Program.to([[51, covenant_puzzle_hash, cov.amount]]),
|
||||
),
|
||||
),
|
||||
@@ -173,7 +173,7 @@ async def test_covenant_layer(cost_logger: CostLogger) -> None:
|
||||
inner_puzzle_hash=ACS_PH,
|
||||
amount=uint64(acs_cov.amount),
|
||||
),
|
||||
Program.to(None),
|
||||
Program.NIL,
|
||||
Program.to([[51, covenant_puzzle_hash, new_acs_cov.amount]]),
|
||||
),
|
||||
),
|
||||
@@ -335,7 +335,7 @@ async def test_revocation_layer(cost_logger: CostLogger) -> None:
|
||||
p2_either_puzzle,
|
||||
solve_revocation_layer(
|
||||
ACS,
|
||||
Program.to(None),
|
||||
Program.NIL,
|
||||
hidden=True,
|
||||
),
|
||||
)
|
||||
@@ -616,16 +616,16 @@ async def test_vc_lifecycle(test_syncing: bool, cost_logger: CostLogger) -> None
|
||||
dpuz_1, launch_crcat_spend_1, cr_1 = CRCAT.launch(
|
||||
cr_coin_1,
|
||||
CreateCoin(ACS_PH, uint64(cr_coin_1.amount)),
|
||||
Program.to(None),
|
||||
Program.to(None),
|
||||
Program.NIL,
|
||||
Program.NIL,
|
||||
AUTHORIZED_PROVIDERS,
|
||||
proofs_checker.as_program(),
|
||||
)
|
||||
dpuz_2, launch_crcat_spend_2, cr_2 = CRCAT.launch(
|
||||
cr_coin_2,
|
||||
CreateCoin(ACS_PH, uint64(cr_coin_2.amount)),
|
||||
Program.to(None),
|
||||
Program.to(None),
|
||||
Program.NIL,
|
||||
Program.NIL,
|
||||
AUTHORIZED_PROVIDERS,
|
||||
proofs_checker.as_program(),
|
||||
)
|
||||
@@ -700,7 +700,7 @@ async def test_vc_lifecycle(test_syncing: bool, cost_logger: CostLogger) -> None
|
||||
),
|
||||
],
|
||||
NEW_PROOFS if error != "use_malicious_cats" else MALICIOUS_PROOFS,
|
||||
Program.to(None),
|
||||
Program.NIL,
|
||||
launcher_id,
|
||||
vc.launcher_id,
|
||||
vc.wrap_inner_with_backdoor().get_tree_hash(),
|
||||
|
||||
@@ -55,7 +55,7 @@ async def mint_cr_cat(
|
||||
full_node_api: FullNodeSimulator,
|
||||
tx_config: TXConfig,
|
||||
authorized_providers: list[bytes32] = [],
|
||||
tail: Program = Program.to(None),
|
||||
tail: Program = Program.NIL,
|
||||
proofs_checker: ProofsChecker = ProofsChecker(["foo", "bar"]),
|
||||
) -> None:
|
||||
async with wallet_0.wallet_state_manager.new_action_scope(tx_config, push=True) as action_scope:
|
||||
@@ -849,7 +849,7 @@ async def test_cat_wallet_conversion(
|
||||
|
||||
# Key point of test: create a normal CAT wallet first, and see if it gets converted to CR-CAT wallet
|
||||
await CATWallet.get_or_create_wallet_for_cat(
|
||||
wallet_node_0.wallet_state_manager, wallet_0, Program.to(None).get_tree_hash().hex()
|
||||
wallet_node_0.wallet_state_manager, wallet_0, Program.NIL.get_tree_hash().hex()
|
||||
)
|
||||
|
||||
did_id = bytes32.zeros
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import io
|
||||
from typing import TYPE_CHECKING, Any, Callable, Optional, TypeVar, Union
|
||||
from typing import TYPE_CHECKING, Any, Callable, ClassVar, Optional, TypeVar, Union
|
||||
|
||||
from chia_rs import MEMPOOL_MODE, run_chia_program, tree_hash
|
||||
from chia_rs.sized_bytes import bytes32
|
||||
@@ -30,6 +30,8 @@ class Program(SExp):
|
||||
A thin wrapper around s-expression data intended to be invoked with "eval".
|
||||
"""
|
||||
|
||||
NIL: ClassVar[Program]
|
||||
|
||||
@classmethod
|
||||
def parse(cls, f) -> Self:
|
||||
return sexp_from_stream(f, cls.to)
|
||||
@@ -247,7 +249,7 @@ def _tree_hash(node: SExp, precalculated: set[bytes32]) -> bytes32:
|
||||
return bytes32(std_hash(s))
|
||||
|
||||
|
||||
NIL = Program.from_bytes(b"\x80")
|
||||
Program.NIL = Program.to(None)
|
||||
|
||||
|
||||
# real return type is more like Union[T_Program, CastableType] when considering corner and terminal cases
|
||||
|
||||
@@ -683,7 +683,7 @@ class CATWallet:
|
||||
cat_condition = UnknownCondition(
|
||||
opcode=Program.to(51),
|
||||
args=[
|
||||
Program.to(None),
|
||||
Program.NIL,
|
||||
Program.to(-113),
|
||||
tail_reveal,
|
||||
tail_solution,
|
||||
|
||||
@@ -245,7 +245,7 @@ class CreateCoin(Condition):
|
||||
uint64(program.at("rrf").as_int()),
|
||||
(
|
||||
None
|
||||
if potential_memos == Program.to(None)
|
||||
if potential_memos == Program.NIL
|
||||
else [memo.as_atom() for memo in potential_memos.at("f").as_iter()]
|
||||
),
|
||||
)
|
||||
@@ -966,9 +966,7 @@ class UnknownCondition(Condition):
|
||||
|
||||
@classmethod
|
||||
def from_program(cls, program: Program) -> UnknownCondition:
|
||||
return cls(
|
||||
program.at("f"), [] if program.at("r") == Program.to(None) else [p for p in program.at("r").as_iter()]
|
||||
)
|
||||
return cls(program.at("f"), [] if program.at("r") == Program.NIL else [p for p in program.at("r").as_iter()])
|
||||
|
||||
|
||||
# Abstractions
|
||||
|
||||
@@ -8,7 +8,7 @@ from chia_rs.sized_bytes import bytes32
|
||||
from chia_rs.sized_ints import uint16, uint64
|
||||
|
||||
from chia.types.blockchain_format.coin import Coin
|
||||
from chia.types.blockchain_format.program import NIL, Program
|
||||
from chia.types.blockchain_format.program import Program
|
||||
from chia.util.streamable import Streamable, streamable
|
||||
from chia.wallet.lineage_proof import LineageProof
|
||||
from chia.wallet.util.curry_and_treehash import NIL_TREEHASH
|
||||
@@ -16,7 +16,7 @@ from chia.wallet.util.curry_and_treehash import NIL_TREEHASH
|
||||
|
||||
def did_recovery_is_nil(recovery_program: Program) -> bool:
|
||||
# cannot use set as not hashable
|
||||
if recovery_program in (NIL, NIL_TREEHASH): # noqa: PLR6201
|
||||
if recovery_program in (Program.NIL, NIL_TREEHASH): # noqa: PLR6201
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
@@ -381,9 +381,7 @@ class DIDWallet:
|
||||
p2_puzzle, recovery_list_hash, num_verification, singleton_struct, metadata = did_curried_args
|
||||
did_data = DIDCoinData(
|
||||
p2_puzzle=p2_puzzle,
|
||||
recovery_list_hash=bytes32(recovery_list_hash.as_atom())
|
||||
if recovery_list_hash != Program.to(None)
|
||||
else None,
|
||||
recovery_list_hash=bytes32(recovery_list_hash.as_atom()) if recovery_list_hash != Program.NIL else None,
|
||||
num_verification=uint16(num_verification.as_int()),
|
||||
singleton_struct=singleton_struct,
|
||||
metadata=metadata,
|
||||
|
||||
@@ -77,4 +77,4 @@ class TransferProgramPuzzle:
|
||||
return None
|
||||
|
||||
def solve(self, constructor: PuzzleInfo, solver: Solver, inner_puzzle: Program, inner_solution: Program) -> Program:
|
||||
return Program.to(None)
|
||||
return Program.NIL
|
||||
|
||||
@@ -96,7 +96,7 @@ class NotificationManager:
|
||||
notification_spend = make_spend(
|
||||
notification_coin,
|
||||
notification_puzzle,
|
||||
Program.to(None),
|
||||
Program.NIL,
|
||||
)
|
||||
extra_spend_bundle = WalletSpendBundle([notification_spend], G2Element())
|
||||
await self.wallet_state_manager.main_wallet.generate_signed_transaction(
|
||||
|
||||
@@ -56,7 +56,7 @@ def compute_spend_hints_and_additions(
|
||||
coin: Coin = Coin(cs.coin.name(), bytes32(rf), uint64(condition.at("rrf").as_int()))
|
||||
hint: Optional[bytes32] = None
|
||||
if (
|
||||
condition.at("rrr") != Program.to(None) # There's more than two arguments
|
||||
condition.at("rrr") != Program.NIL # There's more than two arguments
|
||||
and condition.at("rrrf").atom is None # The 3rd argument is a cons
|
||||
):
|
||||
potential_hint: Optional[bytes] = condition.at("rrrff").atom
|
||||
|
||||
@@ -65,7 +65,7 @@ CREDENTIAL_STRUCT: Program = Program.to(
|
||||
curry_and_treehash(
|
||||
Program.to((1, EXTIGENT_METADATA_LAYER_HASH)).get_tree_hash_precalc(EXTIGENT_METADATA_LAYER_HASH),
|
||||
Program.to(EXTIGENT_METADATA_LAYER_HASH).get_tree_hash(),
|
||||
Program.to(None).get_tree_hash(),
|
||||
Program.NIL.get_tree_hash(),
|
||||
GUARANTEED_NIL_TP_HASH,
|
||||
Program.to(GUARANTEED_NIL_TP_HASH).get_tree_hash(),
|
||||
P2_ANNOUNCED_DELEGATED_PUZZLE_HASH,
|
||||
@@ -615,7 +615,7 @@ class CRCATSpend:
|
||||
inner_puzzle,
|
||||
inner_solution,
|
||||
CRCAT.get_next_from_coin_spend(spend, conditions=inner_conditions),
|
||||
Program.from_serialized(spend.solution).at("f").at("rrrrf") == Program.to(None),
|
||||
Program.from_serialized(spend.solution).at("f").at("rrrrf") == Program.NIL,
|
||||
list(inner_conditions.as_iter()),
|
||||
Program.from_serialized(spend.solution).at("f").at("f"),
|
||||
)
|
||||
@@ -628,7 +628,7 @@ class ProofsChecker(Streamable):
|
||||
|
||||
def as_program(self) -> Program:
|
||||
def byte_sort_flags(f1: str, f2: str) -> int:
|
||||
return 1 if Program.to([10, (1, f1), (1, f2)]).run([]) == Program.to(None) else -1
|
||||
return 1 if Program.to([10, (1, f1), (1, f2)]).run([]) == Program.NIL else -1
|
||||
|
||||
return PROOF_FLAGS_CHECKER.curry(
|
||||
[
|
||||
|
||||
@@ -502,7 +502,7 @@ class CRCATWallet(CATWallet):
|
||||
cat_condition = UnknownCondition(
|
||||
opcode=Program.to(51),
|
||||
args=[
|
||||
Program.to(None),
|
||||
Program.NIL,
|
||||
Program.to(-113),
|
||||
tail_reveal,
|
||||
tail_solution,
|
||||
@@ -583,7 +583,7 @@ class CRCATWallet(CATWallet):
|
||||
expected_announcements, coin_spends, _ = CRCAT.spend_many(
|
||||
inner_spends,
|
||||
proof_of_inclusions,
|
||||
Program.to(None), # TODO: With more proofs checkers, this may need to be flexible. For now, it's hardcoded.
|
||||
Program.NIL, # TODO: With more proofs checkers, this may need to be flexible. For now, it's hardcoded.
|
||||
vc.proof_provider,
|
||||
vc.launcher_id,
|
||||
vc.wrap_inner_with_backdoor().get_tree_hash() if add_authorizations_to_cr_cats else None,
|
||||
@@ -756,7 +756,7 @@ class CRCATWallet(CATWallet):
|
||||
for crcat, inner_puzhash in crcats_and_puzhashes
|
||||
],
|
||||
proof_of_inclusions,
|
||||
Program.to(None), # TODO: With more proofs checkers, this may need to be flexible. For now, it's hardcoded.
|
||||
Program.NIL, # TODO: With more proofs checkers, this may need to be flexible. For now, it's hardcoded.
|
||||
vc.proof_provider,
|
||||
vc.launcher_id,
|
||||
vc.wrap_inner_with_backdoor().get_tree_hash(),
|
||||
|
||||
@@ -587,14 +587,14 @@ class VerifiedCredential(Streamable):
|
||||
)
|
||||
inner_puzzle_hash = bytes32(new_singleton_condition.at("rf").as_atom())
|
||||
magic_condition = next(c for c in conditions if c.at("f").as_int() == -10)
|
||||
if magic_condition.at("rrrf") == Program.to(None):
|
||||
if magic_condition.at("rrrf") == Program.NIL:
|
||||
proof_hash_as_prog: Program = metadata_layer.args.at("rfr")
|
||||
elif magic_condition.at("rrrf").atom is not None:
|
||||
raise ValueError("Specified VC was cleared")
|
||||
else:
|
||||
proof_hash_as_prog = magic_condition.at("rrrfrrf")
|
||||
|
||||
proof_hash = None if proof_hash_as_prog == Program.to(None) else bytes32(proof_hash_as_prog.as_atom())
|
||||
proof_hash = None if proof_hash_as_prog == Program.NIL else bytes32(proof_hash_as_prog.as_atom())
|
||||
|
||||
proof_provider = bytes32(metadata_layer.args.at("rff").as_atom())
|
||||
|
||||
@@ -606,7 +606,7 @@ class VerifiedCredential(Streamable):
|
||||
bytes32(uncurry_puzzle(metadata_layer.args.at("rrrrf")).args.at("rrf").as_atom()),
|
||||
).get_tree_hash(),
|
||||
amount=uint64(parent_coin.amount),
|
||||
parent_proof_hash=None if parent_proof_hash == Program.to(None) else parent_proof_hash,
|
||||
parent_proof_hash=None if parent_proof_hash == Program.NIL else parent_proof_hash,
|
||||
)
|
||||
|
||||
new_vc: Self = cls(
|
||||
@@ -778,7 +778,7 @@ class VerifiedCredential(Streamable):
|
||||
)
|
||||
|
||||
expected_announcement: CreatePuzzleAnnouncement = CreatePuzzleAnnouncement(
|
||||
std_hash(self.coin.name() + Program.to(None).get_tree_hash() + ACS_TRANSFER_PROGRAM.get_tree_hash())
|
||||
std_hash(self.coin.name() + Program.NIL.get_tree_hash() + ACS_TRANSFER_PROGRAM.get_tree_hash())
|
||||
)
|
||||
|
||||
return (
|
||||
|
||||
@@ -24,7 +24,7 @@ class VCProofs:
|
||||
|
||||
def as_program(self) -> Program:
|
||||
def byte_sort_pairs(f1: tuple[str, str], f2: tuple[str, str]) -> int:
|
||||
return 1 if Program.to([10, (1, f1[0]), (1, f2[0])]).run([]) == Program.to(None) else -1
|
||||
return 1 if Program.to([10, (1, f1[0]), (1, f2[0])]).run([]) == Program.NIL else -1
|
||||
|
||||
prog: Program = Program.to(
|
||||
list_to_binary_tree(
|
||||
|
||||
@@ -196,7 +196,7 @@ class VCWallet:
|
||||
extra_conditions=extra_conditions,
|
||||
)
|
||||
for dpuz, coin in zip(dpuzs, coins):
|
||||
solution = solution_for_delegated_puzzle(dpuz, Program.to(None))
|
||||
solution = solution_for_delegated_puzzle(dpuz, Program.NIL)
|
||||
puzzle = await self.standard_wallet.puzzle_for_puzzle_hash(coin.puzzle_hash)
|
||||
coin_spends.append(make_spend(coin, puzzle, solution))
|
||||
spend_bundle = WalletSpendBundle(coin_spends, G2Element())
|
||||
@@ -497,7 +497,7 @@ class VCWallet:
|
||||
bytes32(cc.at("rf").as_atom()) == crcat_spend.crcat.inner_puzzle_hash
|
||||
)
|
||||
or ( # it's going to the pending state
|
||||
cc.at("rrr") != Program.to(None)
|
||||
cc.at("rrr") != Program.NIL
|
||||
and cc.at("rrrf").atom is None
|
||||
and bytes32(cc.at("rf").as_atom())
|
||||
== construct_pending_approval_state(
|
||||
@@ -542,7 +542,7 @@ class VCWallet:
|
||||
solution=Program.from_serialized(spend_to_fix.solution)
|
||||
.replace(
|
||||
ff=coin_args[coin_name][0],
|
||||
frf=Program.to(None), # not general
|
||||
frf=Program.NIL, # not general
|
||||
frrf=bytes32.from_hexstr(coin_args[coin_name][2]),
|
||||
frrrf=bytes32.from_hexstr(coin_args[coin_name][3]),
|
||||
frrrrf=bytes32.from_hexstr(coin_args[coin_name][4]),
|
||||
|
||||
@@ -2606,7 +2606,7 @@ class WalletRpcApi:
|
||||
assert num_verification_int is not None
|
||||
did_data: DIDCoinData = DIDCoinData(
|
||||
p2_puzzle,
|
||||
bytes32(recovery_list_hash.as_atom()) if recovery_list_hash != Program.to(None) else None,
|
||||
bytes32(recovery_list_hash.as_atom()) if recovery_list_hash != Program.NIL else None,
|
||||
num_verification_int,
|
||||
singleton_struct,
|
||||
metadata,
|
||||
|
||||
@@ -33,7 +33,7 @@ from chia.rpc.rpc_server import StateChangedProtocol
|
||||
from chia.server.server import ChiaServer
|
||||
from chia.server.ws_connection import WSChiaConnection
|
||||
from chia.types.blockchain_format.coin import Coin
|
||||
from chia.types.blockchain_format.program import NIL, Program
|
||||
from chia.types.blockchain_format.program import Program
|
||||
from chia.types.coin_record import CoinRecord
|
||||
from chia.types.mempool_inclusion_status import MempoolInclusionStatus
|
||||
from chia.util.bech32m import encode_puzzle_hash
|
||||
@@ -883,7 +883,7 @@ class WalletStateManager:
|
||||
p2_puzzle, recovery_list_hash, num_verification, singleton_struct, metadata = did_curried_args
|
||||
did_data: DIDCoinData = DIDCoinData(
|
||||
p2_puzzle,
|
||||
bytes32(recovery_list_hash.as_atom()) if recovery_list_hash != Program.to(None) else None,
|
||||
bytes32(recovery_list_hash.as_atom()) if recovery_list_hash != Program.NIL else None,
|
||||
uint16(num_verification.as_int()),
|
||||
singleton_struct,
|
||||
metadata,
|
||||
@@ -1309,7 +1309,7 @@ class WalletStateManager:
|
||||
)
|
||||
alt_did_puzzle_empty_recovery = DID_INNERPUZ_MOD.curry(
|
||||
our_inner_puzzle,
|
||||
NIL,
|
||||
Program.NIL,
|
||||
uint64(0),
|
||||
parent_data.singleton_struct,
|
||||
parent_data.metadata,
|
||||
|
||||
Reference in New Issue
Block a user