@odatano/core 2.0.0-rc.49 → 2.0.0-rc.50

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 (120) hide show
  1. package/@cds-models/CardanoAgentService/index.d.ts +6 -12
  2. package/@cds-models/CardanoIndexerService/index.d.ts +200 -2
  3. package/@cds-models/CardanoIndexerService/index.js +24 -0
  4. package/@cds-models/CardanoODataService/index.d.ts +49 -6
  5. package/@cds-models/CardanoODataService/index.js +4 -0
  6. package/@cds-models/CardanoSignService/index.d.ts +3 -3
  7. package/@cds-models/CardanoWorkerService/index.d.ts +4 -3
  8. package/@cds-models/index.d.ts +9 -1
  9. package/@cds-models/index.js +2 -1
  10. package/@cds-models/odatano/cardano/index.d.ts +59 -5
  11. package/@cds-models/odatano/cardano/index.js +6 -0
  12. package/README.md +29 -17
  13. package/db/schema.cds +117 -24
  14. package/db/types.cds +8 -0
  15. package/package.json +17 -15
  16. package/scripts/migrate-schema.mjs +334 -0
  17. package/src/index.d.ts +7 -5
  18. package/src/index.js +12 -10
  19. package/src/plugin.js +6 -7
  20. package/srv/blockchain/backends/blockfrost-backend.js +9 -1
  21. package/srv/blockchain/backends/cardano-backend.d.ts +15 -0
  22. package/srv/blockchain/backends/cardano-backend.js +5 -0
  23. package/srv/blockchain/backends/koios-backend.js +16 -10
  24. package/srv/blockchain/backends/ogmios-backend.d.ts +9 -3
  25. package/srv/blockchain/backends/ogmios-backend.js +60 -18
  26. package/srv/blockchain/cardano-client.d.ts +5 -4
  27. package/srv/blockchain/cardano-client.js +46 -13
  28. package/srv/blockchain/cardano-indexer.d.ts +116 -9
  29. package/srv/blockchain/cardano-indexer.js +436 -189
  30. package/srv/blockchain/crawler/account-snapshots.d.ts +29 -0
  31. package/srv/blockchain/crawler/account-snapshots.js +153 -0
  32. package/srv/blockchain/crawler/asset-registry-backfill.d.ts +23 -1
  33. package/srv/blockchain/crawler/asset-registry-backfill.js +91 -1
  34. package/srv/blockchain/crawler/certificate-backfill.d.ts +2 -0
  35. package/srv/blockchain/crawler/certificate-backfill.js +10 -3
  36. package/srv/blockchain/crawler/crawler.d.ts +15 -0
  37. package/srv/blockchain/crawler/crawler.js +68 -3
  38. package/srv/blockchain/crawler/input-asset-copies.d.ts +34 -0
  39. package/srv/blockchain/crawler/input-asset-copies.js +171 -0
  40. package/srv/blockchain/crawler/metadata-position-backfill.d.ts +16 -0
  41. package/srv/blockchain/crawler/metadata-position-backfill.js +55 -0
  42. package/srv/blockchain/crawler/output-datum-backfill.d.ts +39 -0
  43. package/srv/blockchain/crawler/output-datum-backfill.js +110 -0
  44. package/srv/blockchain/crawler/transaction-backfill.d.ts +2 -0
  45. package/srv/blockchain/crawler/transaction-backfill.js +12 -8
  46. package/srv/blockchain/pool-metadata.d.ts +15 -0
  47. package/srv/blockchain/pool-metadata.js +132 -0
  48. package/srv/blockchain/signing/cose-verifier.d.ts +3 -1
  49. package/srv/blockchain/signing/cose-verifier.js +144 -56
  50. package/srv/blockchain/signing/hsm-signer.js +2 -1
  51. package/srv/blockchain/signing/submission-finalizer.d.ts +15 -4
  52. package/srv/blockchain/signing/submission-finalizer.js +201 -69
  53. package/srv/blockchain/stored-chain.js +1 -1
  54. package/srv/blockchain/transaction-building/buildooor-tx.d.ts +1 -3
  55. package/srv/blockchain/transaction-building/buildooor-tx.js +34 -54
  56. package/srv/blockchain/transaction-presence.d.ts +5 -0
  57. package/srv/blockchain/transaction-presence.js +29 -0
  58. package/srv/blockchain/transaction-rows.js +1 -1
  59. package/srv/blockchain/wallet-worker/build-request.d.ts +4 -1
  60. package/srv/blockchain/wallet-worker/build-request.js +25 -0
  61. package/srv/blockchain/wallet-worker/confirmation-tracker.js +1 -1
  62. package/srv/blockchain/wallet-worker/job-store.d.ts +17 -7
  63. package/srv/blockchain/wallet-worker/job-store.js +0 -0
  64. package/srv/blockchain/wallet-worker/signers.d.ts +2 -0
  65. package/srv/blockchain/wallet-worker/wallet-worker.d.ts +2 -0
  66. package/srv/blockchain/wallet-worker/wallet-worker.js +42 -32
  67. package/srv/cardano-agent-service.cds +11 -12
  68. package/srv/cardano-agent-service.js +2 -0
  69. package/srv/cardano-backend-service.cds +34 -1
  70. package/srv/cardano-backend-service.js +20 -17
  71. package/srv/cardano-indexer-service.cds +153 -12
  72. package/srv/cardano-indexer-service.js +175 -29
  73. package/srv/cardano-service.cds +67 -3
  74. package/srv/cardano-service.js +132 -67
  75. package/srv/cardano-sign-service.cds +30 -20
  76. package/srv/cardano-sign-service.js +13 -10
  77. package/srv/cardano-tx-service.cds +15 -1
  78. package/srv/cardano-tx-service.js +4 -1
  79. package/srv/cardano-worker-service.cds +16 -7
  80. package/srv/cardano-worker-service.js +31 -22
  81. package/srv/cbor/parse.js +11 -34
  82. package/srv/config.d.ts +113 -0
  83. package/srv/config.js +409 -0
  84. package/srv/server.d.ts +9 -14
  85. package/srv/server.js +32 -316
  86. package/srv/utils/agent-access.d.ts +9 -0
  87. package/srv/utils/agent-access.js +67 -0
  88. package/srv/utils/agent-grants-config.d.ts +0 -17
  89. package/srv/utils/agent-grants-config.js +6 -81
  90. package/srv/utils/agent-grants.d.ts +6 -19
  91. package/srv/utils/agent-grants.js +69 -130
  92. package/srv/utils/const.d.ts +4 -0
  93. package/srv/utils/const.js +5 -1
  94. package/srv/utils/db-indexes.js +11 -3
  95. package/srv/utils/error-codes.d.ts +4 -0
  96. package/srv/utils/error-codes.js +4 -0
  97. package/srv/utils/errors.d.ts +6 -0
  98. package/srv/utils/errors.js +23 -1
  99. package/srv/utils/liveness.js +2 -5
  100. package/srv/utils/mappers.d.ts +5 -7
  101. package/srv/utils/mappers.js +22 -9
  102. package/srv/utils/pg-order-nulls.js +4 -3
  103. package/srv/utils/readiness.d.ts +12 -0
  104. package/srv/utils/readiness.js +29 -0
  105. package/srv/utils/result-numbers.d.ts +15 -0
  106. package/srv/utils/result-numbers.js +61 -0
  107. package/srv/utils/tx-request-parsers.d.ts +1 -1
  108. package/srv/utils/tx-request-parsers.js +3 -3
  109. package/srv/utils/tx-utils.d.ts +3 -0
  110. package/srv/utils/tx-utils.js +17 -3
  111. package/srv/utils/types.d.ts +16 -3
  112. package/scripts/migrate-txseq.mjs +0 -138
  113. package/srv/blockchain/transaction-building/buildooor-fee-patch.d.ts +0 -13
  114. package/srv/blockchain/transaction-building/buildooor-fee-patch.js +0 -71
  115. package/srv/blockchain/transaction-building/caller-datums.d.ts +0 -15
  116. package/srv/blockchain/transaction-building/caller-datums.js +0 -133
  117. package/srv/cbor/redeemer-tag-patch.d.ts +0 -3
  118. package/srv/cbor/redeemer-tag-patch.js +0 -61
  119. package/srv/utils/legacy-service-paths.d.ts +0 -11
  120. package/srv/utils/legacy-service-paths.js +0 -58
@@ -3,136 +3,233 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.RESUBMIT_WINDOW_MS = void 0;
6
7
  exports.submitAndFinalize = submitAndFinalize;
7
8
  exports.submitRecorded = submitRecorded;
8
9
  exports.scheduleDeferredSubmit = scheduleDeferredSubmit;
9
10
  exports.redriveInterruptedSubmissions = redriveInterruptedSubmissions;
11
+ exports.startSubmissionReconciler = startSubmissionReconciler;
12
+ exports.stopSubmissionReconciler = stopSubmissionReconciler;
10
13
  const cds_1 = __importDefault(require("@sap/cds"));
11
14
  const errors_1 = require("../../utils/errors");
12
15
  const tx_utils_1 = require("../../utils/tx-utils");
13
16
  const tx_build_helper_1 = require("../../utils/tx-build-helper");
14
17
  const external_signer_1 = require("./external-signer");
18
+ const transaction_presence_1 = require("../transaction-presence");
15
19
  const CardanoTransactionService_1 = require("#cds-models/CardanoTransactionService");
16
20
  const { SELECT, UPDATE } = cds_1.default.ql;
17
21
  const logger = cds_1.default.log('SubmissionFinalizer');
22
+ const SIGNING_REQUESTS = 'odatano.cardano.SigningRequests';
23
+ /** An open submit is sent again for this long. After it only the chain is read. */
24
+ exports.RESUBMIT_WINDOW_MS = 10 * 60_000;
25
+ const RECONCILE_INTERVAL_MS = 60_000;
26
+ // Record ids this process is sending right now. The reconciler leaves them alone.
27
+ const inFlight = new Set();
28
+ // Signing requests whose stored transaction no longer verifies. Reported once, then skipped.
29
+ const unverifiable = new Set();
18
30
  // Lazy require avoids the srv/server.ts <-> this-module import cycle; the app-context
19
31
  // getters are only needed at runtime.
20
32
  function server() {
21
33
  return require('../../server');
22
34
  }
35
+ function liveDeps() {
36
+ return { indexer: server().getCardanoIndexer(), client: server().getCardanoClient() };
37
+ }
38
+ function messageOf(err) {
39
+ return err instanceof Error ? err.message : String(err);
40
+ }
41
+ // Sends the transaction and says what the attempt proves. With send = false only the chain is read,
42
+ // unless no backend can look transactions up: then the node's answer is the only evidence.
43
+ // `error` is the failed submit, also when the transaction turned out to be known.
44
+ async function attemptSubmit(signedTxCbor, txHash, send, indexer, client) {
45
+ const sent = send || !client.supports('getTransaction');
46
+ let error = new Error(`Transaction ${txHash} is not on chain ${exports.RESUBMIT_WINDOW_MS / 60_000} minutes after its submit`);
47
+ if (sent) {
48
+ try {
49
+ await client.submitTransaction(signedTxCbor);
50
+ return { outcome: 'accepted' };
51
+ }
52
+ catch (submitErr) {
53
+ if (submitErr instanceof errors_1.TransactionAlreadySubmittedError)
54
+ return { outcome: 'accepted', error: submitErr };
55
+ error = submitErr;
56
+ }
57
+ }
58
+ // A refusal may mean the transaction is already on chain and its inputs are spent.
59
+ try {
60
+ if (await (0, transaction_presence_1.isTransactionOnChain)(indexer, client, txHash))
61
+ return { outcome: 'accepted', error };
62
+ }
63
+ catch (lookupErr) {
64
+ logger.warn({ txHash, error: messageOf(lookupErr) }, 'Chain lookup after a failed submit was inconclusive');
65
+ return { outcome: 'unknown', error };
66
+ }
67
+ return { outcome: !sent || (0, errors_1.isSubmitRejection)(error) ? 'rejected' : 'unknown', error };
68
+ }
23
69
  // Outcomes are written in detached transactions, so no DB lock is held across the network call.
24
- // A failure is marked 'failed' and rethrown. A crash before finalize leaves 'submitting'.
25
- async function submitAndFinalize(SigningRequests, params, afterFinalize) {
26
- // Persist the submission + 'submitted' status in its own committed transaction.
70
+ // A refused transaction is marked 'failed' and the error rethrown. Without a verdict the request
71
+ // stays 'submitting' for the reconciler and the call throws SubmitOutcomeUnknownError.
72
+ async function submitAndFinalize(SigningRequests, params, afterFinalize, send = true, { indexer, client } = liveDeps()) {
27
73
  const finalizeSubmitted = () => (0, tx_utils_1.detachedTx)('finalize transaction submission', async (db) => {
28
- const submission = await server().getCardanoIndexer().indexVerifiedTransactionSubmission(db, params);
74
+ // Only the caller that moves the request to 'submitted' writes the records.
75
+ const won = await db.run(UPDATE.entity(SigningRequests).set({ status: 'submitted', errorMessage: null })
76
+ .where({ id: params.signingRequestId, status: { in: ['submitting', 'failed'] } }));
77
+ if (won === 0) {
78
+ const request = await db.run(SELECT.one.from(SigningRequests).columns('submission_id').where({ id: params.signingRequestId }));
79
+ return db.run(SELECT.one.from(CardanoTransactionService_1.TransactionSubmissions).where({ id: request?.submission_id ?? null }));
80
+ }
81
+ const submission = await indexer.indexVerifiedTransactionSubmission(db, params);
29
82
  if (afterFinalize)
30
83
  await afterFinalize(db);
31
84
  // Best effort; must never roll back the durable submission record.
32
85
  try {
33
- await server().getCardanoIndexer().invalidateUtxoCacheForTx(db, (0, tx_build_helper_1.extractTxCacheTargets)(params.fullSignedTxCbor));
86
+ await indexer.invalidateUtxoCacheForTx(db, (0, tx_build_helper_1.extractTxCacheTargets)(params.fullSignedTxCbor));
34
87
  }
35
88
  catch (invalidateErr) {
36
- logger.warn(`UTxO cache invalidation failed (submit unaffected): ${invalidateErr instanceof Error ? invalidateErr.message : String(invalidateErr)}`);
89
+ logger.warn(`UTxO cache invalidation failed (submit unaffected): ${messageOf(invalidateErr)}`);
37
90
  }
38
91
  return submission;
39
92
  });
93
+ inFlight.add(params.signingRequestId);
40
94
  try {
41
- await server().getCardanoClient().submitTransaction(params.fullSignedTxCbor);
42
- }
43
- catch (submitErr) {
44
- // Already-submitted means the tx reached the mempool (e.g. first backend accepted it, response
45
- // lost, fallback saw the duplicate): finalize as 'submitted' rather than recording a spurious 'failed'.
46
- if (submitErr instanceof errors_1.TransactionAlreadySubmittedError) {
47
- logger.info({ signingRequestId: params.signingRequestId, txHash: params.txHash }, 'Submit reported already-submitted; finalizing as submitted (tx already in mempool)');
48
- return finalizeSubmitted();
95
+ const { outcome, error } = await attemptSubmit(params.fullSignedTxCbor, params.txHash, send, indexer, client);
96
+ if (outcome === 'unknown') {
97
+ logger.warn({ signingRequestId: params.signingRequestId, txHash: params.txHash, error: messageOf(error) }, 'Submit got no verdict; the signing request stays submitting');
98
+ throw new errors_1.SubmitOutcomeUnknownError(params.txHash, error);
49
99
  }
50
- try {
51
- await (0, tx_utils_1.detachedTx)('mark signing request failed', (db) => db.run(UPDATE.entity(SigningRequests).set({ status: 'failed' }).where({ id: params.signingRequestId })));
100
+ if (outcome === 'rejected') {
101
+ try {
102
+ await (0, tx_utils_1.detachedTx)('mark signing request failed', (db) => db.run(UPDATE.entity(SigningRequests).set({ status: 'failed', errorMessage: messageOf(error) })
103
+ .where({ id: params.signingRequestId, status: 'submitting' })));
104
+ }
105
+ catch (markErr) {
106
+ logger.error({ err: markErr, signingRequestId: params.signingRequestId }, 'Could not durably mark signing request failed after submit error');
107
+ }
108
+ throw error;
52
109
  }
53
- catch (markErr) {
54
- logger.error({ err: markErr, signingRequestId: params.signingRequestId }, 'Could not durably mark signing request failed after submit error');
110
+ if (error) {
111
+ logger.info({ signingRequestId: params.signingRequestId, txHash: params.txHash }, 'Submit failed but the node or the chain has the transaction; finalizing as submitted');
55
112
  }
56
- throw submitErr;
113
+ return await finalizeSubmitted();
114
+ }
115
+ finally {
116
+ inFlight.delete(params.signingRequestId);
57
117
  }
58
- return finalizeSubmitted();
59
118
  }
60
- // 'pending' commits first and the network call runs outside any DB tx.
61
- // The final status commits on its own and survives a rethrown error.
62
- async function submitRecorded(params, indexer = server().getCardanoIndexer(), client = server().getCardanoClient()) {
63
- const record = await (0, tx_utils_1.detachedTx)('record transaction submission', (db) => indexer.persistTransactionSubmission(db, params));
119
+ // Commits what one attempt proves for a recorded submission. Returns only when the node accepted
120
+ // the transaction now. A transaction it already had ends as 409, like a resubmit.
121
+ async function settleRecorded(row, send, indexer, client) {
122
+ inFlight.add(row.id);
64
123
  try {
65
- await client.submitTransaction(params.signedTxCbor);
66
- logger.info({ txHash: params.txHash }, 'Transaction submitted to blockchain');
67
- }
68
- catch (submitErr) {
69
- const alreadySubmitted = submitErr instanceof errors_1.TransactionAlreadySubmittedError;
70
- const errMsg = submitErr instanceof Error ? submitErr.message : String(submitErr);
124
+ const { outcome, error } = await attemptSubmit(row.signedTxCbor, row.txHash, send, indexer, client);
125
+ if (outcome === 'accepted' && error === undefined) {
126
+ logger.info({ txHash: row.txHash }, 'Transaction submitted to blockchain');
127
+ await (0, tx_utils_1.detachedTx)('record submission outcome', async (db) => {
128
+ await indexer.updateSubmissionStatus(db, row.id, 'submitted');
129
+ // best-effort: a cache failure must not roll back the submitted status
130
+ try {
131
+ const senders = row.buildId
132
+ ? await db.run(SELECT.from(CardanoTransactionService_1.AddressTransactionBuilds).columns('address_address').where({ txBuild_id: row.buildId }))
133
+ : [];
134
+ await indexer.invalidateUtxoCacheForTx(db, (0, tx_build_helper_1.extractTxCacheTargets)(row.signedTxCbor), senders.map(r => r.address_address).filter((a) => !!a));
135
+ }
136
+ catch (invalidateErr) {
137
+ logger.warn(`UTxO cache invalidation failed (submit unaffected): ${messageOf(invalidateErr)}`);
138
+ }
139
+ });
140
+ return;
141
+ }
142
+ const errMsg = messageOf(error);
71
143
  try {
72
- // A resubmit keeps one row per transaction: its own row goes when an earlier one exists.
73
144
  await (0, tx_utils_1.detachedTx)('record submission outcome', async (db) => {
74
- if (!alreadySubmitted)
75
- return indexer.updateSubmissionStatus(db, record.id, 'failed', errMsg);
76
- if (await indexer.dropDuplicateSubmission(db, record.id, params.txHash))
145
+ // the row stays pending with the last error; a refusal ends only a row that is still pending
146
+ if (outcome === 'unknown')
147
+ return indexer.updateSubmissionStatus(db, row.id, 'pending', errMsg);
148
+ if (outcome === 'rejected')
149
+ return indexer.updateSubmissionStatus(db, row.id, 'failed', errMsg, 'pending');
150
+ // A resubmit keeps one row per transaction: its own row goes when an earlier one exists.
151
+ if (await indexer.dropDuplicateSubmission(db, row.id, row.txHash))
77
152
  return;
78
- return indexer.updateSubmissionStatus(db, record.id, 'submitted');
153
+ return indexer.updateSubmissionStatus(db, row.id, 'submitted');
79
154
  });
80
155
  }
81
156
  catch (markErr) {
82
- logger.error({ err: markErr, submissionId: record.id }, 'Could not record the submission outcome after a submit error');
157
+ logger.error({ err: markErr, submissionId: row.id }, 'Could not record the submission outcome after a submit error');
83
158
  }
84
- if (!alreadySubmitted)
85
- logger.error({ txHash: params.txHash, error: errMsg }, 'Transaction submission failed');
86
- throw submitErr;
87
- }
88
- await (0, tx_utils_1.detachedTx)('record submission outcome', async (db) => {
89
- await indexer.updateSubmissionStatus(db, record.id, 'submitted');
90
- // best-effort: a cache failure must not roll back the submitted status
91
- try {
92
- const senders = params.buildId
93
- ? await db.run(SELECT.from(CardanoTransactionService_1.AddressTransactionBuilds).columns('address_address').where({ txBuild_id: params.buildId }))
94
- : [];
95
- await indexer.invalidateUtxoCacheForTx(db, (0, tx_build_helper_1.extractTxCacheTargets)(params.signedTxCbor), senders.map(r => r.address_address).filter((a) => !!a));
159
+ if (outcome === 'unknown') {
160
+ logger.warn({ txHash: row.txHash, error: errMsg }, 'Submit got no verdict; the submission stays pending');
161
+ throw new errors_1.SubmitOutcomeUnknownError(row.txHash, error);
96
162
  }
97
- catch (invalidateErr) {
98
- logger.warn(`UTxO cache invalidation failed (submit unaffected): ${invalidateErr instanceof Error ? invalidateErr.message : String(invalidateErr)}`);
163
+ if (outcome === 'rejected') {
164
+ logger.error({ txHash: row.txHash, error: errMsg }, 'Transaction submission failed');
165
+ throw error;
99
166
  }
100
- });
167
+ throw error instanceof errors_1.TransactionAlreadySubmittedError ? error : new errors_1.TransactionAlreadySubmittedError(row.txHash, error);
168
+ }
169
+ finally {
170
+ inFlight.delete(row.id);
171
+ }
172
+ }
173
+ // 'pending' commits first and the network call runs outside any DB tx.
174
+ // The final status commits on its own and survives a rethrown error.
175
+ async function submitRecorded(params, indexer = server().getCardanoIndexer(), client = server().getCardanoClient()) {
176
+ const record = await (0, tx_utils_1.detachedTx)('record transaction submission', (db) => indexer.persistTransactionSubmission(db, params));
177
+ await settleRecorded({ id: record.id, ...params }, true, indexer, client);
101
178
  return { ...record, status: 'submitted' };
102
179
  }
103
180
  // Submits only after the caller's transaction has committed and released its connection.
104
181
  // If the caller rolls back, 'succeeded' never fires and nothing was claimed.
105
182
  function scheduleDeferredSubmit(req, SigningRequests, params) {
106
183
  req.on('succeeded', () => {
184
+ // from the commit on the row is visible to the reconciler
185
+ inFlight.add(params.signingRequestId);
107
186
  setImmediate(() => {
108
187
  (0, tx_utils_1.runWithoutAmbientTx)(() => submitAndFinalize(SigningRequests, params))
109
188
  .then(() => {
110
189
  logger.info({ signingRequestId: params.signingRequestId, txHash: params.txHash }, 'Deferred submit finalized');
111
190
  })
112
191
  .catch((err) => {
113
- // submitAndFinalize already durably marked the request 'failed'.
192
+ // submitAndFinalize already recorded the outcome and logged an open one.
193
+ if (err instanceof errors_1.SubmitOutcomeUnknownError)
194
+ return;
114
195
  logger.error({ err, signingRequestId: params.signingRequestId }, 'Deferred submit failed (signing request marked failed)');
115
196
  });
116
197
  });
117
198
  });
118
199
  }
119
- // Boot recovery for rows stuck at 'submitting' that have signed CBOR. Idempotent, since a tx
120
- // the node already holds finalizes as 'submitted'. Returns the number of rows attempted.
121
- async function redriveInterruptedSubmissions() {
122
- const SigningRequests = 'odatano.cardano.SigningRequests';
123
- const rows = await (0, tx_utils_1.detachedTx)('load interrupted deferred submissions', (db) => db.run(SELECT.from(SigningRequests)
200
+ function olderThanWindow(sinceMs) {
201
+ return Number.isFinite(sinceMs) && Date.now() - sinceMs > exports.RESUBMIT_WINDOW_MS;
202
+ }
203
+ // Resolves signing requests left at 'submitting' and submissions left at 'pending': after a crash
204
+ // or a submit without a verdict. Runs at boot and on a timer. Returns the number of records tried.
205
+ async function redriveInterruptedSubmissions(deps = liveDeps()) {
206
+ const requests = (await (0, tx_utils_1.detachedTx)('load open signing requests', (db) => db.run(SELECT.from(SIGNING_REQUESTS)
207
+ .columns('id', 'build_id', 'txBodyHash', 'signedTxCbor', 'signerType', 'signerInfo', 'signedAt', 'createdAt')
124
208
  .where({ status: 'submitting' })
125
- .and('signedTxCbor is not null')));
126
- if (!rows.length)
209
+ .and('signedTxCbor is not null')))).filter((row) => !inFlight.has(row.id) && !unverifiable.has(row.id));
210
+ const submissions = (await (0, tx_utils_1.detachedTx)('load open submissions', (db) => db.run(SELECT.from(CardanoTransactionService_1.TransactionSubmissions)
211
+ .columns('id', 'build_id', 'txHash', 'signedTxCbor', 'submittedAt')
212
+ .where({ status: 'pending' }))))
213
+ .filter((row) => !inFlight.has(row.id));
214
+ if (!requests.length && !submissions.length)
127
215
  return 0;
128
- logger.info(`Re-driving ${rows.length} interrupted deferred submission(s)`);
216
+ logger.info(`Resolving ${requests.length} open signing request(s) and ${submissions.length} open submission(s)`);
129
217
  let attempted = 0;
130
- for (const row of rows) {
218
+ for (const row of requests) {
219
+ let verificationResult;
131
220
  try {
132
221
  // Re-verify from the persisted CBOR to recompute the witness metadata the finalize step persists.
133
- const verificationResult = (0, external_signer_1.getExternalSignerModule)().verifyOrThrow(row.signedTxCbor, row.txBodyHash);
134
- attempted++;
135
- await submitAndFinalize(SigningRequests, {
222
+ verificationResult = (0, external_signer_1.getExternalSignerModule)().verifyOrThrow(row.signedTxCbor, row.txBodyHash);
223
+ }
224
+ catch (err) {
225
+ unverifiable.add(row.id);
226
+ logger.error({ err, signingRequestId: row.id }, 'Stored signed transaction no longer verifies; the request stays submitting for inspection');
227
+ continue;
228
+ }
229
+ attempted++;
230
+ const send = !olderThanWindow(Date.parse(String(row.signedAt ?? row.createdAt ?? '')));
231
+ try {
232
+ await submitAndFinalize(SIGNING_REQUESTS, {
136
233
  signingRequestId: row.id,
137
234
  buildId: row.build_id ?? '',
138
235
  fullSignedTxCbor: row.signedTxCbor,
@@ -140,15 +237,50 @@ async function redriveInterruptedSubmissions() {
140
237
  verificationResult,
141
238
  signerType: row.signerType ?? undefined,
142
239
  signerInfo: row.signerInfo ?? undefined,
143
- });
144
- logger.info({ signingRequestId: row.id, txHash: row.txBodyHash }, 'Interrupted submission re-driven');
240
+ }, undefined, send, deps);
241
+ logger.info({ signingRequestId: row.id, txHash: row.txBodyHash }, 'Open signing request resolved as submitted');
242
+ }
243
+ catch (err) {
244
+ if (err instanceof errors_1.SubmitOutcomeUnknownError)
245
+ continue;
246
+ logger.error({ err, signingRequestId: row.id }, 'Open signing request resolved as failed');
247
+ }
248
+ }
249
+ for (const row of submissions) {
250
+ attempted++;
251
+ const send = !olderThanWindow(Number(row.submittedAt) * 1000);
252
+ try {
253
+ await settleRecorded({ id: row.id, signedTxCbor: row.signedTxCbor, txHash: row.txHash, buildId: row.build_id ?? null }, send, deps.indexer, deps.client);
254
+ logger.info({ submissionId: row.id, txHash: row.txHash }, 'Open submission resolved as submitted');
145
255
  }
146
256
  catch (err) {
147
- // Submit errors already marked the row 'failed'; verification errors leave it at
148
- // 'submitting' for manual inspection.
149
- logger.error({ err, signingRequestId: row.id }, 'Re-drive of interrupted submission failed');
257
+ if (err instanceof errors_1.SubmitOutcomeUnknownError)
258
+ continue;
259
+ const level = err instanceof errors_1.TransactionAlreadySubmittedError ? 'info' : 'error';
260
+ logger[level]({ submissionId: row.id, txHash: row.txHash, error: messageOf(err) }, 'Open submission resolved');
150
261
  }
151
262
  }
152
263
  return attempted;
153
264
  }
265
+ let reconcileTimer = null;
266
+ let reconcileRunning = false;
267
+ /** Starts the periodic pass over open signing requests and submissions. Idempotent. */
268
+ function startSubmissionReconciler() {
269
+ if (reconcileTimer)
270
+ return;
271
+ reconcileTimer = setInterval(() => {
272
+ if (reconcileRunning)
273
+ return;
274
+ reconcileRunning = true;
275
+ (0, tx_utils_1.runWithoutAmbientTx)(() => redriveInterruptedSubmissions())
276
+ .catch((err) => logger.error({ err }, 'Submission reconcile pass failed'))
277
+ .finally(() => { reconcileRunning = false; });
278
+ }, RECONCILE_INTERVAL_MS);
279
+ reconcileTimer.unref();
280
+ }
281
+ function stopSubmissionReconciler() {
282
+ if (reconcileTimer)
283
+ clearInterval(reconcileTimer);
284
+ reconcileTimer = null;
285
+ }
154
286
  //# sourceMappingURL=submission-finalizer.js.map
@@ -197,7 +197,7 @@ async function assembleTransactions(db, rows) {
197
197
  slot: num(t.slot),
198
198
  index: num(t.txIndex),
199
199
  fee: str(t.fee ?? '0'),
200
- deposit: str(t.deposit ?? '0'),
200
+ deposit: t.deposit == null ? null : str(t.deposit),
201
201
  size: numOrNull(t.size),
202
202
  blockTime: num(t.blockTime),
203
203
  spendsCollaterals,
@@ -27,11 +27,9 @@ export declare class BuildooorTxBuilder implements CardanoTxBuilder {
27
27
  private _buildPlutusSpendTransaction;
28
28
  buildUnsignedPlutusTransaction(req: TxBuildPlutusRequest, ctx: TxBuildContext): Promise<TxBuildResult>;
29
29
  private _buildPlutusTransaction;
30
- /** Appends the outputs in order and returns the CBOR inline datums by output index. */
30
+ /** Appends the outputs in order. A CBOR inline datum keeps its bytes. */
31
31
  private _appendPlutusOutputs;
32
32
  private _minOutputLovelace;
33
- /** Build, then write the caller's datum bytes; when they are longer, a second build raises the fee. */
34
- private _buildWithCallerDatums;
35
33
  /** Extract CBOR, hash, fee, size, inputs and outputs from a built Buildooor Tx */
36
34
  private _extractTxDetails;
37
35
  /** Build the standard TxBuildResult object */
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.BuildooorTxBuilder = void 0;
7
7
  const buildooor_1 = require("@harmoniclabs/buildooor");
8
8
  const uint8array_utils_1 = require("@harmoniclabs/uint8array-utils");
9
+ const crypto_1 = require("@harmoniclabs/crypto");
9
10
  const tx_build_helper_1 = require("../../utils/tx-build-helper");
10
11
  const errors_1 = require("../../utils/errors");
11
12
  const plutus_placeholders_1 = require("../../utils/plutus-placeholders");
@@ -16,21 +17,26 @@ const cardano_ledger_ts_1 = require("@harmoniclabs/cardano-ledger-ts");
16
17
  const TxMetadata_1 = require("@harmoniclabs/cardano-ledger-ts/dist/tx/metadata/TxMetadata");
17
18
  const TxMetadatum_1 = require("@harmoniclabs/cardano-ledger-ts/dist/tx/metadata/TxMetadatum");
18
19
  const plutus_data_1 = require("@harmoniclabs/plutus-data");
19
- const caller_datums_1 = require("./caller-datums");
20
20
  const const_1 = require("../../utils/const");
21
- const buildooor_fee_patch_1 = require("./buildooor-fee-patch");
22
- const redeemer_tag_patch_1 = require("../../cbor/redeemer-tag-patch");
23
21
  const reference_script_1 = require("../../utils/reference-script");
24
22
  const logger = cds_1.default.log('BuildooorTxBuilder');
25
23
  /**
26
24
  * Records local script failures instead of aborting, so `_buildScriptTx` can let Ogmios decide.
27
25
  */
28
26
  function makeScriptBuildOpts(failures) {
27
+ // The machine's message comes with the result, which Buildooor reports before onScriptInvalid.
28
+ const machineErrors = new Map();
29
29
  return {
30
+ onScriptResult: (rdmr, result) => {
31
+ const msg = result?.msg;
32
+ if (typeof msg === 'string' && msg)
33
+ machineErrors.set(redeemerKey(rdmr.tag, rdmr.index), msg);
34
+ },
30
35
  onScriptInvalid: (rdmr, logs) => {
31
- failures.push({ tag: rdmr.tag, index: rdmr.index, logs: logs.slice() });
36
+ const error = machineErrors.get(redeemerKey(rdmr.tag, rdmr.index)) ?? null;
37
+ failures.push({ tag: rdmr.tag, index: rdmr.index, logs: logs.slice(), error });
32
38
  logger.warn(`Plutus script failed local evaluation (redeemer ${(0, cardano_ledger_ts_1.txRedeemerTagToString)(rdmr.tag)}:${rdmr.index}); ` +
33
- `deferring to Ogmios evaluation if available. Logs: [${logs.join(', ')}]`);
39
+ `deferring to Ogmios evaluation if available. Machine error: ${error ?? 'none reported'}. Logs: [${logs.join(', ')}]`);
34
40
  }
35
41
  };
36
42
  }
@@ -111,13 +117,6 @@ function ledgerScript(script) {
111
117
  return new cardano_ledger_ts_1.Script(script.type, script.bytes);
112
118
  }
113
119
  const hasRefScript = (u) => Boolean(u.scriptRef || u.scriptRefCbor);
114
- // Hash32 inherits Hash.clone(), which returns a plain Hash; TxOut rejects that as datum when
115
- // Buildooor clones outputs, so a datum-hash output could never be built. Hash28 has its own clone.
116
- if (!Object.prototype.hasOwnProperty.call(cardano_ledger_ts_1.Hash32.prototype, 'clone')) {
117
- cardano_ledger_ts_1.Hash32.prototype.clone = function () { return new cardano_ledger_ts_1.Hash32(this.toString()); };
118
- }
119
- (0, buildooor_fee_patch_1.installReferenceScriptFeePatch)();
120
- (0, redeemer_tag_patch_1.installRedeemerTagPatch)();
121
120
  /** CardanoTxBuilder implementation on top of Buildooor. */
122
121
  class BuildooorTxBuilder {
123
122
  name = 'BuildooorTxBuilder';
@@ -175,21 +174,22 @@ class BuildooorTxBuilder {
175
174
  if (req.outputDatum !== undefined && req.outputDatumCbor !== undefined) {
176
175
  throw new errors_1.TransactionValidationError('outputDatum and outputDatumCbor exclude each other; pass one');
177
176
  }
178
- const callerDatum = req.outputDatumCbor !== undefined ? Buffer.from(req.outputDatumCbor, 'hex') : undefined;
177
+ // a datum given as CBOR keeps its bytes
178
+ const datum = req.outputDatumCbor !== undefined ? (0, plutus_data_1.dataFromCbor)(req.outputDatumCbor) : undefined;
179
179
  const refScript = this._parseReferenceScript(req.referenceScript);
180
180
  const recipientOut = (lovelace) => {
181
181
  const value = this._buildLedgerValue(lovelace, req.assets);
182
- return callerDatum
183
- ? new cardano_ledger_ts_1.TxOut({ address: recipientAddress, value, datum: (0, plutus_data_1.dataFromCbor)(callerDatum), ...(refScript && { refScript }) })
182
+ return datum
183
+ ? new cardano_ledger_ts_1.TxOut({ address: recipientAddress, value, datum, ...(refScript && { refScript }) })
184
184
  : this._buildTxOut(recipientAddress, value, req.outputDatum, refScript);
185
185
  };
186
186
  let recipient = recipientOut(amount);
187
- const minLovelace = this._minOutputLovelace(recipient, callerDatum);
187
+ const minLovelace = this._minOutputLovelace(recipient);
188
188
  if (amount < minLovelace) {
189
189
  if (!req.ensureMinAda) {
190
190
  throw new errors_1.TransactionValidationError(`recipient output needs at least ${minLovelace.toString()} lovelace (has ${amount.toString()}); raise lovelaceAmount or set ensureMinAda`);
191
191
  }
192
- recipient = recipientOut(this._minOutputLovelace(recipient, callerDatum, true));
192
+ recipient = recipientOut(this._minOutputLovelace(recipient, true));
193
193
  }
194
194
  const outputValue = recipient.value;
195
195
  const outputs = [recipient];
@@ -205,8 +205,7 @@ class BuildooorTxBuilder {
205
205
  ? this._mapOdatanoMetadataToLedgerMetadata(req.metadataJson)
206
206
  : undefined;
207
207
  const validity = this._resolveValiditySlots(req, 'passthrough');
208
- const callerDatums = new Map(callerDatum ? [[0, callerDatum]] : []);
209
- const tx = await this._buildWithCallerDatums({ inputs, outputs, changeAddress, ...(metadata && { metadata }), ...validity }, callerDatums);
208
+ const tx = await this.txBuilder.build({ inputs, outputs, changeAddress, ...(metadata && { metadata }), ...validity });
210
209
  logger.debug(`Built unsigned transaction successfully.`);
211
210
  return this._buildResult(req, ctx, this._extractTxDetails(tx), { forcedInputsUsed: forcedInputs.length });
212
211
  }
@@ -597,14 +596,12 @@ class BuildooorTxBuilder {
597
596
  const sortedInputs = this._computeSortedInputs(req.scriptInputs, forced, this._extractFundingRefs(selectedFundingInputs));
598
597
  const sortedWithdrawals = this._ledgerWithdrawalOrder(withdrawalEntries);
599
598
  const resolveCtx = { sortedInputs, sortedReferenceInputs, sortedWithdrawals };
600
- const witnessDatums = [];
601
599
  const scriptInputs = scriptEntries.map(({ si, utxo, script, refLedgerUtxo }, i) => {
602
600
  const redeemer = si.redeemerCbor ? (0, plutus_data_1.dataFromCbor)(si.redeemerCbor) : (0, tx_build_helper_1.jsonToPlutusData)((0, plutus_placeholders_1.resolveIndexPlaceholders)(si.redeemer, resolveCtx));
603
601
  let datum = "inline";
604
602
  if (si.datumCbor) {
605
603
  const bytes = Buffer.from(si.datumCbor, 'hex');
606
604
  this._checkWitnessDatum(utxo, bytes, `scriptInputs[${i}].datumCbor`, '');
607
- witnessDatums.push(bytes);
608
605
  datum = (0, plutus_data_1.dataFromCbor)(bytes);
609
606
  }
610
607
  else if (si.datum !== undefined) {
@@ -617,7 +614,7 @@ class BuildooorTxBuilder {
617
614
  : { utxo: ledgerUtxo, referenceScript: { refUtxo: refLedgerUtxo, datum, redeemer } };
618
615
  });
619
616
  const outputs = [];
620
- const callerDatums = this._appendPlutusOutputs(outputs, req.outputs.map(o => ({
617
+ this._appendPlutusOutputs(outputs, req.outputs.map(o => ({
621
618
  ...o,
622
619
  inlineDatum: o.inlineDatum !== undefined ? (0, plutus_placeholders_1.resolveIndexPlaceholders)(o.inlineDatum, resolveCtx) : undefined,
623
620
  })));
@@ -651,7 +648,7 @@ class BuildooorTxBuilder {
651
648
  ...(withdrawals.length > 0 && { withdrawals }),
652
649
  ...(certificates.length > 0 && { certificates })
653
650
  };
654
- const tx = await this._buildScriptTx(buildParams, ctx.evaluateTransaction, callerDatums, witnessDatums);
651
+ const tx = await this._buildScriptTx(buildParams, ctx.evaluateTransaction);
655
652
  const details = this._extractTxDetails(tx);
656
653
  const maxTxSize = Number(this.txBuilder.protocolParamters.maxTxSize);
657
654
  if (details.sizeBytes > maxTxSize) {
@@ -679,46 +676,28 @@ class BuildooorTxBuilder {
679
676
  (0, tx_build_helper_1.mapBuilderError)(err, undefined, coinSelectionContext, requestedOutputs);
680
677
  }
681
678
  }
682
- /** Appends the outputs in order and returns the CBOR inline datums by output index. */
679
+ /** Appends the outputs in order. A CBOR inline datum keeps its bytes. */
683
680
  _appendPlutusOutputs(outputs, list) {
684
- const callerDatums = new Map();
685
681
  for (let i = 0; i < list.length; i++) {
686
682
  const o = list[i];
687
683
  const value = this._buildLedgerValue(BigInt(o.lovelaceAmount), o.assets);
688
684
  const refScript = this._parseReferenceScript(o.referenceScript);
689
- const callerDatum = o.inlineDatumCbor ? Buffer.from(o.inlineDatumCbor, 'hex') : undefined;
690
- const datum = o.datumHash ? new cardano_ledger_ts_1.Hash32(o.datumHash) : callerDatum ? (0, plutus_data_1.dataFromCbor)(callerDatum) : undefined;
685
+ const datum = o.datumHash ? new cardano_ledger_ts_1.Hash32(o.datumHash) : o.inlineDatumCbor ? (0, plutus_data_1.dataFromCbor)(o.inlineDatumCbor) : undefined;
691
686
  const txOut = datum
692
687
  ? new cardano_ledger_ts_1.TxOut({ address: cardano_ledger_ts_1.Address.fromString(o.address), value, datum, ...(refScript && { refScript }) })
693
688
  : this._buildTxOut(cardano_ledger_ts_1.Address.fromString(o.address), value, o.inlineDatum, refScript);
694
- const minLovelaces = this._minOutputLovelace(txOut, callerDatum);
689
+ const minLovelaces = this._minOutputLovelace(txOut);
695
690
  if (BigInt(o.lovelaceAmount) < minLovelaces) {
696
691
  throw new errors_1.TransactionValidationError(`outputs[${i}] needs at least ${minLovelaces.toString()} lovelace (has ${o.lovelaceAmount}); raise its lovelaceAmount`);
697
692
  }
698
- if (callerDatum)
699
- callerDatums.set(outputs.length, callerDatum);
700
693
  outputs.push(txOut);
701
694
  }
702
- return callerDatums;
703
695
  }
704
- // Min-ADA also counts caller datum bytes that are longer than Buildooor's encoding.
705
- // `forAnyAmount` sizes the coin field for the largest amount, so the result stays valid.
706
- _minOutputLovelace(txOut, callerDatum, forAnyAmount = false) {
707
- const base = forAnyAmount
696
+ // `forAnyAmount` sizes the coin field for the largest amount, so the result holds for any amount.
697
+ _minOutputLovelace(txOut, forAnyAmount = false) {
698
+ return forAnyAmount
708
699
  ? this.txBuilder.minimizeLovelaces(txOut).value.lovelaces
709
700
  : this.txBuilder.getMinimumOutputLovelaces(txOut);
710
- const growth = callerDatum ? Math.max(0, (0, caller_datums_1.callerDatumGrowth)(callerDatum)) : 0;
711
- return base + BigInt(growth) * BigInt(this.txBuilder.protocolParamters.utxoCostPerByte);
712
- }
713
- /** Build, then write the caller's datum bytes; when they are longer, a second build raises the fee. */
714
- async _buildWithCallerDatums(args, datums) {
715
- const tx = await this.txBuilder.build(args);
716
- const growth = (0, caller_datums_1.callerDatumsGrowth)(datums);
717
- if (growth === 0)
718
- return (0, caller_datums_1.writeCallerDatums)(tx, datums);
719
- // Fee floor: the extra bytes plus a pad for change-size wobble
720
- const fee = BigInt(tx.body.fee.toString()) + BigInt(growth + 10) * this._txFeePerByte();
721
- return (0, caller_datums_1.writeCallerDatums)(await this.txBuilder.build({ ...args, fee }), datums);
722
701
  }
723
702
  //---------------------------------------------------------------------------
724
703
  // Shared Helper Methods
@@ -775,7 +754,7 @@ class BuildooorTxBuilder {
775
754
  }
776
755
  // Buildooor stamps local CEK budgets and ignores caller units. So build once, evaluate via Ogmios,
777
756
  // rebuild with a fee floor for the target units, then stamp them and recompute scriptDataHash.
778
- async _buildScriptTx(buildParams, evaluator, callerDatums = new Map(), witnessDatums = []) {
757
+ async _buildScriptTx(buildParams, evaluator) {
779
758
  const pass1Failures = [];
780
759
  const tx1 = await this.txBuilder.build(buildParams, makeScriptBuildOpts(pass1Failures));
781
760
  if (!tx1) {
@@ -784,7 +763,7 @@ class BuildooorTxBuilder {
784
763
  const rdmrs1 = tx1.witnesses.redeemers ?? [];
785
764
  if (rdmrs1.length === 0) {
786
765
  // Defensive: callers always attach a script; nothing to evaluate or stamp.
787
- return callerDatums.size === 0 ? tx1 : this._buildWithCallerDatums(buildParams, callerDatums);
766
+ return tx1;
788
767
  }
789
768
  // The first-pass CBOR equals a dedicated evaluation build (passed ExUnits are ignored anyway).
790
769
  const evaluatedUnits = evaluator
@@ -799,14 +778,12 @@ class BuildooorTxBuilder {
799
778
  const feeFloor = BigInt(tx1.body.fee.toString())
800
779
  + this._exUnitsPriceDelta(rdmrs1, targets1)
801
780
  + this._exUnitsSizeDelta(rdmrs1, targets1) * this._txFeePerByte()
802
- + BigInt((0, caller_datums_1.callerDatumsGrowth)(callerDatums) + (0, caller_datums_1.witnessDatumsGrowth)(witnessDatums)) * this._txFeePerByte()
803
781
  + 10n * this._txFeePerByte();
804
782
  const pass2Failures = [];
805
783
  const tx2 = await this.txBuilder.build({ ...buildParams, fee: feeFloor }, makeScriptBuildOpts(pass2Failures));
806
784
  const rdmrs2 = tx2.witnesses.redeemers ?? [];
807
785
  const targets2 = this._resolveTargetExUnits(rdmrs2, evaluatedUnits, pass2Failures);
808
- const tx = (0, caller_datums_1.writeCallerDatums)(this._stampExecUnits(tx2, targets2), callerDatums);
809
- return (0, caller_datums_1.writeWitnessDatums)(tx, witnessDatums, this._languageViews(tx));
786
+ return this._stampExecUnits(tx2, targets2);
810
787
  }
811
788
  // Cushioned Ogmios budgets keyed `tag:index`. Undefined when the evaluation is unusable.
812
789
  // Validation errors are rethrown.
@@ -871,7 +848,7 @@ class BuildooorTxBuilder {
871
848
  `and no Ogmios evaluation is available to certify its execution units. Refusing to return a ` +
872
849
  `transaction with unreliable execution units. Signing and submitting it would forfeit the collateral. ` +
873
850
  `Configure an Ogmios backend for authoritative script evaluation, or fix the script/datum/redeemer. ` +
874
- `Script logs: [${failure.logs.join(', ')}]`);
851
+ `Machine error: ${failure.error ?? 'none reported'}. Script logs: [${failure.logs.join(', ')}]`);
875
852
  }
876
853
  return evaluated;
877
854
  }
@@ -944,7 +921,7 @@ class BuildooorTxBuilder {
944
921
  _checkWitnessDatum(utxo, datum, field, hint) {
945
922
  if (!utxo.datumHash || utxo.inlineDatum)
946
923
  return;
947
- const hash = (0, caller_datums_1.datumHashOf)(datum);
924
+ const hash = (0, uint8array_utils_1.toHex)((0, crypto_1.blake2b_256)(datum));
948
925
  if (hash !== utxo.datumHash.toLowerCase()) {
949
926
  throw new errors_1.TransactionValidationError(`${field} hashes to ${hash}, but ${utxo.txHash}#${utxo.outputIndex} is locked with datum hash ${utxo.datumHash}${hint}`);
950
927
  }
@@ -1384,8 +1361,11 @@ class BuildooorTxBuilder {
1384
1361
  _mapLedgerParametersToBuildooorParams(protocolParameters) {
1385
1362
  const pp = protocolParameters;
1386
1363
  const d = cardano_ledger_ts_1.defaultProtocolParameters;
1364
+ const major = toUInt(pp.protocolMajorVer);
1387
1365
  const mapped = {
1388
1366
  ...d,
1367
+ // Buildooor prices builtins by protocol version. Without one it takes the latest it knows.
1368
+ protocolVersion: major ? { major, minor: toUInt(pp.protocolMinorVer) ?? 0 } : undefined,
1389
1369
  txFeePerByte: toUInt(pp.minFeeA) ?? d.txFeePerByte,
1390
1370
  txFeeFixed: toUInt(pp.minFeeB) ?? d.txFeeFixed,
1391
1371
  utxoCostPerByte: toUInt(pp.coinsPerUtxoSize) ?? d.utxoCostPerByte,
@@ -0,0 +1,5 @@
1
+ import type { CardanoIndexer } from './cardano-indexer';
2
+ import type { CardanoClient } from './cardano-client';
3
+ export type TransactionLookup = Pick<CardanoClient, 'getTransaction' | 'supports'>;
4
+ export declare function isTransactionOnChain(indexer: Pick<CardanoIndexer, 'findIndexedTransaction'>, client: TransactionLookup, txHash: string): Promise<boolean | null>;
5
+ //# sourceMappingURL=transaction-presence.d.ts.map