Skip to main content

chip35_dl_coin/
lib.rs

1//! # chip35-dl-coin
2//!
3//! Isolated CHIP-0035 Chia DataLayer **store coin** driver. Provides the
4//! offline spend builders to mint, update, and burn (melt) DataLayer stores,
5//! plus keyless spend-bundle serialization helpers. No networking, no signing,
6//! no key derivation — those are the caller's responsibility.
7
8mod cat;
9mod collection;
10mod consolidation;
11mod did;
12mod dig;
13mod error;
14mod gating;
15mod lazy_mint;
16mod metadata;
17mod nft;
18mod offer;
19mod payment;
20mod select;
21mod store;
22mod subscription;
23mod types;
24
25// Re-export the chia primitives consumers/bindings need.
26pub use chia_bls::{master_to_wallet_unhardened, PublicKey, SecretKey, Signature};
27pub use chia_protocol::{Bytes, Bytes32, Coin, CoinSpend, Program, SpendBundle};
28pub use chia_puzzle_types::{EveProof, LineageProof, Proof};
29// chia-sdk-driver 0.36 respelled `DataStore*` as `Datastore*`. This crate keeps the original
30// spelling because it is echoed verbatim by the wasm bindings' exported names and their generated
31// TypeScript declarations (`wasm/src/ts.rs`), which are a published JavaScript contract; renaming
32// the Rust type would break every JS consumer for a purely cosmetic upstream change. The alias is
33// confined to this one boundary so the rest of the crate speaks a single spelling.
34pub use chia_sdk_driver::{
35    Datastore as DataStore, DatastoreInfo as DataStoreInfo, DatastoreMetadata as DataStoreMetadata,
36    DelegatedPuzzle, Did, DidInfo, HashedPtr,
37};
38
39pub use error::{Error, WalletError};
40
41// DIG-CAT per-capsule store payment (the canonical store-payment builder). Minting a store is FREE
42// of $DIG; a capsule (commit / root-advance) pays the dynamic, USD-pegged per-capsule price in $DIG
43// to the treasury via [`build_dig_store_payment`], concatenated atomically with the root-advance.
44pub use dig::{
45    build_dig_store_payment, dig_treasury_payment_coin, DIG_ASSET_ID,
46    DIG_TREASURY_INNER_PUZZLE_HASH,
47};
48
49pub use store::{
50    add_fee, admin_delegated_puzzle_from_key, datastore_from_spend, digstore_owner_hint,
51    hex_spend_bundle_to_coin_spends, melt_store, mint_store, oracle_delegated_puzzle, oracle_spend,
52    spend_bundle_to_hex, update_store_metadata, update_store_ownership,
53    writer_delegated_puzzle_from_key, DataStoreInnerSpend, DATASTORE_LAUNCHER_HINT,
54    DIGSTORE_OWNER_HINT_DOMAIN,
55};
56pub use types::SuccessResponse;
57
58// Asset toolkit (roadmap #33/#34/#35/#36).
59pub use cat::{issue_cat, IssueCatResponse};
60pub use collection::{
61    build_bulk_mint, build_bulk_mint_funded, build_bulk_mint_funded_no_did, generate_item_metadata,
62    synthetic_puzzle_hash, BulkMintResponse, Collection, ManifestItem, ManifestMedia,
63};
64pub use did::{create_did, CreateDidResponse};
65// Trustless lazy mint / mint-on-claim (roadmap #40): the creator DID precommits a collection ONCE,
66// then anyone mints an individual NFT on demand with no further DID involvement.
67pub use lazy_mint::{
68    build_lazy_mint_claim, build_lazy_mint_commit, merkle_membership_root,
69    verify_merkle_membership, LazyMintClaimResponse, LazyMintCommitResponse, LazyMintItem,
70    LazyMintPolicy, LazyMintTreeDescriptor, MerkleMembershipProof,
71};
72pub use metadata::{
73    sha256, validate_uri_hash, Attribute, Chip0007Metadata, CollectionAttribute, CollectionRef,
74    MetadataError, CHIP0007_FORMAT,
75};
76pub use nft::{
77    mint_nft, mint_nft_with_did, DidAttribution, NftMediaMetadata, NftMintParams, NftMintResponse,
78};
79pub use offer::{decode_offer, encode_offer};
80
81// In-dapp monetization (roadmap #46): payment, paywall (pay-to-unlock), NFT-gating, subscription
82// scaffold. The dapp deployed on DIG EARNs — these are the inbound-economic primitives.
83pub use gating::{
84    prove_collection_membership, prove_nft_ownership, read_nft_ownership, GatingError,
85    NftOwnershipProof,
86};
87pub use payment::{
88    build_cat_payment, build_xch_payment, payment_nonce, verify_payment_receipt, ObservedPayment,
89    PaymentAsset, PaymentReceipt, PaymentResponse, PaywallError,
90};
91
92// Shared coin selection + consolidation (epic #410 / #413): high-value-first selection with a
93// coin-count cap + a distinct NeedsConsolidation signal, plus the keyless self-send consolidation
94// builders the auto-combine loop submits when a wallet is too fragmented to move value. Released via
95// the chip35 wasm; byte-mirrored by the native Rust layer (dig-l1-wallet, #414).
96pub use consolidation::{build_cat_consolidation, build_coin_consolidation};
97pub use select::{select_coins, CoinSelection, SelectCoinsResult, DEFAULT_COIN_CAP};
98pub use subscription::{
99    build_subscription_authorization, build_subscription_claim, SubscriptionTerms,
100};
101
102// Re-export the Cat primitive (consumed by `build_cat_payment`'s caller to construct the buyer's CAT
103// coins, and by the wasm boundary).
104pub use chia_sdk_driver::{Cat, CatInfo};
105
106// Deploy-token delegation (roadmap #17): a deploy token is a **revocable writer delegate**, not a
107// bespoke puzzle. The prior hand-rolled scaffold (`deploy_token.rs`) is superseded — there is no
108// special deploy-token type. To issue one, the owner adds [`writer_delegated_puzzle_from_key`] for
109// the CI deploy key to the store's delegated-puzzle set via [`update_store_ownership`]; the deploy
110// key then advances the root with [`update_store_metadata`] under [`DataStoreInnerSpend::Writer`]
111// (a root advance IS a metadata update — no owner seed required). To revoke, the owner (or an admin
112// delegate) replaces the delegated-puzzle set, dropping that writer. An on-chain DIG spend-cap that
113// would further bound a deploy token is the only non-native extra and is future work.