@odatano/core 1.7.10 → 1.9.0
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/CardanoODataService/index.d.ts +66 -42
- package/@cds-models/CardanoODataService/index.d.ts.map +1 -1
- package/@cds-models/CardanoODataService/index.js.map +1 -1
- package/@cds-models/CardanoODataService/index.ts +11 -7
- package/@cds-models/odatano/cardano/index.d.ts +70 -46
- package/@cds-models/odatano/cardano/index.d.ts.map +1 -1
- package/@cds-models/odatano/cardano/index.js +2 -2
- package/@cds-models/odatano/cardano/index.js.map +1 -1
- package/@cds-models/odatano/cardano/index.ts +13 -13
- package/LICENSE +1 -24
- package/README.md +102 -96
- package/db/schema.cds +18 -18
- package/db/types.cds +3 -3
- package/package.json +25 -11
- package/src/index.d.ts +29 -0
- package/src/index.js +1 -0
- package/src/plugin.d.ts +2 -0
- package/src/plugin.js +6 -0
- package/srv/blockchain/backends/blockfrost-backend.d.ts +155 -0
- package/srv/blockchain/backends/blockfrost-backend.js +19 -8
- package/srv/blockchain/backends/cardano-backend.d.ts +182 -0
- package/srv/blockchain/backends/koios-backend.d.ts +171 -0
- package/srv/blockchain/backends/koios-backend.js +69 -27
- package/srv/blockchain/backends/ogmios-backend.d.ts +188 -0
- package/srv/blockchain/backends/ogmios-backend.js +175 -108
- package/srv/blockchain/cardano-client.d.ts +279 -0
- package/srv/blockchain/cardano-client.js +134 -33
- package/srv/blockchain/cardano-indexer.d.ts +330 -0
- package/srv/blockchain/cardano-indexer.js +51 -8
- package/srv/blockchain/cardano-tx-builder.d.ts +113 -0
- package/srv/blockchain/cardano-tx-builder.js +64 -57
- package/srv/blockchain/circuit-breaker.d.ts +37 -0
- package/srv/blockchain/circuit-breaker.js +11 -2
- package/srv/blockchain/request-coalescer.d.ts +23 -0
- package/srv/blockchain/signing/external-signer.d.ts +146 -0
- package/srv/blockchain/signing/external-signer.js +23 -0
- package/srv/blockchain/signing/hsm-signer.d.ts +74 -0
- package/srv/blockchain/signing/hsm-signer.js +20 -5
- package/srv/blockchain/signing/signature-verifier.d.ts +56 -0
- package/srv/blockchain/signing/signature-verifier.js +79 -79
- package/srv/blockchain/transaction-building/buildooor-tx.d.ts +236 -0
- package/srv/blockchain/transaction-building/buildooor-tx.js +632 -173
- package/srv/blockchain/transaction-building/cardano-tx.d.ts +47 -0
- package/srv/cardano-service.cds +23 -3
- package/srv/cardano-service.d.ts +2 -0
- package/srv/cardano-service.js +26 -6
- package/srv/cardano-sign-service.cds +5 -0
- package/srv/cardano-sign-service.d.ts +2 -0
- package/srv/cardano-sign-service.js +221 -134
- package/srv/cardano-tx-service.cds +8 -0
- package/srv/cardano-tx-service.d.ts +12 -0
- package/srv/cardano-tx-service.js +170 -111
- package/srv/cbor/index.d.ts +2 -0
- package/srv/cbor/parse.d.ts +64 -0
- package/srv/server.d.ts +90 -0
- package/srv/server.js +52 -41
- package/srv/utils/backend-request-handler.d.ts +20 -0
- package/srv/utils/const.d.ts +183 -0
- package/srv/utils/const.js +13 -6
- package/srv/utils/error-codes.d.ts +79 -0
- package/srv/utils/errors.d.ts +259 -0
- package/srv/utils/errors.js +22 -7
- package/srv/utils/mappers.d.ts +260 -0
- package/srv/utils/mappers.js +34 -10
- package/srv/utils/plutus-placeholders.d.ts +35 -0
- package/srv/utils/plutus-placeholders.js +6 -17
- package/srv/utils/signing-helper.d.ts +23 -0
- package/srv/utils/signing-helper.js +11 -49
- package/srv/utils/tx-build-helper.d.ts +76 -0
- package/srv/utils/tx-build-helper.js +29 -80
- package/srv/utils/types.d.ts +653 -0
- package/srv/utils/validators.d.ts +145 -0
- package/srv/utils/validators.js +28 -1
- package/@cds-models/CardanoWatcherAdminService/index.js +0 -109
- package/@cds-models/CardanoWatcherAdminService/index.js.map +0 -1
- package/@cds-models/CardanoWatcherAdminService/index.ts +0 -263
- package/@cds-models/cds/outbox/index.js.map +0 -1
- package/@cds-models/cds/xt/MTXServices/index.js +0 -8
- package/@cds-models/cds/xt/MTXServices/index.js.map +0 -1
- package/@cds-models/cds/xt/MTXServices/index.ts +0 -4
- package/@cds-models/odatano/reeve/index.js +0 -77
- package/@cds-models/odatano/reeve/index.js.map +0 -1
- package/@cds-models/odatano/reeve/index.ts +0 -57
- package/@cds-models/odatano/transactions/index.js +0 -55
- package/@cds-models/odatano/transactions/index.js.map +0 -1
- package/@cds-models/odatano/transactions/index.ts +0 -18
- package/@cds-models/odatano/watch/index.js +0 -114
- package/@cds-models/odatano/watch/index.js.map +0 -1
- package/@cds-models/odatano/watch/index.ts +0 -110
- package/config/preview/cardano-node/alonzo-genesis.json +0 -196
- package/config/preview/cardano-node/byron-genesis.json +0 -117
- package/config/preview/cardano-node/config.json +0 -118
- package/config/preview/cardano-node/conway-genesis.json +0 -297
- package/config/preview/cardano-node/shelley-genesis.json +0 -68
- package/config/preview/cardano-node/topology.json +0 -19
- package/output/sora/iter0_base.json +0 -32
- package/output/sora/iter0_base.mp4 +0 -0
- package/output/sora/logo_ref_1280x720.png +0 -0
- package/output/sora/odatano_full_logo_sky_ref_1280x720.png +0 -0
- package/output/sora/odatano_full_logo_transparent.png +0 -0
- package/output/sora/odatano_full_logo_transparent_dark.png +0 -0
- package/output/sora/odatano_full_logo_v4_8s.json +0 -32
- package/output/sora/odatano_full_logo_v4_8s.mp4 +0 -0
- package/output/sora/odatano_full_logo_v5_create.json +0 -15
- package/output/sora/odatano_full_logo_v5_fixes.json +0 -15
- package/output/sora/odatano_full_logo_v5_fixes.mp4 +0 -0
- package/output/sora/odatano_logo_v1.json +0 -32
- package/output/sora/odatano_logo_v1.mp4 +0 -0
- package/output/sora/odatano_o_only_clean.png +0 -0
- package/output/sora/odatano_o_sky_ref_1280x720.png +0 -0
- package/output/sora/odatano_o_sky_v2_8s.json +0 -32
- package/output/sora/odatano_o_sky_v2_8s.mp4 +0 -0
- package/output/sora/odatano_o_sky_v3_create.json +0 -15
- package/output/sora/odatano_o_sky_v3_splash_text.json +0 -15
- package/output/sora/odatano_o_sky_v3_splash_text.mp4 +0 -0
- package/output/sora/odatano_v6_composite_exact_logo.mp4 +0 -0
- package/output/sora/odatano_v6_composite_exact_logo_clean.mp4 +0 -0
- package/output/sora/odatano_v6_composite_exact_logo_final.mp4 +0 -0
- package/output/sora/odatano_v6_endframe.jpg +0 -0
- package/output/sora/odatano_v6_endframe_clean.jpg +0 -0
- package/output/sora/odatano_v6_endframe_final.jpg +0 -0
- package/output/sora/odatano_v7_1_earlylogo_fadeoldtext.mp4 +0 -0
- package/output/sora/odatano_v7_1_end.jpg +0 -0
- package/output/sora/odatano_v7_1_transition.jpg +0 -0
- package/output/sora/odatano_v7_2_original2d_keep_sky.mp4 +0 -0
- package/output/sora/odatano_v7_endframe_nobg.jpg +0 -0
- package/output/sora/odatano_v7_endframe_nobg_cleanend.jpg +0 -0
- package/output/sora/odatano_v7_spin_splash_logo_nobg.mp4 +0 -0
- package/output/sora/odatano_v7_spin_splash_logo_nobg_cleanend.mp4 +0 -0
- package/src/index.d.ts.map +0 -1
- package/src/index.js.map +0 -1
- package/src/plugin.d.ts.map +0 -1
- package/src/plugin.js.map +0 -1
- package/srv/blockchain/backends/blockfrost-backend.d.ts.map +0 -1
- package/srv/blockchain/backends/blockfrost-backend.js.map +0 -1
- package/srv/blockchain/backends/cardano-backend.d.ts.map +0 -1
- package/srv/blockchain/backends/cardano-backend.js.map +0 -1
- package/srv/blockchain/backends/gerolamo-backend.d.ts.map +0 -1
- package/srv/blockchain/backends/gerolamo-backend.js +0 -321
- package/srv/blockchain/backends/gerolamo-backend.js.map +0 -1
- package/srv/blockchain/backends/koios-backend.d.ts.map +0 -1
- package/srv/blockchain/backends/koios-backend.js.map +0 -1
- package/srv/blockchain/backends/ogmios-backend.d.ts.map +0 -1
- package/srv/blockchain/backends/ogmios-backend.js.map +0 -1
- package/srv/blockchain/cardano-client.d.ts.map +0 -1
- package/srv/blockchain/cardano-client.js.map +0 -1
- package/srv/blockchain/cardano-indexer.d.ts.map +0 -1
- package/srv/blockchain/cardano-indexer.js.map +0 -1
- package/srv/blockchain/cardano-tx-builder.d.ts.map +0 -1
- package/srv/blockchain/cardano-tx-builder.js.map +0 -1
- package/srv/blockchain/circuit-breaker.d.ts.map +0 -1
- package/srv/blockchain/circuit-breaker.js.map +0 -1
- package/srv/blockchain/request-coalescer.d.ts.map +0 -1
- package/srv/blockchain/request-coalescer.js.map +0 -1
- package/srv/blockchain/signing/external-signer.d.ts.map +0 -1
- package/srv/blockchain/signing/external-signer.js.map +0 -1
- package/srv/blockchain/signing/hsm-signer.d.ts.map +0 -1
- package/srv/blockchain/signing/hsm-signer.js.map +0 -1
- package/srv/blockchain/signing/signature-verifier.d.ts.map +0 -1
- package/srv/blockchain/signing/signature-verifier.js.map +0 -1
- package/srv/blockchain/transaction-building/buildooor-tx.d.ts.map +0 -1
- package/srv/blockchain/transaction-building/buildooor-tx.js.map +0 -1
- package/srv/blockchain/transaction-building/cardano-tx.d.ts.map +0 -1
- package/srv/blockchain/transaction-building/cardano-tx.js.map +0 -1
- package/srv/blockchain/transaction-building/csl-tx.d.ts.map +0 -1
- package/srv/blockchain/transaction-building/csl-tx.js +0 -922
- package/srv/blockchain/transaction-building/csl-tx.js.map +0 -1
- package/srv/blockchain/transaction-building/tx-builder-registry.d.ts.map +0 -1
- package/srv/blockchain/transaction-building/tx-builder-registry.js +0 -69
- package/srv/blockchain/transaction-building/tx-builder-registry.js.map +0 -1
- package/srv/cardano-service.d.ts.map +0 -1
- package/srv/cardano-service.js.map +0 -1
- package/srv/cardano-sign-service.d.ts.map +0 -1
- package/srv/cardano-sign-service.js.map +0 -1
- package/srv/cardano-tx-service.d.ts.map +0 -1
- package/srv/cardano-tx-service.js.map +0 -1
- package/srv/cbor/index.d.ts.map +0 -1
- package/srv/cbor/index.js.map +0 -1
- package/srv/cbor/parse.d.ts.map +0 -1
- package/srv/cbor/parse.js.map +0 -1
- package/srv/server.d.ts.map +0 -1
- package/srv/server.js.map +0 -1
- package/srv/utils/backend-request-handler.d.ts.map +0 -1
- package/srv/utils/backend-request-handler.js.map +0 -1
- package/srv/utils/const.d.ts.map +0 -1
- package/srv/utils/const.js.map +0 -1
- package/srv/utils/error-codes.d.ts.map +0 -1
- package/srv/utils/error-codes.js.map +0 -1
- package/srv/utils/errors.d.ts.map +0 -1
- package/srv/utils/errors.js.map +0 -1
- package/srv/utils/mappers.d.ts.map +0 -1
- package/srv/utils/mappers.js.map +0 -1
- package/srv/utils/plutus-placeholders.d.ts.map +0 -1
- package/srv/utils/plutus-placeholders.js.map +0 -1
- package/srv/utils/signing-helper.d.ts.map +0 -1
- package/srv/utils/signing-helper.js.map +0 -1
- package/srv/utils/tx-build-helper.d.ts.map +0 -1
- package/srv/utils/tx-build-helper.js.map +0 -1
- package/srv/utils/types.d.ts.map +0 -1
- package/srv/utils/types.js.map +0 -1
- package/srv/utils/validators.d.ts.map +0 -1
- package/srv/utils/validators.js.map +0 -1
package/srv/server.d.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { CardanoClient, CardanoClientConfig, BackendName, TransactionBuilderName } from './blockchain/cardano-client';
|
|
2
|
+
import { CardanoIndexer } from './blockchain/cardano-indexer';
|
|
3
|
+
import { CardanoTransactionBuilder } from './blockchain/cardano-tx-builder';
|
|
4
|
+
import type { LedgerProtocolParameters, HsmConfig } from './utils/types';
|
|
5
|
+
/**
|
|
6
|
+
* Application context holding initialized blockchain components
|
|
7
|
+
* These are created once during CAP bootstrap and shared across services
|
|
8
|
+
*/
|
|
9
|
+
interface AppContext {
|
|
10
|
+
cardanoClient: CardanoClient;
|
|
11
|
+
cardanoIndexer: CardanoIndexer;
|
|
12
|
+
cardanoTxBuilder: CardanoTransactionBuilder;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get the application context (must be called after bootstrap)
|
|
16
|
+
* @throws {ProviderUnavailableError} 503 when uninitialized — request handlers using
|
|
17
|
+
* handleRequest/mapError translate this into a clean 503 response instead of a raw 500.
|
|
18
|
+
* If bootstrap actively failed, the cause is appended to the message.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getAppContext(): AppContext;
|
|
21
|
+
/**
|
|
22
|
+
* Get the CardanoIndexer instance
|
|
23
|
+
* Convenience function for services
|
|
24
|
+
*/
|
|
25
|
+
export declare function getCardanoIndexer(): CardanoIndexer;
|
|
26
|
+
/**
|
|
27
|
+
* Get the CardanoClient instance
|
|
28
|
+
* Convenience function for services
|
|
29
|
+
*/
|
|
30
|
+
export declare function getCardanoClient(): CardanoClient;
|
|
31
|
+
/**
|
|
32
|
+
* Get the CardanoTransactionBuilder instance
|
|
33
|
+
* Convenience function for services and plugin consumers
|
|
34
|
+
*/
|
|
35
|
+
export declare function getCardanoTxBuilder(): CardanoTransactionBuilder;
|
|
36
|
+
/**
|
|
37
|
+
* Get the HSM configuration (if HSM is enabled).
|
|
38
|
+
* Used by sign service to check requiresRole.
|
|
39
|
+
*/
|
|
40
|
+
export declare function getHsmConfig(): HsmConfig | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Initialize from a pre-built config (used by plugin's src/index.ts)
|
|
43
|
+
* @param config - validated CardanoClientConfig
|
|
44
|
+
* @param protocolParams - Optional protocol parameters (for tests)
|
|
45
|
+
*/
|
|
46
|
+
export declare function initializeFromConfig(config: CardanoClientConfig, protocolParams?: LedgerProtocolParameters, hsmConfig?: HsmConfig): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Reset the application context (for testing only)
|
|
49
|
+
* Allows tests to inject their own instances
|
|
50
|
+
*/
|
|
51
|
+
export declare function resetAppContext(context: AppContext | null): void;
|
|
52
|
+
/**
|
|
53
|
+
* Create a test context with specific backends and transaction builder
|
|
54
|
+
* Used by integration tests to create isolated test instances
|
|
55
|
+
* @param backends Array of backend names to use (e.g., ['koios'], ['blockfrost'])
|
|
56
|
+
* @param _txBuilderName Deprecated/ignored — Buildooor is the sole transaction builder (kept for signature compatibility)
|
|
57
|
+
* @param protocolParams Optional protocol parameters (to skip backend call during init)
|
|
58
|
+
* @returns Promise<AppContext> The created application context
|
|
59
|
+
*/
|
|
60
|
+
export declare function createTestContext(backends: BackendName[], _txBuilderName?: TransactionBuilderName, // kept for signature compat; Buildooor is the only builder
|
|
61
|
+
protocolParams?: LedgerProtocolParameters): Promise<AppContext>;
|
|
62
|
+
/**
|
|
63
|
+
* Shutdown the application context (for cleanup in tests)
|
|
64
|
+
* Closes all backend connections to allow process to exit cleanly
|
|
65
|
+
*/
|
|
66
|
+
export declare function shutdownAppContext(): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Load and validate CardanoClientConfig from CDS config or environment variables.
|
|
69
|
+
*
|
|
70
|
+
* When used as a plugin, consumers configure via package.json:
|
|
71
|
+
* { "cds": { "requires": { "odatano-core": { "network": "preview", "backends": ["blockfrost"], ... }}}}
|
|
72
|
+
*
|
|
73
|
+
* Priority: cds.env.requires["odatano-core"].X > process.env.X > default
|
|
74
|
+
*
|
|
75
|
+
* @returns validated CardanoClientConfig
|
|
76
|
+
* @throws {Error} if any config value is invalid
|
|
77
|
+
*/
|
|
78
|
+
export declare function loadConfigFromEnv(): CardanoClientConfig;
|
|
79
|
+
/**
|
|
80
|
+
* Load HSM configuration from CDS config or environment variables.
|
|
81
|
+
* Returns undefined if HSM is not enabled.
|
|
82
|
+
*
|
|
83
|
+
* Plugin mode: cds.requires.odatano-core.hsm.enabled = true
|
|
84
|
+
* Env mode: HSM_ENABLED=true
|
|
85
|
+
*
|
|
86
|
+
* @returns HsmConfig or undefined
|
|
87
|
+
*/
|
|
88
|
+
export declare function loadHsmConfigFromEnv(): HsmConfig | undefined;
|
|
89
|
+
export {};
|
|
90
|
+
//# sourceMappingURL=server.d.ts.map
|
package/srv/server.js
CHANGED
|
@@ -24,7 +24,6 @@ const process_1 = require("process");
|
|
|
24
24
|
const logger = cds_1.default.log('ODATANO');
|
|
25
25
|
const VALID_NETWORKS = ['mainnet', 'preview', 'preprod'];
|
|
26
26
|
const VALID_BACKENDS = ['blockfrost', 'koios', 'ogmios'];
|
|
27
|
-
const VALID_TX_BUILDERS = ['csl', 'buildooor'];
|
|
28
27
|
let appContext = null;
|
|
29
28
|
let bootstrapError = null;
|
|
30
29
|
/**
|
|
@@ -122,7 +121,17 @@ async function initializeFromConfig(config, protocolParams, hsmConfig) {
|
|
|
122
121
|
return;
|
|
123
122
|
}
|
|
124
123
|
hsmConfigInstance = hsmConfig;
|
|
125
|
-
|
|
124
|
+
try {
|
|
125
|
+
appContext = await initializeAppContext(config, protocolParams, hsmConfig);
|
|
126
|
+
bootstrapError = null;
|
|
127
|
+
}
|
|
128
|
+
catch (err) {
|
|
129
|
+
// Capture the cause so getAppContext() surfaces a structured 503 with diagnostics
|
|
130
|
+
// even in PLUGIN mode (src/plugin.ts only logs the error) — previously bootstrapError
|
|
131
|
+
// stayed null there and the failure showed up as a causeless "not initialized".
|
|
132
|
+
bootstrapError = err instanceof Error ? err : new Error(String(err));
|
|
133
|
+
throw err; // still propagate so the plugin/programmatic caller sees it
|
|
134
|
+
}
|
|
126
135
|
}
|
|
127
136
|
/**
|
|
128
137
|
* Reset the application context (for testing only)
|
|
@@ -140,32 +149,25 @@ function resetAppContext(context) {
|
|
|
140
149
|
* Create a test context with specific backends and transaction builder
|
|
141
150
|
* Used by integration tests to create isolated test instances
|
|
142
151
|
* @param backends Array of backend names to use (e.g., ['koios'], ['blockfrost'])
|
|
143
|
-
* @param
|
|
152
|
+
* @param _txBuilderName Deprecated/ignored — Buildooor is the sole transaction builder (kept for signature compatibility)
|
|
144
153
|
* @param protocolParams Optional protocol parameters (to skip backend call during init)
|
|
145
154
|
* @returns Promise<AppContext> The created application context
|
|
146
155
|
*/
|
|
147
|
-
async function createTestContext(backends,
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
indexTtlMs: Number(process_1.env.INDEX_TTL_MS) || 3600000,
|
|
163
|
-
};
|
|
164
|
-
return await initializeAppContext(config, protocolParams);
|
|
165
|
-
}
|
|
166
|
-
finally {
|
|
167
|
-
process_1.env.TX_BUILDERS = previousTxBuilders;
|
|
168
|
-
}
|
|
156
|
+
async function createTestContext(backends, _txBuilderName = 'buildooor', // kept for signature compat; Buildooor is the only builder
|
|
157
|
+
protocolParams) {
|
|
158
|
+
const config = {
|
|
159
|
+
network: process_1.env.NETWORK || 'preview',
|
|
160
|
+
backends,
|
|
161
|
+
blockfrostApiKey: process_1.env.BLOCKFROST_API_KEY || '',
|
|
162
|
+
blockfrostCustomBackend: process_1.env.BLOCKFROST_CUSTOM_BACKEND || undefined,
|
|
163
|
+
koiosApiKey: process_1.env.KOIOS_API_KEY || '',
|
|
164
|
+
ogmiosUrl: process_1.env.OGMIOS_URL || '',
|
|
165
|
+
transactionBuilders: ['buildooor'],
|
|
166
|
+
primaryTimeoutMs: Number(process_1.env.PRIMARY_TIMEOUT_MS) || 30000, // || intentional: NaN (missing env var) falls back to default
|
|
167
|
+
fallbackTimeoutMs: Number(process_1.env.FALLBACK_TIMEOUT_MS) || 60000,
|
|
168
|
+
indexTtlMs: Number(process_1.env.INDEX_TTL_MS) || 3600000,
|
|
169
|
+
};
|
|
170
|
+
return await initializeAppContext(config, protocolParams);
|
|
169
171
|
}
|
|
170
172
|
/**
|
|
171
173
|
* Shutdown the application context (for cleanup in tests)
|
|
@@ -210,25 +212,22 @@ function loadConfigFromEnv() {
|
|
|
210
212
|
throw new errors_1.ConfigError(`Invalid BACKENDS: "${invalidBackends.join(', ')}". Must be one of: ${VALID_BACKENDS.join(', ')}`);
|
|
211
213
|
}
|
|
212
214
|
const backends = backendStrings;
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const invalidBuilders = txBuilderStrings.filter(b => !VALID_TX_BUILDERS.includes(b));
|
|
216
|
-
if (invalidBuilders.length > 0) {
|
|
217
|
-
throw new errors_1.ConfigError(`Invalid TX_BUILDERS: "${invalidBuilders.join(', ')}". Must be one of: ${VALID_TX_BUILDERS.join(', ')}`);
|
|
218
|
-
}
|
|
219
|
-
const txBuilders = txBuilderStrings;
|
|
215
|
+
// Buildooor is the sole transaction builder; any legacy txBuilders/TX_BUILDERS config is ignored.
|
|
216
|
+
const txBuilders = ['buildooor'];
|
|
220
217
|
const primaryTimeout = cdsConfig.primaryTimeoutMs ?? process_1.env.PRIMARY_TIMEOUT_MS;
|
|
221
218
|
const fallbackTimeout = cdsConfig.fallbackTimeoutMs ?? process_1.env.FALLBACK_TIMEOUT_MS;
|
|
222
|
-
|
|
219
|
+
// `!= null` not truthiness: a CDS-config numeric 0 is falsy, so `timeout && …`
|
|
220
|
+
// skipped the <=0 check and 0 then silently became the default via `Number(0)||default`.
|
|
221
|
+
if (primaryTimeout != null && isNaN(Number(primaryTimeout))) {
|
|
223
222
|
throw new errors_1.ConfigError(`Invalid PRIMARY_TIMEOUT_MS "${primaryTimeout}". Must be a number.`);
|
|
224
223
|
}
|
|
225
|
-
if (primaryTimeout && Number(primaryTimeout) <= 0) {
|
|
224
|
+
if (primaryTimeout != null && Number(primaryTimeout) <= 0) {
|
|
226
225
|
throw new errors_1.ConfigError(`Invalid PRIMARY_TIMEOUT_MS "${primaryTimeout}". Must be a positive number.`);
|
|
227
226
|
}
|
|
228
|
-
if (fallbackTimeout && isNaN(Number(fallbackTimeout))) {
|
|
227
|
+
if (fallbackTimeout != null && isNaN(Number(fallbackTimeout))) {
|
|
229
228
|
throw new errors_1.ConfigError(`Invalid FALLBACK_TIMEOUT_MS "${fallbackTimeout}". Must be a number.`);
|
|
230
229
|
}
|
|
231
|
-
if (fallbackTimeout && Number(fallbackTimeout) <= 0) {
|
|
230
|
+
if (fallbackTimeout != null && Number(fallbackTimeout) <= 0) {
|
|
232
231
|
throw new errors_1.ConfigError(`Invalid FALLBACK_TIMEOUT_MS "${fallbackTimeout}". Must be a positive number.`);
|
|
233
232
|
}
|
|
234
233
|
const blockfrostApiKey = cdsConfig.blockfrostApiKey || process_1.env.BLOCKFROST_API_KEY || '';
|
|
@@ -289,6 +288,12 @@ function loadHsmConfigFromEnv() {
|
|
|
289
288
|
if (!Number.isInteger(slot) || slot < 0) {
|
|
290
289
|
throw new errors_1.ConfigError(`Invalid HSM slot: "${hsmCds.slot ?? process_1.env.HSM_SLOT}" — must be a non-negative integer`);
|
|
291
290
|
}
|
|
291
|
+
// Fail-closed: HSM controls a real signing key. Require an explicit role gate so
|
|
292
|
+
// that an authenticated user cannot drain the HSM-controlled wallet by default.
|
|
293
|
+
const requiresRole = hsmCds.requiresRole || process_1.env.HSM_REQUIRES_ROLE || '';
|
|
294
|
+
if (!requiresRole) {
|
|
295
|
+
throw new errors_1.ConfigError('HSM_REQUIRES_ROLE (or cds.requires.odatano-core.hsm.requiresRole) is required when HSM is enabled — set it to the XSUAA scope name allowed to invoke HSM signing actions');
|
|
296
|
+
}
|
|
292
297
|
return {
|
|
293
298
|
enabled: true,
|
|
294
299
|
pkcs11Module,
|
|
@@ -296,7 +301,7 @@ function loadHsmConfigFromEnv() {
|
|
|
296
301
|
pin,
|
|
297
302
|
keyId: hsmCds.keyId || process_1.env.HSM_KEY_ID,
|
|
298
303
|
keyLabel: hsmCds.keyLabel || process_1.env.HSM_KEY_LABEL,
|
|
299
|
-
requiresRole
|
|
304
|
+
requiresRole,
|
|
300
305
|
};
|
|
301
306
|
}
|
|
302
307
|
// Bootstrap hook - runs when CAP server has loaded all services
|
|
@@ -309,10 +314,15 @@ cds_1.default.on('served', async () => {
|
|
|
309
314
|
logger.info('Skipping auto-initialization (SKIP_AUTO_INIT=true)');
|
|
310
315
|
return;
|
|
311
316
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
317
|
+
// NOTE: config loading is INSIDE the try — loadConfigFromEnv/loadHsmConfigFromEnv
|
|
318
|
+
// throw ConfigError synchronously (missing HSM_PIN, bad slot, no requiresRole…).
|
|
319
|
+
// Outside the try that would crash the host app's bootstrap in plugin mode,
|
|
320
|
+
// violating the plugin contract ("never throw on failure").
|
|
321
|
+
let config;
|
|
315
322
|
try {
|
|
323
|
+
config = loadConfigFromEnv();
|
|
324
|
+
const hsmConfig = loadHsmConfigFromEnv();
|
|
325
|
+
hsmConfigInstance = hsmConfig;
|
|
316
326
|
appContext = await initializeAppContext(config, undefined, hsmConfig);
|
|
317
327
|
bootstrapError = null;
|
|
318
328
|
logger.info('CAP server bootstrap complete');
|
|
@@ -324,8 +334,9 @@ cds_1.default.on('served', async () => {
|
|
|
324
334
|
bootstrapError = err instanceof Error ? err : new Error(String(err));
|
|
325
335
|
// Write to stderr directly so the cause stays visible even when test runners
|
|
326
336
|
// suppress console.error (jest.setup.ts in this repo silences it).
|
|
337
|
+
const where = config ? `backends={${config.backends.join(',')}} network=${config.network}` : 'config load';
|
|
327
338
|
const msg = err instanceof Error ? `${err.name}: ${err.message}\n${err.stack ?? ''}` : String(err);
|
|
328
|
-
process.stderr.write(`[ODATANO] Failed to initialize blockchain components —
|
|
339
|
+
process.stderr.write(`[ODATANO] Failed to initialize blockchain components — ${where}\n${msg}\n`);
|
|
329
340
|
logger.error('Failed to initialize blockchain components:', err);
|
|
330
341
|
}
|
|
331
342
|
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import cds, { Request } from '@sap/cds';
|
|
2
|
+
/**
|
|
3
|
+
* BackendRequestHandler - Provides standardized handling for backend requests
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* BackendRequestHandler - Wraps a backend method call with standardized error handling
|
|
7
|
+
* @param fn - The async function to execute
|
|
8
|
+
* @param backendName - Name of the backend (for error context)
|
|
9
|
+
* @param resourceName - Name of the resource being accessed (e.g., "Transaction", "Address")
|
|
10
|
+
* @returns {Promise<T>} The result of the backend call or a normalized error
|
|
11
|
+
*/
|
|
12
|
+
export declare function handleBackendRequest<T>(fn: () => Promise<T>, backendName: string): Promise<T>;
|
|
13
|
+
/**
|
|
14
|
+
* General request handler for CardanoService
|
|
15
|
+
* @param req - The incoming request
|
|
16
|
+
* @param handler - The async function containing business logic
|
|
17
|
+
* @returns {Promise<unknown>} The result of the handler or a mapped error response
|
|
18
|
+
*/
|
|
19
|
+
export declare function handleRequest(req: Request, handler: (db: cds.Transaction) => Promise<unknown>): Promise<unknown>;
|
|
20
|
+
//# sourceMappingURL=backend-request-handler.d.ts.map
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cardano protocol constants
|
|
3
|
+
*/
|
|
4
|
+
export declare const CARDANO_DEFAULTS: {
|
|
5
|
+
/** Maximum ADA supply in lovelace (45 billion ADA) */
|
|
6
|
+
MAX_LOVELACE_SUPPLY: string;
|
|
7
|
+
/** Milliseconds per slot */
|
|
8
|
+
MS_PER_SLOT: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Network-specific epoch geometry, anchored at the Shelley transition:
|
|
12
|
+
* `epochStartSlot(epoch) = shelleyStartSlot + (epoch - shelleyStartEpoch) * slotsPerEpoch`.
|
|
13
|
+
* A single global SLOTS_PER_EPOCH is wrong twice over — preview uses 86 400 (1 day),
|
|
14
|
+
* and mainnet/preprod epochs are offset by their Byron era.
|
|
15
|
+
*/
|
|
16
|
+
export declare const EPOCH_CONFIG_BY_NETWORK: {
|
|
17
|
+
readonly mainnet: {
|
|
18
|
+
readonly shelleyStartEpoch: 208;
|
|
19
|
+
readonly shelleyStartSlot: 4492800;
|
|
20
|
+
readonly slotsPerEpoch: 432000;
|
|
21
|
+
};
|
|
22
|
+
readonly preprod: {
|
|
23
|
+
readonly shelleyStartEpoch: 4;
|
|
24
|
+
readonly shelleyStartSlot: 86400;
|
|
25
|
+
readonly slotsPerEpoch: 432000;
|
|
26
|
+
};
|
|
27
|
+
readonly preview: {
|
|
28
|
+
readonly shelleyStartEpoch: 0;
|
|
29
|
+
readonly shelleyStartSlot: 0;
|
|
30
|
+
readonly slotsPerEpoch: 86400;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Default execution units for Plutus scripts
|
|
35
|
+
* Used when dynamic evaluation is not available
|
|
36
|
+
*/
|
|
37
|
+
export declare const DEFAULT_EXECUTION_UNITS: {
|
|
38
|
+
/** Memory units for script execution */
|
|
39
|
+
mem: number;
|
|
40
|
+
/** CPU steps for script execution */
|
|
41
|
+
cpu: number;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* High execution units for initial transaction build (before evaluation)
|
|
45
|
+
* Set higher than DEFAULT to ensure fee estimation is sufficient before actual evaluation
|
|
46
|
+
*/
|
|
47
|
+
export declare const HIGH_EXECUTION_UNITS: {
|
|
48
|
+
/** Memory units - high for evaluation pass */
|
|
49
|
+
mem: number;
|
|
50
|
+
/** CPU steps - high for evaluation pass */
|
|
51
|
+
cpu: number;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Execution unit buffer — relative multiplier applied to evaluator output.
|
|
55
|
+
* Combined with ABS_* floors below so small validators also get a meaningful cushion.
|
|
56
|
+
*/
|
|
57
|
+
export declare const EXECUTION_UNIT_BUFFER = 1.1;
|
|
58
|
+
/**
|
|
59
|
+
* Absolute ExUnits floor added on top of the relative multiplier.
|
|
60
|
+
*
|
|
61
|
+
* Rationale: validators that iterate reference inputs and decode inline CBOR
|
|
62
|
+
* datums (e.g. oracle-consuming mint policies) show a larger ScriptContext →
|
|
63
|
+
* ledger drift than the documented ~10k–30k CPU / ~50–100 mem band — real-world
|
|
64
|
+
* cases overshot a 50k/1k floor by ~27k CPU / ~56 mem, burning the submit fee.
|
|
65
|
+
* The floor is sized to cover reference-input + CBOR-decoding drift on top of
|
|
66
|
+
* the 10% relative multiplier; `max_tx_ex_units` still caps build-time totals,
|
|
67
|
+
* so oversizing here cannot push a tx past network limits — it only trades a
|
|
68
|
+
* few extra lovelace of fee for avoiding an opaque PlutusFailure on submit.
|
|
69
|
+
*/
|
|
70
|
+
export declare const ABS_CPU_BUFFER = 200000;
|
|
71
|
+
export declare const ABS_MEM_BUFFER = 5000;
|
|
72
|
+
/**
|
|
73
|
+
* Transaction building constants
|
|
74
|
+
*/
|
|
75
|
+
/** Collateral amount in lovelace (5 ADA) */
|
|
76
|
+
export declare const COLLATERAL_LOVELACE = 5000000n;
|
|
77
|
+
/** Fee buffer in lovelace (1 ADA) */
|
|
78
|
+
export declare const FEE_BUFFER_LOVELACE = 1000000n;
|
|
79
|
+
export declare const HRP: {
|
|
80
|
+
mainnet: {
|
|
81
|
+
addr: RegExp;
|
|
82
|
+
stake: RegExp;
|
|
83
|
+
};
|
|
84
|
+
preview: {
|
|
85
|
+
addr: RegExp;
|
|
86
|
+
stake: RegExp;
|
|
87
|
+
};
|
|
88
|
+
preprod: {
|
|
89
|
+
addr: RegExp;
|
|
90
|
+
stake: RegExp;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Input validation limits to prevent DoS attacks
|
|
95
|
+
*/
|
|
96
|
+
/** Maximum JSON string length in bytes (1MB) */
|
|
97
|
+
export declare const MAX_JSON_SIZE = 1048576;
|
|
98
|
+
/** Maximum nesting depth for JSON objects/arrays */
|
|
99
|
+
export declare const MAX_DEPTH = 10;
|
|
100
|
+
/** Maximum number of keys in a JSON object */
|
|
101
|
+
export declare const MAX_KEYS = 100;
|
|
102
|
+
/** Maximum number of elements in a JSON array */
|
|
103
|
+
export declare const MAX_ARRAY_LENGTH = 1000;
|
|
104
|
+
/** Maximum length of a single string value */
|
|
105
|
+
export declare const MAX_STRING_LENGTH = 65536;
|
|
106
|
+
/** Maximum ech32 string length to prevent DoS */
|
|
107
|
+
export declare const BECH32_MAX_LENGTH = 2000;
|
|
108
|
+
/**
|
|
109
|
+
* Maximum hex length of transaction CBOR accepted by ParseTransactionCbor.
|
|
110
|
+
* Mainnet `maxTxSize` is currently 16 KiB; 64 KiB raw (= 128 KiB hex) leaves
|
|
111
|
+
* generous headroom for future protocol bumps and reference-script outputs
|
|
112
|
+
* while keeping the parser from being a memory-exhaustion vector.
|
|
113
|
+
*/
|
|
114
|
+
export declare const MAX_TX_CBOR_HEX_LENGTH: number;
|
|
115
|
+
/** Maximum reasonable epoch number */
|
|
116
|
+
export declare const MAX_EPOCH = 100000;
|
|
117
|
+
/** Standard pool ID payload length */
|
|
118
|
+
export declare const POOL_ID_BYTES = 28;
|
|
119
|
+
/** Standard DRep ID payload length (1 byte type prefix + 28 byte key hash) */
|
|
120
|
+
export declare const DREP_ID_BYTES = 29;
|
|
121
|
+
/** Length of a hex-encoded Cardano policy ID (28 bytes = 56 hex chars) */
|
|
122
|
+
export declare const POLICY_ID_HEX_LENGTH = 56;
|
|
123
|
+
/** Minimum length of a full asset unit (policyId + at least 1 char assetName) */
|
|
124
|
+
export declare const MIN_FULL_ASSET_UNIT_LENGTH: number;
|
|
125
|
+
/** Length of a hex-encoded Ed25519 key hash (28 bytes = 56 hex chars) */
|
|
126
|
+
export declare const ED25519_KEY_HASH_HEX_LENGTH = 56;
|
|
127
|
+
/** Regex for validating Ed25519 key hash hex strings */
|
|
128
|
+
export declare const ED25519_KEY_HASH_REGEX: RegExp;
|
|
129
|
+
/** Minimum lovelace for a change output carrying native assets (2 ADA) */
|
|
130
|
+
export declare const MIN_CHANGE_LOVELACE = 2000000;
|
|
131
|
+
/**
|
|
132
|
+
* Shelley-era genesis parameters per network, used to construct Buildooor's
|
|
133
|
+
* GenesisInfos so `TxBuilder.posixToSlot()` can convert validity-window
|
|
134
|
+
* Posix ms into ledger slots. `slotLengthMs` is 1000 ms on all current networks.
|
|
135
|
+
*/
|
|
136
|
+
export declare const GENESIS_INFOS_BY_NETWORK: {
|
|
137
|
+
readonly mainnet: {
|
|
138
|
+
readonly systemStartPosixMs: 1596491091000;
|
|
139
|
+
readonly slotLengthMs: 1000;
|
|
140
|
+
readonly startSlotNo: 4492800;
|
|
141
|
+
};
|
|
142
|
+
readonly preprod: {
|
|
143
|
+
readonly systemStartPosixMs: 1655683200000;
|
|
144
|
+
readonly slotLengthMs: 1000;
|
|
145
|
+
readonly startSlotNo: 0;
|
|
146
|
+
};
|
|
147
|
+
readonly preview: {
|
|
148
|
+
readonly systemStartPosixMs: 1666656000000;
|
|
149
|
+
readonly slotLengthMs: 1000;
|
|
150
|
+
readonly startSlotNo: 0;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
/** Default validity-window start offset: `now - 2 min` to absorb clock skew. */
|
|
154
|
+
export declare const DEFAULT_VALIDITY_START_OFFSET_MS = 120000;
|
|
155
|
+
/** Default validity-window end offset: `now + 1 h` — generous enough for human-latency sign+submit flows. */
|
|
156
|
+
export declare const DEFAULT_VALIDITY_END_OFFSET_MS: number;
|
|
157
|
+
/** Max accepted digits in a Posix-ms string (13 digits covers Unix ms timestamps through ~Nov 2286). */
|
|
158
|
+
export declare const MAX_POSIX_MS_DIGITS = 13;
|
|
159
|
+
/**
|
|
160
|
+
* Generic 64-character hex string (used for block hashes and other 32-byte hex identifiers)
|
|
161
|
+
*/
|
|
162
|
+
export declare const HEX_64_REGEX: RegExp;
|
|
163
|
+
/**
|
|
164
|
+
* Generic 56-character hex string — 28-byte hashes (Blake2b-224 / payment credential / script hash / pool key hash).
|
|
165
|
+
*/
|
|
166
|
+
export declare const HEX_56_REGEX: RegExp;
|
|
167
|
+
/**
|
|
168
|
+
* Transaction hash Regex - 64-character hexadecimal string
|
|
169
|
+
*/
|
|
170
|
+
export declare const TX_HASH_REGEX: RegExp;
|
|
171
|
+
/**
|
|
172
|
+
* Asset unit Regex - policy ID (56 hex chars) + asset name (0-128 hex chars)
|
|
173
|
+
*/
|
|
174
|
+
export declare const ASSET_UNIT_REGEX: RegExp;
|
|
175
|
+
/**
|
|
176
|
+
* Pool ID Regex - bech32 with HRP "pool" and 28 bytes payload
|
|
177
|
+
*/
|
|
178
|
+
export declare const POOL_ID_REGEX: RegExp;
|
|
179
|
+
/**
|
|
180
|
+
* DRep ID Regex - bech32 with HRP "drep" and 50-60 chars payload
|
|
181
|
+
*/
|
|
182
|
+
export declare const DREP_ID_REGEX: RegExp;
|
|
183
|
+
//# sourceMappingURL=const.d.ts.map
|
package/srv/utils/const.js
CHANGED
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DREP_ID_REGEX = exports.POOL_ID_REGEX = exports.ASSET_UNIT_REGEX = exports.TX_HASH_REGEX = exports.HEX_56_REGEX = exports.HEX_64_REGEX = exports.MAX_POSIX_MS_DIGITS = exports.DEFAULT_VALIDITY_END_OFFSET_MS = exports.DEFAULT_VALIDITY_START_OFFSET_MS = exports.GENESIS_INFOS_BY_NETWORK = exports.MIN_CHANGE_LOVELACE = exports.ED25519_KEY_HASH_REGEX = exports.ED25519_KEY_HASH_HEX_LENGTH = exports.MIN_FULL_ASSET_UNIT_LENGTH = exports.POLICY_ID_HEX_LENGTH = exports.DREP_ID_BYTES = exports.POOL_ID_BYTES = exports.MAX_EPOCH = exports.MAX_TX_CBOR_HEX_LENGTH = exports.BECH32_MAX_LENGTH = exports.MAX_STRING_LENGTH = exports.MAX_ARRAY_LENGTH = exports.MAX_KEYS = exports.MAX_DEPTH = exports.MAX_JSON_SIZE = exports.HRP = exports.FEE_BUFFER_LOVELACE = exports.COLLATERAL_LOVELACE = exports.
|
|
3
|
+
exports.DREP_ID_REGEX = exports.POOL_ID_REGEX = exports.ASSET_UNIT_REGEX = exports.TX_HASH_REGEX = exports.HEX_56_REGEX = exports.HEX_64_REGEX = exports.MAX_POSIX_MS_DIGITS = exports.DEFAULT_VALIDITY_END_OFFSET_MS = exports.DEFAULT_VALIDITY_START_OFFSET_MS = exports.GENESIS_INFOS_BY_NETWORK = exports.MIN_CHANGE_LOVELACE = exports.ED25519_KEY_HASH_REGEX = exports.ED25519_KEY_HASH_HEX_LENGTH = exports.MIN_FULL_ASSET_UNIT_LENGTH = exports.POLICY_ID_HEX_LENGTH = exports.DREP_ID_BYTES = exports.POOL_ID_BYTES = exports.MAX_EPOCH = exports.MAX_TX_CBOR_HEX_LENGTH = exports.BECH32_MAX_LENGTH = exports.MAX_STRING_LENGTH = exports.MAX_ARRAY_LENGTH = exports.MAX_KEYS = exports.MAX_DEPTH = exports.MAX_JSON_SIZE = exports.HRP = exports.FEE_BUFFER_LOVELACE = exports.COLLATERAL_LOVELACE = exports.ABS_MEM_BUFFER = exports.ABS_CPU_BUFFER = exports.EXECUTION_UNIT_BUFFER = exports.HIGH_EXECUTION_UNITS = exports.DEFAULT_EXECUTION_UNITS = exports.EPOCH_CONFIG_BY_NETWORK = exports.CARDANO_DEFAULTS = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Cardano protocol constants
|
|
6
6
|
*/
|
|
7
7
|
exports.CARDANO_DEFAULTS = {
|
|
8
8
|
/** Maximum ADA supply in lovelace (45 billion ADA) */
|
|
9
9
|
MAX_LOVELACE_SUPPLY: '45000000000000000',
|
|
10
|
-
/** Slots per epoch (mainnet/testnets) */
|
|
11
|
-
SLOTS_PER_EPOCH: 432_000,
|
|
12
10
|
/** Milliseconds per slot */
|
|
13
11
|
MS_PER_SLOT: 1000,
|
|
14
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Network-specific epoch geometry, anchored at the Shelley transition:
|
|
15
|
+
* `epochStartSlot(epoch) = shelleyStartSlot + (epoch - shelleyStartEpoch) * slotsPerEpoch`.
|
|
16
|
+
* A single global SLOTS_PER_EPOCH is wrong twice over — preview uses 86 400 (1 day),
|
|
17
|
+
* and mainnet/preprod epochs are offset by their Byron era.
|
|
18
|
+
*/
|
|
19
|
+
exports.EPOCH_CONFIG_BY_NETWORK = {
|
|
20
|
+
mainnet: { shelleyStartEpoch: 208, shelleyStartSlot: 4_492_800, slotsPerEpoch: 432_000 },
|
|
21
|
+
preprod: { shelleyStartEpoch: 4, shelleyStartSlot: 86_400, slotsPerEpoch: 432_000 },
|
|
22
|
+
preview: { shelleyStartEpoch: 0, shelleyStartSlot: 0, slotsPerEpoch: 86_400 },
|
|
23
|
+
};
|
|
15
24
|
/**
|
|
16
25
|
* Default execution units for Plutus scripts
|
|
17
26
|
* Used when dynamic evaluation is not available
|
|
@@ -54,8 +63,6 @@ exports.ABS_MEM_BUFFER = 5_000;
|
|
|
54
63
|
/**
|
|
55
64
|
* Transaction building constants
|
|
56
65
|
*/
|
|
57
|
-
/** Buffer for witness set CBOR overhead when signing adds ~44 bytes */
|
|
58
|
-
exports.WITNESS_BUFFER_BYTES = 50;
|
|
59
66
|
/** Collateral amount in lovelace (5 ADA) */
|
|
60
67
|
exports.COLLATERAL_LOVELACE = 5000000n;
|
|
61
68
|
/** Fee buffer in lovelace (1 ADA) */
|
|
@@ -134,7 +141,7 @@ exports.TX_HASH_REGEX = /^[a-f0-9]{64}$/;
|
|
|
134
141
|
/**
|
|
135
142
|
* Asset unit Regex - policy ID (56 hex chars) + asset name (0-128 hex chars)
|
|
136
143
|
*/
|
|
137
|
-
exports.ASSET_UNIT_REGEX = /^[a-f0-9]{56}([a-f0-9]{2})
|
|
144
|
+
exports.ASSET_UNIT_REGEX = /^[a-f0-9]{56}([a-f0-9]{2}){0,32}$/; // policy ID (56) + asset name (0-32 bytes per ledger rules -> 0-64 hex chars, even length; total ≤ 120 = String(120) key column)
|
|
138
145
|
/**
|
|
139
146
|
* Pool ID Regex - bech32 with HRP "pool" and 28 bytes payload
|
|
140
147
|
*/
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error codes used throughout the ODATANO backend
|
|
3
|
+
*/
|
|
4
|
+
export declare const ERROR_CODES: {
|
|
5
|
+
/**
|
|
6
|
+
* 400 – Invalid input
|
|
7
|
+
* Indicates that the input provided by the client is invalid (malformed address, invalid transaction hash, etc.)
|
|
8
|
+
*/
|
|
9
|
+
readonly INVALID_INPUT: "ODATANO_INVALID_INPUT";
|
|
10
|
+
/**
|
|
11
|
+
* 404 – Data not found
|
|
12
|
+
* Indicates that the requested resource could not be found (Empty result set Address with no UTxOs, Transaction hash not found, etc.)
|
|
13
|
+
*/
|
|
14
|
+
readonly NOT_FOUND: "ODATANO_NOT_FOUND";
|
|
15
|
+
/**
|
|
16
|
+
* 400 – Insufficient funds/assets
|
|
17
|
+
* Indicates that the address does not have enough funds or assets to complete the transaction
|
|
18
|
+
*/
|
|
19
|
+
readonly INSUFFICIENT_FUNDS: "ODATANO_INSUFFICIENT_FUNDS";
|
|
20
|
+
/**
|
|
21
|
+
* 400 – Transaction validation failed
|
|
22
|
+
* Indicates that the transaction failed validation (wrong signature, tampered CBOR, etc.)
|
|
23
|
+
*/
|
|
24
|
+
readonly TX_VALIDATION_FAILED: "ODATANO_TX_VALIDATION_FAILED";
|
|
25
|
+
/**
|
|
26
|
+
* 400 – Transaction CBOR parse failed
|
|
27
|
+
* Indicates that the provided transaction CBOR could not be decoded
|
|
28
|
+
* (malformed bytes, truncated, not a Cardano Conway tx). Distinct from
|
|
29
|
+
* TX_VALIDATION_FAILED which applies to decoded-but-invalid transactions.
|
|
30
|
+
*/
|
|
31
|
+
readonly TX_PARSE_FAILED: "ODATANO_TX_PARSE_FAILED";
|
|
32
|
+
/**
|
|
33
|
+
* 400 – Plutus script validation failed
|
|
34
|
+
* Indicates that the ledger cleanly rejected the transaction due to script
|
|
35
|
+
* evaluation — e.g. PlutusFailure, CekError, overspent budget, script hash
|
|
36
|
+
* mismatch. Distinct from provider outages (503) and generic tx validation.
|
|
37
|
+
*/
|
|
38
|
+
readonly SCRIPT_VALIDATION_FAILURE: "ODATANO_SCRIPT_VALIDATION_FAILURE";
|
|
39
|
+
/**
|
|
40
|
+
* 409 – Transaction already submitted
|
|
41
|
+
* Indicates that the transaction has already been submitted (duplicate/replay)
|
|
42
|
+
*/
|
|
43
|
+
readonly TX_ALREADY_SUBMITTED: "ODATANO_TX_ALREADY_SUBMITTED";
|
|
44
|
+
/**
|
|
45
|
+
* 429 – Rate limiting
|
|
46
|
+
* indicates temporary unavailability
|
|
47
|
+
*/
|
|
48
|
+
readonly PROVIDER_RATE_LIMITED: "ODATANO_PROVIDER_RATE_LIMITED";
|
|
49
|
+
/**
|
|
50
|
+
* 503 – Upstream / connectivity
|
|
51
|
+
* Indicates that the Cardano data provider is currently unavailable
|
|
52
|
+
*/
|
|
53
|
+
readonly PROVIDER_UNAVAILABLE: "ODATANO_PROVIDER_UNAVAILABLE";
|
|
54
|
+
/**
|
|
55
|
+
* 500 – Internal fallback
|
|
56
|
+
* Indicates an unexpected internal error
|
|
57
|
+
*/
|
|
58
|
+
readonly INTERNAL_ERROR: "ODATANO_INTERNAL_ERROR";
|
|
59
|
+
/**
|
|
60
|
+
* 503 – HSM unavailable
|
|
61
|
+
* Indicates the HSM device or session is not available
|
|
62
|
+
*/
|
|
63
|
+
readonly HSM_UNAVAILABLE: "ODATANO_HSM_UNAVAILABLE";
|
|
64
|
+
/**
|
|
65
|
+
* 500 – HSM signing failed
|
|
66
|
+
* Indicates the HSM signing operation failed
|
|
67
|
+
*/
|
|
68
|
+
readonly HSM_SIGNING_FAILED: "ODATANO_HSM_SIGNING_FAILED";
|
|
69
|
+
/**
|
|
70
|
+
* 400 – HSM not configured
|
|
71
|
+
* Indicates HSM signing was requested but HSM is not configured
|
|
72
|
+
*/
|
|
73
|
+
readonly HSM_NOT_CONFIGURED: "ODATANO_HSM_NOT_CONFIGURED";
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* EnumType representing all possible error codes
|
|
77
|
+
*/
|
|
78
|
+
export type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
|
|
79
|
+
//# sourceMappingURL=error-codes.d.ts.map
|