@odatano/core 2.0.0-rc.49 → 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.
Files changed (120) hide show
  1. package/@cds-models/CardanoAgentService/index.d.ts +6 -12
  2. package/@cds-models/CardanoIndexerService/index.d.ts +200 -2
  3. package/@cds-models/CardanoIndexerService/index.js +24 -0
  4. package/@cds-models/CardanoODataService/index.d.ts +49 -6
  5. package/@cds-models/CardanoODataService/index.js +4 -0
  6. package/@cds-models/CardanoSignService/index.d.ts +3 -3
  7. package/@cds-models/CardanoWorkerService/index.d.ts +4 -3
  8. package/@cds-models/index.d.ts +9 -1
  9. package/@cds-models/index.js +2 -1
  10. package/@cds-models/odatano/cardano/index.d.ts +59 -5
  11. package/@cds-models/odatano/cardano/index.js +6 -0
  12. package/README.md +29 -17
  13. package/db/schema.cds +117 -24
  14. package/db/types.cds +8 -0
  15. package/package.json +17 -15
  16. package/scripts/migrate-schema.mjs +334 -0
  17. package/src/index.d.ts +7 -5
  18. package/src/index.js +12 -10
  19. package/src/plugin.js +6 -7
  20. package/srv/blockchain/backends/blockfrost-backend.js +9 -1
  21. package/srv/blockchain/backends/cardano-backend.d.ts +15 -0
  22. package/srv/blockchain/backends/cardano-backend.js +5 -0
  23. package/srv/blockchain/backends/koios-backend.js +16 -10
  24. package/srv/blockchain/backends/ogmios-backend.d.ts +9 -3
  25. package/srv/blockchain/backends/ogmios-backend.js +60 -18
  26. package/srv/blockchain/cardano-client.d.ts +5 -4
  27. package/srv/blockchain/cardano-client.js +46 -13
  28. package/srv/blockchain/cardano-indexer.d.ts +116 -9
  29. package/srv/blockchain/cardano-indexer.js +436 -189
  30. package/srv/blockchain/crawler/account-snapshots.d.ts +29 -0
  31. package/srv/blockchain/crawler/account-snapshots.js +153 -0
  32. package/srv/blockchain/crawler/asset-registry-backfill.d.ts +23 -1
  33. package/srv/blockchain/crawler/asset-registry-backfill.js +91 -1
  34. package/srv/blockchain/crawler/certificate-backfill.d.ts +2 -0
  35. package/srv/blockchain/crawler/certificate-backfill.js +10 -3
  36. package/srv/blockchain/crawler/crawler.d.ts +15 -0
  37. package/srv/blockchain/crawler/crawler.js +68 -3
  38. package/srv/blockchain/crawler/input-asset-copies.d.ts +34 -0
  39. package/srv/blockchain/crawler/input-asset-copies.js +171 -0
  40. package/srv/blockchain/crawler/metadata-position-backfill.d.ts +16 -0
  41. package/srv/blockchain/crawler/metadata-position-backfill.js +55 -0
  42. package/srv/blockchain/crawler/output-datum-backfill.d.ts +39 -0
  43. package/srv/blockchain/crawler/output-datum-backfill.js +110 -0
  44. package/srv/blockchain/crawler/transaction-backfill.d.ts +2 -0
  45. package/srv/blockchain/crawler/transaction-backfill.js +12 -8
  46. package/srv/blockchain/pool-metadata.d.ts +15 -0
  47. package/srv/blockchain/pool-metadata.js +132 -0
  48. package/srv/blockchain/signing/cose-verifier.d.ts +3 -1
  49. package/srv/blockchain/signing/cose-verifier.js +144 -56
  50. package/srv/blockchain/signing/hsm-signer.js +2 -1
  51. package/srv/blockchain/signing/submission-finalizer.d.ts +15 -4
  52. package/srv/blockchain/signing/submission-finalizer.js +201 -69
  53. package/srv/blockchain/stored-chain.js +1 -1
  54. package/srv/blockchain/transaction-building/buildooor-tx.d.ts +1 -3
  55. package/srv/blockchain/transaction-building/buildooor-tx.js +34 -54
  56. package/srv/blockchain/transaction-presence.d.ts +5 -0
  57. package/srv/blockchain/transaction-presence.js +29 -0
  58. package/srv/blockchain/transaction-rows.js +1 -1
  59. package/srv/blockchain/wallet-worker/build-request.d.ts +4 -1
  60. package/srv/blockchain/wallet-worker/build-request.js +25 -0
  61. package/srv/blockchain/wallet-worker/confirmation-tracker.js +1 -1
  62. package/srv/blockchain/wallet-worker/job-store.d.ts +17 -7
  63. package/srv/blockchain/wallet-worker/job-store.js +0 -0
  64. package/srv/blockchain/wallet-worker/signers.d.ts +2 -0
  65. package/srv/blockchain/wallet-worker/wallet-worker.d.ts +2 -0
  66. package/srv/blockchain/wallet-worker/wallet-worker.js +42 -32
  67. package/srv/cardano-agent-service.cds +11 -12
  68. package/srv/cardano-agent-service.js +2 -0
  69. package/srv/cardano-backend-service.cds +34 -1
  70. package/srv/cardano-backend-service.js +20 -17
  71. package/srv/cardano-indexer-service.cds +153 -12
  72. package/srv/cardano-indexer-service.js +175 -29
  73. package/srv/cardano-service.cds +67 -3
  74. package/srv/cardano-service.js +132 -67
  75. package/srv/cardano-sign-service.cds +30 -20
  76. package/srv/cardano-sign-service.js +13 -10
  77. package/srv/cardano-tx-service.cds +15 -1
  78. package/srv/cardano-tx-service.js +4 -1
  79. package/srv/cardano-worker-service.cds +16 -7
  80. package/srv/cardano-worker-service.js +31 -22
  81. package/srv/cbor/parse.js +11 -34
  82. package/srv/config.d.ts +113 -0
  83. package/srv/config.js +409 -0
  84. package/srv/server.d.ts +9 -14
  85. package/srv/server.js +32 -316
  86. package/srv/utils/agent-access.d.ts +9 -0
  87. package/srv/utils/agent-access.js +67 -0
  88. package/srv/utils/agent-grants-config.d.ts +0 -17
  89. package/srv/utils/agent-grants-config.js +6 -81
  90. package/srv/utils/agent-grants.d.ts +6 -19
  91. package/srv/utils/agent-grants.js +69 -130
  92. package/srv/utils/const.d.ts +4 -0
  93. package/srv/utils/const.js +5 -1
  94. package/srv/utils/db-indexes.js +11 -3
  95. package/srv/utils/error-codes.d.ts +4 -0
  96. package/srv/utils/error-codes.js +4 -0
  97. package/srv/utils/errors.d.ts +6 -0
  98. package/srv/utils/errors.js +23 -1
  99. package/srv/utils/liveness.js +2 -5
  100. package/srv/utils/mappers.d.ts +5 -7
  101. package/srv/utils/mappers.js +22 -9
  102. package/srv/utils/pg-order-nulls.js +4 -3
  103. package/srv/utils/readiness.d.ts +12 -0
  104. package/srv/utils/readiness.js +29 -0
  105. package/srv/utils/result-numbers.d.ts +15 -0
  106. package/srv/utils/result-numbers.js +61 -0
  107. package/srv/utils/tx-request-parsers.d.ts +1 -1
  108. package/srv/utils/tx-request-parsers.js +3 -3
  109. package/srv/utils/tx-utils.d.ts +3 -0
  110. package/srv/utils/tx-utils.js +17 -3
  111. package/srv/utils/types.d.ts +16 -3
  112. package/scripts/migrate-txseq.mjs +0 -138
  113. package/srv/blockchain/transaction-building/buildooor-fee-patch.d.ts +0 -13
  114. package/srv/blockchain/transaction-building/buildooor-fee-patch.js +0 -71
  115. package/srv/blockchain/transaction-building/caller-datums.d.ts +0 -15
  116. package/srv/blockchain/transaction-building/caller-datums.js +0 -133
  117. package/srv/cbor/redeemer-tag-patch.d.ts +0 -3
  118. package/srv/cbor/redeemer-tag-patch.js +0 -61
  119. package/srv/utils/legacy-service-paths.d.ts +0 -11
  120. package/srv/utils/legacy-service-paths.js +0 -58
@@ -0,0 +1,171 @@
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.ASSET_COLUMNS = void 0;
7
+ exports.referenceStatement = referenceStatement;
8
+ exports.deleteCopiesStatement = deleteCopiesStatement;
9
+ exports.keptStatement = keptStatement;
10
+ exports.restoreCopiesStatement = restoreCopiesStatement;
11
+ exports.dropReferenceStatement = dropReferenceStatement;
12
+ exports.bothStatement = bothStatement;
13
+ exports.pruneInputAssetCopies = pruneInputAssetCopies;
14
+ exports.restoreInputAssetCopies = restoreInputAssetCopies;
15
+ const cds_1 = __importDefault(require("@sap/cds"));
16
+ const mappers_1 = require("../../utils/mappers");
17
+ const cardano_1 = require("#cds-models/odatano/cardano");
18
+ const { SELECT } = cds_1.default.ql;
19
+ const logger = cds_1.default.log('InputAssetCopies');
20
+ // An input reads its assets from a stored copy or, through `spentTxSeq`, from the output it spent.
21
+ // It has one of the two, never both. The prune moves the inputs of a slot range from copies to the
22
+ // reference, the restore moves them back. Both walk by the slot of the spending transaction.
23
+ const INPUTS = 'odatano_cardano_TransactionInputs';
24
+ const COPIES = 'odatano_cardano_TransactionInputAssetCopies';
25
+ const TRANSACTIONS = 'odatano_cardano_Transactions';
26
+ const OUTPUTS = 'odatano_cardano_TransactionOutputs';
27
+ const OUTPUT_ASSETS = 'odatano_cardano_TransactionOutputAssets';
28
+ /** Columns of an asset row besides its key, the same in the copies and in the output assets. */
29
+ exports.ASSET_COLUMNS = ['asset_quantity', 'asset_policyId', 'asset_assetNameHex', 'asset_assetName', 'asset_fingerprint'];
30
+ const supported = (kind) => kind === 'postgres' || kind === 'sqlite' || kind === 'better-sqlite';
31
+ const bounds = (kind) => (kind === 'postgres' ? ['$1', '$2'] : ['?', '?']);
32
+ // Points the inputs of a window at their output. Only where the output is stored and holds
33
+ // exactly the asset rows of the input's copy, so the input reads the same assets afterwards.
34
+ function referenceStatement(kind) {
35
+ if (!supported(kind))
36
+ return null;
37
+ const [lo, hi] = bounds(kind);
38
+ const copy = `c.input_txSeq = i.txSeq AND c.input_inputIndex = i.inputIndex`;
39
+ const spent = `a.output_txSeq = t.txSeq AND a.output_outputIndex = i.spentOutputIndex`;
40
+ return `UPDATE ${INPUTS} AS i SET spentTxSeq = t.txSeq FROM ${TRANSACTIONS} AS t ` +
41
+ `WHERE t.hash = i.spentTxHash AND i.spentTxSeq IS NULL AND i.txSeq >= ${lo} AND i.txSeq < ${hi} ` +
42
+ `AND EXISTS (SELECT 1 FROM ${OUTPUTS} AS o WHERE o.txSeq = t.txSeq AND o.outputIndex = i.spentOutputIndex) ` +
43
+ `AND NOT EXISTS (SELECT 1 FROM ${COPIES} AS c WHERE ${copy} AND NOT EXISTS (` +
44
+ `SELECT 1 FROM ${OUTPUT_ASSETS} AS a WHERE ${spent} AND a.unit = c.unit AND a.asset_quantity = c.asset_quantity)) ` +
45
+ `AND (SELECT count(*) FROM ${COPIES} AS c WHERE ${copy}) = (SELECT count(*) FROM ${OUTPUT_ASSETS} AS a WHERE ${spent})`;
46
+ }
47
+ /** Deletes the copies of the inputs of a window that have a reference. */
48
+ function deleteCopiesStatement(kind) {
49
+ if (!supported(kind))
50
+ return null;
51
+ const [lo, hi] = bounds(kind);
52
+ return `DELETE FROM ${COPIES} WHERE input_txSeq >= ${lo} AND input_txSeq < ${hi} AND EXISTS (` +
53
+ `SELECT 1 FROM ${INPUTS} AS i WHERE i.txSeq = ${COPIES}.input_txSeq AND i.inputIndex = ${COPIES}.input_inputIndex ` +
54
+ `AND i.spentTxSeq IS NOT NULL)`;
55
+ }
56
+ /** Counts the inputs of a window that have no reference. */
57
+ function keptStatement(kind) {
58
+ if (!supported(kind))
59
+ return null;
60
+ const [lo, hi] = bounds(kind);
61
+ return `SELECT count(*) AS n FROM ${INPUTS} WHERE txSeq >= ${lo} AND txSeq < ${hi} AND spentTxSeq IS NULL`;
62
+ }
63
+ /** Writes the copies of the inputs of a window that have a reference, from the outputs they spent. */
64
+ function restoreCopiesStatement(kind) {
65
+ if (!supported(kind))
66
+ return null;
67
+ const [lo, hi] = bounds(kind);
68
+ const columns = exports.ASSET_COLUMNS.join(', ');
69
+ return `INSERT INTO ${COPIES} (input_txSeq, input_inputIndex, unit, ${columns}) ` +
70
+ `SELECT i.txSeq, i.inputIndex, a.unit, ${exports.ASSET_COLUMNS.map(c => `a.${c}`).join(', ')} FROM ${INPUTS} AS i ` +
71
+ `JOIN ${OUTPUT_ASSETS} AS a ON a.output_txSeq = i.spentTxSeq AND a.output_outputIndex = i.spentOutputIndex ` +
72
+ `WHERE i.txSeq >= ${lo} AND i.txSeq < ${hi}`;
73
+ }
74
+ /** Takes the reference from the inputs of a window, once their copies are written. */
75
+ function dropReferenceStatement(kind) {
76
+ if (!supported(kind))
77
+ return null;
78
+ const [lo, hi] = bounds(kind);
79
+ return `UPDATE ${INPUTS} SET spentTxSeq = NULL WHERE txSeq >= ${lo} AND txSeq < ${hi} AND spentTxSeq IS NOT NULL`;
80
+ }
81
+ // Counts the inputs of a window that have copies and a reference. The view would show their
82
+ // assets twice, so a window that leaves one behind is rolled back.
83
+ function bothStatement(kind) {
84
+ if (!supported(kind))
85
+ return null;
86
+ const [lo, hi] = bounds(kind);
87
+ return `SELECT count(*) AS n FROM ${INPUTS} AS i WHERE i.txSeq >= ${lo} AND i.txSeq < ${hi} AND i.spentTxSeq IS NOT NULL ` +
88
+ `AND EXISTS (SELECT 1 FROM ${COPIES} AS c WHERE c.input_txSeq = i.txSeq AND c.input_inputIndex = i.inputIndex)`;
89
+ }
90
+ async function assertOneSource(tx, check, window) {
91
+ const [found] = await tx.run(check, window);
92
+ const both = Number(found?.n ?? 0);
93
+ if (both > 0)
94
+ throw new Error(`${both} inputs between txSeq ${window[0]} and ${window[1]} would have copies and a reference; the window is left unchanged`);
95
+ }
96
+ const dbKind = () => cds_1.default.db?.kind ?? '';
97
+ /** Rows a plain statement changed; the drivers answer with their own result object. */
98
+ function changed(result) {
99
+ const r = result;
100
+ return typeof r === 'number' ? r : Number(r?.changes ?? r?.rowCount) || 0;
101
+ }
102
+ function statementFor(build) {
103
+ const sql = build(dbKind());
104
+ if (!sql)
105
+ throw new Error(`Input asset copies are pruned and restored on PostgreSQL and SQLite only (database kind: ${dbKind() || 'none'})`);
106
+ return sql;
107
+ }
108
+ /** The asked slots cut to the slots that hold a stored input. Null when there is nothing to walk. */
109
+ async function slotRange(opts) {
110
+ const stored = (await cds_1.default.tx((tx) => tx.run(SELECT.one.from(cardano_1.TransactionInputs).columns('min(txSeq) as lo', 'max(txSeq) as hi'))));
111
+ if (stored?.lo == null || stored.hi == null)
112
+ return null;
113
+ const from = Math.max(opts.fromSlot, Math.floor(Number(stored.lo) / mappers_1.TX_SEQ_SLOT_FACTOR));
114
+ const to = Math.min(opts.toSlot, Math.floor(Number(stored.hi) / mappers_1.TX_SEQ_SLOT_FACTOR));
115
+ return from <= to ? { from, to } : null;
116
+ }
117
+ /** Calls `step` with the txSeq bounds of each slot window, each in a transaction of its own. */
118
+ async function walk(opts, progress, step) {
119
+ const slotWindow = opts.slotWindow ?? 20_000;
120
+ const range = await slotRange(opts);
121
+ if (!range)
122
+ return null;
123
+ progress.toSlot = range.to;
124
+ for (let slot = range.from; slot <= range.to; slot += slotWindow) {
125
+ const window = [slot * mappers_1.TX_SEQ_SLOT_FACTOR, Math.min(slot + slotWindow, range.to + 1) * mappers_1.TX_SEQ_SLOT_FACTOR];
126
+ await cds_1.default.tx((tx) => step(tx, window));
127
+ progress.atSlot = Math.min(slot + slotWindow - 1, range.to);
128
+ opts.onProgress?.({ ...progress });
129
+ }
130
+ return range;
131
+ }
132
+ // Moves the inputs of the slot range from copies to the reference. Per window, in one transaction:
133
+ // set the reference where the output's assets equal the copy, then delete the copies of those inputs.
134
+ async function pruneInputAssetCopies(opts) {
135
+ const reference = statementFor(referenceStatement);
136
+ const remove = statementFor(deleteCopiesStatement);
137
+ const count = statementFor(keptStatement);
138
+ const check = statementFor(bothStatement);
139
+ const progress = { atSlot: 0, toSlot: 0, referenced: 0, kept: 0, deleted: 0 };
140
+ const range = await walk(opts, progress, async (tx, window) => {
141
+ const referenced = changed(await tx.run(reference, window));
142
+ const deleted = changed(await tx.run(remove, window));
143
+ await assertOneSource(tx, check, window);
144
+ const [left] = await tx.run(count, window);
145
+ progress.referenced += referenced;
146
+ progress.deleted += deleted;
147
+ progress.kept += Number(left?.n ?? 0);
148
+ });
149
+ if (range)
150
+ logger.info(`input asset copies pruned: ${progress.referenced} inputs read from their output, ${progress.kept} left without a reference,${progress.deleted} rows deleted, slots ${range.from} to ${range.to}`);
151
+ return progress;
152
+ }
153
+ // Moves the inputs of the slot range back to copies. Per window, in one transaction: write the
154
+ // copies from the outputs, then take the reference from those inputs.
155
+ async function restoreInputAssetCopies(opts) {
156
+ const write = statementFor(restoreCopiesStatement);
157
+ const release = statementFor(dropReferenceStatement);
158
+ const check = statementFor(bothStatement);
159
+ const progress = { atSlot: 0, toSlot: 0, restored: 0, rows: 0 };
160
+ const range = await walk(opts, progress, async (tx, window) => {
161
+ const rows = changed(await tx.run(write, window));
162
+ const restored = changed(await tx.run(release, window));
163
+ await assertOneSource(tx, check, window);
164
+ progress.rows += rows;
165
+ progress.restored += restored;
166
+ });
167
+ if (range)
168
+ logger.info(`input asset copies restored: ${progress.restored} inputs, ${progress.rows} rows, slots ${range.from} to ${range.to}`);
169
+ return progress;
170
+ }
171
+ //# sourceMappingURL=input-asset-copies.js.map
@@ -0,0 +1,16 @@
1
+ export interface MetadataPositionProgress {
2
+ /** Slot the walk has reached. */
3
+ atSlot: number;
4
+ /** Last slot that holds a stored transaction. */
5
+ toSlot: number;
6
+ /** Metadata rows that received their position. */
7
+ rows: number;
8
+ }
9
+ export interface MetadataPositionOptions {
10
+ /** Slots per statement. */
11
+ slotWindow?: number;
12
+ onProgress?: (p: MetadataPositionProgress) => void;
13
+ }
14
+ export declare function metadataPositionStatement(kind: string): string | null;
15
+ export declare function backfillMetadataPositions(opts?: MetadataPositionOptions): Promise<MetadataPositionProgress>;
16
+ //# sourceMappingURL=metadata-position-backfill.d.ts.map
@@ -0,0 +1,55 @@
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.metadataPositionStatement = metadataPositionStatement;
7
+ exports.backfillMetadataPositions = backfillMetadataPositions;
8
+ const cds_1 = __importDefault(require("@sap/cds"));
9
+ const mappers_1 = require("../../utils/mappers");
10
+ const cardano_1 = require("#cds-models/odatano/cardano");
11
+ const { SELECT, UPDATE } = cds_1.default.ql;
12
+ const logger = cds_1.default.log('MetadataPositionBackfill');
13
+ const METADATA_TABLE = 'odatano_cardano_TransactionMetadata';
14
+ const TRANSACTIONS_TABLE = 'odatano_cardano_Transactions';
15
+ // One UPDATE per window that takes the position from the transaction row. Null for databases
16
+ // other than Postgres and SQLite, which update transaction by transaction.
17
+ function metadataPositionStatement(kind) {
18
+ if (kind !== 'postgres' && kind !== 'sqlite' && kind !== 'better-sqlite')
19
+ return null;
20
+ const [lo, hi] = kind === 'postgres' ? ['$1', '$2'] : ['?', '?'];
21
+ return `UPDATE ${METADATA_TABLE} AS m SET txSeq = t.txSeq FROM ${TRANSACTIONS_TABLE} AS t ` +
22
+ `WHERE t.hash = m.tx_hash AND m.txSeq IS NULL AND t.txSeq >= ${lo} AND t.txSeq < ${hi}`;
23
+ }
24
+ async function fillWindow(tx, lo, hi) {
25
+ const sql = metadataPositionStatement(cds_1.default.db?.kind ?? '');
26
+ if (sql) {
27
+ // a plain statement answers with the driver's result object
28
+ const result = await tx.run(sql, [lo, hi]);
29
+ return Number(result?.changes) || 0;
30
+ }
31
+ const txs = (await tx.run(SELECT.from(cardano_1.Transactions).columns('hash', 'txSeq').where({ txSeq: { '>=': lo, '<': hi } }))) ?? [];
32
+ let rows = 0;
33
+ for (const t of txs) {
34
+ rows += Number(await tx.run(UPDATE.entity(cardano_1.TransactionMetadata).set({ txSeq: Number(t.txSeq) }).where({ tx_hash: t.hash, txSeq: null }))) || 0;
35
+ }
36
+ return rows;
37
+ }
38
+ async function backfillMetadataPositions(opts = {}) {
39
+ const slotWindow = opts.slotWindow ?? 20_000;
40
+ const bounds = (await cds_1.default.tx((tx) => tx.run(SELECT.one.from(cardano_1.Transactions).columns('min(txSeq) as lo', 'max(txSeq) as hi'))));
41
+ const progress = { atSlot: 0, toSlot: 0, rows: 0 };
42
+ if (bounds?.lo == null || bounds.hi == null)
43
+ return progress;
44
+ const firstSlot = Math.floor(Number(bounds.lo) / mappers_1.TX_SEQ_SLOT_FACTOR);
45
+ progress.toSlot = Math.floor(Number(bounds.hi) / mappers_1.TX_SEQ_SLOT_FACTOR);
46
+ for (let slot = firstSlot; slot <= progress.toSlot; slot += slotWindow) {
47
+ const next = slot + slotWindow;
48
+ progress.rows += await cds_1.default.tx((tx) => fillWindow(tx, slot * mappers_1.TX_SEQ_SLOT_FACTOR, next * mappers_1.TX_SEQ_SLOT_FACTOR));
49
+ progress.atSlot = Math.min(next - 1, progress.toSlot);
50
+ opts.onProgress?.({ ...progress });
51
+ }
52
+ logger.info(`metadata positions: ${progress.rows} rows filled up to slot ${progress.toSlot}`);
53
+ return progress;
54
+ }
55
+ //# sourceMappingURL=metadata-position-backfill.js.map
@@ -0,0 +1,39 @@
1
+ import type { Transaction as CapTransaction } from '@sap/cds';
2
+ import type { CardanoClient } from '../cardano-client';
3
+ import type { TxOutputLine } from '../../utils/types';
4
+ /** A transaction as the source of its outputs' fields. */
5
+ export interface OutputSource {
6
+ hash: string;
7
+ txSeq: number;
8
+ outputs: TxOutputLine[];
9
+ }
10
+ /** Rows that received at least one field, per table. */
11
+ export interface OutputFillCounts {
12
+ outputs: number;
13
+ inputs: number;
14
+ ledgerUtxos: number;
15
+ }
16
+ export declare function fillOutputFields(tx: CapTransaction, sources: OutputSource[]): Promise<OutputFillCounts>;
17
+ export declare class OutputDatumBackfillError extends Error {
18
+ constructor(message: string);
19
+ }
20
+ export interface OutputDatumBackfillProgress extends OutputFillCounts {
21
+ /** Stored outputs read. */
22
+ scanned: number;
23
+ /** Outputs with a datum hash and no inline datum. */
24
+ candidates: number;
25
+ /** Transactions read again from the backend. */
26
+ transactions: number;
27
+ /** Candidate transactions the backend did not return. */
28
+ missing: number;
29
+ }
30
+ export interface OutputDatumBackfillOptions {
31
+ client: Pick<CardanoClient, 'getTransactionsBatch' | 'supports'>;
32
+ /** Stored outputs per page. Must exceed the outputs one transaction can hold. */
33
+ chunkSize?: number;
34
+ /** Transactions per backend read. */
35
+ batchSize?: number;
36
+ onProgress?: (p: OutputDatumBackfillProgress) => void;
37
+ }
38
+ export declare function backfillOutputDatums(opts: OutputDatumBackfillOptions): Promise<OutputDatumBackfillProgress>;
39
+ //# sourceMappingURL=output-datum-backfill.d.ts.map
@@ -0,0 +1,110 @@
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.OutputDatumBackfillError = void 0;
7
+ exports.fillOutputFields = fillOutputFields;
8
+ exports.backfillOutputDatums = backfillOutputDatums;
9
+ const cds_1 = __importDefault(require("@sap/cds"));
10
+ const collections_1 = require("../../utils/collections");
11
+ const cardano_1 = require("#cds-models/odatano/cardano");
12
+ const { SELECT, UPDATE } = cds_1.default.ql;
13
+ const logger = cds_1.default.log('OutputDatumBackfill');
14
+ // Datum and reference-script fields of stored outputs that an earlier read left empty. The same
15
+ // values go to the input rows that spent the output and to its row in the crawler-fed UTxO set.
16
+ const FIELDS = ['dataHash', 'inlineDatum', 'referenceScriptHash', 'referenceScriptSize', 'referenceScriptType'];
17
+ const OUTPUT_COLUMNS = ['txSeq', 'outputIndex', ...FIELDS.map((f) => `utxo_${f}`)];
18
+ /** Fields the stored output lacks and the fresh one carries. */
19
+ function missingFields(row, fresh) {
20
+ return FIELDS.flatMap((f) => {
21
+ const value = fresh[f];
22
+ return row[`utxo_${f}`] == null && value != null && value !== '' ? [[f, value]] : [];
23
+ });
24
+ }
25
+ // Fills the empty datum and reference-script fields of the stored outputs of these transactions,
26
+ // of the inputs that spent them and of their UTxO set rows. Only empty fields change.
27
+ async function fillOutputFields(tx, sources) {
28
+ const counts = { outputs: 0, inputs: 0, ledgerUtxos: 0 };
29
+ const bySeq = new Map(sources.map((s) => [s.txSeq, s]));
30
+ for (const seqs of (0, collections_1.chunk)([...bySeq.keys()], collections_1.IN_CHUNK)) {
31
+ const rows = (await tx.run(SELECT.from(cardano_1.TransactionOutputs).columns(...OUTPUT_COLUMNS).where({ txSeq: { in: seqs } }))) ?? [];
32
+ for (const row of rows) {
33
+ const source = bySeq.get(Number(row.txSeq));
34
+ const outputIndex = Number(row.outputIndex);
35
+ const fresh = source?.outputs.find((o) => o.outputIndex === outputIndex);
36
+ const missing = fresh ? missingFields(row, fresh) : [];
37
+ if (!source || !missing.length)
38
+ continue;
39
+ const set = Object.fromEntries(missing.map(([f, v]) => [`utxo_${f}`, v]));
40
+ await tx.run(UPDATE.entity(cardano_1.TransactionOutputs).set(set).where({ txSeq: row.txSeq, outputIndex }));
41
+ counts.outputs++;
42
+ let inputs = 0;
43
+ let ledgerUtxos = 0;
44
+ for (const [f, v] of missing) {
45
+ const spent = { spentTxHash: source.hash, spentOutputIndex: outputIndex, [`utxoData_${f}`]: null };
46
+ inputs = Math.max(inputs, Number(await tx.run(UPDATE.entity(cardano_1.TransactionInputs).set({ [`utxoData_${f}`]: v }).where(spent))) || 0);
47
+ const unspent = { txHash: source.hash, outputIndex, [`utxo_${f}`]: null };
48
+ ledgerUtxos = Math.max(ledgerUtxos, Number(await tx.run(UPDATE.entity(cardano_1.LedgerUTxOs).set({ [`utxo_${f}`]: v }).where(unspent))) || 0);
49
+ }
50
+ counts.inputs += inputs;
51
+ counts.ledgerUtxos += ledgerUtxos;
52
+ }
53
+ }
54
+ return counts;
55
+ }
56
+ class OutputDatumBackfillError extends Error {
57
+ constructor(message) {
58
+ super(message);
59
+ this.name = 'OutputDatumBackfillError';
60
+ }
61
+ }
62
+ exports.OutputDatumBackfillError = OutputDatumBackfillError;
63
+ // Reads every transaction again that holds an output with a datum hash and no inline datum, and
64
+ // fills what the backend returns. Pages by primary key only. Backend reads run outside any DB tx.
65
+ async function backfillOutputDatums(opts) {
66
+ if (!opts.client.supports('getTransaction')) {
67
+ throw new OutputDatumBackfillError('No configured backend serves transactions. With Ogmios only, run backfillTransactions over the crawled range.');
68
+ }
69
+ const chunkSize = opts.chunkSize ?? 5000;
70
+ const batchSize = Math.min(opts.batchSize ?? 100, collections_1.IN_CHUNK);
71
+ const progress = { scanned: 0, candidates: 0, transactions: 0, missing: 0, outputs: 0, inputs: 0, ledgerUtxos: 0 };
72
+ let cursor = null;
73
+ for (;;) {
74
+ const after = cursor;
75
+ const rows = (await cds_1.default.tx((tx) => tx.run(SELECT.from(cardano_1.TransactionOutputs).columns('txSeq', 'outputIndex', 'utxo_dataHash', 'utxo_inlineDatum')
76
+ .where(after == null ? {} : { txSeq: { '>': after } }).orderBy('txSeq', 'outputIndex').limit(chunkSize)))) ?? [];
77
+ if (!rows.length)
78
+ break;
79
+ const full = rows.length === chunkSize;
80
+ const lastSeq = Number(rows[rows.length - 1].txSeq);
81
+ // The last transaction of a full page may continue on the next one, so its rows wait there.
82
+ const whole = rows.filter((r) => Number(r.txSeq) !== lastSeq);
83
+ const complete = full && whole.length ? whole : rows;
84
+ const candidates = complete.filter((r) => r.utxo_dataHash != null && r.utxo_inlineDatum == null);
85
+ progress.scanned += complete.length;
86
+ progress.candidates += candidates.length;
87
+ for (const seqs of (0, collections_1.chunk)([...new Set(candidates.map((r) => Number(r.txSeq)))], batchSize)) {
88
+ const stored = (await cds_1.default.tx((tx) => tx.run(SELECT.from(cardano_1.Transactions).columns('hash', 'txSeq').where({ txSeq: { in: seqs } })))) ?? [];
89
+ const fresh = stored.length ? await opts.client.getTransactionsBatch(stored.map((t) => t.hash)) : new Map();
90
+ const sources = stored.flatMap((t) => {
91
+ const read = fresh.get(t.hash);
92
+ return read ? [{ hash: t.hash, txSeq: Number(t.txSeq), outputs: read.outputs ?? [] }] : [];
93
+ });
94
+ progress.transactions += sources.length;
95
+ progress.missing += seqs.length - sources.length;
96
+ const counts = await cds_1.default.tx((tx) => fillOutputFields(tx, sources));
97
+ progress.outputs += counts.outputs;
98
+ progress.inputs += counts.inputs;
99
+ progress.ledgerUtxos += counts.ledgerUtxos;
100
+ }
101
+ cursor = Number(complete[complete.length - 1].txSeq);
102
+ opts.onProgress?.({ ...progress });
103
+ if (!full)
104
+ break;
105
+ }
106
+ logger.info(`output datums: ${progress.outputs} outputs, ${progress.inputs} inputs and ${progress.ledgerUtxos} UTxO set rows filled; ` +
107
+ `${progress.candidates} candidates in ${progress.scanned} outputs, ${progress.transactions} transactions read, ${progress.missing} not returned`);
108
+ return progress;
109
+ }
110
+ //# sourceMappingURL=output-datum-backfill.js.map
@@ -13,6 +13,8 @@ export interface TransactionBackfillProgress {
13
13
  transactions: number;
14
14
  /** Input rows that got at least one field. */
15
15
  inputs: number;
16
+ /** Output rows that got a datum or reference-script field. */
17
+ outputs: number;
16
18
  redeemers: number;
17
19
  datums: number;
18
20
  /** Transactions whose stored rows differed from the ledger view (order, inputs or outputs the ledger did not apply) and were rewritten. */
@@ -10,11 +10,12 @@ const cds_1 = __importDefault(require("@sap/cds"));
10
10
  const mappers_1 = require("../../utils/mappers");
11
11
  const collections_1 = require("../../utils/collections");
12
12
  const certificate_backfill_1 = require("./certificate-backfill");
13
+ const output_datum_backfill_1 = require("./output-datum-backfill");
13
14
  const cardano_1 = require("#cds-models/odatano/cardano");
14
15
  const { SELECT, UPDATE, UPSERT, DELETE } = cds_1.default.ql;
15
16
  const logger = cds_1.default.log('TransactionBackfill');
16
- // Complete crawled transactions from a second chain-sync stream: spent outputs, input fields,
17
- // redeemers and witness datums. Only empty fields are filled. Mismatching transactions stay as they are.
17
+ // Complete crawled transactions from a second chain-sync stream: spent outputs, input and output
18
+ // fields, redeemers and witness datums. Only empty fields are filled. Mismatching transactions stay.
18
19
  class TransactionBackfillError extends Error {
19
20
  constructor(message) {
20
21
  super(message);
@@ -143,18 +144,18 @@ async function writeInputFills(tx, fills) {
143
144
  }
144
145
  // Rewrite one transaction's inputs in ledger order. Rows left out are dropped, empty fields filled.
145
146
  async function rewriteInOrder(tx, seq, ordered, fresh) {
146
- const assets = (await tx.run(SELECT.from(cardano_1.TransactionInputAssets).where({ input_txSeq: seq }))) ?? [];
147
+ const assets = (await tx.run(SELECT.from(cardano_1.TransactionInputAssetCopies).where({ input_txSeq: seq }))) ?? [];
147
148
  const newIndex = new Map(ordered.map((r, i) => [Number(r.inputIndex), i]));
148
149
  const rows = ordered.map((r, i) => ({ ...r, ...missingFields(r, fresh[i]), txSeq: seq, inputIndex: i }));
149
150
  // assets of rows the ledger view drops go with them
150
151
  const movedAssets = assets
151
152
  .filter((a) => newIndex.has(Number(a.input_inputIndex)))
152
153
  .map((a) => ({ ...a, input_txSeq: seq, input_inputIndex: newIndex.get(Number(a.input_inputIndex)) }));
153
- await tx.run(DELETE.from(cardano_1.TransactionInputAssets).where({ input_txSeq: seq }));
154
+ await tx.run(DELETE.from(cardano_1.TransactionInputAssetCopies).where({ input_txSeq: seq }));
154
155
  await tx.run(DELETE.from(cardano_1.TransactionInputs).where({ txSeq: seq }));
155
156
  await tx.run(UPSERT.into(cardano_1.TransactionInputs).entries(rows));
156
157
  if (movedAssets.length)
157
- await tx.run(UPSERT.into(cardano_1.TransactionInputAssets).entries(movedAssets));
158
+ await tx.run(UPSERT.into(cardano_1.TransactionInputAssetCopies).entries(movedAssets));
158
159
  }
159
160
  // Delete outputs the ledger never produced, which some providers list for phase-2 results.
160
161
  // Runs only when every streamed output is stored. Returns the transactions touched.
@@ -180,7 +181,7 @@ async function dropUnappliedOutputs(tx, txs) {
180
181
  }
181
182
  async function backfillTransactions(opts) {
182
183
  const { fromSlot, toSlot, indexer } = opts;
183
- const progress = { atSlot: 0, blocks: 0, transactions: 0, inputs: 0, redeemers: 0, datums: 0, rewritten: 0, skipped: 0 };
184
+ const progress = { atSlot: 0, blocks: 0, transactions: 0, inputs: 0, outputs: 0, redeemers: 0, datums: 0, rewritten: 0, skipped: 0 };
184
185
  let started = false;
185
186
  const intersection = await (0, certificate_backfill_1.streamCrawledBlocks)({ ...opts, errorType: TransactionBackfillError }, (_block, txs) => txs, async (tx, blocks) => {
186
187
  const txs = blocks.flatMap((b) => b.payload);
@@ -188,6 +189,9 @@ async function backfillTransactions(opts) {
188
189
  progress.transactions += txs.length;
189
190
  if (!txs.length)
190
191
  return;
192
+ // outputs first, so the inputs resolved below read the filled rows
193
+ const filled = await (0, output_datum_backfill_1.fillOutputFields)(tx, txs.map((t) => ({ hash: t.hash, txSeq: (0, mappers_1.txSeqOf)(t.slot, t.index), outputs: t.outputs ?? [] })));
194
+ progress.outputs += filled.outputs;
191
195
  // the UTxO set rows answer too: they keep spent outputs, also those from before the crawl
192
196
  await indexer.resolveInputs(tx, txs, { hashes: new Set(), rows: new Map(), assets: new Map() });
193
197
  const seqs = txs.map((t) => (0, mappers_1.txSeqOf)(t.slot, t.index));
@@ -246,7 +250,7 @@ async function backfillTransactions(opts) {
246
250
  await writeInputFills(tx, fills);
247
251
  progress.inputs += fills.length;
248
252
  if (assetRows.length)
249
- await tx.run(UPSERT.into(cardano_1.TransactionInputAssets).entries(assetRows));
253
+ await tx.run(UPSERT.into(cardano_1.TransactionInputAssetCopies).entries(assetRows));
250
254
  for (const r of reorders)
251
255
  await rewriteInOrder(tx, r.seq, r.rows, r.inputs);
252
256
  for (const seq of await dropUnappliedOutputs(tx, txs))
@@ -267,7 +271,7 @@ async function backfillTransactions(opts) {
267
271
  });
268
272
  if (!started)
269
273
  progress.atSlot = intersection === 'origin' ? 0 : intersection.slot;
270
- logger.info(`Transaction backfill ${fromSlot}..${toSlot}: ${progress.blocks} blocks, ${progress.inputs} inputs, ` +
274
+ logger.info(`Transaction backfill ${fromSlot}..${toSlot}: ${progress.blocks} blocks, ${progress.inputs} inputs, ${progress.outputs} outputs, ` +
271
275
  `${progress.redeemers} redeemers, ${progress.datums} datums, ${progress.rewritten} transactions rewritten, ${progress.skipped} skipped`);
272
276
  return { ...progress, fromSlot, toSlot, intersection };
273
277
  }
@@ -0,0 +1,15 @@
1
+ import net from 'node:net';
2
+ /** A stake pool's metadata file is at most this many bytes. */
3
+ export declare const POOL_METADATA_MAX_BYTES = 512;
4
+ /** The four fields of a stake pool's metadata file. */
5
+ export interface PoolMetadata {
6
+ name: string;
7
+ ticker: string;
8
+ homepage: string;
9
+ description: string;
10
+ }
11
+ export declare function validPoolMetadata(value: unknown): PoolMetadata | null;
12
+ export declare function isPublicAddress(address: string): boolean;
13
+ export declare const publicLookup: net.LookupFunction;
14
+ export declare function fetchPoolMetadata(url: string, hash: string): Promise<PoolMetadata | null>;
15
+ //# sourceMappingURL=pool-metadata.d.ts.map
@@ -0,0 +1,132 @@
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.publicLookup = exports.POOL_METADATA_MAX_BYTES = void 0;
7
+ exports.validPoolMetadata = validPoolMetadata;
8
+ exports.isPublicAddress = isPublicAddress;
9
+ exports.fetchPoolMetadata = fetchPoolMetadata;
10
+ const cds_1 = __importDefault(require("@sap/cds"));
11
+ const node_dns_1 = __importDefault(require("node:dns"));
12
+ const node_http_1 = __importDefault(require("node:http"));
13
+ const node_https_1 = __importDefault(require("node:https"));
14
+ const node_net_1 = __importDefault(require("node:net"));
15
+ const node_util_1 = require("node:util");
16
+ const crypto_1 = require("@harmoniclabs/crypto");
17
+ const logger = cds_1.default.log('PoolMetadata');
18
+ /** A stake pool's metadata file is at most this many bytes. */
19
+ exports.POOL_METADATA_MAX_BYTES = 512;
20
+ const MAX_REDIRECTS = 5;
21
+ /** For the whole fetch, redirects included. */
22
+ const FETCH_TIMEOUT_MS = 3_000;
23
+ const chars = (s) => [...s].length;
24
+ // The limits cardano-db-sync applies: name up to 50 characters, description up to 255, ticker 3 to 5.
25
+ // Null when a field is missing, not a string or out of range.
26
+ function validPoolMetadata(value) {
27
+ if (!value || typeof value !== 'object' || Array.isArray(value))
28
+ return null;
29
+ const { name, ticker, homepage, description } = value;
30
+ if (typeof name !== 'string' || typeof ticker !== 'string' || typeof homepage !== 'string' || typeof description !== 'string')
31
+ return null;
32
+ if (chars(name) > 50 || chars(description) > 255 || chars(ticker) < 3 || chars(ticker) > 5)
33
+ return null;
34
+ if (Buffer.byteLength(homepage, 'utf8') > exports.POOL_METADATA_MAX_BYTES)
35
+ return null;
36
+ return { name, ticker, homepage, description };
37
+ }
38
+ // Loopback, private, link-local, carrier-grade NAT, multicast and reserved ranges.
39
+ // A pool registers any URL it likes, so the fetch must not reach hosts behind this server.
40
+ const NON_PUBLIC = new node_net_1.default.BlockList();
41
+ for (const [prefix, bits] of [
42
+ ['0.0.0.0', 8], ['10.0.0.0', 8], ['100.64.0.0', 10], ['127.0.0.0', 8], ['169.254.0.0', 16], ['172.16.0.0', 12],
43
+ ['192.0.0.0', 24], ['192.168.0.0', 16], ['198.18.0.0', 15], ['224.0.0.0', 3],
44
+ ])
45
+ NON_PUBLIC.addSubnet(prefix, bits, 'ipv4');
46
+ for (const [prefix, bits] of [['::', 127], ['64:ff9b::', 96], ['fc00::', 7], ['fe80::', 10], ['ff00::', 8]]) {
47
+ NON_PUBLIC.addSubnet(prefix, bits, 'ipv6');
48
+ }
49
+ function isPublicAddress(address) {
50
+ const family = node_net_1.default.isIP(address);
51
+ return family !== 0 && !NON_PUBLIC.check(address, family === 6 ? 'ipv6' : 'ipv4');
52
+ }
53
+ // DNS lookup that refuses a name with any non-public address. The connection uses the checked
54
+ // addresses, so a second, different DNS answer cannot redirect it.
55
+ const publicLookup = (hostname, options, callback) => {
56
+ node_dns_1.default.lookup(hostname, { ...options, all: true }, (err, addresses) => {
57
+ if (err)
58
+ return callback(err, '', 4);
59
+ if (addresses.length === 0 || addresses.some(a => !isPublicAddress(a.address))) {
60
+ return callback(new Error(`${hostname} resolves to a non-public address`), '', 4);
61
+ }
62
+ if (options.all)
63
+ return callback(null, addresses);
64
+ return callback(null, addresses[0].address, addresses[0].family);
65
+ });
66
+ };
67
+ exports.publicLookup = publicLookup;
68
+ function get(url, signal) {
69
+ return new Promise((resolve, reject) => {
70
+ const transport = url.protocol === 'https:' ? node_https_1.default : node_http_1.default;
71
+ const req = transport.get(url, { lookup: exports.publicLookup, signal, headers: { accept: 'application/json' } }, (res) => {
72
+ const chunks = [];
73
+ let size = 0;
74
+ const done = (body) => resolve({ status: res.statusCode ?? 0, location: res.headers.location, body });
75
+ res.on('data', (chunk) => {
76
+ size += chunk.length;
77
+ if (size > exports.POOL_METADATA_MAX_BYTES) {
78
+ res.destroy();
79
+ done(null);
80
+ }
81
+ else {
82
+ chunks.push(chunk);
83
+ }
84
+ });
85
+ res.on('end', () => done(Buffer.concat(chunks)));
86
+ res.on('error', reject);
87
+ });
88
+ req.on('error', reject);
89
+ });
90
+ }
91
+ /** The file behind `url`, following redirects; every hop must be http(s) on a public host. */
92
+ async function download(url) {
93
+ const signal = AbortSignal.timeout(FETCH_TIMEOUT_MS);
94
+ let next = new URL(url);
95
+ for (let hop = 0; hop <= MAX_REDIRECTS; hop++) {
96
+ if (next.protocol !== 'http:' && next.protocol !== 'https:')
97
+ throw new Error(`unsupported protocol ${next.protocol}`);
98
+ // an address literal never reaches the DNS lookup
99
+ const host = next.hostname.replace(/^\[|\]$/g, '');
100
+ if (node_net_1.default.isIP(host) && !isPublicAddress(host))
101
+ throw new Error(`${host} is not a public address`);
102
+ const reply = await get(next, signal);
103
+ if ([301, 302, 303, 307, 308].includes(reply.status) && reply.location) {
104
+ next = new URL(reply.location, next);
105
+ continue;
106
+ }
107
+ if (reply.status !== 200)
108
+ throw new Error(`HTTP ${reply.status}`);
109
+ if (!reply.body)
110
+ throw new Error(`more than ${exports.POOL_METADATA_MAX_BYTES} bytes`);
111
+ return reply.body;
112
+ }
113
+ throw new Error(`more than ${MAX_REDIRECTS} redirects`);
114
+ }
115
+ // Loads a pool's metadata file and returns its fields when the bytes hash to `hash` (blake2b-256,
116
+ // as registered on chain). Null for any failure; never throws.
117
+ async function fetchPoolMetadata(url, hash) {
118
+ try {
119
+ const bytes = await download(url);
120
+ if (Buffer.from((0, crypto_1.blake2b_256)(bytes)).toString('hex') !== hash.toLowerCase())
121
+ throw new Error('hash mismatch');
122
+ const metadata = validPoolMetadata(JSON.parse(new node_util_1.TextDecoder('utf-8', { fatal: true }).decode(bytes)));
123
+ if (!metadata)
124
+ throw new Error('not a valid pool metadata file');
125
+ return metadata;
126
+ }
127
+ catch (err) {
128
+ logger.debug(`Pool metadata ${url} not used: ${err instanceof Error ? err.message : String(err)}`);
129
+ return null;
130
+ }
131
+ }
132
+ //# sourceMappingURL=pool-metadata.js.map
@@ -9,8 +9,10 @@ export interface CoseVerifyResult {
9
9
  valid: boolean;
10
10
  /** failure detail when !valid; empty string when valid */
11
11
  reason: string;
12
- /** UTF-8 of the signed payload, echoed back for the caller to inspect */
12
+ /** The signed message as text. Empty when the payload is not UTF-8, or hashed and not matched. */
13
13
  signedPayload: string;
14
+ /** hex; the payload bytes as signed (the blake2b-224 of the message when the wallet hashed it) */
15
+ signedPayloadHex: string;
14
16
  /** hex blake2b-224 of the signer public key (empty until the key is parsed) */
15
17
  signerVkh: string;
16
18
  }