@odatano/core 2.0.0-rc.5 → 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 (208) hide show
  1. package/@cds-models/CardanoAgentService/index.d.ts +99 -51
  2. package/@cds-models/CardanoAgentService/index.js +15 -0
  3. package/@cds-models/CardanoBackendService/index.d.ts +347 -0
  4. package/@cds-models/CardanoBackendService/index.js +40 -0
  5. package/@cds-models/CardanoIndexerService/index.d.ts +496 -11
  6. package/@cds-models/CardanoIndexerService/index.js +64 -0
  7. package/@cds-models/CardanoODataService/index.d.ts +414 -57
  8. package/@cds-models/CardanoODataService/index.js +42 -0
  9. package/@cds-models/CardanoSignService/index.d.ts +32 -19
  10. package/@cds-models/CardanoSignService/index.js +3 -0
  11. package/@cds-models/CardanoTransactionService/index.d.ts +58 -44
  12. package/@cds-models/CardanoTransactionService/index.js +4 -0
  13. package/@cds-models/CardanoWorkerService/index.d.ts +7 -22
  14. package/@cds-models/index.d.ts +101 -1
  15. package/@cds-models/index.js +16 -1
  16. package/@cds-models/odatano/cardano/index.d.ts +437 -32
  17. package/@cds-models/odatano/cardano/index.js +48 -0
  18. package/README.md +207 -167
  19. package/db/schema.cds +2402 -1705
  20. package/db/types.cds +446 -295
  21. package/package.json +41 -16
  22. package/scripts/migrate-schema.mjs +334 -0
  23. package/scripts/migrate-slot-leader.mjs +96 -0
  24. package/src/index.d.ts +20 -21
  25. package/src/index.js +45 -31
  26. package/src/plugin.js +17 -35
  27. package/srv/blockchain/asset-decimals.d.ts +7 -0
  28. package/srv/blockchain/asset-decimals.js +91 -0
  29. package/srv/blockchain/backends/blockfrost-backend.d.ts +25 -135
  30. package/srv/blockchain/backends/blockfrost-backend.js +66 -172
  31. package/srv/blockchain/backends/cardano-backend.d.ts +94 -186
  32. package/srv/blockchain/backends/cardano-backend.js +29 -5
  33. package/srv/blockchain/backends/koios-backend.d.ts +103 -168
  34. package/srv/blockchain/backends/koios-backend.js +428 -360
  35. package/srv/blockchain/backends/odatano-backend.d.ts +54 -0
  36. package/srv/blockchain/backends/odatano-backend.js +169 -0
  37. package/srv/blockchain/backends/ogmios-backend.d.ts +123 -190
  38. package/srv/blockchain/backends/ogmios-backend.js +637 -315
  39. package/srv/blockchain/backends/ogmios-frame-guard.d.ts +14 -0
  40. package/srv/blockchain/backends/ogmios-frame-guard.js +89 -0
  41. package/srv/blockchain/cardano-client.d.ts +61 -241
  42. package/srv/blockchain/cardano-client.js +253 -293
  43. package/srv/blockchain/cardano-indexer.d.ts +282 -281
  44. package/srv/blockchain/cardano-indexer.js +1551 -484
  45. package/srv/blockchain/cardano-tx-builder.d.ts +25 -89
  46. package/srv/blockchain/cardano-tx-builder.js +164 -140
  47. package/srv/blockchain/circuit-breaker.d.ts +1 -13
  48. package/srv/blockchain/circuit-breaker.js +5 -15
  49. package/srv/blockchain/crawler/account-snapshots.d.ts +29 -0
  50. package/srv/blockchain/crawler/account-snapshots.js +153 -0
  51. package/srv/blockchain/crawler/asset-decimals-backfill.d.ts +15 -0
  52. package/srv/blockchain/crawler/asset-decimals-backfill.js +56 -0
  53. package/srv/blockchain/crawler/asset-registry-backfill.d.ts +43 -0
  54. package/srv/blockchain/crawler/asset-registry-backfill.js +153 -0
  55. package/srv/blockchain/crawler/certificate-backfill.d.ts +52 -0
  56. package/srv/blockchain/crawler/certificate-backfill.js +162 -0
  57. package/srv/blockchain/crawler/crawler.d.ts +104 -81
  58. package/srv/blockchain/crawler/crawler.js +532 -160
  59. package/srv/blockchain/crawler/credential-backfill.d.ts +28 -0
  60. package/srv/blockchain/crawler/credential-backfill.js +124 -0
  61. package/srv/blockchain/crawler/hooks.d.ts +2 -17
  62. package/srv/blockchain/crawler/index.d.ts +1 -8
  63. package/srv/blockchain/crawler/index.js +31 -17
  64. package/srv/blockchain/crawler/input-asset-copies.d.ts +34 -0
  65. package/srv/blockchain/crawler/input-asset-copies.js +171 -0
  66. package/srv/blockchain/crawler/metadata-position-backfill.d.ts +16 -0
  67. package/srv/blockchain/crawler/metadata-position-backfill.js +55 -0
  68. package/srv/blockchain/crawler/output-datum-backfill.d.ts +39 -0
  69. package/srv/blockchain/crawler/output-datum-backfill.js +110 -0
  70. package/srv/blockchain/crawler/sync-state.d.ts +27 -47
  71. package/srv/blockchain/crawler/sync-state.js +113 -63
  72. package/srv/blockchain/crawler/transaction-backfill.d.ts +44 -0
  73. package/srv/blockchain/crawler/transaction-backfill.js +278 -0
  74. package/srv/blockchain/crawler/utxo-set-import.d.ts +66 -0
  75. package/srv/blockchain/crawler/utxo-set-import.js +399 -0
  76. package/srv/blockchain/ledger-state.d.ts +62 -0
  77. package/srv/blockchain/ledger-state.js +419 -0
  78. package/srv/blockchain/pending-spends.d.ts +16 -0
  79. package/srv/blockchain/pending-spends.js +81 -0
  80. package/srv/blockchain/pool-metadata.d.ts +15 -0
  81. package/srv/blockchain/pool-metadata.js +132 -0
  82. package/srv/blockchain/request-coalescer.d.ts +2 -16
  83. package/srv/blockchain/request-coalescer.js +2 -16
  84. package/srv/blockchain/signing/cose-verifier.d.ts +3 -17
  85. package/srv/blockchain/signing/cose-verifier.js +146 -70
  86. package/srv/blockchain/signing/external-signer.d.ts +15 -115
  87. package/srv/blockchain/signing/external-signer.js +17 -126
  88. package/srv/blockchain/signing/hsm-signer.d.ts +10 -54
  89. package/srv/blockchain/signing/hsm-signer.js +28 -79
  90. package/srv/blockchain/signing/signature-verifier.d.ts +9 -47
  91. package/srv/blockchain/signing/signature-verifier.js +70 -83
  92. package/srv/blockchain/signing/submission-finalizer.d.ts +23 -45
  93. package/srv/blockchain/signing/submission-finalizer.js +219 -86
  94. package/srv/blockchain/stored-chain.d.ts +20 -0
  95. package/srv/blockchain/stored-chain.js +237 -0
  96. package/srv/blockchain/transaction-building/buildooor-tx.d.ts +31 -229
  97. package/srv/blockchain/transaction-building/buildooor-tx.js +652 -416
  98. package/srv/blockchain/transaction-building/cardano-tx.d.ts +9 -37
  99. package/srv/blockchain/transaction-presence.d.ts +5 -0
  100. package/srv/blockchain/transaction-presence.js +29 -0
  101. package/srv/blockchain/transaction-rows.d.ts +12 -0
  102. package/srv/blockchain/transaction-rows.js +44 -0
  103. package/srv/blockchain/wallet-worker/build-request.d.ts +5 -20
  104. package/srv/blockchain/wallet-worker/build-request.js +47 -30
  105. package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +5 -46
  106. package/srv/blockchain/wallet-worker/confirmation-tracker.js +25 -45
  107. package/srv/blockchain/wallet-worker/index.d.ts +1 -1
  108. package/srv/blockchain/wallet-worker/index.js +3 -11
  109. package/srv/blockchain/wallet-worker/job-store.d.ts +30 -148
  110. package/srv/blockchain/wallet-worker/job-store.js +101 -201
  111. package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +2 -26
  112. package/srv/blockchain/wallet-worker/lease-heartbeat.js +6 -28
  113. package/srv/blockchain/wallet-worker/signers.d.ts +5 -24
  114. package/srv/blockchain/wallet-worker/signers.js +4 -12
  115. package/srv/blockchain/wallet-worker/wallet-worker.d.ts +8 -80
  116. package/srv/blockchain/wallet-worker/wallet-worker.js +107 -155
  117. package/srv/cardano-agent-service.cds +122 -84
  118. package/srv/cardano-agent-service.js +4 -9
  119. package/srv/cardano-backend-service.cds +78 -0
  120. package/srv/cardano-backend-service.d.ts +2 -0
  121. package/srv/cardano-backend-service.js +242 -0
  122. package/srv/cardano-indexer-service.cds +387 -73
  123. package/srv/cardano-indexer-service.d.ts +5 -1
  124. package/srv/cardano-indexer-service.js +532 -16
  125. package/srv/cardano-service.cds +424 -269
  126. package/srv/cardano-service.js +289 -201
  127. package/srv/cardano-sign-service.cds +201 -180
  128. package/srv/cardano-sign-service.js +71 -201
  129. package/srv/cardano-tx-service.cds +451 -370
  130. package/srv/cardano-tx-service.js +271 -289
  131. package/srv/cardano-ui.cds +16 -16
  132. package/srv/cardano-worker-service.cds +118 -125
  133. package/srv/cardano-worker-service.js +52 -61
  134. package/srv/cbor/cip68.d.ts +13 -0
  135. package/srv/cbor/cip68.js +56 -0
  136. package/srv/cbor/index.d.ts +3 -1
  137. package/srv/cbor/index.js +9 -1
  138. package/srv/cbor/parse.d.ts +30 -18
  139. package/srv/cbor/parse.js +44 -9
  140. package/srv/cbor/plutus-data-json.d.ts +20 -0
  141. package/srv/cbor/plutus-data-json.js +32 -0
  142. package/srv/config.d.ts +113 -0
  143. package/srv/config.js +409 -0
  144. package/srv/server.d.ts +15 -110
  145. package/srv/server.js +84 -404
  146. package/srv/utils/agent-access.d.ts +9 -0
  147. package/srv/utils/agent-access.js +67 -0
  148. package/srv/utils/agent-grants-config.d.ts +0 -46
  149. package/srv/utils/agent-grants-config.js +17 -85
  150. package/srv/utils/agent-grants.d.ts +106 -122
  151. package/srv/utils/agent-grants.js +538 -236
  152. package/srv/utils/agent-token-auth.d.ts +4 -99
  153. package/srv/utils/agent-token-auth.js +18 -182
  154. package/srv/utils/backend-request-handler.d.ts +3 -17
  155. package/srv/utils/backend-request-handler.js +3 -18
  156. package/srv/utils/collections.d.ts +3 -10
  157. package/srv/utils/collections.js +3 -10
  158. package/srv/utils/const.d.ts +23 -74
  159. package/srv/utils/const.js +32 -79
  160. package/srv/utils/crypto.d.ts +3 -12
  161. package/srv/utils/crypto.js +6 -21
  162. package/srv/utils/db-indexes.d.ts +27 -0
  163. package/srv/utils/db-indexes.js +120 -0
  164. package/srv/utils/db-sanitize.d.ts +20 -0
  165. package/srv/utils/db-sanitize.js +80 -0
  166. package/srv/utils/deep-json.d.ts +6 -0
  167. package/srv/utils/deep-json.js +240 -0
  168. package/srv/utils/epoch-slots.d.ts +13 -0
  169. package/srv/utils/epoch-slots.js +38 -0
  170. package/srv/utils/error-codes.d.ts +22 -75
  171. package/srv/utils/error-codes.js +23 -72
  172. package/srv/utils/errors.d.ts +46 -187
  173. package/srv/utils/errors.js +114 -230
  174. package/srv/utils/liveness.d.ts +12 -0
  175. package/srv/utils/liveness.js +35 -0
  176. package/srv/utils/mappers.d.ts +102 -223
  177. package/srv/utils/mappers.js +387 -316
  178. package/srv/utils/network-context.js +2 -13
  179. package/srv/utils/paging.d.ts +31 -0
  180. package/srv/utils/paging.js +43 -0
  181. package/srv/utils/pg-inline-json.d.ts +8 -0
  182. package/srv/utils/pg-inline-json.js +58 -0
  183. package/srv/utils/pg-order-nulls.d.ts +14 -0
  184. package/srv/utils/pg-order-nulls.js +54 -0
  185. package/srv/utils/plutus-placeholders.d.ts +16 -22
  186. package/srv/utils/plutus-placeholders.js +62 -33
  187. package/srv/utils/rate-limiter.d.ts +2 -21
  188. package/srv/utils/rate-limiter.js +5 -17
  189. package/srv/utils/readiness.d.ts +12 -0
  190. package/srv/utils/readiness.js +29 -0
  191. package/srv/utils/reference-script.d.ts +19 -0
  192. package/srv/utils/reference-script.js +84 -0
  193. package/srv/utils/result-numbers.d.ts +15 -0
  194. package/srv/utils/result-numbers.js +61 -0
  195. package/srv/utils/service-events.d.ts +0 -24
  196. package/srv/utils/service-events.js +3 -25
  197. package/srv/utils/signing-helper.d.ts +3 -20
  198. package/srv/utils/signing-helper.js +35 -64
  199. package/srv/utils/tx-build-helper.d.ts +10 -105
  200. package/srv/utils/tx-build-helper.js +81 -144
  201. package/srv/utils/tx-request-parsers.d.ts +82 -33
  202. package/srv/utils/tx-request-parsers.js +401 -49
  203. package/srv/utils/tx-utils.d.ts +3 -27
  204. package/srv/utils/tx-utils.js +32 -50
  205. package/srv/utils/types.d.ts +261 -191
  206. package/srv/utils/types.js +2 -6
  207. package/srv/utils/validators.d.ts +22 -92
  208. package/srv/utils/validators.js +50 -149
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odatano/core",
3
- "version": "2.0.0-rc.5",
3
+ "version": "2.0.0-rc.50",
4
4
  "description": "SAP CAP plugin for Cardano blockchain OData V4 integration",
5
5
  "imports": {
6
6
  "#cds-models/*": "./@cds-models/*/index.js"
@@ -15,24 +15,29 @@
15
15
  "srv/**/*.d.ts",
16
16
  "srv/**/*.cds",
17
17
  "db/**/*.cds",
18
- "@cds-models/"
18
+ "@cds-models/",
19
+ "scripts/migrate-schema.mjs",
20
+ "scripts/migrate-slot-leader.mjs"
19
21
  ],
20
22
  "engines": {
21
23
  "node": ">=22.5"
22
24
  },
23
25
  "peerDependencies": {
24
- "@sap/cds": ">=10"
26
+ "@sap/cds": "^10"
25
27
  },
26
28
  "dependencies": {
27
- "@blockfrost/blockfrost-js": "~6.0.0",
29
+ "@blockfrost/blockfrost-js": "~6.2.0",
28
30
  "@cap-js/hana": "^3",
29
- "@cardano-ogmios/client": "^6.14.0",
30
- "@harmoniclabs/buildooor": "0.2.9",
31
- "@harmoniclabs/cardano-costmodels-ts": "~1.6.1",
32
- "@harmoniclabs/cardano-ledger-ts": "^0.5.6",
33
- "@harmoniclabs/cbor": "^2.0.1",
34
- "@harmoniclabs/crypto": "^0.3.0",
31
+ "@cardano-ogmios/client": "^7.0.0",
32
+ "@harmoniclabs/buildooor": "0.3.0",
33
+ "@harmoniclabs/cardano-costmodels-ts": "~1.7.0",
34
+ "@harmoniclabs/cardano-ledger-ts": "^0.6.1",
35
+ "@harmoniclabs/cbor": "^2.1.0",
36
+ "@harmoniclabs/crypto": "^0.3.2",
37
+ "@harmoniclabs/plutus-data": "^2.1.1",
35
38
  "@harmoniclabs/uint8array-utils": "^1.0.4",
39
+ "@harmoniclabs/uplc": "^2.0.8",
40
+ "@odatano/cap-auth": "^0.1.0",
36
41
  "@sap/xssec": "^4",
37
42
  "axios": "^1.18.0",
38
43
  "bech32": "^2.0.0",
@@ -55,6 +60,7 @@
55
60
  "@cap-js/cds-test": "^0.4.1",
56
61
  "@cap-js/cds-typer": "^0.40.0",
57
62
  "@cap-js/cds-types": "^0.18.0",
63
+ "@cap-js/postgres": "^3.1.1",
58
64
  "@cap-js/sqlite": "^3",
59
65
  "@sap/cds": "^10",
60
66
  "@sap/cds-dk": "^10",
@@ -73,6 +79,18 @@
73
79
  "vitest": "^4.1.10"
74
80
  },
75
81
  "cds": {
82
+ "log": {
83
+ "mask_headers": [
84
+ "/authorization/i",
85
+ "/cookie/i",
86
+ "/cert/i",
87
+ "/ssl/i",
88
+ "/token/i",
89
+ "/key/i",
90
+ "/secret/i",
91
+ "/project_id/i"
92
+ ]
93
+ },
76
94
  "typer": {
77
95
  "ieee754compatible": true
78
96
  },
@@ -95,6 +113,9 @@
95
113
  "kind": "sqlite",
96
114
  "credentials": {
97
115
  "url": "db.sqlite"
116
+ },
117
+ "client": {
118
+ "timeout": 5000
98
119
  }
99
120
  },
100
121
  "[production]": {
@@ -124,15 +145,16 @@
124
145
  "lint": "eslint .",
125
146
  "typecheck": "tsc --noEmit",
126
147
  "db:deploy": "cds deploy",
127
- "pretest": "npm run clean && npm run cds:types && npm run db:deploy",
148
+ "db:fresh": "node -e \"for(const f of ['db.sqlite','db.sqlite-wal','db.sqlite-shm'])require('fs').rmSync(f,{force:true})\" && npm run db:deploy",
149
+ "pretest": "npm run clean && npm run cds:types && npm run db:fresh",
128
150
  "test": "vitest run",
129
- "pretest:coverage": "npm run clean && npm run cds:types && npm run db:deploy",
151
+ "pretest:coverage": "npm run clean && npm run cds:types && npm run db:fresh",
130
152
  "test:coverage": "vitest run --coverage",
131
- "pretest:ci": "npm run clean && npm run cds:types && npm run db:deploy",
153
+ "pretest:ci": "npm run clean && npm run cds:types && npm run db:fresh",
132
154
  "test:ci": "vitest run --exclude \"**/core-ogmios.test.ts\"",
133
- "pretest:ci:coverage": "npm run clean && npm run cds:types && npm run db:deploy",
155
+ "pretest:ci:coverage": "npm run clean && npm run cds:types && npm run db:fresh",
134
156
  "test:ci:coverage": "vitest run --coverage --exclude \"**/core-ogmios.test.ts\"",
135
- "pretest:integration": "npm run clean && npm run cds:types && npm run db:deploy",
157
+ "pretest:integration": "npm run clean && npm run cds:types && npm run db:fresh",
136
158
  "test:integration": "vitest run --project integration",
137
159
  "test:integration:blockfrost": "vitest run test/integration/core.blockfrost.test.ts",
138
160
  "test:integration:koios": "vitest run test/integration/core.koios.test.ts",
@@ -141,7 +163,10 @@
141
163
  "pretest:unit": "npm run cds:types",
142
164
  "test:unit": "vitest run --project unit",
143
165
  "watch-odatano": "cds watch --open odatano/index.html?sap-ui-xx-viewCache=false --livereload false",
144
- "watch-wallet": "cds watch --open wallet/webapp/index.html"
166
+ "watch-wallet": "cds watch --open wallet/webapp/index.html",
167
+ "release:check": "node scripts/release-check.mjs",
168
+ "smoke:consumer": "node scripts/smoke-consumer.mjs",
169
+ "prepublishOnly": "node scripts/publish-guard.mjs"
145
170
  },
146
171
  "sapux": [
147
172
  "app/odatano"
@@ -0,0 +1,334 @@
1
+ #!/usr/bin/env node
2
+ // Applies the schema changes the additive schema deploy refuses: a changed key, a changed column
3
+ // type, a dropped column, a renamed table. Every step runs only where it is still due.
4
+ // Run with ODATANO stopped, before the schema deploy. --dry-run only reports.
5
+ import cds from '@sap/cds';
6
+
7
+ const T = (name) => `odatano_cardano_${name}`;
8
+ const E = (name) => `odatano.cardano.${name}`;
9
+ const TX_SEQ_SLOT_FACTOR = 65536;
10
+ /** Column type the schema deploy creates for a timestamp, per database. */
11
+ const TIMESTAMP = { postgres: 'TIMESTAMP', sqlite: 'TIMESTAMP_TEXT' };
12
+
13
+ /** Column names of a table with their declared types, both lower-cased. Empty when the table is missing. */
14
+ export async function columnsOf(db, table) {
15
+ const rows = db.kind === 'postgres'
16
+ ? await db.run(`SELECT column_name AS name, data_type AS type FROM information_schema.columns WHERE table_schema = current_schema() AND table_name = '${table.toLowerCase()}'`)
17
+ : await db.run(`SELECT name, type FROM pragma_table_info('${table}')`);
18
+ return new Map(rows.map(r => [String(r.name).toLowerCase(), String(r.type).toLowerCase()]));
19
+ }
20
+
21
+ /** 'table', 'view' or null for a name in the current schema. */
22
+ export async function relationKind(db, name) {
23
+ const rows = db.kind === 'postgres'
24
+ ? await db.run(`SELECT CASE c.relkind WHEN 'v' THEN 'view' ELSE 'table' END AS kind FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace
25
+ WHERE n.nspname = current_schema() AND c.relkind IN ('r', 'p', 'v') AND c.relname = '${name.toLowerCase()}'`)
26
+ : await db.run(`SELECT type AS kind FROM sqlite_schema WHERE type IN ('table', 'view') AND lower(name) = '${name.toLowerCase()}'`);
27
+ return rows[0]?.kind ?? null;
28
+ }
29
+
30
+ /** True for a declared type that holds a time as plain text. */
31
+ export function isTextType(type) {
32
+ return /char|text|string/.test(type) && !type.includes('timestamp');
33
+ }
34
+
35
+ /** Counts the blocks whose time is not a UTC timestamp in ISO 8601 form. */
36
+ export function unparsableSql(kind) {
37
+ const pattern = kind === 'postgres'
38
+ ? `time !~ '^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]+)?Z$'`
39
+ : `time NOT GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9]*Z'`;
40
+ return `SELECT count(*) AS n FROM ${T('Blocks')} WHERE time IS NOT NULL AND ${pattern}`;
41
+ }
42
+
43
+ /** CREATE TABLE statement of a SQLite table under a new name, with `time` declared as a timestamp. */
44
+ export function rebuiltTableSql(createSql, table, newName) {
45
+ const retyped = createSql.replace(/(\btime\s+)N?VARCHAR\s*\(\s*\d+\s*\)/i, `$1${TIMESTAMP.sqlite}`);
46
+ if (retyped === createSql) throw new Error(`${table}: no text column time in its table definition`);
47
+ return retyped.replace(new RegExp(`^(\\s*CREATE TABLE\\s+)"?${table}"?`, 'i'), `$1${newName}`);
48
+ }
49
+
50
+ // Tables that moved from the transaction hash to Transactions.txSeq as their key.
51
+ // `to` is the entity that holds the rows in the model of this version.
52
+ const TX_SEQ_TABLES = [
53
+ { from: 'TransactionInputs', to: 'TransactionInputs', hashKey: 'tx_hash', seqKey: 'txSeq', order: 'inputIndex' },
54
+ { from: 'TransactionOutputs', to: 'TransactionOutputs', hashKey: 'tx_hash', seqKey: 'txSeq', order: 'outputIndex' },
55
+ { from: 'TransactionInputAssets', to: 'TransactionInputAssetCopies', hashKey: 'input_tx_hash', seqKey: 'input_txSeq', order: 'input_inputIndex, unit' },
56
+ { from: 'TransactionOutputAssets', to: 'TransactionOutputAssets', hashKey: 'output_tx_hash', seqKey: 'output_txSeq', order: 'output_outputIndex, unit' },
57
+ ];
58
+
59
+ /** Copy statement: the given columns of the old table, the new key from Transactions. */
60
+ export function copySql(spec, columns, target) {
61
+ const others = columns.filter(c => c !== spec.hashKey.toLowerCase());
62
+ const into = [spec.seqKey, ...others].join(', ');
63
+ const source = ['t.txSeq', ...others.map(c => `x.${c}`)].join(', ');
64
+ const order = ['t.txSeq', ...spec.order.split(',').map(c => `x.${c.trim()}`)].join(', ');
65
+ return `INSERT INTO ${target} (${into}) SELECT ${source} FROM ${T(spec.from)} x `
66
+ + `JOIN ${T('Transactions')} t ON t.hash = x.${spec.hashKey} ORDER BY ${order}`;
67
+ }
68
+
69
+ async function count(tx, table) {
70
+ const [row] = await tx.run(`SELECT count(*) AS n FROM ${table}`);
71
+ return Number(row.n);
72
+ }
73
+
74
+ // The steps, oldest first. `due` says whether the database still needs the step (`pending` names the
75
+ // earlier steps that are due), `apply` changes the database, `model` makes the stored model say the same.
76
+ export const STEPS = [
77
+ {
78
+ name: 'transaction inputs and outputs keyed by txSeq',
79
+ async due(db) {
80
+ if (!(await columnsOf(db, T('TransactionInputs'))).has('tx_hash')) return false;
81
+ const open = Number((await db.run(`SELECT count(*) AS n FROM ${T('Transactions')} WHERE slot IS NULL OR txIndex IS NULL`))[0].n);
82
+ if (open > 0) throw new Error(`${open} transactions have no slot or txIndex; their txSeq cannot be derived`);
83
+ return true;
84
+ },
85
+ async apply(tx, { ddl, log }) {
86
+ if (!(await columnsOf(tx, T('Transactions'))).has('txseq')) await tx.run(`ALTER TABLE ${T('Transactions')} ADD COLUMN txSeq BIGINT`);
87
+ await tx.run(`UPDATE ${T('Transactions')} SET txSeq = slot * ${TX_SEQ_SLOT_FACTOR} + txIndex`);
88
+ await tx.run(`CREATE INDEX IF NOT EXISTS odatano_cardano_transactions_txseq ON ${T('Transactions')} (txSeq)`);
89
+
90
+ for (const spec of TX_SEQ_TABLES) {
91
+ const from = T(spec.from);
92
+ const to = T(spec.to);
93
+ const rebuilt = `${to}_txseq_new`;
94
+ const rows = await count(tx, from);
95
+ await tx.run(ddl(spec.to).replace(new RegExp(`^(\\s*CREATE TABLE )${to}\\b`, 'i'), `$1${rebuilt}`));
96
+ // only columns both layouts have: a column this version dropped stays behind
97
+ const kept = new Set((await columnsOf(tx, rebuilt)).keys());
98
+ const columns = [...(await columnsOf(tx, from)).keys()].filter(c => c === spec.hashKey.toLowerCase() || kept.has(c));
99
+ await tx.run(copySql(spec, columns, rebuilt));
100
+ const copied = await count(tx, rebuilt);
101
+ if (copied !== rows) throw new Error(`${from}: ${rows} rows, ${copied} copied (rows without a Transactions row?)`);
102
+ await tx.run(`DROP TABLE ${from}`);
103
+ await tx.run(`ALTER TABLE ${rebuilt} RENAME TO ${to}`);
104
+ if (tx.kind === 'postgres') {
105
+ await tx.run(`ALTER TABLE ${to} RENAME CONSTRAINT ${rebuilt.toLowerCase()}_pkey TO ${to.toLowerCase()}_pkey`);
106
+ }
107
+ log(`${to}: ${copied} rows`);
108
+ }
109
+ // fresh planner statistics: without them the rebuilt tables are read by sequential scans
110
+ for (const name of ['Transactions', ...TX_SEQ_TABLES.map(t => t.to)]) await tx.run(`ANALYZE ${T(name)}`);
111
+ },
112
+ model(definitions, image) {
113
+ delete definitions[E('TransactionInputAssets')];
114
+ for (const spec of TX_SEQ_TABLES) definitions[E(spec.to)] = image[E(spec.to)];
115
+ const transactions = definitions[E('Transactions')];
116
+ if (transactions?.elements) transactions.elements.txSeq = image[E('Transactions')].elements.txSeq;
117
+ },
118
+ },
119
+ {
120
+ name: 'Blocks.time: text -> timestamp',
121
+ async due(db) {
122
+ const type = (await columnsOf(db, T('Blocks'))).get('time');
123
+ if (type === undefined || !isTextType(type)) return false;
124
+ const unparsable = Number((await db.run(unparsableSql(db.kind)))[0].n);
125
+ if (unparsable > 0) throw new Error(`${unparsable} blocks hold a time that is no ISO 8601 UTC timestamp`);
126
+ return `${await count(db, T('Blocks'))} rows`;
127
+ },
128
+ async apply(tx) {
129
+ const table = T('Blocks');
130
+ if (tx.kind === 'postgres') {
131
+ await tx.run(`ALTER TABLE ${table} ALTER COLUMN time TYPE ${TIMESTAMP.postgres} USING (time::timestamptz AT TIME ZONE 'UTC')`);
132
+ return;
133
+ }
134
+ // SQLite cannot change a column's type: the table is rebuilt with the same rows
135
+ const rebuilt = `${table}_time_new`;
136
+ const rows = await count(tx, table);
137
+ const [stored] = await tx.run(`SELECT sql FROM sqlite_schema WHERE type = 'table' AND name = '${table}'`);
138
+ await tx.run(rebuiltTableSql(stored.sql, table, rebuilt));
139
+ await tx.run(`INSERT INTO ${rebuilt} SELECT * FROM ${table}`);
140
+ const copied = await count(tx, rebuilt);
141
+ if (copied !== rows) throw new Error(`${table}: ${rows} rows, ${copied} copied`);
142
+ await tx.run(`DROP TABLE ${table}`);
143
+ await tx.run(`ALTER TABLE ${rebuilt} RENAME TO ${table}`);
144
+ },
145
+ model(definitions, image) {
146
+ const stored = definitions[E('Blocks')];
147
+ if (stored?.elements?.time) stored.elements.time = image[E('Blocks')].elements.time;
148
+ },
149
+ },
150
+ {
151
+ name: 'CardanoAgentGrants: columns walletId and allowedJobKinds removed',
152
+ async due(db) {
153
+ const columns = await columnsOf(db, T('CardanoAgentGrants'));
154
+ return columns.has('walletid') || columns.has('allowedjobkinds');
155
+ },
156
+ async apply(tx) {
157
+ const columns = await columnsOf(tx, T('CardanoAgentGrants'));
158
+ for (const column of ['walletId', 'allowedJobKinds']) {
159
+ if (columns.has(column.toLowerCase())) await tx.run(`ALTER TABLE ${T('CardanoAgentGrants')} DROP COLUMN ${column}`);
160
+ }
161
+ },
162
+ model(definitions) {
163
+ const elements = definitions[E('CardanoAgentGrants')]?.elements ?? {};
164
+ delete elements.walletId;
165
+ delete elements.allowedJobKinds;
166
+ },
167
+ },
168
+ {
169
+ name: 'TransactionInputAssets: table renamed to TransactionInputAssetCopies',
170
+ async due(db, pending) {
171
+ // the txSeq step builds the table under its new name already
172
+ if (pending.includes(STEPS[0].name)) return false;
173
+ if (await relationKind(db, T('TransactionInputAssets')) !== 'table') return false;
174
+ if (await relationKind(db, T('TransactionInputAssetCopies'))) {
175
+ throw new Error(`${T('TransactionInputAssets')} and ${T('TransactionInputAssetCopies')} both exist as tables`);
176
+ }
177
+ return true;
178
+ },
179
+ async apply(tx) {
180
+ const from = T('TransactionInputAssets');
181
+ const to = T('TransactionInputAssetCopies');
182
+ await tx.run(`ALTER TABLE ${from} RENAME TO ${to}`);
183
+ if (tx.kind !== 'postgres') return;
184
+ const [key] = await tx.run(`SELECT 1 AS x FROM pg_constraint WHERE conname = '${from.toLowerCase()}_pkey' AND connamespace = current_schema()::regnamespace`);
185
+ if (key) await tx.run(`ALTER TABLE ${to} RENAME CONSTRAINT ${from.toLowerCase()}_pkey TO ${to.toLowerCase()}_pkey`);
186
+ },
187
+ model(definitions, image) {
188
+ delete definitions[E('TransactionInputAssets')];
189
+ definitions[E('TransactionInputAssetCopies')] = image[E('TransactionInputAssetCopies')];
190
+ // the deploy adds the association to the view again; it has no column
191
+ delete definitions[E('TransactionInputs')]?.elements?.assets;
192
+ },
193
+ },
194
+ ];
195
+
196
+ /** Names of all views of the schema, the ones created last first. */
197
+ async function viewNames(db) {
198
+ const rows = db.kind === 'postgres'
199
+ ? await db.run(`SELECT c.relname AS name FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace
200
+ WHERE c.relkind = 'v' AND n.nspname = current_schema() ORDER BY c.oid DESC`)
201
+ : await db.run(`SELECT name FROM sqlite_schema WHERE type = 'view' ORDER BY rowid DESC`);
202
+ return rows.map(r => r.name);
203
+ }
204
+
205
+ async function hasModelTable(db) {
206
+ const [found] = await db.run(db.kind === 'postgres'
207
+ ? `SELECT 1 AS x FROM pg_tables WHERE tablename = 'cds_model' AND schemaname = current_schema()`
208
+ : `SELECT 1 AS x FROM sqlite_schema WHERE name = 'cds_model'`);
209
+ return Boolean(found);
210
+ }
211
+
212
+ /** The model of this version as the schema deploy stores it, and the CREATE TABLE statement of an entity. */
213
+ async function modelOfThisVersion(db) {
214
+ const model = await cds.load('*').then(cds.minify);
215
+ cds.deploy.exclude_external_entities_in(model);
216
+ const options = { ...db.options };
217
+ const statements = cds.compile.to.sql(model, options);
218
+ const ddl = (name) => {
219
+ const found = statements.find(s => new RegExp(`^CREATE TABLE ${T(name)} \\(`, 'i').test(s.trim()));
220
+ if (!found) throw new Error(`the model has no table ${T(name)}`);
221
+ return found;
222
+ };
223
+ return { image: cds.compile.to.sql.delta(model, options).afterImage, ddl };
224
+ }
225
+
226
+ const isView = (def) => Boolean(def.query || def.projection);
227
+
228
+ // The model of this version cut down to what the database holds: its tables and their columns,
229
+ // no views. The schema deploy then adds exactly what is missing.
230
+ export async function modelOfDatabase(db, image) {
231
+ const definitions = {};
232
+ for (const [name, def] of Object.entries(image.definitions)) {
233
+ if (def.kind !== 'entity') { definitions[name] = def; continue; }
234
+ if (isView(def)) continue;
235
+ const columns = await columnsOf(db, name.replace(/\./g, '_'));
236
+ if (!columns.size) continue;
237
+ const elements = Object.fromEntries(Object.entries(def.elements ?? {}).filter(([, element]) => {
238
+ const column = element['@cds.persistence.name'];
239
+ return column === undefined || columns.has(String(column).toLowerCase());
240
+ }));
241
+ definitions[name] = { ...def, elements };
242
+ }
243
+ return { ...image, definitions };
244
+ }
245
+
246
+ /** Waits for the first connection, which can take longer than the pool waits for one. */
247
+ async function connected(db) {
248
+ for (let attempt = 1; ; attempt++) {
249
+ try {
250
+ return await db.run('SELECT 1 AS x');
251
+ } catch (err) {
252
+ if (attempt === 15) throw err;
253
+ }
254
+ }
255
+ }
256
+
257
+ /** The steps the database still needs, with what `due` reported for each. */
258
+ async function dueSteps(db) {
259
+ const due = [];
260
+ for (const step of STEPS) {
261
+ const detail = await step.due(db, due.map(d => d.step.name));
262
+ if (detail) due.push({ step, detail });
263
+ }
264
+ return due;
265
+ }
266
+
267
+ // Brings an existing database to the point where the additive schema deploy can take over, and
268
+ // returns the names of the steps it ran. A database without a stored model gets one here.
269
+ // Whenever it changes something the views are gone afterwards; the deploy creates them.
270
+ export async function migrateSchema(db, { dryRun = false, log = console.log } = {}) {
271
+ if (db.kind !== 'postgres' && db.kind !== 'sqlite') return [];
272
+ await connected(db);
273
+
274
+ const due = await dueSteps(db);
275
+ const stored = await hasModelTable(db);
276
+ // a database that holds none of our tables is new: the deploy creates it
277
+ const adopt = !stored && (await columnsOf(db, T('Blocks'))).size > 0;
278
+ if (!due.length && !adopt) return [];
279
+
280
+ const [lease] = await db.run(`SELECT leaseUntil FROM ${T('CardanoSyncState')}`).catch(() => []);
281
+ const leaseUntil = lease?.leaseUntil ?? lease?.leaseuntil;
282
+ if (leaseUntil && Date.parse(leaseUntil) > Date.now()) {
283
+ throw new Error(`the crawler lease is held until ${leaseUntil}: stop ODATANO first`);
284
+ }
285
+
286
+ for (const { step, detail } of due) log(`due: ${step.name}${detail === true ? '' : ` (${detail})`}`);
287
+ if (adopt) log('due: the database has no stored model (cds_model), it is written from its tables');
288
+ const names = due.map(d => d.step.name);
289
+ if (dryRun) { log('dry run: nothing changed'); return names; }
290
+
291
+ const { image, ddl } = await modelOfThisVersion(db);
292
+ const views = await viewNames(db);
293
+ await db.tx(async (tx) => {
294
+ const started = Date.now();
295
+ const done = (msg) => log(`[${Math.round((Date.now() - started) / 1000)}s] ${msg}`);
296
+
297
+ for (const name of views) await tx.run(`DROP VIEW IF EXISTS "${name}"${db.kind === 'postgres' ? ' CASCADE' : ''}`);
298
+ done(`${views.length} views dropped`);
299
+
300
+ const model = stored ? JSON.parse((await tx.run('SELECT csn FROM cds_model'))[0].csn) : null;
301
+ for (const { step } of due) {
302
+ await step.apply(tx, { ddl, log: done });
303
+ if (model) step.model(model.definitions, image.definitions);
304
+ done(step.name);
305
+ }
306
+
307
+ if (model) {
308
+ // the stored model lists no view any more, so the deploy creates every view of this version
309
+ for (const [name, def] of Object.entries(model.definitions)) {
310
+ if (isView(def)) delete model.definitions[name];
311
+ }
312
+ await tx.run(db.kind === 'postgres' ? 'UPDATE cds_model SET csn = $1' : 'UPDATE cds_model SET csn = ?', [JSON.stringify(model)]);
313
+ } else {
314
+ const csn = JSON.stringify(await modelOfDatabase(tx, image));
315
+ await tx.run(`CREATE TABLE cds_model (csn ${db.kind === 'postgres' ? 'TEXT' : 'CLOB'})`);
316
+ await tx.run(db.kind === 'postgres' ? 'INSERT INTO cds_model VALUES ($1)' : 'INSERT INTO cds_model VALUES (?)', [csn]);
317
+ }
318
+ done(`cds_model ${model ? 'updated' : 'written'}`);
319
+ });
320
+ return adopt ? [...names, 'stored model written'] : names;
321
+ }
322
+
323
+ async function main() {
324
+ const db = await cds.connect.to('db');
325
+ if (db.kind !== 'postgres' && db.kind !== 'sqlite') throw new Error(`unsupported database kind ${db.kind}`);
326
+ const dryRun = process.argv.includes('--dry-run');
327
+ const ran = await migrateSchema(db, { dryRun });
328
+ if (!ran.length) console.log('The schema needs no migration.');
329
+ else if (!dryRun) console.log('Migrated. Deploy the schema now; it creates the views again.');
330
+ }
331
+
332
+ if (process.argv[1] && import.meta.url === (await import('node:url')).pathToFileURL(process.argv[1]).href) {
333
+ main().then(() => process.exit(0), (err) => { console.error(`FAILED: ${err.message}`); process.exit(1); });
334
+ }
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env node
2
+ // Reads old Blocks.slotLeader values on stdin and prints SQL that rewrites them to bech32 pool ids.
3
+ // Issuer keys are hashed. VRF keys are matched via --stake-pools. Unmapped values go to stderr.
4
+ // --extra-map supplies those as "<old value> <pool id>" lines. The database is not touched.
5
+ import fs from 'node:fs';
6
+ import { pathToFileURL } from 'node:url';
7
+ import { bech32 } from 'bech32';
8
+ import { blake2b_224, blake2b_256 } from '@harmoniclabs/crypto';
9
+
10
+ const toHex = (bytes) => Buffer.from(bytes).toString('hex');
11
+ const lines = (text) => text.split(/\r?\n/).map(l => l.trim()).filter(Boolean);
12
+
13
+ /** VRF key hash (hex) -> pool id, from an Ogmios stakePools response (whole JSON-RPC reply or its result). */
14
+ export function vrfMapFromStakePools(response) {
15
+ const pools = response?.result ?? response ?? {};
16
+ const map = new Map();
17
+ for (const [id, pool] of Object.entries(pools)) {
18
+ const vrf = pool?.vrfVerificationKeyHash;
19
+ if (typeof vrf === 'string') map.set(vrf.toLowerCase(), pool.id ?? id);
20
+ }
21
+ return map;
22
+ }
23
+
24
+ /** "<old value> <pool id>" lines to a Map; lines starting with # are skipped. */
25
+ export function parseExtraMap(text) {
26
+ const map = new Map();
27
+ for (const line of lines(text)) {
28
+ if (line.startsWith('#')) continue;
29
+ const [from, to] = line.split(/\s+/);
30
+ if (!to?.startsWith('pool1')) throw new Error(`extra map: no pool id for ${from}`);
31
+ map.set(from, to);
32
+ }
33
+ return map;
34
+ }
35
+
36
+ /** Bech32 pool id for an old slotLeader value, or null when it cannot be derived. */
37
+ export function slotLeaderToPoolId(value, vrfMap = new Map()) {
38
+ if (typeof value !== 'string') return null;
39
+ const v = value.trim();
40
+ if (/^[0-9a-f]{64}$/i.test(v)) {
41
+ return bech32.encode('pool', bech32.toWords(blake2b_224(Uint8Array.from(Buffer.from(v, 'hex')))));
42
+ }
43
+ if (v.startsWith('vrf_vk1')) {
44
+ const { words } = bech32.decode(v, 120);
45
+ const vrfHash = toHex(blake2b_256(Uint8Array.from(bech32.fromWords(words))));
46
+ return vrfMap.get(vrfHash) ?? null;
47
+ }
48
+ return null;
49
+ }
50
+
51
+ const sqlString = (s) => `'${s.replace(/'/g, "''")}'`;
52
+
53
+ /** SQL that rewrites every mapped value in one UPDATE; empty string when nothing maps. */
54
+ export function migrationSql(mapping) {
55
+ if (mapping.size === 0) return '';
56
+ const rows = [...mapping].map(([from, to]) => ` (${sqlString(from)}, ${sqlString(to)})`);
57
+ return [
58
+ 'BEGIN;',
59
+ 'CREATE TEMPORARY TABLE slot_leader_map (old_value VARCHAR(200) PRIMARY KEY, new_value VARCHAR(120) NOT NULL);',
60
+ `INSERT INTO slot_leader_map (old_value, new_value) VALUES\n${rows.join(',\n')};`,
61
+ 'UPDATE odatano_cardano_Blocks',
62
+ ' SET slotLeader = (SELECT m.new_value FROM slot_leader_map m WHERE m.old_value = odatano_cardano_Blocks.slotLeader)',
63
+ ' WHERE slotLeader IN (SELECT old_value FROM slot_leader_map);',
64
+ 'DROP TABLE slot_leader_map;',
65
+ 'COMMIT;',
66
+ '',
67
+ ].join('\n');
68
+ }
69
+
70
+ function argValue(name) {
71
+ const i = process.argv.indexOf(name);
72
+ return i >= 0 ? process.argv[i + 1] : undefined;
73
+ }
74
+
75
+ function main() {
76
+ const stakePoolsFile = argValue('--stake-pools');
77
+ const extraMapFile = argValue('--extra-map');
78
+ const vrfMap = stakePoolsFile ? vrfMapFromStakePools(JSON.parse(fs.readFileSync(stakePoolsFile, 'utf8'))) : new Map();
79
+ const extraMap = extraMapFile ? parseExtraMap(fs.readFileSync(extraMapFile, 'utf8')) : new Map();
80
+
81
+ const values = [...new Set(lines(fs.readFileSync(0, 'utf8')))];
82
+ const mapping = new Map();
83
+ const unmapped = [];
84
+ for (const v of values) {
85
+ if (v.startsWith('pool1')) continue;
86
+ const poolId = extraMap.get(v) ?? slotLeaderToPoolId(v, vrfMap);
87
+ if (poolId) mapping.set(v, poolId);
88
+ else unmapped.push(v);
89
+ }
90
+
91
+ process.stdout.write(migrationSql(mapping));
92
+ console.error(`slotLeader values: ${values.length} read, ${mapping.size} mapped, ${unmapped.length} left unchanged`);
93
+ for (const v of unmapped) console.error(` unmapped: ${v}`);
94
+ }
95
+
96
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) main();
package/src/index.d.ts CHANGED
@@ -1,32 +1,31 @@
1
+ import type { TransactionConfirmations } from '../srv/utils/types';
1
2
  export { CardanoClient } from '../srv/blockchain/cardano-client';
2
- export type { CardanoClientConfig, Network, BackendName, TransactionBuilderName } from '../srv/blockchain/cardano-client';
3
+ export type { CardanoClientConfig, Network, BackendName } from '../srv/blockchain/cardano-client';
3
4
  export { CardanoIndexer } from '../srv/blockchain/cardano-indexer';
4
5
  export { CardanoTransactionBuilder } from '../srv/blockchain/cardano-tx-builder';
5
- export { getAppContext, getCardanoIndexer, getCardanoClient, getCardanoTxBuilder, loadConfigFromEnv, loadHsmConfigFromEnv, loadCrawlerConfigFromEnv, startCrawlerIfConfigured, loadWalletWorkerConfigFromEnv, startWalletWorkerIfConfigured, shutdownAppContext, } from '../srv/server';
6
+ export { getAppContext, getCardanoIndexer, getCardanoClient, getCardanoTxBuilder, startCrawlerIfConfigured, startWalletWorkerIfConfigured, shutdownAppContext, } from '../srv/server';
7
+ export { loadConfigFromEnv, loadHsmConfigFromEnv, loadCrawlerConfigFromEnv, loadWalletWorkerConfigFromEnv, loadAgentGrantsConfig, } from '../srv/config';
8
+ export type { AgentGrantsConfig } from '../srv/config';
6
9
  export { getHsmSigner } from '../srv/blockchain/signing/hsm-signer';
7
- export { issueAgentGrant, revokeAgentGrantById, hashAgentToken, AGENT_TOKEN_HEADER, AGENT_TOKEN_PREFIX, AGENT_ROLE, AGENT_ALLOWLISTABLE_ACTIONS, AGENT_ALWAYS_ALLOWED_EVENTS, } from '../srv/utils/agent-grants';
8
- export type { IssueAgentGrantInput, IssuedAgentGrant, AgentGrantStatus } from '../srv/utils/agent-grants';
9
- export { registerTransportLane } from '../srv/utils/agent-token-auth';
10
- export type { TransportLane, LaneOutcome } from '../srv/utils/agent-token-auth';
11
- export { loadAgentGrantsConfig } from '../srv/utils/agent-grants-config';
12
- export type { AgentGrantsConfig } from '../srv/utils/agent-grants-config';
10
+ export { issueAgentGrant, updateAgentGrant, rotateAgentGrantToken, revokeAgentGrantById, getGrantUsage, resolveUsageWindow, hashAgentToken, AGENT_TOKEN_HEADER, AGENT_TOKEN_PREFIX, AGENT_ROLE, } from '../srv/utils/agent-grants';
11
+ export { agentAccessOf, agentGrantableActions } from '../srv/utils/agent-access';
12
+ export type { AgentAccess } from '../srv/utils/agent-access';
13
+ export type { IssueAgentGrantInput, IssuedAgentGrant, AgentGrantStatus, UpdateAgentGrantInput, UpdateAgentGrantResult, RotatedAgentGrant, AgentGrantUsage, GrantUsageCall, UsageWindow, } from '../srv/utils/agent-grants';
14
+ export { registerTransportLane } from '@odatano/cap-auth';
15
+ export type { TransportLane, LaneOutcome } from '@odatano/cap-auth';
13
16
  export type { HsmConfig, HsmSignResult } from '../srv/utils/types';
14
17
  export { parseTransaction } from '../srv/cbor';
15
- export type { ParsedTransaction, ParsedInput, ParsedOutput, ParsedAsset, ParsedWitnesses, } from '../srv/cbor';
16
- /**
17
- * Initialize the ODATANO plugin.
18
- * Loads configuration from cds.env.requires["odatano-core"] OR environment variables,
19
- * then initializes all blockchain components.
20
- */
18
+ export type { ParsedTransaction, ParsedInput, ParsedOutput, ParsedAsset, ParsedWitnesses, ParsedWithdrawal, ParsedCertificate, } from '../srv/cbor';
19
+ export { verifyTxWitnesses } from '../srv/blockchain/signing/signature-verifier';
20
+ export { posixToSlot, slotToPosixMs } from '../srv/utils/epoch-slots';
21
+ export type { TxWitnessVerification, TransactionConfirmations } from '../srv/utils/types';
22
+ export { applyScriptParameters, plutusScriptHash } from '../srv/utils/tx-build-helper';
21
23
  export declare function initialize(): Promise<void>;
22
- /**
23
- * Shutdown the ODATANO plugin.
24
- * Cleans up all backend connections (especially Ogmios WebSocket).
25
- */
24
+ /** Shut down the plugin and close all backend connections. */
26
25
  export declare function shutdown(): Promise<void>;
27
- /**
28
- * Get the current status of the plugin.
29
- */
26
+ /** Confirmations of a transaction; needs initialize(). See CardanoIndexer.resolveTransactionConfirmations. */
27
+ export declare function getTransactionConfirmations(txHash: string): Promise<TransactionConfirmations>;
28
+ /** Current plugin status. */
30
29
  export declare function getStatus(): {
31
30
  initialized: boolean;
32
31
  network?: string;