@terminal3/t3n-sdk 2.3.0 → 2.4.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.
@@ -54,6 +54,50 @@ export declare class RpcError extends T3nError {
54
54
  /** Per-request correlation id (JSON-RPC `error.data.request_id`). */
55
55
  requestId?: string | undefined);
56
56
  }
57
+ /**
58
+ * Error thrown when the cluster's T3-TS-030 metering chargepoint
59
+ * denies a contract-register or contract-invocation request because
60
+ * the billing DID's available balance is below the operation's cost.
61
+ *
62
+ * Recognised by the SDK from a stable wire format the node emits
63
+ * for the `ServiceError::InsufficientCredit` variant — see
64
+ * `node/api/src/error.rs::service_insufficient_credit_wire_format_is_stable`.
65
+ * Subclass of `RpcError` so callers that catch the parent still see
66
+ * the structured `httpStatus` / `requestId` fields; callers that
67
+ * want the typed surface (frontends rendering an "out of credit"
68
+ * banner) `instanceof InsufficientCreditError` to read `available`
69
+ * and `required` directly.
70
+ *
71
+ * Terminal — do NOT retry. The next call needs either a mint to
72
+ * `account` (admin operation) or a reduction in the requested
73
+ * operation's cost.
74
+ */
75
+ export declare class InsufficientCreditError extends RpcError {
76
+ /** Hex DID (no `did:t3n:` prefix) the chargepoint billed. */
77
+ readonly account: string;
78
+ /** Tokens the chargepoint required (parsed from `required=`). */
79
+ readonly required: bigint;
80
+ /** Tokens available on `account` at check time (parsed from `available=`). */
81
+ readonly available: bigint;
82
+ constructor(message: string,
83
+ /** Hex DID (no `did:t3n:` prefix) the chargepoint billed. */
84
+ account: string,
85
+ /** Tokens the chargepoint required (parsed from `required=`). */
86
+ required: bigint,
87
+ /** Tokens available on `account` at check time (parsed from `available=`). */
88
+ available: bigint, rpcMethod?: string, requestId?: string);
89
+ }
90
+ /**
91
+ * Try to parse the node's stable `InsufficientCredit (account=..., required=..., available=...)`
92
+ * wire format. Returns the typed error on match, `null` otherwise.
93
+ * Callers wrap RPC error construction in this so a Forbidden whose
94
+ * detail matches the format surfaces as the typed class.
95
+ *
96
+ * The format is pinned by a server-side test
97
+ * (`api/src/error.rs::service_insufficient_credit_wire_format_is_stable`)
98
+ * so a node change that breaks this parser also breaks CI.
99
+ */
100
+ export declare function tryParseInsufficientCredit(message: string, rpcMethod?: string, requestId?: string): InsufficientCreditError | null;
57
101
  /**
58
102
  * Error thrown when WASM operations fail
59
103
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@terminal3/t3n-sdk",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "type": "module",
5
5
  "description": "T3n TypeScript SDK - A minimal SDK that mirrors the server's RPC handler approach",
6
6
  "main": "dist/index.js",