Commit graph

3 commits

Author SHA1 Message Date
dd435a5e2d v0.2: add store, mint, and monitor integration tests
Three new modules land in tests/ alongside the v0.1 pure-module
tests:

- test_store_protocol.py: InMemoryStore round-trips + Protocol
  conformance. Covers create / get / update / list_by_status /
  next_derivation_index / record_tx idempotency + defensive-copy
  semantics.
- test_mint_metadata.py: mint_nft_cert end-to-end against a stubbed
  ChainContext (no live Ogmios). Exercises the 2-of-2 native-script
  policy shape, tx body construction, CIP-25 envelope CBOR
  round-trip, and the oversize-asset-name guard.
- test_monitor_with_inmemory_store.py: monitor loop driven against
  InMemoryStore with Koios + the oracle monkeypatched. Covers every
  status transition the scheduler cares about (confirm, overpay,
  underpay, stay-pending, record_tx, expiry skip) and the two
  reprice code paths (successful reprice bumps expected_lovelace +
  expires_at; max_repricings flips to EXPIRED).

All 42 tests pass on pycardano 0.16 with pytest-asyncio auto mode.
2026-04-23 19:58:46 -07:00
eef22dc5cd addresses: swap nonexistent HDPublicKey for HDWallet soft derivation
pycardano >=0.11 doesn't ship HDPublicKey — the v0.1 extraction
imported a symbol that never existed in the installed version, which
meant every address-derivation test failed at import time.

Use HDWallet rooted at the account level with public-only fields set,
then soft-derive receive chain (0) and staking chain (2). Hash the
resulting verification keys through PaymentVerificationKey /
StakeVerificationKey to compose the Shelley base address.

Refresh the test-vector xpub with a real, deterministic CIP-1852
account xpub derived from the well-known "test ... junk" mnemonic so
validate_xpub + derive_address actually exercise the BIP32 math.

Drop the "random hex should be rejected" assertion — BIP32-ED25519
soft derivation doesn't enforce that the 32-byte pubkey half is a
point on the curve, so arbitrary well-shaped hex is accepted by the
underlying crypto.
2026-04-23 19:55:16 -07:00
dc6378eda6 v0.1.0-dev: initial extraction from TradeCraft + new abstractions
Sulkta Coop's Python SDK for merchant-side Cardano payments +
NFT certificate-of-authenticity minting. Zero-custody by design.

Extracted from TradeCraft's services/cardano_*.py (2,400+ lines of
production Cardano-mainnet code) and restructured as an installable
Python package.

Package layout (cardano_checkout/):
- addresses.py   — lifted verbatim: CIP-1852 HD derivation, pure pycardano
- oracles.py     — lifted from cardano_price.py: Koios ADA/USD feed w/ 5m cache
- monitor.py     — lifted verbatim (SQLAlchemy-coupled; v0.2 refactors to Store)
- scheduler.py   — lifted verbatim (same refactor note)
- invoice.py     — NEW: framework-agnostic Invoice dataclass + lifecycle enum
- store.py       — NEW: InvoiceStore Protocol for pluggable persistence
- mint.py        — NEW: CIP-25 v2 metadata builder (works); tx submission stub for v0.2
- ipfs.py        — NEW: kubo HTTP client with primary-pin + mirror-pin pattern
- txbuild.py     — NEW: v0.2 stub for PyCardano / Ogmios tx construction

Design:
- Consumers provide xpub + InvoiceStore impl. SDK provides everything else.
- IPFS: local kubo for upload + serve, optional mirror pins for archival.
  Chromaticcraft pattern: Rackham kubo primary, Lucy kubo mirror.
- NFT: single native-script policy per merchant studio (CIP-25 v2, not CIP-68
  — full wallet coverage, no mutability needed for static certs). Policy skey
  stays under Sulkta cold-custody (Lucy pattern); signing is an external
  hand-off like ADAMaps payouts.

Tests: pure-module smoke tests pass for invoice, store-protocol, CIP-25
metadata envelope, IPFS client import, txbuild stub module. Address
derivation tests ship but require pycardano + will exercise in CI.

LICENSE: Apache-2.0 (matches upstream Cardano tooling).

Next (v0.2 scope):
- Refactor monitor + scheduler around InvoiceStore (drop SQLAlchemy coupling)
- Wire mint.mint_nft_cert to PyCardano + local Ogmios on Rackham
- txbuild: Ogmios chain-context + cold-signer hand-off shape
- chromaticcraft Phase 2 imports the SDK as its first external consumer
2026-04-23 18:04:00 -07:00