@odatano/core 2.0.0-rc.19 → 2.0.0-rc.20

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 (119) hide show
  1. package/@cds-models/CardanoAgentService/index.d.ts +1 -5
  2. package/@cds-models/CardanoIndexerService/index.d.ts +51 -2
  3. package/@cds-models/CardanoIndexerService/index.js +7 -0
  4. package/package.json +1 -1
  5. package/src/index.d.ts +4 -10
  6. package/src/index.js +6 -16
  7. package/src/plugin.js +11 -27
  8. package/srv/blockchain/backends/blockfrost-backend.d.ts +29 -131
  9. package/srv/blockchain/backends/blockfrost-backend.js +39 -150
  10. package/srv/blockchain/backends/cardano-backend.d.ts +53 -171
  11. package/srv/blockchain/backends/cardano-backend.js +1 -5
  12. package/srv/blockchain/backends/koios-backend.d.ts +26 -71
  13. package/srv/blockchain/backends/koios-backend.js +50 -132
  14. package/srv/blockchain/backends/ogmios-backend.d.ts +43 -124
  15. package/srv/blockchain/backends/ogmios-backend.js +71 -179
  16. package/srv/blockchain/backends/ogmios-frame-guard.d.ts +12 -57
  17. package/srv/blockchain/backends/ogmios-frame-guard.js +27 -66
  18. package/srv/blockchain/cardano-client.d.ts +43 -216
  19. package/srv/blockchain/cardano-client.js +49 -234
  20. package/srv/blockchain/cardano-indexer.d.ts +79 -357
  21. package/srv/blockchain/cardano-indexer.js +98 -406
  22. package/srv/blockchain/cardano-tx-builder.d.ts +19 -84
  23. package/srv/blockchain/cardano-tx-builder.js +21 -107
  24. package/srv/blockchain/crawler/certificate-backfill.d.ts +45 -0
  25. package/srv/blockchain/crawler/certificate-backfill.js +150 -0
  26. package/srv/blockchain/crawler/crawler.d.ts +41 -145
  27. package/srv/blockchain/crawler/crawler.js +57 -172
  28. package/srv/blockchain/crawler/hooks.d.ts +3 -14
  29. package/srv/blockchain/crawler/index.d.ts +2 -6
  30. package/srv/blockchain/crawler/index.js +4 -9
  31. package/srv/blockchain/crawler/sync-state.d.ts +17 -39
  32. package/srv/blockchain/crawler/sync-state.js +23 -55
  33. package/srv/blockchain/crawler/utxo-set-import.d.ts +5 -22
  34. package/srv/blockchain/crawler/utxo-set-import.js +8 -28
  35. package/srv/blockchain/ledger-state.d.ts +3 -12
  36. package/srv/blockchain/signing/cose-verifier.d.ts +5 -12
  37. package/srv/blockchain/signing/cose-verifier.js +6 -12
  38. package/srv/blockchain/signing/external-signer.d.ts +16 -113
  39. package/srv/blockchain/signing/external-signer.js +19 -122
  40. package/srv/blockchain/signing/hsm-signer.d.ts +13 -45
  41. package/srv/blockchain/signing/hsm-signer.js +23 -63
  42. package/srv/blockchain/signing/signature-verifier.d.ts +8 -44
  43. package/srv/blockchain/signing/signature-verifier.js +13 -54
  44. package/srv/blockchain/signing/submission-finalizer.d.ts +9 -36
  45. package/srv/blockchain/signing/submission-finalizer.js +16 -48
  46. package/srv/blockchain/transaction-building/buildooor-tx.d.ts +65 -174
  47. package/srv/blockchain/transaction-building/buildooor-tx.js +107 -266
  48. package/srv/blockchain/transaction-building/cardano-tx.d.ts +8 -34
  49. package/srv/blockchain/wallet-worker/build-request.d.ts +4 -17
  50. package/srv/blockchain/wallet-worker/build-request.js +9 -22
  51. package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +12 -35
  52. package/srv/blockchain/wallet-worker/confirmation-tracker.js +16 -32
  53. package/srv/blockchain/wallet-worker/index.js +2 -8
  54. package/srv/blockchain/wallet-worker/job-store.d.ts +33 -111
  55. package/srv/blockchain/wallet-worker/job-store.js +0 -0
  56. package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +4 -20
  57. package/srv/blockchain/wallet-worker/lease-heartbeat.js +4 -20
  58. package/srv/blockchain/wallet-worker/signers.d.ts +6 -19
  59. package/srv/blockchain/wallet-worker/signers.js +3 -8
  60. package/srv/blockchain/wallet-worker/wallet-worker.d.ts +15 -71
  61. package/srv/blockchain/wallet-worker/wallet-worker.js +34 -90
  62. package/srv/cardano-agent-service.cds +1 -5
  63. package/srv/cardano-agent-service.js +3 -7
  64. package/srv/cardano-indexer-service.cds +32 -4
  65. package/srv/cardano-indexer-service.js +83 -15
  66. package/srv/cardano-service.js +36 -98
  67. package/srv/cardano-sign-service.cds +1 -1
  68. package/srv/cardano-sign-service.js +55 -173
  69. package/srv/cardano-tx-service.cds +1 -1
  70. package/srv/cardano-tx-service.js +54 -174
  71. package/srv/cardano-worker-service.js +7 -15
  72. package/srv/server.d.ts +27 -86
  73. package/srv/server.js +52 -148
  74. package/srv/utils/agent-grants-config.d.ts +11 -50
  75. package/srv/utils/agent-grants-config.js +12 -45
  76. package/srv/utils/agent-grants.d.ts +34 -123
  77. package/srv/utils/agent-grants.js +57 -156
  78. package/srv/utils/agent-token-auth.d.ts +2 -5
  79. package/srv/utils/agent-token-auth.js +2 -5
  80. package/srv/utils/backend-request-handler.d.ts +2 -16
  81. package/srv/utils/backend-request-handler.js +3 -18
  82. package/srv/utils/collections.d.ts +4 -8
  83. package/srv/utils/collections.js +4 -8
  84. package/srv/utils/const.d.ts +19 -68
  85. package/srv/utils/const.js +20 -69
  86. package/srv/utils/crypto.d.ts +3 -12
  87. package/srv/utils/crypto.js +5 -18
  88. package/srv/utils/db-indexes.d.ts +2 -7
  89. package/srv/utils/db-indexes.js +7 -34
  90. package/srv/utils/db-sanitize.d.ts +5 -18
  91. package/srv/utils/db-sanitize.js +6 -19
  92. package/srv/utils/error-codes.d.ts +18 -73
  93. package/srv/utils/error-codes.js +17 -70
  94. package/srv/utils/errors.d.ts +29 -191
  95. package/srv/utils/errors.js +44 -229
  96. package/srv/utils/liveness.d.ts +2 -9
  97. package/srv/utils/liveness.js +3 -11
  98. package/srv/utils/mappers.d.ts +50 -298
  99. package/srv/utils/mappers.js +80 -386
  100. package/srv/utils/network-context.js +2 -11
  101. package/srv/utils/pg-order-nulls.js +4 -23
  102. package/srv/utils/plutus-placeholders.d.ts +6 -18
  103. package/srv/utils/plutus-placeholders.js +6 -20
  104. package/srv/utils/rate-limiter.d.ts +6 -17
  105. package/srv/utils/rate-limiter.js +5 -15
  106. package/srv/utils/service-events.d.ts +2 -22
  107. package/srv/utils/service-events.js +3 -23
  108. package/srv/utils/signing-helper.d.ts +3 -18
  109. package/srv/utils/signing-helper.js +10 -32
  110. package/srv/utils/tx-build-helper.d.ts +18 -92
  111. package/srv/utils/tx-build-helper.js +32 -123
  112. package/srv/utils/tx-request-parsers.d.ts +7 -26
  113. package/srv/utils/tx-request-parsers.js +7 -26
  114. package/srv/utils/tx-utils.d.ts +4 -23
  115. package/srv/utils/tx-utils.js +12 -41
  116. package/srv/utils/types.d.ts +67 -206
  117. package/srv/utils/types.js +2 -6
  118. package/srv/utils/validators.d.ts +19 -89
  119. package/srv/utils/validators.js +31 -138
@@ -1,6 +1,4 @@
1
- /**
2
- * Cardano protocol constants
3
- */
1
+ /** Cardano protocol constants */
4
2
  export declare const CARDANO_DEFAULTS: {
5
3
  /** Maximum ADA supply in lovelace (45 billion ADA) */
6
4
  MAX_LOVELACE_SUPPLY: string;
@@ -8,10 +6,9 @@ export declare const CARDANO_DEFAULTS: {
8
6
  MS_PER_SLOT: number;
9
7
  };
10
8
  /**
11
- * Network-specific epoch geometry, anchored at the Shelley transition:
9
+ * Per-network epoch geometry anchored at the Shelley transition:
12
10
  * `epochStartSlot(epoch) = shelleyStartSlot + (epoch - shelleyStartEpoch) * slotsPerEpoch`.
13
- * A single global SLOTS_PER_EPOCH is wrong twice over — preview uses 86 400 (1 day),
14
- * and mainnet/preprod epochs are offset by their Byron era.
11
+ * Preview epochs are 1 day; mainnet/preprod are offset by their Byron era.
15
12
  */
16
13
  export declare const EPOCH_CONFIG_BY_NETWORK: {
17
14
  readonly mainnet: {
@@ -30,48 +27,25 @@ export declare const EPOCH_CONFIG_BY_NETWORK: {
30
27
  readonly slotsPerEpoch: 86400;
31
28
  };
32
29
  };
33
- /**
34
- * Default execution units for Plutus scripts
35
- * Used when dynamic evaluation is not available
36
- */
30
+ /** Default Plutus execution units when dynamic evaluation is not available */
37
31
  export declare const DEFAULT_EXECUTION_UNITS: {
38
- /** Memory units for script execution */
39
32
  mem: number;
40
- /** CPU steps for script execution */
41
33
  cpu: number;
42
34
  };
43
- /**
44
- * High execution units for initial transaction build (before evaluation)
45
- * Set higher than DEFAULT to ensure fee estimation is sufficient before actual evaluation
46
- */
35
+ /** High execution units for the initial build pass, so the fee estimate holds before evaluation */
47
36
  export declare const HIGH_EXECUTION_UNITS: {
48
- /** Memory units - high for evaluation pass */
49
37
  mem: number;
50
- /** CPU steps - high for evaluation pass */
51
38
  cpu: number;
52
39
  };
53
- /**
54
- * Execution unit buffer — relative multiplier applied to evaluator output.
55
- * Combined with ABS_* floors below so small validators also get a meaningful cushion.
56
- */
40
+ /** Relative multiplier on evaluator ExUnits; combined with the ABS_* floors below. */
57
41
  export declare const EXECUTION_UNIT_BUFFER = 1.1;
58
42
  /**
59
- * Absolute ExUnits floor added on top of the relative multiplier.
60
- *
61
- * Rationale: validators that iterate reference inputs and decode inline CBOR
62
- * datums (e.g. oracle-consuming mint policies) show a larger ScriptContext →
63
- * ledger drift than the documented ~10k–30k CPU / ~50–100 mem band — real-world
64
- * cases overshot a 50k/1k floor by ~27k CPU / ~56 mem, burning the submit fee.
65
- * The floor is sized to cover reference-input + CBOR-decoding drift on top of
66
- * the 10% relative multiplier; `max_tx_ex_units` still caps build-time totals,
67
- * so oversizing here cannot push a tx past network limits — it only trades a
68
- * few extra lovelace of fee for avoiding an opaque PlutusFailure on submit.
43
+ * Absolute ExUnits floor on top of the relative multiplier: covers ScriptContext drift of validators
44
+ * that iterate reference inputs and decode CBOR datums. `max_tx_ex_units` still caps the total.
69
45
  */
70
46
  export declare const ABS_CPU_BUFFER = 200000;
71
47
  export declare const ABS_MEM_BUFFER = 5000;
72
- /**
73
- * Transaction building constants
74
- */
48
+ /** Transaction building constants */
75
49
  /** Collateral amount in lovelace (5 ADA) */
76
50
  export declare const COLLATERAL_LOVELACE = 5000000n;
77
51
  /** Fee buffer in lovelace (1 ADA) */
@@ -90,9 +64,7 @@ export declare const HRP: {
90
64
  stake: RegExp;
91
65
  };
92
66
  };
93
- /**
94
- * Input validation limits to prevent DoS attacks
95
- */
67
+ /** Input validation limits to prevent DoS attacks */
96
68
  /** Maximum JSON string length in bytes (1MB) */
97
69
  export declare const MAX_JSON_SIZE = 1048576;
98
70
  /** Maximum nesting depth for JSON objects/arrays */
@@ -105,12 +77,7 @@ export declare const MAX_ARRAY_LENGTH = 1000;
105
77
  export declare const MAX_STRING_LENGTH = 65536;
106
78
  /** Maximum ech32 string length to prevent DoS */
107
79
  export declare const BECH32_MAX_LENGTH = 2000;
108
- /**
109
- * Maximum hex length of transaction CBOR accepted by ParseTransactionCbor.
110
- * Mainnet `maxTxSize` is currently 16 KiB; 64 KiB raw (= 128 KiB hex) leaves
111
- * generous headroom for future protocol bumps and reference-script outputs
112
- * while keeping the parser from being a memory-exhaustion vector.
113
- */
80
+ /** Max tx CBOR hex accepted by ParseTransactionCbor: 64 KiB raw, well above mainnet maxTxSize (16 KiB). */
114
81
  export declare const MAX_TX_CBOR_HEX_LENGTH: number;
115
82
  /** Maximum reasonable epoch number */
116
83
  export declare const MAX_EPOCH = 100000;
@@ -128,11 +95,7 @@ export declare const ED25519_KEY_HASH_HEX_LENGTH = 56;
128
95
  export declare const ED25519_KEY_HASH_REGEX: RegExp;
129
96
  /** Minimum lovelace for a change output carrying native assets (2 ADA) */
130
97
  export declare const MIN_CHANGE_LOVELACE = 2000000;
131
- /**
132
- * Shelley-era genesis parameters per network, used to construct Buildooor's
133
- * GenesisInfos so `TxBuilder.posixToSlot()` can convert validity-window
134
- * Posix ms into ledger slots. `slotLengthMs` is 1000 ms on all current networks.
135
- */
98
+ /** Shelley genesis parameters per network for Buildooor's GenesisInfos (`TxBuilder.posixToSlot()`). */
136
99
  export declare const GENESIS_INFOS_BY_NETWORK: {
137
100
  readonly mainnet: {
138
101
  readonly systemStartPosixMs: 1596491091000;
@@ -152,32 +115,20 @@ export declare const GENESIS_INFOS_BY_NETWORK: {
152
115
  };
153
116
  /** Default validity-window start offset: `now - 2 min` to absorb clock skew. */
154
117
  export declare const DEFAULT_VALIDITY_START_OFFSET_MS = 120000;
155
- /** Default validity-window end offset: `now + 1 h` — generous enough for human-latency sign+submit flows. */
118
+ /** Default validity-window end offset: `now + 1 h`, enough for human-latency sign+submit flows. */
156
119
  export declare const DEFAULT_VALIDITY_END_OFFSET_MS: number;
157
120
  /** Max accepted digits in a Posix-ms string (13 digits covers Unix ms timestamps through ~Nov 2286). */
158
121
  export declare const MAX_POSIX_MS_DIGITS = 13;
159
- /**
160
- * Generic 64-character hex string (used for block hashes and other 32-byte hex identifiers)
161
- */
122
+ /** Generic 64-character hex string (block hashes and other 32-byte identifiers) */
162
123
  export declare const HEX_64_REGEX: RegExp;
163
- /**
164
- * Generic 56-character hex string — 28-byte hashes (Blake2b-224 / payment credential / script hash / pool key hash).
165
- */
124
+ /** Generic 56-character hex string: 28-byte hashes (Blake2b-224, payment credential, script hash, pool key hash) */
166
125
  export declare const HEX_56_REGEX: RegExp;
167
- /**
168
- * Transaction hash Regex - 64-character hexadecimal string
169
- */
126
+ /** Transaction hash: 64-character hex string */
170
127
  export declare const TX_HASH_REGEX: RegExp;
171
- /**
172
- * Asset unit Regex - policy ID (56 hex chars) + asset name (0-64 hex chars)
173
- */
128
+ /** Asset unit: policy ID (56 hex) + asset name (0-32 bytes = 0-64 hex, even length; total <= 120 = String(120) key column) */
174
129
  export declare const ASSET_UNIT_REGEX: RegExp;
175
- /**
176
- * Pool ID Regex - bech32 with HRP "pool" and 28 bytes payload
177
- */
130
+ /** Pool ID: bech32 with HRP "pool" and 28-byte payload */
178
131
  export declare const POOL_ID_REGEX: RegExp;
179
- /**
180
- * DRep ID Regex - bech32 with HRP "drep" and 50-60 chars payload
181
- */
132
+ /** DRep ID: bech32 with HRP "drep" and 50-60 chars payload */
182
133
  export declare const DREP_ID_REGEX: RegExp;
183
134
  //# sourceMappingURL=const.d.ts.map
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DREP_ID_REGEX = exports.POOL_ID_REGEX = exports.ASSET_UNIT_REGEX = exports.TX_HASH_REGEX = exports.HEX_56_REGEX = exports.HEX_64_REGEX = exports.MAX_POSIX_MS_DIGITS = exports.DEFAULT_VALIDITY_END_OFFSET_MS = exports.DEFAULT_VALIDITY_START_OFFSET_MS = exports.GENESIS_INFOS_BY_NETWORK = exports.MIN_CHANGE_LOVELACE = exports.ED25519_KEY_HASH_REGEX = exports.ED25519_KEY_HASH_HEX_LENGTH = exports.MIN_FULL_ASSET_UNIT_LENGTH = exports.POLICY_ID_HEX_LENGTH = exports.DREP_ID_BYTES = exports.POOL_ID_BYTES = exports.MAX_EPOCH = exports.MAX_TX_CBOR_HEX_LENGTH = exports.BECH32_MAX_LENGTH = exports.MAX_STRING_LENGTH = exports.MAX_ARRAY_LENGTH = exports.MAX_KEYS = exports.MAX_DEPTH = exports.MAX_JSON_SIZE = exports.HRP = exports.FEE_BUFFER_LOVELACE = exports.COLLATERAL_LOVELACE = exports.ABS_MEM_BUFFER = exports.ABS_CPU_BUFFER = exports.EXECUTION_UNIT_BUFFER = exports.HIGH_EXECUTION_UNITS = exports.DEFAULT_EXECUTION_UNITS = exports.EPOCH_CONFIG_BY_NETWORK = exports.CARDANO_DEFAULTS = void 0;
4
- /**
5
- * Cardano protocol constants
6
- */
4
+ /** Cardano protocol constants */
7
5
  exports.CARDANO_DEFAULTS = {
8
6
  /** Maximum ADA supply in lovelace (45 billion ADA) */
9
7
  MAX_LOVELACE_SUPPLY: '45000000000000000',
@@ -11,58 +9,34 @@ exports.CARDANO_DEFAULTS = {
11
9
  MS_PER_SLOT: 1000,
12
10
  };
13
11
  /**
14
- * Network-specific epoch geometry, anchored at the Shelley transition:
12
+ * Per-network epoch geometry anchored at the Shelley transition:
15
13
  * `epochStartSlot(epoch) = shelleyStartSlot + (epoch - shelleyStartEpoch) * slotsPerEpoch`.
16
- * A single global SLOTS_PER_EPOCH is wrong twice over — preview uses 86 400 (1 day),
17
- * and mainnet/preprod epochs are offset by their Byron era.
14
+ * Preview epochs are 1 day; mainnet/preprod are offset by their Byron era.
18
15
  */
19
16
  exports.EPOCH_CONFIG_BY_NETWORK = {
20
17
  mainnet: { shelleyStartEpoch: 208, shelleyStartSlot: 4_492_800, slotsPerEpoch: 432_000 },
21
18
  preprod: { shelleyStartEpoch: 4, shelleyStartSlot: 86_400, slotsPerEpoch: 432_000 },
22
19
  preview: { shelleyStartEpoch: 0, shelleyStartSlot: 0, slotsPerEpoch: 86_400 },
23
20
  };
24
- /**
25
- * Default execution units for Plutus scripts
26
- * Used when dynamic evaluation is not available
27
- */
21
+ /** Default Plutus execution units when dynamic evaluation is not available */
28
22
  exports.DEFAULT_EXECUTION_UNITS = {
29
- /** Memory units for script execution */
30
23
  mem: 14_000_000,
31
- /** CPU steps for script execution */
32
24
  cpu: 10_000_000_000,
33
25
  };
34
- /**
35
- * High execution units for initial transaction build (before evaluation)
36
- * Set higher than DEFAULT to ensure fee estimation is sufficient before actual evaluation
37
- */
26
+ /** High execution units for the initial build pass, so the fee estimate holds before evaluation */
38
27
  exports.HIGH_EXECUTION_UNITS = {
39
- /** Memory units - high for evaluation pass */
40
28
  mem: 28_000_000,
41
- /** CPU steps - high for evaluation pass */
42
29
  cpu: 20_000_000_000,
43
30
  };
44
- /**
45
- * Execution unit buffer — relative multiplier applied to evaluator output.
46
- * Combined with ABS_* floors below so small validators also get a meaningful cushion.
47
- */
31
+ /** Relative multiplier on evaluator ExUnits; combined with the ABS_* floors below. */
48
32
  exports.EXECUTION_UNIT_BUFFER = 1.1;
49
33
  /**
50
- * Absolute ExUnits floor added on top of the relative multiplier.
51
- *
52
- * Rationale: validators that iterate reference inputs and decode inline CBOR
53
- * datums (e.g. oracle-consuming mint policies) show a larger ScriptContext →
54
- * ledger drift than the documented ~10k–30k CPU / ~50–100 mem band — real-world
55
- * cases overshot a 50k/1k floor by ~27k CPU / ~56 mem, burning the submit fee.
56
- * The floor is sized to cover reference-input + CBOR-decoding drift on top of
57
- * the 10% relative multiplier; `max_tx_ex_units` still caps build-time totals,
58
- * so oversizing here cannot push a tx past network limits — it only trades a
59
- * few extra lovelace of fee for avoiding an opaque PlutusFailure on submit.
34
+ * Absolute ExUnits floor on top of the relative multiplier: covers ScriptContext drift of validators
35
+ * that iterate reference inputs and decode CBOR datums. `max_tx_ex_units` still caps the total.
60
36
  */
61
37
  exports.ABS_CPU_BUFFER = 200_000;
62
38
  exports.ABS_MEM_BUFFER = 5_000;
63
- /**
64
- * Transaction building constants
65
- */
39
+ /** Transaction building constants */
66
40
  /** Collateral amount in lovelace (5 ADA) */
67
41
  exports.COLLATERAL_LOVELACE = 5000000n;
68
42
  /** Fee buffer in lovelace (1 ADA) */
@@ -72,9 +46,7 @@ exports.HRP = {
72
46
  preview: { addr: /^addr_test1[0-9a-z]{50,100}$/, stake: /^stake_test1[0-9a-z]{53,}$/ },
73
47
  preprod: { addr: /^addr_test1[0-9a-z]{50,100}$/, stake: /^stake_test1[0-9a-z]{53,}$/ },
74
48
  };
75
- /**
76
- * Input validation limits to prevent DoS attacks
77
- */
49
+ /** Input validation limits to prevent DoS attacks */
78
50
  /** Maximum JSON string length in bytes (1MB) */
79
51
  exports.MAX_JSON_SIZE = 1_048_576;
80
52
  /** Maximum nesting depth for JSON objects/arrays */
@@ -87,12 +59,7 @@ exports.MAX_ARRAY_LENGTH = 1000;
87
59
  exports.MAX_STRING_LENGTH = 65536;
88
60
  /** Maximum ech32 string length to prevent DoS */
89
61
  exports.BECH32_MAX_LENGTH = 2000;
90
- /**
91
- * Maximum hex length of transaction CBOR accepted by ParseTransactionCbor.
92
- * Mainnet `maxTxSize` is currently 16 KiB; 64 KiB raw (= 128 KiB hex) leaves
93
- * generous headroom for future protocol bumps and reference-script outputs
94
- * while keeping the parser from being a memory-exhaustion vector.
95
- */
62
+ /** Max tx CBOR hex accepted by ParseTransactionCbor: 64 KiB raw, well above mainnet maxTxSize (16 KiB). */
96
63
  exports.MAX_TX_CBOR_HEX_LENGTH = 65536 * 2;
97
64
  /** Maximum reasonable epoch number */
98
65
  exports.MAX_EPOCH = 100_000;
@@ -110,11 +77,7 @@ exports.ED25519_KEY_HASH_HEX_LENGTH = 56;
110
77
  exports.ED25519_KEY_HASH_REGEX = /^[a-f0-9]{56}$/i;
111
78
  /** Minimum lovelace for a change output carrying native assets (2 ADA) */
112
79
  exports.MIN_CHANGE_LOVELACE = 2_000_000;
113
- /**
114
- * Shelley-era genesis parameters per network, used to construct Buildooor's
115
- * GenesisInfos so `TxBuilder.posixToSlot()` can convert validity-window
116
- * Posix ms into ledger slots. `slotLengthMs` is 1000 ms on all current networks.
117
- */
80
+ /** Shelley genesis parameters per network for Buildooor's GenesisInfos (`TxBuilder.posixToSlot()`). */
118
81
  exports.GENESIS_INFOS_BY_NETWORK = {
119
82
  mainnet: { systemStartPosixMs: 1596491091000, slotLengthMs: 1000, startSlotNo: 4492800 },
120
83
  preprod: { systemStartPosixMs: 1655683200000, slotLengthMs: 1000, startSlotNo: 0 },
@@ -122,32 +85,20 @@ exports.GENESIS_INFOS_BY_NETWORK = {
122
85
  };
123
86
  /** Default validity-window start offset: `now - 2 min` to absorb clock skew. */
124
87
  exports.DEFAULT_VALIDITY_START_OFFSET_MS = 120_000;
125
- /** Default validity-window end offset: `now + 1 h` — generous enough for human-latency sign+submit flows. */
88
+ /** Default validity-window end offset: `now + 1 h`, enough for human-latency sign+submit flows. */
126
89
  exports.DEFAULT_VALIDITY_END_OFFSET_MS = 60 * 60 * 1000;
127
90
  /** Max accepted digits in a Posix-ms string (13 digits covers Unix ms timestamps through ~Nov 2286). */
128
91
  exports.MAX_POSIX_MS_DIGITS = 13;
129
- /**
130
- * Generic 64-character hex string (used for block hashes and other 32-byte hex identifiers)
131
- */
92
+ /** Generic 64-character hex string (block hashes and other 32-byte identifiers) */
132
93
  exports.HEX_64_REGEX = /^[a-f0-9]{64}$/;
133
- /**
134
- * Generic 56-character hex string — 28-byte hashes (Blake2b-224 / payment credential / script hash / pool key hash).
135
- */
94
+ /** Generic 56-character hex string: 28-byte hashes (Blake2b-224, payment credential, script hash, pool key hash) */
136
95
  exports.HEX_56_REGEX = /^[a-f0-9]{56}$/;
137
- /**
138
- * Transaction hash Regex - 64-character hexadecimal string
139
- */
96
+ /** Transaction hash: 64-character hex string */
140
97
  exports.TX_HASH_REGEX = /^[a-f0-9]{64}$/;
141
- /**
142
- * Asset unit Regex - policy ID (56 hex chars) + asset name (0-64 hex chars)
143
- */
144
- exports.ASSET_UNIT_REGEX = /^[a-f0-9]{56}([a-f0-9]{2}){0,32}$/; // policy ID (56) + asset name (0-32 bytes per ledger rules -> 0-64 hex chars, even length; total ≤ 120 = String(120) key column)
145
- /**
146
- * Pool ID Regex - bech32 with HRP "pool" and 28 bytes payload
147
- */
98
+ /** Asset unit: policy ID (56 hex) + asset name (0-32 bytes = 0-64 hex, even length; total <= 120 = String(120) key column) */
99
+ exports.ASSET_UNIT_REGEX = /^[a-f0-9]{56}([a-f0-9]{2}){0,32}$/;
100
+ /** Pool ID: bech32 with HRP "pool" and 28-byte payload */
148
101
  exports.POOL_ID_REGEX = /^pool1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{51}$/;
149
- /**
150
- * DRep ID Regex - bech32 with HRP "drep" and 50-60 chars payload
151
- */
102
+ /** DRep ID: bech32 with HRP "drep" and 50-60 chars payload */
152
103
  exports.DREP_ID_REGEX = /^drep1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{50,60}$/;
153
104
  //# sourceMappingURL=const.js.map
@@ -1,16 +1,7 @@
1
- /**
2
- * Derive the 32-byte encryption key from the environment.
3
- * Production: ENCRYPTION_KEY is required. Development: process-scoped fallback.
4
- */
1
+ /** 32-byte key from ENCRYPTION_KEY; development falls back to a process-scoped key. */
5
2
  export declare function getEncryptionKey(): Buffer;
6
- /**
7
- * Encrypt plaintext with AES-256-GCM.
8
- * Returns the combined format `base64(iv):base64(authTag):base64(ciphertext)`.
9
- */
3
+ /** Encrypts to `base64(iv):base64(authTag):base64(ciphertext)`. */
10
4
  export declare function encrypt(plaintext: string, key: Buffer): string;
11
- /**
12
- * Decrypt a combined `iv:authTag:ciphertext` string back to plaintext.
13
- * Throws on authentication failure (tampered ciphertext or wrong key).
14
- */
5
+ /** Decrypts a combined `iv:authTag:ciphertext` string; throws on auth-tag mismatch. */
15
6
  export declare function decrypt(combined: string, key: Buffer): string;
16
7
  //# sourceMappingURL=crypto.d.ts.map
@@ -11,20 +11,13 @@ const node_os_1 = __importDefault(require("node:os"));
11
11
  const cds_1 = __importDefault(require("@sap/cds"));
12
12
  const logger = cds_1.default.log('CardanoWalletWorker');
13
13
  /**
14
- * AES-256-GCM utilities for secrets at rest (v2.0 wallet worker).
15
- *
16
- * Ported from NIGHTGATE's srv/utils/crypto.ts. Used to decrypt operator-provided
17
- * software signing keys (`iv:authTag:ciphertext`, all base64). Keys are derived
18
- * from the ENCRYPTION_KEY environment variable; production refuses to start
19
- * without it, development falls back to a process-scoped key.
14
+ * AES-256-GCM for secrets at rest (wallet worker signing keys), format `iv:authTag:ciphertext` in base64.
15
+ * Key derived from ENCRYPTION_KEY; production refuses to start without it.
20
16
  */
21
17
  const ALGORITHM = 'aes-256-gcm';
22
18
  const IV_LENGTH = 12; // 96 bits, recommended for GCM
23
19
  const AUTH_TAG_LENGTH = 16; // 128 bits
24
- /**
25
- * Derive the 32-byte encryption key from the environment.
26
- * Production: ENCRYPTION_KEY is required. Development: process-scoped fallback.
27
- */
20
+ /** 32-byte key from ENCRYPTION_KEY; development falls back to a process-scoped key. */
28
21
  function getEncryptionKey() {
29
22
  const envKey = process.env.ENCRYPTION_KEY;
30
23
  if (envKey) {
@@ -37,10 +30,7 @@ function getEncryptionKey() {
37
30
  const fallback = `odatano-core-${process.pid}-${node_os_1.default.hostname()}`;
38
31
  return node_crypto_1.default.createHash('sha256').update(fallback).digest();
39
32
  }
40
- /**
41
- * Encrypt plaintext with AES-256-GCM.
42
- * Returns the combined format `base64(iv):base64(authTag):base64(ciphertext)`.
43
- */
33
+ /** Encrypts to `base64(iv):base64(authTag):base64(ciphertext)`. */
44
34
  function encrypt(plaintext, key) {
45
35
  const iv = node_crypto_1.default.randomBytes(IV_LENGTH);
46
36
  const cipher = node_crypto_1.default.createCipheriv(ALGORITHM, key, iv, { authTagLength: AUTH_TAG_LENGTH });
@@ -48,10 +38,7 @@ function encrypt(plaintext, key) {
48
38
  const authTag = cipher.getAuthTag();
49
39
  return `${iv.toString('base64')}:${authTag.toString('base64')}:${encrypted.toString('base64')}`;
50
40
  }
51
- /**
52
- * Decrypt a combined `iv:authTag:ciphertext` string back to plaintext.
53
- * Throws on authentication failure (tampered ciphertext or wrong key).
54
- */
41
+ /** Decrypts a combined `iv:authTag:ciphertext` string; throws on auth-tag mismatch. */
55
42
  function decrypt(combined, key) {
56
43
  const parts = combined.split(':');
57
44
  if (parts.length !== 3) {
@@ -8,7 +8,7 @@ export interface IndexSpec {
8
8
  /** PostgreSQL spelling when it differs (SQLite knows no NULLS in an index definition). */
9
9
  postgres?: string;
10
10
  }
11
- /** Every entry answers a query the service or the crawler actually runs (see the module doc). */
11
+ /** Every entry answers a query the service or the crawler actually runs. */
12
12
  export declare const DB_INDEXES: readonly IndexSpec[];
13
13
  /** The statement for one entry; exported so tests pin the shape. */
14
14
  export declare function indexStatement(spec: IndexSpec, kind?: string): string;
@@ -17,12 +17,7 @@ export type SqlRunner = {
17
17
  run: (sql: string) => Promise<unknown>;
18
18
  kind?: string;
19
19
  };
20
- /**
21
- * Creates every index that does not exist yet. Returns the names it ran;
22
- * a failing statement is logged and skipped (a missing table on a partial
23
- * deployment, a database without the privilege), the others still run.
24
- * On HANA nothing runs (see the module doc).
25
- */
20
+ /** Creates every missing index; a failing statement is logged and skipped, the others still run. */
26
21
  export declare function ensureDbIndexes(runner?: SqlRunner | undefined): Promise<{
27
22
  ensured: string[];
28
23
  failed: string[];
@@ -7,40 +7,18 @@ exports.DB_INDEXES = void 0;
7
7
  exports.indexStatement = indexStatement;
8
8
  exports.ensureDbIndexes = ensureDbIndexes;
9
9
  /**
10
- * Secondary indexes the CDS model cannot declare. `cds deploy` creates the
11
- * primary keys only, and the temporal entities (Assets, Pools, Accounts,
12
- * Addresses, AddressUTxOs, ...) carry `validFrom` FIRST in their key, so every
13
- * lookup by unit / poolId / stakeAddress / address scanned the table; Blocks
14
- * by height (ORDER BY height DESC is the "latest block" read), by slot and by
15
- * epoch, Transactions by block, TransactionMetadata by tx and AssetHistory by
16
- * tx (crawler rollback) had no index at all. Measured on the hosted preprod
17
- * box on 2026-09-23 (930k blocks, 1.4M transactions, 521k metadata rows):
18
- * latest block 200 ms, GetMetadataByTxHash 1.0 s, GetAssetInfo 78 ms, a
19
- * block by height 168 ms; with the indexes 0.2 ms each.
20
- *
21
- * Created at start with CREATE INDEX IF NOT EXISTS: idempotent, plain SQL
22
- * that SQLite and PostgreSQL both accept, identifiers unquoted so Postgres
23
- * folds them exactly like @cap-js/postgres folds the table names. A plain
24
- * CREATE INDEX locks the table against writes for the build; on a large
25
- * live PostgreSQL create them once beforehand with CONCURRENTLY (ODATANO
26
- * ACCESS's scripts/odatano-indexes-on-box.sh does that), then this is a
27
- * no-op at every boot. A failure is logged, never fatal: the service works
28
- * without them, only slower.
29
- *
30
- * HANA is skipped: its CREATE INDEX knows neither IF NOT EXISTS nor NULLS
31
- * LAST, and the column store keeps an inverted index per column anyway, so
32
- * these lookups do not scan there.
10
+ * Secondary indexes the CDS model cannot declare (temporal keys start with `validFrom`, so business-key
11
+ * lookups would scan). Created at start with CREATE INDEX IF NOT EXISTS, unquoted identifiers so Postgres
12
+ * folds them like @cap-js does; failures are logged, never fatal. HANA is skipped (column store, no IF NOT EXISTS).
33
13
  */
34
14
  const cds_1 = __importDefault(require("@sap/cds"));
35
15
  const logger = cds_1.default.log('DbIndexes');
36
- /** Every entry answers a query the service or the crawler actually runs (see the module doc). */
16
+ /** Every entry answers a query the service or the crawler actually runs. */
37
17
  exports.DB_INDEXES = Object.freeze([
38
18
  // Blocks: latest (ORDER BY height DESC), byHeight, crawler `height in`, rollback `slot >`, epoch filters
39
19
  { name: 'odatano_cardano_blocks_height', table: 'odatano_cardano_Blocks', columns: 'height' },
40
- // CAP renders `$orderby=height desc` as ORDER BY height DESC NULLS LAST, which the
41
- // plain (ASC NULLS LAST) index cannot serve backwards (200 ms sort on the box
42
- // with the plain index in place). This one serves it, and ASC NULLS FIRST
43
- // backwards; the plain one stays for plain ASC and equality.
20
+ // CAP renders `$orderby=height desc` as DESC NULLS LAST, which the plain ASC NULLS LAST
21
+ // index cannot serve backwards; the plain one stays for ASC and equality.
44
22
  { name: 'odatano_cardano_blocks_height_desc', table: 'odatano_cardano_Blocks', columns: 'height DESC', postgres: 'height DESC NULLS LAST' },
45
23
  { name: 'odatano_cardano_blocks_slot', table: 'odatano_cardano_Blocks', columns: 'slot' },
46
24
  { name: 'odatano_cardano_blocks_epoch', table: 'odatano_cardano_Blocks', columns: 'epochNumber' },
@@ -81,12 +59,7 @@ function indexStatement(spec, kind = 'sqlite') {
81
59
  const columns = kind === 'postgres' && spec.postgres ? spec.postgres : spec.columns;
82
60
  return `CREATE INDEX IF NOT EXISTS ${spec.name} ON ${spec.table} (${columns})`;
83
61
  }
84
- /**
85
- * Creates every index that does not exist yet. Returns the names it ran;
86
- * a failing statement is logged and skipped (a missing table on a partial
87
- * deployment, a database without the privilege), the others still run.
88
- * On HANA nothing runs (see the module doc).
89
- */
62
+ /** Creates every missing index; a failing statement is logged and skipped, the others still run. */
90
63
  async function ensureDbIndexes(runner = cds_1.default.db) {
91
64
  const ensured = [];
92
65
  const failed = [];
@@ -1,16 +1,8 @@
1
1
  /**
2
- * Last line of defence before writes to PostgreSQL.
3
- *
4
- * PostgreSQL cannot store U+0000 in `text`, and @cap-js/postgres passes bulk
5
- * INSERT/UPSERT rows as one JSON document whose parser rejects the escape
6
- * sequence for NUL ("unsupported Unicode escape sequence"). A single decoded
7
- * string with a NUL character therefore fails the whole write — a crawled block
8
- * or a lazily indexed request alike. Mappers avoid producing such strings (see
9
- * decodeAssetName); installDbSanitizer() guarantees it for every row this plugin
10
- * writes, whatever the source (provider JSON such as Koios' asset_name_ascii or
11
- * pool metadata included), by hooking the database service once per process.
2
+ * Strips U+0000 from every row this plugin writes: PostgreSQL cannot store NUL in `text`, and
3
+ * @cap-js/postgres bulk rows go through a JSON parser that rejects the NUL escape, failing the whole write.
12
4
  */
13
- /** Remove U+0000 from every string value of the row (nested plain objects included). Returns the same row when nothing changed. */
5
+ /** Remove U+0000 from every string value of the row (nested objects included); same row when unchanged. */
14
6
  export declare function stripNulStrings<T>(row: T): T;
15
7
  /** Sanitise a row array for the database; cheap when nothing needs changing. */
16
8
  export declare function sanitizeRows<T>(rows: T[]): T[];
@@ -21,18 +13,13 @@ export interface DbWriteRequest {
21
13
  name?: string;
22
14
  } | null;
23
15
  }
24
- /**
25
- * `before` handler for the database service: strips U+0000 from the rows of an
26
- * INSERT / UPSERT / UPDATE against one of this plugin's entities, in place.
27
- */
16
+ /** `before` handler for the db service: strips U+0000 from INSERT / UPSERT / UPDATE rows in place. */
28
17
  export declare function sanitizeDbRequest(req: DbWriteRequest): void;
29
18
  interface HookableService {
30
19
  before(event: string | string[], handler: (req: DbWriteRequest) => void): unknown;
31
20
  }
32
21
  /**
33
- * Hook the sanitizer into the database service (idempotent per service instance).
34
- * Called from the app-context bootstrap; a missing/unconnected db is a no-op so
35
- * unit tests and early programmatic initialize() calls never fail here.
22
+ * Hook the sanitizer into the database service (idempotent per instance; no-op without a db).
36
23
  * @returns true when the hook was installed by this call
37
24
  */
38
25
  export declare function installDbSanitizer(db?: HookableService | undefined): boolean;
@@ -9,18 +9,10 @@ exports.sanitizeDbRequest = sanitizeDbRequest;
9
9
  exports.installDbSanitizer = installDbSanitizer;
10
10
  const cds_1 = __importDefault(require("@sap/cds"));
11
11
  /**
12
- * Last line of defence before writes to PostgreSQL.
13
- *
14
- * PostgreSQL cannot store U+0000 in `text`, and @cap-js/postgres passes bulk
15
- * INSERT/UPSERT rows as one JSON document whose parser rejects the escape
16
- * sequence for NUL ("unsupported Unicode escape sequence"). A single decoded
17
- * string with a NUL character therefore fails the whole write — a crawled block
18
- * or a lazily indexed request alike. Mappers avoid producing such strings (see
19
- * decodeAssetName); installDbSanitizer() guarantees it for every row this plugin
20
- * writes, whatever the source (provider JSON such as Koios' asset_name_ascii or
21
- * pool metadata included), by hooking the database service once per process.
12
+ * Strips U+0000 from every row this plugin writes: PostgreSQL cannot store NUL in `text`, and
13
+ * @cap-js/postgres bulk rows go through a JSON parser that rejects the NUL escape, failing the whole write.
22
14
  */
23
- /** Remove U+0000 from every string value of the row (nested plain objects included). Returns the same row when nothing changed. */
15
+ /** Remove U+0000 from every string value of the row (nested objects included); same row when unchanged. */
24
16
  function stripNulStrings(row) {
25
17
  if (typeof row === 'string')
26
18
  return (row.includes('\u0000') ? row.replaceAll('\u0000', '') : row);
@@ -59,12 +51,9 @@ function sanitizeRows(rows) {
59
51
  }
60
52
  return out ?? rows;
61
53
  }
62
- /** Only this plugin's entities are rewritten — a consumer's own data is never touched. */
54
+ /** Only this plugin's entities are rewritten; a consumer's own data is never touched. */
63
55
  const OWN_NAMESPACE = 'odatano.cardano.';
64
- /**
65
- * `before` handler for the database service: strips U+0000 from the rows of an
66
- * INSERT / UPSERT / UPDATE against one of this plugin's entities, in place.
67
- */
56
+ /** `before` handler for the db service: strips U+0000 from INSERT / UPSERT / UPDATE rows in place. */
68
57
  function sanitizeDbRequest(req) {
69
58
  if (!req.target?.name?.startsWith(OWN_NAMESPACE))
70
59
  return;
@@ -83,9 +72,7 @@ function sanitizeDbRequest(req) {
83
72
  }
84
73
  const installed = new WeakSet();
85
74
  /**
86
- * Hook the sanitizer into the database service (idempotent per service instance).
87
- * Called from the app-context bootstrap; a missing/unconnected db is a no-op so
88
- * unit tests and early programmatic initialize() calls never fail here.
75
+ * Hook the sanitizer into the database service (idempotent per instance; no-op without a db).
89
76
  * @returns true when the hook was installed by this call
90
77
  */
91
78
  function installDbSanitizer(db = cds_1.default.db) {