nirium-pollar-adapter 0.3.1 → 0.4.1

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/README.md CHANGED
@@ -71,13 +71,20 @@ Swapping to a Pollar wallet is one line:
71
71
  + const signer = createPollarSigner(pollarClient);
72
72
  ```
73
73
 
74
- **Verified with a real Pollar social login (5 Aug 2026):** a user who signed in
75
- with Google paid $0.02 USDC on mainnet —
74
+ **Verified with a real Pollar social login (our own test account, 5 Aug
75
+ 2026):** a user who signed in with Google paid $0.02 USDC on mainnet —
76
76
  [`e4fa3df9…`](https://stellar.expert/explorer/public/tx/e4fa3df9cb225a4d7f64dd0082eb38218ada4b4af3378f288989a5d4b1116ed9)
77
77
  — holding **zero XLM** at any point. Pollar sponsors the account reserve and the
78
78
  trustline; the x402 facilitator sponsors the network fee and is the transaction
79
79
  source. The user never saw a key, a seed phrase or a gas prompt.
80
80
 
81
+ Both proofs above paid `/premium/signals` ($0.02). Since 6-Aug-2026 that
82
+ endpoint is **testnet only** — the mainnet agent box runs no autonomous loop,
83
+ so a capability guard now returns 501 before any charge. The example above
84
+ pays `/premium/market` ($0.05) instead, which has no such guard and still
85
+ settles on mainnet today; the two linked transactions remain real, they are
86
+ just no longer reproducible verbatim with the current example.
87
+
81
88
  ## API
82
89
 
83
90
  ### `createNiriumAdapter(config)`
@@ -94,6 +101,7 @@ Returns:
94
101
 
95
102
  - **`x402Fetch(url, init?)`** — fetch that pays on `402` and retries. Passes through untouched on `200`.
96
103
  - **`getPremiumSignals()`** — typed shortcut to the agent's paid signals endpoint. **Testnet only**: signals come from the autonomous loop, which does not run on the mainnet box; there the endpoint returns 501 without charging.
104
+ - **`getPremiumMarket()`** — typed shortcut to the agent's paid market-state endpoint ($0.05). Works and charges on **both** networks — no autonomous loop dependency.
97
105
  - **`anchorAuditRecord({ hash?, record?, txHash?, tag? })`** — anchors evidence to IPFS, returns the CID. No signature, no payment. Anchor **hashes, not personal data** — IPFS cannot be deleted.
98
106
  - **`getCetesRate()`** — public reference rate, no key required.
99
107
 
@@ -153,7 +161,8 @@ request is rejected.
153
161
  |---|---|
154
162
  | x402 Settlement | ✅ mainnet |
155
163
  | Audit Trail (IPFS) | ✅ mainnet |
156
- | Treasury vault (DeFindex, client-owned) | ✅ mainnet — invite-only during legal review |
164
+ | Treasury vault (DeFindex, client-owned) — Nirium signs and executes | ✅ mainnet — invite-only during legal review |
165
+ | Treasury vault — propose only, you sign | ✅ mainnet — public, no invite required (`POST /api/treasury/rebalance/propose`, not yet wrapped by this adapter) |
157
166
  | Nirium's own NiriumVault | audit-gated — testnet only |
158
167
  | MPP session channels | audit-gated — testnet only |
159
168
 
package/dist/index.d.ts CHANGED
@@ -90,6 +90,7 @@ export declare function createNiriumAdapter(config: NiriumAdapterConfig): {
90
90
  address: string;
91
91
  x402Fetch: (url: string, init?: RequestInit) => Promise<Response>;
92
92
  getPremiumSignals: () => Promise<unknown>;
93
+ getPremiumMarket: () => Promise<unknown>;
93
94
  anchorAuditRecord: (input: AuditAnchorInput) => Promise<{
94
95
  cid: string;
95
96
  } & Record<string, unknown>>;
package/dist/index.js CHANGED
@@ -241,13 +241,32 @@ export function createNiriumAdapter(config) {
241
241
  throw e;
242
242
  }
243
243
  }
244
- /** Atajo tipado a los endpoints premium del agente. */
244
+ /**
245
+ * Atajo tipado a los endpoints premium del agente.
246
+ *
247
+ * TESTNET ONLY: las señales las produce el loop autónomo, que no corre en
248
+ * el box de mainnet — ahí un guard de capacidad responde 501 ANTES del
249
+ * cobro (agregado el 6-ago-2026, ver `capabilityGuard` en el agente), así
250
+ * que no se cobra, pero tampoco hay señales. Para verificar el pago en
251
+ * mainnet usa getPremiumMarket().
252
+ */
245
253
  async function getPremiumSignals() {
246
254
  const res = await x402Fetch(`${agentBaseUrl}/api/v1/premium/signals`);
247
255
  if (!res.ok)
248
256
  throw new Error(`premium/signals respondió HTTP ${res.status}`);
249
257
  return res.json();
250
258
  }
259
+ /**
260
+ * Atajo tipado al estado de mercado premium. A diferencia de
261
+ * getPremiumSignals(), no depende del loop autónomo — funciona y cobra
262
+ * igual en testnet y en mainnet.
263
+ */
264
+ async function getPremiumMarket() {
265
+ const res = await x402Fetch(`${agentBaseUrl}/api/v1/premium/market`);
266
+ if (!res.ok)
267
+ throw new Error(`premium/market respondió HTTP ${res.status}`);
268
+ return res.json();
269
+ }
251
270
  /**
252
271
  * Ancla evidencia en IPFS (Audit Trail Node). Software-only: no firma, no
253
272
  * mueve fondos, funciona en mainnet hoy. Se anclan HASHES, no PII.
@@ -289,6 +308,7 @@ export function createNiriumAdapter(config) {
289
308
  // Settlement (x402) — mainnet
290
309
  x402Fetch,
291
310
  getPremiumSignals,
311
+ getPremiumMarket,
292
312
  // Audit Trail — mainnet
293
313
  anchorAuditRecord,
294
314
  // Lecturas públicas
@@ -12,7 +12,12 @@
12
12
  // NIRIUM_DEMO_SECRET=S... node examples/pay-with-keypair.mjs
13
13
  // NIRIUM_DEMO_SECRET=S... NIRIUM_NETWORK=stellar:testnet node examples/pay-with-keypair.mjs
14
14
  //
15
- // OJO: contra stellar:pubnet esto gasta USDC REAL (0.02 por llamada a signals).
15
+ // OJO: contra stellar:pubnet esto gasta USDC REAL (0.05 por llamada a market).
16
+ //
17
+ // Usa getPremiumMarket(), no getPremiumSignals(): desde el 6-ago-2026 el box
18
+ // de mainnet responde 501 a /premium/signals ANTES de cobrar (no hay loop
19
+ // autónomo ahí que produzca señales) — con signals este ejemplo fallaría en
20
+ // el paso 1/2 usando su propio default de red.
16
21
  // ───────────────────────────────────────────────────────────────────────────
17
22
 
18
23
  import { createEd25519Signer } from "@x402/stellar";
@@ -33,14 +38,14 @@ console.log(`pagador : ${signer.address}`);
33
38
  console.log(`agente : ${nirium.agentBaseUrl}`);
34
39
 
35
40
  // 1) x402 — el 402, la firma del auth entry y el reintento pasan por debajo.
36
- console.log("\n[1/2] pagando /api/v1/premium/signals (0.02 USDC)…");
37
- const signals = await nirium.getPremiumSignals();
38
- console.log(" OK — respuesta:", JSON.stringify(signals).slice(0, 220));
41
+ console.log("\n[1/2] pagando /api/v1/premium/market (0.05 USDC)…");
42
+ const market = await nirium.getPremiumMarket();
43
+ console.log(" OK — respuesta:", JSON.stringify(market).slice(0, 220));
39
44
 
40
45
  // 2) Audit Trail — software-only, sin firma ni pago.
41
46
  console.log("\n[2/2] anclando evidencia en IPFS…");
42
47
  const anchor = await nirium.anchorAuditRecord({
43
- record: { source: "pollar-adapter-example", paidResource: "premium/signals", at: new Date().toISOString() },
48
+ record: { source: "pollar-adapter-example", paidResource: "premium/market", at: new Date().toISOString() },
44
49
  tag: "adapter-e2e",
45
50
  });
46
51
  console.log(" OK — CID:", anchor.cid ?? JSON.stringify(anchor).slice(0, 200));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nirium-pollar-adapter",
3
- "version": "0.3.1",
4
- "description": "Nirium adapter for the Pollar SDK \u2014 x402 pay-per-request and IPFS audit anchoring using the wallet a user onboarded through Pollar. Signs SEP-43 auth entries; the facilitator sponsors network fees.",
3
+ "version": "0.4.1",
4
+ "description": "Nirium adapter for the Pollar SDK — x402 pay-per-request and IPFS audit anchoring using the wallet a user onboarded through Pollar. Signs SEP-43 auth entries; the facilitator sponsors network fees.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",