@zeroxyz/sdk 0.10.0 → 0.12.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.
@@ -591,6 +591,7 @@ var pickSessionCloseAmount = (receipt, openTimeCumulative) => {
591
591
  if (receipt.metered === true) return fromReceipt;
592
592
  return fromReceipt > openTimeCumulative ? fromReceipt : openTimeCumulative;
593
593
  };
594
+ var isMeteredZeroReceipt = (receipt) => receipt?.metered === true && BigInt(receipt.acceptedCumulative) === 0n && BigInt(receipt.spent) === 0n;
594
595
  var raceWithSignal = (p, signal, client) => {
595
596
  if (!signal) return p;
596
597
  if (signal.aborted) {
@@ -1164,7 +1165,7 @@ var Payments = class {
1164
1165
  }
1165
1166
  const receipt = readSessionReceipt(response);
1166
1167
  let closeAmount = pickSessionCloseAmount(receipt, openTimeCumulative);
1167
- if (closeAmount === 0n && channelEntry.cumulativeAmount > 0n) {
1168
+ if (closeAmount === 0n && channelEntry.cumulativeAmount > 0n && !isMeteredZeroReceipt(receipt)) {
1168
1169
  closeAmount = channelEntry.cumulativeAmount;
1169
1170
  }
1170
1171
  const reconcileAmount = receipt && isUintString(receipt.acceptedCumulative) ? receipt.acceptedCumulative : closeAmount.toString();
@@ -1181,7 +1182,7 @@ var Payments = class {
1181
1182
  capturedAmount,
1182
1183
  cause
1183
1184
  });
1184
- if (closeAmount === 0n) {
1185
+ if (closeAmount === 0n && !isMeteredZeroReceipt(receipt)) {
1185
1186
  throw closeFailed(
1186
1187
  `Refusing to sign zero close credential for channel ${channelId} \u2014 neither receipt nor channelEntry produced a nonzero cumulativeAmount. Query escrow directly to recover; check logger for an earlier 'non-bigint cumulativeAmount' warning.`
1187
1188
  );
@@ -1952,7 +1953,7 @@ var clientFetch = async (client, url, opts = {}) => {
1952
1953
 
1953
1954
  // package.json
1954
1955
  var package_default = {
1955
- version: "0.10.0"};
1956
+ version: "0.12.0"};
1956
1957
 
1957
1958
  // src/version.ts
1958
1959
  var SDK_VERSION = package_default.version;
@@ -2443,6 +2444,7 @@ var userWalletDtoSchema = zod.z.object({
2443
2444
  source: zod.z.enum(["self_custody", "privy_embedded"]),
2444
2445
  isPrimary: zod.z.boolean(),
2445
2446
  linkedAt: zod.z.union([zod.z.string(), zod.z.date()]).nullable().optional(),
2447
+ importedAt: zod.z.union([zod.z.string(), zod.z.date()]).nullable().optional(),
2446
2448
  delegationGranted: zod.z.boolean(),
2447
2449
  signerQuorumId: zod.z.string().nullable(),
2448
2450
  // Per-transaction USDC cap in base units (6 dp). null = unlimited, 0 = free-only.
@@ -2841,6 +2843,12 @@ var capabilityResponseSchema = zod.z.object({
2841
2843
  bodySchema: zod.z.record(zod.z.string(), zod.z.unknown()).nullable(),
2842
2844
  responseSchema: zod.z.record(zod.z.string(), zod.z.unknown()).nullable(),
2843
2845
  example: zod.z.object({ request: zod.z.unknown(), response: zod.z.unknown() }).nullable(),
2846
+ // The bare, schema-validated request body to send — `.request` unwrapped
2847
+ // from the transcript envelope and checked against the current bodySchema.
2848
+ // Null when there's no usable example or it's stale vs the schema; `example`
2849
+ // is retained for the response sample. Optional for back-compat with older
2850
+ // servers that don't emit it.
2851
+ exampleRequest: zod.z.record(zod.z.string(), zod.z.unknown()).nullable().optional(),
2844
2852
  tags: zod.z.array(zod.z.string()).nullable(),
2845
2853
  exampleAgentPrompt: zod.z.string().nullable().optional(),
2846
2854
  whatItDoes: zod.z.string().nullable().optional(),
@@ -3228,6 +3236,48 @@ var Wallet = class {
3228
3236
  },
3229
3237
  userWalletDtoSchema
3230
3238
  );
3239
+ // Link an existing self-custody wallet to the session user by private key.
3240
+ // Session-only. 409s when the wallet is already linked (to this or another
3241
+ // profile — the error message says which).
3242
+ import = (opts) => request(
3243
+ this.client,
3244
+ {
3245
+ method: "POST",
3246
+ path: "/v1/users/me/wallets/import",
3247
+ body: {
3248
+ privateKey: opts.privateKey,
3249
+ ...opts.makePrimary !== void 0 ? { makePrimary: opts.makePrimary } : {}
3250
+ },
3251
+ signal: opts.signal
3252
+ },
3253
+ userWalletDtoSchema
3254
+ );
3255
+ // Make one of the session user's linked wallets the primary payer.
3256
+ // Session-only. 404s when the address isn't linked to the user.
3257
+ setPrimary = (opts) => request(
3258
+ this.client,
3259
+ {
3260
+ method: "PATCH",
3261
+ path: "/v1/users/me/wallets/primary",
3262
+ body: { walletAddress: opts.walletAddress },
3263
+ signal: opts.signal
3264
+ },
3265
+ userWalletDtoSchema
3266
+ );
3267
+ // Unlink a wallet from the session user. Session-only. 409s on the primary
3268
+ // wallet or a non-zero balance (the error message says which); 404s when
3269
+ // the address isn't linked. Responds 204 — resolves to void.
3270
+ remove = async (opts) => {
3271
+ await request(
3272
+ this.client,
3273
+ {
3274
+ method: "DELETE",
3275
+ path: `/v1/users/me/wallets/${opts.walletAddress}`,
3276
+ signal: opts.signal
3277
+ },
3278
+ zod.z.undefined()
3279
+ );
3280
+ };
3231
3281
  // Routes by identity: account mode signs EIP-191 against /v1/wallet/fund-url,
3232
3282
  // session mode hits /v1/users/me/fund-url (Bearer-authed, wallet resolved
3233
3283
  // server-side). Both honor `provider` (coinbase | stripe).
@@ -3785,5 +3835,5 @@ exports.normalizeTransportEnvelopeRequest = normalizeTransportEnvelopeRequest;
3785
3835
  exports.paymentHasAnchor = paymentHasAnchor;
3786
3836
  exports.tempoChainLabelFromId = tempoChainLabelFromId;
3787
3837
  exports.unwrapTransportEnvelope = unwrapTransportEnvelope;
3788
- //# sourceMappingURL=chunk-IFVGW4ZN.cjs.map
3789
- //# sourceMappingURL=chunk-IFVGW4ZN.cjs.map
3838
+ //# sourceMappingURL=chunk-O7424YAR.cjs.map
3839
+ //# sourceMappingURL=chunk-O7424YAR.cjs.map