@bounded-sh/core 0.0.117 → 0.0.118

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.
Files changed (39) hide show
  1. package/dist/client/reconcile.d.ts +2 -2
  2. package/dist/client/solana-confirm.d.ts +49 -0
  3. package/dist/client/solana-operations.d.ts +7 -1
  4. package/dist/{index-C6ZW5Gt2.mjs → index-BXfRRAUZ.mjs} +84 -28
  5. package/dist/index-BXfRRAUZ.mjs.map +1 -0
  6. package/dist/{index-DQ0FXeI8.js → index-l9LI3y1q.js} +84 -27
  7. package/dist/index-l9LI3y1q.js.map +1 -0
  8. package/dist/index.d.ts +2 -0
  9. package/dist/index.js +2 -1
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.mjs +1 -1
  12. package/dist/{mirror-sync-ChzMq7bH.js → mirror-sync-DJVm0KKu.js} +2 -2
  13. package/dist/{mirror-sync-ChzMq7bH.js.map → mirror-sync-DJVm0KKu.js.map} +1 -1
  14. package/dist/{mirror-sync-kt9PzQen.mjs → mirror-sync-DoH9ewTo.mjs} +2 -2
  15. package/dist/{mirror-sync-kt9PzQen.mjs.map → mirror-sync-DoH9ewTo.mjs.map} +1 -1
  16. package/dist/{realtime-store-FUjGL_Z8.mjs → realtime-store-BreUReSo.mjs} +2 -2
  17. package/dist/{realtime-store-FUjGL_Z8.mjs.map → realtime-store-BreUReSo.mjs.map} +1 -1
  18. package/dist/{realtime-store-CURbZ68v.js → realtime-store-kZMPgwVB.js} +2 -2
  19. package/dist/{realtime-store-CURbZ68v.js.map → realtime-store-kZMPgwVB.js.map} +1 -1
  20. package/dist/{solana-message-CEjXjnaG.mjs → solana-message-CjI0h27k.mjs} +2 -2
  21. package/dist/{solana-message-CEjXjnaG.mjs.map → solana-message-CjI0h27k.mjs.map} +1 -1
  22. package/dist/{solana-message-F1e5wPKF.js → solana-message-HkOoUz8z.js} +2 -2
  23. package/dist/{solana-message-F1e5wPKF.js.map → solana-message-HkOoUz8z.js.map} +1 -1
  24. package/dist/{solana-operations-5WjFwhnt.mjs → solana-operations-CD6pks4-.mjs} +32 -30
  25. package/dist/solana-operations-CD6pks4-.mjs.map +1 -0
  26. package/dist/{solana-operations-CI0sREvl.js → solana-operations-DFohVGz6.js} +32 -29
  27. package/dist/solana-operations-DFohVGz6.js.map +1 -0
  28. package/dist/{solana-v1-operations-oot2R63I.js → solana-v1-operations-bhDjo-5U.js} +10 -24
  29. package/dist/solana-v1-operations-bhDjo-5U.js.map +1 -0
  30. package/dist/{solana-v1-operations-DB9pih7o.mjs → solana-v1-operations-ewIzFDeY.mjs} +10 -24
  31. package/dist/solana-v1-operations-ewIzFDeY.mjs.map +1 -0
  32. package/dist/types.d.ts +8 -15
  33. package/package.json +1 -1
  34. package/dist/index-C6ZW5Gt2.mjs.map +0 -1
  35. package/dist/index-DQ0FXeI8.js.map +0 -1
  36. package/dist/solana-operations-5WjFwhnt.mjs.map +0 -1
  37. package/dist/solana-operations-CI0sREvl.js.map +0 -1
  38. package/dist/solana-v1-operations-DB9pih7o.mjs.map +0 -1
  39. package/dist/solana-v1-operations-oot2R63I.js.map +0 -1
@@ -4307,7 +4307,7 @@ class ServerSessionManager {
4307
4307
  const sessionConfig = (_a = this.sessionConfig) !== null && _a !== void 0 ? _a : undefined;
4308
4308
  /* fetch nonce from auth API (bound to the snapshotted app+issuer) */
4309
4309
  const nonce = await genAuthNonce(sessionConfig);
4310
- const { genSolanaMessage } = await Promise.resolve().then(function () { return require('./solana-message-F1e5wPKF.js'); });
4310
+ const { genSolanaMessage } = await Promise.resolve().then(function () { return require('./solana-message-HkOoUz8z.js'); });
4311
4311
  const message = await genSolanaMessage(address, nonce, sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.appId);
4312
4312
  /* sign the message */
4313
4313
  const sigBytes = nacl.sign.detached(new TextEncoder().encode(message), kp.secretKey);
@@ -7679,7 +7679,7 @@ async function doReconnectWithNewAuth() {
7679
7679
  console.warn('[WS v2] Failed to clear HTTP read cache on auth change:', error);
7680
7680
  }
7681
7681
  try {
7682
- const { reconnectRealtimeStoreWithNewAuth } = await Promise.resolve().then(function () { return require('./realtime-store-CURbZ68v.js'); });
7682
+ const { reconnectRealtimeStoreWithNewAuth } = await Promise.resolve().then(function () { return require('./realtime-store-kZMPgwVB.js'); });
7683
7683
  await reconnectRealtimeStoreWithNewAuth();
7684
7684
  }
7685
7685
  catch (error) {
@@ -8898,7 +8898,7 @@ function buildRequestedDocuments(documents) {
8898
8898
  /** Best-effort readback, including a failure to load its lazy implementation. */
8899
8899
  async function attemptMirrorSync(paths, options, transactionSignature) {
8900
8900
  try {
8901
- const mirror = await Promise.resolve().then(function () { return require('./mirror-sync-ChzMq7bH.js'); });
8901
+ const mirror = await Promise.resolve().then(function () { return require('./mirror-sync-DJVm0KKu.js'); });
8902
8902
  return await mirror.attemptMirrorSync(paths, options, transactionSignature);
8903
8903
  }
8904
8904
  catch (error) {
@@ -9118,7 +9118,7 @@ async function setMany(many, options) {
9118
9118
  if (typeof curTx.serializedTransaction !== 'string' || typeof curTx.poofnetIntentId !== 'string') {
9119
9119
  throw new Error('Unsupported 202 transaction shape: a poofnet write needs serializedTransaction and poofnetIntentId');
9120
9120
  }
9121
- const { signPoofnetTransaction, buildExpectedWriteIntent } = await Promise.resolve().then(function () { return require('./solana-operations-CI0sREvl.js'); });
9121
+ const { signPoofnetTransaction, buildExpectedWriteIntent } = await Promise.resolve().then(function () { return require('./solana-operations-DFohVGz6.js'); });
9122
9122
  const signedTransaction = await signPoofnetTransaction(curTx.serializedTransaction, authProvider, options, buildExpectedWriteIntent(documents));
9123
9123
  // Signing-only, exactly as on a real chain: signed and NOT committed.
9124
9124
  if ((options === null || options === void 0 ? void 0 : options.shouldSubmitTx) === false) {
@@ -9156,7 +9156,7 @@ async function setMany(many, options) {
9156
9156
  'Nothing was signed or submitted.');
9157
9157
  }
9158
9158
  const solanaChain = workerChain;
9159
- const { handlePreBuiltTransaction, buildExpectedWriteIntent } = await Promise.resolve().then(function () { return require('./solana-operations-CI0sREvl.js'); });
9159
+ const { handlePreBuiltTransaction, buildExpectedWriteIntent } = await Promise.resolve().then(function () { return require('./solana-operations-DFohVGz6.js'); });
9160
9160
  // OA-0001: derive the expected intent from OUR OWN request (the one
9161
9161
  // ground truth a tampered builder response cannot change) so the
9162
9162
  // validator can reject any transaction whose operation semantics
@@ -9496,9 +9496,81 @@ var operations = /*#__PURE__*/Object.freeze({
9496
9496
  signTransaction: signTransaction
9497
9497
  });
9498
9498
 
9499
+ const DEFAULT_POLL_INTERVAL_MS$1 = 1000;
9500
+ const DEFAULT_MAX_WAIT_MS = 120000;
9501
+ /**
9502
+ * Whether a status is final enough to decide on. `processed` can still belong to a fork
9503
+ * that is dropped, so only `confirmed` or `finalized` settle a write; an RPC that omits
9504
+ * `confirmationStatus` reports a rooted transaction as `confirmations: null`.
9505
+ */
9506
+ function settledSignatureStatus(status) {
9507
+ if (!status)
9508
+ return false;
9509
+ if (status.confirmationStatus === 'confirmed' || status.confirmationStatus === 'finalized')
9510
+ return true;
9511
+ return status.confirmationStatus == null && status.confirmations === null;
9512
+ }
9513
+ /**
9514
+ * Poll the SAME signature until it is seen at `confirmed` or the blockhash fence closes.
9515
+ * Never broadcasts. A `processed` status, even one carrying an error, is not a verdict and
9516
+ * keeps the loop going. Once the confirmed block height passes `lastValidBlockHeight`, one
9517
+ * history-searching read decides whether the transaction landed anyway; if not, the answer
9518
+ * is "not seen" or "seen only below confirmed", never "never landed": only a finalized
9519
+ * expiry proves that, which is `reconcileSetResult`'s job. Transient RPC failures retry the
9520
+ * same signature.
9521
+ */
9522
+ async function confirmSignature(rpc, fence, options = {}) {
9523
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
9524
+ if (typeof rpc.getSignatureStatuses !== 'function' || typeof rpc.getBlockHeight !== 'function') {
9525
+ // An injected RPC that cannot answer is reported at once, not retried for two minutes.
9526
+ return { landed: false, reason: 'the configured Solana RPC cannot report signature statuses and block height' };
9527
+ }
9528
+ const pollIntervalMs = (_a = options.pollIntervalMs) !== null && _a !== void 0 ? _a : DEFAULT_POLL_INTERVAL_MS$1;
9529
+ const maxWaitMs = (_b = options.maxWaitMs) !== null && _b !== void 0 ? _b : DEFAULT_MAX_WAIT_MS;
9530
+ const startedAt = Date.now();
9531
+ let lastFailure = null;
9532
+ for (;;) {
9533
+ try {
9534
+ // Status first: a settled status decides on its own, and the height is read only
9535
+ // while the transaction is still unseen, so a failing height read never discards
9536
+ // a confirmation this tick already has.
9537
+ const statuses = await rpc.getSignatureStatuses([fence.signature]);
9538
+ const status = (_d = (_c = statuses === null || statuses === void 0 ? void 0 : statuses.value) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : null;
9539
+ if (settledSignatureStatus(status))
9540
+ return { landed: true, status, contextSlot: (_e = statuses === null || statuses === void 0 ? void 0 : statuses.context) === null || _e === void 0 ? void 0 : _e.slot };
9541
+ const blockHeight = await rpc.getBlockHeight('confirmed');
9542
+ if (blockHeight > fence.lastValidBlockHeight) {
9543
+ const history = await rpc.getSignatureStatuses([fence.signature], { searchTransactionHistory: true });
9544
+ const late = (_g = (_f = history === null || history === void 0 ? void 0 : history.value) === null || _f === void 0 ? void 0 : _f[0]) !== null && _g !== void 0 ? _g : null;
9545
+ if (settledSignatureStatus(late))
9546
+ return { landed: true, status: late, contextSlot: (_h = history === null || history === void 0 ? void 0 : history.context) === null || _h === void 0 ? void 0 : _h.slot };
9547
+ const seen = late ? `seen only at ${String((_j = late.confirmationStatus) !== null && _j !== void 0 ? _j : 'an unconfirmed')} commitment` : 'not seen at confirmed';
9548
+ return {
9549
+ landed: false,
9550
+ reason: `${seen} before the blockhash expired (block height ${blockHeight} is past ${fence.lastValidBlockHeight})`,
9551
+ };
9552
+ }
9553
+ lastFailure = null;
9554
+ }
9555
+ catch (error) {
9556
+ // Transient: keep polling the same signature. The ceiling below bounds a dead RPC.
9557
+ lastFailure = error instanceof Error ? error.message : String(error);
9558
+ }
9559
+ if (Date.now() - startedAt >= maxWaitMs) {
9560
+ return {
9561
+ landed: false,
9562
+ reason: lastFailure
9563
+ ? `the RPC kept failing while the transaction was awaited: ${lastFailure}`
9564
+ : `not seen at confirmed within ${Math.round(maxWaitMs / 1000)}s and the block height never passed the blockhash fence`,
9565
+ };
9566
+ }
9567
+ await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
9568
+ }
9569
+ }
9570
+
9499
9571
  const DEFAULT_TIMEOUT_MS = 60000;
9500
- const DEFAULT_MAX_ATTEMPTS$1 = 20;
9501
- const DEFAULT_POLL_INTERVAL_MS = 3000;
9572
+ const DEFAULT_MAX_ATTEMPTS$1 = 60;
9573
+ const DEFAULT_POLL_INTERVAL_MS = 1000;
9502
9574
  function errorText(error) {
9503
9575
  const message = error === null || error === void 0 ? void 0 : error.message;
9504
9576
  return typeof message === 'string' && message.length > 0 ? message : String(error);
@@ -9566,18 +9638,6 @@ async function resolveSolanaRpc(config, options) {
9566
9638
  const { Connection } = await import('@solana/web3.js');
9567
9639
  return new Connection(rpcUrl, 'confirmed');
9568
9640
  }
9569
- /**
9570
- * Whether a signature status is final enough to decide on. `processed` can still belong to a fork
9571
- * that is dropped, so only `confirmed` or `finalized` settle a write; an RPC that omits
9572
- * `confirmationStatus` reports a rooted transaction as `confirmations: null`.
9573
- */
9574
- function settledStatus(status) {
9575
- if (!status)
9576
- return false;
9577
- if (status.confirmationStatus === 'confirmed' || status.confirmationStatus === 'finalized')
9578
- return true;
9579
- return status.confirmationStatus == null && status.confirmations === null;
9580
- }
9581
9641
  /**
9582
9642
  * Solana reconciliation NEVER broadcasts. It settles on a `confirmed` or `finalized` status only,
9583
9643
  * and reaches `expired_not_landed` only from the chain's own blockhash expiry: the FINALIZED block
@@ -9589,17 +9649,13 @@ function settledStatus(status) {
9589
9649
  async function reconcileSolana(receipt, config, options) {
9590
9650
  var _a, _b, _c, _d;
9591
9651
  const rpc = await resolveSolanaRpc(config, options);
9592
- if (typeof rpc.getSignatureStatuses !== 'function') {
9593
- return stillSubmitted(receipt, 'the configured Solana RPC cannot report signature statuses');
9594
- }
9595
9652
  // Expiry is read BEFORE the status, so an absence observed afterwards is an absence after the
9596
9653
  // fence closed for good. A finalized height past lastValidBlockHeight is final: the blockhash
9597
9654
  // can never become valid again.
9598
9655
  let finalizedHeight;
9599
9656
  let finalizedSlot;
9600
9657
  try {
9601
- if (typeof rpc.getBlockHeight === 'function')
9602
- finalizedHeight = await rpc.getBlockHeight('finalized');
9658
+ finalizedHeight = await rpc.getBlockHeight('finalized');
9603
9659
  if (typeof rpc.getSlot === 'function')
9604
9660
  finalizedSlot = await rpc.getSlot('finalized');
9605
9661
  }
@@ -9618,7 +9674,7 @@ async function reconcileSolana(receipt, config, options) {
9618
9674
  return stillSubmitted(receipt, `signature status lookup failed: ${errorText(error)}`);
9619
9675
  }
9620
9676
  if (statusValue) {
9621
- if (!settledStatus(statusValue)) {
9677
+ if (!settledSignatureStatus(statusValue)) {
9622
9678
  return stillSubmitted(receipt, `seen at ${String((_d = statusValue.confirmationStatus) !== null && _d !== void 0 ? _d : 'an unconfirmed')} commitment; waiting for confirmed`);
9623
9679
  }
9624
9680
  // Landed. A landed-but-failed transaction is a genuine failure, not `submitted`.
@@ -10988,7 +11044,7 @@ function toMillis(seconds) {
10988
11044
 
10989
11045
  /** SIWS message creation is async already, so its onchain module can be lazy. */
10990
11046
  async function genSolanaMessage(address, nonce) {
10991
- const implementation = await Promise.resolve().then(function () { return require('./solana-message-F1e5wPKF.js'); });
11047
+ const implementation = await Promise.resolve().then(function () { return require('./solana-message-HkOoUz8z.js'); });
10992
11048
  return implementation.genSolanaMessage(address, nonce);
10993
11049
  }
10994
11050
 
@@ -11567,6 +11623,7 @@ exports.clearAppTokenCache = clearAppTokenCache;
11567
11623
  exports.clearCache = clearCache;
11568
11624
  exports.closeAllQuerySubscriptions = closeAllQuerySubscriptions;
11569
11625
  exports.closeAllSubscriptions = closeAllSubscriptions;
11626
+ exports.confirmSignature = confirmSignature;
11570
11627
  exports.count = count;
11571
11628
  exports.createAppTokenAuthHeaders = createAppTokenAuthHeaders;
11572
11629
  exports.createClient = createClient;
@@ -11642,4 +11699,4 @@ exports.toSeconds = toSeconds;
11642
11699
  exports.waitForSetResult = waitForSetResult;
11643
11700
  exports.withEffects = withEffects;
11644
11701
  exports.writeNotAppliedPhase = writeNotAppliedPhase;
11645
- //# sourceMappingURL=index-DQ0FXeI8.js.map
11702
+ //# sourceMappingURL=index-l9LI3y1q.js.map