@secondlayer/sdk 14.3.0 → 14.5.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/dist/index.d.ts CHANGED
@@ -1820,6 +1820,14 @@ type IndexStateWrite = {
1820
1820
  /** Full MARF key, e.g. `vm::<contract>::0::map::<hex>`. */
1821
1821
  key: string;
1822
1822
  value_hex: string;
1823
+ /** The writing transaction, present only when `txContext: true` was
1824
+ * passed; null for block-level writes. */
1825
+ tx_id?: string | null;
1826
+ tx_sender?: string | null;
1827
+ tx_type?: string | null;
1828
+ tx_status?: string | null;
1829
+ tx_contract_id?: string | null;
1830
+ tx_function_name?: string | null;
1823
1831
  };
1824
1832
  type StateWritesEnvelope = {
1825
1833
  state_writes: IndexStateWrite[];
@@ -1835,6 +1843,10 @@ type StateWritesListParams = {
1835
1843
  toHeight?: number;
1836
1844
  /** One block. Excludes `fromHeight`/`toHeight`; a cursor must sit at it. */
1837
1845
  blockHeight?: number;
1846
+ /** One contract (`<address>.<name>`): only keys under `vm::<contractId>::`. */
1847
+ contractId?: string;
1848
+ /** Join the writing transaction's `tx_*` fields onto each row. */
1849
+ txContext?: boolean;
1838
1850
  };
1839
1851
  type StateWritesWalkParams = Omit<StateWritesListParams, "limit"> & WalkOptions;
1840
1852
  /** A block resource. Metadata is intentionally thin — only chain-linkage and
@@ -2968,6 +2980,13 @@ interface SubgraphSource {
2968
2980
  name: string;
2969
2981
  version: string;
2970
2982
  sourceCode: string | null;
2983
+ /** The bundled handler the runtime executes; null for local deploys. */
2984
+ handlerCode?: string | null;
2985
+ /** sha256 of `pinPreimage`; null for local deploys. */
2986
+ pin?: string | null;
2987
+ /** The canonical JSON the pin hashes (handler hash, network, runtime,
2988
+ * schema hash, startBlock); null before it was stored. */
2989
+ pinPreimage?: string | null;
2971
2990
  readOnly: boolean;
2972
2991
  reason?: string;
2973
2992
  updatedAt: string;
@@ -3455,6 +3474,13 @@ declare class ApiError extends SecondLayerError {
3455
3474
  /** Raw response body (parsed JSON if possible) — preserved for callers that need error details. */
3456
3475
  body?: unknown;
3457
3476
  constructor(status: number, message: string, body?: unknown, code?: string, options?: SecondLayerErrorOptions);
3477
+ /** The API's `request_id` for this failure (from the error body), when sent.
3478
+ * Quote it when reporting a failed call. */
3479
+ get requestId(): string | undefined;
3480
+ toJSON(): ReturnType<SecondLayerError["toJSON"]> & {
3481
+ status: number;
3482
+ requestId: string | undefined;
3483
+ };
3458
3484
  }
3459
3485
  /** Thrown on a 401 by both the instance clients and Streams. Carries the
3460
3486
  * server's `{error, code}` envelope when it sent one, so a revoked token reads
package/dist/index.js CHANGED
@@ -88,6 +88,17 @@ class ApiError extends SecondLayerError {
88
88
  this.body = body;
89
89
  this.name = "ApiError";
90
90
  }
91
+ get requestId() {
92
+ const b = this.body;
93
+ return b && typeof b === "object" && typeof b.request_id === "string" ? b.request_id : undefined;
94
+ }
95
+ toJSON() {
96
+ return {
97
+ ...super.toJSON(),
98
+ status: this.status,
99
+ requestId: this.requestId
100
+ };
101
+ }
91
102
  }
92
103
 
93
104
  class AuthError extends ApiError {
@@ -1449,7 +1460,9 @@ class Index extends BaseClient {
1449
1460
  async listStateWrites(params = {}) {
1450
1461
  return this.request("GET", `/v1/index/state-writes${buildQuery({
1451
1462
  ...indexPageQuery(params),
1452
- block_height: params.blockHeight
1463
+ block_height: params.blockHeight,
1464
+ contract_id: params.contractId,
1465
+ tx_context: params.txContext ? "true" : undefined
1453
1466
  })}`, undefined, { signal: params.signal });
1454
1467
  }
1455
1468
  walkStateWrites(params = {}) {
@@ -3464,5 +3477,5 @@ export {
3464
3477
  verifyWebhookSignature
3465
3478
  };
3466
3479
 
3467
- //# debugId=B2DAEC1BBFDB7B6E64756E2164756E21
3480
+ //# debugId=D9B8A03B011C93A864756E2164756E21
3468
3481
  //# sourceMappingURL=index.js.map