@sweepconsole/node 0.1.1 → 0.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/README.md CHANGED
@@ -91,7 +91,7 @@ app.post("/subscribe/usdc", async (req, res) => {
91
91
  email: req.user.email,
92
92
  maxAmount: usdc("15.00"), // the CEILING, not the price
93
93
  interval: "monthly",
94
- chains: ["base", "arbitrum", "optimism"],
94
+ chains: ["base", "arbitrum", "optimism"], // what to OFFER — they pick
95
95
  expiresAt: new Date("2027-01-01"),
96
96
  returnUrl: "https://shop.example.com/thanks",
97
97
  });
@@ -101,6 +101,11 @@ app.post("/subscribe/usdc", async (req, res) => {
101
101
  });
102
102
  ```
103
103
 
104
+ The payer chooses which of those chains to sign, so `chains` is a maximum rather
105
+ than a promise. What they actually granted comes back as `mandate.grantedChains`,
106
+ and on the `mandate.authorized` event as `chain_ids`. Charge against those — a
107
+ mandate offered on three chains is often live on one.
108
+
104
109
  **2 — react to what happens**
105
110
 
106
111
  ```ts
package/dist/client.js CHANGED
@@ -247,6 +247,7 @@ function toMandate(raw) {
247
247
  interval: raw.interval,
248
248
  periodDuration: raw.period_duration,
249
249
  chains: raw.chains ?? [],
250
+ grantedChains: raw.granted_chains ?? [],
250
251
  testMode: !!raw.test_mode,
251
252
  expiresAt: date(raw.expires_at),
252
253
  authorizationUrl: raw.authorization_url ?? null,
package/dist/types.d.ts CHANGED
@@ -33,7 +33,22 @@ export interface Mandate {
33
33
  currency: "USDC";
34
34
  interval: Interval;
35
35
  periodDuration: number;
36
+ /**
37
+ * The chains you OFFERED when you created the mandate.
38
+ *
39
+ * Not what the payer granted. The authorization page lets them choose which
40
+ * of these to sign, so a mandate offered on three chains can be live on one
41
+ * — and this still reads three. Charge against `grantedChains`.
42
+ */
36
43
  chains: string[];
44
+ /**
45
+ * The chains the payer actually signed, and what a charge can draw from.
46
+ *
47
+ * Empty while the mandate is pending. It shrinks if they later disable a
48
+ * chain in their own wallet, which is the same set `grant.revoked` reports
49
+ * as `remaining_chains`.
50
+ */
51
+ grantedChains: string[];
37
52
  testMode: boolean;
38
53
  /** When the authorization stops being redeemable. */
39
54
  expiresAt: Date;
@@ -78,6 +93,12 @@ export interface CreateMandateParams {
78
93
  /** The ceiling per interval — NOT the price. Give it headroom. */
79
94
  maxAmount: Usdc;
80
95
  interval: Interval;
96
+ /**
97
+ * The chains to OFFER the payer. They choose which to sign, so this is a
98
+ * maximum, not a promise — read `grantedChains` back to see what you got.
99
+ * More chains means more ways for a charge to succeed, so offer all you
100
+ * support unless you have a reason not to.
101
+ */
81
102
  chains: Chain[];
82
103
  expiresAt: Date;
83
104
  returnUrl?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sweepconsole/node",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Node/TypeScript client for the Sweep Console payment rail — charge a USDC wallet from your own app",
5
5
  "license": "MIT",
6
6
  "type": "module",