@odatano/core 2.0.0-rc.44 → 2.0.0-rc.46

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 (168) hide show
  1. package/@cds-models/CardanoAgentService/index.d.ts +0 -46
  2. package/@cds-models/CardanoBackendService/index.d.ts +0 -10
  3. package/@cds-models/CardanoIndexerService/index.d.ts +5 -20
  4. package/@cds-models/CardanoODataService/index.d.ts +18 -47
  5. package/@cds-models/CardanoSignService/index.d.ts +3 -18
  6. package/@cds-models/CardanoTransactionService/index.d.ts +9 -31
  7. package/@cds-models/CardanoWorkerService/index.d.ts +3 -19
  8. package/@cds-models/index.d.ts +17 -0
  9. package/@cds-models/index.js +2 -0
  10. package/@cds-models/odatano/cardano/index.d.ts +0 -34
  11. package/README.md +20 -20
  12. package/db/schema.cds +25 -44
  13. package/db/types.cds +22 -5
  14. package/package.json +3 -1
  15. package/scripts/migrate-slot-leader.mjs +3 -11
  16. package/scripts/migrate-txseq.mjs +3 -12
  17. package/src/index.d.ts +0 -4
  18. package/src/index.js +3 -5
  19. package/src/plugin.js +4 -8
  20. package/srv/blockchain/asset-decimals.d.ts +0 -9
  21. package/srv/blockchain/asset-decimals.js +21 -16
  22. package/srv/blockchain/backends/blockfrost-backend.d.ts +2 -10
  23. package/srv/blockchain/backends/blockfrost-backend.js +15 -21
  24. package/srv/blockchain/backends/cardano-backend.d.ts +12 -71
  25. package/srv/blockchain/backends/koios-backend.d.ts +14 -147
  26. package/srv/blockchain/backends/koios-backend.js +43 -166
  27. package/srv/blockchain/backends/odatano-backend.d.ts +1 -11
  28. package/srv/blockchain/backends/odatano-backend.js +11 -12
  29. package/srv/blockchain/backends/ogmios-backend.d.ts +19 -160
  30. package/srv/blockchain/backends/ogmios-backend.js +96 -175
  31. package/srv/blockchain/backends/ogmios-frame-guard.d.ts +2 -18
  32. package/srv/blockchain/backends/ogmios-frame-guard.js +8 -20
  33. package/srv/blockchain/cardano-client.d.ts +12 -80
  34. package/srv/blockchain/cardano-client.js +36 -88
  35. package/srv/blockchain/cardano-indexer.d.ts +14 -192
  36. package/srv/blockchain/cardano-indexer.js +136 -222
  37. package/srv/blockchain/cardano-tx-builder.d.ts +1 -28
  38. package/srv/blockchain/cardano-tx-builder.js +17 -34
  39. package/srv/blockchain/circuit-breaker.d.ts +1 -13
  40. package/srv/blockchain/circuit-breaker.js +5 -15
  41. package/srv/blockchain/crawler/asset-decimals-backfill.d.ts +0 -5
  42. package/srv/blockchain/crawler/asset-decimals-backfill.js +2 -5
  43. package/srv/blockchain/crawler/certificate-backfill.d.ts +0 -17
  44. package/srv/blockchain/crawler/certificate-backfill.js +8 -22
  45. package/srv/blockchain/crawler/crawler.d.ts +16 -93
  46. package/srv/blockchain/crawler/crawler.js +85 -160
  47. package/srv/blockchain/crawler/credential-backfill.d.ts +0 -10
  48. package/srv/blockchain/crawler/credential-backfill.js +2 -4
  49. package/srv/blockchain/crawler/hooks.d.ts +1 -5
  50. package/srv/blockchain/crawler/index.d.ts +0 -12
  51. package/srv/blockchain/crawler/index.js +6 -20
  52. package/srv/blockchain/crawler/sync-state.d.ts +6 -44
  53. package/srv/blockchain/crawler/sync-state.js +18 -53
  54. package/srv/blockchain/crawler/transaction-backfill.d.ts +0 -11
  55. package/srv/blockchain/crawler/transaction-backfill.js +11 -30
  56. package/srv/blockchain/crawler/utxo-set-import.d.ts +1 -30
  57. package/srv/blockchain/crawler/utxo-set-import.js +27 -53
  58. package/srv/blockchain/ledger-state.d.ts +10 -54
  59. package/srv/blockchain/ledger-state.js +11 -27
  60. package/srv/blockchain/pending-spends.d.ts +0 -12
  61. package/srv/blockchain/pending-spends.js +4 -12
  62. package/srv/blockchain/request-coalescer.d.ts +2 -16
  63. package/srv/blockchain/request-coalescer.js +2 -16
  64. package/srv/blockchain/signing/cose-verifier.d.ts +0 -9
  65. package/srv/blockchain/signing/cose-verifier.js +4 -10
  66. package/srv/blockchain/signing/external-signer.d.ts +1 -4
  67. package/srv/blockchain/signing/external-signer.js +2 -8
  68. package/srv/blockchain/signing/hsm-signer.d.ts +6 -18
  69. package/srv/blockchain/signing/hsm-signer.js +16 -28
  70. package/srv/blockchain/signing/signature-verifier.d.ts +1 -8
  71. package/srv/blockchain/signing/signature-verifier.js +9 -19
  72. package/srv/blockchain/signing/submission-finalizer.d.ts +10 -16
  73. package/srv/blockchain/signing/submission-finalizer.js +53 -19
  74. package/srv/blockchain/stored-chain.d.ts +1 -14
  75. package/srv/blockchain/stored-chain.js +3 -8
  76. package/srv/blockchain/transaction-building/buildooor-fee-patch.d.ts +0 -4
  77. package/srv/blockchain/transaction-building/buildooor-fee-patch.js +4 -9
  78. package/srv/blockchain/transaction-building/buildooor-tx.d.ts +7 -150
  79. package/srv/blockchain/transaction-building/buildooor-tx.js +91 -196
  80. package/srv/blockchain/transaction-building/caller-datums.d.ts +0 -14
  81. package/srv/blockchain/transaction-building/caller-datums.js +3 -9
  82. package/srv/blockchain/transaction-building/cardano-tx.d.ts +1 -4
  83. package/srv/blockchain/wallet-worker/build-request.d.ts +0 -5
  84. package/srv/blockchain/wallet-worker/build-request.js +6 -9
  85. package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +5 -23
  86. package/srv/blockchain/wallet-worker/confirmation-tracker.js +16 -20
  87. package/srv/blockchain/wallet-worker/index.d.ts +1 -1
  88. package/srv/blockchain/wallet-worker/index.js +3 -5
  89. package/srv/blockchain/wallet-worker/job-store.d.ts +15 -65
  90. package/srv/blockchain/wallet-worker/job-store.js +0 -0
  91. package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +2 -10
  92. package/srv/blockchain/wallet-worker/lease-heartbeat.js +6 -12
  93. package/srv/blockchain/wallet-worker/signers.d.ts +3 -11
  94. package/srv/blockchain/wallet-worker/signers.js +3 -6
  95. package/srv/blockchain/wallet-worker/wallet-worker.d.ts +3 -21
  96. package/srv/blockchain/wallet-worker/wallet-worker.js +47 -54
  97. package/srv/cardano-agent-service.cds +123 -146
  98. package/srv/cardano-agent-service.js +2 -5
  99. package/srv/cardano-backend-service.cds +10 -17
  100. package/srv/cardano-backend-service.js +7 -12
  101. package/srv/cardano-indexer-service.cds +16 -37
  102. package/srv/cardano-indexer-service.d.ts +5 -1
  103. package/srv/cardano-indexer-service.js +44 -35
  104. package/srv/cardano-service.cds +56 -40
  105. package/srv/cardano-service.js +42 -69
  106. package/srv/cardano-sign-service.cds +14 -23
  107. package/srv/cardano-sign-service.js +18 -24
  108. package/srv/cardano-tx-service.cds +27 -29
  109. package/srv/cardano-tx-service.js +60 -122
  110. package/srv/cardano-worker-service.cds +109 -125
  111. package/srv/cardano-worker-service.js +21 -31
  112. package/srv/cbor/cip68.d.ts +0 -4
  113. package/srv/cbor/cip68.js +2 -4
  114. package/srv/cbor/parse.d.ts +3 -18
  115. package/srv/cbor/parse.js +2 -7
  116. package/srv/cbor/plutus-data-json.d.ts +0 -4
  117. package/srv/server.d.ts +5 -36
  118. package/srv/server.js +30 -51
  119. package/srv/utils/agent-grants-config.d.ts +0 -18
  120. package/srv/utils/agent-grants-config.js +6 -13
  121. package/srv/utils/agent-grants.d.ts +14 -68
  122. package/srv/utils/agent-grants.js +42 -60
  123. package/srv/utils/agent-token-auth.d.ts +0 -5
  124. package/srv/utils/agent-token-auth.js +2 -5
  125. package/srv/utils/backend-request-handler.d.ts +1 -1
  126. package/srv/utils/collections.d.ts +1 -4
  127. package/srv/utils/collections.js +1 -4
  128. package/srv/utils/const.d.ts +0 -18
  129. package/srv/utils/const.js +7 -18
  130. package/srv/utils/crypto.js +3 -5
  131. package/srv/utils/db-indexes.d.ts +2 -0
  132. package/srv/utils/db-indexes.js +22 -9
  133. package/srv/utils/db-sanitize.d.ts +1 -8
  134. package/srv/utils/db-sanitize.js +3 -8
  135. package/srv/utils/epoch-slots.d.ts +1 -8
  136. package/srv/utils/epoch-slots.js +3 -8
  137. package/srv/utils/error-codes.d.ts +0 -4
  138. package/srv/utils/error-codes.js +2 -4
  139. package/srv/utils/errors.d.ts +2 -22
  140. package/srv/utils/errors.js +13 -27
  141. package/srv/utils/liveness.d.ts +0 -4
  142. package/srv/utils/liveness.js +2 -4
  143. package/srv/utils/mappers.d.ts +0 -37
  144. package/srv/utils/mappers.js +19 -39
  145. package/srv/utils/network-context.js +2 -4
  146. package/srv/utils/paging.d.ts +31 -0
  147. package/srv/utils/paging.js +43 -0
  148. package/srv/utils/pg-inline-json.js +3 -7
  149. package/srv/utils/pg-order-nulls.js +2 -5
  150. package/srv/utils/plutus-placeholders.d.ts +0 -13
  151. package/srv/utils/plutus-placeholders.js +6 -13
  152. package/srv/utils/rate-limiter.d.ts +0 -8
  153. package/srv/utils/rate-limiter.js +2 -4
  154. package/srv/utils/reference-script.d.ts +0 -18
  155. package/srv/utils/reference-script.js +8 -19
  156. package/srv/utils/service-events.d.ts +0 -4
  157. package/srv/utils/service-events.js +2 -4
  158. package/srv/utils/signing-helper.d.ts +1 -8
  159. package/srv/utils/signing-helper.js +3 -8
  160. package/srv/utils/tx-build-helper.d.ts +2 -32
  161. package/srv/utils/tx-build-helper.js +26 -40
  162. package/srv/utils/tx-request-parsers.d.ts +1 -25
  163. package/srv/utils/tx-request-parsers.js +10 -25
  164. package/srv/utils/tx-utils.d.ts +0 -8
  165. package/srv/utils/tx-utils.js +10 -13
  166. package/srv/utils/types.d.ts +2 -37
  167. package/srv/utils/validators.d.ts +0 -4
  168. package/srv/utils/validators.js +2 -4
@@ -9,10 +9,8 @@ exports.detachedTx = detachedTx;
9
9
  const cds_1 = __importDefault(require("@sap/cds"));
10
10
  const errors_1 = require("./errors");
11
11
  const error_codes_1 = require("./error-codes");
12
- /**
13
- * Transaction helpers for the sign-service and background workers. @cap-js/sqlite has a single pooled
14
- * connection held by the request tx, so a new root tx awaited by that request would wait forever.
15
- */
12
+ // @cap-js/sqlite has a single pooled connection held by the request transaction.
13
+ // A new root transaction awaited by that request would wait forever.
16
14
  const logger = cds_1.default.log('tx-utils');
17
15
  /** Default acquire budget for detached bookkeeping transactions. */
18
16
  exports.DETACHED_TX_TIMEOUT_MS = 10_000;
@@ -21,10 +19,8 @@ function effectiveTimeoutMs() {
21
19
  const fromEnv = Number(process.env.ODATANO_DETACHED_TX_TIMEOUT_MS);
22
20
  return Number.isFinite(fromEnv) && fromEnv > 0 ? fromEnv : exports.DETACHED_TX_TIMEOUT_MS;
23
21
  }
24
- /**
25
- * Run `fn` with `cds.context` cleared so inner `db.run` calls get short-lived transactions instead of
26
- * joining a long-lived ambient one; keeps the single sqlite connection free during long awaits.
27
- */
22
+ // Clears cds.context so inner db.run calls use short transactions instead of joining an ambient one.
23
+ // This keeps the single SQLite connection free during long awaits.
28
24
  function runWithoutAmbientTx(fn) {
29
25
  return cds_1.default._with(undefined, fn);
30
26
  }
@@ -35,10 +31,8 @@ class DetachedTxAbortedError extends Error {
35
31
  this.name = 'DetachedTxAbortedError';
36
32
  }
37
33
  }
38
- /**
39
- * `cds.tx(fn)` as a new root transaction with a deadlock guard: throws BackendError 503
40
- * `ODATANO_NESTED_TX_TIMEOUT` when no pooled connection arrives in time, and a late grant does no work.
41
- */
34
+ // New root transaction with a deadlock guard. Throws 503 ODATANO_NESTED_TX_TIMEOUT when no
35
+ // connection arrives in time. A connection granted after the timeout does no work.
42
36
  async function detachedTx(label, fn, timeoutMs) {
43
37
  const effectiveTimeout = timeoutMs ?? effectiveTimeoutMs();
44
38
  let timedOut = false;
@@ -49,6 +43,9 @@ async function detachedTx(label, fn, timeoutMs) {
49
43
  await db.begin();
50
44
  if (timedOut)
51
45
  throw new DetachedTxAbortedError(label);
46
+ // the timeout bounds the acquire only; once begun, the work runs to its own commit
47
+ if (timer)
48
+ clearTimeout(timer);
52
49
  return fn(db);
53
50
  });
54
51
  const guard = new Promise((_, reject) => {
@@ -56,7 +53,7 @@ async function detachedTx(label, fn, timeoutMs) {
56
53
  timedOut = true;
57
54
  reject(new errors_1.BackendError(`${label}: could not begin a detached DB transaction within ${effectiveTimeout}ms. ` +
58
55
  `Most likely the calling request still holds the pooled DB connection open ` +
59
- `(in-process nested call — do not await this action while your request ` +
56
+ `(in-process nested call: do not await this action while your request ` +
60
57
  `transaction is open; detach your reads into a committed cds.tx first). ` +
61
58
  `Alternatively the connection pool is exhausted.`, 503, error_codes_1.ERROR_CODES.NESTED_TX_TIMEOUT));
62
59
  }, effectiveTimeout);
@@ -41,10 +41,6 @@ export interface TxOutputLine {
41
41
  referenceScriptSize?: number | null;
42
42
  referenceScriptType?: ReferenceScriptType | null;
43
43
  }
44
- /**
45
- * Normalized certificate kinds; unknown types pass through as the raw source string. A Conway
46
- * stake+vote delegation is split into `pool_delegation` + `vote_delegation` sharing one `certIndex`.
47
- */
48
44
  export type CertificateKind = 'stake_registration' | 'stake_deregistration' | 'pool_delegation' | 'vote_delegation' | 'pool_registration' | 'pool_retirement' | 'drep_registration' | 'drep_update' | 'drep_retirement' | 'committee_hot_auth' | 'committee_resign' | 'genesis_delegation' | 'treasury_mir' | 'reserve_mir' | 'pot_transfer' | 'param_proposal' | (string & {});
49
45
  /** One certificate of a transaction (crawler ledger-state coverage). */
50
46
  export interface TxCertificate {
@@ -101,20 +97,9 @@ export interface Transaction {
101
97
  /** What the ledger charged: the declared fee, or on a phase-2 failure the collateral consumed. */
102
98
  fee: Lovelace | string;
103
99
  deposit: Lovelace | string;
104
- /**
105
- * True when phase-2 failed: inputs/outputs not applied, collateral consumed, only the collateral
106
- * return produced. Ogmios (`spends`) and Blockfrost (`valid_contract`) report it; Koios leaves it undefined.
107
- */
100
+ /** True when phase 2 failed and only collateral was consumed. Undefined when the source does not report it. */
108
101
  spendsCollaterals?: boolean;
109
- /**
110
- * `total_collateral` from the body when declared; equals the collateral consumed on a phase-2 failure.
111
- * Null when omitted, the charge is then derived from the resolved collateral inputs minus the return.
112
- */
113
102
  totalCollateral?: Lovelace | string | null;
114
- /**
115
- * Signed net mint/burn per unit (negative = burn), never `lovelace`. Ogmios and Koios report it;
116
- * Blockfrost leaves it undefined and the indexer derives it from resolved input/output assets.
117
- */
118
103
  mint?: Amount[];
119
104
  /** Tx size in bytes; null when the source cannot provide it (Ogmios chain-sync). */
120
105
  size: number | null;
@@ -337,20 +322,12 @@ export type MintAction = {
337
322
  quantity: bigint;
338
323
  /** Optional integer redeemer, default 0 */
339
324
  redeemer?: number;
340
- /**
341
- * Per-action minting policy (CBOR hex, applied as-is) for multi-policy transactions; overrides the
342
- * top-level mintingPolicyScript. The assetUnit must carry this script's policyId.
343
- */
344
325
  mintingPolicyScript?: string;
345
326
  /** BuildPlutusTransaction only: UTxO that carries the policy as reference script; exclusive with mintingPolicyScript. */
346
327
  referenceScript?: {
347
328
  txHash: string;
348
329
  outputIndex: number;
349
330
  };
350
- /**
351
- * Per-action redeemer (parsed PlutusData JSON), only with mintingPolicyScript or referenceScript; falls back to mintRedeemer.
352
- * Actions on the same policy must agree (one redeemer per policy in the ledger).
353
- */
354
331
  redeemerJson?: JSONValue;
355
332
  };
356
333
  /** Plutus script execution for spending from a script address */
@@ -399,10 +376,7 @@ export type TxBuildRequest = {
399
376
  mintRedeemer?: JSONValue;
400
377
  /** When true, route output to enterprise script address derived from applied script hash */
401
378
  lockOnScript?: boolean;
402
- /**
403
- * UTxOs that must be consumed, added before coin selection (one-shot minting seeds);
404
- * deduplicated against plutusScriptExecution.scriptUtxo.
405
- */
379
+ /** UTxOs that must be spent, such as one-shot minting seeds. Added before coin selection. */
406
380
  forceInputs?: Array<{
407
381
  txHash: string;
408
382
  outputIndex: number;
@@ -471,10 +445,6 @@ export type PlutusTxOutput = NonNullable<TxBuildRequest['extraOutputs']>[number]
471
445
  /** Inline datum as PlutusData CBOR hex, taken byte for byte; exclusive with inlineDatum. */
472
446
  inlineDatumCbor?: string;
473
447
  };
474
- /**
475
- * Reward-account withdrawal of a BuildPlutusTransaction. A staking script (inline or by reference)
476
- * runs with the redeemer under the Reward purpose; without a script the stake key signs.
477
- */
478
448
  export type WithdrawalInput = {
479
449
  /** Bech32 reward account (stake address). */
480
450
  rewardAddress: string;
@@ -492,11 +462,6 @@ export type WithdrawalInput = {
492
462
  /** Redeemer as PlutusData CBOR hex; wins over `redeemer`, no placeholders. */
493
463
  redeemerCbor?: string;
494
464
  };
495
- /**
496
- * Stake-credential certificate of a BuildPlutusTransaction. A registration without a script is the
497
- * witness-free legacy form (key or script credential); with a script the Conway deposit form, run
498
- * under the Certifying purpose. A deregistration needs the key's witness or the script.
499
- */
500
465
  export type CertificateInput = {
501
466
  type: 'registerStake' | 'deregisterStake';
502
467
  /** Bech32 stake address of the credential. */
@@ -32,10 +32,6 @@ export declare function isEpochNumber(s: unknown): s is number;
32
32
  export declare function isValidCbor(cborRaw: unknown): cborRaw is string;
33
33
  /** `isValidCbor` plus the MAX_TX_CBOR_HEX_LENGTH cap (ParseTransactionCbor memory bound). */
34
34
  export declare function isValidTxCborHex(cborRaw: unknown): cborRaw is string;
35
- /**
36
- * Payment credential of a Shelley bech32 address: 28-byte hash (hex) plus whether it is a script
37
- * credential (bit 0 of the header's high nibble); null for undecodable or stake addresses.
38
- */
39
35
  export declare function extractPaymentCredential(address: string): {
40
36
  hash: string;
41
37
  isScript: boolean;
@@ -207,10 +207,8 @@ function isValidTxCborHex(cborRaw) {
207
207
  return false;
208
208
  return cborRaw.trim().length <= const_1.MAX_TX_CBOR_HEX_LENGTH;
209
209
  }
210
- /**
211
- * Payment credential of a Shelley bech32 address: 28-byte hash (hex) plus whether it is a script
212
- * credential (bit 0 of the header's high nibble); null for undecodable or stake addresses.
213
- */
210
+ // Payment credential hash of a Shelley address and whether it is a script credential.
211
+ // Null for undecodable or stake addresses.
214
212
  function extractPaymentCredential(address) {
215
213
  try {
216
214
  const decoded = bech32_1.bech32.decode(address, const_1.BECH32_MAX_LENGTH);