@predictasiax/api 2.1.0 → 2.2.0

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # @predictasiax/api Changelog
2
2
 
3
+ ## v2.2.0 — 2026-09-05
4
+
5
+ **Trust Layer — public Merkle verifier.**
6
+
7
+ ### Added
8
+ - **`pax.audit`** — new resource for the public no-auth verifier surface. Any
9
+ third party (auditor / investor / external verifier) can independently
10
+ reconstruct the hash-chained event log + Merkle batches + R2 anchors without
11
+ trusting the PAX API at all.
12
+ - **`pax.audit.status()`** — live counts: total events, batches, anchored,
13
+ anchor lag, publisher mode.
14
+ - **`pax.audit.latestBatch()`** — most recent Merkle batch metadata.
15
+ - **`pax.audit.getBatch(batchNum)`** — inspect any historical batch.
16
+ - **`pax.audit.getEvent(seq)`** — inspect one event (payload, event_hash,
17
+ prev_event_hash — full hash-chain surface).
18
+ - **`pax.audit.getProof(seq)`** — Merkle inclusion proof (sibling hashes)
19
+ proving the event is in its batch's `merkle_root`. Algo: OpenZeppelin
20
+ sorted-pair sha256 — Solidity-compatible for on-chain verification.
21
+ - **`pax.audit.getAnchor(batchNum)`** — resolve to external anchor URL
22
+ (R2 signed payload) for out-of-band verification.
23
+ - **`AuditResource.verifyProof(leaf, root, proof)`** — Node-side local
24
+ verification helper.
25
+ - **`AuditResource.verifyProofAsync(leaf, root, proof)`** — WebCrypto
26
+ variant for browsers / edge runtimes.
27
+ - **New types**: `AuditStatus`, `AuditBatch`, `AuditEvent`, `MerkleProof`.
28
+
29
+ ### Why this matters
30
+ Polymarket and OPINION Labs both publish smart-contract audit PDFs, but
31
+ neither exposes a live public verifier over their operational ledger. PAX now
32
+ does — auditors can chain-verify every fill without contacting PAX support.
33
+
34
+ ## v2.1.0 — 2026-09-05
3
35
  ## v2.1.0 — 2026-09-05
4
36
 
5
37
  **Polymarket-parity + surpass surface.**
package/dist/index.cjs CHANGED
@@ -33,6 +33,7 @@ __export(index_exports, {
33
33
  APIPromise: () => APIPromise,
34
34
  AccountResource: () => AccountResource,
35
35
  ApplyResource: () => ApplyResource,
36
+ AuditResource: () => AuditResource,
36
37
  CursorPage: () => CursorPage,
37
38
  FeesResource: () => FeesResource,
38
39
  GrantsResource: () => GrantsResource,
@@ -364,7 +365,7 @@ async function runWithRetry(fn, opts = {}) {
364
365
  }
365
366
 
366
367
  // src/http.ts
367
- var VERSION = "2.1.0";
368
+ var VERSION = "2.2.0";
368
369
  var ENV_URLS = {
369
370
  production: "https://api.predictasiax.com/v1",
370
371
  prod: "https://api.predictasiax.com/v1",
@@ -785,6 +786,72 @@ var AccountResource = class extends Resource {
785
786
  }
786
787
  };
787
788
 
789
+ // src/resources/audit.ts
790
+ var AuditResource = class extends Resource {
791
+ status(opts) {
792
+ return this._apiPromise(
793
+ () => this._http.request("GET", "/v1/audit/status", void 0, void 0, opts)
794
+ );
795
+ }
796
+ latestBatch(opts) {
797
+ return this._apiPromise(
798
+ () => this._http.request("GET", "/v1/audit/batches/latest", void 0, void 0, opts)
799
+ );
800
+ }
801
+ getBatch(batchNum, opts) {
802
+ return this._apiPromise(
803
+ () => this._http.request("GET", `/v1/audit/batches/${batchNum}`, void 0, void 0, opts)
804
+ );
805
+ }
806
+ getEvent(seq, opts) {
807
+ return this._apiPromise(
808
+ () => this._http.request("GET", `/v1/audit/events/${seq}`, void 0, void 0, opts)
809
+ );
810
+ }
811
+ getProof(seq, opts) {
812
+ return this._apiPromise(
813
+ () => this._http.request("GET", `/v1/audit/proof/${seq}`, void 0, void 0, opts)
814
+ );
815
+ }
816
+ getAnchor(batchNum, opts) {
817
+ return this._apiPromise(
818
+ () => this._http.request("GET", `/v1/audit/anchor/${batchNum}`, void 0, void 0, opts)
819
+ );
820
+ }
821
+ /**
822
+ * Verify a Merkle inclusion proof locally (client-side). Mirrors
823
+ * OpenZeppelin's sorted-pair sha256 algorithm — identical logic to the
824
+ * server-side batcher, so callers can independently confirm inclusion
825
+ * without trusting the API response.
826
+ */
827
+ static verifyProof(leaf, root, proof) {
828
+ const crypto = globalThis.crypto || require("crypto");
829
+ let hash = leaf;
830
+ for (const sibling of proof) {
831
+ const [a, b] = hash < sibling ? [hash, sibling] : [sibling, hash];
832
+ if (crypto.subtle && typeof crypto.subtle.digest === "function") {
833
+ throw new Error("Use verifyProofAsync() in browser/edge runtimes (WebCrypto is async)");
834
+ }
835
+ hash = crypto.createHash("sha256").update(a + b).digest("hex");
836
+ }
837
+ return hash === root;
838
+ }
839
+ /** Async variant using WebCrypto — works in browsers, Deno, Bun, edge runtimes. */
840
+ static async verifyProofAsync(leaf, root, proof) {
841
+ const enc = new TextEncoder();
842
+ async function sha(s) {
843
+ const buf = await globalThis.crypto.subtle.digest("SHA-256", enc.encode(s));
844
+ return Array.from(new Uint8Array(buf)).map((b) => b.toString(16).padStart(2, "0")).join("");
845
+ }
846
+ let hash = leaf;
847
+ for (const sibling of proof) {
848
+ const [a, b] = hash < sibling ? [hash, sibling] : [sibling, hash];
849
+ hash = await sha(a + b);
850
+ }
851
+ return hash === root;
852
+ }
853
+ };
854
+
788
855
  // src/resources/fees.ts
789
856
  var FeesResource = class extends Resource {
790
857
  estimate(params, opts) {
@@ -1134,6 +1201,8 @@ var PaxClient = class {
1134
1201
  grants;
1135
1202
  fees;
1136
1203
  // v2.1+: GET /v1/fees/estimate
1204
+ audit;
1205
+ // v2.2+: public Merkle chain verifier (no-auth)
1137
1206
  constructor(opts) {
1138
1207
  this._http = new HttpClient(opts);
1139
1208
  this.markets = new MarketsResource(this._http);
@@ -1146,6 +1215,7 @@ var PaxClient = class {
1146
1215
  this.apply = new ApplyResource(this._http);
1147
1216
  this.grants = new GrantsResource(this._http);
1148
1217
  this.fees = new FeesResource(this._http);
1218
+ this.audit = new AuditResource(this._http);
1149
1219
  }
1150
1220
  get baseUrl() {
1151
1221
  return this._http.baseUrl;
@@ -1418,6 +1488,7 @@ var PaxWSClient = class {
1418
1488
  APIPromise,
1419
1489
  AccountResource,
1420
1490
  ApplyResource,
1491
+ AuditResource,
1421
1492
  CursorPage,
1422
1493
  FeesResource,
1423
1494
  GrantsResource,