@odatano/core 2.0.0-rc.4 → 2.0.0-rc.40
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 +251 -0
- package/@cds-models/CardanoAgentService/index.js +36 -0
- package/@cds-models/CardanoBackendService/index.d.ts +357 -0
- package/@cds-models/CardanoBackendService/index.js +40 -0
- package/@cds-models/CardanoIndexerService/index.d.ts +194 -2
- package/@cds-models/CardanoIndexerService/index.js +25 -0
- package/@cds-models/CardanoODataService/index.d.ts +305 -7
- package/@cds-models/CardanoODataService/index.js +34 -0
- package/@cds-models/CardanoSignService/index.d.ts +28 -3
- package/@cds-models/CardanoSignService/index.js +3 -0
- package/@cds-models/CardanoTransactionService/index.d.ts +46 -13
- package/@cds-models/CardanoTransactionService/index.js +4 -0
- package/@cds-models/index.d.ts +72 -0
- package/@cds-models/index.js +12 -0
- package/@cds-models/odatano/cardano/index.d.ts +408 -7
- package/@cds-models/odatano/cardano/index.js +42 -0
- package/README.md +64 -5
- package/db/schema.cds +2297 -1633
- package/db/types.cds +114 -0
- package/package.json +27 -6
- package/scripts/migrate-slot-leader.mjs +104 -0
- package/scripts/migrate-txseq.mjs +147 -0
- package/src/index.d.ts +18 -11
- package/src/index.js +44 -14
- package/src/plugin.js +42 -52
- package/srv/blockchain/backends/blockfrost-backend.d.ts +29 -131
- package/srv/blockchain/backends/blockfrost-backend.js +53 -162
- package/srv/blockchain/backends/cardano-backend.d.ts +104 -158
- package/srv/blockchain/backends/cardano-backend.js +19 -5
- package/srv/blockchain/backends/koios-backend.d.ts +126 -60
- package/srv/blockchain/backends/koios-backend.js +376 -235
- package/srv/blockchain/backends/odatano-backend.d.ts +64 -0
- package/srv/blockchain/backends/odatano-backend.js +170 -0
- package/srv/blockchain/backends/ogmios-backend.d.ts +162 -94
- package/srv/blockchain/backends/ogmios-backend.js +556 -201
- package/srv/blockchain/backends/ogmios-frame-guard.d.ts +32 -0
- package/srv/blockchain/backends/ogmios-frame-guard.js +142 -0
- package/srv/blockchain/cardano-client.d.ts +87 -202
- package/srv/blockchain/cardano-client.js +210 -240
- package/srv/blockchain/cardano-indexer.d.ts +311 -242
- package/srv/blockchain/cardano-indexer.js +1238 -362
- package/srv/blockchain/cardano-tx-builder.d.ts +44 -81
- package/srv/blockchain/cardano-tx-builder.js +173 -132
- package/srv/blockchain/crawler/certificate-backfill.d.ts +67 -0
- package/srv/blockchain/crawler/certificate-backfill.js +169 -0
- package/srv/blockchain/crawler/crawler.d.ts +139 -54
- package/srv/blockchain/crawler/crawler.js +478 -96
- package/srv/blockchain/crawler/hooks.d.ts +3 -14
- package/srv/blockchain/crawler/index.d.ts +5 -0
- package/srv/blockchain/crawler/index.js +35 -7
- package/srv/blockchain/crawler/sync-state.d.ts +46 -28
- package/srv/blockchain/crawler/sync-state.js +128 -43
- package/srv/blockchain/crawler/transaction-backfill.d.ts +52 -0
- package/srv/blockchain/crawler/transaction-backfill.js +283 -0
- package/srv/blockchain/crawler/utxo-set-import.d.ts +78 -0
- package/srv/blockchain/crawler/utxo-set-import.js +363 -0
- package/srv/blockchain/ledger-state.d.ts +101 -0
- package/srv/blockchain/ledger-state.js +432 -0
- package/srv/blockchain/pending-spends.d.ts +28 -0
- package/srv/blockchain/pending-spends.js +89 -0
- package/srv/blockchain/signing/cose-verifier.d.ts +5 -12
- package/srv/blockchain/signing/cose-verifier.js +6 -12
- package/srv/blockchain/signing/external-signer.d.ts +16 -113
- package/srv/blockchain/signing/external-signer.js +19 -122
- package/srv/blockchain/signing/hsm-signer.d.ts +13 -45
- package/srv/blockchain/signing/hsm-signer.js +23 -63
- package/srv/blockchain/signing/signature-verifier.d.ts +14 -45
- package/srv/blockchain/signing/signature-verifier.js +73 -76
- package/srv/blockchain/signing/submission-finalizer.d.ts +9 -36
- package/srv/blockchain/signing/submission-finalizer.js +16 -49
- package/srv/blockchain/stored-chain.d.ts +33 -0
- package/srv/blockchain/stored-chain.js +234 -0
- package/srv/blockchain/transaction-building/buildooor-tx.d.ts +111 -173
- package/srv/blockchain/transaction-building/buildooor-tx.js +649 -326
- package/srv/blockchain/transaction-building/caller-datums.d.ts +29 -0
- package/srv/blockchain/transaction-building/caller-datums.js +139 -0
- package/srv/blockchain/transaction-building/cardano-tx.d.ts +10 -35
- package/srv/blockchain/transaction-rows.d.ts +12 -0
- package/srv/blockchain/transaction-rows.js +43 -0
- package/srv/blockchain/wallet-worker/build-request.d.ts +4 -17
- package/srv/blockchain/wallet-worker/build-request.js +18 -23
- package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +25 -17
- package/srv/blockchain/wallet-worker/confirmation-tracker.js +87 -41
- package/srv/blockchain/wallet-worker/index.js +2 -8
- package/srv/blockchain/wallet-worker/job-store.d.ts +36 -103
- package/srv/blockchain/wallet-worker/job-store.js +0 -0
- package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +4 -20
- package/srv/blockchain/wallet-worker/lease-heartbeat.js +4 -20
- package/srv/blockchain/wallet-worker/signers.d.ts +6 -19
- package/srv/blockchain/wallet-worker/signers.js +3 -8
- package/srv/blockchain/wallet-worker/wallet-worker.d.ts +15 -71
- package/srv/blockchain/wallet-worker/wallet-worker.js +40 -91
- package/srv/cardano-agent-service.cds +146 -0
- package/srv/cardano-agent-service.d.ts +2 -0
- package/srv/cardano-agent-service.js +12 -0
- package/srv/cardano-backend-service.cds +52 -0
- package/srv/cardano-backend-service.d.ts +2 -0
- package/srv/cardano-backend-service.js +244 -0
- package/srv/cardano-indexer-service.cds +201 -73
- package/srv/cardano-indexer-service.js +280 -11
- package/srv/cardano-service.cds +65 -2
- package/srv/cardano-service.js +170 -129
- package/srv/cardano-sign-service.cds +200 -180
- package/srv/cardano-sign-service.js +57 -184
- package/srv/cardano-tx-service.cds +439 -370
- package/srv/cardano-tx-service.js +231 -190
- package/srv/cardano-ui.cds +16 -16
- package/srv/cardano-worker-service.js +7 -15
- package/srv/cbor/index.d.ts +1 -1
- package/srv/cbor/parse.d.ts +27 -0
- package/srv/cbor/parse.js +63 -2
- package/srv/server.d.ts +28 -86
- package/srv/server.js +132 -135
- package/srv/utils/agent-grants-config.d.ts +37 -0
- package/srv/utils/agent-grants-config.js +138 -0
- package/srv/utils/agent-grants.d.ts +262 -0
- package/srv/utils/agent-grants.js +922 -0
- package/srv/utils/agent-token-auth.d.ts +16 -0
- package/srv/utils/agent-token-auth.js +78 -0
- package/srv/utils/backend-request-handler.d.ts +2 -16
- package/srv/utils/backend-request-handler.js +3 -18
- package/srv/utils/collections.d.ts +4 -8
- package/srv/utils/collections.js +4 -8
- package/srv/utils/const.d.ts +30 -67
- package/srv/utils/const.js +32 -72
- package/srv/utils/crypto.d.ts +3 -12
- package/srv/utils/crypto.js +5 -18
- package/srv/utils/db-indexes.d.ts +25 -0
- package/srv/utils/db-indexes.js +94 -0
- package/srv/utils/db-sanitize.d.ts +27 -0
- package/srv/utils/db-sanitize.js +85 -0
- package/srv/utils/epoch-slots.d.ts +20 -0
- package/srv/utils/epoch-slots.js +43 -0
- package/srv/utils/error-codes.d.ts +20 -73
- package/srv/utils/error-codes.js +19 -70
- package/srv/utils/errors.d.ts +50 -177
- package/srv/utils/errors.js +94 -218
- package/srv/utils/legacy-service-paths.d.ts +11 -0
- package/srv/utils/legacy-service-paths.js +58 -0
- package/srv/utils/liveness.d.ts +16 -0
- package/srv/utils/liveness.js +40 -0
- package/srv/utils/mappers.d.ts +128 -214
- package/srv/utils/mappers.js +354 -299
- package/srv/utils/network-context.js +2 -11
- package/srv/utils/pg-inline-json.d.ts +8 -0
- package/srv/utils/pg-inline-json.js +62 -0
- package/srv/utils/pg-order-nulls.d.ts +14 -0
- package/srv/utils/pg-order-nulls.js +56 -0
- package/srv/utils/plutus-placeholders.d.ts +23 -16
- package/srv/utils/plutus-placeholders.js +63 -27
- package/srv/utils/rate-limiter.d.ts +46 -0
- package/srv/utils/rate-limiter.js +116 -0
- package/srv/utils/service-events.d.ts +2 -22
- package/srv/utils/service-events.js +3 -23
- package/srv/utils/signing-helper.d.ts +6 -16
- package/srv/utils/signing-helper.js +36 -60
- package/srv/utils/tx-build-helper.d.ts +28 -93
- package/srv/utils/tx-build-helper.js +75 -124
- package/srv/utils/tx-request-parsers.d.ts +101 -28
- package/srv/utils/tx-request-parsers.js +410 -43
- package/srv/utils/tx-utils.d.ts +4 -23
- package/srv/utils/tx-utils.js +12 -41
- package/srv/utils/types.d.ts +252 -179
- package/srv/utils/types.js +2 -6
- package/srv/utils/validators.d.ts +24 -90
- package/srv/utils/validators.js +50 -147
package/srv/cardano-ui.cds
CHANGED
|
@@ -891,13 +891,13 @@ annotate srv.Addresses with @(
|
|
|
891
891
|
$Type : 'UI.ReferenceFacet',
|
|
892
892
|
Label : 'Assets',
|
|
893
893
|
Target : 'assets/@UI.LineItem',
|
|
894
|
-
|
|
894
|
+
@UI.Hidden: (not hasAssets)
|
|
895
895
|
},
|
|
896
896
|
{
|
|
897
897
|
$Type : 'UI.ReferenceFacet',
|
|
898
898
|
Label : 'UTxOs',
|
|
899
899
|
Target : 'utxos/@UI.LineItem',
|
|
900
|
-
|
|
900
|
+
@UI.Hidden: (not hasUTxOs)
|
|
901
901
|
}
|
|
902
902
|
],
|
|
903
903
|
|
|
@@ -1075,7 +1075,7 @@ annotate srv.AddressUTxOs with @(
|
|
|
1075
1075
|
$Type : 'UI.ReferenceFacet',
|
|
1076
1076
|
Label : 'Assets',
|
|
1077
1077
|
Target : 'assets/@UI.LineItem',
|
|
1078
|
-
|
|
1078
|
+
@UI.Hidden: (not hasAssets)
|
|
1079
1079
|
},
|
|
1080
1080
|
{
|
|
1081
1081
|
$Type : 'UI.ReferenceFacet',
|
|
@@ -1305,19 +1305,19 @@ annotate srv.Transactions with @(
|
|
|
1305
1305
|
$Type : 'UI.ReferenceFacet',
|
|
1306
1306
|
Label : 'Metadata',
|
|
1307
1307
|
Target : 'metadata/@UI.LineItem',
|
|
1308
|
-
|
|
1308
|
+
@UI.Hidden: (not hasMetadata)
|
|
1309
1309
|
},
|
|
1310
1310
|
{
|
|
1311
1311
|
$Type : 'UI.ReferenceFacet',
|
|
1312
1312
|
Label : 'Inputs',
|
|
1313
1313
|
Target : 'inputs/@UI.LineItem',
|
|
1314
|
-
|
|
1314
|
+
@UI.Hidden: (not hasInputs)
|
|
1315
1315
|
},
|
|
1316
1316
|
{
|
|
1317
1317
|
$Type : 'UI.ReferenceFacet',
|
|
1318
1318
|
Label : 'Outputs',
|
|
1319
1319
|
Target : 'outputs/@UI.LineItem',
|
|
1320
|
-
|
|
1320
|
+
@UI.Hidden: (not hasOutputs)
|
|
1321
1321
|
}
|
|
1322
1322
|
],
|
|
1323
1323
|
|
|
@@ -1451,7 +1451,7 @@ annotate srv.TransactionInputs with @(
|
|
|
1451
1451
|
$Type : 'UI.ReferenceFacet',
|
|
1452
1452
|
Label : 'Assets',
|
|
1453
1453
|
Target : 'assets/@UI.LineItem',
|
|
1454
|
-
|
|
1454
|
+
@UI.Hidden: (not hasAssets)
|
|
1455
1455
|
},
|
|
1456
1456
|
{
|
|
1457
1457
|
$Type : 'UI.ReferenceFacet',
|
|
@@ -1625,7 +1625,7 @@ annotate srv.TransactionOutputs with @(
|
|
|
1625
1625
|
$Type : 'UI.ReferenceFacet',
|
|
1626
1626
|
Label : 'Assets',
|
|
1627
1627
|
Target : 'assets/@UI.LineItem',
|
|
1628
|
-
|
|
1628
|
+
@UI.Hidden: (not hasAssets)
|
|
1629
1629
|
},
|
|
1630
1630
|
{
|
|
1631
1631
|
$Type : 'UI.ReferenceFacet',
|
|
@@ -1860,7 +1860,7 @@ annotate srv.Accounts with @(
|
|
|
1860
1860
|
$Type : 'UI.ReferenceFacet',
|
|
1861
1861
|
Label : 'Addresses',
|
|
1862
1862
|
Target : 'Address/@UI.LineItem',
|
|
1863
|
-
|
|
1863
|
+
@UI.Hidden: (not hasAddresses)
|
|
1864
1864
|
}
|
|
1865
1865
|
],
|
|
1866
1866
|
|
|
@@ -2301,19 +2301,19 @@ annotate txsrv.TransactionBuilds with @(
|
|
|
2301
2301
|
$Type : 'UI.ReferenceFacet',
|
|
2302
2302
|
Label : 'Inputs',
|
|
2303
2303
|
Target : 'inputs/@UI.LineItem',
|
|
2304
|
-
|
|
2304
|
+
@UI.Hidden: (not hasInputs)
|
|
2305
2305
|
},
|
|
2306
2306
|
{
|
|
2307
2307
|
$Type : 'UI.ReferenceFacet',
|
|
2308
2308
|
Label : 'Outputs',
|
|
2309
2309
|
Target : 'outputs/@UI.LineItem',
|
|
2310
|
-
|
|
2310
|
+
@UI.Hidden: (not hasOutputs)
|
|
2311
2311
|
},
|
|
2312
2312
|
{
|
|
2313
2313
|
$Type : 'UI.ReferenceFacet',
|
|
2314
2314
|
Label : 'Submission',
|
|
2315
2315
|
Target : 'submission/@UI.FieldGroup#SubmissionDetails',
|
|
2316
|
-
|
|
2316
|
+
@UI.Hidden: (not wasSubmitted)
|
|
2317
2317
|
}
|
|
2318
2318
|
],
|
|
2319
2319
|
|
|
@@ -2439,7 +2439,7 @@ annotate txsrv.TransactionBuildInputs with @(
|
|
|
2439
2439
|
$Type : 'UI.ReferenceFacet',
|
|
2440
2440
|
Label : 'Assets',
|
|
2441
2441
|
Target : 'assets/@UI.LineItem',
|
|
2442
|
-
|
|
2442
|
+
@UI.Hidden: (not hasAssets)
|
|
2443
2443
|
},
|
|
2444
2444
|
{
|
|
2445
2445
|
$Type : 'UI.ReferenceFacet',
|
|
@@ -2611,7 +2611,7 @@ annotate txsrv.TransactionBuildOutputs with @(
|
|
|
2611
2611
|
$Type : 'UI.ReferenceFacet',
|
|
2612
2612
|
Label : 'Assets',
|
|
2613
2613
|
Target : 'assets/@UI.LineItem',
|
|
2614
|
-
|
|
2614
|
+
@UI.Hidden: (not hasAssets)
|
|
2615
2615
|
},
|
|
2616
2616
|
{
|
|
2617
2617
|
$Type : 'UI.ReferenceFacet',
|
|
@@ -2796,13 +2796,13 @@ annotate txsrv.TransactionSubmissions with @(
|
|
|
2796
2796
|
$Type : 'UI.ReferenceFacet',
|
|
2797
2797
|
Label : 'Error Details',
|
|
2798
2798
|
Target : '@UI.FieldGroup#ErrorDetails',
|
|
2799
|
-
|
|
2799
|
+
@UI.Hidden: (not hasErrors)
|
|
2800
2800
|
},
|
|
2801
2801
|
{
|
|
2802
2802
|
$Type : 'UI.ReferenceFacet',
|
|
2803
2803
|
Label : 'Errors',
|
|
2804
2804
|
Target : 'errors/@UI.LineItem',
|
|
2805
|
-
|
|
2805
|
+
@UI.Hidden: (not hasErrors)
|
|
2806
2806
|
}
|
|
2807
2807
|
],
|
|
2808
2808
|
|
|
@@ -13,22 +13,16 @@ const job_store_1 = require("./blockchain/wallet-worker/job-store");
|
|
|
13
13
|
const server_1 = require("./server");
|
|
14
14
|
const logger = cds_1.default.log('CardanoWorkerService');
|
|
15
15
|
/**
|
|
16
|
-
* CardanoWorkerService handlers
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* Validation rejections happen BEFORE handleRequest (project convention); the
|
|
21
|
-
* job INSERT runs on the request's ambient transaction (NIGHTGATE lesson 1).
|
|
16
|
+
* CardanoWorkerService handlers: control surface over the wallet-worker singleton
|
|
17
|
+
* (srv/blockchain/wallet-worker). Validates inputs, inserts/reads job rows, starts/stops
|
|
18
|
+
* the worker. The job INSERT runs on the request's ambient transaction.
|
|
22
19
|
*/
|
|
23
20
|
function isAdmin(req) {
|
|
24
21
|
return req.user?.is?.('Admin') ?? false;
|
|
25
22
|
}
|
|
26
23
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* cardano-sign-service.ts) — 'authenticated-user' alone must not reach the HSM.
|
|
30
|
-
* Returns the role the caller is missing, or null when the wallet is not HSM-backed,
|
|
31
|
-
* no role is configured, or the caller holds it.
|
|
24
|
+
* HSM-backed wallets inherit the SignWithHsm role gate (enforceHsmRole in the sign service).
|
|
25
|
+
* Returns the role the caller is missing, or null when not HSM-backed, no role configured, or held.
|
|
32
26
|
*/
|
|
33
27
|
function missingHsmRole(req, signerType) {
|
|
34
28
|
if (signerType !== 'hsm')
|
|
@@ -125,10 +119,8 @@ module.exports = (srv) => {
|
|
|
125
119
|
return (0, backend_request_handler_1.handleRequest)(req, async (db) => {
|
|
126
120
|
const job = await (0, job_store_1.getJobById)(db, jobId);
|
|
127
121
|
if (!job || (!isAdmin(req) && job.createdBy !== req.user?.id)) {
|
|
128
|
-
// Same 404 for "not found" and "not yours"
|
|
129
|
-
//
|
|
130
|
-
// see a plain CAP error and remap it to 500 (mapError). A BackendError
|
|
131
|
-
// carries its status through.
|
|
122
|
+
// Same 404 for "not found" and "not yours" (no existence oracle). Throw, don't
|
|
123
|
+
// req.reject: inside handleRequest a plain CAP error is remapped to 500.
|
|
132
124
|
throw new errors_1.NotFoundError(`Job ${jobId}`);
|
|
133
125
|
}
|
|
134
126
|
const cancelled = await (0, job_store_1.markCancelled)(db, jobId);
|
package/srv/cbor/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { parseTransaction, type ParsedTransaction, type ParsedInput, type ParsedOutput, type ParsedAsset, type ParsedWitnesses, } from './parse';
|
|
1
|
+
export { parseTransaction, type ParsedTransaction, type ParsedInput, type ParsedOutput, type ParsedAsset, type ParsedWitnesses, type ParsedWithdrawal, type ParsedCertificate, } from './parse';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/srv/cbor/parse.d.ts
CHANGED
|
@@ -15,6 +15,19 @@ export interface ParsedOutput {
|
|
|
15
15
|
datumHash: string | null;
|
|
16
16
|
inlineDatumHex: string | null;
|
|
17
17
|
referenceScriptHex: string | null;
|
|
18
|
+
/** Byte length of the output as it stands in the transaction. */
|
|
19
|
+
cborSize: number;
|
|
20
|
+
}
|
|
21
|
+
export interface ParsedWithdrawal {
|
|
22
|
+
/** Bech32 reward address. */
|
|
23
|
+
rewardAddress: string;
|
|
24
|
+
lovelace: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ParsedCertificate {
|
|
27
|
+
/** Position in the body's certificate list. */
|
|
28
|
+
index: number;
|
|
29
|
+
/** Ledger certificate name, e.g. `StakeDelegation` or `RegistrationDrep`. */
|
|
30
|
+
type: string;
|
|
18
31
|
}
|
|
19
32
|
export interface ParsedWitnesses {
|
|
20
33
|
vkeyCount: number;
|
|
@@ -35,6 +48,8 @@ export interface ParsedTransaction {
|
|
|
35
48
|
* consumer needing that split must compare against the service network.
|
|
36
49
|
*/
|
|
37
50
|
network: 'mainnet' | 'testnet' | null;
|
|
51
|
+
/** Body field 15: 1 = mainnet, 0 = testnet, null if absent. */
|
|
52
|
+
networkId: number | null;
|
|
38
53
|
inputs: ParsedInput[];
|
|
39
54
|
outputs: ParsedOutput[];
|
|
40
55
|
/** Validity-interval start slot (decimal string) or `null` if absent. */
|
|
@@ -48,9 +63,21 @@ export interface ParsedTransaction {
|
|
|
48
63
|
/** Metadata labels present (uint64 → decimal string); full payload via GetMetadataByTxHash for submitted txs. */
|
|
49
64
|
metadataLabels: string[];
|
|
50
65
|
collateral: ParsedInput[];
|
|
66
|
+
referenceInputs: ParsedInput[];
|
|
67
|
+
withdrawals: ParsedWithdrawal[];
|
|
68
|
+
certificates: ParsedCertificate[];
|
|
69
|
+
/** Number of votes over all voters; 0 if the body has no voting procedures. */
|
|
70
|
+
votingProcedures: number;
|
|
71
|
+
proposalProcedures: number;
|
|
72
|
+
/** Lovelace (decimal string) or `null` if absent. */
|
|
73
|
+
treasuryDonation: string | null;
|
|
74
|
+
/** Lovelace (decimal string) or `null` if absent. */
|
|
75
|
+
currentTreasuryValue: string | null;
|
|
51
76
|
/** 28-byte Ed25519 key hashes listed in the tx body's required_signers field. */
|
|
52
77
|
requiredSigners: string[];
|
|
53
78
|
scriptDataHash: string | null;
|
|
79
|
+
/** `false` when the transaction is flagged as failing its scripts. On chain it then spends only the collateral and creates no outputs. */
|
|
80
|
+
isValid: boolean;
|
|
54
81
|
witnesses: ParsedWitnesses;
|
|
55
82
|
}
|
|
56
83
|
/**
|
package/srv/cbor/parse.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseTransaction = parseTransaction;
|
|
4
4
|
const buildooor_1 = require("@harmoniclabs/buildooor");
|
|
5
|
+
const cardano_ledger_ts_1 = require("@harmoniclabs/cardano-ledger-ts");
|
|
6
|
+
const cbor_1 = require("@harmoniclabs/cbor");
|
|
5
7
|
const errors_1 = require("../utils/errors");
|
|
6
8
|
const error_codes_1 = require("../utils/error-codes");
|
|
7
9
|
/**
|
|
@@ -13,8 +15,12 @@ const error_codes_1 = require("../utils/error-codes");
|
|
|
13
15
|
*/
|
|
14
16
|
function parseTransaction(cborHex) {
|
|
15
17
|
let tx;
|
|
18
|
+
let raw;
|
|
16
19
|
try {
|
|
17
|
-
|
|
20
|
+
// one decode for both readers; keepRef keeps the original bytes for the body hash and datums
|
|
21
|
+
const parsed = cbor_1.Cbor.parse(Buffer.from(cborHex, 'hex'), { keepRef: true });
|
|
22
|
+
tx = buildooor_1.Tx.fromCborObj(parsed);
|
|
23
|
+
raw = readBodyFields(parsed);
|
|
18
24
|
}
|
|
19
25
|
catch (e) {
|
|
20
26
|
const msg = e instanceof Error ? e.message : String(e);
|
|
@@ -24,6 +30,7 @@ function parseTransaction(cborHex) {
|
|
|
24
30
|
return {
|
|
25
31
|
txHash: body.hash.toString(),
|
|
26
32
|
network: normalizeNetwork(body.network),
|
|
33
|
+
networkId: raw.networkId,
|
|
27
34
|
inputs: body.inputs.map(mapInput),
|
|
28
35
|
outputs: body.outputs.map(mapOutput),
|
|
29
36
|
validityStart: body.validityIntervalStart != null ? body.validityIntervalStart.toString() : null,
|
|
@@ -32,8 +39,19 @@ function parseTransaction(cborHex) {
|
|
|
32
39
|
mint: mapMint(body.mint),
|
|
33
40
|
metadataLabels: extractMetadataLabels(tx.auxiliaryData),
|
|
34
41
|
collateral: (body.collateralInputs ?? []).map(mapInput),
|
|
42
|
+
referenceInputs: (body.refInputs ?? []).map(mapInput),
|
|
43
|
+
withdrawals: (body.withdrawals?.map ?? []).map((w) => ({
|
|
44
|
+
rewardAddress: w.rewardAccount.toString(),
|
|
45
|
+
lovelace: w.amount.toString(),
|
|
46
|
+
})),
|
|
47
|
+
certificates: (body.certs ?? []).map(mapCertificate),
|
|
48
|
+
votingProcedures: raw.votingProcedures,
|
|
49
|
+
proposalProcedures: raw.proposalProcedures,
|
|
50
|
+
treasuryDonation: raw.treasuryDonation,
|
|
51
|
+
currentTreasuryValue: raw.currentTreasuryValue,
|
|
35
52
|
requiredSigners: (body.requiredSigners ?? []).map((s) => s.toString()),
|
|
36
53
|
scriptDataHash: body.scriptDataHash ? body.scriptDataHash.toString() : null,
|
|
54
|
+
isValid: tx.isScriptValid,
|
|
37
55
|
witnesses: countWitnesses(tx.witnesses),
|
|
38
56
|
};
|
|
39
57
|
}
|
|
@@ -66,7 +84,7 @@ function mapOutput(out) {
|
|
|
66
84
|
}
|
|
67
85
|
else {
|
|
68
86
|
// anything not a Hash32 is an inline `Data` (PlutusData) payload
|
|
69
|
-
inlineDatumHex = Buffer.from((0, buildooor_1.dataToCbor)(out.datum)).toString('hex');
|
|
87
|
+
inlineDatumHex = Buffer.from(inlineDatumBytes(out) ?? (0, buildooor_1.dataToCbor)(out.datum)).toString('hex');
|
|
70
88
|
}
|
|
71
89
|
}
|
|
72
90
|
const referenceScriptHex = out.refScript
|
|
@@ -79,8 +97,51 @@ function mapOutput(out) {
|
|
|
79
97
|
datumHash,
|
|
80
98
|
inlineDatumHex,
|
|
81
99
|
referenceScriptHex,
|
|
100
|
+
// the bytes as received; a re-encoding can be shorter
|
|
101
|
+
cborSize: out.cborRef ? out.cborRef.toBuffer().length : out.toCborBytes().length,
|
|
82
102
|
};
|
|
83
103
|
}
|
|
104
|
+
function mapCertificate(cert, index) {
|
|
105
|
+
return { index, type: (0, cardano_ledger_ts_1.certTypeToString)(cert.certType) };
|
|
106
|
+
}
|
|
107
|
+
/** Body fields 15 and 19 to 22 as they stand in the bytes. `Tx.fromCbor` drops 19 to 22 and maps any network byte other than 0 to mainnet. */
|
|
108
|
+
function readBodyFields(parsed) {
|
|
109
|
+
const body = parsed instanceof cbor_1.CborArray ? parsed.array[0] : undefined;
|
|
110
|
+
const field = (key) => body instanceof cbor_1.CborMap ? body.map.find(e => e.k instanceof cbor_1.CborUInt && e.k.num === BigInt(key))?.v : undefined;
|
|
111
|
+
const uint = (key) => {
|
|
112
|
+
const v = field(key);
|
|
113
|
+
return v instanceof cbor_1.CborUInt ? v.num : null;
|
|
114
|
+
};
|
|
115
|
+
// voting_procedures = { voter => { gov_action_id => voting_procedure } }
|
|
116
|
+
const voting = field(19);
|
|
117
|
+
const votes = voting instanceof cbor_1.CborMap
|
|
118
|
+
? voting.map.reduce((n, e) => n + (e.v instanceof cbor_1.CborMap ? e.v.map.length : 0), 0)
|
|
119
|
+
: 0;
|
|
120
|
+
const networkId = uint(15);
|
|
121
|
+
return {
|
|
122
|
+
networkId: networkId == null ? null : Number(networkId),
|
|
123
|
+
votingProcedures: votes,
|
|
124
|
+
proposalProcedures: setItems(field(20)).length,
|
|
125
|
+
treasuryDonation: uint(22)?.toString() ?? null,
|
|
126
|
+
currentTreasuryValue: uint(21)?.toString() ?? null,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/** Items of a CBOR set, with or without the Conway set tag 258. */
|
|
130
|
+
function setItems(obj) {
|
|
131
|
+
const inner = obj instanceof cbor_1.CborTag ? obj.data : obj;
|
|
132
|
+
return inner instanceof cbor_1.CborArray ? inner.array : [];
|
|
133
|
+
}
|
|
134
|
+
/** Inline datum bytes as they stand in the transaction; decoding and re-encoding may change them. */
|
|
135
|
+
function inlineDatumBytes(out) {
|
|
136
|
+
if (!out.cborRef)
|
|
137
|
+
return undefined;
|
|
138
|
+
const parsed = cbor_1.Cbor.parse(out.toCborBytes());
|
|
139
|
+
if (!(parsed instanceof cbor_1.CborMap))
|
|
140
|
+
return undefined;
|
|
141
|
+
const option = parsed.map.find(e => e.k instanceof cbor_1.CborUInt && e.k.num === 2n)?.v;
|
|
142
|
+
const tagged = option instanceof cbor_1.CborArray ? option.array[1] : undefined;
|
|
143
|
+
return tagged instanceof cbor_1.CborTag && tagged.data instanceof cbor_1.CborBytes ? tagged.data.bytes : undefined;
|
|
144
|
+
}
|
|
84
145
|
function mapMint(mint) {
|
|
85
146
|
if (!mint)
|
|
86
147
|
return [];
|
package/srv/server.d.ts
CHANGED
|
@@ -4,126 +4,68 @@ import { CardanoTransactionBuilder } from './blockchain/cardano-tx-builder';
|
|
|
4
4
|
import type { LedgerProtocolParameters, HsmConfig } from './utils/types';
|
|
5
5
|
import type { CrawlerConfig } from './blockchain/crawler/crawler';
|
|
6
6
|
import type { WalletWorkerConfig } from './blockchain/wallet-worker';
|
|
7
|
-
/**
|
|
8
|
-
* Application context holding initialized blockchain components
|
|
9
|
-
* These are created once during CAP bootstrap and shared across services
|
|
10
|
-
*/
|
|
7
|
+
/** Blockchain components created once at bootstrap and shared across services. */
|
|
11
8
|
interface AppContext {
|
|
12
9
|
cardanoClient: CardanoClient;
|
|
13
10
|
cardanoIndexer: CardanoIndexer;
|
|
14
11
|
cardanoTxBuilder: CardanoTransactionBuilder;
|
|
15
12
|
}
|
|
13
|
+
/** Agent-grant feature switch; its own module so src/plugin.ts can read it at load. */
|
|
14
|
+
export { loadAgentGrantsConfig, activateAgentGrants } from './utils/agent-grants-config';
|
|
16
15
|
/**
|
|
17
|
-
*
|
|
18
|
-
* @throws {ProviderUnavailableError} 503 when uninitialized
|
|
19
|
-
* handleRequest/mapError translate this into a clean 503 response instead of a raw 500.
|
|
20
|
-
* If bootstrap actively failed, the cause is appended to the message.
|
|
16
|
+
* The application context.
|
|
17
|
+
* @throws {ProviderUnavailableError} 503 when uninitialized; a bootstrap failure is appended as cause.
|
|
21
18
|
*/
|
|
22
19
|
export declare function getAppContext(): AppContext;
|
|
23
|
-
/**
|
|
24
|
-
* Get the CardanoIndexer instance
|
|
25
|
-
* Convenience function for services
|
|
26
|
-
*/
|
|
27
20
|
export declare function getCardanoIndexer(): CardanoIndexer;
|
|
28
|
-
/**
|
|
29
|
-
* Get the CardanoClient instance
|
|
30
|
-
* Convenience function for services
|
|
31
|
-
*/
|
|
32
21
|
export declare function getCardanoClient(): CardanoClient;
|
|
33
|
-
/**
|
|
34
|
-
* Get the CardanoTransactionBuilder instance
|
|
35
|
-
* Convenience function for services and plugin consumers
|
|
36
|
-
*/
|
|
37
22
|
export declare function getCardanoTxBuilder(): CardanoTransactionBuilder;
|
|
38
|
-
/**
|
|
39
|
-
* Get the HSM configuration (if HSM is enabled).
|
|
40
|
-
* Used by sign service to check requiresRole.
|
|
41
|
-
*/
|
|
23
|
+
/** HSM configuration when enabled; the sign service reads requiresRole from it. */
|
|
42
24
|
export declare function getHsmConfig(): HsmConfig | undefined;
|
|
43
25
|
/**
|
|
44
|
-
* Initialize from a pre-built config (
|
|
45
|
-
*
|
|
46
|
-
* @param protocolParams - Optional protocol parameters (for tests)
|
|
26
|
+
* Initialize from a pre-built config (plugin path). Idempotent: a second call must not
|
|
27
|
+
* create a duplicate CardanoClient; tests reinitialize via resetAppContext() / createTestContext().
|
|
47
28
|
*/
|
|
48
29
|
export declare function initializeFromConfig(config: CardanoClientConfig, protocolParams?: LedgerProtocolParameters, hsmConfig?: HsmConfig): Promise<void>;
|
|
49
|
-
/**
|
|
50
|
-
* Reset the application context (for testing only)
|
|
51
|
-
* Allows tests to inject their own instances
|
|
52
|
-
*/
|
|
30
|
+
/** Reset the application context (tests only); lets tests inject their own instances. */
|
|
53
31
|
export declare function resetAppContext(context: AppContext | null): void;
|
|
54
32
|
/**
|
|
55
|
-
* Create
|
|
56
|
-
*
|
|
57
|
-
* @param
|
|
58
|
-
* @param _txBuilderName Deprecated/ignored — Buildooor is the sole transaction builder (kept for signature compatibility)
|
|
59
|
-
* @param protocolParams Optional protocol parameters (to skip backend call during init)
|
|
60
|
-
* @returns Promise<AppContext> The created application context
|
|
61
|
-
*/
|
|
62
|
-
export declare function createTestContext(backends: BackendName[], _txBuilderName?: TransactionBuilderName, // kept for signature compat; Buildooor is the only builder
|
|
63
|
-
protocolParams?: LedgerProtocolParameters): Promise<AppContext>;
|
|
64
|
-
/**
|
|
65
|
-
* Shutdown the application context (for cleanup in tests)
|
|
66
|
-
* Closes all backend connections to allow process to exit cleanly
|
|
33
|
+
* Create an isolated test context with the given backends.
|
|
34
|
+
* @param _txBuilderName ignored; Buildooor is the sole builder (kept for signature compatibility)
|
|
35
|
+
* @param protocolParams optional, skips the backend call during init
|
|
67
36
|
*/
|
|
37
|
+
export declare function createTestContext(backends: BackendName[], _txBuilderName?: TransactionBuilderName, protocolParams?: LedgerProtocolParameters): Promise<AppContext>;
|
|
38
|
+
/** Stop worker and crawler, then close all backend connections. */
|
|
68
39
|
export declare function shutdownAppContext(): Promise<void>;
|
|
69
40
|
/**
|
|
70
|
-
* Load and validate CardanoClientConfig
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* { "cds": { "requires": { "odatano-core": { "network": "preview", "backends": ["blockfrost"], ... }}}}
|
|
74
|
-
*
|
|
75
|
-
* Priority: cds.env.requires["odatano-core"].X > process.env.X > default
|
|
76
|
-
*
|
|
77
|
-
* @returns validated CardanoClientConfig
|
|
78
|
-
* @throws {Error} if any config value is invalid
|
|
41
|
+
* Load and validate CardanoClientConfig.
|
|
42
|
+
* Priority: cds.env.requires["odatano-core"].X > process.env.X > default.
|
|
43
|
+
* @throws {ConfigError} if any value is invalid
|
|
79
44
|
*/
|
|
80
45
|
export declare function loadConfigFromEnv(): CardanoClientConfig;
|
|
81
46
|
/**
|
|
82
|
-
* Load HSM configuration
|
|
83
|
-
* Returns undefined
|
|
84
|
-
*
|
|
85
|
-
* Plugin mode: cds.requires.odatano-core.hsm.enabled = true
|
|
86
|
-
* Env mode: HSM_ENABLED=true
|
|
87
|
-
*
|
|
88
|
-
* @returns HsmConfig or undefined
|
|
47
|
+
* Load the HSM configuration (cds.requires.odatano-core.hsm.* or HSM_* env vars).
|
|
48
|
+
* Returns undefined when HSM is not enabled.
|
|
89
49
|
*/
|
|
90
50
|
export declare function loadHsmConfigFromEnv(): HsmConfig | undefined;
|
|
91
51
|
/**
|
|
92
|
-
* Load the chain-crawler configuration
|
|
93
|
-
* Returns { enabled:false } when the crawler is
|
|
94
|
-
* existing deployments are unaffected.
|
|
95
|
-
*
|
|
96
|
-
* Plugin mode: cds.requires.odatano-core.crawler.{enabled,startSlot,startBlockHash,...}
|
|
97
|
-
* Env mode: CRAWLER_ENABLED / CRAWLER_START_SLOT / CRAWLER_START_HASH / ...
|
|
52
|
+
* Load the chain-crawler configuration (cds.requires.odatano-core.crawler.* or CRAWLER_* env vars).
|
|
53
|
+
* Returns { enabled: false } when the crawler is off (the default).
|
|
98
54
|
*/
|
|
99
55
|
export declare function loadCrawlerConfigFromEnv(): CrawlerConfig;
|
|
100
|
-
/**
|
|
101
|
-
* Start the chain crawler if it is enabled and the app context is ready. Never throws
|
|
102
|
-
* (crawler failure must not affect request serving) — errors are logged. Idempotent:
|
|
103
|
-
* startCrawler() is a no-op when one is already running.
|
|
104
|
-
*/
|
|
56
|
+
/** Start the crawler if enabled and the app context is ready. Never throws; idempotent. */
|
|
105
57
|
export declare function startCrawlerIfConfigured(): Promise<void>;
|
|
106
58
|
/**
|
|
107
|
-
* Load the wallet-worker configuration
|
|
108
|
-
* Returns { enabled:false } when the worker is
|
|
109
|
-
*
|
|
110
|
-
* Plugin mode: cds.requires.odatano-core.walletWorker.{enabled,wallets,...}
|
|
111
|
-
* Env mode: WALLET_WORKER_ENABLED / WALLET_WORKER_WALLETS (JSON) / ...
|
|
59
|
+
* Load the wallet-worker configuration (cds.requires.odatano-core.walletWorker.* or WALLET_WORKER_* env vars).
|
|
60
|
+
* Returns { enabled: false } when the worker is off (the default).
|
|
112
61
|
*/
|
|
113
62
|
export declare function loadWalletWorkerConfigFromEnv(): WalletWorkerConfig;
|
|
114
|
-
/**
|
|
115
|
-
* Start the wallet worker if it is enabled and the app context is ready. Never
|
|
116
|
-
* throws (worker failure must not affect request serving) — errors are logged.
|
|
117
|
-
* Idempotent: startWalletWorker() is a no-op when one is already running.
|
|
118
|
-
*/
|
|
63
|
+
/** Start the wallet worker if enabled and the app context is ready. Never throws; idempotent. */
|
|
119
64
|
export declare function startWalletWorkerIfConfigured(): Promise<void>;
|
|
120
65
|
/**
|
|
121
|
-
* Re-drive deferred submissions
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
* submitted tx finalizes via the TransactionAlreadySubmittedError path.
|
|
125
|
-
* Non-fatal, mirrors startCrawlerIfConfigured/startWalletWorkerIfConfigured.
|
|
66
|
+
* Re-drive deferred submissions claimed as 'submitting' whose detached submit never ran
|
|
67
|
+
* (process died first). Idempotent: an already submitted tx finalizes via
|
|
68
|
+
* TransactionAlreadySubmittedError. Never throws.
|
|
126
69
|
*/
|
|
127
70
|
export declare function redriveInterruptedSubmissionsIfConfigured(): Promise<void>;
|
|
128
|
-
export {};
|
|
129
71
|
//# sourceMappingURL=server.d.ts.map
|