@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
|
@@ -1,47 +1,19 @@
|
|
|
1
|
-
import { TxBuildRequest, TxBuildMintRequest, TxBuildPlutusSpendRequest, TxBuildContext, TxBuildResult, LedgerProtocolParameters } from "../../utils/types";
|
|
1
|
+
import { TxBuildRequest, TxBuildMintRequest, TxBuildPlutusSpendRequest, TxBuildPlutusRequest, TxBuildContext, TxBuildResult, LedgerProtocolParameters } from "../../utils/types";
|
|
2
2
|
import { CardanoClient } from "../cardano-client";
|
|
3
|
-
/**
|
|
4
|
-
* CardanoTxBuilder - Interface Definition for the Cardano transaction builder (Buildooor)
|
|
5
|
-
* Defines the standard methods that any Cardano transaction builder must implement to be used interchangeably.
|
|
6
|
-
*/
|
|
3
|
+
/** Interface for the Cardano transaction builder (Buildooor). */
|
|
7
4
|
export interface CardanoTxBuilder {
|
|
8
|
-
/**
|
|
9
|
-
* Builder name
|
|
10
|
-
*/
|
|
5
|
+
/** Builder name */
|
|
11
6
|
name: string;
|
|
12
|
-
/**
|
|
13
|
-
* Initialize the builder
|
|
14
|
-
* @param client - The CardanoClient instance
|
|
15
|
-
* @param protocolParams - Optional protocol parameters (if not provided, fetched from backend)
|
|
16
|
-
*/
|
|
7
|
+
/** Initialize the builder. Protocol parameters are fetched when omitted. */
|
|
17
8
|
init(client: CardanoClient, protocolParams?: LedgerProtocolParameters): Promise<void>;
|
|
18
|
-
/**
|
|
19
|
-
* Build unsigned transfer transaction (ADA-only or with native assets)
|
|
20
|
-
* @param req transaction build request
|
|
21
|
-
* @param ctx transaction build context
|
|
22
|
-
* @returns {Promise<TxBuildResult>} transaction build result
|
|
23
|
-
*/
|
|
9
|
+
/** Build an unsigned transfer transaction (ADA-only or with native assets). */
|
|
24
10
|
buildUnsignedTransfer(req: TxBuildRequest, ctx: TxBuildContext): Promise<TxBuildResult>;
|
|
25
|
-
/**
|
|
26
|
-
* Build unsigned transaction with metadata
|
|
27
|
-
* @param req transaction build request
|
|
28
|
-
* @param ctx transaction build context
|
|
29
|
-
* @returns {Promise<TxBuildResult>} transaction build result
|
|
30
|
-
*/
|
|
11
|
+
/** Build an unsigned transaction with attached metadata. */
|
|
31
12
|
buildUnsignedTransactionWithMetadata(req: TxBuildRequest, ctx: TxBuildContext): Promise<TxBuildResult>;
|
|
32
|
-
/**
|
|
33
|
-
* Build unsigned Plutus SC transaction
|
|
34
|
-
* @param req transaction build request
|
|
35
|
-
* @param ctx transaction build context
|
|
36
|
-
* @returns {Promise<TxBuildResult>} transaction build result
|
|
37
|
-
*/
|
|
13
|
+
/** Build an unsigned Plutus mint transaction. */
|
|
38
14
|
buildUnsignedMintTransaction(req: TxBuildMintRequest, ctx: TxBuildContext): Promise<TxBuildResult>;
|
|
39
|
-
/**
|
|
40
|
-
* Build unsigned Plutus spending transaction (consume UTxO at script address)
|
|
41
|
-
* @param req transaction build request with plutusScriptExecution
|
|
42
|
-
* @param ctx transaction build context
|
|
43
|
-
* @returns {Promise<TxBuildResult>} transaction build result
|
|
44
|
-
*/
|
|
15
|
+
/** Build an unsigned Plutus spending transaction (consume a UTxO at a script address). */
|
|
45
16
|
buildUnsignedPlutusSpendTransaction(req: TxBuildPlutusSpendRequest, ctx: TxBuildContext): Promise<TxBuildResult>;
|
|
17
|
+
buildUnsignedPlutusTransaction(req: TxBuildPlutusRequest, ctx: TxBuildContext): Promise<TxBuildResult>;
|
|
46
18
|
}
|
|
47
19
|
//# sourceMappingURL=cardano-tx.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CardanoIndexer } from './cardano-indexer';
|
|
2
|
+
import type { CardanoClient } from './cardano-client';
|
|
3
|
+
export type TransactionLookup = Pick<CardanoClient, 'getTransaction' | 'supports'>;
|
|
4
|
+
export declare function isTransactionOnChain(indexer: Pick<CardanoIndexer, 'findIndexedTransaction'>, client: TransactionLookup, txHash: string): Promise<boolean | null>;
|
|
5
|
+
//# sourceMappingURL=transaction-presence.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isTransactionOnChain = isTransactionOnChain;
|
|
7
|
+
const cds_1 = __importDefault(require("@sap/cds"));
|
|
8
|
+
const errors_1 = require("../utils/errors");
|
|
9
|
+
const tx_utils_1 = require("../utils/tx-utils");
|
|
10
|
+
// True when the transaction is on chain, false when every backend answers not found, null when
|
|
11
|
+
// no configured backend can look transactions up. Throws when the lookup itself fails.
|
|
12
|
+
async function isTransactionOnChain(indexer, client, txHash) {
|
|
13
|
+
// the local index first (filled by the crawler), then the backends
|
|
14
|
+
const indexed = await (0, tx_utils_1.runWithoutAmbientTx)(() => cds_1.default.tx((t) => indexer.findIndexedTransaction(t, txHash)));
|
|
15
|
+
if (indexed)
|
|
16
|
+
return true;
|
|
17
|
+
if (!client.supports('getTransaction'))
|
|
18
|
+
return null;
|
|
19
|
+
try {
|
|
20
|
+
await client.getTransaction(txHash);
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
if ((0, errors_1.isNotFoundOnAllBackends)(err))
|
|
25
|
+
return false;
|
|
26
|
+
throw err;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=transaction-presence.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Transaction as CapTransaction } from '@sap/cds';
|
|
2
|
+
export interface TxKey {
|
|
3
|
+
hash: string;
|
|
4
|
+
txSeq: number | string | null;
|
|
5
|
+
}
|
|
6
|
+
/** `txSeq` as a stable map key: Int64 columns come back as number or string depending on the driver. */
|
|
7
|
+
export declare const seqKey: (txSeq: number | string) => string;
|
|
8
|
+
/** Hash and txSeq of the given transactions that are indexed. */
|
|
9
|
+
export declare function readTxKeys(tx: CapTransaction, hashes: string[]): Promise<TxKey[]>;
|
|
10
|
+
/** Delete transactions with their input/output, asset, metadata, certificate, withdrawal, redeemer and datum rows. */
|
|
11
|
+
export declare function deleteTransactionRows(tx: CapTransaction, keys: TxKey[]): Promise<void>;
|
|
12
|
+
//# sourceMappingURL=transaction-rows.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.seqKey = void 0;
|
|
7
|
+
exports.readTxKeys = readTxKeys;
|
|
8
|
+
exports.deleteTransactionRows = deleteTransactionRows;
|
|
9
|
+
const cds_1 = __importDefault(require("@sap/cds"));
|
|
10
|
+
const cardano_1 = require("#cds-models/odatano/cardano");
|
|
11
|
+
const collections_1 = require("../utils/collections");
|
|
12
|
+
const { SELECT, DELETE } = cds_1.default.ql;
|
|
13
|
+
/** `txSeq` as a stable map key: Int64 columns come back as number or string depending on the driver. */
|
|
14
|
+
const seqKey = (txSeq) => String(Number(txSeq));
|
|
15
|
+
exports.seqKey = seqKey;
|
|
16
|
+
/** Hash and txSeq of the given transactions that are indexed. */
|
|
17
|
+
async function readTxKeys(tx, hashes) {
|
|
18
|
+
const keys = [];
|
|
19
|
+
for (const hashChunk of (0, collections_1.chunk)(hashes, collections_1.IN_CHUNK)) {
|
|
20
|
+
const rows = await tx.run(SELECT.from(cardano_1.Transactions).columns('hash', 'txSeq').where({ hash: { in: hashChunk } }));
|
|
21
|
+
keys.push(...(rows ?? []));
|
|
22
|
+
}
|
|
23
|
+
return keys;
|
|
24
|
+
}
|
|
25
|
+
/** Delete transactions with their input/output, asset, metadata, certificate, withdrawal, redeemer and datum rows. */
|
|
26
|
+
async function deleteTransactionRows(tx, keys) {
|
|
27
|
+
for (const keyChunk of (0, collections_1.chunk)(keys, collections_1.IN_CHUNK)) {
|
|
28
|
+
const hashes = keyChunk.map(k => k.hash);
|
|
29
|
+
const seqs = keyChunk.filter(k => k.txSeq != null).map(k => k.txSeq);
|
|
30
|
+
if (seqs.length) {
|
|
31
|
+
await tx.run(DELETE.from(cardano_1.TransactionInputAssetCopies).where({ input_txSeq: { in: seqs } }));
|
|
32
|
+
await tx.run(DELETE.from(cardano_1.TransactionOutputAssets).where({ output_txSeq: { in: seqs } }));
|
|
33
|
+
await tx.run(DELETE.from(cardano_1.TransactionInputs).where({ txSeq: { in: seqs } }));
|
|
34
|
+
await tx.run(DELETE.from(cardano_1.TransactionOutputs).where({ txSeq: { in: seqs } }));
|
|
35
|
+
}
|
|
36
|
+
await tx.run(DELETE.from(cardano_1.TransactionMetadata_).where({ tx_hash: { in: hashes } }));
|
|
37
|
+
await tx.run(DELETE.from(cardano_1.TransactionCertificates).where({ tx_hash: { in: hashes } }));
|
|
38
|
+
await tx.run(DELETE.from(cardano_1.TransactionWithdrawals).where({ tx_hash: { in: hashes } }));
|
|
39
|
+
await tx.run(DELETE.from(cardano_1.TransactionRedeemers).where({ tx_hash: { in: hashes } }));
|
|
40
|
+
await tx.run(DELETE.from(cardano_1.TransactionDatums).where({ tx_hash: { in: hashes } }));
|
|
41
|
+
await tx.run(DELETE.from(cardano_1.Transactions).where({ hash: { in: hashes } }));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=transaction-rows.js.map
|
|
@@ -1,26 +1,11 @@
|
|
|
1
|
-
import type { TxBuildRequest } from '../../utils/types';
|
|
1
|
+
import type { TxBuildPlutusRequest, TxBuildRequest } from '../../utils/types';
|
|
2
2
|
import type { Network } from '../cardano-client';
|
|
3
3
|
import type { WalletJobKindValue } from './job-store';
|
|
4
|
-
/**
|
|
5
|
-
* Transform a stored wallet-job `requestJson` (the documented Build*-action
|
|
6
|
-
* payload shape — assetsJson, mintActionsJson, metadataJson strings, …) into
|
|
7
|
-
* the TxBuildRequest shape the CardanoIndexer build methods expect (assets,
|
|
8
|
-
* mintActions with bigint quantities, parsed metadata, assembled
|
|
9
|
-
* plutusScriptExecution, …).
|
|
10
|
-
*
|
|
11
|
-
* The synchronous CardanoTransactionService handlers do this transformation
|
|
12
|
-
* inline per action; the worker executes the SAME payload asynchronously, so
|
|
13
|
-
* this module mirrors that logic using the shared parsers
|
|
14
|
-
* (srv/utils/tx-request-parsers.ts). Validation failures throw
|
|
15
|
-
* BackendError 400 INVALID_INPUT — deterministic, so the job fails terminally
|
|
16
|
-
* instead of burning retries.
|
|
17
|
-
*/
|
|
18
4
|
type RawRequest = Record<string, unknown>;
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*/
|
|
5
|
+
/** Most recipients one payout job takes; the transaction size limit may be reached earlier. */
|
|
6
|
+
export declare const MAX_PAYOUT_OUTPUTS = 150;
|
|
7
|
+
export declare function preparePayoutRequest(raw: RawRequest): TxBuildPlutusRequest;
|
|
8
|
+
/** Raw job request → TxBuildRequest for the matching build method; malformed payloads throw 400 INVALID_INPUT. */
|
|
24
9
|
export declare function prepareWorkerBuildRequest(kind: WalletJobKindValue, raw: RawRequest, network: Network): TxBuildRequest;
|
|
25
10
|
export {};
|
|
26
11
|
//# sourceMappingURL=build-request.d.ts.map
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAX_PAYOUT_OUTPUTS = void 0;
|
|
4
|
+
exports.preparePayoutRequest = preparePayoutRequest;
|
|
3
5
|
exports.prepareWorkerBuildRequest = prepareWorkerBuildRequest;
|
|
4
6
|
const cardano_ledger_ts_1 = require("@harmoniclabs/cardano-ledger-ts");
|
|
5
7
|
const errors_1 = require("../../utils/errors");
|
|
@@ -12,12 +14,7 @@ const const_1 = require("../../utils/const");
|
|
|
12
14
|
function fail(message) {
|
|
13
15
|
throw new errors_1.BackendError(message, 400, error_codes_1.ERROR_CODES.INVALID_INPUT);
|
|
14
16
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Presence-only check for required payload fields. Format validation (bech32,
|
|
17
|
-
* hex, amounts) deliberately stays with the builder/indexer, mirroring what a
|
|
18
|
-
* missing field would produce on the synchronous path — the transform's job is
|
|
19
|
-
* the SHAPE, not re-validating content.
|
|
20
|
-
*/
|
|
17
|
+
/** Presence-only check; format validation (bech32, hex, amounts) stays with the builder/indexer. */
|
|
21
18
|
function requirePresent(raw, required) {
|
|
22
19
|
const missing = required.filter((f) => raw[f] === undefined || raw[f] === null || raw[f] === '');
|
|
23
20
|
if (missing.length > 0)
|
|
@@ -29,7 +26,7 @@ function parseJsonField(raw, field) {
|
|
|
29
26
|
return undefined;
|
|
30
27
|
if (typeof value !== 'string')
|
|
31
28
|
fail(`${field} must be a JSON string`);
|
|
32
|
-
const result = (0, validators_1.validateJsonWithLimits)(value, field);
|
|
29
|
+
const result = validators_1.PLUTUS_JSON_FIELDS.has(field) ? (0, validators_1.validatePlutusJson)(value, field) : (0, validators_1.validateJsonWithLimits)(value, field);
|
|
33
30
|
if (!result.valid)
|
|
34
31
|
fail(result.error);
|
|
35
32
|
return result.parsed;
|
|
@@ -42,8 +39,7 @@ function parseScriptParams(raw) {
|
|
|
42
39
|
fail('scriptParamsJson must be a JSON array');
|
|
43
40
|
return parsed;
|
|
44
41
|
}
|
|
45
|
-
/**
|
|
46
|
-
* multi-policy per-action fields). */
|
|
42
|
+
/** Mint-action parsing as in BuildMint/BuildPlutusSpend (bigint quantities, per-action policy fields). */
|
|
47
43
|
function parseMintActions(raw, allowBareNames) {
|
|
48
44
|
const parsed = parseJsonField(raw, 'mintActionsJson');
|
|
49
45
|
if (!Array.isArray(parsed))
|
|
@@ -54,11 +50,11 @@ function parseMintActions(raw, allowBareNames) {
|
|
|
54
50
|
}
|
|
55
51
|
const action = rawAction;
|
|
56
52
|
if (typeof action.quantity !== 'string' || !/^-?\d+$/.test(action.quantity)) {
|
|
57
|
-
fail(`Invalid quantity: "${String(action.quantity)}"
|
|
53
|
+
fail(`Invalid quantity: "${String(action.quantity)}": must be an integer string`);
|
|
58
54
|
}
|
|
59
55
|
if (typeof action.assetUnit !== 'string')
|
|
60
56
|
fail('Each mint action must have an assetUnit string');
|
|
61
|
-
//
|
|
57
|
+
// Optional per-action mintingPolicyScript + redeemerJson (multi-policy mint).
|
|
62
58
|
const policyFields = (0, tx_request_parsers_1.parseMintActionPolicyFields)(action, i);
|
|
63
59
|
if (policyFields.error)
|
|
64
60
|
fail(policyFields.error);
|
|
@@ -71,7 +67,7 @@ function parseMintActions(raw, allowBareNames) {
|
|
|
71
67
|
action.assetUnit.length % 2 === 0 &&
|
|
72
68
|
/^[0-9a-fA-F]*$/.test(action.assetUnit);
|
|
73
69
|
if (!(0, validators_1.isAssetUnit)(action.assetUnit) && !bareAssetNameForExpansion) {
|
|
74
|
-
fail(`Invalid assetUnit: "${action.assetUnit}"
|
|
70
|
+
fail(`Invalid assetUnit: "${action.assetUnit}": must be policyId+assetName hex (or a bare assetName hex when scriptParamsJson or a per-action mintingPolicyScript is set)`);
|
|
75
71
|
}
|
|
76
72
|
let assetUnit = action.assetUnit;
|
|
77
73
|
if (actionPolicyId) {
|
|
@@ -99,17 +95,12 @@ function scriptHashOf(scriptHex, context) {
|
|
|
99
95
|
return fail(`${context}: ${err instanceof Error ? err.message : String(err)}`);
|
|
100
96
|
}
|
|
101
97
|
}
|
|
102
|
-
/**
|
|
103
|
-
* BUG 9 mirror: every (expanded) mint action must carry the effective policy id —
|
|
104
|
-
* parseAssetUnit silently discards the first 56 hex chars, so a mismatched prefix
|
|
105
|
-
* would mint a truncated asset name.
|
|
106
|
-
*/
|
|
98
|
+
/** parseAssetUnit drops the first 56 hex chars, so a wrong policy prefix would mint a truncated name. */
|
|
107
99
|
function assertPolicyPrefix(actions, policyId) {
|
|
108
|
-
// Actions with their own
|
|
109
|
-
// script's policy id during parsing.
|
|
100
|
+
// Actions with their own script were already checked against that script's policy id.
|
|
110
101
|
const mismatch = actions.find((a) => !a.mintingPolicyScript && !a.assetUnit.toLowerCase().startsWith(policyId));
|
|
111
102
|
if (mismatch) {
|
|
112
|
-
fail(`assetUnit "${mismatch.assetUnit}" does not start with the minting policy id ${policyId}
|
|
103
|
+
fail(`assetUnit "${mismatch.assetUnit}" does not start with the minting policy id ${policyId}. Pass the full unit as policyId+assetName (asset names longer than 28 bytes cannot be passed bare)`);
|
|
113
104
|
}
|
|
114
105
|
}
|
|
115
106
|
function takeParsed(result) {
|
|
@@ -122,6 +113,8 @@ function prepareSimpleAda(raw, network) {
|
|
|
122
113
|
const clean = { ...raw };
|
|
123
114
|
clean.forceInputs = takeParsed((0, tx_request_parsers_1.parseUtxoRefArray)(raw.forceInputsJson, 'forceInputsJson'));
|
|
124
115
|
delete clean.forceInputsJson;
|
|
116
|
+
clean.protectInputs = takeParsed((0, tx_request_parsers_1.parseUtxoRefArray)(raw.protectInputsJson, 'protectInputsJson'));
|
|
117
|
+
delete clean.protectInputsJson;
|
|
125
118
|
const outputDatum = parseJsonField(raw, 'outputDatumJson');
|
|
126
119
|
if (outputDatum !== undefined)
|
|
127
120
|
clean.outputDatum = outputDatum;
|
|
@@ -178,6 +171,7 @@ function prepareMint(raw, network) {
|
|
|
178
171
|
const inlineDatum = parseJsonField(raw, 'inlineDatumJson');
|
|
179
172
|
const mintRedeemer = parseJsonField(raw, 'mintRedeemerJson');
|
|
180
173
|
const forceInputs = takeParsed((0, tx_request_parsers_1.parseUtxoRefArray)(raw.forceInputsJson, 'forceInputsJson'));
|
|
174
|
+
const protectInputs = takeParsed((0, tx_request_parsers_1.parseUtxoRefArray)(raw.protectInputsJson, 'protectInputsJson'));
|
|
181
175
|
const referenceInputs = takeParsed((0, tx_request_parsers_1.parseUtxoRefArray)(raw.referenceInputsJson, 'referenceInputsJson'));
|
|
182
176
|
const extraOutputs = takeParsed((0, tx_request_parsers_1.parseExtraOutputs)(raw.extraOutputsJson));
|
|
183
177
|
if (raw.lockOnScript && (!scriptParams || scriptParams.length === 0)) {
|
|
@@ -198,6 +192,7 @@ function prepareMint(raw, network) {
|
|
|
198
192
|
delete clean.mintRedeemerJson;
|
|
199
193
|
delete clean.lockOnScript;
|
|
200
194
|
delete clean.forceInputsJson;
|
|
195
|
+
delete clean.protectInputsJson;
|
|
201
196
|
delete clean.referenceInputsJson;
|
|
202
197
|
delete clean.extraOutputsJson;
|
|
203
198
|
if (parsedMetadata)
|
|
@@ -207,8 +202,7 @@ function prepareMint(raw, network) {
|
|
|
207
202
|
if (raw.referenceScriptHex)
|
|
208
203
|
clean.referenceScript = raw.referenceScriptHex;
|
|
209
204
|
delete clean.referenceScriptHex;
|
|
210
|
-
// Apply script parameters
|
|
211
|
-
// route lockOnScript output — mirrors BuildMintTransaction.
|
|
205
|
+
// Apply script parameters, expand bare asset names, route lockOnScript output.
|
|
212
206
|
let finalMintingPolicyScript = raw.mintingPolicyScript;
|
|
213
207
|
let effectivePolicyId;
|
|
214
208
|
if (scriptParams && scriptParams.length > 0) {
|
|
@@ -233,7 +227,7 @@ function prepareMint(raw, network) {
|
|
|
233
227
|
effectivePolicyId = cardano_ledger_ts_1.Script.fromCbor(Buffer.from(raw.mintingPolicyScript, 'hex')).hash.toString();
|
|
234
228
|
}
|
|
235
229
|
catch {
|
|
236
|
-
//
|
|
230
|
+
// Invalid script CBOR. The builder rejects it with its own message.
|
|
237
231
|
}
|
|
238
232
|
}
|
|
239
233
|
if (effectivePolicyId)
|
|
@@ -246,6 +240,7 @@ function prepareMint(raw, network) {
|
|
|
246
240
|
inlineDatum,
|
|
247
241
|
mintRedeemer,
|
|
248
242
|
forceInputs,
|
|
243
|
+
protectInputs,
|
|
249
244
|
referenceInputs,
|
|
250
245
|
extraOutputs,
|
|
251
246
|
};
|
|
@@ -264,9 +259,10 @@ function preparePlutusSpend(raw, network) {
|
|
|
264
259
|
fail('lockOnScript requires scriptParamsJson to derive script address');
|
|
265
260
|
}
|
|
266
261
|
const forceInputs = takeParsed((0, tx_request_parsers_1.parseUtxoRefArray)(raw.forceInputsJson, 'forceInputsJson'));
|
|
262
|
+
const protectInputs = takeParsed((0, tx_request_parsers_1.parseUtxoRefArray)(raw.protectInputsJson, 'protectInputsJson'));
|
|
267
263
|
const referenceInputs = takeParsed((0, tx_request_parsers_1.parseUtxoRefArray)(raw.referenceInputsJson, 'referenceInputsJson'));
|
|
268
264
|
const extraOutputs = takeParsed((0, tx_request_parsers_1.parseExtraOutputs)(raw.extraOutputsJson));
|
|
269
|
-
// Optional combined spend+mint
|
|
265
|
+
// Optional combined spend+mint.
|
|
270
266
|
const validatorScript = raw.validatorScript;
|
|
271
267
|
const mintingPolicyScript = raw.mintingPolicyScript;
|
|
272
268
|
let mintActions;
|
|
@@ -306,7 +302,7 @@ function preparePlutusSpend(raw, network) {
|
|
|
306
302
|
mintPolicyId = cardano_ledger_ts_1.Script.fromCbor(Buffer.from(finalMintingPolicyScript, 'hex')).hash.toString();
|
|
307
303
|
}
|
|
308
304
|
catch {
|
|
309
|
-
//
|
|
305
|
+
// Invalid script CBOR. The builder rejects it with its own message.
|
|
310
306
|
}
|
|
311
307
|
if (mintPolicyId)
|
|
312
308
|
assertPolicyPrefix(mintActions, mintPolicyId);
|
|
@@ -326,6 +322,7 @@ function preparePlutusSpend(raw, network) {
|
|
|
326
322
|
requiredSigners,
|
|
327
323
|
inlineDatum,
|
|
328
324
|
forceInputs,
|
|
325
|
+
protectInputs,
|
|
329
326
|
referenceInputs,
|
|
330
327
|
extraOutputs,
|
|
331
328
|
mintActions,
|
|
@@ -338,6 +335,7 @@ function preparePlutusSpend(raw, network) {
|
|
|
338
335
|
delete clean.scriptParamsJson;
|
|
339
336
|
delete clean.inlineDatumJson;
|
|
340
337
|
delete clean.forceInputsJson;
|
|
338
|
+
delete clean.protectInputsJson;
|
|
341
339
|
delete clean.referenceInputsJson;
|
|
342
340
|
delete clean.extraOutputsJson;
|
|
343
341
|
delete clean.mintActionsJson;
|
|
@@ -351,11 +349,30 @@ function preparePlutusSpend(raw, network) {
|
|
|
351
349
|
delete clean.lockOnScript;
|
|
352
350
|
return clean;
|
|
353
351
|
}
|
|
354
|
-
/**
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
352
|
+
/** Most recipients one payout job takes; the transaction size limit may be reached earlier. */
|
|
353
|
+
exports.MAX_PAYOUT_OUTPUTS = 150;
|
|
354
|
+
// payout: the outputs of `outputsJson` in the given order, paid from the wallet in one transaction.
|
|
355
|
+
// Entries read like those of BuildPlutusTransaction. No script runs.
|
|
356
|
+
function preparePayoutRequest(raw) {
|
|
357
|
+
requirePresent(raw, ['senderAddress', 'outputsJson']);
|
|
358
|
+
if (typeof raw.outputsJson !== 'string')
|
|
359
|
+
fail('outputsJson must be a JSON string');
|
|
360
|
+
const outputs = takeParsed((0, tx_request_parsers_1.parseOutputList)(raw.outputsJson, 'outputsJson', exports.MAX_PAYOUT_OUTPUTS));
|
|
361
|
+
if (!outputs)
|
|
362
|
+
fail('outputsJson must list at least one output');
|
|
363
|
+
return {
|
|
364
|
+
network: raw.network,
|
|
365
|
+
senderAddress: raw.senderAddress,
|
|
366
|
+
changeAddress: raw.changeAddress,
|
|
367
|
+
scriptInputs: [],
|
|
368
|
+
outputs,
|
|
369
|
+
forceInputs: takeParsed((0, tx_request_parsers_1.parseUtxoRefArray)(raw.forceInputsJson, 'forceInputsJson')),
|
|
370
|
+
protectInputs: takeParsed((0, tx_request_parsers_1.parseUtxoRefArray)(raw.protectInputsJson, 'protectInputsJson')),
|
|
371
|
+
validityStartMs: raw.validityStartMs,
|
|
372
|
+
validityEndMs: raw.validityEndMs,
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
/** Raw job request → TxBuildRequest for the matching build method; malformed payloads throw 400 INVALID_INPUT. */
|
|
359
376
|
function prepareWorkerBuildRequest(kind, raw, network) {
|
|
360
377
|
switch (kind) {
|
|
361
378
|
case 'simpleAda': return prepareSimpleAda(raw, network);
|
|
@@ -1,22 +1,4 @@
|
|
|
1
1
|
import type { CardanoClient } from '../cardano-client';
|
|
2
|
-
/**
|
|
3
|
-
* Confirmation tracker (v2.0, design §7).
|
|
4
|
-
*
|
|
5
|
-
* Watches `submitted` jobs until their tx sits at depth ≥ `confirmationDepth`:
|
|
6
|
-
* - Crawler hook (preferred, zero extra load): `blockIndexed` events match
|
|
7
|
-
* submitted tx hashes and carry the advancing tip; `reorg` events invalidate
|
|
8
|
-
* confirmation points behind the fork and optionally re-submit the SAME
|
|
9
|
-
* signed CBOR (never a rebuild — the double-spend guard).
|
|
10
|
-
* - Polling fallback (always on, hook path just accelerates): every
|
|
11
|
-
* `pollIntervalMs` unfound txs are looked up via `client.getTransaction`
|
|
12
|
-
* and the tip via `client.getLatestBlock`.
|
|
13
|
-
*
|
|
14
|
-
* A tx that stays unseen past `confirmationTimeoutMs` fails as TX_DROPPED —
|
|
15
|
-
* safe to retry from the caller, because the guard is the on-chain lookup itself.
|
|
16
|
-
*
|
|
17
|
-
* Confirmations are counted as `tipHeight - foundHeight + 1`, so depth 1 means
|
|
18
|
-
* "confirmed as soon as included in a block".
|
|
19
|
-
*/
|
|
20
2
|
export interface TrackedJob {
|
|
21
3
|
jobId: string;
|
|
22
4
|
walletId: string;
|
|
@@ -28,12 +10,7 @@ export interface TrackedJob {
|
|
|
28
10
|
submittedAt: string;
|
|
29
11
|
foundSlot: number | null;
|
|
30
12
|
foundHeight: number | null;
|
|
31
|
-
/**
|
|
32
|
-
* Polling round in which the tx was last SEEN on-chain (found or
|
|
33
|
-
* re-validated). A job found in the current round needs no second lookup
|
|
34
|
-
* before it is confirmed; one found in an earlier round is re-checked, so a
|
|
35
|
-
* rollback the crawler did not report (crawler off) cannot slip through.
|
|
36
|
-
*/
|
|
13
|
+
/** Polling round that last saw the tx. Older inclusions are re-checked to catch unreported rollbacks. */
|
|
37
14
|
seenRound?: number;
|
|
38
15
|
}
|
|
39
16
|
export interface ConfirmationTrackerOptions {
|
|
@@ -51,7 +28,7 @@ export interface ConfirmationTrackerDeps {
|
|
|
51
28
|
walletId: string;
|
|
52
29
|
outcome: 'confirmed' | 'failed';
|
|
53
30
|
kind: string | null;
|
|
54
|
-
/**
|
|
31
|
+
/** Set even on failure, since the tx was submitted. */
|
|
55
32
|
txHash: string;
|
|
56
33
|
errorCode?: string;
|
|
57
34
|
errorMessage?: string;
|
|
@@ -86,31 +63,13 @@ export declare class ConfirmationTracker {
|
|
|
86
63
|
}): void;
|
|
87
64
|
private onBlockIndexed;
|
|
88
65
|
private onReorg;
|
|
89
|
-
/**
|
|
90
|
-
* The recorded inclusion is gone (a reorg the crawler reported, or a polling
|
|
91
|
-
* re-check that no longer finds the tx): back to watching, and optionally
|
|
92
|
-
* re-submit the SAME signed CBOR — never a rebuild, that is the double-spend
|
|
93
|
-
* guard. "Already known" means the tx survived into the new chain's mempool;
|
|
94
|
-
* that is success, not an error.
|
|
95
|
-
*/
|
|
66
|
+
/** Back to watching after a rollback. Re-submits the same signed CBOR, never a rebuild, to avoid a double spend. */
|
|
96
67
|
private forgetInclusion;
|
|
97
68
|
/** One polling round. Public for tests; guarded against overlapping rounds. */
|
|
98
69
|
pollOnce(): Promise<void>;
|
|
99
|
-
/**
|
|
100
|
-
* Confirm every found job whose depth requirement is met by the known tip.
|
|
101
|
-
* `revalidate` (polling path): an inclusion not seen in THIS round is looked
|
|
102
|
-
* up again first — the crawler's reorg events are the only rollback signal,
|
|
103
|
-
* and with the crawler off there is none, so a tx that was found at height N
|
|
104
|
-
* and then rolled back would otherwise be confirmed on the tip alone.
|
|
105
|
-
*/
|
|
70
|
+
/** Confirms found jobs deep enough. With revalidate, an inclusion not seen this round is looked up again. */
|
|
106
71
|
private confirmMature;
|
|
107
|
-
/**
|
|
108
|
-
* Is the tx still on-chain, and still deep enough? Re-reads it; a tx that
|
|
109
|
-
* moved to another block (re-included after a rollback) gets its new point
|
|
110
|
-
* and is judged at the new height; one that is gone is forgotten (back to
|
|
111
|
-
* watching, optional same-CBOR re-submit) and the tip is re-learned next
|
|
112
|
-
* round, because the pre-rollback tip may overstate the depth.
|
|
113
|
-
*/
|
|
72
|
+
/** True if the tx is still on-chain and deep enough. A moved tx takes its new height, a vanished one is watched again. */
|
|
114
73
|
private stillIncluded;
|
|
115
74
|
private finalize;
|
|
116
75
|
}
|