@odatano/core 2.0.0-rc.23 → 2.0.0-rc.25
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/CardanoBackendService/index.d.ts +357 -0
- package/@cds-models/CardanoBackendService/index.js +40 -0
- package/@cds-models/CardanoIndexerService/index.d.ts +37 -0
- package/@cds-models/CardanoIndexerService/index.js +4 -0
- package/@cds-models/CardanoODataService/index.d.ts +27 -2
- package/@cds-models/CardanoODataService/index.js +3 -0
- package/@cds-models/CardanoSignService/index.d.ts +23 -1
- package/@cds-models/CardanoSignService/index.js +3 -0
- package/@cds-models/CardanoTransactionService/index.d.ts +34 -1
- package/@cds-models/CardanoTransactionService/index.js +4 -0
- package/@cds-models/index.d.ts +18 -0
- package/@cds-models/index.js +3 -0
- package/@cds-models/odatano/cardano/index.d.ts +49 -2
- package/@cds-models/odatano/cardano/index.js +6 -0
- package/db/schema.cds +74 -3
- package/db/types.cds +27 -0
- package/package.json +182 -181
- package/srv/blockchain/backends/blockfrost-backend.js +4 -2
- package/srv/blockchain/backends/cardano-backend.d.ts +0 -2
- package/srv/blockchain/backends/koios-backend.d.ts +1 -1
- package/srv/blockchain/backends/koios-backend.js +61 -14
- package/srv/blockchain/backends/odatano-backend.d.ts +64 -0
- package/srv/blockchain/backends/odatano-backend.js +166 -0
- package/srv/blockchain/backends/ogmios-backend.d.ts +12 -2
- package/srv/blockchain/backends/ogmios-backend.js +91 -21
- package/srv/blockchain/cardano-client.d.ts +23 -9
- package/srv/blockchain/cardano-client.js +77 -25
- package/srv/blockchain/cardano-indexer.d.ts +61 -15
- package/srv/blockchain/cardano-indexer.js +248 -79
- package/srv/blockchain/cardano-tx-builder.d.ts +11 -1
- package/srv/blockchain/cardano-tx-builder.js +59 -4
- package/srv/blockchain/crawler/certificate-backfill.d.ts +22 -0
- package/srv/blockchain/crawler/certificate-backfill.js +49 -30
- package/srv/blockchain/crawler/crawler.d.ts +3 -1
- package/srv/blockchain/crawler/crawler.js +12 -7
- package/srv/blockchain/crawler/sync-state.d.ts +3 -1
- package/srv/blockchain/crawler/sync-state.js +15 -2
- 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 +9 -0
- package/srv/blockchain/crawler/utxo-set-import.js +138 -47
- package/srv/blockchain/ledger-state.d.ts +16 -1
- package/srv/blockchain/ledger-state.js +38 -18
- package/srv/blockchain/pending-spends.d.ts +28 -0
- package/srv/blockchain/pending-spends.js +89 -0
- 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 +12 -3
- package/srv/blockchain/transaction-building/buildooor-tx.js +203 -21
- package/srv/blockchain/transaction-building/cardano-tx.d.ts +2 -1
- package/srv/blockchain/transaction-rows.d.ts +1 -1
- package/srv/blockchain/transaction-rows.js +2 -1
- package/srv/blockchain/wallet-worker/build-request.js +1 -1
- 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 -176
- package/srv/cardano-indexer-service.js +104 -10
- package/srv/cardano-service.cds +5 -0
- package/srv/cardano-tx-service.cds +39 -0
- package/srv/cardano-tx-service.js +88 -14
- package/srv/server.js +20 -2
- package/srv/utils/agent-grants.js +8 -0
- package/srv/utils/const.d.ts +5 -0
- package/srv/utils/const.js +6 -1
- package/srv/utils/error-codes.d.ts +2 -0
- package/srv/utils/error-codes.js +2 -0
- package/srv/utils/errors.d.ts +7 -0
- package/srv/utils/errors.js +11 -1
- package/srv/utils/mappers.d.ts +24 -2
- package/srv/utils/mappers.js +49 -0
- package/srv/utils/pg-inline-json.d.ts +8 -0
- package/srv/utils/pg-inline-json.js +63 -0
- package/srv/utils/tx-build-helper.d.ts +2 -0
- package/srv/utils/tx-build-helper.js +12 -0
- package/srv/utils/tx-request-parsers.d.ts +46 -5
- package/srv/utils/tx-request-parsers.js +227 -16
- package/srv/utils/types.d.ts +59 -0
- package/srv/utils/validators.d.ts +5 -1
- package/srv/utils/validators.js +19 -9
package/srv/utils/types.d.ts
CHANGED
|
@@ -62,6 +62,22 @@ export interface TxWithdrawal {
|
|
|
62
62
|
/** Lovelace as string. */
|
|
63
63
|
amount: Lovelace | string;
|
|
64
64
|
}
|
|
65
|
+
/** One redeemer of a transaction. */
|
|
66
|
+
export interface TxRedeemer {
|
|
67
|
+
/** spend | mint | publish | withdraw | vote | propose */
|
|
68
|
+
purpose: string;
|
|
69
|
+
/** Index within its purpose, as the ledger counts it. */
|
|
70
|
+
index: number;
|
|
71
|
+
/** PlutusData CBOR hex. */
|
|
72
|
+
data: string;
|
|
73
|
+
mem: string;
|
|
74
|
+
steps: string;
|
|
75
|
+
/** spend: the redeemed input. */
|
|
76
|
+
txHash?: Hex | null;
|
|
77
|
+
outputIndex?: number | null;
|
|
78
|
+
/** mint: the policy. */
|
|
79
|
+
policyId?: Hex | null;
|
|
80
|
+
}
|
|
65
81
|
/** Normalized transaction */
|
|
66
82
|
export interface Transaction {
|
|
67
83
|
hash: Hex;
|
|
@@ -98,6 +114,8 @@ export interface Transaction {
|
|
|
98
114
|
certificates?: TxCertificate[];
|
|
99
115
|
/** Reward-account withdrawals; same `[]` vs undefined convention as `certificates`. */
|
|
100
116
|
withdrawals?: TxWithdrawal[];
|
|
117
|
+
/** Redeemers; `[]` when the tx has none, undefined when the source does not report them (Blockfrost, Koios). */
|
|
118
|
+
redeemers?: TxRedeemer[];
|
|
101
119
|
}
|
|
102
120
|
/** Address view with current value and known UTxOs */
|
|
103
121
|
export interface Address {
|
|
@@ -118,6 +136,8 @@ export interface UTxO {
|
|
|
118
136
|
blockHash?: Hex;
|
|
119
137
|
datumHash?: Hex | null;
|
|
120
138
|
scriptRef?: Hex | null;
|
|
139
|
+
/** Full CBOR of the reference script (Plutus) when the source delivers it; builder use only. */
|
|
140
|
+
scriptRefCbor?: Hex | null;
|
|
121
141
|
inlineDatum?: string | null;
|
|
122
142
|
}
|
|
123
143
|
/** Basic block information */
|
|
@@ -390,6 +410,38 @@ export type TxBuildMintRequest = TxBuildRequest & {
|
|
|
390
410
|
export type TxBuildPlutusSpendRequest = TxBuildRequest & {
|
|
391
411
|
plutusScriptExecution: PlutusScriptExecution;
|
|
392
412
|
};
|
|
413
|
+
/** One script UTxO spent by a BuildPlutusTransaction: an inline validator or a UTxO carrying the script. */
|
|
414
|
+
export type ScriptInput = {
|
|
415
|
+
txHash: string;
|
|
416
|
+
outputIndex: number;
|
|
417
|
+
/** Validator CBOR hex (script params already applied); exclusive with referenceScript. */
|
|
418
|
+
validatorScript?: string;
|
|
419
|
+
/** UTxO that carries the validator as reference script; added as reference input. */
|
|
420
|
+
referenceScript?: {
|
|
421
|
+
txHash: string;
|
|
422
|
+
outputIndex: number;
|
|
423
|
+
};
|
|
424
|
+
/** Redeemer (PlutusData JSON); `__INPUT_IDX__` placeholders resolve against the final inputs. */
|
|
425
|
+
redeemer: JSONValue;
|
|
426
|
+
/** Redeemer as PlutusData CBOR hex; wins over `redeemer`, no placeholders. */
|
|
427
|
+
redeemerCbor?: string;
|
|
428
|
+
/** Datum preimage (PlutusData JSON) for a hash-datum UTxO; inline datums are read from the UTxO. */
|
|
429
|
+
datum?: JSONValue;
|
|
430
|
+
/** Datum preimage as PlutusData CBOR hex; wins over `datum`. */
|
|
431
|
+
datumCbor?: string;
|
|
432
|
+
};
|
|
433
|
+
/** Output of a BuildPlutusTransaction, kept in the given order. */
|
|
434
|
+
export type PlutusTxOutput = NonNullable<TxBuildRequest['extraOutputs']>[number] & {
|
|
435
|
+
/** Datum hash to lock the output with (hex); exclusive with inlineDatum. */
|
|
436
|
+
datumHash?: string;
|
|
437
|
+
/** Inline datum as PlutusData CBOR hex, taken byte for byte; exclusive with inlineDatum. */
|
|
438
|
+
inlineDatumCbor?: string;
|
|
439
|
+
};
|
|
440
|
+
/** BuildPlutusTransaction: several script inputs, the outputs as given, change after them. */
|
|
441
|
+
export type TxBuildPlutusRequest = Pick<TxBuildRequest, 'network' | 'senderAddress' | 'changeAddress' | 'requiredSigners' | 'forceInputs' | 'referenceInputs' | 'mintActions' | 'validityStartMs' | 'validityEndMs'> & {
|
|
442
|
+
scriptInputs: ScriptInput[];
|
|
443
|
+
outputs: PlutusTxOutput[];
|
|
444
|
+
};
|
|
393
445
|
/** Execution budget for Plutus scripts */
|
|
394
446
|
export type ExecutionBudget = {
|
|
395
447
|
memory: number;
|
|
@@ -449,6 +501,13 @@ export type TxBuildResult = {
|
|
|
449
501
|
forcedInputsUsed?: number;
|
|
450
502
|
/** Number of CIP-31 reference inputs included in the built transaction (0 if referenceInputs was not used). */
|
|
451
503
|
referenceInputsUsed?: number;
|
|
504
|
+
/** Execution units stamped on each redeemer (script builds). */
|
|
505
|
+
redeemers?: Array<{
|
|
506
|
+
tag: string;
|
|
507
|
+
index: number;
|
|
508
|
+
mem: string;
|
|
509
|
+
steps: string;
|
|
510
|
+
}>;
|
|
452
511
|
};
|
|
453
512
|
/** Supported external signer types */
|
|
454
513
|
export declare enum ExternalSignerType {
|
|
@@ -5,7 +5,11 @@ interface JsonValidationResult {
|
|
|
5
5
|
parsed?: unknown;
|
|
6
6
|
}
|
|
7
7
|
/** Parse a JSON string under size and complexity limits (DoS prevention); `fieldName` is for messages. */
|
|
8
|
-
export declare function validateJsonWithLimits(jsonString: string, fieldName: string): JsonValidationResult;
|
|
8
|
+
export declare function validateJsonWithLimits(jsonString: string, fieldName: string, maxDepth?: number): JsonValidationResult;
|
|
9
|
+
/** PlutusData JSON (redeemer, datum, script params): the same limits with PLUTUS_DATA_MAX_DEPTH. */
|
|
10
|
+
export declare function validatePlutusJson(jsonString: string, fieldName: string): JsonValidationResult;
|
|
11
|
+
/** Request fields that carry PlutusData JSON. */
|
|
12
|
+
export declare const PLUTUS_JSON_FIELDS: ReadonlySet<string>;
|
|
9
13
|
/** Transaction hash: 64-character hex string */
|
|
10
14
|
export declare function isTxHash(s: unknown): s is string;
|
|
11
15
|
/** Asset unit: policy ID (56 hex chars) + asset name (0-64 hex chars, even length) */
|
package/srv/utils/validators.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PLUTUS_JSON_FIELDS = void 0;
|
|
3
4
|
exports.validateJsonWithLimits = validateJsonWithLimits;
|
|
5
|
+
exports.validatePlutusJson = validatePlutusJson;
|
|
4
6
|
exports.isTxHash = isTxHash;
|
|
5
7
|
exports.isAssetUnit = isAssetUnit;
|
|
6
8
|
exports.isBlockHash = isBlockHash;
|
|
@@ -44,7 +46,7 @@ function wordsToBytesLen(words) {
|
|
|
44
46
|
return Buffer.from(bech32_1.bech32.fromWords(words)).length;
|
|
45
47
|
}
|
|
46
48
|
/** Parse a JSON string under size and complexity limits (DoS prevention); `fieldName` is for messages. */
|
|
47
|
-
function validateJsonWithLimits(jsonString, fieldName) {
|
|
49
|
+
function validateJsonWithLimits(jsonString, fieldName, maxDepth = const_1.MAX_DEPTH) {
|
|
48
50
|
// Size limit before parsing
|
|
49
51
|
if (jsonString.length > const_1.MAX_JSON_SIZE) {
|
|
50
52
|
return { valid: false, error: `${fieldName} exceeds maximum size of ${const_1.MAX_JSON_SIZE} bytes` };
|
|
@@ -56,16 +58,24 @@ function validateJsonWithLimits(jsonString, fieldName) {
|
|
|
56
58
|
catch {
|
|
57
59
|
return { valid: false, error: `Invalid JSON in ${fieldName}` };
|
|
58
60
|
}
|
|
59
|
-
const complexityError = checkJsonComplexity(parsed, 0);
|
|
61
|
+
const complexityError = checkJsonComplexity(parsed, 0, maxDepth);
|
|
60
62
|
if (complexityError) {
|
|
61
63
|
return { valid: false, error: `${fieldName}: ${complexityError}` };
|
|
62
64
|
}
|
|
63
65
|
return { valid: true, parsed };
|
|
64
66
|
}
|
|
67
|
+
/** PlutusData JSON (redeemer, datum, script params): the same limits with PLUTUS_DATA_MAX_DEPTH. */
|
|
68
|
+
function validatePlutusJson(jsonString, fieldName) {
|
|
69
|
+
return validateJsonWithLimits(jsonString, fieldName, const_1.PLUTUS_DATA_MAX_DEPTH);
|
|
70
|
+
}
|
|
71
|
+
/** Request fields that carry PlutusData JSON. */
|
|
72
|
+
exports.PLUTUS_JSON_FIELDS = new Set([
|
|
73
|
+
'redeemerJson', 'datumJson', 'inlineDatumJson', 'outputDatumJson', 'mintRedeemerJson', 'scriptParamsJson',
|
|
74
|
+
]);
|
|
65
75
|
/** Recursive complexity check (depth, keys, array length, string length); error message or null. */
|
|
66
|
-
function checkJsonComplexity(value, depth) {
|
|
67
|
-
if (depth >
|
|
68
|
-
return `Maximum nesting depth of ${
|
|
76
|
+
function checkJsonComplexity(value, depth, maxDepth) {
|
|
77
|
+
if (depth > maxDepth) {
|
|
78
|
+
return `Maximum nesting depth of ${maxDepth} exceeded`;
|
|
69
79
|
}
|
|
70
80
|
if (value === null || typeof value !== 'object') {
|
|
71
81
|
if (typeof value === 'string' && value.length > const_1.MAX_STRING_LENGTH) {
|
|
@@ -78,7 +88,7 @@ function checkJsonComplexity(value, depth) {
|
|
|
78
88
|
return `Array exceeds maximum length of ${const_1.MAX_ARRAY_LENGTH}`;
|
|
79
89
|
}
|
|
80
90
|
for (const item of value) {
|
|
81
|
-
const error = checkJsonComplexity(item, depth + 1);
|
|
91
|
+
const error = checkJsonComplexity(item, depth + 1, maxDepth);
|
|
82
92
|
if (error)
|
|
83
93
|
return error;
|
|
84
94
|
}
|
|
@@ -89,7 +99,7 @@ function checkJsonComplexity(value, depth) {
|
|
|
89
99
|
return `Object exceeds maximum key count of ${const_1.MAX_KEYS}`;
|
|
90
100
|
}
|
|
91
101
|
for (const key of keys) {
|
|
92
|
-
const error = checkJsonComplexity(value[key], depth + 1);
|
|
102
|
+
const error = checkJsonComplexity(value[key], depth + 1, maxDepth);
|
|
93
103
|
if (error)
|
|
94
104
|
return error;
|
|
95
105
|
}
|
|
@@ -363,7 +373,7 @@ function validateTransactionInputs(inputs, requiredFields) {
|
|
|
363
373
|
}
|
|
364
374
|
}
|
|
365
375
|
if (inputs.redeemerJson) {
|
|
366
|
-
const result =
|
|
376
|
+
const result = validatePlutusJson(inputs.redeemerJson, 'redeemerJson');
|
|
367
377
|
if (!result.valid) {
|
|
368
378
|
errors.push({
|
|
369
379
|
type: 'invalid',
|
|
@@ -373,7 +383,7 @@ function validateTransactionInputs(inputs, requiredFields) {
|
|
|
373
383
|
}
|
|
374
384
|
}
|
|
375
385
|
if (inputs.datumJson) {
|
|
376
|
-
const result =
|
|
386
|
+
const result = validatePlutusJson(inputs.datumJson, 'datumJson');
|
|
377
387
|
if (!result.valid) {
|
|
378
388
|
errors.push({
|
|
379
389
|
type: 'invalid',
|