@odatano/core 2.0.0-rc.3 → 2.0.0-rc.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@cds-models/CardanoAgentService/index.d.ts +251 -0
- package/@cds-models/CardanoAgentService/index.js +36 -0
- package/@cds-models/CardanoBackendService/index.d.ts +357 -0
- package/@cds-models/CardanoBackendService/index.js +40 -0
- package/@cds-models/CardanoIndexerService/index.d.ts +194 -2
- package/@cds-models/CardanoIndexerService/index.js +25 -0
- package/@cds-models/CardanoODataService/index.d.ts +294 -7
- package/@cds-models/CardanoODataService/index.js +33 -0
- package/@cds-models/CardanoSignService/index.d.ts +28 -3
- package/@cds-models/CardanoSignService/index.js +3 -0
- package/@cds-models/CardanoTransactionService/index.d.ts +52 -19
- 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 +408 -7
- package/@cds-models/odatano/cardano/index.js +42 -0
- package/README.md +64 -5
- package/db/schema.cds +677 -13
- package/db/types.cds +27 -0
- package/package.json +182 -173
- package/scripts/migrate-slot-leader.mjs +104 -0
- package/scripts/migrate-txseq.mjs +147 -0
- package/src/index.d.ts +11 -10
- package/src/index.js +28 -14
- package/src/plugin.js +39 -52
- package/srv/blockchain/backends/blockfrost-backend.d.ts +29 -131
- package/srv/blockchain/backends/blockfrost-backend.js +49 -160
- package/srv/blockchain/backends/cardano-backend.d.ts +104 -158
- package/srv/blockchain/backends/cardano-backend.js +19 -5
- package/srv/blockchain/backends/koios-backend.d.ts +126 -60
- package/srv/blockchain/backends/koios-backend.js +356 -217
- package/srv/blockchain/backends/odatano-backend.d.ts +64 -0
- package/srv/blockchain/backends/odatano-backend.js +170 -0
- package/srv/blockchain/backends/ogmios-backend.d.ts +162 -94
- package/srv/blockchain/backends/ogmios-backend.js +548 -197
- package/srv/blockchain/backends/ogmios-frame-guard.d.ts +32 -0
- package/srv/blockchain/backends/ogmios-frame-guard.js +142 -0
- package/srv/blockchain/cardano-client.d.ts +78 -205
- package/srv/blockchain/cardano-client.js +186 -242
- package/srv/blockchain/cardano-indexer.d.ts +302 -242
- package/srv/blockchain/cardano-indexer.js +1191 -362
- package/srv/blockchain/cardano-tx-builder.d.ts +43 -81
- package/srv/blockchain/cardano-tx-builder.js +177 -132
- package/srv/blockchain/crawler/certificate-backfill.d.ts +67 -0
- package/srv/blockchain/crawler/certificate-backfill.js +169 -0
- package/srv/blockchain/crawler/crawler.d.ts +139 -54
- package/srv/blockchain/crawler/crawler.js +478 -96
- package/srv/blockchain/crawler/hooks.d.ts +3 -14
- package/srv/blockchain/crawler/index.d.ts +5 -0
- package/srv/blockchain/crawler/index.js +35 -7
- package/srv/blockchain/crawler/sync-state.d.ts +46 -28
- package/srv/blockchain/crawler/sync-state.js +128 -43
- package/srv/blockchain/crawler/transaction-backfill.d.ts +52 -0
- package/srv/blockchain/crawler/transaction-backfill.js +283 -0
- package/srv/blockchain/crawler/utxo-set-import.d.ts +78 -0
- package/srv/blockchain/crawler/utxo-set-import.js +363 -0
- package/srv/blockchain/ledger-state.d.ts +101 -0
- package/srv/blockchain/ledger-state.js +432 -0
- package/srv/blockchain/pending-spends.d.ts +28 -0
- package/srv/blockchain/pending-spends.js +89 -0
- package/srv/blockchain/signing/cose-verifier.d.ts +5 -12
- package/srv/blockchain/signing/cose-verifier.js +6 -12
- package/srv/blockchain/signing/external-signer.d.ts +16 -113
- package/srv/blockchain/signing/external-signer.js +19 -122
- package/srv/blockchain/signing/hsm-signer.d.ts +13 -45
- package/srv/blockchain/signing/hsm-signer.js +23 -63
- package/srv/blockchain/signing/signature-verifier.d.ts +8 -44
- package/srv/blockchain/signing/signature-verifier.js +13 -54
- package/srv/blockchain/signing/submission-finalizer.d.ts +9 -36
- package/srv/blockchain/signing/submission-finalizer.js +16 -49
- package/srv/blockchain/stored-chain.d.ts +33 -0
- package/srv/blockchain/stored-chain.js +234 -0
- package/srv/blockchain/transaction-building/buildooor-tx.d.ts +108 -160
- package/srv/blockchain/transaction-building/buildooor-tx.js +620 -285
- package/srv/blockchain/transaction-building/caller-datums.d.ts +17 -0
- package/srv/blockchain/transaction-building/caller-datums.js +50 -0
- package/srv/blockchain/transaction-building/cardano-tx.d.ts +10 -35
- package/srv/blockchain/transaction-rows.d.ts +12 -0
- package/srv/blockchain/transaction-rows.js +43 -0
- package/srv/blockchain/wallet-worker/build-request.d.ts +4 -17
- package/srv/blockchain/wallet-worker/build-request.js +48 -24
- package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +25 -17
- package/srv/blockchain/wallet-worker/confirmation-tracker.js +87 -41
- package/srv/blockchain/wallet-worker/index.js +2 -8
- package/srv/blockchain/wallet-worker/job-store.d.ts +36 -103
- package/srv/blockchain/wallet-worker/job-store.js +0 -0
- package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +4 -20
- package/srv/blockchain/wallet-worker/lease-heartbeat.js +4 -20
- package/srv/blockchain/wallet-worker/signers.d.ts +6 -19
- package/srv/blockchain/wallet-worker/signers.js +3 -8
- package/srv/blockchain/wallet-worker/wallet-worker.d.ts +15 -71
- package/srv/blockchain/wallet-worker/wallet-worker.js +40 -91
- package/srv/cardano-agent-service.cds +146 -0
- package/srv/cardano-agent-service.d.ts +2 -0
- package/srv/cardano-agent-service.js +12 -0
- package/srv/cardano-backend-service.cds +52 -0
- package/srv/cardano-backend-service.d.ts +2 -0
- package/srv/cardano-backend-service.js +244 -0
- package/srv/cardano-indexer-service.cds +201 -73
- package/srv/cardano-indexer-service.js +280 -11
- package/srv/cardano-service.cds +56 -1
- package/srv/cardano-service.js +52 -113
- package/srv/cardano-sign-service.cds +200 -180
- package/srv/cardano-sign-service.js +55 -173
- package/srv/cardano-tx-service.cds +439 -364
- package/srv/cardano-tx-service.js +305 -209
- package/srv/cardano-ui.cds +16 -16
- package/srv/cardano-worker-service.js +7 -15
- package/srv/cbor/parse.js +13 -1
- package/srv/server.d.ts +28 -86
- package/srv/server.js +127 -135
- package/srv/utils/agent-grants-config.d.ts +37 -0
- package/srv/utils/agent-grants-config.js +138 -0
- package/srv/utils/agent-grants.d.ts +262 -0
- package/srv/utils/agent-grants.js +922 -0
- package/srv/utils/agent-token-auth.d.ts +16 -0
- package/srv/utils/agent-token-auth.js +78 -0
- package/srv/utils/backend-request-handler.d.ts +2 -16
- package/srv/utils/backend-request-handler.js +3 -18
- package/srv/utils/collections.d.ts +4 -8
- package/srv/utils/collections.js +4 -8
- package/srv/utils/const.d.ts +30 -67
- package/srv/utils/const.js +32 -72
- package/srv/utils/crypto.d.ts +3 -12
- package/srv/utils/crypto.js +5 -18
- package/srv/utils/db-indexes.d.ts +25 -0
- package/srv/utils/db-indexes.js +94 -0
- package/srv/utils/db-sanitize.d.ts +27 -0
- package/srv/utils/db-sanitize.js +85 -0
- package/srv/utils/epoch-slots.d.ts +13 -0
- package/srv/utils/epoch-slots.js +25 -0
- package/srv/utils/error-codes.d.ts +20 -73
- package/srv/utils/error-codes.js +19 -70
- package/srv/utils/errors.d.ts +50 -177
- package/srv/utils/errors.js +94 -218
- package/srv/utils/liveness.d.ts +16 -0
- package/srv/utils/liveness.js +40 -0
- package/srv/utils/mappers.d.ts +128 -214
- package/srv/utils/mappers.js +354 -299
- package/srv/utils/network-context.js +2 -11
- package/srv/utils/pg-inline-json.d.ts +8 -0
- package/srv/utils/pg-inline-json.js +62 -0
- package/srv/utils/pg-order-nulls.d.ts +14 -0
- package/srv/utils/pg-order-nulls.js +56 -0
- package/srv/utils/plutus-placeholders.d.ts +23 -16
- package/srv/utils/plutus-placeholders.js +63 -27
- package/srv/utils/rate-limiter.d.ts +46 -0
- package/srv/utils/rate-limiter.js +116 -0
- package/srv/utils/service-events.d.ts +2 -22
- package/srv/utils/service-events.js +3 -23
- package/srv/utils/signing-helper.d.ts +3 -18
- package/srv/utils/signing-helper.js +10 -32
- package/srv/utils/tx-build-helper.d.ts +26 -92
- package/srv/utils/tx-build-helper.js +68 -123
- package/srv/utils/tx-request-parsers.d.ts +107 -21
- package/srv/utils/tx-request-parsers.js +433 -34
- package/srv/utils/tx-utils.d.ts +4 -23
- package/srv/utils/tx-utils.js +12 -41
- package/srv/utils/types.d.ts +238 -169
- package/srv/utils/types.js +2 -6
- package/srv/utils/validators.d.ts +24 -90
- package/srv/utils/validators.js +50 -147
package/srv/utils/mappers.d.ts
CHANGED
|
@@ -1,260 +1,174 @@
|
|
|
1
|
-
import { Transaction as TransactionProviderData, Address as AddressProviderData, UTxO as UtxosProviderData, TxInputLine as TxInputProviderData, TxOutputLine as TxOutputProviderData, Amount as AmountProviderData, NetworkInformation as NetworkInfoProviderData, BlockData as BlockProviderData, EpochData as EpochProviderData, MetadataLabelTx as MetadataLabelTxProviderData, PoolData as PoolProviderData, DrepData as DrepProviderData, AccountData as AccountProviderData, AssetInfo as AssetInfoProviderData, AssetHistoryEntry as AssetHistoryEntryProviderData, TxBuildResult as TransactionBuildResult, LedgerProtocolParameters as ProtocolParameters } from './types';
|
|
2
|
-
import { Address as AddressRow, AddressAsset as AddressAssetRow, AddressUTxO as AddressUTxORow, UTxOAsset as UTxOAssetRow, Transaction as TransactionRow, TransactionInput as TransactionInputRow, TransactionInputAsset as TransactionInputAssetRow, TransactionOutput as TransactionOutputRow, TransactionOutputAsset as TransactionOutputAssetRow, NetworkInformation as NetworkInfoRow, TransactionMetadata as TransactionMetadataRow, Block as BlockRow, Epoch as EpochRow, Pool as PoolRow, Drep as DrepRow, Asset as AssetRow, AssetHistory as AssetHistoryRow, Account as AccountRow, LedgerProtocolParameter as ProtocolParameterRow, AddressTransaction as AddressTransactionRow } from '#cds-models/CardanoODataService';
|
|
1
|
+
import { Transaction as TransactionProviderData, Address as AddressProviderData, UTxO as UtxosProviderData, TxInputLine as TxInputProviderData, TxOutputLine as TxOutputProviderData, TxCertificate as TxCertificateProviderData, TxWithdrawal as TxWithdrawalProviderData, TxRedeemer as TxRedeemerProviderData, Amount as AmountProviderData, NetworkInformation as NetworkInfoProviderData, BlockData as BlockProviderData, EpochData as EpochProviderData, MetadataLabelTx as MetadataLabelTxProviderData, PoolData as PoolProviderData, DrepData as DrepProviderData, AccountData as AccountProviderData, AssetInfo as AssetInfoProviderData, AssetHistoryEntry as AssetHistoryEntryProviderData, TxBuildResult as TransactionBuildResult, LedgerProtocolParameters as ProtocolParameters } from './types';
|
|
2
|
+
import { Address as AddressRow, AddressAsset as AddressAssetRow, AddressUTxO as AddressUTxORow, UTxOAsset as UTxOAssetRow, Transaction as TransactionRow, TransactionInput as TransactionInputRow, TransactionInputAsset as TransactionInputAssetRow, TransactionOutput as TransactionOutputRow, TransactionOutputAsset as TransactionOutputAssetRow, TransactionCertificate as TransactionCertificateRow, TransactionWithdrawal as TransactionWithdrawalRow, TransactionRedeemer as TransactionRedeemerRow, NetworkInformation as NetworkInfoRow, TransactionMetadata as TransactionMetadataRow, Block as BlockRow, Epoch as EpochRow, Pool as PoolRow, Drep as DrepRow, PoolEpochSnapshot as PoolEpochSnapshotRow, DrepEpochSnapshot as DrepEpochSnapshotRow, Asset as AssetRow, AssetHistory as AssetHistoryRow, Account as AccountRow, LedgerProtocolParameter as ProtocolParameterRow, AddressTransaction as AddressTransactionRow } from '#cds-models/CardanoODataService';
|
|
3
3
|
import type { TransactionBuild as TransactionBuildRow, TransactionBuildInput as TransactionBuildInputRow, TransactionBuildOutput as TransactionBuildOutputRow, TransactionSubmission as TransactionSubmissionRow, AddressTransactionBuild as AddressTransactionBuildRow } from '#cds-models/CardanoTransactionService';
|
|
4
4
|
import type { AddressSigningRequest as AddressSigningRequestRow } from '#cds-models/CardanoSignService';
|
|
5
5
|
import type { Request } from '@sap/cds';
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Map Transaction Data
|
|
11
|
-
* Converts provider transaction data into TransactionRow format
|
|
12
|
-
* @param providerTx
|
|
13
|
-
* @returns {TransactionRow} mapped transaction row
|
|
14
|
-
*/
|
|
6
|
+
/** Key of a transaction's input/output rows: chain position, ascending, below 2^53 for any real slot. */
|
|
7
|
+
export declare const TX_SEQ_SLOT_FACTOR = 65536;
|
|
8
|
+
export declare function txSeqOf(slot: number, txIndex: number): number;
|
|
9
|
+
/** Provider transaction to TransactionRow. */
|
|
15
10
|
export declare function mapTransaction(providerTx: TransactionProviderData): TransactionRow;
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*/
|
|
23
|
-
export declare function
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
*
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
*/
|
|
47
|
-
export declare function
|
|
48
|
-
/**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
* @param address address string
|
|
52
|
-
* @param addressData address data from provider
|
|
53
|
-
* @returns {AddressRow} mapped address row
|
|
54
|
-
*/
|
|
11
|
+
/** Provider transaction inputs to TransactionInputRows, keyed by position in the tx. */
|
|
12
|
+
export declare function mapTransactionInputs(txSeq: number, txInputs: TxInputProviderData[]): TransactionInputRow[];
|
|
13
|
+
/** Provider transaction input assets to TransactionInputAssetRows. */
|
|
14
|
+
export declare function mapTransactionInputAssets(txSeq: number, inputs: TxInputProviderData[]): TransactionInputAssetRow[];
|
|
15
|
+
/** Normalized certificates to TransactionCertificateRows, one per (certIndex, kind). */
|
|
16
|
+
export declare function mapTransactionCertificates(txHash: string, certificates: TxCertificateProviderData[]): TransactionCertificateRow[];
|
|
17
|
+
/** Normalized withdrawals to TransactionWithdrawalRows, one per reward account. */
|
|
18
|
+
export declare function mapTransactionWithdrawals(txHash: string, withdrawals: TxWithdrawalProviderData[]): TransactionWithdrawalRow[];
|
|
19
|
+
/** Ledger order of output references: transaction hash bytewise, then output index. */
|
|
20
|
+
export declare function compareOutRef(a: {
|
|
21
|
+
txHash: string;
|
|
22
|
+
outputIndex: number;
|
|
23
|
+
}, b: {
|
|
24
|
+
txHash: string;
|
|
25
|
+
outputIndex: number;
|
|
26
|
+
}): number;
|
|
27
|
+
/**
|
|
28
|
+
* Inputs of a transaction in the order chain-sync reports them: regular, collateral, reference,
|
|
29
|
+
* each sorted like the ledger's input sets. `inputIndex` and spend-redeemer indices rely on it.
|
|
30
|
+
*/
|
|
31
|
+
export declare function ledgerInputOrder(inputs: TxInputProviderData[]): TxInputProviderData[];
|
|
32
|
+
/**
|
|
33
|
+
* The transaction as the ledger applied it, the same for every source: inputs in ledger order;
|
|
34
|
+
* after a phase-2 failure only collateral and reference inputs, the collateral return as the only
|
|
35
|
+
* output and no mint; otherwise no collateral return (never produced). Unknown validity
|
|
36
|
+
* (`spendsCollaterals` undefined) keeps what the source reported.
|
|
37
|
+
*/
|
|
38
|
+
export declare function ledgerView<T extends TransactionProviderData>(tx: T): T;
|
|
39
|
+
/** Normalized redeemers to TransactionRedeemerRows, keyed (tx, purpose, index). */
|
|
40
|
+
export declare function mapTransactionRedeemers(txHash: string, redeemers: TxRedeemerProviderData[]): TransactionRedeemerRow[];
|
|
41
|
+
/** Provider transaction outputs to TransactionOutputRows. */
|
|
42
|
+
export declare function mapTransactionOutputs(txSeq: number, txOutputs: TxOutputProviderData[]): TransactionOutputRow[];
|
|
43
|
+
/** Provider transaction output assets to TransactionOutputAssetRows. */
|
|
44
|
+
export declare function mapTransactionOutputAssets(txSeq: number, outputs: TxOutputProviderData[]): TransactionOutputAssetRow[];
|
|
45
|
+
/** Provider address to a temporal AddressRow valid for `maxAge` ms. */
|
|
55
46
|
export declare function mapAddress(address: string, addressData: AddressProviderData, maxAge: number): AddressRow;
|
|
56
|
-
/**
|
|
57
|
-
* Map Address Transactions
|
|
58
|
-
* Converts provider address transaction data into AddressTransactionRow format
|
|
59
|
-
* @param addr address string
|
|
60
|
-
* @param addressTxsData address transactions data from provider
|
|
61
|
-
* @returns {AddressTransactionRow[]} mapped address transaction rows
|
|
62
|
-
* */
|
|
47
|
+
/** Provider transactions to AddressTransactionRows with the address's net amounts; non-temporal. */
|
|
63
48
|
export declare function mapAddressTransactions(addr: string, addressTxsData: TransactionProviderData[]): AddressTransactionRow[];
|
|
64
|
-
/**
|
|
65
|
-
* Map Address UTxOs
|
|
66
|
-
* @param addr address string
|
|
67
|
-
* @param validFrom validFrom
|
|
68
|
-
* @param validTo validTo
|
|
69
|
-
* @param addressUtxosData address UTxOs data from provider
|
|
70
|
-
* @returns {AddressUTxORow[]} mapped address UTxO rows
|
|
71
|
-
*/
|
|
49
|
+
/** Provider UTxOs to temporal AddressUTxORows. */
|
|
72
50
|
export declare function mapAddressUtxos(addr: string, validFrom: string, validTo: string, addressUtxosData: UtxosProviderData[]): AddressUTxORow[];
|
|
73
|
-
/**
|
|
74
|
-
* Map Address Assets
|
|
75
|
-
* Converts provider address asset data into AddressAssetRow format
|
|
76
|
-
* @param addr address string
|
|
77
|
-
* @param validFrom validFrom
|
|
78
|
-
* @param validTo validTo
|
|
79
|
-
* @param AssetAssets address assets from provider
|
|
80
|
-
* @returns {AddressAssetRow[]} mapped address asset rows
|
|
81
|
-
*/
|
|
51
|
+
/** Provider address amounts (without lovelace) to temporal AddressAssetRows. */
|
|
82
52
|
export declare function mapAddressAssets(addr: string, validFrom: string, validTo: string, AssetAssets: AmountProviderData[]): AddressAssetRow[];
|
|
83
|
-
/**
|
|
84
|
-
* Map UTxO Assets
|
|
85
|
-
* Converts provider address UTxO asset data into UTxOAssetRow format
|
|
86
|
-
* @param addressUtxosData address UTxOs data from provider
|
|
87
|
-
* @param validFrom validFrom
|
|
88
|
-
* @param validTo validTo
|
|
89
|
-
* @returns {UTxOAssetRow[]} mapped UTxO asset rows
|
|
90
|
-
*/
|
|
53
|
+
/** Native assets of provider UTxOs to temporal UTxOAssetRows. */
|
|
91
54
|
export declare function mapAddressUtxoAssets(addressUtxosData: UtxosProviderData[], validFrom: string, validTo: string): UTxOAssetRow[];
|
|
92
|
-
/**
|
|
93
|
-
* Map Network Information
|
|
94
|
-
* Converts provider network information data into NetworkInfoRow format
|
|
95
|
-
* @param providerNetworkData
|
|
96
|
-
* @returns {NetworkInfoRow} mapped network information row
|
|
97
|
-
*/
|
|
55
|
+
/** Provider network information to a temporal NetworkInfoRow. */
|
|
98
56
|
export declare function mapNetworkInfo(providerNetworkData: NetworkInfoProviderData, max_age: number, network: string): NetworkInfoRow;
|
|
99
|
-
/**
|
|
100
|
-
* Map Block Data
|
|
101
|
-
* Converts provider block data into BlockRow format
|
|
102
|
-
* @param providerBlockData block data from provider
|
|
103
|
-
* @param epochData epoch data for the block's epoch
|
|
104
|
-
* @returns {BlockRow} mapped block row
|
|
105
|
-
*/
|
|
57
|
+
/** Provider block to BlockRow. */
|
|
106
58
|
export declare function mapBlock(providerBlockData: BlockProviderData, epochData?: EpochRow): BlockRow;
|
|
107
|
-
/**
|
|
108
|
-
* Map Epoch Data
|
|
109
|
-
* Converts provider epoch data into EpochRow format
|
|
110
|
-
* @param providerEpochData epoch data from provider
|
|
111
|
-
* @returns {EpochRow} mapped epoch row
|
|
112
|
-
*/
|
|
59
|
+
/** Provider epoch to EpochRow. */
|
|
113
60
|
export declare function mapEpoch(providerEpochData: EpochProviderData): EpochRow;
|
|
114
|
-
/**
|
|
115
|
-
* Map Transaction Metadata
|
|
116
|
-
* Converts provider transaction metadata labels into TransactionMetadataRow format
|
|
117
|
-
* @param providerLabels array of metadata label data from provider
|
|
118
|
-
* @returns {TransactionMetadataRow[]} mapped transaction metadata rows
|
|
119
|
-
*/
|
|
61
|
+
/** Provider metadata labels to TransactionMetadataRows; non-uint64 labels are skipped. */
|
|
120
62
|
export declare function mapTransactionMetadata(providerLabels: MetadataLabelTxProviderData[]): TransactionMetadataRow[];
|
|
121
63
|
/**
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
* @
|
|
125
|
-
|
|
126
|
-
|
|
64
|
+
* uint64 metadata label to the int64 `TransactionMetadata.id` key: labels >= 2^63 wrap via two's complement,
|
|
65
|
+
* values beyond 2^53 are passed as a decimal string (CAP accepts strings for Integer64).
|
|
66
|
+
* @returns the key, or null when the label is not a non-negative integer
|
|
67
|
+
*/
|
|
68
|
+
export declare function metadataIdFor(label: string | number): number | string | null;
|
|
69
|
+
/** Where an epoch snapshot came from; `hash` is the block the ledger state was read at (Ogmios only). */
|
|
70
|
+
export interface SnapshotOrigin {
|
|
71
|
+
source: 'ogmios' | 'koios';
|
|
72
|
+
hash?: string | null;
|
|
73
|
+
}
|
|
74
|
+
/** Pool observation at an epoch boundary to a non-temporal PoolEpochSnapshotRow dated by (epoch, snapshotSlot). */
|
|
75
|
+
export declare function mapPoolSnapshot(providerPoolData: PoolProviderData, epoch: number, at: {
|
|
76
|
+
slot: number;
|
|
77
|
+
time: number;
|
|
78
|
+
}, origin?: SnapshotOrigin): PoolEpochSnapshotRow;
|
|
79
|
+
/** DRep observation at an epoch boundary to a non-temporal DrepEpochSnapshotRow. */
|
|
80
|
+
export declare function mapDrepSnapshot(providerDrepData: DrepProviderData, epoch: number, at: {
|
|
81
|
+
slot: number;
|
|
82
|
+
time: number;
|
|
83
|
+
}, origin?: SnapshotOrigin): DrepEpochSnapshotRow;
|
|
84
|
+
/** Provider pool to a temporal PoolRow valid for `max_age` ms. */
|
|
127
85
|
export declare function mapPool(providerPoolData: PoolProviderData, max_age: number): PoolRow;
|
|
128
|
-
/**
|
|
129
|
-
* Map Asset Info Data
|
|
130
|
-
* Converts provider asset info into AssetRow format. Provider data is already
|
|
131
|
-
* normalized by the backend mapper into the canonical AssetInfo shape, so this
|
|
132
|
-
* function just stamps temporal validity and JSON-stringifies the on-chain metadata.
|
|
133
|
-
* @param providerAssetInfo canonical asset info from backend
|
|
134
|
-
* @param max_age TTL window in ms for the temporal validity
|
|
135
|
-
* @returns {AssetRow} mapped asset row
|
|
136
|
-
*/
|
|
86
|
+
/** Canonical asset info to a temporal AssetRow valid for `max_age` ms; on-chain metadata is JSON-stringified. */
|
|
137
87
|
export declare function mapAsset(providerAssetInfo: AssetInfoProviderData, max_age: number): AssetRow;
|
|
138
88
|
/**
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
* @param entries asset history events from backend (already canonical)
|
|
142
|
-
* @returns {AssetHistoryRow[]} mapped rows
|
|
89
|
+
* Fixed validity stamp for a crawler-written bare `Assets` row: epoch zero, so the row is born expired
|
|
90
|
+
* (hidden by CAP's temporal filter) and its `(validFrom, unit)` key never collides with a mapAsset() slice.
|
|
143
91
|
*/
|
|
144
|
-
export declare
|
|
92
|
+
export declare const BARE_ASSET_STAMP = "1970-01-01T00:00:00.000Z";
|
|
145
93
|
/**
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
* @returns
|
|
94
|
+
* Bare AssetRow from the unit alone (policyId, assetNameHex, decoded name, CIP-14 fingerprint), no provider call.
|
|
95
|
+
* Stamped `validTo === validFrom` with the fixed sentinel: hidden from OData reads, so the first keyed read
|
|
96
|
+
* still misses and the lazy path enriches it; one idempotent row per unit inside the crawler's block tx.
|
|
97
|
+
* @returns the row, or null when the unit is not a native asset unit
|
|
150
98
|
*/
|
|
99
|
+
export declare function mapBareAsset(unit: string): AssetRow | null;
|
|
100
|
+
/** Asset history events to non-temporal AssetHistoryRows (immutable, keyed on unit + txHash). */
|
|
101
|
+
export declare function mapAssetHistory(entries: AssetHistoryEntryProviderData[]): AssetHistoryRow[];
|
|
102
|
+
/** Provider DRep to a temporal DrepRow valid for `max_age` ms. */
|
|
151
103
|
export declare function mapDrep(providerDrepData: DrepProviderData, max_age: number): DrepRow;
|
|
152
|
-
/**
|
|
153
|
-
* Map Account Data
|
|
154
|
-
* Converts provider account data into AccountRow format
|
|
155
|
-
* @param providerAccountData account data from provider
|
|
156
|
-
* @returns {AccountRow} mapped account row
|
|
157
|
-
*/
|
|
104
|
+
/** Provider account to a temporal AccountRow valid for `max_age` ms. */
|
|
158
105
|
export declare function mapAccount(providerAccountData: AccountProviderData, max_age: number): AccountRow;
|
|
159
|
-
/**
|
|
160
|
-
* Map Backend Error
|
|
161
|
-
* Converts BackendError or unknown error into OData request rejection
|
|
162
|
-
* @param req OData request
|
|
163
|
-
* @param err error object (BackendError or unknown)
|
|
164
|
-
* @param ctx context string for error message
|
|
165
|
-
*/
|
|
106
|
+
/** Rejects the OData request for a BackendError; unknown errors are logged and answered as a sanitized 500. */
|
|
166
107
|
export declare function mapError(req: Request, err: unknown, ctx: string): never;
|
|
167
|
-
/**
|
|
168
|
-
* Map Transaction Build Result
|
|
169
|
-
* Converts provider transaction build result into TransactionBuildRow format
|
|
170
|
-
* @param txbuildResult transaction build result from provider
|
|
171
|
-
* @returns {TransactionBuildRow} mapped transaction build row
|
|
172
|
-
*/
|
|
108
|
+
/** Build result to a temporal TransactionBuildRow with a fresh build id. */
|
|
173
109
|
export declare function mapBuildResult(txbuildResult: TransactionBuildResult, max_age: number): TransactionBuildRow;
|
|
174
|
-
/**
|
|
175
|
-
* Map Transaction Build Inputs
|
|
176
|
-
* Converts transaction build result inputs into TransactionBuildInputRow format
|
|
177
|
-
* @param buildId the transaction build ID
|
|
178
|
-
* @param inputs transaction build result inputs
|
|
179
|
-
* @returns {TransactionBuildInputRow[]} mapped transaction build input rows
|
|
180
|
-
*/
|
|
110
|
+
/** Build result inputs to TransactionBuildInputRows. */
|
|
181
111
|
export declare function mapBuildInputs(buildId: string, inputs: Array<{
|
|
182
112
|
txHash: string;
|
|
183
113
|
index: number;
|
|
184
114
|
lovelace: string;
|
|
185
115
|
address?: string;
|
|
186
116
|
}>): TransactionBuildInputRow[];
|
|
187
|
-
/**
|
|
188
|
-
* Map Transaction Build Outputs
|
|
189
|
-
* Converts transaction build result outputs into TransactionBuildOutputRow format
|
|
190
|
-
* @param buildId the transaction build ID
|
|
191
|
-
* @param outputs transaction build result outputs
|
|
192
|
-
* @param changeAddress the change address to identify change outputs
|
|
193
|
-
* @returns {TransactionBuildOutputRow[]} mapped transaction build output rows
|
|
194
|
-
*/
|
|
117
|
+
/** Build result outputs to TransactionBuildOutputRows; `changeAddress` marks the change output. */
|
|
195
118
|
export declare function mapBuildOutputs(buildId: string, outputs: Array<{
|
|
196
119
|
address: string;
|
|
197
120
|
lovelace: string;
|
|
198
121
|
}>, changeAddress?: string): TransactionBuildOutputRow[];
|
|
199
|
-
/**
|
|
200
|
-
* Map Protocol Parameters
|
|
201
|
-
* Converts provider protocol parameters into ProtocolParameterRow format
|
|
202
|
-
* @param providerParams protocol parameters from provider
|
|
203
|
-
* @returns {ProtocolParameterRow} mapped protocol parameter row
|
|
204
|
-
*/
|
|
122
|
+
/** Provider protocol parameters to ProtocolParameterRow. */
|
|
205
123
|
export declare function mapProtocolParameters(providerParams: ProtocolParameters): ProtocolParameterRow;
|
|
206
|
-
/**
|
|
207
|
-
* Map Transaction Submission
|
|
208
|
-
* Converts signed transaction CBOR and hash into TransactionSubmissionRow format
|
|
209
|
-
* @param signedTxCbor signed transaction in CBOR hex format
|
|
210
|
-
* @param txHash transaction hash
|
|
211
|
-
* @returns {TransactionSubmissionRow} mapped transaction submission row
|
|
212
|
-
*/
|
|
124
|
+
/** Signed tx CBOR and hash to a TransactionSubmissionRow stamped now (epoch seconds). */
|
|
213
125
|
export declare function mapTransactionSubmission(signedTxCbor: string, txHash: string): TransactionSubmissionRow;
|
|
214
|
-
/**
|
|
215
|
-
* Map Address Signing Requests
|
|
216
|
-
* Creates AddressSigningRequest row for address-signing request association
|
|
217
|
-
* @param addr bech32 address
|
|
218
|
-
* @param signingRequestId signing request UUID
|
|
219
|
-
* @returns {AddressSigningRequestRow} mapped address signing request row
|
|
220
|
-
*/
|
|
126
|
+
/** Address to signing-request association row. */
|
|
221
127
|
export declare function mapAddressSigningRequest(addr: string, signingRequestId: string): AddressSigningRequestRow;
|
|
222
|
-
/**
|
|
223
|
-
* Map Address Transaction Builds
|
|
224
|
-
* Creates AddressTransactionBuild row for address-build association
|
|
225
|
-
* @param addr bech32 address
|
|
226
|
-
* @param buildId transaction build UUID
|
|
227
|
-
* @returns {AddressTransactionBuildRow} mapped address transaction build row
|
|
228
|
-
*/
|
|
128
|
+
/** Address to transaction-build association row. */
|
|
229
129
|
export declare function mapAddressTransactionBuild(addr: string, buildId: string): AddressTransactionBuildRow;
|
|
230
130
|
/**
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
* Blockfrost's cost_models (named keys) has known key-value mapping bugs for
|
|
234
|
-
* PlutusV3 (shifted values in the quotientInteger/remainderInteger region).
|
|
235
|
-
* The Blockfrost backend now prefers cost_models_raw (canonical arrays from the
|
|
236
|
-
* node) which bypasses this issue entirely.
|
|
237
|
-
*
|
|
238
|
-
* For V3 arrays: already in canonical order, just pad to 297 via toCostModelArrV3.
|
|
239
|
-
* For V3 objects (Ogmios named format): toCostModelArrV3(obj) maps via canonical keys.
|
|
240
|
-
* For V1/V2: alphabetical order IS the canonical order (no reordering needed).
|
|
241
|
-
*
|
|
242
|
-
* @param raw - Raw cost models from any backend (Blockfrost, Ogmios, Koios)
|
|
243
|
-
* @returns Object with all cost model values as number arrays in canonical order
|
|
131
|
+
* Cost models to number arrays in canonical Plutus parameter order. V3 goes through toCostModelArrV3
|
|
132
|
+
* (canonical keys, padded to 297); for V1/V2 alphabetical key order is the canonical order.
|
|
244
133
|
*/
|
|
245
134
|
export declare function normalizeCostModels(raw: Record<string, unknown>): Record<string, number[]>;
|
|
246
135
|
/**
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
* @param policyIdHex - Policy ID as hex string (56 chars / 28 bytes)
|
|
250
|
-
* @param assetNameHex - Asset name as hex string (variable length)
|
|
251
|
-
* @returns CIP-14 fingerprint string (e.g. "asset1...")
|
|
136
|
+
* Asset name (hex bytes) to its display string; the hex is returned unchanged for invalid UTF-8 or
|
|
137
|
+
* names containing U+0000 (PostgreSQL rejects NUL in `text`). `assetNameHex` always keeps the exact bytes.
|
|
252
138
|
*/
|
|
139
|
+
export declare function decodeAssetName(hex: string): string;
|
|
140
|
+
/** CIP-14 fingerprint: bech32("asset", blake2b_160(policyId_bytes + assetName_bytes)). */
|
|
253
141
|
export declare function computeCip14Fingerprint(policyIdHex: string, assetNameHex: string): string;
|
|
254
|
-
/**
|
|
255
|
-
* Derive an enterprise script address from a script hash and network.
|
|
256
|
-
* Enterprise address = header_byte + 28-byte script hash, bech32-encoded.
|
|
257
|
-
* Header: 0x71 (mainnet, type 7 network 1) or 0x70 (testnet, type 7 network 0).
|
|
258
|
-
*/
|
|
142
|
+
/** Enterprise script address: header 0x71 (mainnet) / 0x70 (testnet) + 28-byte script hash, bech32. */
|
|
259
143
|
export declare function scriptHashToEnterpriseAddress(scriptHashHex: string, network: 'mainnet' | 'preprod' | 'preview'): string;
|
|
144
|
+
/** Stake credential to bech32 reward account; header nibbles 0xe key / 0xf script, network 1 mainnet / 0 testnets. */
|
|
145
|
+
export declare function credentialToStakeAddress(credentialHex: string, isScript: boolean, network: 'mainnet' | 'preprod' | 'preview'): string;
|
|
146
|
+
export interface DecodedAddress {
|
|
147
|
+
type: 'base' | 'pointer' | 'enterprise' | 'reward' | 'byron' | 'unknown';
|
|
148
|
+
/** Payment credential is a script hash. */
|
|
149
|
+
isScript: boolean;
|
|
150
|
+
/** Reward account (bech32) of a base address; null for every other type. */
|
|
151
|
+
stakeAddress: string | null;
|
|
152
|
+
/** Payment key/script hash (hex) of a base, pointer or enterprise address; null otherwise. */
|
|
153
|
+
paymentCredential: string | null;
|
|
154
|
+
/** Network nibble of the header (1 = mainnet, 0 = testnets); null when not a Shelley address. */
|
|
155
|
+
networkId: number | null;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Decode the CIP-19 Shelley address header: type, script flag and, for base addresses, the embedded
|
|
159
|
+
* stake credential as a reward account. Byron (base58) and unparseable input yield `byron` / `unknown`.
|
|
160
|
+
*/
|
|
161
|
+
export declare function decodeShelleyAddress(address: string): DecodedAddress;
|
|
162
|
+
/** DRep credential to CIP-129 DRep ID (29 bytes): header 0x22 key hash / 0x23 script hash. */
|
|
163
|
+
export declare function credentialToDrepId(credentialHex: string, isScript: boolean): string;
|
|
164
|
+
/** Address balance from its UTxOs: lovelace first, then every native asset summed per unit. */
|
|
165
|
+
export declare function sumUtxoAmounts(utxos: Array<{
|
|
166
|
+
amount: Array<{
|
|
167
|
+
unit: string;
|
|
168
|
+
quantity: string;
|
|
169
|
+
}>;
|
|
170
|
+
}>): Array<{
|
|
171
|
+
unit: string;
|
|
172
|
+
quantity: string;
|
|
173
|
+
}>;
|
|
260
174
|
//# sourceMappingURL=mappers.d.ts.map
|