chia-blockchain 2.5.2rc2__py3-none-any.whl → 2.5.3rc2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- chia/__init__.py +7 -0
- chia/_tests/blockchain/blockchain_test_utils.py +1 -1
- chia/_tests/blockchain/test_augmented_chain.py +54 -5
- chia/_tests/blockchain/test_blockchain.py +5 -12
- chia/_tests/blockchain/test_blockchain_transactions.py +3 -5
- chia/_tests/blockchain/test_get_block_generator.py +2 -2
- chia/_tests/blockchain/test_lookup_fork_chain.py +2 -2
- chia/_tests/clvm/benchmark_costs.py +2 -1
- chia/_tests/clvm/coin_store.py +4 -3
- chia/_tests/clvm/test_chialisp_deserialization.py +2 -2
- chia/_tests/clvm/test_curry_and_treehash.py +1 -1
- chia/_tests/clvm/test_puzzle_compression.py +2 -2
- chia/_tests/clvm/test_puzzles.py +2 -2
- chia/_tests/clvm/test_singletons.py +2 -2
- chia/_tests/clvm/test_spend_sim.py +1 -1
- chia/_tests/cmds/cmd_test_utils.py +2 -2
- chia/_tests/cmds/test_click_types.py +2 -2
- chia/_tests/cmds/test_cmd_framework.py +6 -6
- chia/_tests/cmds/test_show.py +4 -3
- chia/_tests/cmds/test_tx_config_args.py +1 -1
- chia/_tests/cmds/testing_classes.py +2 -2
- chia/_tests/cmds/wallet/test_consts.py +2 -2
- chia/_tests/cmds/wallet/test_did.py +2 -2
- chia/_tests/cmds/wallet/test_nft.py +2 -2
- chia/_tests/cmds/wallet/test_notifications.py +3 -2
- chia/_tests/cmds/wallet/test_vcs.py +2 -2
- chia/_tests/cmds/wallet/test_wallet.py +4 -8
- chia/_tests/conftest.py +4 -3
- chia/_tests/connection_utils.py +2 -2
- chia/_tests/core/cmds/test_keys.py +1 -2
- chia/_tests/core/cmds/test_wallet.py +2 -2
- chia/_tests/core/consensus/test_block_creation.py +2 -2
- chia/_tests/core/consensus/test_pot_iterations.py +1 -1
- chia/_tests/core/custom_types/test_coin.py +2 -2
- chia/_tests/core/custom_types/test_proof_of_space.py +2 -2
- chia/_tests/core/custom_types/test_spend_bundle.py +2 -2
- chia/_tests/core/data_layer/conftest.py +1 -1
- chia/_tests/core/data_layer/test_data_layer.py +1 -1
- chia/_tests/core/data_layer/test_data_layer_util.py +1 -1
- chia/_tests/core/data_layer/test_data_rpc.py +2 -2
- chia/_tests/core/data_layer/test_data_store.py +1 -1
- chia/_tests/core/data_layer/test_data_store_schema.py +1 -1
- chia/_tests/core/data_layer/util.py +2 -1
- chia/_tests/core/farmer/test_farmer_api.py +1 -1
- chia/_tests/core/full_node/full_sync/test_full_sync.py +1 -7
- chia/_tests/core/full_node/ram_db.py +2 -1
- chia/_tests/core/full_node/stores/test_block_store.py +2 -2
- chia/_tests/core/full_node/stores/test_coin_store.py +2 -2
- chia/_tests/core/full_node/stores/test_full_node_store.py +3 -3
- chia/_tests/core/full_node/stores/test_hint_store.py +2 -2
- chia/_tests/core/full_node/stores/test_sync_store.py +1 -1
- chia/_tests/core/full_node/test_address_manager.py +1 -1
- chia/_tests/core/full_node/test_block_height_map.py +2 -2
- chia/_tests/core/full_node/test_conditions.py +1 -1
- chia/_tests/core/full_node/test_full_node.py +346 -164
- chia/_tests/core/full_node/test_generator_tools.py +3 -2
- chia/_tests/core/full_node/test_hint_management.py +2 -2
- chia/_tests/core/full_node/test_performance.py +2 -15
- chia/_tests/core/full_node/test_subscriptions.py +1 -1
- chia/_tests/core/full_node/test_transactions.py +186 -185
- chia/_tests/core/full_node/test_tx_processing_queue.py +1 -1
- chia/_tests/core/make_block_generator.py +2 -2
- chia/_tests/core/mempool/test_mempool.py +165 -22
- chia/_tests/core/mempool/test_mempool_fee_estimator.py +1 -1
- chia/_tests/core/mempool/test_mempool_fee_protocol.py +1 -1
- chia/_tests/core/mempool/test_mempool_manager.py +476 -66
- chia/_tests/core/mempool/test_mempool_performance.py +2 -2
- chia/_tests/core/mempool/test_singleton_fast_forward.py +19 -25
- chia/_tests/core/node_height.py +2 -1
- chia/_tests/core/server/test_capabilities.py +1 -1
- chia/_tests/core/server/test_dos.py +36 -28
- chia/_tests/core/server/test_loop.py +3 -3
- chia/_tests/core/server/test_rate_limits.py +1 -1
- chia/_tests/core/server/test_server.py +2 -2
- chia/_tests/core/services/test_services.py +1 -1
- chia/_tests/core/ssl/test_ssl.py +1 -1
- chia/_tests/core/test_coins.py +2 -1
- chia/_tests/core/test_cost_calculation.py +2 -2
- chia/_tests/core/test_crawler.py +2 -2
- chia/_tests/core/test_db_conversion.py +2 -2
- chia/_tests/core/test_db_validation.py +26 -13
- chia/_tests/core/test_farmer_harvester_rpc.py +2 -2
- chia/_tests/core/test_full_node_rpc.py +2 -2
- chia/_tests/core/test_merkle_set.py +2 -2
- chia/_tests/core/test_program.py +2 -2
- chia/_tests/core/test_rpc_util.py +1 -1
- chia/_tests/core/test_seeder.py +1 -1
- chia/_tests/core/util/test_block_cache.py +3 -3
- chia/_tests/core/util/test_jsonify.py +3 -2
- chia/_tests/core/util/test_keychain.py +3 -3
- chia/_tests/core/util/test_streamable.py +3 -4
- chia/_tests/environments/wallet.py +3 -2
- chia/_tests/farmer_harvester/test_farmer.py +3 -4
- chia/_tests/farmer_harvester/test_farmer_harvester.py +2 -2
- chia/_tests/farmer_harvester/test_filter_prefix_bits.py +2 -2
- chia/_tests/farmer_harvester/test_third_party_harvesters.py +3 -4
- chia/_tests/fee_estimation/test_fee_estimation_integration.py +1 -1
- chia/_tests/fee_estimation/test_fee_estimation_rpc.py +2 -2
- chia/_tests/fee_estimation/test_fee_estimation_unit_tests.py +1 -1
- chia/_tests/fee_estimation/test_mempoolitem_height_added.py +3 -4
- chia/_tests/generator/test_compression.py +20 -10
- chia/_tests/generator/test_rom.py +7 -9
- chia/_tests/plot_sync/test_delta.py +2 -2
- chia/_tests/plot_sync/test_plot_sync.py +2 -2
- chia/_tests/plot_sync/test_receiver.py +2 -2
- chia/_tests/plot_sync/test_sender.py +2 -2
- chia/_tests/plot_sync/test_sync_simulated.py +2 -2
- chia/_tests/plot_sync/util.py +3 -2
- chia/_tests/plotting/test_plot_manager.py +1 -1
- chia/_tests/pools/test_pool_cli_parsing.py +3 -2
- chia/_tests/pools/test_pool_cmdline.py +2 -2
- chia/_tests/pools/test_pool_puzzles_lifecycle.py +3 -3
- chia/_tests/pools/test_pool_rpc.py +4 -5
- chia/_tests/pools/test_pool_wallet.py +1 -1
- chia/_tests/pools/test_wallet_pool_store.py +2 -2
- chia/_tests/rpc/test_rpc_client.py +1 -1
- chia/_tests/rpc/test_rpc_server.py +1 -1
- chia/_tests/simulation/test_simulation.py +36 -8
- chia/_tests/simulation/test_simulator.py +5 -5
- chia/_tests/simulation/test_start_simulator.py +2 -2
- chia/_tests/timelord/test_new_peak.py +2 -2
- chia/_tests/tools/test_run_block.py +3 -2
- chia/_tests/util/benchmark_cost.py +2 -2
- chia/_tests/util/benchmarks.py +17 -6
- chia/_tests/util/blockchain.py +2 -1
- chia/_tests/util/blockchain_mock.py +9 -5
- chia/_tests/util/build_network_protocol_files.py +2 -1
- chia/_tests/util/constants.py +2 -1
- chia/_tests/util/full_sync.py +6 -3
- chia/_tests/util/gen_ssl_certs.py +2 -2
- chia/_tests/util/generator_tools_testing.py +4 -3
- chia/_tests/util/get_name_puzzle_conditions.py +2 -2
- chia/_tests/util/misc.py +16 -2
- chia/_tests/util/network_protocol_data.py +17 -7
- chia/_tests/util/run_block.py +6 -8
- chia/_tests/util/setup_nodes.py +4 -3
- chia/_tests/util/spend_sim.py +9 -5
- chia/_tests/util/test_condition_tools.py +2 -2
- chia/_tests/util/test_config.py +2 -1
- chia/_tests/util/test_errors.py +2 -1
- chia/_tests/util/test_full_block_utils.py +17 -7
- chia/_tests/util/test_misc.py +1 -1
- chia/_tests/util/test_network_protocol_test.py +24 -24
- chia/_tests/util/test_replace_str_to_bytes.py +2 -2
- chia/_tests/util/test_trusted_peer.py +1 -1
- chia/_tests/util/time_out_assert.py +20 -7
- chia/_tests/wallet/cat_wallet/test_cat_lifecycle.py +1 -1
- chia/_tests/wallet/cat_wallet/test_cat_outer_puzzle.py +2 -2
- chia/_tests/wallet/cat_wallet/test_cat_wallet.py +5 -6
- chia/_tests/wallet/cat_wallet/test_offer_lifecycle.py +17 -15
- chia/_tests/wallet/cat_wallet/test_trades.py +2 -2
- chia/_tests/wallet/clawback/test_clawback_lifecycle.py +2 -2
- chia/_tests/wallet/clawback/test_clawback_metadata.py +2 -2
- chia/_tests/wallet/conftest.py +3 -3
- chia/_tests/wallet/db_wallet/test_db_graftroot.py +3 -5
- chia/_tests/wallet/db_wallet/test_dl_offers.py +2 -2
- chia/_tests/wallet/db_wallet/test_dl_wallet.py +433 -384
- chia/_tests/wallet/did_wallet/test_did.py +3 -3
- chia/_tests/wallet/nft_wallet/test_nft_1_offers.py +2 -2
- chia/_tests/wallet/nft_wallet/test_nft_bulk_mint.py +2 -2
- chia/_tests/wallet/nft_wallet/test_nft_lifecycle.py +3 -4
- chia/_tests/wallet/nft_wallet/test_nft_offers.py +1293 -703
- chia/_tests/wallet/nft_wallet/test_nft_puzzles.py +28 -30
- chia/_tests/wallet/nft_wallet/test_nft_wallet.py +2 -2
- chia/_tests/wallet/nft_wallet/test_ownership_outer_puzzle.py +2 -2
- chia/_tests/wallet/rpc/config.py +1 -1
- chia/_tests/wallet/rpc/test_dl_wallet_rpc.py +2 -2
- chia/_tests/wallet/rpc/test_wallet_rpc.py +20 -77
- chia/_tests/wallet/simple_sync/test_simple_sync_protocol.py +9 -7
- chia/_tests/wallet/sync/test_wallet_sync.py +79 -31
- chia/_tests/wallet/test_clvm_streamable.py +2 -2
- chia/_tests/wallet/test_coin_management.py +7 -7
- chia/_tests/wallet/test_coin_selection.py +20 -2
- chia/_tests/wallet/test_conditions.py +2 -2
- chia/_tests/wallet/test_debug_spend_bundle.py +2 -2
- chia/_tests/wallet/test_new_wallet_protocol.py +2 -2
- chia/_tests/wallet/test_nft_store.py +2 -2
- chia/_tests/wallet/test_notifications.py +2 -2
- chia/_tests/wallet/test_puzzle_store.py +2 -2
- chia/_tests/wallet/test_sign_coin_spends.py +2 -2
- chia/_tests/wallet/test_signer_protocol.py +3 -3
- chia/_tests/wallet/test_singleton.py +3 -11
- chia/_tests/wallet/test_singleton_lifecycle_fast.py +12 -13
- chia/_tests/wallet/test_singleton_store.py +2 -4
- chia/_tests/wallet/test_transaction_store.py +2 -2
- chia/_tests/wallet/test_util.py +2 -2
- chia/_tests/wallet/test_wallet.py +53 -49
- chia/_tests/wallet/test_wallet_action_scope.py +24 -6
- chia/_tests/wallet/test_wallet_blockchain.py +1 -1
- chia/_tests/wallet/test_wallet_coin_store.py +2 -2
- chia/_tests/wallet/test_wallet_interested_store.py +2 -2
- chia/_tests/wallet/test_wallet_node.py +3 -3
- chia/_tests/wallet/test_wallet_retry.py +3 -3
- chia/_tests/wallet/test_wallet_state_manager.py +8 -8
- chia/_tests/wallet/test_wallet_test_framework.py +1 -1
- chia/_tests/wallet/test_wallet_trade_store.py +2 -2
- chia/_tests/wallet/test_wallet_utils.py +2 -2
- chia/_tests/wallet/vc_wallet/test_cr_outer_puzzle.py +3 -2
- chia/_tests/wallet/vc_wallet/test_vc_lifecycle.py +15 -15
- chia/_tests/wallet/vc_wallet/test_vc_wallet.py +5 -3
- chia/_tests/wallet/wallet_block_tools.py +15 -7
- chia/_tests/weight_proof/test_weight_proof.py +3 -3
- chia/cmds/chia.py +0 -2
- chia/cmds/cmd_classes.py +3 -3
- chia/cmds/cmd_helpers.py +4 -4
- chia/cmds/cmds_util.py +2 -2
- chia/cmds/coin_funcs.py +3 -2
- chia/cmds/coins.py +1 -1
- chia/cmds/data.py +2 -2
- chia/cmds/data_funcs.py +3 -2
- chia/cmds/db_upgrade_func.py +2 -2
- chia/cmds/db_validate_func.py +15 -8
- chia/cmds/farm.py +2 -4
- chia/cmds/keys.py +0 -2
- chia/cmds/keys_funcs.py +1 -1
- chia/cmds/netspace_funcs.py +2 -1
- chia/cmds/param_types.py +2 -2
- chia/cmds/plotnft.py +2 -2
- chia/cmds/plotnft_funcs.py +2 -2
- chia/cmds/rpc.py +1 -1
- chia/cmds/show.py +1 -2
- chia/cmds/show_funcs.py +6 -3
- chia/cmds/signer.py +1 -2
- chia/cmds/sim.py +1 -2
- chia/cmds/sim_funcs.py +2 -2
- chia/cmds/wallet.py +2 -2
- chia/cmds/wallet_funcs.py +4 -11
- chia/consensus/block_body_validation.py +3 -4
- chia/consensus/block_creation.py +10 -6
- chia/consensus/block_header_validation.py +3 -4
- chia/consensus/block_record.py +2 -3
- chia/consensus/block_rewards.py +1 -1
- chia/consensus/blockchain.py +20 -17
- chia/consensus/blockchain_interface.py +5 -4
- chia/consensus/coinbase.py +2 -2
- chia/consensus/constants.py +1 -1
- chia/consensus/cost_calculator.py +2 -1
- chia/consensus/default_constants.py +4 -3
- chia/consensus/deficit.py +3 -2
- chia/consensus/difficulty_adjustment.py +8 -9
- chia/consensus/find_fork_point.py +4 -3
- chia/consensus/full_block_to_block_record.py +4 -3
- chia/consensus/get_block_challenge.py +4 -3
- chia/consensus/get_block_generator.py +3 -2
- chia/consensus/make_sub_epoch_summary.py +3 -2
- chia/consensus/multiprocess_validation.py +9 -4
- chia/consensus/pos_quality.py +1 -1
- chia/consensus/pot_iterations.py +4 -3
- chia/consensus/vdf_info_computation.py +4 -3
- chia/daemon/client.py +1 -1
- chia/daemon/keychain_server.py +1 -1
- chia/daemon/server.py +1 -1
- chia/daemon/windows_signal.py +1 -1
- chia/data_layer/data_layer.py +4 -3
- chia/data_layer/data_layer_errors.py +1 -1
- chia/data_layer/data_layer_util.py +2 -2
- chia/data_layer/data_layer_wallet.py +47 -69
- chia/data_layer/data_store.py +1 -1
- chia/data_layer/dl_wallet_store.py +5 -6
- chia/data_layer/download_data.py +1 -1
- chia/data_layer/s3_plugin_service.py +4 -4
- chia/data_layer/singleton_record.py +23 -0
- chia/data_layer/util/benchmark.py +2 -1
- chia/farmer/farmer.py +4 -6
- chia/farmer/farmer_api.py +4 -6
- chia/full_node/bitcoin_fee_estimator.py +2 -1
- chia/full_node/block_height_map.py +2 -2
- chia/full_node/block_store.py +8 -9
- chia/{util → full_node}/check_fork_next_block.py +2 -1
- chia/full_node/coin_store.py +10 -10
- chia/full_node/fee_estimate.py +2 -1
- chia/full_node/fee_estimation.py +2 -1
- chia/full_node/fee_estimator.py +2 -1
- chia/full_node/fee_estimator_interface.py +1 -1
- chia/full_node/fee_history.py +2 -1
- chia/full_node/fee_tracker.py +2 -1
- chia/full_node/full_node.py +15 -13
- chia/full_node/full_node_api.py +12 -32
- chia/full_node/full_node_store.py +4 -3
- chia/full_node/hint_management.py +2 -1
- chia/full_node/hint_store.py +3 -3
- chia/full_node/mempool.py +80 -12
- chia/full_node/mempool_check_conditions.py +6 -7
- chia/full_node/mempool_manager.py +168 -21
- chia/full_node/pending_tx_cache.py +2 -2
- chia/full_node/subscriptions.py +2 -2
- chia/full_node/sync_store.py +2 -3
- chia/full_node/tx_processing_queue.py +2 -1
- chia/full_node/weight_proof.py +5 -8
- chia/harvester/harvester.py +5 -3
- chia/harvester/harvester_api.py +2 -2
- chia/introducer/introducer.py +30 -2
- chia/introducer/introducer_api.py +9 -1
- chia/legacy/keyring.py +1 -2
- chia/plot_sync/exceptions.py +2 -1
- chia/plot_sync/receiver.py +2 -2
- chia/plot_sync/sender.py +1 -1
- chia/plotting/cache.py +2 -2
- chia/plotting/check_plots.py +4 -2
- chia/plotting/create_plots.py +1 -1
- chia/plotting/manager.py +3 -3
- chia/plotting/util.py +2 -2
- chia/pools/pool_config.py +1 -1
- chia/pools/pool_puzzles.py +23 -17
- chia/pools/pool_wallet.py +22 -9
- chia/pools/pool_wallet_info.py +2 -2
- chia/protocols/farmer_protocol.py +3 -6
- chia/protocols/full_node_protocol.py +3 -2
- chia/protocols/harvester_protocol.py +3 -4
- chia/protocols/pool_protocol.py +2 -2
- chia/protocols/shared_protocol.py +2 -1
- chia/protocols/timelord_protocol.py +4 -4
- chia/protocols/wallet_protocol.py +2 -2
- chia/rpc/data_layer_rpc_api.py +3 -4
- chia/rpc/data_layer_rpc_client.py +3 -2
- chia/rpc/farmer_rpc_api.py +2 -2
- chia/rpc/farmer_rpc_client.py +2 -1
- chia/rpc/full_node_rpc_api.py +3 -2
- chia/rpc/full_node_rpc_client.py +3 -2
- chia/rpc/harvester_rpc_api.py +2 -1
- chia/rpc/rpc_client.py +2 -2
- chia/rpc/rpc_server.py +1 -1
- chia/rpc/wallet_request_types.py +2 -62
- chia/rpc/wallet_rpc_api.py +98 -628
- chia/rpc/wallet_rpc_client.py +5 -253
- chia/seeder/crawl_store.py +1 -1
- chia/seeder/crawler.py +2 -2
- chia/seeder/peer_record.py +2 -1
- chia/seeder/start_crawler.py +3 -1
- chia/server/address_manager.py +2 -1
- chia/server/address_manager_store.py +1 -1
- chia/server/capabilities.py +2 -1
- chia/server/introducer_peers.py +2 -1
- chia/server/node_discovery.py +1 -1
- chia/server/outbound_message.py +2 -1
- chia/server/server.py +2 -2
- chia/server/start_data_layer.py +2 -1
- chia/server/start_farmer.py +3 -1
- chia/server/start_full_node.py +4 -2
- chia/server/start_harvester.py +3 -1
- chia/server/start_introducer.py +12 -1
- chia/server/start_service.py +2 -1
- chia/server/start_timelord.py +3 -1
- chia/server/start_wallet.py +3 -1
- chia/server/upnp.py +1 -2
- chia/server/ws_connection.py +3 -4
- chia/simulator/add_blocks_in_batches.py +5 -3
- chia/simulator/block_tools.py +16 -12
- chia/simulator/full_node_simulator.py +9 -14
- chia/simulator/setup_services.py +5 -3
- chia/simulator/simulator_full_node_rpc_api.py +3 -2
- chia/simulator/simulator_full_node_rpc_client.py +3 -2
- chia/simulator/simulator_protocol.py +3 -2
- chia/simulator/simulator_test_tools.py +2 -2
- chia/simulator/start_simulator.py +3 -2
- chia/simulator/wallet_tools.py +3 -4
- chia/timelord/iters_from_block.py +4 -4
- chia/timelord/timelord.py +7 -12
- chia/timelord/timelord_api.py +3 -3
- chia/timelord/timelord_state.py +4 -3
- chia/types/block_protocol.py +2 -2
- chia/types/blockchain_format/coin.py +2 -2
- chia/types/blockchain_format/program.py +1 -1
- chia/types/blockchain_format/proof_of_space.py +3 -4
- chia/types/blockchain_format/tree_hash.py +1 -1
- chia/types/blockchain_format/vdf.py +3 -4
- chia/types/clvm_cost.py +1 -1
- chia/types/coin_record.py +4 -3
- chia/types/coin_spend.py +1 -1
- chia/types/eligible_coin_spends.py +9 -5
- chia/types/fee_rate.py +1 -1
- chia/types/generator_types.py +3 -3
- chia/types/internal_mempool_item.py +3 -2
- chia/types/mempool_item.py +10 -3
- chia/types/mempool_submission_status.py +2 -1
- chia/types/mojos.py +1 -1
- chia/types/peer_info.py +2 -1
- chia/types/transaction_queue_entry.py +2 -1
- chia/types/unfinished_header_block.py +4 -4
- chia/types/validation_state.py +2 -1
- chia/types/weight_proof.py +1 -9
- chia/util/augmented_chain.py +20 -9
- chia/util/block_cache.py +8 -4
- chia/util/condition_tools.py +2 -2
- chia/util/full_block_utils.py +3 -4
- chia/util/generator_tools.py +2 -2
- chia/util/initial-config.yaml +2 -11
- chia/util/network.py +2 -2
- chia/util/prev_transaction_block.py +2 -1
- chia/util/task_timing.py +1 -1
- chia/util/vdf_prover.py +3 -3
- chia/util/ws_message.py +1 -1
- chia/wallet/cat_wallet/cat_info.py +3 -2
- chia/wallet/cat_wallet/cat_outer_puzzle.py +3 -2
- chia/wallet/cat_wallet/cat_utils.py +6 -4
- chia/wallet/cat_wallet/cat_wallet.py +16 -18
- chia/wallet/cat_wallet/lineage_store.py +2 -1
- chia/wallet/coin_selection.py +5 -5
- chia/wallet/conditions.py +22 -16
- chia/wallet/db_wallet/db_wallet_puzzles.py +15 -15
- chia/wallet/derivation_record.py +2 -2
- chia/wallet/derive_keys.py +2 -2
- chia/wallet/did_wallet/did_info.py +3 -2
- chia/wallet/did_wallet/did_wallet.py +41 -19
- chia/wallet/did_wallet/did_wallet_puzzles.py +18 -12
- chia/wallet/driver_protocol.py +1 -1
- chia/wallet/lineage_proof.py +3 -2
- chia/wallet/nft_wallet/metadata_outer_puzzle.py +6 -7
- chia/wallet/nft_wallet/nft_info.py +5 -5
- chia/wallet/nft_wallet/nft_puzzle_utils.py +293 -0
- chia/wallet/nft_wallet/nft_puzzles.py +21 -298
- chia/wallet/nft_wallet/nft_wallet.py +47 -62
- chia/wallet/nft_wallet/ownership_outer_puzzle.py +4 -8
- chia/wallet/nft_wallet/singleton_outer_puzzle.py +3 -2
- chia/wallet/nft_wallet/transfer_program_puzzle.py +6 -10
- chia/wallet/nft_wallet/uncurry_nft.py +6 -8
- chia/wallet/notification_manager.py +5 -5
- chia/wallet/notification_store.py +3 -2
- chia/wallet/outer_puzzles.py +2 -1
- chia/wallet/puzzles/clawback/drivers.py +21 -8
- chia/wallet/puzzles/clawback/metadata.py +3 -2
- chia/wallet/puzzles/clawback/puzzle_decorator.py +5 -4
- chia/wallet/puzzles/deployed_puzzle_hashes.json +0 -10
- chia/wallet/puzzles/p2_conditions.py +3 -2
- chia/wallet/puzzles/p2_delegated_conditions.py +3 -2
- chia/wallet/puzzles/p2_delegated_puzzle.py +3 -2
- chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.py +3 -3
- chia/wallet/puzzles/p2_m_of_n_delegate_direct.py +3 -2
- chia/wallet/puzzles/p2_puzzle_hash.py +4 -3
- chia/wallet/puzzles/puzzle_utils.py +3 -2
- chia/wallet/puzzles/singleton_top_layer.py +26 -10
- chia/wallet/puzzles/singleton_top_layer_v1_1.py +21 -9
- chia/wallet/puzzles/tails.py +21 -129
- chia/wallet/signer_protocol.py +3 -2
- chia/wallet/singleton.py +12 -6
- chia/wallet/singleton_record.py +3 -2
- chia/wallet/trade_manager.py +31 -55
- chia/wallet/trade_record.py +3 -2
- chia/wallet/trading/offer.py +14 -13
- chia/wallet/trading/trade_store.py +3 -4
- chia/wallet/transaction_record.py +2 -2
- chia/wallet/util/blind_signer_tl.py +3 -2
- chia/wallet/util/compute_hints.py +3 -2
- chia/wallet/util/compute_memos.py +2 -2
- chia/wallet/util/curry_and_treehash.py +1 -2
- chia/wallet/util/merkle_tree.py +1 -1
- chia/wallet/util/merkle_utils.py +1 -1
- chia/wallet/util/new_peak_queue.py +2 -1
- chia/wallet/util/notifications.py +5 -4
- chia/wallet/util/peer_request_cache.py +3 -2
- chia/wallet/util/puzzle_compression.py +6 -4
- chia/wallet/util/puzzle_decorator.py +6 -4
- chia/wallet/util/query_filter.py +3 -2
- chia/wallet/util/tx_config.py +3 -3
- chia/wallet/util/wallet_sync_utils.py +2 -2
- chia/wallet/util/wallet_types.py +2 -3
- chia/wallet/vc_wallet/cr_cat_drivers.py +18 -22
- chia/wallet/vc_wallet/cr_cat_wallet.py +14 -10
- chia/wallet/vc_wallet/cr_outer_puzzle.py +2 -2
- chia/wallet/vc_wallet/vc_drivers.py +50 -68
- chia/wallet/vc_wallet/vc_store.py +2 -2
- chia/wallet/vc_wallet/vc_wallet.py +47 -15
- chia/wallet/wallet.py +51 -46
- chia/wallet/wallet_action_scope.py +4 -0
- chia/wallet/wallet_blockchain.py +12 -7
- chia/wallet/wallet_coin_record.py +3 -2
- chia/wallet/wallet_coin_store.py +3 -2
- chia/wallet/wallet_info.py +2 -1
- chia/wallet/wallet_interested_store.py +3 -2
- chia/wallet/wallet_nft_store.py +4 -4
- chia/wallet/wallet_node.py +3 -4
- chia/wallet/wallet_pool_store.py +3 -4
- chia/wallet/wallet_protocol.py +19 -5
- chia/wallet/wallet_puzzle_store.py +2 -2
- chia/wallet/wallet_retry_store.py +3 -6
- chia/wallet/wallet_singleton_store.py +2 -2
- chia/wallet/wallet_state_manager.py +20 -197
- chia/wallet/wallet_transaction_store.py +2 -2
- chia/wallet/wallet_user_store.py +2 -1
- chia/wallet/wallet_weight_proof_handler.py +3 -2
- {chia_blockchain-2.5.2rc2.dist-info → chia_blockchain-2.5.3rc2.dist-info}/METADATA +3 -2
- chia_blockchain-2.5.3rc2.dist-info/RECORD +891 -0
- mozilla-ca/cacert.pem +64 -33
- chia/_tests/clvm/test_condition_codes.py +0 -13
- chia/_tests/cmds/wallet/test_dao.py +0 -565
- chia/_tests/wallet/dao_wallet/__init__.py +0 -0
- chia/_tests/wallet/dao_wallet/config.py +0 -3
- chia/_tests/wallet/dao_wallet/test_dao_clvm.py +0 -1330
- chia/_tests/wallet/dao_wallet/test_dao_wallets.py +0 -3488
- chia/cmds/dao.py +0 -1064
- chia/cmds/dao_funcs.py +0 -598
- chia/consensus/puzzles/__init__.py +0 -0
- chia/consensus/puzzles/chialisp_deserialisation.clsp +0 -69
- chia/consensus/puzzles/chialisp_deserialisation.clsp.hex +0 -1
- chia/consensus/puzzles/rom_bootstrap_generator.clsp +0 -37
- chia/consensus/puzzles/rom_bootstrap_generator.clsp.hex +0 -1
- chia/full_node/puzzles/__init__.py +0 -0
- chia/full_node/puzzles/block_program_zero.clsp +0 -14
- chia/full_node/puzzles/block_program_zero.clsp.hex +0 -1
- chia/full_node/puzzles/decompress_coin_spend_entry.clsp +0 -5
- chia/full_node/puzzles/decompress_coin_spend_entry.clsp.hex +0 -1
- chia/full_node/puzzles/decompress_coin_spend_entry_with_prefix.clsp +0 -7
- chia/full_node/puzzles/decompress_coin_spend_entry_with_prefix.clsp.hex +0 -1
- chia/full_node/puzzles/decompress_puzzle.clsp +0 -6
- chia/full_node/puzzles/decompress_puzzle.clsp.hex +0 -1
- chia/pools/puzzles/__init__.py +0 -0
- chia/pools/puzzles/pool_member_innerpuz.clsp +0 -70
- chia/pools/puzzles/pool_member_innerpuz.clsp.hex +0 -1
- chia/pools/puzzles/pool_waitingroom_innerpuz.clsp +0 -69
- chia/pools/puzzles/pool_waitingroom_innerpuz.clsp.hex +0 -1
- chia/simulator/simulator_constants.py +0 -13
- chia/types/blockchain_format/foliage.py +0 -8
- chia/types/blockchain_format/pool_target.py +0 -5
- chia/types/blockchain_format/reward_chain_block.py +0 -6
- chia/types/blockchain_format/sized_bytes.py +0 -11
- chia/util/ints.py +0 -19
- chia/wallet/cat_wallet/dao_cat_info.py +0 -28
- chia/wallet/cat_wallet/dao_cat_wallet.py +0 -669
- chia/wallet/cat_wallet/puzzles/__init__.py +0 -0
- chia/wallet/cat_wallet/puzzles/cat_truths.clib +0 -31
- chia/wallet/cat_wallet/puzzles/cat_v2.clsp +0 -397
- chia/wallet/cat_wallet/puzzles/cat_v2.clsp.hex +0 -1
- chia/wallet/cat_wallet/puzzles/delegated_tail.clsp +0 -25
- chia/wallet/cat_wallet/puzzles/delegated_tail.clsp.hex +0 -1
- chia/wallet/cat_wallet/puzzles/everything_with_signature.clsp +0 -15
- chia/wallet/cat_wallet/puzzles/everything_with_signature.clsp.hex +0 -1
- chia/wallet/cat_wallet/puzzles/genesis_by_coin_id.clsp +0 -26
- chia/wallet/cat_wallet/puzzles/genesis_by_coin_id.clsp.hex +0 -1
- chia/wallet/cat_wallet/puzzles/genesis_by_coin_id_or_singleton.clsp +0 -42
- chia/wallet/cat_wallet/puzzles/genesis_by_coin_id_or_singleton.clsp.hex +0 -1
- chia/wallet/cat_wallet/puzzles/genesis_by_puzzle_hash.clsp +0 -24
- chia/wallet/cat_wallet/puzzles/genesis_by_puzzle_hash.clsp.hex +0 -1
- chia/wallet/dao_wallet/__init__.py +0 -0
- chia/wallet/dao_wallet/dao_info.py +0 -61
- chia/wallet/dao_wallet/dao_utils.py +0 -811
- chia/wallet/dao_wallet/dao_wallet.py +0 -2119
- chia/wallet/did_wallet/puzzles/__init__.py +0 -0
- chia/wallet/did_wallet/puzzles/did_innerpuz.clsp +0 -135
- chia/wallet/did_wallet/puzzles/did_innerpuz.clsp.hex +0 -1
- chia/wallet/payment.py +0 -33
- chia/wallet/puzzles/augmented_condition.clsp +0 -13
- chia/wallet/puzzles/augmented_condition.clsp.hex +0 -1
- chia/wallet/puzzles/condition_codes.clib +0 -77
- chia/wallet/puzzles/curry-and-treehash.clib +0 -102
- chia/wallet/puzzles/curry.clib +0 -135
- chia/wallet/puzzles/curry_by_index.clib +0 -16
- chia/wallet/puzzles/dao_cat_eve.clsp +0 -17
- chia/wallet/puzzles/dao_cat_eve.clsp.hex +0 -1
- chia/wallet/puzzles/dao_cat_launcher.clsp +0 -36
- chia/wallet/puzzles/dao_cat_launcher.clsp.hex +0 -1
- chia/wallet/puzzles/dao_finished_state.clsp +0 -35
- chia/wallet/puzzles/dao_finished_state.clsp.hex +0 -1
- chia/wallet/puzzles/dao_finished_state.clsp.hex.sha256tree +0 -1
- chia/wallet/puzzles/dao_lockup.clsp +0 -288
- chia/wallet/puzzles/dao_lockup.clsp.hex +0 -1
- chia/wallet/puzzles/dao_lockup.clsp.hex.sha256tree +0 -1
- chia/wallet/puzzles/dao_proposal.clsp +0 -377
- chia/wallet/puzzles/dao_proposal.clsp.hex +0 -1
- chia/wallet/puzzles/dao_proposal.clsp.hex.sha256tree +0 -1
- chia/wallet/puzzles/dao_proposal_timer.clsp +0 -78
- chia/wallet/puzzles/dao_proposal_timer.clsp.hex +0 -1
- chia/wallet/puzzles/dao_proposal_timer.clsp.hex.sha256tree +0 -1
- chia/wallet/puzzles/dao_proposal_validator.clsp +0 -87
- chia/wallet/puzzles/dao_proposal_validator.clsp.hex +0 -1
- chia/wallet/puzzles/dao_proposal_validator.clsp.hex.sha256tree +0 -1
- chia/wallet/puzzles/dao_spend_p2_singleton_v2.clsp +0 -240
- chia/wallet/puzzles/dao_spend_p2_singleton_v2.clsp.hex +0 -1
- chia/wallet/puzzles/dao_spend_p2_singleton_v2.clsp.hex.sha256tree +0 -1
- chia/wallet/puzzles/dao_treasury.clsp +0 -115
- chia/wallet/puzzles/dao_treasury.clsp.hex +0 -1
- chia/wallet/puzzles/dao_update_proposal.clsp +0 -44
- chia/wallet/puzzles/dao_update_proposal.clsp.hex +0 -1
- chia/wallet/puzzles/json.clib +0 -25
- chia/wallet/puzzles/merkle_utils.clib +0 -18
- chia/wallet/puzzles/notification.clsp +0 -7
- chia/wallet/puzzles/notification.clsp.hex +0 -1
- chia/wallet/puzzles/p2_1_of_n.clsp +0 -22
- chia/wallet/puzzles/p2_1_of_n.clsp.hex +0 -1
- chia/wallet/puzzles/p2_conditions.clsp +0 -3
- chia/wallet/puzzles/p2_conditions.clsp.hex +0 -1
- chia/wallet/puzzles/p2_delegated_conditions.clsp +0 -18
- chia/wallet/puzzles/p2_delegated_conditions.clsp.hex +0 -1
- chia/wallet/puzzles/p2_delegated_puzzle.clsp +0 -19
- chia/wallet/puzzles/p2_delegated_puzzle.clsp.hex +0 -1
- chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.clsp +0 -91
- chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.clsp.hex +0 -1
- chia/wallet/puzzles/p2_m_of_n_delegate_direct.clsp +0 -108
- chia/wallet/puzzles/p2_m_of_n_delegate_direct.clsp.hex +0 -1
- chia/wallet/puzzles/p2_parent.clsp +0 -19
- chia/wallet/puzzles/p2_parent.clsp.hex +0 -1
- chia/wallet/puzzles/p2_puzzle_hash.clsp +0 -18
- chia/wallet/puzzles/p2_puzzle_hash.clsp.hex +0 -1
- chia/wallet/puzzles/p2_singleton.clsp +0 -30
- chia/wallet/puzzles/p2_singleton.clsp.hex +0 -1
- chia/wallet/puzzles/p2_singleton_aggregator.clsp +0 -81
- chia/wallet/puzzles/p2_singleton_aggregator.clsp.hex +0 -1
- chia/wallet/puzzles/p2_singleton_or_delayed_puzhash.clsp +0 -50
- chia/wallet/puzzles/p2_singleton_or_delayed_puzhash.clsp.hex +0 -1
- chia/wallet/puzzles/p2_singleton_via_delegated_puzzle.clsp +0 -47
- chia/wallet/puzzles/p2_singleton_via_delegated_puzzle.clsp.hex +0 -1
- chia/wallet/puzzles/settlement_payments.clsp +0 -49
- chia/wallet/puzzles/settlement_payments.clsp.hex +0 -1
- chia/wallet/puzzles/sha256tree.clib +0 -11
- chia/wallet/puzzles/singleton_launcher.clsp +0 -16
- chia/wallet/puzzles/singleton_launcher.clsp.hex +0 -1
- chia/wallet/puzzles/singleton_top_layer.clsp +0 -177
- chia/wallet/puzzles/singleton_top_layer.clsp.hex +0 -1
- chia/wallet/puzzles/singleton_top_layer_v1_1.clsp +0 -107
- chia/wallet/puzzles/singleton_top_layer_v1_1.clsp.hex +0 -1
- chia/wallet/puzzles/singleton_truths.clib +0 -21
- chia/wallet/vc_wallet/cr_puzzles/__init__.py +0 -0
- chia/wallet/vc_wallet/cr_puzzles/conditions_w_fee_announce.clsp +0 -3
- chia/wallet/vc_wallet/cr_puzzles/conditions_w_fee_announce.clsp.hex +0 -1
- chia/wallet/vc_wallet/cr_puzzles/credential_restriction.clsp +0 -304
- chia/wallet/vc_wallet/cr_puzzles/credential_restriction.clsp.hex +0 -1
- chia/wallet/vc_wallet/cr_puzzles/flag_proofs_checker.clsp +0 -45
- chia/wallet/vc_wallet/cr_puzzles/flag_proofs_checker.clsp.hex +0 -1
- chia/wallet/vc_wallet/vc_puzzles/__init__.py +0 -0
- chia/wallet/vc_wallet/vc_puzzles/covenant_layer.clsp +0 -30
- chia/wallet/vc_wallet/vc_puzzles/covenant_layer.clsp.hex +0 -1
- chia/wallet/vc_wallet/vc_puzzles/eml_covenant_morpher.clsp +0 -75
- chia/wallet/vc_wallet/vc_puzzles/eml_covenant_morpher.clsp.hex +0 -1
- chia/wallet/vc_wallet/vc_puzzles/eml_transfer_program_covenant_adapter.clsp +0 -32
- chia/wallet/vc_wallet/vc_puzzles/eml_transfer_program_covenant_adapter.clsp.hex +0 -1
- chia/wallet/vc_wallet/vc_puzzles/eml_update_metadata_with_DID.clsp +0 -80
- chia/wallet/vc_wallet/vc_puzzles/eml_update_metadata_with_DID.clsp.hex +0 -1
- chia/wallet/vc_wallet/vc_puzzles/exigent_metadata_layer.clsp +0 -163
- chia/wallet/vc_wallet/vc_puzzles/exigent_metadata_layer.clsp.hex +0 -1
- chia/wallet/vc_wallet/vc_puzzles/p2_announced_delegated_puzzle.clsp +0 -16
- chia/wallet/vc_wallet/vc_puzzles/p2_announced_delegated_puzzle.clsp.hex +0 -1
- chia/wallet/vc_wallet/vc_puzzles/standard_vc_backdoor_puzzle.clsp +0 -74
- chia/wallet/vc_wallet/vc_puzzles/standard_vc_backdoor_puzzle.clsp.hex +0 -1
- chia/wallet/vc_wallet/vc_puzzles/std_parent_morpher.clsp +0 -23
- chia/wallet/vc_wallet/vc_puzzles/std_parent_morpher.clsp.hex +0 -1
- chia/wallet/vc_wallet/vc_puzzles/viral_backdoor.clsp +0 -64
- chia/wallet/vc_wallet/vc_puzzles/viral_backdoor.clsp.hex +0 -1
- chia_blockchain-2.5.2rc2.dist-info/RECORD +0 -1042
- {chia_blockchain-2.5.2rc2.dist-info → chia_blockchain-2.5.3rc2.dist-info}/LICENSE +0 -0
- {chia_blockchain-2.5.2rc2.dist-info → chia_blockchain-2.5.3rc2.dist-info}/WHEEL +0 -0
- {chia_blockchain-2.5.2rc2.dist-info → chia_blockchain-2.5.3rc2.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from typing import Any, Literal, Optional, Union
|
|
5
|
+
|
|
6
|
+
from chia_rs.sized_bytes import bytes32
|
|
7
|
+
from chia_rs.sized_ints import uint16, uint64
|
|
8
|
+
from clvm_tools.binutils import disassemble
|
|
9
|
+
|
|
10
|
+
from chia.types.blockchain_format.program import Program
|
|
11
|
+
from chia.types.blockchain_format.serialized_program import SerializedProgram
|
|
12
|
+
from chia.util.bech32m import encode_puzzle_hash
|
|
13
|
+
from chia.wallet.nft_wallet.nft_info import NFTCoinInfo, NFTInfo
|
|
14
|
+
from chia.wallet.nft_wallet.nft_puzzles import (
|
|
15
|
+
NFT_OWNERSHIP_LAYER,
|
|
16
|
+
NFT_OWNERSHIP_LAYER_HASH,
|
|
17
|
+
NFT_STATE_LAYER_MOD,
|
|
18
|
+
NFT_STATE_LAYER_MOD_HASH,
|
|
19
|
+
NFT_TRANSFER_PROGRAM_DEFAULT,
|
|
20
|
+
)
|
|
21
|
+
from chia.wallet.nft_wallet.uncurry_nft import UncurriedNFT
|
|
22
|
+
from chia.wallet.puzzles.p2_delegated_puzzle_or_hidden_puzzle import solution_for_conditions
|
|
23
|
+
from chia.wallet.singleton import (
|
|
24
|
+
SINGLETON_LAUNCHER_PUZZLE_HASH,
|
|
25
|
+
SINGLETON_TOP_LAYER_MOD,
|
|
26
|
+
SINGLETON_TOP_LAYER_MOD_HASH,
|
|
27
|
+
)
|
|
28
|
+
from chia.wallet.util.address_type import AddressType
|
|
29
|
+
|
|
30
|
+
log = logging.getLogger(__name__)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def create_nft_layer_puzzle_with_curry_params(
|
|
34
|
+
metadata: Program, metadata_updater_hash: bytes32, inner_puzzle: Program
|
|
35
|
+
) -> Program:
|
|
36
|
+
"""Curries params into nft_state_layer.clsp
|
|
37
|
+
|
|
38
|
+
Args to curry:
|
|
39
|
+
NFT_STATE_LAYER_MOD_HASH
|
|
40
|
+
METADATA
|
|
41
|
+
METADATA_UPDATER_PUZZLE_HASH
|
|
42
|
+
INNER_PUZZLE"""
|
|
43
|
+
return NFT_STATE_LAYER_MOD.curry(NFT_STATE_LAYER_MOD_HASH, metadata, metadata_updater_hash, inner_puzzle)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def create_full_puzzle_with_nft_puzzle(singleton_id: bytes32, inner_puzzle: Program) -> Program:
|
|
47
|
+
if log.isEnabledFor(logging.DEBUG):
|
|
48
|
+
log.debug("Creating full NFT puzzle with inner puzzle: \n%r\n%r", singleton_id, inner_puzzle.get_tree_hash())
|
|
49
|
+
singleton_struct = Program.to((SINGLETON_TOP_LAYER_MOD_HASH, (singleton_id, SINGLETON_LAUNCHER_PUZZLE_HASH)))
|
|
50
|
+
|
|
51
|
+
full_puzzle = SINGLETON_TOP_LAYER_MOD.curry(singleton_struct, inner_puzzle)
|
|
52
|
+
if log.isEnabledFor(logging.DEBUG):
|
|
53
|
+
log.debug("Created NFT full puzzle with inner: %s", full_puzzle.get_tree_hash())
|
|
54
|
+
return full_puzzle
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def create_full_puzzle(
|
|
58
|
+
singleton_id: bytes32, metadata: Program, metadata_updater_puzhash: bytes32, inner_puzzle: Program
|
|
59
|
+
) -> Program:
|
|
60
|
+
if log.isEnabledFor(logging.DEBUG):
|
|
61
|
+
log.debug(
|
|
62
|
+
"Creating full NFT puzzle with: \n%r\n%r\n%r\n%r",
|
|
63
|
+
singleton_id,
|
|
64
|
+
metadata.get_tree_hash(),
|
|
65
|
+
metadata_updater_puzhash,
|
|
66
|
+
inner_puzzle.get_tree_hash(),
|
|
67
|
+
)
|
|
68
|
+
singleton_struct = Program.to((SINGLETON_TOP_LAYER_MOD_HASH, (singleton_id, SINGLETON_LAUNCHER_PUZZLE_HASH)))
|
|
69
|
+
singleton_inner_puzzle = create_nft_layer_puzzle_with_curry_params(metadata, metadata_updater_puzhash, inner_puzzle)
|
|
70
|
+
|
|
71
|
+
full_puzzle = SINGLETON_TOP_LAYER_MOD.curry(singleton_struct, singleton_inner_puzzle)
|
|
72
|
+
if log.isEnabledFor(logging.DEBUG):
|
|
73
|
+
log.debug("Created NFT full puzzle: %s", full_puzzle.get_tree_hash())
|
|
74
|
+
return full_puzzle
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
async def get_nft_info_from_puzzle(nft_coin_info: NFTCoinInfo, config: dict[str, Any]) -> NFTInfo:
|
|
78
|
+
"""
|
|
79
|
+
Extract NFT info from a full puzzle
|
|
80
|
+
:param nft_coin_info NFTCoinInfo in local database
|
|
81
|
+
:param config Wallet config
|
|
82
|
+
:param ignore_size_limit Ignore the off-chain metadata loading size limit
|
|
83
|
+
:return: NFTInfo
|
|
84
|
+
"""
|
|
85
|
+
uncurried_nft: Optional[UncurriedNFT] = UncurriedNFT.uncurry(*nft_coin_info.full_puzzle.uncurry())
|
|
86
|
+
assert uncurried_nft is not None
|
|
87
|
+
data_uris: list[str] = []
|
|
88
|
+
|
|
89
|
+
for uri in uncurried_nft.data_uris.as_python():
|
|
90
|
+
data_uris.append(str(uri, "utf-8"))
|
|
91
|
+
meta_uris: list[str] = []
|
|
92
|
+
for uri in uncurried_nft.meta_uris.as_python():
|
|
93
|
+
meta_uris.append(str(uri, "utf-8"))
|
|
94
|
+
license_uris: list[str] = []
|
|
95
|
+
for uri in uncurried_nft.license_uris.as_python():
|
|
96
|
+
license_uris.append(str(uri, "utf-8"))
|
|
97
|
+
off_chain_metadata: Optional[str] = None
|
|
98
|
+
nft_info = NFTInfo(
|
|
99
|
+
encode_puzzle_hash(uncurried_nft.singleton_launcher_id, prefix=AddressType.NFT.hrp(config=config)),
|
|
100
|
+
uncurried_nft.singleton_launcher_id,
|
|
101
|
+
nft_coin_info.coin.name(),
|
|
102
|
+
nft_coin_info.latest_height,
|
|
103
|
+
uncurried_nft.owner_did,
|
|
104
|
+
uncurried_nft.trade_price_percentage,
|
|
105
|
+
uncurried_nft.royalty_address,
|
|
106
|
+
data_uris,
|
|
107
|
+
uncurried_nft.data_hash.as_python(),
|
|
108
|
+
meta_uris,
|
|
109
|
+
uncurried_nft.meta_hash.as_python(),
|
|
110
|
+
license_uris,
|
|
111
|
+
uncurried_nft.license_hash.as_python(),
|
|
112
|
+
uint64(uncurried_nft.edition_total.as_int()),
|
|
113
|
+
uint64(uncurried_nft.edition_number.as_int()),
|
|
114
|
+
uncurried_nft.metadata_updater_hash.as_python(),
|
|
115
|
+
disassemble(uncurried_nft.metadata),
|
|
116
|
+
nft_coin_info.mint_height,
|
|
117
|
+
uncurried_nft.supports_did,
|
|
118
|
+
uncurried_nft.p2_puzzle.get_tree_hash(),
|
|
119
|
+
nft_coin_info.pending_transaction,
|
|
120
|
+
nft_coin_info.minter_did,
|
|
121
|
+
off_chain_metadata=off_chain_metadata,
|
|
122
|
+
)
|
|
123
|
+
return nft_info
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def metadata_to_program(metadata: dict[bytes, Any]) -> Program:
|
|
127
|
+
"""
|
|
128
|
+
Convert the metadata dict to a Chialisp program
|
|
129
|
+
:param metadata: User defined metadata
|
|
130
|
+
:return: Chialisp program
|
|
131
|
+
"""
|
|
132
|
+
kv_list = []
|
|
133
|
+
for key, value in metadata.items():
|
|
134
|
+
kv_list.append((key, value))
|
|
135
|
+
program: Program = Program.to(kv_list)
|
|
136
|
+
return program
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def nft_program_to_metadata(program: Program) -> dict[bytes, Any]:
|
|
140
|
+
"""
|
|
141
|
+
Convert a program to a metadata dict
|
|
142
|
+
:param program: Chialisp program contains the metadata
|
|
143
|
+
:return: Metadata dict
|
|
144
|
+
"""
|
|
145
|
+
metadata = {}
|
|
146
|
+
for kv_pair in program.as_iter():
|
|
147
|
+
metadata[kv_pair.first().as_atom()] = kv_pair.rest().as_python()
|
|
148
|
+
return metadata
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def prepend_value(key: bytes, value: Program, metadata: dict[bytes, Any]) -> None:
|
|
152
|
+
"""
|
|
153
|
+
Prepend a value to a list in the metadata
|
|
154
|
+
:param key: Key of the field
|
|
155
|
+
:param value: Value want to add
|
|
156
|
+
:param metadata: Metadata
|
|
157
|
+
:return:
|
|
158
|
+
"""
|
|
159
|
+
if value != Program.to(0):
|
|
160
|
+
if metadata[key] == b"":
|
|
161
|
+
metadata[key] = [value.as_python()]
|
|
162
|
+
else:
|
|
163
|
+
metadata[key].insert(0, value.as_python())
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def update_metadata(metadata: Program, update_condition: Program) -> Program:
|
|
167
|
+
"""
|
|
168
|
+
Apply conditions of metadata updater to the previous metadata
|
|
169
|
+
:param metadata: Previous metadata
|
|
170
|
+
:param update_condition: Update metadata conditions
|
|
171
|
+
:return: Updated metadata
|
|
172
|
+
"""
|
|
173
|
+
new_metadata: dict[bytes, Any] = nft_program_to_metadata(metadata)
|
|
174
|
+
uri: Program = update_condition.rest().rest().first()
|
|
175
|
+
prepend_value(uri.first().as_python(), uri.rest(), new_metadata)
|
|
176
|
+
return metadata_to_program(new_metadata)
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def construct_ownership_layer(
|
|
180
|
+
current_owner: Optional[bytes32],
|
|
181
|
+
transfer_program: Program,
|
|
182
|
+
inner_puzzle: Program,
|
|
183
|
+
) -> Program:
|
|
184
|
+
return NFT_OWNERSHIP_LAYER.curry(NFT_OWNERSHIP_LAYER_HASH, current_owner, transfer_program, inner_puzzle)
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def create_ownership_layer_puzzle(
|
|
188
|
+
nft_id: bytes32,
|
|
189
|
+
did_id: bytes,
|
|
190
|
+
p2_puzzle: Program,
|
|
191
|
+
percentage: uint16,
|
|
192
|
+
royalty_puzzle_hash: Optional[bytes32] = None,
|
|
193
|
+
) -> Program:
|
|
194
|
+
log.debug(
|
|
195
|
+
"Creating ownership layer puzzle with NFT_ID: %s DID_ID: %s Royalty_Percentage: %d P2_puzzle: %s",
|
|
196
|
+
nft_id.hex(),
|
|
197
|
+
did_id,
|
|
198
|
+
percentage,
|
|
199
|
+
p2_puzzle,
|
|
200
|
+
)
|
|
201
|
+
singleton_struct = Program.to((SINGLETON_TOP_LAYER_MOD_HASH, (nft_id, SINGLETON_LAUNCHER_PUZZLE_HASH)))
|
|
202
|
+
if not royalty_puzzle_hash:
|
|
203
|
+
royalty_puzzle_hash = p2_puzzle.get_tree_hash()
|
|
204
|
+
transfer_program = NFT_TRANSFER_PROGRAM_DEFAULT.curry(singleton_struct, royalty_puzzle_hash, percentage)
|
|
205
|
+
nft_inner_puzzle = p2_puzzle
|
|
206
|
+
|
|
207
|
+
nft_ownership_layer_puzzle = construct_ownership_layer(
|
|
208
|
+
bytes32(did_id) if did_id else None, transfer_program, nft_inner_puzzle
|
|
209
|
+
)
|
|
210
|
+
return nft_ownership_layer_puzzle
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def create_ownership_layer_transfer_solution(
|
|
214
|
+
new_did: bytes, new_did_inner_hash: bytes, trade_prices_list: list[list[int]], new_puzhash: bytes32
|
|
215
|
+
) -> Program:
|
|
216
|
+
log.debug(
|
|
217
|
+
"Creating a transfer solution with: DID:%s Inner_puzhash:%s trade_price:%s puzhash:%s",
|
|
218
|
+
new_did.hex(),
|
|
219
|
+
new_did_inner_hash.hex(),
|
|
220
|
+
str(trade_prices_list),
|
|
221
|
+
new_puzhash.hex(),
|
|
222
|
+
)
|
|
223
|
+
condition_list = [[51, new_puzhash, 1, [new_puzhash]], [-10, new_did, trade_prices_list, new_did_inner_hash]]
|
|
224
|
+
log.debug("Condition list raw: %r", condition_list)
|
|
225
|
+
solution = Program.to([[solution_for_conditions(condition_list)]])
|
|
226
|
+
log.debug("Generated transfer solution: %s", solution)
|
|
227
|
+
return solution
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def get_metadata_and_phs(unft: UncurriedNFT, solution: SerializedProgram) -> tuple[Program, bytes32]:
|
|
231
|
+
conditions = unft.p2_puzzle.run(unft.get_innermost_solution(solution.to_program()))
|
|
232
|
+
metadata = unft.metadata
|
|
233
|
+
puzhash_for_derivation: Optional[bytes32] = None
|
|
234
|
+
for condition in conditions.as_iter():
|
|
235
|
+
if condition.list_len() < 2:
|
|
236
|
+
# invalid condition
|
|
237
|
+
continue
|
|
238
|
+
condition_code = condition.first().as_int()
|
|
239
|
+
log.debug("Checking condition code: %r", condition_code)
|
|
240
|
+
if condition_code == -24:
|
|
241
|
+
# metadata update
|
|
242
|
+
metadata = update_metadata(metadata, condition)
|
|
243
|
+
metadata = Program.to(metadata)
|
|
244
|
+
elif condition_code == 51:
|
|
245
|
+
atom = condition.rest().rest().first().as_int()
|
|
246
|
+
|
|
247
|
+
if atom == 1:
|
|
248
|
+
# destination puzhash
|
|
249
|
+
if puzhash_for_derivation is not None:
|
|
250
|
+
# ignore duplicated create coin conditions
|
|
251
|
+
continue
|
|
252
|
+
memo = bytes32(condition.at("rrrff").as_atom())
|
|
253
|
+
puzhash_for_derivation = memo
|
|
254
|
+
log.debug("Got back puzhash from solution: %s", puzhash_for_derivation)
|
|
255
|
+
assert puzhash_for_derivation
|
|
256
|
+
return metadata, puzhash_for_derivation
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def recurry_nft_puzzle(unft: UncurriedNFT, solution: Program, new_inner_puzzle: Program) -> Program:
|
|
260
|
+
log.debug("Generating NFT puzzle with ownership support: %s", disassemble(solution))
|
|
261
|
+
conditions = unft.p2_puzzle.run(unft.get_innermost_solution(solution))
|
|
262
|
+
new_did_id = unft.owner_did
|
|
263
|
+
new_puzhash = None
|
|
264
|
+
for condition in conditions.as_iter():
|
|
265
|
+
if condition.first().as_int() == -10:
|
|
266
|
+
# this is the change owner magic condition
|
|
267
|
+
atom = condition.at("rf").atom
|
|
268
|
+
if atom is None or atom == b"":
|
|
269
|
+
new_did_id = None
|
|
270
|
+
else:
|
|
271
|
+
new_did_id = bytes32(atom)
|
|
272
|
+
elif condition.first().as_int() == 51:
|
|
273
|
+
new_puzhash = condition.at("rf").atom
|
|
274
|
+
# assert new_puzhash and new_did_id
|
|
275
|
+
log.debug(f"Found NFT puzzle details: {new_did_id!r} {new_puzhash!r}")
|
|
276
|
+
assert unft.transfer_program
|
|
277
|
+
new_ownership_puzzle = construct_ownership_layer(new_did_id, unft.transfer_program, new_inner_puzzle)
|
|
278
|
+
|
|
279
|
+
return new_ownership_puzzle
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
def get_new_owner_did(unft: UncurriedNFT, solution: Program) -> Union[Literal[b""], bytes32, None]:
|
|
283
|
+
conditions = unft.p2_puzzle.run(unft.get_innermost_solution(solution))
|
|
284
|
+
new_did_id: Union[Literal[b""], bytes32, None] = None
|
|
285
|
+
for condition in conditions.as_iter():
|
|
286
|
+
if condition.first().as_int() == -10:
|
|
287
|
+
# this is the change owner magic condition
|
|
288
|
+
atom = condition.at("rf").as_atom()
|
|
289
|
+
if atom == b"":
|
|
290
|
+
new_did_id = b""
|
|
291
|
+
else:
|
|
292
|
+
new_did_id = bytes32(atom)
|
|
293
|
+
return new_did_id
|
|
@@ -1,305 +1,28 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
from chia.types.blockchain_format.sized_bytes import bytes32
|
|
11
|
-
from chia.util.bech32m import encode_puzzle_hash
|
|
12
|
-
from chia.util.ints import uint16, uint64
|
|
13
|
-
from chia.wallet.nft_wallet.nft_info import NFTCoinInfo, NFTInfo
|
|
14
|
-
from chia.wallet.nft_wallet.uncurry_nft import UncurriedNFT
|
|
15
|
-
from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile
|
|
16
|
-
from chia.wallet.puzzles.p2_delegated_puzzle_or_hidden_puzzle import solution_for_conditions
|
|
17
|
-
from chia.wallet.util.address_type import AddressType
|
|
18
|
-
|
|
19
|
-
log = logging.getLogger(__name__)
|
|
20
|
-
SINGLETON_TOP_LAYER_MOD = load_clvm_maybe_recompile("singleton_top_layer_v1_1.clsp")
|
|
21
|
-
LAUNCHER_PUZZLE = load_clvm_maybe_recompile("singleton_launcher.clsp")
|
|
22
|
-
NFT_STATE_LAYER_MOD = load_clvm_maybe_recompile(
|
|
23
|
-
"nft_state_layer.clsp", package_or_requirement="chia.wallet.nft_wallet.puzzles"
|
|
24
|
-
)
|
|
25
|
-
LAUNCHER_PUZZLE_HASH = LAUNCHER_PUZZLE.get_tree_hash()
|
|
26
|
-
SINGLETON_MOD_HASH = SINGLETON_TOP_LAYER_MOD.get_tree_hash()
|
|
27
|
-
NFT_STATE_LAYER_MOD_HASH = NFT_STATE_LAYER_MOD.get_tree_hash()
|
|
28
|
-
NFT_METADATA_UPDATER = load_clvm_maybe_recompile(
|
|
29
|
-
"nft_metadata_updater_default.clsp", package_or_requirement="chia.wallet.nft_wallet.puzzles"
|
|
3
|
+
from chia_puzzles_py.programs import (
|
|
4
|
+
NFT_INTERMEDIATE_LAUNCHER,
|
|
5
|
+
NFT_METADATA_UPDATER_DEFAULT,
|
|
6
|
+
NFT_METADATA_UPDATER_DEFAULT_HASH,
|
|
7
|
+
NFT_OWNERSHIP_TRANSFER_PROGRAM_ONE_WAY_CLAIM_WITH_ROYALTIES,
|
|
8
|
+
NFT_STATE_LAYER,
|
|
9
|
+
NFT_STATE_LAYER_HASH,
|
|
30
10
|
)
|
|
31
|
-
|
|
32
|
-
|
|
11
|
+
from chia_puzzles_py.programs import (
|
|
12
|
+
NFT_OWNERSHIP_LAYER as NFT_OWNERSHIP_LAYER_BYTES,
|
|
33
13
|
)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"nft_ownership_transfer_program_one_way_claim_with_royalties.clsp",
|
|
37
|
-
package_or_requirement="chia.wallet.nft_wallet.puzzles",
|
|
14
|
+
from chia_puzzles_py.programs import (
|
|
15
|
+
NFT_OWNERSHIP_LAYER_HASH as NFT_OWNERSHIP_LAYER_HASH_BYTES,
|
|
38
16
|
)
|
|
39
|
-
|
|
40
|
-
INTERMEDIATE_LAUNCHER_MOD = load_clvm_maybe_recompile(
|
|
41
|
-
"nft_intermediate_launcher.clsp", package_or_requirement="chia.wallet.nft_wallet.puzzles"
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def create_nft_layer_puzzle_with_curry_params(
|
|
46
|
-
metadata: Program, metadata_updater_hash: bytes32, inner_puzzle: Program
|
|
47
|
-
) -> Program:
|
|
48
|
-
"""Curries params into nft_state_layer.clsp
|
|
49
|
-
|
|
50
|
-
Args to curry:
|
|
51
|
-
NFT_STATE_LAYER_MOD_HASH
|
|
52
|
-
METADATA
|
|
53
|
-
METADATA_UPDATER_PUZZLE_HASH
|
|
54
|
-
INNER_PUZZLE"""
|
|
55
|
-
return NFT_STATE_LAYER_MOD.curry(NFT_STATE_LAYER_MOD_HASH, metadata, metadata_updater_hash, inner_puzzle)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
def create_full_puzzle_with_nft_puzzle(singleton_id: bytes32, inner_puzzle: Program) -> Program:
|
|
59
|
-
if log.isEnabledFor(logging.DEBUG):
|
|
60
|
-
log.debug("Creating full NFT puzzle with inner puzzle: \n%r\n%r", singleton_id, inner_puzzle.get_tree_hash())
|
|
61
|
-
singleton_struct = Program.to((SINGLETON_MOD_HASH, (singleton_id, LAUNCHER_PUZZLE_HASH)))
|
|
62
|
-
|
|
63
|
-
full_puzzle = SINGLETON_TOP_LAYER_MOD.curry(singleton_struct, inner_puzzle)
|
|
64
|
-
if log.isEnabledFor(logging.DEBUG):
|
|
65
|
-
log.debug("Created NFT full puzzle with inner: %s", full_puzzle.get_tree_hash())
|
|
66
|
-
return full_puzzle
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
def create_full_puzzle(
|
|
70
|
-
singleton_id: bytes32, metadata: Program, metadata_updater_puzhash: bytes32, inner_puzzle: Program
|
|
71
|
-
) -> Program:
|
|
72
|
-
if log.isEnabledFor(logging.DEBUG):
|
|
73
|
-
log.debug(
|
|
74
|
-
"Creating full NFT puzzle with: \n%r\n%r\n%r\n%r",
|
|
75
|
-
singleton_id,
|
|
76
|
-
metadata.get_tree_hash(),
|
|
77
|
-
metadata_updater_puzhash,
|
|
78
|
-
inner_puzzle.get_tree_hash(),
|
|
79
|
-
)
|
|
80
|
-
singleton_struct = Program.to((SINGLETON_MOD_HASH, (singleton_id, LAUNCHER_PUZZLE_HASH)))
|
|
81
|
-
singleton_inner_puzzle = create_nft_layer_puzzle_with_curry_params(metadata, metadata_updater_puzhash, inner_puzzle)
|
|
82
|
-
|
|
83
|
-
full_puzzle = SINGLETON_TOP_LAYER_MOD.curry(singleton_struct, singleton_inner_puzzle)
|
|
84
|
-
if log.isEnabledFor(logging.DEBUG):
|
|
85
|
-
log.debug("Created NFT full puzzle: %s", full_puzzle.get_tree_hash())
|
|
86
|
-
return full_puzzle
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
async def get_nft_info_from_puzzle(nft_coin_info: NFTCoinInfo, config: dict[str, Any]) -> NFTInfo:
|
|
90
|
-
"""
|
|
91
|
-
Extract NFT info from a full puzzle
|
|
92
|
-
:param nft_coin_info NFTCoinInfo in local database
|
|
93
|
-
:param config Wallet config
|
|
94
|
-
:param ignore_size_limit Ignore the off-chain metadata loading size limit
|
|
95
|
-
:return: NFTInfo
|
|
96
|
-
"""
|
|
97
|
-
uncurried_nft: Optional[UncurriedNFT] = UncurriedNFT.uncurry(*nft_coin_info.full_puzzle.uncurry())
|
|
98
|
-
assert uncurried_nft is not None
|
|
99
|
-
data_uris: list[str] = []
|
|
100
|
-
|
|
101
|
-
for uri in uncurried_nft.data_uris.as_python():
|
|
102
|
-
data_uris.append(str(uri, "utf-8"))
|
|
103
|
-
meta_uris: list[str] = []
|
|
104
|
-
for uri in uncurried_nft.meta_uris.as_python():
|
|
105
|
-
meta_uris.append(str(uri, "utf-8"))
|
|
106
|
-
license_uris: list[str] = []
|
|
107
|
-
for uri in uncurried_nft.license_uris.as_python():
|
|
108
|
-
license_uris.append(str(uri, "utf-8"))
|
|
109
|
-
off_chain_metadata: Optional[str] = None
|
|
110
|
-
nft_info = NFTInfo(
|
|
111
|
-
encode_puzzle_hash(uncurried_nft.singleton_launcher_id, prefix=AddressType.NFT.hrp(config=config)),
|
|
112
|
-
uncurried_nft.singleton_launcher_id,
|
|
113
|
-
nft_coin_info.coin.name(),
|
|
114
|
-
nft_coin_info.latest_height,
|
|
115
|
-
uncurried_nft.owner_did,
|
|
116
|
-
uncurried_nft.trade_price_percentage,
|
|
117
|
-
uncurried_nft.royalty_address,
|
|
118
|
-
data_uris,
|
|
119
|
-
uncurried_nft.data_hash.as_python(),
|
|
120
|
-
meta_uris,
|
|
121
|
-
uncurried_nft.meta_hash.as_python(),
|
|
122
|
-
license_uris,
|
|
123
|
-
uncurried_nft.license_hash.as_python(),
|
|
124
|
-
uint64(uncurried_nft.edition_total.as_int()),
|
|
125
|
-
uint64(uncurried_nft.edition_number.as_int()),
|
|
126
|
-
uncurried_nft.metadata_updater_hash.as_python(),
|
|
127
|
-
disassemble(uncurried_nft.metadata),
|
|
128
|
-
nft_coin_info.mint_height,
|
|
129
|
-
uncurried_nft.supports_did,
|
|
130
|
-
uncurried_nft.p2_puzzle.get_tree_hash(),
|
|
131
|
-
nft_coin_info.pending_transaction,
|
|
132
|
-
nft_coin_info.minter_did,
|
|
133
|
-
off_chain_metadata=off_chain_metadata,
|
|
134
|
-
)
|
|
135
|
-
return nft_info
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
def metadata_to_program(metadata: dict[bytes, Any]) -> Program:
|
|
139
|
-
"""
|
|
140
|
-
Convert the metadata dict to a Chialisp program
|
|
141
|
-
:param metadata: User defined metadata
|
|
142
|
-
:return: Chialisp program
|
|
143
|
-
"""
|
|
144
|
-
kv_list = []
|
|
145
|
-
for key, value in metadata.items():
|
|
146
|
-
kv_list.append((key, value))
|
|
147
|
-
program: Program = Program.to(kv_list)
|
|
148
|
-
return program
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
def nft_program_to_metadata(program: Program) -> dict[bytes, Any]:
|
|
152
|
-
"""
|
|
153
|
-
Convert a program to a metadata dict
|
|
154
|
-
:param program: Chialisp program contains the metadata
|
|
155
|
-
:return: Metadata dict
|
|
156
|
-
"""
|
|
157
|
-
metadata = {}
|
|
158
|
-
for kv_pair in program.as_iter():
|
|
159
|
-
metadata[kv_pair.first().as_atom()] = kv_pair.rest().as_python()
|
|
160
|
-
return metadata
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
def prepend_value(key: bytes, value: Program, metadata: dict[bytes, Any]) -> None:
|
|
164
|
-
"""
|
|
165
|
-
Prepend a value to a list in the metadata
|
|
166
|
-
:param key: Key of the field
|
|
167
|
-
:param value: Value want to add
|
|
168
|
-
:param metadata: Metadata
|
|
169
|
-
:return:
|
|
170
|
-
"""
|
|
171
|
-
if value != Program.to(0):
|
|
172
|
-
if metadata[key] == b"":
|
|
173
|
-
metadata[key] = [value.as_python()]
|
|
174
|
-
else:
|
|
175
|
-
metadata[key].insert(0, value.as_python())
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
def update_metadata(metadata: Program, update_condition: Program) -> Program:
|
|
179
|
-
"""
|
|
180
|
-
Apply conditions of metadata updater to the previous metadata
|
|
181
|
-
:param metadata: Previous metadata
|
|
182
|
-
:param update_condition: Update metadata conditions
|
|
183
|
-
:return: Updated metadata
|
|
184
|
-
"""
|
|
185
|
-
new_metadata: dict[bytes, Any] = nft_program_to_metadata(metadata)
|
|
186
|
-
uri: Program = update_condition.rest().rest().first()
|
|
187
|
-
prepend_value(uri.first().as_python(), uri.rest(), new_metadata)
|
|
188
|
-
return metadata_to_program(new_metadata)
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
def construct_ownership_layer(
|
|
192
|
-
current_owner: Optional[bytes32],
|
|
193
|
-
transfer_program: Program,
|
|
194
|
-
inner_puzzle: Program,
|
|
195
|
-
) -> Program:
|
|
196
|
-
return NFT_OWNERSHIP_LAYER.curry(NFT_OWNERSHIP_LAYER_HASH, current_owner, transfer_program, inner_puzzle)
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
def create_ownership_layer_puzzle(
|
|
200
|
-
nft_id: bytes32,
|
|
201
|
-
did_id: bytes,
|
|
202
|
-
p2_puzzle: Program,
|
|
203
|
-
percentage: uint16,
|
|
204
|
-
royalty_puzzle_hash: Optional[bytes32] = None,
|
|
205
|
-
) -> Program:
|
|
206
|
-
log.debug(
|
|
207
|
-
"Creating ownership layer puzzle with NFT_ID: %s DID_ID: %s Royalty_Percentage: %d P2_puzzle: %s",
|
|
208
|
-
nft_id.hex(),
|
|
209
|
-
did_id,
|
|
210
|
-
percentage,
|
|
211
|
-
p2_puzzle,
|
|
212
|
-
)
|
|
213
|
-
singleton_struct = Program.to((SINGLETON_MOD_HASH, (nft_id, LAUNCHER_PUZZLE_HASH)))
|
|
214
|
-
if not royalty_puzzle_hash:
|
|
215
|
-
royalty_puzzle_hash = p2_puzzle.get_tree_hash()
|
|
216
|
-
transfer_program = NFT_TRANSFER_PROGRAM_DEFAULT.curry(singleton_struct, royalty_puzzle_hash, percentage)
|
|
217
|
-
nft_inner_puzzle = p2_puzzle
|
|
218
|
-
|
|
219
|
-
nft_ownership_layer_puzzle = construct_ownership_layer(
|
|
220
|
-
bytes32(did_id) if did_id else None, transfer_program, nft_inner_puzzle
|
|
221
|
-
)
|
|
222
|
-
return nft_ownership_layer_puzzle
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
def create_ownership_layer_transfer_solution(
|
|
226
|
-
new_did: bytes, new_did_inner_hash: bytes, trade_prices_list: list[list[int]], new_puzhash: bytes32
|
|
227
|
-
) -> Program:
|
|
228
|
-
log.debug(
|
|
229
|
-
"Creating a transfer solution with: DID:%s Inner_puzhash:%s trade_price:%s puzhash:%s",
|
|
230
|
-
new_did.hex(),
|
|
231
|
-
new_did_inner_hash.hex(),
|
|
232
|
-
str(trade_prices_list),
|
|
233
|
-
new_puzhash.hex(),
|
|
234
|
-
)
|
|
235
|
-
condition_list = [[51, new_puzhash, 1, [new_puzhash]], [-10, new_did, trade_prices_list, new_did_inner_hash]]
|
|
236
|
-
log.debug("Condition list raw: %r", condition_list)
|
|
237
|
-
solution = Program.to([[solution_for_conditions(condition_list)]])
|
|
238
|
-
log.debug("Generated transfer solution: %s", solution)
|
|
239
|
-
return solution
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
def get_metadata_and_phs(unft: UncurriedNFT, solution: SerializedProgram) -> tuple[Program, bytes32]:
|
|
243
|
-
conditions = unft.p2_puzzle.run(unft.get_innermost_solution(solution.to_program()))
|
|
244
|
-
metadata = unft.metadata
|
|
245
|
-
puzhash_for_derivation: Optional[bytes32] = None
|
|
246
|
-
for condition in conditions.as_iter():
|
|
247
|
-
if condition.list_len() < 2:
|
|
248
|
-
# invalid condition
|
|
249
|
-
continue
|
|
250
|
-
condition_code = condition.first().as_int()
|
|
251
|
-
log.debug("Checking condition code: %r", condition_code)
|
|
252
|
-
if condition_code == -24:
|
|
253
|
-
# metadata update
|
|
254
|
-
metadata = update_metadata(metadata, condition)
|
|
255
|
-
metadata = Program.to(metadata)
|
|
256
|
-
elif condition_code == 51:
|
|
257
|
-
atom = condition.rest().rest().first().as_int()
|
|
258
|
-
|
|
259
|
-
if atom == 1:
|
|
260
|
-
# destination puzhash
|
|
261
|
-
if puzhash_for_derivation is not None:
|
|
262
|
-
# ignore duplicated create coin conditions
|
|
263
|
-
continue
|
|
264
|
-
memo = bytes32(condition.at("rrrff").as_atom())
|
|
265
|
-
puzhash_for_derivation = memo
|
|
266
|
-
log.debug("Got back puzhash from solution: %s", puzhash_for_derivation)
|
|
267
|
-
assert puzhash_for_derivation
|
|
268
|
-
return metadata, puzhash_for_derivation
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
def recurry_nft_puzzle(unft: UncurriedNFT, solution: Program, new_inner_puzzle: Program) -> Program:
|
|
272
|
-
log.debug("Generating NFT puzzle with ownership support: %s", disassemble(solution))
|
|
273
|
-
conditions = unft.p2_puzzle.run(unft.get_innermost_solution(solution))
|
|
274
|
-
new_did_id = unft.owner_did
|
|
275
|
-
new_puzhash = None
|
|
276
|
-
for condition in conditions.as_iter():
|
|
277
|
-
if condition.first().as_int() == -10:
|
|
278
|
-
# this is the change owner magic condition
|
|
279
|
-
atom = condition.at("rf").atom
|
|
280
|
-
if atom is None or atom == b"":
|
|
281
|
-
new_did_id = None
|
|
282
|
-
else:
|
|
283
|
-
new_did_id = bytes32(atom)
|
|
284
|
-
elif condition.first().as_int() == 51:
|
|
285
|
-
new_puzhash = condition.at("rf").atom
|
|
286
|
-
# assert new_puzhash and new_did_id
|
|
287
|
-
log.debug(f"Found NFT puzzle details: {new_did_id!r} {new_puzhash!r}")
|
|
288
|
-
assert unft.transfer_program
|
|
289
|
-
new_ownership_puzzle = construct_ownership_layer(new_did_id, unft.transfer_program, new_inner_puzzle)
|
|
290
|
-
|
|
291
|
-
return new_ownership_puzzle
|
|
17
|
+
from chia_rs.sized_bytes import bytes32
|
|
292
18
|
|
|
19
|
+
from chia.types.blockchain_format.program import Program
|
|
293
20
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
new_did_id = b""
|
|
303
|
-
else:
|
|
304
|
-
new_did_id = bytes32(atom)
|
|
305
|
-
return new_did_id
|
|
21
|
+
NFT_STATE_LAYER_MOD = Program.from_bytes(NFT_STATE_LAYER)
|
|
22
|
+
NFT_STATE_LAYER_MOD_HASH = bytes32(NFT_STATE_LAYER_HASH)
|
|
23
|
+
NFT_METADATA_UPDATER = Program.from_bytes(NFT_METADATA_UPDATER_DEFAULT)
|
|
24
|
+
NFT_METADATA_UPDATER_HASH = bytes32(NFT_METADATA_UPDATER_DEFAULT_HASH)
|
|
25
|
+
NFT_OWNERSHIP_LAYER = Program.from_bytes(NFT_OWNERSHIP_LAYER_BYTES)
|
|
26
|
+
NFT_OWNERSHIP_LAYER_HASH = bytes32(NFT_OWNERSHIP_LAYER_HASH_BYTES)
|
|
27
|
+
NFT_TRANSFER_PROGRAM_DEFAULT = Program.from_bytes(NFT_OWNERSHIP_TRANSFER_PROGRAM_ONE_WAY_CLAIM_WITH_ROYALTIES)
|
|
28
|
+
INTERMEDIATE_LAUNCHER_MOD = Program.from_bytes(NFT_INTERMEDIATE_LAUNCHER)
|