@odatano/core 2.0.0-rc.5 → 2.0.0-rc.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@cds-models/CardanoAgentService/index.d.ts +99 -51
- package/@cds-models/CardanoAgentService/index.js +15 -0
- package/@cds-models/CardanoBackendService/index.d.ts +347 -0
- package/@cds-models/CardanoBackendService/index.js +40 -0
- package/@cds-models/CardanoIndexerService/index.d.ts +496 -11
- package/@cds-models/CardanoIndexerService/index.js +64 -0
- package/@cds-models/CardanoODataService/index.d.ts +414 -57
- package/@cds-models/CardanoODataService/index.js +42 -0
- package/@cds-models/CardanoSignService/index.d.ts +32 -19
- package/@cds-models/CardanoSignService/index.js +3 -0
- package/@cds-models/CardanoTransactionService/index.d.ts +58 -44
- package/@cds-models/CardanoTransactionService/index.js +4 -0
- package/@cds-models/CardanoWorkerService/index.d.ts +7 -22
- package/@cds-models/index.d.ts +101 -1
- package/@cds-models/index.js +16 -1
- package/@cds-models/odatano/cardano/index.d.ts +437 -32
- package/@cds-models/odatano/cardano/index.js +48 -0
- package/README.md +207 -167
- package/db/schema.cds +2402 -1705
- package/db/types.cds +446 -295
- package/package.json +41 -16
- package/scripts/migrate-schema.mjs +334 -0
- package/scripts/migrate-slot-leader.mjs +96 -0
- package/src/index.d.ts +20 -21
- package/src/index.js +45 -31
- package/src/plugin.js +17 -35
- package/srv/blockchain/asset-decimals.d.ts +7 -0
- package/srv/blockchain/asset-decimals.js +91 -0
- package/srv/blockchain/backends/blockfrost-backend.d.ts +25 -135
- package/srv/blockchain/backends/blockfrost-backend.js +66 -172
- package/srv/blockchain/backends/cardano-backend.d.ts +94 -186
- package/srv/blockchain/backends/cardano-backend.js +29 -5
- package/srv/blockchain/backends/koios-backend.d.ts +103 -168
- package/srv/blockchain/backends/koios-backend.js +428 -360
- package/srv/blockchain/backends/odatano-backend.d.ts +54 -0
- package/srv/blockchain/backends/odatano-backend.js +169 -0
- package/srv/blockchain/backends/ogmios-backend.d.ts +123 -190
- package/srv/blockchain/backends/ogmios-backend.js +637 -315
- package/srv/blockchain/backends/ogmios-frame-guard.d.ts +14 -0
- package/srv/blockchain/backends/ogmios-frame-guard.js +89 -0
- package/srv/blockchain/cardano-client.d.ts +61 -241
- package/srv/blockchain/cardano-client.js +253 -293
- package/srv/blockchain/cardano-indexer.d.ts +282 -281
- package/srv/blockchain/cardano-indexer.js +1551 -484
- package/srv/blockchain/cardano-tx-builder.d.ts +25 -89
- package/srv/blockchain/cardano-tx-builder.js +164 -140
- package/srv/blockchain/circuit-breaker.d.ts +1 -13
- package/srv/blockchain/circuit-breaker.js +5 -15
- package/srv/blockchain/crawler/account-snapshots.d.ts +29 -0
- package/srv/blockchain/crawler/account-snapshots.js +153 -0
- package/srv/blockchain/crawler/asset-decimals-backfill.d.ts +15 -0
- package/srv/blockchain/crawler/asset-decimals-backfill.js +56 -0
- package/srv/blockchain/crawler/asset-registry-backfill.d.ts +43 -0
- package/srv/blockchain/crawler/asset-registry-backfill.js +153 -0
- package/srv/blockchain/crawler/certificate-backfill.d.ts +52 -0
- package/srv/blockchain/crawler/certificate-backfill.js +162 -0
- package/srv/blockchain/crawler/crawler.d.ts +104 -81
- package/srv/blockchain/crawler/crawler.js +532 -160
- package/srv/blockchain/crawler/credential-backfill.d.ts +28 -0
- package/srv/blockchain/crawler/credential-backfill.js +124 -0
- package/srv/blockchain/crawler/hooks.d.ts +2 -17
- package/srv/blockchain/crawler/index.d.ts +1 -8
- package/srv/blockchain/crawler/index.js +31 -17
- package/srv/blockchain/crawler/input-asset-copies.d.ts +34 -0
- package/srv/blockchain/crawler/input-asset-copies.js +171 -0
- package/srv/blockchain/crawler/metadata-position-backfill.d.ts +16 -0
- package/srv/blockchain/crawler/metadata-position-backfill.js +55 -0
- package/srv/blockchain/crawler/output-datum-backfill.d.ts +39 -0
- package/srv/blockchain/crawler/output-datum-backfill.js +110 -0
- package/srv/blockchain/crawler/sync-state.d.ts +27 -47
- package/srv/blockchain/crawler/sync-state.js +113 -63
- package/srv/blockchain/crawler/transaction-backfill.d.ts +44 -0
- package/srv/blockchain/crawler/transaction-backfill.js +278 -0
- package/srv/blockchain/crawler/utxo-set-import.d.ts +66 -0
- package/srv/blockchain/crawler/utxo-set-import.js +399 -0
- package/srv/blockchain/ledger-state.d.ts +62 -0
- package/srv/blockchain/ledger-state.js +419 -0
- package/srv/blockchain/pending-spends.d.ts +16 -0
- package/srv/blockchain/pending-spends.js +81 -0
- package/srv/blockchain/pool-metadata.d.ts +15 -0
- package/srv/blockchain/pool-metadata.js +132 -0
- package/srv/blockchain/request-coalescer.d.ts +2 -16
- package/srv/blockchain/request-coalescer.js +2 -16
- package/srv/blockchain/signing/cose-verifier.d.ts +3 -17
- package/srv/blockchain/signing/cose-verifier.js +146 -70
- package/srv/blockchain/signing/external-signer.d.ts +15 -115
- package/srv/blockchain/signing/external-signer.js +17 -126
- package/srv/blockchain/signing/hsm-signer.d.ts +10 -54
- package/srv/blockchain/signing/hsm-signer.js +28 -79
- package/srv/blockchain/signing/signature-verifier.d.ts +9 -47
- package/srv/blockchain/signing/signature-verifier.js +70 -83
- package/srv/blockchain/signing/submission-finalizer.d.ts +23 -45
- package/srv/blockchain/signing/submission-finalizer.js +219 -86
- package/srv/blockchain/stored-chain.d.ts +20 -0
- package/srv/blockchain/stored-chain.js +237 -0
- package/srv/blockchain/transaction-building/buildooor-tx.d.ts +31 -229
- package/srv/blockchain/transaction-building/buildooor-tx.js +652 -416
- package/srv/blockchain/transaction-building/cardano-tx.d.ts +9 -37
- package/srv/blockchain/transaction-presence.d.ts +5 -0
- package/srv/blockchain/transaction-presence.js +29 -0
- package/srv/blockchain/transaction-rows.d.ts +12 -0
- package/srv/blockchain/transaction-rows.js +44 -0
- package/srv/blockchain/wallet-worker/build-request.d.ts +5 -20
- package/srv/blockchain/wallet-worker/build-request.js +47 -30
- package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +5 -46
- package/srv/blockchain/wallet-worker/confirmation-tracker.js +25 -45
- package/srv/blockchain/wallet-worker/index.d.ts +1 -1
- package/srv/blockchain/wallet-worker/index.js +3 -11
- package/srv/blockchain/wallet-worker/job-store.d.ts +30 -148
- package/srv/blockchain/wallet-worker/job-store.js +101 -201
- package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +2 -26
- package/srv/blockchain/wallet-worker/lease-heartbeat.js +6 -28
- package/srv/blockchain/wallet-worker/signers.d.ts +5 -24
- package/srv/blockchain/wallet-worker/signers.js +4 -12
- package/srv/blockchain/wallet-worker/wallet-worker.d.ts +8 -80
- package/srv/blockchain/wallet-worker/wallet-worker.js +107 -155
- package/srv/cardano-agent-service.cds +122 -84
- package/srv/cardano-agent-service.js +4 -9
- package/srv/cardano-backend-service.cds +78 -0
- package/srv/cardano-backend-service.d.ts +2 -0
- package/srv/cardano-backend-service.js +242 -0
- package/srv/cardano-indexer-service.cds +387 -73
- package/srv/cardano-indexer-service.d.ts +5 -1
- package/srv/cardano-indexer-service.js +532 -16
- package/srv/cardano-service.cds +424 -269
- package/srv/cardano-service.js +289 -201
- package/srv/cardano-sign-service.cds +201 -180
- package/srv/cardano-sign-service.js +71 -201
- package/srv/cardano-tx-service.cds +451 -370
- package/srv/cardano-tx-service.js +271 -289
- package/srv/cardano-ui.cds +16 -16
- package/srv/cardano-worker-service.cds +118 -125
- package/srv/cardano-worker-service.js +52 -61
- package/srv/cbor/cip68.d.ts +13 -0
- package/srv/cbor/cip68.js +56 -0
- package/srv/cbor/index.d.ts +3 -1
- package/srv/cbor/index.js +9 -1
- package/srv/cbor/parse.d.ts +30 -18
- package/srv/cbor/parse.js +44 -9
- package/srv/cbor/plutus-data-json.d.ts +20 -0
- package/srv/cbor/plutus-data-json.js +32 -0
- package/srv/config.d.ts +113 -0
- package/srv/config.js +409 -0
- package/srv/server.d.ts +15 -110
- package/srv/server.js +84 -404
- package/srv/utils/agent-access.d.ts +9 -0
- package/srv/utils/agent-access.js +67 -0
- package/srv/utils/agent-grants-config.d.ts +0 -46
- package/srv/utils/agent-grants-config.js +17 -85
- package/srv/utils/agent-grants.d.ts +106 -122
- package/srv/utils/agent-grants.js +538 -236
- package/srv/utils/agent-token-auth.d.ts +4 -99
- package/srv/utils/agent-token-auth.js +18 -182
- package/srv/utils/backend-request-handler.d.ts +3 -17
- package/srv/utils/backend-request-handler.js +3 -18
- package/srv/utils/collections.d.ts +3 -10
- package/srv/utils/collections.js +3 -10
- package/srv/utils/const.d.ts +23 -74
- package/srv/utils/const.js +32 -79
- package/srv/utils/crypto.d.ts +3 -12
- package/srv/utils/crypto.js +6 -21
- package/srv/utils/db-indexes.d.ts +27 -0
- package/srv/utils/db-indexes.js +120 -0
- package/srv/utils/db-sanitize.d.ts +20 -0
- package/srv/utils/db-sanitize.js +80 -0
- package/srv/utils/deep-json.d.ts +6 -0
- package/srv/utils/deep-json.js +240 -0
- package/srv/utils/epoch-slots.d.ts +13 -0
- package/srv/utils/epoch-slots.js +38 -0
- package/srv/utils/error-codes.d.ts +22 -75
- package/srv/utils/error-codes.js +23 -72
- package/srv/utils/errors.d.ts +46 -187
- package/srv/utils/errors.js +114 -230
- package/srv/utils/liveness.d.ts +12 -0
- package/srv/utils/liveness.js +35 -0
- package/srv/utils/mappers.d.ts +102 -223
- package/srv/utils/mappers.js +387 -316
- package/srv/utils/network-context.js +2 -13
- package/srv/utils/paging.d.ts +31 -0
- package/srv/utils/paging.js +43 -0
- package/srv/utils/pg-inline-json.d.ts +8 -0
- package/srv/utils/pg-inline-json.js +58 -0
- package/srv/utils/pg-order-nulls.d.ts +14 -0
- package/srv/utils/pg-order-nulls.js +54 -0
- package/srv/utils/plutus-placeholders.d.ts +16 -22
- package/srv/utils/plutus-placeholders.js +62 -33
- package/srv/utils/rate-limiter.d.ts +2 -21
- package/srv/utils/rate-limiter.js +5 -17
- package/srv/utils/readiness.d.ts +12 -0
- package/srv/utils/readiness.js +29 -0
- package/srv/utils/reference-script.d.ts +19 -0
- package/srv/utils/reference-script.js +84 -0
- package/srv/utils/result-numbers.d.ts +15 -0
- package/srv/utils/result-numbers.js +61 -0
- package/srv/utils/service-events.d.ts +0 -24
- package/srv/utils/service-events.js +3 -25
- package/srv/utils/signing-helper.d.ts +3 -20
- package/srv/utils/signing-helper.js +35 -64
- package/srv/utils/tx-build-helper.d.ts +10 -105
- package/srv/utils/tx-build-helper.js +81 -144
- package/srv/utils/tx-request-parsers.d.ts +82 -33
- package/srv/utils/tx-request-parsers.js +401 -49
- package/srv/utils/tx-utils.d.ts +3 -27
- package/srv/utils/tx-utils.js +32 -50
- package/srv/utils/types.d.ts +261 -191
- package/srv/utils/types.js +2 -6
- package/srv/utils/validators.d.ts +22 -92
- package/srv/utils/validators.js +50 -149
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CIP68_LABEL = void 0;
|
|
4
|
+
exports.cip68ReferenceUnit = cip68ReferenceUnit;
|
|
5
|
+
exports.cip68UserUnits = cip68UserUnits;
|
|
6
|
+
exports.cip68DecimalsFromDatum = cip68DecimalsFromDatum;
|
|
7
|
+
const plutus_data_1 = require("@harmoniclabs/plutus-data");
|
|
8
|
+
/** CIP-67 asset-name labels of the CIP-68 token classes, as the first 4 bytes of the asset name. */
|
|
9
|
+
exports.CIP68_LABEL = {
|
|
10
|
+
reference: '000643b0',
|
|
11
|
+
nft: '000de140',
|
|
12
|
+
ft: '0014df10',
|
|
13
|
+
rft: '001bc280',
|
|
14
|
+
};
|
|
15
|
+
/** Labels whose reference datum may carry `decimals`. */
|
|
16
|
+
const USER_LABELS_WITH_DECIMALS = [exports.CIP68_LABEL.ft, exports.CIP68_LABEL.rft];
|
|
17
|
+
const labelOf = (unit) => unit.slice(56, 64);
|
|
18
|
+
/** Reference-NFT unit of a CIP-68 user token with label 333 or 444; null for any other unit. */
|
|
19
|
+
function cip68ReferenceUnit(unit) {
|
|
20
|
+
if (unit.length < 64 || !USER_LABELS_WITH_DECIMALS.includes(labelOf(unit)))
|
|
21
|
+
return null;
|
|
22
|
+
return unit.slice(0, 56) + exports.CIP68_LABEL.reference + unit.slice(64);
|
|
23
|
+
}
|
|
24
|
+
/** The label-333 and label-444 units a CIP-68 reference NFT describes; null for any other unit. */
|
|
25
|
+
function cip68UserUnits(referenceUnit) {
|
|
26
|
+
if (referenceUnit.length < 64 || labelOf(referenceUnit) !== exports.CIP68_LABEL.reference)
|
|
27
|
+
return null;
|
|
28
|
+
return USER_LABELS_WITH_DECIMALS.map((label) => referenceUnit.slice(0, 56) + label + referenceUnit.slice(64));
|
|
29
|
+
}
|
|
30
|
+
const DECIMALS_KEY = Buffer.from('decimals');
|
|
31
|
+
// The datum is Constr 0 with the metadata map, keyed by UTF-8 bytes, as first field.
|
|
32
|
+
// Null when the shape differs or decimals is not an integer in 0..255.
|
|
33
|
+
function cip68DecimalsFromDatum(cborHex) {
|
|
34
|
+
let data;
|
|
35
|
+
try {
|
|
36
|
+
data = (0, plutus_data_1.dataFromCbor)(cborHex);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
if (!(data instanceof plutus_data_1.DataConstr) || data.constr !== 0n)
|
|
42
|
+
return null;
|
|
43
|
+
const metadata = data.fields[0];
|
|
44
|
+
if (!(metadata instanceof plutus_data_1.DataMap))
|
|
45
|
+
return null;
|
|
46
|
+
for (const kv of metadata.map) {
|
|
47
|
+
if (!(kv.fst instanceof plutus_data_1.DataB) || !DECIMALS_KEY.equals(Buffer.from(kv.fst.bytes)))
|
|
48
|
+
continue;
|
|
49
|
+
if (!(kv.snd instanceof plutus_data_1.DataI))
|
|
50
|
+
return null;
|
|
51
|
+
const n = kv.snd.int;
|
|
52
|
+
return n >= 0n && n <= 255n ? Number(n) : null;
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=cip68.js.map
|
package/srv/cbor/index.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
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
|
+
export { decodePlutusData, plutusDataToJson, type PlutusDataJson } from './plutus-data-json';
|
|
3
|
+
export { CIP68_LABEL, cip68ReferenceUnit, cip68UserUnits, cip68DecimalsFromDatum } from './cip68';
|
|
2
4
|
//# sourceMappingURL=index.d.ts.map
|
package/srv/cbor/index.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseTransaction = void 0;
|
|
3
|
+
exports.cip68DecimalsFromDatum = exports.cip68UserUnits = exports.cip68ReferenceUnit = exports.CIP68_LABEL = exports.plutusDataToJson = exports.decodePlutusData = exports.parseTransaction = void 0;
|
|
4
4
|
var parse_1 = require("./parse");
|
|
5
5
|
Object.defineProperty(exports, "parseTransaction", { enumerable: true, get: function () { return parse_1.parseTransaction; } });
|
|
6
|
+
var plutus_data_json_1 = require("./plutus-data-json");
|
|
7
|
+
Object.defineProperty(exports, "decodePlutusData", { enumerable: true, get: function () { return plutus_data_json_1.decodePlutusData; } });
|
|
8
|
+
Object.defineProperty(exports, "plutusDataToJson", { enumerable: true, get: function () { return plutus_data_json_1.plutusDataToJson; } });
|
|
9
|
+
var cip68_1 = require("./cip68");
|
|
10
|
+
Object.defineProperty(exports, "CIP68_LABEL", { enumerable: true, get: function () { return cip68_1.CIP68_LABEL; } });
|
|
11
|
+
Object.defineProperty(exports, "cip68ReferenceUnit", { enumerable: true, get: function () { return cip68_1.cip68ReferenceUnit; } });
|
|
12
|
+
Object.defineProperty(exports, "cip68UserUnits", { enumerable: true, get: function () { return cip68_1.cip68UserUnits; } });
|
|
13
|
+
Object.defineProperty(exports, "cip68DecimalsFromDatum", { enumerable: true, get: function () { return cip68_1.cip68DecimalsFromDatum; } });
|
|
6
14
|
//# sourceMappingURL=index.js.map
|
package/srv/cbor/parse.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export interface ParsedInput {
|
|
|
5
5
|
export interface ParsedAsset {
|
|
6
6
|
/** `"policyIdHex" + "assetNameHex"` (concatenated, no separator). */
|
|
7
7
|
unit: string;
|
|
8
|
-
/** Signed decimal string
|
|
8
|
+
/** Signed decimal string; negative for burns in `mint`, never negative in outputs. */
|
|
9
9
|
quantity: string;
|
|
10
10
|
}
|
|
11
11
|
export interface ParsedOutput {
|
|
@@ -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;
|
|
@@ -24,17 +37,11 @@ export interface ParsedWitnesses {
|
|
|
24
37
|
redeemers: number;
|
|
25
38
|
}
|
|
26
39
|
export interface ParsedTransaction {
|
|
27
|
-
/**
|
|
28
|
-
* Blake2b-256 hash of the transaction body. Stable across signed/unsigned
|
|
29
|
-
* CBOR — signing adds witnesses without changing the body hash.
|
|
30
|
-
*/
|
|
40
|
+
/** Blake2b-256 of the body. Signing adds witnesses, so the hash stays the same. */
|
|
31
41
|
txHash: string;
|
|
32
|
-
/**
|
|
33
|
-
* `"mainnet"` or `"testnet"` when the body carries a network ID byte, else
|
|
34
|
-
* `null`. Preview vs preprod cannot be distinguished from CBOR alone; a
|
|
35
|
-
* consumer needing that split must compare against the service network.
|
|
36
|
-
*/
|
|
37
42
|
network: 'mainnet' | 'testnet' | null;
|
|
43
|
+
/** Body field 15: 1 = mainnet, 0 = testnet, null if absent. */
|
|
44
|
+
networkId: number | null;
|
|
38
45
|
inputs: ParsedInput[];
|
|
39
46
|
outputs: ParsedOutput[];
|
|
40
47
|
/** Validity-interval start slot (decimal string) or `null` if absent. */
|
|
@@ -43,22 +50,27 @@ export interface ParsedTransaction {
|
|
|
43
50
|
validityEnd: string | null;
|
|
44
51
|
/** Fee in lovelace (decimal string). */
|
|
45
52
|
fee: string;
|
|
46
|
-
/** Native-asset mint
|
|
53
|
+
/** Native-asset mint and burn entries; quantities are signed. */
|
|
47
54
|
mint: ParsedAsset[];
|
|
48
55
|
/** Metadata labels present (uint64 → decimal string); full payload via GetMetadataByTxHash for submitted txs. */
|
|
49
56
|
metadataLabels: string[];
|
|
50
57
|
collateral: ParsedInput[];
|
|
58
|
+
referenceInputs: ParsedInput[];
|
|
59
|
+
withdrawals: ParsedWithdrawal[];
|
|
60
|
+
certificates: ParsedCertificate[];
|
|
61
|
+
/** Number of votes over all voters; 0 if the body has no voting procedures. */
|
|
62
|
+
votingProcedures: number;
|
|
63
|
+
proposalProcedures: number;
|
|
64
|
+
/** Lovelace (decimal string) or `null` if absent. */
|
|
65
|
+
treasuryDonation: string | null;
|
|
66
|
+
/** Lovelace (decimal string) or `null` if absent. */
|
|
67
|
+
currentTreasuryValue: string | null;
|
|
51
68
|
/** 28-byte Ed25519 key hashes listed in the tx body's required_signers field. */
|
|
52
69
|
requiredSigners: string[];
|
|
53
70
|
scriptDataHash: string | null;
|
|
71
|
+
/** `false` when the transaction is flagged as failing its scripts. On chain it then spends only the collateral and creates no outputs. */
|
|
72
|
+
isValid: boolean;
|
|
54
73
|
witnesses: ParsedWitnesses;
|
|
55
74
|
}
|
|
56
|
-
/**
|
|
57
|
-
* Parse hex-encoded Cardano transaction CBOR (signed or unsigned) into structured
|
|
58
|
-
* fields. Pure function — no network call, no DB write. Callers are responsible
|
|
59
|
-
* for upstream size/format validation via `isValidTxCborHex`.
|
|
60
|
-
*
|
|
61
|
-
* @throws TransactionValidationError with code `TX_PARSE_FAILED` on malformed CBOR.
|
|
62
|
-
*/
|
|
63
75
|
export declare function parseTransaction(cborHex: string): ParsedTransaction;
|
|
64
76
|
//# sourceMappingURL=parse.d.ts.map
|
package/srv/cbor/parse.js
CHANGED
|
@@ -2,19 +2,20 @@
|
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
* fields. Pure function — no network call, no DB write. Callers are responsible
|
|
10
|
-
* for upstream size/format validation via `isValidTxCborHex`.
|
|
11
|
-
*
|
|
12
|
-
* @throws TransactionValidationError with code `TX_PARSE_FAILED` on malformed CBOR.
|
|
13
|
-
*/
|
|
9
|
+
// Pure, no network call. Callers validate size and format with `isValidTxCborHex` first.
|
|
10
|
+
// Throws TX_PARSE_FAILED on malformed CBOR.
|
|
14
11
|
function parseTransaction(cborHex) {
|
|
15
12
|
let tx;
|
|
13
|
+
let networkId;
|
|
16
14
|
try {
|
|
17
|
-
|
|
15
|
+
// one decode for both readers; keepRef keeps the original bytes for the body hash and datums
|
|
16
|
+
const parsed = cbor_1.Cbor.parse(Buffer.from(cborHex, 'hex'), { keepRef: true });
|
|
17
|
+
tx = buildooor_1.Tx.fromCborObj(parsed);
|
|
18
|
+
networkId = readNetworkId(parsed);
|
|
18
19
|
}
|
|
19
20
|
catch (e) {
|
|
20
21
|
const msg = e instanceof Error ? e.message : String(e);
|
|
@@ -24,6 +25,7 @@ function parseTransaction(cborHex) {
|
|
|
24
25
|
return {
|
|
25
26
|
txHash: body.hash.toString(),
|
|
26
27
|
network: normalizeNetwork(body.network),
|
|
28
|
+
networkId,
|
|
27
29
|
inputs: body.inputs.map(mapInput),
|
|
28
30
|
outputs: body.outputs.map(mapOutput),
|
|
29
31
|
validityStart: body.validityIntervalStart != null ? body.validityIntervalStart.toString() : null,
|
|
@@ -32,8 +34,19 @@ function parseTransaction(cborHex) {
|
|
|
32
34
|
mint: mapMint(body.mint),
|
|
33
35
|
metadataLabels: extractMetadataLabels(tx.auxiliaryData),
|
|
34
36
|
collateral: (body.collateralInputs ?? []).map(mapInput),
|
|
37
|
+
referenceInputs: (body.refInputs ?? []).map(mapInput),
|
|
38
|
+
withdrawals: (body.withdrawals?.map ?? []).map((w) => ({
|
|
39
|
+
rewardAddress: w.rewardAccount.toString(),
|
|
40
|
+
lovelace: w.amount.toString(),
|
|
41
|
+
})),
|
|
42
|
+
certificates: (body.certs ?? []).map(mapCertificate),
|
|
43
|
+
votingProcedures: (body.votingProcedures?.procedures ?? []).reduce((n, voter) => n + voter.votes.length, 0),
|
|
44
|
+
proposalProcedures: (body.proposalProcedures ?? []).length,
|
|
45
|
+
treasuryDonation: body.donation?.toString() ?? null,
|
|
46
|
+
currentTreasuryValue: body.currentTreasuryValue?.toString() ?? null,
|
|
35
47
|
requiredSigners: (body.requiredSigners ?? []).map((s) => s.toString()),
|
|
36
48
|
scriptDataHash: body.scriptDataHash ? body.scriptDataHash.toString() : null,
|
|
49
|
+
isValid: tx.isScriptValid,
|
|
37
50
|
witnesses: countWitnesses(tx.witnesses),
|
|
38
51
|
};
|
|
39
52
|
}
|
|
@@ -66,7 +79,7 @@ function mapOutput(out) {
|
|
|
66
79
|
}
|
|
67
80
|
else {
|
|
68
81
|
// anything not a Hash32 is an inline `Data` (PlutusData) payload
|
|
69
|
-
inlineDatumHex = Buffer.from((0, buildooor_1.dataToCbor)(out.datum)).toString('hex');
|
|
82
|
+
inlineDatumHex = Buffer.from(inlineDatumBytes(out) ?? (0, buildooor_1.dataToCbor)(out.datum)).toString('hex');
|
|
70
83
|
}
|
|
71
84
|
}
|
|
72
85
|
const referenceScriptHex = out.refScript
|
|
@@ -79,8 +92,30 @@ function mapOutput(out) {
|
|
|
79
92
|
datumHash,
|
|
80
93
|
inlineDatumHex,
|
|
81
94
|
referenceScriptHex,
|
|
95
|
+
// the bytes as received; a re-encoding can be shorter
|
|
96
|
+
cborSize: out.cborRef ? out.cborRef.toBuffer().length : out.toCborBytes().length,
|
|
82
97
|
};
|
|
83
98
|
}
|
|
99
|
+
function mapCertificate(cert, index) {
|
|
100
|
+
return { index, type: (0, cardano_ledger_ts_1.certTypeToString)(cert.certType) };
|
|
101
|
+
}
|
|
102
|
+
/** Body field 15 as it stands in the bytes. `Tx.fromCbor` maps any network byte other than 0 to mainnet. */
|
|
103
|
+
function readNetworkId(parsed) {
|
|
104
|
+
const body = parsed instanceof cbor_1.CborArray ? parsed.array[0] : undefined;
|
|
105
|
+
const value = body instanceof cbor_1.CborMap ? body.map.find(e => e.k instanceof cbor_1.CborUInt && e.k.num === 15n)?.v : undefined;
|
|
106
|
+
return value instanceof cbor_1.CborUInt ? Number(value.num) : null;
|
|
107
|
+
}
|
|
108
|
+
/** Inline datum bytes as they stand in the transaction; decoding and re-encoding may change them. */
|
|
109
|
+
function inlineDatumBytes(out) {
|
|
110
|
+
if (!out.cborRef)
|
|
111
|
+
return undefined;
|
|
112
|
+
const parsed = cbor_1.Cbor.parse(out.toCborBytes());
|
|
113
|
+
if (!(parsed instanceof cbor_1.CborMap))
|
|
114
|
+
return undefined;
|
|
115
|
+
const option = parsed.map.find(e => e.k instanceof cbor_1.CborUInt && e.k.num === 2n)?.v;
|
|
116
|
+
const tagged = option instanceof cbor_1.CborArray ? option.array[1] : undefined;
|
|
117
|
+
return tagged instanceof cbor_1.CborTag && tagged.data instanceof cbor_1.CborBytes ? tagged.data.bytes : undefined;
|
|
118
|
+
}
|
|
84
119
|
function mapMint(mint) {
|
|
85
120
|
if (!mint)
|
|
86
121
|
return [];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Data } from '@harmoniclabs/plutus-data';
|
|
2
|
+
export type PlutusDataJson = {
|
|
3
|
+
constructor: number;
|
|
4
|
+
fields: PlutusDataJson[];
|
|
5
|
+
} | {
|
|
6
|
+
int: number | string;
|
|
7
|
+
} | {
|
|
8
|
+
bytes: string;
|
|
9
|
+
} | {
|
|
10
|
+
list: PlutusDataJson[];
|
|
11
|
+
} | {
|
|
12
|
+
map: {
|
|
13
|
+
k: PlutusDataJson;
|
|
14
|
+
v: PlutusDataJson;
|
|
15
|
+
}[];
|
|
16
|
+
};
|
|
17
|
+
export declare function plutusDataToJson(data: Data): PlutusDataJson;
|
|
18
|
+
/** @throws TransactionValidationError (`TX_PARSE_FAILED`) when the hex is not PlutusData CBOR. */
|
|
19
|
+
export declare function decodePlutusData(cborHex: string): PlutusDataJson;
|
|
20
|
+
//# sourceMappingURL=plutus-data-json.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.plutusDataToJson = plutusDataToJson;
|
|
4
|
+
exports.decodePlutusData = decodePlutusData;
|
|
5
|
+
const plutus_data_1 = require("@harmoniclabs/plutus-data");
|
|
6
|
+
const errors_1 = require("../utils/errors");
|
|
7
|
+
const error_codes_1 = require("../utils/error-codes");
|
|
8
|
+
function plutusDataToJson(data) {
|
|
9
|
+
if (data instanceof plutus_data_1.DataConstr)
|
|
10
|
+
return { constructor: Number(data.constr), fields: data.fields.map(plutusDataToJson) };
|
|
11
|
+
if (data instanceof plutus_data_1.DataI) {
|
|
12
|
+
const i = data.int;
|
|
13
|
+
return { int: i >= BigInt(Number.MIN_SAFE_INTEGER) && i <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(i) : i.toString() };
|
|
14
|
+
}
|
|
15
|
+
if (data instanceof plutus_data_1.DataB)
|
|
16
|
+
return { bytes: Buffer.from(data.bytes).toString('hex') };
|
|
17
|
+
if (data instanceof plutus_data_1.DataList)
|
|
18
|
+
return { list: data.list.map(plutusDataToJson) };
|
|
19
|
+
if (data instanceof plutus_data_1.DataMap)
|
|
20
|
+
return { map: data.map.map((kv) => ({ k: plutusDataToJson(kv.fst), v: plutusDataToJson(kv.snd) })) };
|
|
21
|
+
throw new TypeError('unknown PlutusData node');
|
|
22
|
+
}
|
|
23
|
+
/** @throws TransactionValidationError (`TX_PARSE_FAILED`) when the hex is not PlutusData CBOR. */
|
|
24
|
+
function decodePlutusData(cborHex) {
|
|
25
|
+
try {
|
|
26
|
+
return plutusDataToJson((0, plutus_data_1.dataFromCbor)(cborHex.trim().toLowerCase()));
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
throw new errors_1.TransactionValidationError(`Not PlutusData CBOR: ${err instanceof Error ? err.message : String(err)}`, err, error_codes_1.ERROR_CODES.TX_PARSE_FAILED);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=plutus-data-json.js.map
|
package/srv/config.d.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { CardanoClientConfig } from './blockchain/cardano-client';
|
|
2
|
+
import type { CrawlerConfig } from './blockchain/crawler/crawler';
|
|
3
|
+
import type { WalletWorkerConfig } from './blockchain/wallet-worker';
|
|
4
|
+
import type { HsmConfig } from './utils/types';
|
|
5
|
+
/** `cds.requires.odatano-core` as the host app wrote it; nested sections stay raw and are coerced on read. */
|
|
6
|
+
export interface OdatanoCoreCdsConfig {
|
|
7
|
+
network?: string;
|
|
8
|
+
backends?: string[] | string;
|
|
9
|
+
blockfrostApiKey?: string;
|
|
10
|
+
blockfrostCustomBackend?: string;
|
|
11
|
+
koiosApiKey?: string;
|
|
12
|
+
ogmiosUrl?: string;
|
|
13
|
+
odatanoUrl?: string;
|
|
14
|
+
odatanoApiKey?: string;
|
|
15
|
+
primaryTimeoutMs?: number;
|
|
16
|
+
fallbackTimeoutMs?: number;
|
|
17
|
+
indexTtlMs?: number;
|
|
18
|
+
poolMetadataFetch?: CdsBoolean;
|
|
19
|
+
hsm?: HsmCdsSection;
|
|
20
|
+
crawler?: CrawlerCdsSection;
|
|
21
|
+
walletWorker?: WalletWorkerCdsSection;
|
|
22
|
+
agentGrants?: AgentGrantsCdsSection;
|
|
23
|
+
}
|
|
24
|
+
/** Numbers and booleans may arrive as strings; the loaders coerce and validate them. */
|
|
25
|
+
export type CdsNumber = number | string;
|
|
26
|
+
export type CdsBoolean = boolean | string;
|
|
27
|
+
export interface CrawlerCdsSection {
|
|
28
|
+
enabled?: CdsBoolean;
|
|
29
|
+
startSlot?: CdsNumber;
|
|
30
|
+
startHeight?: CdsNumber;
|
|
31
|
+
startBlockHash?: string;
|
|
32
|
+
source?: string;
|
|
33
|
+
batchSize?: CdsNumber;
|
|
34
|
+
confirmationDepth?: CdsNumber;
|
|
35
|
+
pollIntervalMs?: CdsNumber;
|
|
36
|
+
assetHistory?: CdsBoolean;
|
|
37
|
+
assetCatalogue?: string;
|
|
38
|
+
assetEnrichRate?: CdsNumber;
|
|
39
|
+
epochSnapshots?: CdsBoolean;
|
|
40
|
+
accountSnapshots?: CdsBoolean;
|
|
41
|
+
certificates?: CdsBoolean;
|
|
42
|
+
utxoSet?: CdsBoolean;
|
|
43
|
+
authoritative?: CdsBoolean;
|
|
44
|
+
inputAssetCopies?: CdsBoolean;
|
|
45
|
+
}
|
|
46
|
+
export interface WalletWorkerCdsSection {
|
|
47
|
+
enabled?: CdsBoolean;
|
|
48
|
+
wallets?: unknown;
|
|
49
|
+
maxConcurrentWallets?: CdsNumber;
|
|
50
|
+
confirmationDepth?: CdsNumber;
|
|
51
|
+
confirmationTimeoutMs?: CdsNumber;
|
|
52
|
+
pollIntervalMs?: CdsNumber;
|
|
53
|
+
defaultMaxAttempts?: CdsNumber;
|
|
54
|
+
resubmitOnRollback?: CdsBoolean;
|
|
55
|
+
}
|
|
56
|
+
export interface HsmCdsSection {
|
|
57
|
+
enabled?: boolean;
|
|
58
|
+
pkcs11Module?: string;
|
|
59
|
+
slot?: number;
|
|
60
|
+
pin?: string;
|
|
61
|
+
keyId?: string;
|
|
62
|
+
keyLabel?: string;
|
|
63
|
+
requiresRole?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface AgentGrantsCdsSection {
|
|
66
|
+
enabled?: CdsBoolean;
|
|
67
|
+
delegate?: string;
|
|
68
|
+
adminRateLimit?: CdsNumber;
|
|
69
|
+
tokenCacheMs?: CdsNumber;
|
|
70
|
+
usageRetentionDays?: CdsNumber;
|
|
71
|
+
}
|
|
72
|
+
/** The section as configured. Every read of it goes through here. */
|
|
73
|
+
export declare function coreCdsConfig(): OdatanoCoreCdsConfig;
|
|
74
|
+
/** The network as written, unchecked: for probes that answer even when the configuration is invalid. */
|
|
75
|
+
export declare function configuredNetworkName(): string;
|
|
76
|
+
/** SKIP_AUTO_INIT=true: tests mount the services without starting backends, crawler or worker. */
|
|
77
|
+
export declare function autoInitSkipped(): boolean;
|
|
78
|
+
/** ODATANO_DETACHED_TX_TIMEOUT_MS when it is a positive number; read per call. */
|
|
79
|
+
export declare function detachedTxTimeoutMs(): number | undefined;
|
|
80
|
+
/** Blockchain components created once at bootstrap and shared across services. */
|
|
81
|
+
/** Backends and their credentials. Throws ConfigError for an invalid value. */
|
|
82
|
+
export declare function loadConfigFromEnv(): CardanoClientConfig;
|
|
83
|
+
/** `poolMetadataFetch` / POOL_METADATA_FETCH: load pool metadata files from their registered URL. Off by default. */
|
|
84
|
+
export declare function loadPoolMetadataFetchFromEnv(): boolean;
|
|
85
|
+
/** From cds.requires.odatano-core.hsm or HSM_* env vars. Undefined when HSM is off. */
|
|
86
|
+
export declare function loadHsmConfigFromEnv(): HsmConfig | undefined;
|
|
87
|
+
/** From cds.requires.odatano-core.crawler or CRAWLER_* env vars. Off by default. */
|
|
88
|
+
export declare function loadCrawlerConfigFromEnv(): CrawlerConfig;
|
|
89
|
+
/** From cds.requires.odatano-core.walletWorker or WALLET_WORKER_* env vars. Off by default. */
|
|
90
|
+
export declare function loadWalletWorkerConfigFromEnv(): WalletWorkerConfig;
|
|
91
|
+
/** Agent grants: `agentGrants` in the section, else AGENT_GRANT* variables. */
|
|
92
|
+
export interface AgentGrantsConfig {
|
|
93
|
+
enabled: boolean;
|
|
94
|
+
/** CAP auth kind the transport middleware delegates to for non-token requests. */
|
|
95
|
+
delegate: string;
|
|
96
|
+
/** Grant administration calls per principal per hour (integer >= 1). */
|
|
97
|
+
adminRateLimit: number;
|
|
98
|
+
}
|
|
99
|
+
export declare const AGENT_GRANTS_DELEGATES: readonly string[];
|
|
100
|
+
export declare const AGENT_GRANT_ADMIN_RATE_LIMIT_DEFAULT = 10;
|
|
101
|
+
export declare function loadGrantAdminRateLimit(vars?: Record<string, string | undefined>): number;
|
|
102
|
+
export declare const AGENT_TOKEN_CACHE_MS_DEFAULT = 10000;
|
|
103
|
+
export declare function loadTokenCacheMs(vars?: Record<string, string | undefined>): number;
|
|
104
|
+
export declare const AGENT_GRANT_USAGE_RETENTION_DAYS_DEFAULT = 400;
|
|
105
|
+
export declare function loadGrantUsageRetentionDays(vars?: Record<string, string | undefined>): number;
|
|
106
|
+
/** The configured `cds.requires.auth` as an object (the shorthand `"auth": "xsuaa"` is a string). */
|
|
107
|
+
export declare function configuredAuth(): Record<string, unknown>;
|
|
108
|
+
/** The transport middleware, recognisable in `auth.impl` so activation stays idempotent. */
|
|
109
|
+
export declare const AGENT_AUTH_IMPL = "cap-auth";
|
|
110
|
+
/** A host-configured custom `cds.requires.auth.impl` (not this package's middleware); the lane wraps it. */
|
|
111
|
+
export declare function customAuthImpl(auth?: Record<string, unknown>): string | null;
|
|
112
|
+
export declare function loadAgentGrantsConfig(vars?: Record<string, string | undefined>): AgentGrantsConfig;
|
|
113
|
+
//# sourceMappingURL=config.d.ts.map
|