@odatano/core 1.10.0 → 2.0.0-rc.1

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 (118) hide show
  1. package/@cds-models/CardanoIndexerService/index.d.ts +142 -0
  2. package/@cds-models/CardanoIndexerService/index.js +23 -0
  3. package/@cds-models/CardanoODataService/index.d.ts +693 -2172
  4. package/@cds-models/CardanoODataService/index.js +88 -390
  5. package/@cds-models/CardanoSignService/index.d.ts +443 -1574
  6. package/@cds-models/CardanoSignService/index.js +62 -293
  7. package/@cds-models/CardanoTransactionService/index.d.ts +431 -1488
  8. package/@cds-models/CardanoTransactionService/index.js +60 -271
  9. package/@cds-models/CardanoWorkerService/index.d.ts +224 -0
  10. package/@cds-models/CardanoWorkerService/index.js +32 -0
  11. package/@cds-models/_/index.d.ts +70 -40
  12. package/@cds-models/_/index.js +17 -32
  13. package/@cds-models/cds/outbox/index.d.ts +28 -0
  14. package/@cds-models/index.d.ts +225 -522
  15. package/@cds-models/index.js +35 -218
  16. package/@cds-models/odatano/cardano/index.d.ts +896 -2947
  17. package/@cds-models/odatano/cardano/index.js +109 -536
  18. package/@cds-models/sap/common/index.d.ts +196 -600
  19. package/@cds-models/sap/common/index.js +28 -269
  20. package/README.md +136 -102
  21. package/db/schema.cds +283 -1
  22. package/db/types.cds +48 -0
  23. package/package.json +43 -34
  24. package/src/index.d.ts +1 -1
  25. package/src/index.js +10 -2
  26. package/src/plugin.js +12 -2
  27. package/srv/blockchain/backends/blockfrost-backend.d.ts +21 -2
  28. package/srv/blockchain/backends/blockfrost-backend.js +68 -15
  29. package/srv/blockchain/backends/cardano-backend.d.ts +69 -0
  30. package/srv/blockchain/backends/cardano-backend.js +13 -0
  31. package/srv/blockchain/backends/koios-backend.d.ts +26 -2
  32. package/srv/blockchain/backends/koios-backend.js +147 -15
  33. package/srv/blockchain/backends/ogmios-backend.d.ts +37 -6
  34. package/srv/blockchain/backends/ogmios-backend.js +254 -5
  35. package/srv/blockchain/cardano-client.d.ts +19 -0
  36. package/srv/blockchain/cardano-client.js +36 -0
  37. package/srv/blockchain/cardano-indexer.d.ts +50 -1
  38. package/srv/blockchain/cardano-indexer.js +191 -0
  39. package/srv/blockchain/crawler/crawler.d.ts +151 -0
  40. package/srv/blockchain/crawler/crawler.js +677 -0
  41. package/srv/blockchain/crawler/hooks.d.ts +43 -0
  42. package/srv/blockchain/crawler/hooks.js +62 -0
  43. package/srv/blockchain/crawler/index.d.ts +26 -0
  44. package/srv/blockchain/crawler/index.js +135 -0
  45. package/srv/blockchain/crawler/sync-state.d.ts +94 -0
  46. package/srv/blockchain/crawler/sync-state.js +265 -0
  47. package/srv/blockchain/signing/hsm-signer.d.ts +45 -0
  48. package/srv/blockchain/signing/hsm-signer.js +8 -1
  49. package/srv/blockchain/signing/signature-verifier.js +4 -5
  50. package/srv/blockchain/transaction-building/buildooor-tx.d.ts +7 -10
  51. package/srv/blockchain/transaction-building/buildooor-tx.js +12 -15
  52. package/srv/blockchain/wallet-worker/build-request.d.ts +26 -0
  53. package/srv/blockchain/wallet-worker/build-request.js +341 -0
  54. package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +86 -0
  55. package/srv/blockchain/wallet-worker/confirmation-tracker.js +228 -0
  56. package/srv/blockchain/wallet-worker/index.d.ts +14 -0
  57. package/srv/blockchain/wallet-worker/index.js +80 -0
  58. package/srv/blockchain/wallet-worker/job-store.d.ts +261 -0
  59. package/srv/blockchain/wallet-worker/job-store.js +564 -0
  60. package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +43 -0
  61. package/srv/blockchain/wallet-worker/lease-heartbeat.js +99 -0
  62. package/srv/blockchain/wallet-worker/signers.d.ts +57 -0
  63. package/srv/blockchain/wallet-worker/signers.js +131 -0
  64. package/srv/blockchain/wallet-worker/wallet-worker.d.ts +145 -0
  65. package/srv/blockchain/wallet-worker/wallet-worker.js +542 -0
  66. package/srv/cardano-indexer-service.cds +73 -0
  67. package/srv/cardano-indexer-service.d.ts +2 -0
  68. package/srv/cardano-indexer-service.js +76 -0
  69. package/srv/cardano-service.js +22 -1
  70. package/srv/cardano-tx-service.d.ts +1 -11
  71. package/srv/cardano-tx-service.js +11 -162
  72. package/srv/cardano-worker-service.cds +125 -0
  73. package/srv/cardano-worker-service.d.ts +2 -0
  74. package/srv/cardano-worker-service.js +199 -0
  75. package/srv/server.d.ts +32 -1
  76. package/srv/server.js +228 -2
  77. package/srv/utils/collections.d.ts +13 -0
  78. package/srv/utils/collections.js +24 -0
  79. package/srv/utils/crypto.d.ts +16 -0
  80. package/srv/utils/crypto.js +75 -0
  81. package/srv/utils/error-codes.d.ts +6 -0
  82. package/srv/utils/error-codes.js +6 -0
  83. package/srv/utils/errors.d.ts +12 -0
  84. package/srv/utils/errors.js +45 -0
  85. package/srv/utils/mappers.js +13 -3
  86. package/srv/utils/service-events.d.ts +26 -0
  87. package/srv/utils/service-events.js +46 -0
  88. package/srv/utils/tx-build-helper.d.ts +1 -2
  89. package/srv/utils/tx-build-helper.js +3 -5
  90. package/srv/utils/tx-request-parsers.d.ts +58 -0
  91. package/srv/utils/tx-request-parsers.js +170 -0
  92. package/srv/utils/tx-utils.d.ts +2 -1
  93. package/srv/utils/tx-utils.js +3 -2
  94. package/srv/utils/types.d.ts +2 -1
  95. package/@cds-models/CardanoODataService/index.d.ts.map +0 -1
  96. package/@cds-models/CardanoODataService/index.js.map +0 -1
  97. package/@cds-models/CardanoODataService/index.ts +0 -776
  98. package/@cds-models/CardanoSignService/index.d.ts.map +0 -1
  99. package/@cds-models/CardanoSignService/index.js.map +0 -1
  100. package/@cds-models/CardanoSignService/index.ts +0 -569
  101. package/@cds-models/CardanoTransactionService/index.d.ts.map +0 -1
  102. package/@cds-models/CardanoTransactionService/index.js.map +0 -1
  103. package/@cds-models/CardanoTransactionService/index.ts +0 -526
  104. package/@cds-models/_/index.d.ts.map +0 -1
  105. package/@cds-models/_/index.js.map +0 -1
  106. package/@cds-models/_/index.ts +0 -96
  107. package/@cds-models/cds/outbox/index.ts +0 -27
  108. package/@cds-models/index.d.ts.map +0 -1
  109. package/@cds-models/index.js.map +0 -1
  110. package/@cds-models/index.ts +0 -245
  111. package/@cds-models/odatano/cardano/index.d.ts.map +0 -1
  112. package/@cds-models/odatano/cardano/index.js.map +0 -1
  113. package/@cds-models/odatano/cardano/index.ts +0 -789
  114. package/@cds-models/sap/common/index.d.ts.map +0 -1
  115. package/@cds-models/sap/common/index.js.map +0 -1
  116. package/@cds-models/sap/common/index.ts +0 -249
  117. package/srv/blockchain/transaction-building/keep-relevant.d.ts +0 -29
  118. package/srv/blockchain/transaction-building/keep-relevant.js +0 -116
package/db/schema.cds CHANGED
@@ -1,5 +1,5 @@
1
1
  using {temporal, } from '@sap/cds/common';
2
- using {Lovelace, Blake2b224, Blake2b256, HexBytes, Bech32, AssetUnit, AssetSlice, SigningStatus,SubmissionStatus, UTxODataSlice, MetadataLabel} from '../db/types';
2
+ using {Lovelace, Blake2b224, Blake2b256, HexBytes, Bech32, AssetUnit, AssetSlice, SigningStatus,SubmissionStatus, UTxODataSlice, MetadataLabel, CrawlSyncStatus, ReorgStatus, WalletJobStatus, WalletJobKind, WorkerSignerType} from '../db/types';
3
3
 
4
4
  namespace odatano.cardano;
5
5
 
@@ -74,6 +74,10 @@ entity Blocks {
74
74
  epoch : Association to Epochs
75
75
  on epoch.epoch = $self.epochNumber;
76
76
 
77
+ @title : 'Block Absolute Slot'
78
+ @description: 'Absolute slot number of the block'
79
+ slot : Integer64;
80
+
77
81
  @title : 'Block Slot within Epoch'
78
82
  @description: 'Slot number within the epoch as integer'
79
83
  epochSlot : Integer;
@@ -1349,3 +1353,281 @@ entity SignatureVerifications {
1349
1353
  @description: 'Timestamp when the verification was performed'
1350
1354
  verifiedAt : Timestamp;
1351
1355
  }
1356
+
1357
+ // -----------------------------------------------------
1358
+ // Chain Crawler / Pre-Sync (v2.0)
1359
+ // -----------------------------------------------------
1360
+
1361
+ @title : 'Cardano Sync State'
1362
+ @description: 'Singleton crawl cursor tracking the pre-sync progress of the chain crawler'
1363
+ entity CardanoSyncState {
1364
+
1365
+ @title : 'Cursor Id (Key)'
1366
+ @description: 'Singleton key — always the literal string SINGLETON'
1367
+ key ID : String(10) default 'SINGLETON';
1368
+
1369
+ @title : 'Network'
1370
+ @description: 'The Cardano network this cursor tracks (mainnet | preprod | preview)'
1371
+ network : String(10);
1372
+
1373
+ @title : 'Start Slot'
1374
+ @description: 'Absolute slot of the configured pre-sync origin (immutable once syncing starts)'
1375
+ startSlot : Integer64;
1376
+
1377
+ @title : 'Start Block Hash'
1378
+ @description: 'Block hash of the configured pre-sync origin'
1379
+ startBlockHash : Blake2b256;
1380
+
1381
+ @title : 'Last Slot'
1382
+ @description: 'Absolute slot of the last indexed block (resume point)'
1383
+ lastSlot : Integer64 default 0;
1384
+
1385
+ @title : 'Last Block Hash'
1386
+ @description: 'Hash of the last indexed block — used for the reorg parent-hash check'
1387
+ lastBlockHash : Blake2b256;
1388
+
1389
+ @title : 'Last Height'
1390
+ @description: 'Block height of the last indexed block'
1391
+ lastHeight : Integer64 default 0;
1392
+
1393
+ @title : 'Last Indexed At'
1394
+ @description: 'Wall-clock timestamp of the last successful block persist'
1395
+ lastIndexedAt : Timestamp;
1396
+
1397
+ @title : 'Tip Slot'
1398
+ @description: 'Latest known chain-tip slot, for lag/progress calculation'
1399
+ tipSlot : Integer64;
1400
+
1401
+ @title : 'Tip Height'
1402
+ @description: 'Latest known chain-tip height'
1403
+ tipHeight : Integer64;
1404
+
1405
+ @title : 'Sync Status'
1406
+ @description: 'Current crawler state (stopped | syncing | synced | error)'
1407
+ syncStatus : CrawlSyncStatus default 'stopped';
1408
+
1409
+ // NOTE: live progress is computed by CardanoIndexerService.getStatus from
1410
+ // lastHeight/tipHeight — deliberately NOT persisted here (a stored copy went
1411
+ // stale immediately and misled OData readers).
1412
+
1413
+ @title : 'Last Error'
1414
+ @description: 'Message of the most recent crawler error (null when healthy)'
1415
+ lastError : String(500);
1416
+
1417
+ @title : 'Last Error At'
1418
+ @description: 'Timestamp of the most recent crawler error'
1419
+ lastErrorAt : Timestamp;
1420
+
1421
+ @title : 'Consecutive Errors'
1422
+ @description: 'Count of back-to-back failures; trips the circuit breaker past its threshold'
1423
+ consecutiveErrors : Integer default 0;
1424
+
1425
+ @title : 'Crawler Desired Running State'
1426
+ @description: 'Cluster-wide operator intent. False fences every crawler instance before its next write.'
1427
+ desiredRunning : Boolean default true;
1428
+
1429
+ @title : 'Crawler Lease Owner'
1430
+ @description: 'Opaque process identifier of the single crawler instance currently allowed to write'
1431
+ leaseOwner : String(128);
1432
+
1433
+ @title : 'Crawler Lease Expiry'
1434
+ @description: 'Lease deadline renewed by the active crawler; another instance may take over only after this time'
1435
+ leaseUntil : Timestamp;
1436
+ }
1437
+
1438
+ @title : 'Cardano Reorg Log'
1439
+ @description: 'Audit trail of chain rollbacks (reorgs) handled by the crawler'
1440
+ entity CardanoReorgLog {
1441
+
1442
+ @title : 'Reorg Id (Key)'
1443
+ @description: 'Unique identifier of the reorg event'
1444
+ key ID : UUID;
1445
+
1446
+ @title : 'Detected At'
1447
+ @description: 'Timestamp when the rollback was detected'
1448
+ detectedAt : Timestamp;
1449
+
1450
+ @title : 'Fork Slot'
1451
+ @description: 'Absolute slot of the common ancestor the chain rolled back to'
1452
+ forkSlot : Integer64;
1453
+
1454
+ @title : 'Fork Height'
1455
+ @description: 'Block height of the common ancestor the chain rolled back to'
1456
+ forkHeight : Integer64;
1457
+
1458
+ @title : 'Old Tip Hash'
1459
+ @description: 'Hash of the abandoned tip before the rollback'
1460
+ oldTipHash : Blake2b256;
1461
+
1462
+ @title : 'New Tip Hash'
1463
+ @description: 'Hash of the block the chain rolled back to'
1464
+ newTipHash : Blake2b256;
1465
+
1466
+ @title : 'Blocks Rolled Back'
1467
+ @description: 'Number of blocks (and their child rows) deleted during rollback'
1468
+ blocksRolledBack : Integer;
1469
+
1470
+ @title : 'Status'
1471
+ @description: 'Lifecycle of the reorg handling (detected | rolling_back | reindexing | completed)'
1472
+ status : ReorgStatus;
1473
+ }
1474
+
1475
+ // -----------------------------------------------------
1476
+ // Wallet Worker / Job Engine (v2.1)
1477
+ // -----------------------------------------------------
1478
+
1479
+ @title : 'Cardano Worker Wallets'
1480
+ @description: 'Operator-registered server-side wallets the wallet worker executes jobs from. No key material is ever stored here.'
1481
+ entity CardanoWorkerWallets {
1482
+
1483
+ @title : 'Wallet Id (Key)'
1484
+ @description: 'Stable operator-chosen handle used in job requests'
1485
+ key walletId : String(50);
1486
+
1487
+ @title : 'Signer Type'
1488
+ @description: 'How this wallet signs (hsm | software)'
1489
+ signerType : WorkerSignerType;
1490
+
1491
+ @title : 'Address'
1492
+ @description: 'Bech32 address derived from the signing key at worker init (informational)'
1493
+ address : Bech32;
1494
+
1495
+ @title : 'Public Key Hash'
1496
+ @description: 'Blake2b-224 hash of the wallet verification key'
1497
+ publicKeyHash : Blake2b224;
1498
+
1499
+ @title : 'Enabled'
1500
+ @description: 'Disabled wallets accept no new jobs and are skipped by the dispatch loop'
1501
+ enabled : Boolean default true;
1502
+
1503
+ @title : 'Wallet Lease Owner'
1504
+ @description: 'Opaque process identifier of the single worker instance currently allowed to execute jobs for this wallet'
1505
+ leaseOwner : String(128);
1506
+
1507
+ @title : 'Wallet Lease Expiry'
1508
+ @description: 'Lease deadline renewed by the executing worker; another instance may take over only after this time'
1509
+ leaseUntil : Timestamp;
1510
+
1511
+ @title : 'Last Job At'
1512
+ @description: 'Timestamp of the most recent job execution for this wallet'
1513
+ lastJobAt : Timestamp;
1514
+
1515
+ @title : 'Jobs Confirmed'
1516
+ @description: 'Rolling count of jobs that reached confirmed state'
1517
+ jobsConfirmed : Integer64 default 0;
1518
+
1519
+ @title : 'Jobs Failed'
1520
+ @description: 'Rolling count of jobs that reached failed state'
1521
+ jobsFailed : Integer64 default 0;
1522
+ }
1523
+
1524
+ @title : 'Cardano Wallet Jobs'
1525
+ @description: 'Asynchronous transaction jobs executed by the wallet worker (build → sign → submit → confirm)'
1526
+ // Idempotency is enforced by the DATABASE, not by a read-before-insert check:
1527
+ // concurrent retries of the same key (two app instances, or two HANA sessions)
1528
+ // can both find no existing job and both insert. The unique constraint makes one
1529
+ // of them lose, and insertJob returns the winner's job to it. See `dedupKey`.
1530
+ // Generates a table UNIQUE constraint on SQLite and a UNIQUE INVERTED INDEX on HANA.
1531
+ @assert.unique.dedup: [
1532
+ walletId,
1533
+ kind,
1534
+ dedupKey
1535
+ ]
1536
+ entity CardanoWalletJobs {
1537
+
1538
+ @title : 'Job Id (Key)'
1539
+ @description: 'Unique identifier of the job, returned by SubmitWalletJob'
1540
+ key ID : UUID;
1541
+
1542
+ @title : 'Wallet Id'
1543
+ @description: 'The worker wallet this job executes from'
1544
+ walletId : String(50);
1545
+
1546
+ @title : 'Job Kind'
1547
+ @description: 'Transaction kind (simpleAda | metadata | multiAsset | mint | plutusSpend | submitSigned)'
1548
+ kind : WalletJobKind;
1549
+
1550
+ @title : 'Status'
1551
+ @description: 'Job lifecycle state (pending | building | submitting | submitted | confirmed | failed | cancelled)'
1552
+ status : WalletJobStatus default 'pending';
1553
+
1554
+ @title : 'Idempotency Key'
1555
+ @description: 'Optional caller-supplied dedup key — a non-failed job with the same (walletId, kind, idempotencyKey) is returned instead of creating a new one'
1556
+ idempotencyKey : String(100);
1557
+
1558
+ @title : 'Dedup Key (internal)'
1559
+ @description: 'Backing value of the unique (walletId, kind, dedupKey) constraint: the caller idempotency key while the job holds it, otherwise the job ID (unique by construction). Keyless jobs and terminated jobs therefore never collide — no reliance on NULL semantics, which differ across databases.'
1560
+ dedupKey : String(100);
1561
+
1562
+ @title : 'Request'
1563
+ @description: 'The build-action payload as JSON, verbatim (validated before insert; never contains key material)'
1564
+ request : LargeString;
1565
+
1566
+ @title : 'Priority'
1567
+ @description: 'Dispatch order within a wallet queue — lower runs sooner (default 100)'
1568
+ priority : Integer default 100;
1569
+
1570
+ @title : 'Not Before'
1571
+ @description: 'Optional earliest execution time (one-shot scheduling)'
1572
+ notBefore : Timestamp;
1573
+
1574
+ @title : 'Attempt'
1575
+ @description: 'Number of execution attempts made so far'
1576
+ attempt : Integer default 0;
1577
+
1578
+ @title : 'Max Attempts'
1579
+ @description: 'Bound for transient-failure retries (build/submit); deterministic rejections fail immediately'
1580
+ maxAttempts : Integer default 3;
1581
+
1582
+ @title : 'Transaction Hash'
1583
+ @description: 'Hash of the signed transaction — persisted before the submit call (status submitting), so a crash mid-submit stays reconcilable'
1584
+ txHash : Blake2b256;
1585
+
1586
+ @title : 'Unsigned Transaction CBOR'
1587
+ @description: 'The built unsigned transaction, kept for diagnosis until the job confirms'
1588
+ unsignedTxCbor : LargeString;
1589
+
1590
+ @title : 'Signed Transaction CBOR'
1591
+ @description: 'The signed transaction, stored before submission — reused verbatim for crash reconciliation and rollback re-submission (never rebuilt)'
1592
+ signedTxCbor : LargeString;
1593
+
1594
+ @title : 'Fee'
1595
+ @description: 'Transaction fee in lovelace, from the build result'
1596
+ fee : Lovelace;
1597
+
1598
+ @title : 'Submitted At'
1599
+ @description: 'Timestamp of the submission attempt (written with the signed tx, before it is sent) — the base for the confirmation timeout'
1600
+ submittedAt : Timestamp;
1601
+
1602
+ @title : 'Confirmed At'
1603
+ @description: 'Timestamp when the configured confirmation depth was reached'
1604
+ confirmedAt : Timestamp;
1605
+
1606
+ @title : 'Confirmed Slot'
1607
+ @description: 'Absolute slot of the block containing the transaction — used for reorg checks'
1608
+ confirmedSlot : Integer64;
1609
+
1610
+ @title : 'Confirmed Height'
1611
+ @description: 'Block height of the block containing the transaction — used for depth calculation'
1612
+ confirmedHeight : Integer64;
1613
+
1614
+ @title : 'Error Code'
1615
+ @description: 'Machine-readable code of the terminal failure (null while healthy)'
1616
+ errorCode : String(50);
1617
+
1618
+ @title : 'Error Message'
1619
+ @description: 'Human-readable message of the terminal failure'
1620
+ errorMessage : String(500);
1621
+
1622
+ @title : 'Created At'
1623
+ @description: 'Timestamp the job was accepted'
1624
+ createdAt : Timestamp;
1625
+
1626
+ @title : 'Created By'
1627
+ @description: 'User id of the caller that submitted the job'
1628
+ createdBy : String(100);
1629
+
1630
+ @title : 'Finished At'
1631
+ @description: 'Timestamp the job reached a terminal state (confirmed | failed | cancelled)'
1632
+ finishedAt : Timestamp;
1633
+ }
package/db/types.cds CHANGED
@@ -111,6 +111,54 @@ type SigningStatus : String(20) enum {
111
111
  failed = 'failed';
112
112
  }
113
113
 
114
+ @title : 'Crawl Sync Status'
115
+ @description: 'Enum type for the chain crawler / pre-sync cursor state'
116
+ type CrawlSyncStatus : String(12) enum {
117
+ stopped = 'stopped'; // crawler not running
118
+ syncing = 'syncing'; // actively catching up / streaming
119
+ synced = 'synced'; // caught up to (tip - confirmationDepth)
120
+ error = 'error'; // circuit-broken after repeated failures
121
+ }
122
+
123
+ @title : 'Reorg Status'
124
+ @description: 'Enum type for the lifecycle of a handled chain rollback'
125
+ type ReorgStatus : String(12) enum {
126
+ detected = 'detected';
127
+ rolling_back = 'rolling_back';
128
+ reindexing = 'reindexing';
129
+ completed = 'completed';
130
+ }
131
+
132
+ @title : 'Wallet Job Status'
133
+ @description: 'Enum type for the wallet-worker job lifecycle'
134
+ type WalletJobStatus : String(12) enum {
135
+ pending = 'pending'; // queued, waiting for the worker to pick it up
136
+ building = 'building'; // build + sign in progress, nothing sent to the network yet
137
+ submitting = 'submitting'; // signed tx durably stored, submit in flight or its outcome unknown
138
+ submitted = 'submitted'; // accepted into the mempool, awaiting confirmation
139
+ confirmed = 'confirmed'; // on-chain at the configured confirmation depth
140
+ failed = 'failed'; // terminal failure (see errorCode/errorMessage)
141
+ cancelled = 'cancelled'; // cancelled by the caller while still pending
142
+ }
143
+
144
+ @title : 'Wallet Job Kind'
145
+ @description: 'Enum type for the transaction kind a wallet-worker job executes'
146
+ type WalletJobKind : String(12) enum {
147
+ simpleAda = 'simpleAda'; // BuildSimpleAdaTransaction payload
148
+ metadata = 'metadata'; // BuildTransactionWithMetadata payload
149
+ multiAsset = 'multiAsset'; // BuildMultiAssetTransaction payload
150
+ mint = 'mint'; // BuildMintTransaction payload
151
+ plutusSpend = 'plutusSpend'; // BuildPlutusSpendTransaction payload
152
+ submitSigned = 'submitSigned'; // externally signed CBOR — managed submit + confirm only
153
+ }
154
+
155
+ @title : 'Worker Signer Type'
156
+ @description: 'Enum type for how a worker wallet signs transactions'
157
+ type WorkerSignerType : String(10) enum {
158
+ hsm = 'hsm'; // PKCS#11 HSM (production) — keys never leave the module
159
+ software = 'software'; // operator-configured Ed25519 key (dev/test)
160
+ }
161
+
114
162
  // -----------------------------------------------------
115
163
  // Parsed Transaction (ParseTransactionCbor action result)
116
164
  // -----------------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odatano/core",
3
- "version": "1.10.0",
3
+ "version": "2.0.0-rc.1",
4
4
  "description": "SAP CAP plugin for Cardano blockchain OData V4 integration",
5
5
  "imports": {
6
6
  "#cds-models/*": "./@cds-models/*/index.js"
@@ -18,23 +18,23 @@
18
18
  "@cds-models/"
19
19
  ],
20
20
  "engines": {
21
- "node": ">=20"
21
+ "node": ">=22.5"
22
22
  },
23
23
  "peerDependencies": {
24
- "@sap/cds": ">=9"
24
+ "@sap/cds": ">=10"
25
25
  },
26
26
  "dependencies": {
27
27
  "@blockfrost/blockfrost-js": "~6.0.0",
28
- "@cap-js/hana": "^2",
28
+ "@cap-js/hana": "^3",
29
29
  "@cardano-ogmios/client": "^6.14.0",
30
- "@harmoniclabs/buildooor": "0.2.6",
31
- "@harmoniclabs/cardano-costmodels-ts": "~1.4.0",
32
- "@harmoniclabs/cardano-ledger-ts": "^0.5.1",
30
+ "@harmoniclabs/buildooor": "0.2.9",
31
+ "@harmoniclabs/cardano-costmodels-ts": "~1.6.1",
32
+ "@harmoniclabs/cardano-ledger-ts": "^0.5.6",
33
33
  "@harmoniclabs/cbor": "^2.0.1",
34
34
  "@harmoniclabs/crypto": "^0.3.0",
35
35
  "@harmoniclabs/uint8array-utils": "^1.0.4",
36
36
  "@sap/xssec": "^4",
37
- "axios": "^1.16.1",
37
+ "axios": "^1.18.0",
38
38
  "bech32": "^2.0.0",
39
39
  "blake2b": "^2.1.4"
40
40
  },
@@ -42,29 +42,35 @@
42
42
  "pkcs11js": "^2.1.6"
43
43
  },
44
44
  "overrides": {
45
- "axios": "^1.16.1"
45
+ "axios": "^1.18.0",
46
+ "esbuild": "0.28.1",
47
+ "form-data": "^4.0.6",
48
+ "fast-uri": "^3.1.5",
49
+ "ws": "7.5.11",
50
+ "@sap/approuter": {
51
+ "body-parser": "^2.2.3"
52
+ }
46
53
  },
47
54
  "devDependencies": {
48
55
  "@cap-js/cds-test": "^0.4.1",
49
- "@cap-js/cds-typer": "^0.38.0",
50
- "@cap-js/cds-types": "^0.15.0",
51
- "@cap-js/sqlite": "^2",
52
- "@sap/cds": "^9",
53
- "@sap/cds-dk": "^9.4.3",
54
- "@sap/eslint-plugin-cds": "^4",
56
+ "@cap-js/cds-typer": "^0.40.0",
57
+ "@cap-js/cds-types": "^0.18.0",
58
+ "@cap-js/sqlite": "^3",
59
+ "@sap/cds": "^10",
60
+ "@sap/cds-dk": "^10",
61
+ "@sap/eslint-plugin-cds": "^4.2.4",
55
62
  "@types/blake2b": "^2.1.3",
56
- "@types/jest": "^29.5.14",
57
63
  "@types/node": "^22.19.7",
58
64
  "@typescript-eslint/eslint-plugin": "^8.50.1",
59
65
  "@typescript-eslint/parser": "^8.50.1",
66
+ "@vitest/coverage-v8": "^4.1.10",
60
67
  "dotenv": "^16.3.1",
61
68
  "eslint": "^9.39.2",
62
- "jest": "^29.6.1",
63
69
  "nock": "^13.5.6",
64
- "ts-jest": "^29.4.5",
65
70
  "ts-node": "^10.9.2",
66
71
  "tsx": "^4.21.0",
67
- "typescript": "^5.9.3"
72
+ "typescript": "^5.9.3",
73
+ "vitest": "^4.1.10"
68
74
  },
69
75
  "cds": {
70
76
  "typer": {
@@ -105,11 +111,12 @@
105
111
  }
106
112
  },
107
113
  "scripts": {
108
- "clean": "node -e \"require('glob').sync('{srv,db,src}/**/*.{js,js.map,d.ts,d.ts.map}',{ignore:'**/node_modules/**'}).forEach(f=>require('fs').unlinkSync(f));console.log('Clean complete')\"",
114
+ "clean": "node -e \"const fs=require('fs');fs.globSync('{srv,db,src}/**/*.{js,js.map,d.ts,d.ts.map}').filter(f=>!f.includes('node_modules')).forEach(f=>fs.unlinkSync(f));console.log('Clean complete')\"",
109
115
  "clean:models": "node -e \"require('fs').rmSync('@cds-models',{recursive:true,force:true});console.log('Removed @cds-models')\"",
110
116
  "build": "npm run cds:types && tsc",
111
117
  "build:plugin": "npm run cds:types && tsc -p tsconfig.build.json",
112
- "prepublishOnly": "npm run clean && npm run clean:models && npm run build:plugin",
118
+ "build:package": "npm run clean && npm run clean:models && npm run build:plugin",
119
+ "prepare": "npm run build:package",
113
120
  "start": "cds-serve",
114
121
  "cds:watch": "cds watch",
115
122
  "cds:serve": "cds serve --with-mocks",
@@ -117,23 +124,25 @@
117
124
  "lint": "eslint .",
118
125
  "typecheck": "tsc --noEmit",
119
126
  "db:deploy": "cds deploy",
120
- "pretest": "npm run cds:types && npm run db:deploy",
121
- "test": "jest --runInBand --forceExit",
122
- "test:coverage": "jest --runInBand --coverage --forceExit",
123
- "test:ci": "jest --runInBand --testPathIgnorePatterns=core-ogmios.test.ts --forceExit",
124
- "test:ci:coverage": "jest --runInBand --coverage --testPathIgnorePatterns=core-ogmios.test.ts --forceExit",
125
- "test:integration": "npm test -- --testPathPattern=integration",
126
- "test:integration:blockfrost": "npm test -- --testPathPattern=core.blockfrost.test.ts",
127
- "test:integration:koios": "npm test -- --testPathPattern=core.koios.test.ts",
128
- "test:integration:ogmios": "npm test -- --testPathPattern=core-ogmios.test.ts",
127
+ "pretest": "npm run clean && npm run cds:types && npm run db:deploy",
128
+ "test": "vitest run",
129
+ "pretest:coverage": "npm run clean && npm run cds:types && npm run db:deploy",
130
+ "test:coverage": "vitest run --coverage",
131
+ "pretest:ci": "npm run clean && npm run cds:types && npm run db:deploy",
132
+ "test:ci": "vitest run --exclude \"**/core-ogmios.test.ts\"",
133
+ "pretest:ci:coverage": "npm run clean && npm run cds:types && npm run db:deploy",
134
+ "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",
136
+ "test:integration": "vitest run --project integration",
137
+ "test:integration:blockfrost": "vitest run test/integration/core.blockfrost.test.ts",
138
+ "test:integration:koios": "vitest run test/integration/core.koios.test.ts",
139
+ "test:integration:ogmios": "vitest run test/integration/core-ogmios.test.ts",
129
140
  "test:integration:both": "npm run test:integration:blockfrost && npm run test:integration:koios",
130
- "test:unit": "npm test -- --testPathPattern=unit",
141
+ "pretest:unit": "npm run cds:types",
142
+ "test:unit": "vitest run --project unit",
131
143
  "watch-odatano": "cds watch --open odatano/index.html?sap-ui-xx-viewCache=false --livereload false",
132
144
  "watch-wallet": "cds watch --open wallet/webapp/index.html"
133
145
  },
134
- "workspaces": [
135
- "app/router"
136
- ],
137
146
  "sapux": [
138
147
  "app/odatano"
139
148
  ],
package/src/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export { CardanoClient } from '../srv/blockchain/cardano-client';
2
2
  export type { CardanoClientConfig, Network, BackendName, TransactionBuilderName } from '../srv/blockchain/cardano-client';
3
3
  export { CardanoIndexer } from '../srv/blockchain/cardano-indexer';
4
4
  export { CardanoTransactionBuilder } from '../srv/blockchain/cardano-tx-builder';
5
- export { getAppContext, getCardanoIndexer, getCardanoClient, getCardanoTxBuilder, loadConfigFromEnv, loadHsmConfigFromEnv, shutdownAppContext, } from '../srv/server';
5
+ export { getAppContext, getCardanoIndexer, getCardanoClient, getCardanoTxBuilder, loadConfigFromEnv, loadHsmConfigFromEnv, loadCrawlerConfigFromEnv, startCrawlerIfConfigured, loadWalletWorkerConfigFromEnv, startWalletWorkerIfConfigured, shutdownAppContext, } from '../srv/server';
6
6
  export { getHsmSigner } from '../srv/blockchain/signing/hsm-signer';
7
7
  export type { HsmConfig, HsmSignResult } from '../srv/utils/types';
8
8
  export { parseTransaction } from '../srv/cbor';
package/src/index.js CHANGED
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.parseTransaction = exports.getHsmSigner = exports.shutdownAppContext = exports.loadHsmConfigFromEnv = exports.loadConfigFromEnv = exports.getCardanoTxBuilder = exports.getCardanoClient = exports.getCardanoIndexer = exports.getAppContext = exports.CardanoTransactionBuilder = exports.CardanoIndexer = exports.CardanoClient = void 0;
39
+ exports.parseTransaction = exports.getHsmSigner = exports.shutdownAppContext = exports.startWalletWorkerIfConfigured = exports.loadWalletWorkerConfigFromEnv = exports.startCrawlerIfConfigured = exports.loadCrawlerConfigFromEnv = exports.loadHsmConfigFromEnv = exports.loadConfigFromEnv = exports.getCardanoTxBuilder = exports.getCardanoClient = exports.getCardanoIndexer = exports.getAppContext = exports.CardanoTransactionBuilder = exports.CardanoIndexer = exports.CardanoClient = void 0;
40
40
  exports.initialize = initialize;
41
41
  exports.shutdown = shutdown;
42
42
  exports.getStatus = getStatus;
@@ -57,6 +57,10 @@ Object.defineProperty(exports, "getCardanoClient", { enumerable: true, get: func
57
57
  Object.defineProperty(exports, "getCardanoTxBuilder", { enumerable: true, get: function () { return server_1.getCardanoTxBuilder; } });
58
58
  Object.defineProperty(exports, "loadConfigFromEnv", { enumerable: true, get: function () { return server_1.loadConfigFromEnv; } });
59
59
  Object.defineProperty(exports, "loadHsmConfigFromEnv", { enumerable: true, get: function () { return server_1.loadHsmConfigFromEnv; } });
60
+ Object.defineProperty(exports, "loadCrawlerConfigFromEnv", { enumerable: true, get: function () { return server_1.loadCrawlerConfigFromEnv; } });
61
+ Object.defineProperty(exports, "startCrawlerIfConfigured", { enumerable: true, get: function () { return server_1.startCrawlerIfConfigured; } });
62
+ Object.defineProperty(exports, "loadWalletWorkerConfigFromEnv", { enumerable: true, get: function () { return server_1.loadWalletWorkerConfigFromEnv; } });
63
+ Object.defineProperty(exports, "startWalletWorkerIfConfigured", { enumerable: true, get: function () { return server_1.startWalletWorkerIfConfigured; } });
60
64
  Object.defineProperty(exports, "shutdownAppContext", { enumerable: true, get: function () { return server_1.shutdownAppContext; } });
61
65
  // Re-export HSM signer for programmatic access
62
66
  var hsm_signer_1 = require("../srv/blockchain/signing/hsm-signer");
@@ -85,8 +89,12 @@ async function initialize() {
85
89
  if (!alreadyInitialized) {
86
90
  logger.info('ODATANO core initialized');
87
91
  }
92
+ // Start the pre-sync crawler if configured (plugin mode). Non-fatal.
93
+ const { startCrawlerIfConfigured, startWalletWorkerIfConfigured, redriveInterruptedSubmissionsIfConfigured } = await Promise.resolve().then(() => __importStar(require('../srv/server')));
94
+ await startCrawlerIfConfigured();
95
+ // Start the wallet worker if configured (plugin mode). Non-fatal.
96
+ await startWalletWorkerIfConfigured();
88
97
  // Re-drive deferred submissions interrupted by a restart (plugin mode). Non-fatal.
89
- const { redriveInterruptedSubmissionsIfConfigured } = await Promise.resolve().then(() => __importStar(require('../srv/server')));
90
98
  await redriveInterruptedSubmissionsIfConfigured();
91
99
  }
92
100
  /**
package/src/plugin.js CHANGED
@@ -58,7 +58,9 @@ cds_1.default.env.requires.kinds['odatano-core'] = {
58
58
  '@odatano/core/db/schema',
59
59
  '@odatano/core/srv/cardano-service',
60
60
  '@odatano/core/srv/cardano-tx-service',
61
- '@odatano/core/srv/cardano-sign-service'
61
+ '@odatano/core/srv/cardano-sign-service',
62
+ '@odatano/core/srv/cardano-indexer-service',
63
+ '@odatano/core/srv/cardano-worker-service'
62
64
  ]
63
65
  };
64
66
  // CRITICAL: Also set model directly on the requires entry.
@@ -70,7 +72,9 @@ if (req) {
70
72
  '@odatano/core/db/schema',
71
73
  '@odatano/core/srv/cardano-service',
72
74
  '@odatano/core/srv/cardano-tx-service',
73
- '@odatano/core/srv/cardano-sign-service'
75
+ '@odatano/core/srv/cardano-sign-service',
76
+ '@odatano/core/srv/cardano-indexer-service',
77
+ '@odatano/core/srv/cardano-worker-service'
74
78
  ];
75
79
  }
76
80
  logger.debug('Plugin registered');
@@ -95,6 +99,12 @@ cds_1.default.on('loaded', (model) => {
95
99
  else if (def['@impl'] === 'srv/cardano-sign-service') {
96
100
  def['@impl'] = '@odatano/core/srv/cardano-sign-service';
97
101
  }
102
+ else if (def['@impl'] === 'srv/cardano-indexer-service') {
103
+ def['@impl'] = '@odatano/core/srv/cardano-indexer-service';
104
+ }
105
+ else if (def['@impl'] === 'srv/cardano-worker-service') {
106
+ def['@impl'] = '@odatano/core/srv/cardano-worker-service';
107
+ }
98
108
  }
99
109
  });
100
110
  /**
@@ -1,11 +1,11 @@
1
- import { CardanoBackend } from './cardano-backend';
1
+ import { CardanoBackend, PaginatingBackend } from './cardano-backend';
2
2
  import { Transaction, BlockData, Address, UTxO, NetworkInformation, EpochData, MetadataLabelTx, PoolData, AccountData, DrepData, AssetInfo, AssetHistoryEntry, LedgerProtocolParameters } from '../../utils/types';
3
3
  import { Network } from '../cardano-client';
4
4
  /**
5
5
  * BlockfrostBackend Implementation for CardanoBackend Interface
6
6
  * Implements the CardanoBackend interface using Blockfrost API SDK
7
7
  */
8
- export declare class BlockfrostBackend implements CardanoBackend {
8
+ export declare class BlockfrostBackend implements CardanoBackend, PaginatingBackend {
9
9
  readonly name = "blockfrost";
10
10
  private api;
11
11
  private network;
@@ -151,5 +151,24 @@ export declare class BlockfrostBackend implements CardanoBackend {
151
151
  * @returns {Promise<Map<string, Transaction>>} map of hash -> Transaction
152
152
  */
153
153
  getTransactionsBatch(txHashes: string[]): Promise<Map<string, Transaction>>;
154
+ /**
155
+ * Map a Blockfrost block summary (from blocks()/blocksNext()) to our BlockData.
156
+ * Same shape getBlock() maps inline — kept private to avoid touching getBlock().
157
+ */
158
+ private toBlockData;
159
+ /**
160
+ * Get a block by its height. Blockfrost's `blocks` endpoint accepts a height as
161
+ * well as a hash.
162
+ */
163
+ getBlockByHeight(height: number): Promise<BlockData>;
164
+ /**
165
+ * Get up to `count` blocks immediately following `afterHash`, in ascending chain order.
166
+ */
167
+ getNextBlocks(afterHash: string, count: number): Promise<BlockData[]>;
168
+ /**
169
+ * Get the full transaction list of a block in block order. Blockfrost returns tx
170
+ * hashes; details are batched via getTransactionsBatch. Order is preserved.
171
+ */
172
+ getBlockTransactions(blockHash: string): Promise<Transaction[]>;
154
173
  }
155
174
  //# sourceMappingURL=blockfrost-backend.d.ts.map