@odatano/core 1.11.0 → 2.0.0-rc.10
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.
- package/@cds-models/CardanoAgentService/index.d.ts +255 -0
- package/@cds-models/CardanoAgentService/index.js +36 -0
- package/@cds-models/CardanoIndexerService/index.d.ts +177 -0
- package/@cds-models/CardanoIndexerService/index.js +27 -0
- package/@cds-models/CardanoODataService/index.d.ts +693 -2172
- package/@cds-models/CardanoODataService/index.js +88 -390
- package/@cds-models/CardanoSignService/index.d.ts +448 -1576
- package/@cds-models/CardanoSignService/index.js +62 -293
- package/@cds-models/CardanoTransactionService/index.d.ts +437 -1494
- package/@cds-models/CardanoTransactionService/index.js +60 -271
- package/@cds-models/CardanoWorkerService/index.d.ts +224 -0
- package/@cds-models/CardanoWorkerService/index.js +32 -0
- package/@cds-models/_/index.d.ts +70 -40
- package/@cds-models/_/index.js +17 -32
- package/@cds-models/cds/outbox/index.d.ts +28 -0
- package/@cds-models/index.d.ts +225 -522
- package/@cds-models/index.js +35 -218
- package/@cds-models/odatano/cardano/index.d.ts +919 -2884
- package/@cds-models/odatano/cardano/index.js +115 -536
- package/@cds-models/sap/common/index.d.ts +196 -600
- package/@cds-models/sap/common/index.js +28 -269
- package/README.md +194 -102
- package/db/schema.cds +388 -1
- package/db/types.cds +48 -0
- package/package.json +48 -33
- package/src/index.d.ts +7 -1
- package/src/index.js +30 -2
- package/src/plugin.js +33 -20
- package/srv/blockchain/backends/blockfrost-backend.d.ts +21 -2
- package/srv/blockchain/backends/blockfrost-backend.js +69 -25
- package/srv/blockchain/backends/cardano-backend.d.ts +69 -0
- package/srv/blockchain/backends/cardano-backend.js +13 -0
- package/srv/blockchain/backends/koios-backend.d.ts +26 -2
- package/srv/blockchain/backends/koios-backend.js +148 -25
- package/srv/blockchain/backends/ogmios-backend.d.ts +60 -9
- package/srv/blockchain/backends/ogmios-backend.js +326 -10
- package/srv/blockchain/cardano-client.d.ts +19 -0
- package/srv/blockchain/cardano-client.js +36 -0
- package/srv/blockchain/cardano-indexer.d.ts +50 -1
- package/srv/blockchain/cardano-indexer.js +193 -0
- package/srv/blockchain/crawler/crawler.d.ts +176 -0
- package/srv/blockchain/crawler/crawler.js +744 -0
- package/srv/blockchain/crawler/hooks.d.ts +43 -0
- package/srv/blockchain/crawler/hooks.js +62 -0
- package/srv/blockchain/crawler/index.d.ts +35 -0
- package/srv/blockchain/crawler/index.js +168 -0
- package/srv/blockchain/crawler/sync-state.d.ts +106 -0
- package/srv/blockchain/crawler/sync-state.js +287 -0
- package/srv/blockchain/signing/hsm-signer.d.ts +45 -0
- package/srv/blockchain/signing/hsm-signer.js +8 -1
- package/srv/blockchain/transaction-building/buildooor-tx.d.ts +20 -0
- package/srv/blockchain/transaction-building/buildooor-tx.js +104 -20
- package/srv/blockchain/wallet-worker/build-request.d.ts +26 -0
- package/srv/blockchain/wallet-worker/build-request.js +370 -0
- package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +117 -0
- package/srv/blockchain/wallet-worker/confirmation-tracker.js +290 -0
- package/srv/blockchain/wallet-worker/index.d.ts +14 -0
- package/srv/blockchain/wallet-worker/index.js +80 -0
- package/srv/blockchain/wallet-worker/job-store.d.ts +272 -0
- package/srv/blockchain/wallet-worker/job-store.js +597 -0
- package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +43 -0
- package/srv/blockchain/wallet-worker/lease-heartbeat.js +99 -0
- package/srv/blockchain/wallet-worker/signers.d.ts +57 -0
- package/srv/blockchain/wallet-worker/signers.js +131 -0
- package/srv/blockchain/wallet-worker/wallet-worker.d.ts +145 -0
- package/srv/blockchain/wallet-worker/wallet-worker.js +542 -0
- package/srv/cardano-agent-service.cds +150 -0
- package/srv/cardano-agent-service.d.ts +2 -0
- package/srv/cardano-agent-service.js +16 -0
- package/srv/cardano-indexer-service.cds +106 -0
- package/srv/cardano-indexer-service.d.ts +2 -0
- package/srv/cardano-indexer-service.js +79 -0
- package/srv/cardano-service.js +79 -4
- package/srv/cardano-sign-service.cds +200 -180
- package/srv/cardano-tx-service.cds +32 -26
- package/srv/cardano-tx-service.d.ts +1 -11
- package/srv/cardano-tx-service.js +107 -200
- package/srv/cardano-worker-service.cds +125 -0
- package/srv/cardano-worker-service.d.ts +2 -0
- package/srv/cardano-worker-service.js +199 -0
- package/srv/server.d.ts +34 -2
- package/srv/server.js +246 -36
- package/srv/utils/agent-grants-config.d.ts +65 -0
- package/srv/utils/agent-grants-config.js +148 -0
- package/srv/utils/agent-grants.d.ts +314 -0
- package/srv/utils/agent-grants.js +821 -0
- package/srv/utils/agent-token-auth.d.ts +19 -0
- package/srv/utils/agent-token-auth.js +81 -0
- package/srv/utils/collections.d.ts +13 -0
- package/srv/utils/collections.js +24 -0
- package/srv/utils/crypto.d.ts +16 -0
- package/srv/utils/crypto.js +75 -0
- package/srv/utils/db-sanitize.d.ts +40 -0
- package/srv/utils/db-sanitize.js +98 -0
- package/srv/utils/error-codes.d.ts +6 -0
- package/srv/utils/error-codes.js +6 -0
- package/srv/utils/errors.d.ts +12 -0
- package/srv/utils/errors.js +45 -0
- package/srv/utils/liveness.d.ts +23 -0
- package/srv/utils/liveness.js +49 -0
- package/srv/utils/mappers.d.ts +27 -0
- package/srv/utils/mappers.js +80 -10
- package/srv/utils/rate-limiter.d.ts +57 -0
- package/srv/utils/rate-limiter.js +126 -0
- package/srv/utils/service-events.d.ts +26 -0
- package/srv/utils/service-events.js +46 -0
- package/srv/utils/tx-request-parsers.d.ts +71 -0
- package/srv/utils/tx-request-parsers.js +202 -0
- package/srv/utils/tx-utils.d.ts +2 -1
- package/srv/utils/tx-utils.js +3 -2
- package/srv/utils/types.d.ts +17 -1
- package/@cds-models/CardanoODataService/index.d.ts.map +0 -1
- package/@cds-models/CardanoODataService/index.js.map +0 -1
- package/@cds-models/CardanoODataService/index.ts +0 -776
- package/@cds-models/CardanoSignService/index.d.ts.map +0 -1
- package/@cds-models/CardanoSignService/index.js.map +0 -1
- package/@cds-models/CardanoSignService/index.ts +0 -569
- package/@cds-models/CardanoTransactionService/index.d.ts.map +0 -1
- package/@cds-models/CardanoTransactionService/index.js.map +0 -1
- package/@cds-models/CardanoTransactionService/index.ts +0 -526
- package/@cds-models/_/index.d.ts.map +0 -1
- package/@cds-models/_/index.js.map +0 -1
- package/@cds-models/_/index.ts +0 -96
- package/@cds-models/cds/outbox/index.ts +0 -27
- package/@cds-models/index.d.ts.map +0 -1
- package/@cds-models/index.js.map +0 -1
- package/@cds-models/index.ts +0 -245
- package/@cds-models/odatano/cardano/index.d.ts.map +0 -1
- package/@cds-models/odatano/cardano/index.js.map +0 -1
- package/@cds-models/odatano/cardano/index.ts +0 -789
- package/@cds-models/sap/common/index.d.ts.map +0 -1
- package/@cds-models/sap/common/index.js.map +0 -1
- package/@cds-models/sap/common/index.ts +0 -249
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,386 @@ 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
|
+
}
|
|
1634
|
+
|
|
1635
|
+
/**
|
|
1636
|
+
* Agent grants (v2.0): scoped bearer capabilities an Admin hands to an agent
|
|
1637
|
+
* instead of a full user. The token is a capability, not an identity — it is
|
|
1638
|
+
* stored as SHA-256 only, and a request carrying it runs as the principal
|
|
1639
|
+
* `agent:<ID>` with the role `agent-grant`, never as the operator. Enforcement
|
|
1640
|
+
* (allow list, wallet pinning, daily budget) lives in srv/utils/agent-grants.ts;
|
|
1641
|
+
* the transport lane that admits `x-agent-token` in srv/utils/agent-token-auth.ts.
|
|
1642
|
+
* Admin-only table: creation and revocation happen through CardanoAgentService
|
|
1643
|
+
* actions, a token request may read its own row only.
|
|
1644
|
+
*/
|
|
1645
|
+
@title : 'Agent Grants'
|
|
1646
|
+
@description: 'Scoped, budgeted bearer capabilities for agents (token stored as SHA-256 only)'
|
|
1647
|
+
entity CardanoAgentGrants {
|
|
1648
|
+
|
|
1649
|
+
@title : 'Grant Id (Key)'
|
|
1650
|
+
key ID : UUID;
|
|
1651
|
+
|
|
1652
|
+
@title : 'Operator'
|
|
1653
|
+
@description: 'User id of the Admin that issued the grant (audit; the token never runs as this user)'
|
|
1654
|
+
userId : String(200) not null;
|
|
1655
|
+
|
|
1656
|
+
@title : 'Agent Label'
|
|
1657
|
+
@description: 'Human-readable agent name, informational'
|
|
1658
|
+
agentLabel : String(100);
|
|
1659
|
+
|
|
1660
|
+
@title : 'Token Hash'
|
|
1661
|
+
@description: 'SHA-256 of the bearer token; the token itself is shown once and never stored'
|
|
1662
|
+
tokenHash : String(64) not null;
|
|
1663
|
+
|
|
1664
|
+
@title : 'Allowed Actions'
|
|
1665
|
+
@description: 'JSON array of allow-listed action names (builds, signing-request lifecycle, submits, wallet jobs)'
|
|
1666
|
+
allowedActions : LargeString not null;
|
|
1667
|
+
|
|
1668
|
+
@title : 'Wallet Id'
|
|
1669
|
+
@description: 'Worker wallet this grant is pinned to; required for SubmitWalletJob / CancelJob, injected into those requests'
|
|
1670
|
+
walletId : String(50);
|
|
1671
|
+
|
|
1672
|
+
@title : 'Allowed Job Kinds'
|
|
1673
|
+
@description: 'JSON array of WalletJobKind values the grant may queue; null = every kind'
|
|
1674
|
+
allowedJobKinds : LargeString;
|
|
1675
|
+
|
|
1676
|
+
@title : 'Max Jobs Per Day'
|
|
1677
|
+
@description: 'Daily budget of allow-listed action calls (UTC day); null = unlimited'
|
|
1678
|
+
maxJobsPerDay : Integer;
|
|
1679
|
+
|
|
1680
|
+
@title : 'Jobs Used Today'
|
|
1681
|
+
@description: 'Budget consumed inside budgetWindow'
|
|
1682
|
+
jobsUsedToday : Integer default 0;
|
|
1683
|
+
|
|
1684
|
+
@title : 'Budget Window'
|
|
1685
|
+
@description: 'UTC day YYYY-MM-DD the counter belongs to'
|
|
1686
|
+
budgetWindow : String(10);
|
|
1687
|
+
|
|
1688
|
+
@title : 'Valid Until'
|
|
1689
|
+
@description: 'Expiry; null = no expiry'
|
|
1690
|
+
validUntil : Timestamp;
|
|
1691
|
+
|
|
1692
|
+
@title : 'Is Active'
|
|
1693
|
+
@description: 'False once revoked; a revoked token is an unknown token'
|
|
1694
|
+
isActive : Boolean default true;
|
|
1695
|
+
|
|
1696
|
+
@title : 'Revoked At'
|
|
1697
|
+
revokedAt : Timestamp;
|
|
1698
|
+
|
|
1699
|
+
@title : 'Created At'
|
|
1700
|
+
createdAt : Timestamp;
|
|
1701
|
+
|
|
1702
|
+
@title : 'Last Used At'
|
|
1703
|
+
@description: 'Last request admitted under this token (updated at most once a minute)'
|
|
1704
|
+
lastUsedAt : Timestamp;
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
/**
|
|
1708
|
+
* Daily per-action counters of admitted calls under a grant (feeds
|
|
1709
|
+
* CardanoAgentService.GetGrantUsage). Written by the enforcement hook next to
|
|
1710
|
+
* the daily budget: `calls + 1` when a call is admitted, `refunded + 1` when the
|
|
1711
|
+
* handler then refuses its input. Not exposed as an entity — the function is
|
|
1712
|
+
* the contract. A few dozen rows per grant and day at most; no retention job yet.
|
|
1713
|
+
*/
|
|
1714
|
+
entity CardanoAgentGrantUsage {
|
|
1715
|
+
|
|
1716
|
+
@title : 'Grant'
|
|
1717
|
+
key grant : Association to CardanoAgentGrants;
|
|
1718
|
+
|
|
1719
|
+
@title : 'Day'
|
|
1720
|
+
@description: 'UTC day YYYY-MM-DD the call was admitted on'
|
|
1721
|
+
key day : String(10);
|
|
1722
|
+
|
|
1723
|
+
@title : 'Service'
|
|
1724
|
+
@description: 'CAP service name (CardanoTransactionService, CardanoSignService, ...)'
|
|
1725
|
+
key service : String(60);
|
|
1726
|
+
|
|
1727
|
+
@title : 'Action'
|
|
1728
|
+
@description: 'Action name (BuildSimpleAdaTransaction, SubmitTransaction, ...)'
|
|
1729
|
+
key action : String(100);
|
|
1730
|
+
|
|
1731
|
+
@title : 'Calls'
|
|
1732
|
+
@description: 'Admitted calls (budget charged where the grant has one)'
|
|
1733
|
+
calls : Integer default 0;
|
|
1734
|
+
|
|
1735
|
+
@title : 'Refunded'
|
|
1736
|
+
@description: 'Admitted calls whose handler refused the input (400..428); their unit was given back'
|
|
1737
|
+
refunded : Integer default 0;
|
|
1738
|
+
}
|
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": "
|
|
3
|
+
"version": "2.0.0-rc.10",
|
|
4
4
|
"description": "SAP CAP plugin for Cardano blockchain OData V4 integration",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#cds-models/*": "./@cds-models/*/index.js"
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
"@cds-models/"
|
|
19
19
|
],
|
|
20
20
|
"engines": {
|
|
21
|
-
"node": ">=
|
|
21
|
+
"node": ">=22.5"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"@sap/cds": ">=
|
|
24
|
+
"@sap/cds": ">=10"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@blockfrost/blockfrost-js": "~6.0.0",
|
|
28
|
-
"@cap-js/hana": "^
|
|
28
|
+
"@cap-js/hana": "^3",
|
|
29
29
|
"@cardano-ogmios/client": "^6.14.0",
|
|
30
30
|
"@harmoniclabs/buildooor": "0.2.9",
|
|
31
31
|
"@harmoniclabs/cardano-costmodels-ts": "~1.6.1",
|
|
@@ -33,8 +33,9 @@
|
|
|
33
33
|
"@harmoniclabs/cbor": "^2.0.1",
|
|
34
34
|
"@harmoniclabs/crypto": "^0.3.0",
|
|
35
35
|
"@harmoniclabs/uint8array-utils": "^1.0.4",
|
|
36
|
+
"@odatano/cap-auth": "^0.1.0",
|
|
36
37
|
"@sap/xssec": "^4",
|
|
37
|
-
"axios": "^1.
|
|
38
|
+
"axios": "^1.18.0",
|
|
38
39
|
"bech32": "^2.0.0",
|
|
39
40
|
"blake2b": "^2.1.4"
|
|
40
41
|
},
|
|
@@ -42,29 +43,36 @@
|
|
|
42
43
|
"pkcs11js": "^2.1.6"
|
|
43
44
|
},
|
|
44
45
|
"overrides": {
|
|
45
|
-
"axios": "^1.
|
|
46
|
+
"axios": "^1.18.0",
|
|
47
|
+
"esbuild": "0.28.1",
|
|
48
|
+
"form-data": "^4.0.6",
|
|
49
|
+
"fast-uri": "^3.1.7",
|
|
50
|
+
"ws": "7.5.11",
|
|
51
|
+
"@sap/approuter": {
|
|
52
|
+
"body-parser": "^2.2.3"
|
|
53
|
+
}
|
|
46
54
|
},
|
|
47
55
|
"devDependencies": {
|
|
48
56
|
"@cap-js/cds-test": "^0.4.1",
|
|
49
|
-
"@cap-js/cds-typer": "^0.
|
|
50
|
-
"@cap-js/cds-types": "^0.
|
|
51
|
-
"@cap-js/
|
|
52
|
-
"@
|
|
53
|
-
"@sap/cds
|
|
54
|
-
"@sap/
|
|
57
|
+
"@cap-js/cds-typer": "^0.40.0",
|
|
58
|
+
"@cap-js/cds-types": "^0.18.0",
|
|
59
|
+
"@cap-js/postgres": "^3.1.1",
|
|
60
|
+
"@cap-js/sqlite": "^3",
|
|
61
|
+
"@sap/cds": "^10",
|
|
62
|
+
"@sap/cds-dk": "^10",
|
|
63
|
+
"@sap/eslint-plugin-cds": "^4.2.4",
|
|
55
64
|
"@types/blake2b": "^2.1.3",
|
|
56
|
-
"@types/jest": "^29.5.14",
|
|
57
65
|
"@types/node": "^22.19.7",
|
|
58
66
|
"@typescript-eslint/eslint-plugin": "^8.50.1",
|
|
59
67
|
"@typescript-eslint/parser": "^8.50.1",
|
|
68
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
60
69
|
"dotenv": "^16.3.1",
|
|
61
70
|
"eslint": "^9.39.2",
|
|
62
|
-
"jest": "^29.6.1",
|
|
63
71
|
"nock": "^13.5.6",
|
|
64
|
-
"ts-jest": "^29.4.5",
|
|
65
72
|
"ts-node": "^10.9.2",
|
|
66
73
|
"tsx": "^4.21.0",
|
|
67
|
-
"typescript": "^5.9.3"
|
|
74
|
+
"typescript": "^5.9.3",
|
|
75
|
+
"vitest": "^4.1.10"
|
|
68
76
|
},
|
|
69
77
|
"cds": {
|
|
70
78
|
"typer": {
|
|
@@ -89,6 +97,9 @@
|
|
|
89
97
|
"kind": "sqlite",
|
|
90
98
|
"credentials": {
|
|
91
99
|
"url": "db.sqlite"
|
|
100
|
+
},
|
|
101
|
+
"client": {
|
|
102
|
+
"timeout": 5000
|
|
92
103
|
}
|
|
93
104
|
},
|
|
94
105
|
"[production]": {
|
|
@@ -105,11 +116,12 @@
|
|
|
105
116
|
}
|
|
106
117
|
},
|
|
107
118
|
"scripts": {
|
|
108
|
-
"clean": "node -e \"require('
|
|
119
|
+
"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
120
|
"clean:models": "node -e \"require('fs').rmSync('@cds-models',{recursive:true,force:true});console.log('Removed @cds-models')\"",
|
|
110
121
|
"build": "npm run cds:types && tsc",
|
|
111
122
|
"build:plugin": "npm run cds:types && tsc -p tsconfig.build.json",
|
|
112
|
-
"
|
|
123
|
+
"build:package": "npm run clean && npm run clean:models && npm run build:plugin",
|
|
124
|
+
"prepare": "npm run build:package",
|
|
113
125
|
"start": "cds-serve",
|
|
114
126
|
"cds:watch": "cds watch",
|
|
115
127
|
"cds:serve": "cds serve --with-mocks",
|
|
@@ -117,23 +129,26 @@
|
|
|
117
129
|
"lint": "eslint .",
|
|
118
130
|
"typecheck": "tsc --noEmit",
|
|
119
131
|
"db:deploy": "cds deploy",
|
|
120
|
-
"pretest": "npm run cds:types && npm run db:deploy",
|
|
121
|
-
"test": "
|
|
122
|
-
"
|
|
123
|
-
"test:
|
|
124
|
-
"
|
|
125
|
-
"test:
|
|
126
|
-
"
|
|
127
|
-
"test:
|
|
128
|
-
"
|
|
132
|
+
"pretest": "npm run clean && npm run cds:types && npm run db:deploy",
|
|
133
|
+
"test": "vitest run",
|
|
134
|
+
"pretest:coverage": "npm run clean && npm run cds:types && npm run db:deploy",
|
|
135
|
+
"test:coverage": "vitest run --coverage",
|
|
136
|
+
"pretest:ci": "npm run clean && npm run cds:types && npm run db:deploy",
|
|
137
|
+
"test:ci": "vitest run --exclude \"**/core-ogmios.test.ts\"",
|
|
138
|
+
"pretest:ci:coverage": "npm run clean && npm run cds:types && npm run db:deploy",
|
|
139
|
+
"test:ci:coverage": "vitest run --coverage --exclude \"**/core-ogmios.test.ts\"",
|
|
140
|
+
"pretest:integration": "npm run clean && npm run cds:types && npm run db:deploy",
|
|
141
|
+
"test:integration": "vitest run --project integration",
|
|
142
|
+
"test:integration:blockfrost": "vitest run test/integration/core.blockfrost.test.ts",
|
|
143
|
+
"test:integration:koios": "vitest run test/integration/core.koios.test.ts",
|
|
144
|
+
"test:integration:ogmios": "vitest run test/integration/core-ogmios.test.ts",
|
|
129
145
|
"test:integration:both": "npm run test:integration:blockfrost && npm run test:integration:koios",
|
|
130
|
-
"
|
|
146
|
+
"pretest:unit": "npm run cds:types",
|
|
147
|
+
"test:unit": "vitest run --project unit",
|
|
131
148
|
"watch-odatano": "cds watch --open odatano/index.html?sap-ui-xx-viewCache=false --livereload false",
|
|
132
|
-
"watch-wallet": "cds watch --open wallet/webapp/index.html"
|
|
149
|
+
"watch-wallet": "cds watch --open wallet/webapp/index.html",
|
|
150
|
+
"release:check": "node scripts/release-check.mjs"
|
|
133
151
|
},
|
|
134
|
-
"workspaces": [
|
|
135
|
-
"app/router"
|
|
136
|
-
],
|
|
137
152
|
"sapux": [
|
|
138
153
|
"app/odatano"
|
|
139
154
|
],
|
|
@@ -161,4 +176,4 @@
|
|
|
161
176
|
"url": "https://github.com/ODATANO/ODATANO/issues"
|
|
162
177
|
},
|
|
163
178
|
"homepage": "https://github.com/ODATANO/ODATANO#readme"
|
|
164
|
-
}
|
|
179
|
+
}
|
package/src/index.d.ts
CHANGED
|
@@ -2,8 +2,14 @@ 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
|
+
export { issueAgentGrant, updateAgentGrant, rotateAgentGrantToken, revokeAgentGrantById, getGrantUsage, resolveUsageWindow, 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, UpdateAgentGrantInput, UpdateAgentGrantResult, RotatedAgentGrant, AgentGrantUsage, GrantUsageCall, UsageWindow, } from '../srv/utils/agent-grants';
|
|
9
|
+
export { registerTransportLane } from '@odatano/cap-auth';
|
|
10
|
+
export type { TransportLane, LaneOutcome } from '@odatano/cap-auth';
|
|
11
|
+
export { loadAgentGrantsConfig } from '../srv/utils/agent-grants-config';
|
|
12
|
+
export type { AgentGrantsConfig } from '../srv/utils/agent-grants-config';
|
|
7
13
|
export type { HsmConfig, HsmSignResult } from '../srv/utils/types';
|
|
8
14
|
export { parseTransaction } from '../srv/cbor';
|
|
9
15
|
export type { ParsedTransaction, ParsedInput, ParsedOutput, ParsedAsset, ParsedWitnesses, } from '../srv/cbor';
|