Expose contract-only RGB asset import - #68
Conversation
d7d9b23 to
a72948f
Compare
a72948f to
b33aac2
Compare
🌗 Pull Request OverviewThis PR exposes new Rust APIs for exporting and importing RGB asset contracts without transferring allocations. It introduces explicit persistence control in Reviewed Changes Show a summary per file
📋 Review Findings📄
|
|
Review: Expose contract-only RGB asset import Thanks for the thorough PR description — the reasoning around "persist the stock before committing SQL so every interrupted state is repairable on retry" is the right shape, and the A few things I think need attention before merge, roughly in order of importance. 1.
The winning thread holds that lockfile across: Two disk round-trips of the whole stock plus a SQLite commit inside a ~1.2 s budget, on a CI runner also running regtest and other parallel tests, is not a safe bet. When it loses, Suggestion: assert the invariant that actually matters rather than the cross-thread interleaving — after both threads finish, exactly one asset row exists, metadata is canonical, balance is zero — and tolerate 2. The attachment guard has a hole for UDA
let media = contract.contract_terms().media.map(|a| Media::from_attachment(&a, media_dir));rgb-lib own UDA issuance always passes This PR makes 3.
If a contract consignment produced by Two smaller points in the same expression:
4.
That is probably the behaviour you want, but it is an unannounced contract change on an existing public API: the doc comment still says "Extract the metadata of a new RGB asset and save the asset into the DB", and neither new branch has a test — not the idempotent success, not the 5. Both let contract_in_stock = runtime.genesis(contract_id).is_ok();6. Critical section is longer than needed, and repeat imports rewrite the whole stock The attachment rejection depends only on The same applies to the 7. Minor
8. Design question Contracts declaring attachments are rejected, and no companion "supply and verify the files" flow ships here. That means any NIA/CFA/IFA issued with a media file, and any UDA with token media, is simply not importable — and the doc comment points at a flow that does not exist yet. If the RLN use case involves media-bearing assets, the payload likely needs to carry the attachment bytes alongside the contract. Worth stating explicitly in the doc comment which asset shapes are in scope today. Nothing here is structural — the persistence ordering is sound and the repair semantics are well thought through. Items 1 (flaky test), 2 (UDA media hole) and 3 (panicking resolver on caller-supplied input) are the ones I would want resolved before merge. |
Problem
Fresh wallets need a way to register a trusted, network-specific RGB asset before the first transfer. An asset ID is only an identifier; it is not enough to reconstruct or validate the contract.
Changes
already_importedresultSemantics and safety
Direct rgb-lib consumers should preserve the library's existing single-writer discipline for heterogeneous wallet mutations. The RLN integration serializes these operations through its unlocked-wallet lifecycle guard.
Validation
Validated at
95332c41fd715939ac6e078ad859d474b1f6fa9b.Dependency chain
No ownership state can be created by this API; a real RGB transfer is still required before the wallet can hold or spend units.