@secondlayer/sdk 14.2.0 → 14.3.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.
@@ -1843,6 +1843,37 @@ type CanonicalListParams = {
1843
1843
  toHeight?: number;
1844
1844
  };
1845
1845
  type CanonicalWalkParams = Omit<CanonicalListParams, "limit"> & WalkOptions;
1846
+ /** One MARF write a block committed, in the node's write order. Present only
1847
+ * from the height the instance's node subscribed to `state_writes`. */
1848
+ type IndexStateWrite = {
1849
+ /** `<block_height>:<ordinal>`. */
1850
+ cursor: string;
1851
+ block_height: number;
1852
+ /** Position in the block's write order: a separate clock from
1853
+ * `event_index`. */
1854
+ ordinal: number;
1855
+ /** Null for block-level writes. */
1856
+ tx_index: number | null;
1857
+ /** Full MARF key, e.g. `vm::<contract>::0::map::<hex>`. */
1858
+ key: string;
1859
+ value_hex: string;
1860
+ };
1861
+ type StateWritesEnvelope = {
1862
+ state_writes: IndexStateWrite[];
1863
+ next_cursor: string | null;
1864
+ tip: IndexTip;
1865
+ reorgs: IndexReorg[];
1866
+ };
1867
+ type StateWritesListParams = {
1868
+ cursor?: string | null;
1869
+ fromCursor?: string | null;
1870
+ limit?: number;
1871
+ fromHeight?: number;
1872
+ toHeight?: number;
1873
+ /** One block. Excludes `fromHeight`/`toHeight`; a cursor must sit at it. */
1874
+ blockHeight?: number;
1875
+ };
1876
+ type StateWritesWalkParams = Omit<StateWritesListParams, "limit"> & WalkOptions;
1846
1877
  /** A block resource. Metadata is intentionally thin — only chain-linkage and
1847
1878
  * burn-anchor fields are persisted (no miner / tx_count / signer). */
1848
1879
  type IndexBlock = {
@@ -2854,6 +2885,11 @@ declare class Index extends BaseClient {
2854
2885
  list: (params?: CanonicalListParams) => Promise<CanonicalEnvelope>;
2855
2886
  walk: (params?: CanonicalWalkParams) => AsyncIterable<IndexCanonicalBlock>;
2856
2887
  };
2888
+ /** Exact MARF writes per canonical block (`/v1/index/state-writes`). */
2889
+ readonly stateWrites: {
2890
+ list: (params?: StateWritesListParams) => Promise<StateWritesEnvelope>;
2891
+ walk: (params?: StateWritesWalkParams) => AsyncIterable<IndexStateWrite>;
2892
+ };
2857
2893
  /** Canonical blocks: paginated `list`/`walk`, plus `get` by height or hash
2858
2894
  * (resolves to null on 404). */
2859
2895
  readonly blocks: {
@@ -2923,6 +2959,8 @@ declare class Index extends BaseClient {
2923
2959
  private walkContractCalls;
2924
2960
  private listCanonical;
2925
2961
  private walkCanonical;
2962
+ private listStateWrites;
2963
+ private walkStateWrites;
2926
2964
  private listBlocks;
2927
2965
  private getBlock;
2928
2966
  private walkBlocks;
@@ -1711,6 +1711,10 @@ class Index extends BaseClient {
1711
1711
  list: (params = {}) => this.listCanonical(params),
1712
1712
  walk: (params = {}) => this.walkCanonical(params)
1713
1713
  };
1714
+ stateWrites = {
1715
+ list: (params = {}) => this.listStateWrites(params),
1716
+ walk: (params = {}) => this.walkStateWrites(params)
1717
+ };
1714
1718
  blocks = {
1715
1719
  list: (params = {}) => this.listBlocks(params),
1716
1720
  walk: (params = {}) => this.walkBlocks(params),
@@ -1906,6 +1910,19 @@ class Index extends BaseClient {
1906
1910
  walkCanonical(params = {}) {
1907
1911
  return this.keysetWalk(params, (page) => this.listCanonical({ ...params, ...page }), (e) => e.canonical);
1908
1912
  }
1913
+ async listStateWrites(params = {}) {
1914
+ return this.request("GET", `/v1/index/state-writes${buildQuery({
1915
+ ...indexPageQuery(params),
1916
+ block_height: params.blockHeight
1917
+ })}`, undefined, { signal: params.signal });
1918
+ }
1919
+ walkStateWrites(params = {}) {
1920
+ return this.keysetWalk(params, (page) => this.listStateWrites({
1921
+ ...params,
1922
+ ...page,
1923
+ fromHeight: params.blockHeight === undefined ? page.fromHeight : undefined
1924
+ }), (e) => e.state_writes);
1925
+ }
1909
1926
  async listBlocks(params = {}) {
1910
1927
  return this.request("GET", `/v1/index/blocks${buildQuery(indexPageQuery(params))}`, undefined, { signal: params.signal });
1911
1928
  }
@@ -2806,5 +2823,5 @@ export {
2806
2823
  getSubgraph
2807
2824
  };
2808
2825
 
2809
- //# debugId=DD76B5EA212EEC4D64756E2164756E21
2826
+ //# debugId=3252B7843081BB3A64756E2164756E21
2810
2827
  //# sourceMappingURL=index.js.map