@thru/thru-sdk 0.2.0 → 0.2.3

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.
@@ -1,7 +1,7 @@
1
1
  import { utils, etc, Point, CURVE, getPublicKeyAsync } from '@noble/ed25519';
2
2
  import { create } from '@bufbuild/protobuf';
3
3
  import { encodeAddress, decodeAddress, isHexString, hexToBytes, encodeSignature, decodeSignature, ensureBytes } from '@thru/helpers';
4
- import { AccountView, BlockView, TransactionView, ConsensusStatus, VersionContextSchema, CurrentVersionSchema, PubkeySchema, TaPubkeySchema, SignatureSchema, TsSignatureSchema, TransactionVmError, StreamingService, CommandService, QueryService, PageRequestSchema, PageResponseSchema, StateProofRequestSchema, GenerateStateProofRequestSchema, GetAccountRequestSchema, GetRawAccountRequestSchema, ListAccountsRequestSchema, StateProofType, ExecutionStatus, GetBlockRequestSchema, GetRawBlockRequestSchema, ListBlocksRequestSchema, GetChainInfoRequestSchema, CurrentOrHistoricalVersionSchema, GetEventRequestSchema, ListEventsRequestSchema, GetHeightRequestSchema, FilterParamValueSchema, FilterSchema, StreamBlocksRequestSchema, StreamAccountUpdatesRequestSchema, StreamTransactionsRequestSchema, StreamEventsRequestSchema, TrackTransactionRequestSchema, StreamHeightRequestSchema, GetTransactionRequestSchema, GetRawTransactionRequestSchema, GetTransactionStatusRequestSchema, ListTransactionsForAccountRequestSchema, ListTransactionsRequestSchema, BatchSendTransactionsRequestSchema, SendTransactionRequestSchema, BlockHashSchema } from '@thru/proto';
4
+ import { AccountView, BlockView, TransactionView, ConsensusStatus, VersionContextSchema, CurrentVersionSchema, PubkeySchema, TaPubkeySchema, SignatureSchema, TsSignatureSchema, TransactionVmError, StreamingService, CommandService, QueryService, PageRequestSchema, PageResponseSchema, StateProofRequestSchema, GenerateStateProofRequestSchema, GetStateRootsRequestSchema, GetAccountRequestSchema, GetRawAccountRequestSchema, ListAccountsRequestSchema, StateProofType, ExecutionStatus, GetBlockRequestSchema, GetRawBlockRequestSchema, ListBlocksRequestSchema, GetChainInfoRequestSchema, CurrentOrHistoricalVersionSchema, GetEventRequestSchema, ListEventsRequestSchema, GetHeightRequestSchema, GetNodePubkeyRequestSchema, GetNodeRecordsRequestSchema, GetSlotMetricsRequestSchema, ListSlotMetricsRequestSchema, FilterParamValueSchema, FilterSchema, StreamBlocksRequestSchema, StreamAccountUpdatesRequestSchema, StreamTransactionsRequestSchema, StreamEventsRequestSchema, TrackTransactionRequestSchema, StreamHeightRequestSchema, StreamSlotMetricsRequestSchema, StreamNodeRecordsRequestSchema, GetTransactionRequestSchema, GetRawTransactionRequestSchema, GetTransactionStatusRequestSchema, ListTransactionsForAccountRequestSchema, ListTransactionsRequestSchema, BatchSendTransactionsRequestSchema, SendAndTrackTxnRequestSchema, SendTransactionRequestSchema, BlockHashSchema } from '@thru/proto';
5
5
  import { createClient } from '@connectrpc/connect';
6
6
  import { createGrpcWebTransport } from '@connectrpc/connect-web';
7
7
  import { sha256 } from '@noble/hashes/sha2';
@@ -296,9 +296,10 @@ var SIGNATURE_SIZE2 = 64;
296
296
  var PUBKEY_SIZE2 = 32;
297
297
  var HASH_SIZE = 32;
298
298
  var BLOCK_HEADER_SIZE = 168;
299
+ var BLOCK_HEADER_SIZE_LEGACY = 160;
299
300
  var BLOCK_FOOTER_SIZE = 104;
300
301
  var BLOCK_VERSION_V1 = 1;
301
- var TXN_HEADER_SIZE = 112;
302
+ var TXN_HEADER_BODY_SIZE = 112;
302
303
  var TXN_VERSION_V1 = 1;
303
304
  var TXN_MAX_ACCOUNTS = 1024;
304
305
  var STATE_PROOF_HEADER_SIZE = 40;
@@ -354,11 +355,11 @@ var Transaction = class _Transaction {
354
355
  return transaction;
355
356
  }
356
357
  static parseWire(data, options = {}) {
357
- if (data.length < TXN_HEADER_SIZE + SIGNATURE_SIZE2) {
358
- throw new Error(`Transaction data too short: ${data.length} bytes (expected at least ${TXN_HEADER_SIZE + SIGNATURE_SIZE2})`);
359
- }
360
358
  const strict = options.strict ?? false;
361
359
  const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
360
+ if (data.length < TXN_HEADER_BODY_SIZE) {
361
+ throw new Error(`Transaction data too short: ${data.length} bytes (minimum ${TXN_HEADER_BODY_SIZE})`);
362
+ }
362
363
  let offset = 0;
363
364
  const version = view.getUint8(offset);
364
365
  offset += 1;
@@ -400,8 +401,8 @@ var Transaction = class _Transaction {
400
401
  _Transaction.ensureAvailable(data.length, offset, PUBKEY_SIZE2, "program account");
401
402
  const program = data.slice(offset, offset + PUBKEY_SIZE2);
402
403
  offset += PUBKEY_SIZE2;
403
- if (offset !== TXN_HEADER_SIZE) {
404
- throw new Error(`Transaction header parsing mismatch (expected offset ${TXN_HEADER_SIZE}, got ${offset})`);
404
+ if (offset !== TXN_HEADER_BODY_SIZE) {
405
+ throw new Error(`Transaction header parsing mismatch (expected offset ${TXN_HEADER_BODY_SIZE}, got ${offset})`);
405
406
  }
406
407
  const totalAccountCount = Number(readwriteAccountsCount + readonlyAccountsCount);
407
408
  if (strict && totalAccountCount > TXN_MAX_ACCOUNTS) {
@@ -412,7 +413,7 @@ var Transaction = class _Transaction {
412
413
  const accountsSize = totalAccountCount * PUBKEY_SIZE2;
413
414
  let expectedBodySize = accountsSize + instructionDataSize;
414
415
  if ((flags & TXN_FLAG_HAS_FEE_PAYER_PROOF) !== 0) {
415
- const proofOffset = TXN_HEADER_SIZE + accountsSize + instructionDataSize;
416
+ const proofOffset = TXN_HEADER_BODY_SIZE + accountsSize + instructionDataSize;
416
417
  _Transaction.ensureAvailable(data.length, proofOffset, STATE_PROOF_HEADER_SIZE, "state proof header");
417
418
  const proofView = new DataView(data.buffer, data.byteOffset + proofOffset, STATE_PROOF_HEADER_SIZE);
418
419
  const typeSlot = proofView.getBigUint64(0, true);
@@ -426,9 +427,9 @@ var Transaction = class _Transaction {
426
427
  expectedBodySize += ACCOUNT_META_FOOTPRINT;
427
428
  }
428
429
  }
429
- const txnSize = TXN_HEADER_SIZE + expectedBodySize + SIGNATURE_SIZE2;
430
+ const txnSize = TXN_HEADER_BODY_SIZE + expectedBodySize + SIGNATURE_SIZE2;
430
431
  _Transaction.ensureAvailable(data.length, 0, txnSize, "full transaction");
431
- const sigStart = TXN_HEADER_SIZE + expectedBodySize;
432
+ const sigStart = TXN_HEADER_BODY_SIZE + expectedBodySize;
432
433
  const readWriteAccounts = [];
433
434
  for (let i = 0; i < readwriteAccountsCount; i++) {
434
435
  _Transaction.ensureAvailable(sigStart, offset, PUBKEY_SIZE2, "read-write accounts");
@@ -461,7 +462,7 @@ var Transaction = class _Transaction {
461
462
  }
462
463
  if (offset !== sigStart) {
463
464
  throw new Error(
464
- `Transaction body has trailing bytes: expected ${offset + SIGNATURE_SIZE2} bytes but found ${txnSize}`
465
+ `Transaction body has trailing bytes: expected ${sigStart} bytes consumed but found ${offset}`
465
466
  );
466
467
  }
467
468
  const signatureBytes = data.slice(sigStart, sigStart + SIGNATURE_SIZE2);
@@ -495,7 +496,7 @@ var Transaction = class _Transaction {
495
496
  if (hasSignature) {
496
497
  transaction.setSignature(Signature.from(signatureBytes));
497
498
  }
498
- return { transaction, size: offset + SIGNATURE_SIZE2 };
499
+ return { transaction, size: txnSize };
499
500
  }
500
501
  static fromProto(proto) {
501
502
  if (!proto.header) {
@@ -524,9 +525,9 @@ var Transaction = class _Transaction {
524
525
  header.flags ?? DEFAULT_FLAGS
525
526
  );
526
527
  } catch (sectionErr) {
527
- if (body.length >= TXN_HEADER_SIZE) {
528
+ if (body.length >= TXN_HEADER_BODY_SIZE) {
528
529
  parsed = this.parseBodySections(
529
- body.slice(TXN_HEADER_SIZE),
530
+ body.slice(TXN_HEADER_BODY_SIZE),
530
531
  header.readwriteAccountsCount ?? 0,
531
532
  header.readonlyAccountsCount ?? 0,
532
533
  header.instructionDataSize ?? 0,
@@ -621,7 +622,7 @@ var Transaction = class _Transaction {
621
622
  return this.buildWirePayload(new Uint8Array(header), true);
622
623
  }
623
624
  createHeader() {
624
- const buffer = new ArrayBuffer(TXN_HEADER_SIZE);
625
+ const buffer = new ArrayBuffer(TXN_HEADER_BODY_SIZE);
625
626
  const headerBytes = new Uint8Array(buffer);
626
627
  const view = new DataView(buffer);
627
628
  let offset = 0;
@@ -1322,7 +1323,8 @@ function copyBytes4(bytes) {
1322
1323
  // thru-ts-client-sdk/modules/proofs.ts
1323
1324
  var proofs_exports = {};
1324
1325
  __export(proofs_exports, {
1325
- generateStateProof: () => generateStateProof
1326
+ generateStateProof: () => generateStateProof,
1327
+ getStateRoots: () => getStateRoots
1326
1328
  });
1327
1329
  async function generateStateProof(ctx, options) {
1328
1330
  const targetSlot = options.targetSlot ?? 0n;
@@ -1341,6 +1343,12 @@ async function generateStateProof(ctx, options) {
1341
1343
  }
1342
1344
  return StateProof.fromProto(response.proof);
1343
1345
  }
1346
+ async function getStateRoots(ctx, options = {}) {
1347
+ const request = create(GetStateRootsRequestSchema, {
1348
+ slot: options.slot
1349
+ });
1350
+ return ctx.query.getStateRoots(request, withCallOptions(ctx));
1351
+ }
1344
1352
 
1345
1353
  // thru-ts-client-sdk/modules/accounts.ts
1346
1354
  var accounts_exports = {};
@@ -1558,28 +1566,54 @@ var Block = class _Block {
1558
1566
  return block;
1559
1567
  }
1560
1568
  static fromWire(data) {
1561
- if (data.length < BLOCK_HEADER_SIZE) {
1562
- throw new Error(`Block data too short: ${data.length} bytes (expected at least ${BLOCK_HEADER_SIZE})`);
1569
+ const result = _Block.tryParseWireWithHeaderSize(data, BLOCK_HEADER_SIZE);
1570
+ if (result) {
1571
+ return result;
1572
+ }
1573
+ const legacyResult = _Block.tryParseWireWithHeaderSize(data, BLOCK_HEADER_SIZE_LEGACY);
1574
+ if (legacyResult) {
1575
+ return legacyResult;
1576
+ }
1577
+ throw new Error(`Block data too short: ${data.length} bytes (expected at least ${BLOCK_HEADER_SIZE})`);
1578
+ }
1579
+ static tryParseWireWithHeaderSize(data, headerSize) {
1580
+ if (data.length < headerSize) {
1581
+ return null;
1582
+ }
1583
+ const headerBytes = data.slice(0, headerSize);
1584
+ let header;
1585
+ let blockTimeNs;
1586
+ try {
1587
+ const parsed = this.parseHeaderWithSize(headerBytes, headerSize);
1588
+ header = parsed.header;
1589
+ blockTimeNs = parsed.blockTimeNs;
1590
+ } catch {
1591
+ return null;
1563
1592
  }
1564
- const headerBytes = data.slice(0, BLOCK_HEADER_SIZE);
1565
- const { header, blockTimeNs } = this.parseHeader(headerBytes);
1566
1593
  if (header.version !== BLOCK_VERSION_V1) {
1567
- throw new Error(`Unsupported block version: ${header.version}`);
1594
+ return null;
1568
1595
  }
1569
1596
  let finalHeader = header;
1570
1597
  let footer;
1571
1598
  let footerInfo;
1572
1599
  let body;
1573
- if (data.length >= BLOCK_HEADER_SIZE + BLOCK_FOOTER_SIZE) {
1600
+ if (data.length >= headerSize + BLOCK_FOOTER_SIZE) {
1574
1601
  const footerOffset = data.length - BLOCK_FOOTER_SIZE;
1575
1602
  const footerBytes = data.slice(footerOffset);
1576
- const parsedFooter = this.parseFooter(footerBytes);
1577
- footer = parsedFooter.footer;
1578
- footerInfo = { blockHash: parsedFooter.blockHash, attestorPayment: parsedFooter.attestorPayment };
1579
- finalHeader = header.withBlockHash(parsedFooter.blockHash);
1580
- body = footerOffset > BLOCK_HEADER_SIZE ? data.slice(BLOCK_HEADER_SIZE, footerOffset) : void 0;
1603
+ try {
1604
+ const parsedFooter = this.parseFooter(footerBytes);
1605
+ footer = parsedFooter.footer;
1606
+ footerInfo = { blockHash: parsedFooter.blockHash, attestorPayment: parsedFooter.attestorPayment };
1607
+ finalHeader = header.withBlockHash(parsedFooter.blockHash);
1608
+ } catch {
1609
+ return null;
1610
+ }
1611
+ body = footerOffset > headerSize ? data.slice(headerSize, footerOffset) : void 0;
1581
1612
  } else {
1582
- body = data.length > BLOCK_HEADER_SIZE ? data.slice(BLOCK_HEADER_SIZE) : void 0;
1613
+ body = data.length > headerSize ? data.slice(headerSize) : void 0;
1614
+ }
1615
+ if (body && body.length > 0 && !_Block.looksLikeValidTransactionBody(body)) {
1616
+ return null;
1583
1617
  }
1584
1618
  const block = new _Block({ header: finalHeader, footer, body });
1585
1619
  block.blockTimeNs = blockTimeNs;
@@ -1606,17 +1640,56 @@ var Block = class _Block {
1606
1640
  return _Block.parseTransactionsFromBody(this.body);
1607
1641
  }
1608
1642
  static extractTransactionBody(raw, hasFooter) {
1609
- if (!raw || raw.length <= BLOCK_HEADER_SIZE) {
1610
- return raw && raw.length > BLOCK_HEADER_SIZE ? raw.slice(BLOCK_HEADER_SIZE) : void 0;
1643
+ if (!raw || raw.length === 0) {
1644
+ return void 0;
1645
+ }
1646
+ const bodyWithCurrentHeader = _Block.extractWithHeaderSize(raw, hasFooter, BLOCK_HEADER_SIZE);
1647
+ if (bodyWithCurrentHeader && bodyWithCurrentHeader.length > 0 && _Block.looksLikeValidTransactionBody(bodyWithCurrentHeader)) {
1648
+ return bodyWithCurrentHeader;
1649
+ }
1650
+ const bodyWithLegacyHeader = _Block.extractWithHeaderSize(raw, hasFooter, BLOCK_HEADER_SIZE_LEGACY);
1651
+ if (bodyWithLegacyHeader && bodyWithLegacyHeader.length > 0 && _Block.looksLikeValidTransactionBody(bodyWithLegacyHeader)) {
1652
+ return bodyWithLegacyHeader;
1653
+ }
1654
+ return void 0;
1655
+ }
1656
+ static extractWithHeaderSize(raw, hasFooter, headerSize) {
1657
+ if (raw.length <= headerSize) {
1658
+ return void 0;
1611
1659
  }
1612
- const footerSize = hasFooter && raw.length >= BLOCK_HEADER_SIZE + BLOCK_FOOTER_SIZE ? BLOCK_FOOTER_SIZE : 0;
1613
- const start = BLOCK_HEADER_SIZE;
1660
+ const footerSize = hasFooter && raw.length >= headerSize + BLOCK_FOOTER_SIZE ? BLOCK_FOOTER_SIZE : 0;
1661
+ const start = headerSize;
1614
1662
  const end = Math.max(start, raw.length - footerSize);
1615
1663
  if (end <= start) {
1616
1664
  return void 0;
1617
1665
  }
1618
1666
  return raw.slice(start, end);
1619
1667
  }
1668
+ /**
1669
+ * Checks if the data looks like a valid transaction body.
1670
+ * Uses heuristics to detect if we've correctly offset into the block data.
1671
+ * Wire format: header (112 bytes) + body + signature (64 bytes at end)
1672
+ * This is a lenient heuristic for format detection - version/flag validation
1673
+ * happens in Transaction.parseWire.
1674
+ */
1675
+ static looksLikeValidTransactionBody(data) {
1676
+ const MIN_TXN_SIZE = TXN_HEADER_BODY_SIZE + SIGNATURE_SIZE2;
1677
+ if (data.length < MIN_TXN_SIZE) {
1678
+ return false;
1679
+ }
1680
+ const readwriteCount = data[2] | data[3] << 8;
1681
+ const readonlyCount = data[4] | data[5] << 8;
1682
+ const totalAccounts = readwriteCount + readonlyCount;
1683
+ if (totalAccounts > 1024) {
1684
+ return false;
1685
+ }
1686
+ const instrDataSize = data[6] | data[7] << 8;
1687
+ const expectedMinSize = TXN_HEADER_BODY_SIZE + totalAccounts * PUBKEY_SIZE2 + instrDataSize + SIGNATURE_SIZE2;
1688
+ if (data.length < expectedMinSize) {
1689
+ return false;
1690
+ }
1691
+ return true;
1692
+ }
1620
1693
  serializeHeader() {
1621
1694
  const buffer = new ArrayBuffer(BLOCK_HEADER_SIZE);
1622
1695
  const bytes = new Uint8Array(buffer);
@@ -1721,6 +1794,66 @@ var Block = class _Block {
1721
1794
  });
1722
1795
  return { header, blockTimeNs };
1723
1796
  }
1797
+ /**
1798
+ * Parses a block header with a specific expected size.
1799
+ * Handles both current (168 bytes with weight_slot) and legacy (160 bytes without weight_slot) formats.
1800
+ */
1801
+ static parseHeaderWithSize(bytes, expectedSize) {
1802
+ if (bytes.length !== expectedSize) {
1803
+ throw new Error(`Invalid block header size: ${bytes.length}, expected ${expectedSize}`);
1804
+ }
1805
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
1806
+ let offset = 0;
1807
+ const signature = bytes.slice(offset, offset + SIGNATURE_SIZE2);
1808
+ offset += SIGNATURE_SIZE2;
1809
+ const version = view.getUint8(offset);
1810
+ offset += 1;
1811
+ offset += 5;
1812
+ const chainId = view.getUint16(offset, true);
1813
+ offset += 2;
1814
+ const producer = bytes.slice(offset, offset + PUBKEY_SIZE2);
1815
+ offset += PUBKEY_SIZE2;
1816
+ const bondAmountLockUp = view.getBigUint64(offset, true);
1817
+ offset += 8;
1818
+ const expiryTimestampNs = view.getBigUint64(offset, true);
1819
+ offset += 8;
1820
+ const startSlot = view.getBigUint64(offset, true);
1821
+ offset += 8;
1822
+ const expiryAfter = view.getUint32(offset, true);
1823
+ offset += 4;
1824
+ const maxBlockSize = view.getUint32(offset, true);
1825
+ offset += 4;
1826
+ const maxComputeUnits = view.getBigUint64(offset, true);
1827
+ offset += 8;
1828
+ const maxStateUnits = view.getUint32(offset, true);
1829
+ offset += 4;
1830
+ offset += 4;
1831
+ let weightSlot;
1832
+ let blockTimeNs;
1833
+ if (expectedSize === BLOCK_HEADER_SIZE) {
1834
+ weightSlot = view.getBigUint64(offset, true);
1835
+ offset += 8;
1836
+ blockTimeNs = view.getBigUint64(offset, true);
1837
+ } else {
1838
+ blockTimeNs = view.getBigUint64(offset, true);
1839
+ }
1840
+ const header = new BlockHeader({
1841
+ slot: startSlot,
1842
+ version,
1843
+ headerSignature: signature,
1844
+ producer,
1845
+ expiryTimestamp: nanosecondsToTimestamp(expiryTimestampNs),
1846
+ startSlot,
1847
+ expiryAfter,
1848
+ maxBlockSize,
1849
+ maxComputeUnits,
1850
+ maxStateUnits,
1851
+ bondAmountLockUp,
1852
+ weightSlot,
1853
+ chainId
1854
+ });
1855
+ return { header, blockTimeNs };
1856
+ }
1724
1857
  static parseFooter(bytes) {
1725
1858
  if (bytes.length !== BLOCK_FOOTER_SIZE) {
1726
1859
  throw new Error(`Invalid block footer size: ${bytes.length}`);
@@ -1746,9 +1879,16 @@ var Block = class _Block {
1746
1879
  let offset = 0;
1747
1880
  while (offset < body.length) {
1748
1881
  const slice = body.subarray(offset);
1749
- const { transaction, size } = Transaction.parseWire(slice);
1750
- transactions.push(transaction);
1751
- offset += size;
1882
+ if (slice.length < 176) {
1883
+ break;
1884
+ }
1885
+ try {
1886
+ const { transaction, size } = Transaction.parseWire(slice);
1887
+ transactions.push(transaction);
1888
+ offset += size;
1889
+ } catch {
1890
+ break;
1891
+ }
1752
1892
  }
1753
1893
  return transactions;
1754
1894
  }
@@ -1900,11 +2040,15 @@ async function listBlocks(ctx, options = {}) {
1900
2040
  // thru-ts-client-sdk/modules/chain.ts
1901
2041
  var chain_exports = {};
1902
2042
  __export(chain_exports, {
1903
- getChainId: () => getChainId
2043
+ getChainId: () => getChainId,
2044
+ getChainInfo: () => getChainInfo
1904
2045
  });
1905
- async function getChainId(ctx) {
2046
+ async function getChainInfo(ctx) {
1906
2047
  const request = create(GetChainInfoRequestSchema);
1907
- const response = await ctx.query.getChainInfo(request, withCallOptions(ctx));
2048
+ return ctx.query.getChainInfo(request, withCallOptions(ctx));
2049
+ }
2050
+ async function getChainId(ctx) {
2051
+ const response = await getChainInfo(ctx);
1908
2052
  return response.chainId;
1909
2053
  }
1910
2054
 
@@ -2148,6 +2292,40 @@ function generateSeed() {
2148
2292
  cryptoObj.getRandomValues(bytes);
2149
2293
  return bytes;
2150
2294
  }
2295
+
2296
+ // thru-ts-client-sdk/modules/node.ts
2297
+ var node_exports = {};
2298
+ __export(node_exports, {
2299
+ getNodePubkey: () => getNodePubkey,
2300
+ getNodeRecords: () => getNodeRecords
2301
+ });
2302
+ async function getNodePubkey(ctx) {
2303
+ const request = create(GetNodePubkeyRequestSchema, {});
2304
+ return ctx.query.getNodePubkey(request, withCallOptions(ctx));
2305
+ }
2306
+ async function getNodeRecords(ctx) {
2307
+ const request = create(GetNodeRecordsRequestSchema, {});
2308
+ return ctx.query.getNodeRecords(request, withCallOptions(ctx));
2309
+ }
2310
+
2311
+ // thru-ts-client-sdk/modules/slots.ts
2312
+ var slots_exports = {};
2313
+ __export(slots_exports, {
2314
+ getSlotMetrics: () => getSlotMetrics,
2315
+ listSlotMetrics: () => listSlotMetrics
2316
+ });
2317
+ async function getSlotMetrics(ctx, slot) {
2318
+ const request = create(GetSlotMetricsRequestSchema, { slot });
2319
+ return ctx.query.getSlotMetrics(request, withCallOptions(ctx));
2320
+ }
2321
+ async function listSlotMetrics(ctx, options) {
2322
+ const request = create(ListSlotMetricsRequestSchema, {
2323
+ startSlot: options.startSlot,
2324
+ endSlot: options.endSlot,
2325
+ limit: options.limit
2326
+ });
2327
+ return ctx.query.listSlotMetrics(request, withCallOptions(ctx));
2328
+ }
2151
2329
  function copyBytes8(source) {
2152
2330
  const bytes = new Uint8Array(source.length);
2153
2331
  bytes.set(source);
@@ -2524,6 +2702,8 @@ __export(streaming_exports, {
2524
2702
  streamBlocks: () => streamBlocks,
2525
2703
  streamEvents: () => streamEvents,
2526
2704
  streamHeight: () => streamHeight,
2705
+ streamNodeRecords: () => streamNodeRecords,
2706
+ streamSlotMetrics: () => streamSlotMetrics,
2527
2707
  streamTransactions: () => streamTransactions,
2528
2708
  trackTransaction: () => trackTransaction
2529
2709
  });
@@ -2548,7 +2728,7 @@ function streamBlocks(ctx, options = {}) {
2548
2728
  function streamAccountUpdates(ctx, address, options = {}) {
2549
2729
  const addressBytes = Pubkey.from(address).toBytes();
2550
2730
  const addressFilter = new Filter({
2551
- expression: "snapshot.address.value == params.address || account_update.address.value == params.address",
2731
+ expression: "account_address.value == params.address",
2552
2732
  params: {
2553
2733
  address: FilterParamValue.bytes(addressBytes)
2554
2734
  }
@@ -2642,6 +2822,38 @@ function streamHeight(ctx, options = {}) {
2642
2822
  }
2643
2823
  return mapper();
2644
2824
  }
2825
+ function streamSlotMetrics(ctx, options = {}) {
2826
+ const request = create(StreamSlotMetricsRequestSchema, {
2827
+ startSlot: options.startSlot
2828
+ });
2829
+ const iterable = ctx.streaming.streamSlotMetrics(request, withCallOptions(ctx, { signal: options.signal }));
2830
+ async function* mapper() {
2831
+ for await (const response of iterable) {
2832
+ yield {
2833
+ slot: response.slot,
2834
+ collectedFees: response.collectedFees,
2835
+ globalActivatedStateCounter: response.globalActivatedStateCounter,
2836
+ globalDeactivatedStateCounter: response.globalDeactivatedStateCounter,
2837
+ blockTimestamp: response.blockTimestamp
2838
+ };
2839
+ }
2840
+ }
2841
+ return mapper();
2842
+ }
2843
+ function streamNodeRecords(ctx, options = {}) {
2844
+ const request = create(StreamNodeRecordsRequestSchema, {});
2845
+ const iterable = ctx.streaming.streamNodeRecords(request, withCallOptions(ctx, { signal: options.signal }));
2846
+ async function* mapper() {
2847
+ for await (const response of iterable) {
2848
+ if (response.message.case === "record") {
2849
+ yield { type: "record", record: response.message.value };
2850
+ } else if (response.message.case === "finished") {
2851
+ yield { type: "finished" };
2852
+ }
2853
+ }
2854
+ }
2855
+ return mapper();
2856
+ }
2645
2857
  async function collectStream(iterable, options = {}) {
2646
2858
  const { limit, signal } = options;
2647
2859
  throwIfAborted(signal);
@@ -2698,6 +2910,7 @@ __export(transactions_exports, {
2698
2910
  getTransactionStatus: () => getTransactionStatus,
2699
2911
  listTransactions: () => listTransactions,
2700
2912
  listTransactionsForAccount: () => listTransactionsForAccount,
2913
+ sendAndTrackTxn: () => sendAndTrackTxn,
2701
2914
  sendTransaction: () => sendTransaction
2702
2915
  });
2703
2916
  async function getTransaction(ctx, signature, options = {}) {
@@ -2793,6 +3006,35 @@ async function batchSendTransactions(ctx, transactions, options = {}) {
2793
3006
  });
2794
3007
  return ctx.command.batchSendTransactions(request, withCallOptions(ctx));
2795
3008
  }
3009
+ function sendAndTrackTxn(ctx, transaction, options = {}) {
3010
+ const raw = transaction instanceof Uint8Array ? transaction : transaction.toWire();
3011
+ const request = create(SendAndTrackTxnRequestSchema, {
3012
+ transaction: raw,
3013
+ timeout: options.timeoutMs != null ? {
3014
+ seconds: BigInt(Math.floor(options.timeoutMs / 1e3)),
3015
+ nanos: options.timeoutMs % 1e3 * 1e6
3016
+ } : void 0
3017
+ });
3018
+ const iterable = ctx.command.sendAndTrackTxn(request, {
3019
+ ...withCallOptions(ctx),
3020
+ signal: options.signal
3021
+ });
3022
+ async function* mapper() {
3023
+ for await (const response of iterable) {
3024
+ yield {
3025
+ status: response.status,
3026
+ signature: response.signature ? { value: response.signature.value } : void 0,
3027
+ consensusStatus: response.consensusStatus,
3028
+ executionResult: response.executionResult ? {
3029
+ vmError: response.executionResult.vmError,
3030
+ consumedComputeUnits: response.executionResult.consumedComputeUnits,
3031
+ userErrorCode: response.executionResult.userErrorCode
3032
+ } : void 0
3033
+ };
3034
+ }
3035
+ }
3036
+ return mapper();
3037
+ }
2796
3038
  async function sendRawTransaction(ctx, rawTransaction) {
2797
3039
  const request = create(SendTransactionRequestSchema, { rawTransaction });
2798
3040
  const response = await ctx.command.sendTransaction(request, withCallOptions(ctx));
@@ -2931,6 +3173,6 @@ var VersionInfo = class _VersionInfo {
2931
3173
  }
2932
3174
  };
2933
3175
 
2934
- export { Account, Block, ChainEvent, Filter, FilterParamValue, HeightSnapshot, PageRequest, PageResponse, Pubkey, Signature, SignatureDomain, StateProof, Transaction, TransactionBuilder, TransactionStatusSnapshot, VersionInfo, accounts_exports, batchSendTransactions, blocks_exports, buildAndSignTransaction, buildTransaction, chain_exports, collectStream, consensusStatusToString, consensus_exports, createAccount, createThruClientContext, currentOrHistoricalVersionContext, currentVersionContext, deriveAddress, deriveProgramAddress, events_exports, firstStreamValue, forEachStreamValue, fromPrivateKey, generateKeyPair, generateStateProof, getAccount, getBlock, getBlockHeight, getEvent, getRawAccount, getRawBlock, getRawTransaction, getTransaction, getTransactionStatus, height_exports, keys_exports, listAccounts, listBlocks, listEvents, listTransactions, listTransactionsForAccount, proofs_exports, sendTransaction, seqVersionContext, signWithDomain, slotVersionContext, streamAccountUpdates, streamBlocks, streamEvents, streamHeight, streamTransactions, streaming_exports, timestampVersionContext, trackTransaction, transactions_exports, verifyWithDomain, versionContext, withCallOptions };
2935
- //# sourceMappingURL=chunk-YIQKZL4H.js.map
2936
- //# sourceMappingURL=chunk-YIQKZL4H.js.map
3176
+ export { Account, Block, ChainEvent, Filter, FilterParamValue, HeightSnapshot, PageRequest, PageResponse, Pubkey, Signature, SignatureDomain, StateProof, Transaction, TransactionBuilder, TransactionStatusSnapshot, VersionInfo, accounts_exports, batchSendTransactions, blocks_exports, buildAndSignTransaction, buildTransaction, chain_exports, collectStream, consensusStatusToString, consensus_exports, createAccount, createThruClientContext, currentOrHistoricalVersionContext, currentVersionContext, deriveAddress, deriveProgramAddress, events_exports, firstStreamValue, forEachStreamValue, fromPrivateKey, generateKeyPair, generateStateProof, getAccount, getBlock, getBlockHeight, getChainId, getChainInfo, getEvent, getNodePubkey, getNodeRecords, getRawAccount, getRawBlock, getRawTransaction, getSlotMetrics, getStateRoots, getTransaction, getTransactionStatus, height_exports, keys_exports, listAccounts, listBlocks, listEvents, listSlotMetrics, listTransactions, listTransactionsForAccount, node_exports, proofs_exports, sendAndTrackTxn, sendTransaction, seqVersionContext, signWithDomain, slotVersionContext, slots_exports, streamAccountUpdates, streamBlocks, streamEvents, streamHeight, streamNodeRecords, streamSlotMetrics, streamTransactions, streaming_exports, timestampVersionContext, trackTransaction, transactions_exports, verifyWithDomain, versionContext, withCallOptions };
3177
+ //# sourceMappingURL=chunk-ZMDQDIE5.js.map
3178
+ //# sourceMappingURL=chunk-ZMDQDIE5.js.map