@frontiercompute/zap1-zodl
v0.1.0
Published
ZAP1 helpers for the ZODL ecosystem. Typed swap, stake, faucet, Flexa, and address book attestations.
Readme
@frontiercompute/zap1-zodl
import { Zap1Client } from "@frontiercompute/zap1-attest";
import { ZodlZap1Client } from "@frontiercompute/zap1-zodl";
const zap1 = new Zap1Client({ baseUrl: process.env.ZAP1_BASE_URL, apiKey: process.env.ZAP1_API_KEY });
const zodl = new ZodlZap1Client(zap1, { app: "zashi-ios" });
const leaf = await zodl.attestSwap({ from: "ZEC", to: "USDC", amountIn: "125000000", amountInFormatted: "1.25", recipient: "0xfeedbeef", refundAddress: "u1refund", quote_id: "near-quote-123" });
const anchored = await zap1.waitForAnchor(leaf.leaf_hash, { timeoutMs: 600_000 });
console.log(leaf.leaf_hash, anchored.txid, anchored.height);Typed ZAP1 helpers for the ZODL ecosystem. The wrapper canonicalizes ZODL payloads, derives a deterministic serial_number, hashes the payload to contract_sha256, and submits a CONTRACT_ANCHOR leaf through @frontiercompute/zap1-attest.
No ZODL app code is imported. No endpoints or secrets are baked in.
Install
npm install @frontiercompute/zap1-attest @frontiercompute/zap1-zodlAPI
const zodl = new ZodlZap1Client(zap1, { app: "zashi-ios" });Supported apps:
zashi-ioszashi-androidzodl-ioszodl-androidzodl-web
Methods:
attestSwap({ from, to, amountIn, amountInFormatted, recipient, refundAddress, quote_id? })attestStake({ amount, finalizer_pubkey, stake_epoch })attestUnstake({ stake_id, finalizer_pubkey })attestFaucet({ recipient, amount, source })attestFlexaSession({ session_id, account_id, vendor_guard_present })attestAddressBookChange({ account_id, action, entry_count })
Each helper returns:
leaf_hashroot_hashverify_urlserial_numbercontract_sha256- normalized
payload policy_warnings
Event Encoding
Every helper uses:
event_type = "CONTRACT_ANCHOR"wallet_hash = "zodl-<app>"serial_number = "zodl-<type>-<hash8>"contract_sha256 = sha256(canonical_payload_json)
That keeps one deterministic attestation shape across swap, stake, faucet, Flexa, and address-book events while still exposing a typed ZODL API to the caller.
Policy Defaults
evaluateZodlPolicy() extends the base evaluatePolicy() helper and adds:
- block on client/server
contract_sha256mismatch - warn when
vendor_guard_present === false - block JWT bearer tokens unless their SHA-256 fingerprint is allowlisted
Example
See examples/zashi-swap-attestation.ts for a full runnable swap flow from setup through anchor verification.
License
MIT
