@odatano/core 2.0.0-rc.19 → 2.0.0-rc.20

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 (119) hide show
  1. package/@cds-models/CardanoAgentService/index.d.ts +1 -5
  2. package/@cds-models/CardanoIndexerService/index.d.ts +51 -2
  3. package/@cds-models/CardanoIndexerService/index.js +7 -0
  4. package/package.json +1 -1
  5. package/src/index.d.ts +4 -10
  6. package/src/index.js +6 -16
  7. package/src/plugin.js +11 -27
  8. package/srv/blockchain/backends/blockfrost-backend.d.ts +29 -131
  9. package/srv/blockchain/backends/blockfrost-backend.js +39 -150
  10. package/srv/blockchain/backends/cardano-backend.d.ts +53 -171
  11. package/srv/blockchain/backends/cardano-backend.js +1 -5
  12. package/srv/blockchain/backends/koios-backend.d.ts +26 -71
  13. package/srv/blockchain/backends/koios-backend.js +50 -132
  14. package/srv/blockchain/backends/ogmios-backend.d.ts +43 -124
  15. package/srv/blockchain/backends/ogmios-backend.js +71 -179
  16. package/srv/blockchain/backends/ogmios-frame-guard.d.ts +12 -57
  17. package/srv/blockchain/backends/ogmios-frame-guard.js +27 -66
  18. package/srv/blockchain/cardano-client.d.ts +43 -216
  19. package/srv/blockchain/cardano-client.js +49 -234
  20. package/srv/blockchain/cardano-indexer.d.ts +79 -357
  21. package/srv/blockchain/cardano-indexer.js +98 -406
  22. package/srv/blockchain/cardano-tx-builder.d.ts +19 -84
  23. package/srv/blockchain/cardano-tx-builder.js +21 -107
  24. package/srv/blockchain/crawler/certificate-backfill.d.ts +45 -0
  25. package/srv/blockchain/crawler/certificate-backfill.js +150 -0
  26. package/srv/blockchain/crawler/crawler.d.ts +41 -145
  27. package/srv/blockchain/crawler/crawler.js +57 -172
  28. package/srv/blockchain/crawler/hooks.d.ts +3 -14
  29. package/srv/blockchain/crawler/index.d.ts +2 -6
  30. package/srv/blockchain/crawler/index.js +4 -9
  31. package/srv/blockchain/crawler/sync-state.d.ts +17 -39
  32. package/srv/blockchain/crawler/sync-state.js +23 -55
  33. package/srv/blockchain/crawler/utxo-set-import.d.ts +5 -22
  34. package/srv/blockchain/crawler/utxo-set-import.js +8 -28
  35. package/srv/blockchain/ledger-state.d.ts +3 -12
  36. package/srv/blockchain/signing/cose-verifier.d.ts +5 -12
  37. package/srv/blockchain/signing/cose-verifier.js +6 -12
  38. package/srv/blockchain/signing/external-signer.d.ts +16 -113
  39. package/srv/blockchain/signing/external-signer.js +19 -122
  40. package/srv/blockchain/signing/hsm-signer.d.ts +13 -45
  41. package/srv/blockchain/signing/hsm-signer.js +23 -63
  42. package/srv/blockchain/signing/signature-verifier.d.ts +8 -44
  43. package/srv/blockchain/signing/signature-verifier.js +13 -54
  44. package/srv/blockchain/signing/submission-finalizer.d.ts +9 -36
  45. package/srv/blockchain/signing/submission-finalizer.js +16 -48
  46. package/srv/blockchain/transaction-building/buildooor-tx.d.ts +65 -174
  47. package/srv/blockchain/transaction-building/buildooor-tx.js +107 -266
  48. package/srv/blockchain/transaction-building/cardano-tx.d.ts +8 -34
  49. package/srv/blockchain/wallet-worker/build-request.d.ts +4 -17
  50. package/srv/blockchain/wallet-worker/build-request.js +9 -22
  51. package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +12 -35
  52. package/srv/blockchain/wallet-worker/confirmation-tracker.js +16 -32
  53. package/srv/blockchain/wallet-worker/index.js +2 -8
  54. package/srv/blockchain/wallet-worker/job-store.d.ts +33 -111
  55. package/srv/blockchain/wallet-worker/job-store.js +0 -0
  56. package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +4 -20
  57. package/srv/blockchain/wallet-worker/lease-heartbeat.js +4 -20
  58. package/srv/blockchain/wallet-worker/signers.d.ts +6 -19
  59. package/srv/blockchain/wallet-worker/signers.js +3 -8
  60. package/srv/blockchain/wallet-worker/wallet-worker.d.ts +15 -71
  61. package/srv/blockchain/wallet-worker/wallet-worker.js +34 -90
  62. package/srv/cardano-agent-service.cds +1 -5
  63. package/srv/cardano-agent-service.js +3 -7
  64. package/srv/cardano-indexer-service.cds +32 -4
  65. package/srv/cardano-indexer-service.js +83 -15
  66. package/srv/cardano-service.js +36 -98
  67. package/srv/cardano-sign-service.cds +1 -1
  68. package/srv/cardano-sign-service.js +55 -173
  69. package/srv/cardano-tx-service.cds +1 -1
  70. package/srv/cardano-tx-service.js +54 -174
  71. package/srv/cardano-worker-service.js +7 -15
  72. package/srv/server.d.ts +27 -86
  73. package/srv/server.js +52 -148
  74. package/srv/utils/agent-grants-config.d.ts +11 -50
  75. package/srv/utils/agent-grants-config.js +12 -45
  76. package/srv/utils/agent-grants.d.ts +34 -123
  77. package/srv/utils/agent-grants.js +57 -156
  78. package/srv/utils/agent-token-auth.d.ts +2 -5
  79. package/srv/utils/agent-token-auth.js +2 -5
  80. package/srv/utils/backend-request-handler.d.ts +2 -16
  81. package/srv/utils/backend-request-handler.js +3 -18
  82. package/srv/utils/collections.d.ts +4 -8
  83. package/srv/utils/collections.js +4 -8
  84. package/srv/utils/const.d.ts +19 -68
  85. package/srv/utils/const.js +20 -69
  86. package/srv/utils/crypto.d.ts +3 -12
  87. package/srv/utils/crypto.js +5 -18
  88. package/srv/utils/db-indexes.d.ts +2 -7
  89. package/srv/utils/db-indexes.js +7 -34
  90. package/srv/utils/db-sanitize.d.ts +5 -18
  91. package/srv/utils/db-sanitize.js +6 -19
  92. package/srv/utils/error-codes.d.ts +18 -73
  93. package/srv/utils/error-codes.js +17 -70
  94. package/srv/utils/errors.d.ts +29 -191
  95. package/srv/utils/errors.js +44 -229
  96. package/srv/utils/liveness.d.ts +2 -9
  97. package/srv/utils/liveness.js +3 -11
  98. package/srv/utils/mappers.d.ts +50 -298
  99. package/srv/utils/mappers.js +80 -386
  100. package/srv/utils/network-context.js +2 -11
  101. package/srv/utils/pg-order-nulls.js +4 -23
  102. package/srv/utils/plutus-placeholders.d.ts +6 -18
  103. package/srv/utils/plutus-placeholders.js +6 -20
  104. package/srv/utils/rate-limiter.d.ts +6 -17
  105. package/srv/utils/rate-limiter.js +5 -15
  106. package/srv/utils/service-events.d.ts +2 -22
  107. package/srv/utils/service-events.js +3 -23
  108. package/srv/utils/signing-helper.d.ts +3 -18
  109. package/srv/utils/signing-helper.js +10 -32
  110. package/srv/utils/tx-build-helper.d.ts +18 -92
  111. package/srv/utils/tx-build-helper.js +32 -123
  112. package/srv/utils/tx-request-parsers.d.ts +7 -26
  113. package/srv/utils/tx-request-parsers.js +7 -26
  114. package/srv/utils/tx-utils.d.ts +4 -23
  115. package/srv/utils/tx-utils.js +12 -41
  116. package/srv/utils/types.d.ts +67 -206
  117. package/srv/utils/types.js +2 -6
  118. package/srv/utils/validators.d.ts +19 -89
  119. package/srv/utils/validators.js +31 -138
@@ -1,94 +1,39 @@
1
- /**
2
- * Error codes used throughout the ODATANO backend
3
- */
1
+ /** Error codes used throughout the backend. */
4
2
  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
- */
3
+ /** 400: malformed client input (address, tx hash, ...). */
9
4
  readonly INVALID_INPUT: "ODATANO_INVALID_INPUT";
10
- /**
11
- * 403 – Caller lacks the required role
12
- * Indicates the caller is authenticated but not authorized for the operation
13
- * (e.g. HSM-backed signing without the configured hsm.requiresRole)
14
- */
5
+ /** 403: authenticated but lacking the required role (e.g. hsm.requiresRole). */
15
6
  readonly FORBIDDEN: "ODATANO_FORBIDDEN";
16
- /**
17
- * 404 – Data not found
18
- * Indicates that the requested resource could not be found (Empty result set Address with no UTxOs, Transaction hash not found, etc.)
19
- */
7
+ /** 404: requested resource not found (unknown tx hash, address without UTxOs, ...). */
20
8
  readonly NOT_FOUND: "ODATANO_NOT_FOUND";
21
- /**
22
- * 400 – Insufficient funds/assets
23
- * Indicates that the address does not have enough funds or assets to complete the transaction
24
- */
9
+ /** 400: address lacks the funds or assets for the transaction. */
25
10
  readonly INSUFFICIENT_FUNDS: "ODATANO_INSUFFICIENT_FUNDS";
26
- /**
27
- * 400 – Transaction validation failed
28
- * Indicates that the transaction failed validation (wrong signature, tampered CBOR, etc.)
29
- */
11
+ /** 400: decoded transaction failed validation (wrong signature, tampered CBOR, ...). */
30
12
  readonly TX_VALIDATION_FAILED: "ODATANO_TX_VALIDATION_FAILED";
31
- /**
32
- * 400 – Transaction CBOR parse failed
33
- * Indicates that the provided transaction CBOR could not be decoded
34
- * (malformed bytes, truncated, not a Cardano Conway tx). Distinct from
35
- * TX_VALIDATION_FAILED which applies to decoded-but-invalid transactions.
36
- */
13
+ /** 400: transaction CBOR could not be decoded (malformed, truncated, not a Conway tx). */
37
14
  readonly TX_PARSE_FAILED: "ODATANO_TX_PARSE_FAILED";
38
- /**
39
- * 400 – Plutus script validation failed
40
- * Indicates that the ledger cleanly rejected the transaction due to script
41
- * evaluation — e.g. PlutusFailure, CekError, overspent budget, script hash
42
- * mismatch. Distinct from provider outages (503) and generic tx validation.
43
- */
15
+ /** 400: ledger rejected the tx on script evaluation (PlutusFailure, CekError, budget, hash mismatch). */
44
16
  readonly SCRIPT_VALIDATION_FAILURE: "ODATANO_SCRIPT_VALIDATION_FAILURE";
45
- /**
46
- * 409 – Transaction already submitted
47
- * Indicates that the transaction has already been submitted (duplicate/replay)
48
- */
17
+ /** 409: transaction already submitted (duplicate / replay). */
49
18
  readonly TX_ALREADY_SUBMITTED: "ODATANO_TX_ALREADY_SUBMITTED";
50
- /**
51
- * 429 – Rate limiting
52
- * indicates temporary unavailability
53
- */
19
+ /** 429: provider rate limit hit. */
54
20
  readonly PROVIDER_RATE_LIMITED: "ODATANO_PROVIDER_RATE_LIMITED";
55
- /**
56
- * 503 – Upstream / connectivity
57
- * Indicates that the Cardano data provider is currently unavailable
58
- */
21
+ /** 503: Cardano data provider unavailable. */
59
22
  readonly PROVIDER_UNAVAILABLE: "ODATANO_PROVIDER_UNAVAILABLE";
60
- /**
61
- * 500 – Internal fallback
62
- * Indicates an unexpected internal error
63
- */
23
+ /** 500: unexpected internal error. */
64
24
  readonly INTERNAL_ERROR: "ODATANO_INTERNAL_ERROR";
65
- /**
66
- * 503 – HSM unavailable
67
- * Indicates the HSM device or session is not available
68
- */
25
+ /** 503: HSM device or session not available. */
69
26
  readonly HSM_UNAVAILABLE: "ODATANO_HSM_UNAVAILABLE";
70
- /**
71
- * 500 – HSM signing failed
72
- * Indicates the HSM signing operation failed
73
- */
27
+ /** 500: HSM signing operation failed. */
74
28
  readonly HSM_SIGNING_FAILED: "ODATANO_HSM_SIGNING_FAILED";
75
- /**
76
- * 400 – HSM not configured
77
- * Indicates HSM signing was requested but HSM is not configured
78
- */
29
+ /** 400: HSM signing requested but HSM not configured. */
79
30
  readonly HSM_NOT_CONFIGURED: "ODATANO_HSM_NOT_CONFIGURED";
80
31
  /**
81
- * 503 – Detached transaction could not begin in time
82
- * The sign-service could not acquire a pooled DB connection for one of its
83
- * detached bookkeeping transactions. Most common cause: an in-process
84
- * consumer awaits SubmitVerifiedTransaction/SignAndSubmitWithHsm while its
85
- * own request transaction holds the (single) pooled sqlite connection —
86
- * see docs/KNOWN_ISSUES.md issue 11.
32
+ * 503: a detached bookkeeping transaction could not acquire a pooled DB connection in time,
33
+ * typically because an in-process caller awaits the action while its own request tx holds the single sqlite connection.
87
34
  */
88
35
  readonly NESTED_TX_TIMEOUT: "ODATANO_NESTED_TX_TIMEOUT";
89
36
  };
90
- /**
91
- * EnumType representing all possible error codes
92
- */
37
+ /** Union of all error code values. */
93
38
  export type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
94
39
  //# sourceMappingURL=error-codes.d.ts.map
@@ -1,92 +1,39 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ERROR_CODES = void 0;
4
- /**
5
- * Error codes used throughout the ODATANO backend
6
- */
4
+ /** Error codes used throughout the backend. */
7
5
  exports.ERROR_CODES = {
8
- /**
9
- * 400 – Invalid input
10
- * Indicates that the input provided by the client is invalid (malformed address, invalid transaction hash, etc.)
11
- */
6
+ /** 400: malformed client input (address, tx hash, ...). */
12
7
  INVALID_INPUT: 'ODATANO_INVALID_INPUT',
13
- /**
14
- * 403 – Caller lacks the required role
15
- * Indicates the caller is authenticated but not authorized for the operation
16
- * (e.g. HSM-backed signing without the configured hsm.requiresRole)
17
- */
8
+ /** 403: authenticated but lacking the required role (e.g. hsm.requiresRole). */
18
9
  FORBIDDEN: 'ODATANO_FORBIDDEN',
19
- /**
20
- * 404 – Data not found
21
- * Indicates that the requested resource could not be found (Empty result set Address with no UTxOs, Transaction hash not found, etc.)
22
- */
10
+ /** 404: requested resource not found (unknown tx hash, address without UTxOs, ...). */
23
11
  NOT_FOUND: 'ODATANO_NOT_FOUND',
24
- /**
25
- * 400 – Insufficient funds/assets
26
- * Indicates that the address does not have enough funds or assets to complete the transaction
27
- */
12
+ /** 400: address lacks the funds or assets for the transaction. */
28
13
  INSUFFICIENT_FUNDS: 'ODATANO_INSUFFICIENT_FUNDS',
29
- /**
30
- * 400 – Transaction validation failed
31
- * Indicates that the transaction failed validation (wrong signature, tampered CBOR, etc.)
32
- */
14
+ /** 400: decoded transaction failed validation (wrong signature, tampered CBOR, ...). */
33
15
  TX_VALIDATION_FAILED: 'ODATANO_TX_VALIDATION_FAILED',
34
- /**
35
- * 400 – Transaction CBOR parse failed
36
- * Indicates that the provided transaction CBOR could not be decoded
37
- * (malformed bytes, truncated, not a Cardano Conway tx). Distinct from
38
- * TX_VALIDATION_FAILED which applies to decoded-but-invalid transactions.
39
- */
16
+ /** 400: transaction CBOR could not be decoded (malformed, truncated, not a Conway tx). */
40
17
  TX_PARSE_FAILED: 'ODATANO_TX_PARSE_FAILED',
41
- /**
42
- * 400 – Plutus script validation failed
43
- * Indicates that the ledger cleanly rejected the transaction due to script
44
- * evaluation — e.g. PlutusFailure, CekError, overspent budget, script hash
45
- * mismatch. Distinct from provider outages (503) and generic tx validation.
46
- */
18
+ /** 400: ledger rejected the tx on script evaluation (PlutusFailure, CekError, budget, hash mismatch). */
47
19
  SCRIPT_VALIDATION_FAILURE: 'ODATANO_SCRIPT_VALIDATION_FAILURE',
48
- /**
49
- * 409 – Transaction already submitted
50
- * Indicates that the transaction has already been submitted (duplicate/replay)
51
- */
20
+ /** 409: transaction already submitted (duplicate / replay). */
52
21
  TX_ALREADY_SUBMITTED: 'ODATANO_TX_ALREADY_SUBMITTED',
53
- /**
54
- * 429 – Rate limiting
55
- * indicates temporary unavailability
56
- */
22
+ /** 429: provider rate limit hit. */
57
23
  PROVIDER_RATE_LIMITED: 'ODATANO_PROVIDER_RATE_LIMITED',
58
- /**
59
- * 503 – Upstream / connectivity
60
- * Indicates that the Cardano data provider is currently unavailable
61
- */
24
+ /** 503: Cardano data provider unavailable. */
62
25
  PROVIDER_UNAVAILABLE: 'ODATANO_PROVIDER_UNAVAILABLE',
63
- /**
64
- * 500 – Internal fallback
65
- * Indicates an unexpected internal error
66
- */
26
+ /** 500: unexpected internal error. */
67
27
  INTERNAL_ERROR: 'ODATANO_INTERNAL_ERROR',
68
- /**
69
- * 503 – HSM unavailable
70
- * Indicates the HSM device or session is not available
71
- */
28
+ /** 503: HSM device or session not available. */
72
29
  HSM_UNAVAILABLE: 'ODATANO_HSM_UNAVAILABLE',
73
- /**
74
- * 500 – HSM signing failed
75
- * Indicates the HSM signing operation failed
76
- */
30
+ /** 500: HSM signing operation failed. */
77
31
  HSM_SIGNING_FAILED: 'ODATANO_HSM_SIGNING_FAILED',
78
- /**
79
- * 400 – HSM not configured
80
- * Indicates HSM signing was requested but HSM is not configured
81
- */
32
+ /** 400: HSM signing requested but HSM not configured. */
82
33
  HSM_NOT_CONFIGURED: 'ODATANO_HSM_NOT_CONFIGURED',
83
34
  /**
84
- * 503 – Detached transaction could not begin in time
85
- * The sign-service could not acquire a pooled DB connection for one of its
86
- * detached bookkeeping transactions. Most common cause: an in-process
87
- * consumer awaits SubmitVerifiedTransaction/SignAndSubmitWithHsm while its
88
- * own request transaction holds the (single) pooled sqlite connection —
89
- * see docs/KNOWN_ISSUES.md issue 11.
35
+ * 503: a detached bookkeeping transaction could not acquire a pooled DB connection in time,
36
+ * typically because an in-process caller awaits the action while its own request tx holds the single sqlite connection.
90
37
  */
91
38
  NESTED_TX_TIMEOUT: 'ODATANO_NESTED_TX_TIMEOUT',
92
39
  };
@@ -1,169 +1,67 @@
1
1
  import { type ErrorCode } from './error-codes';
2
2
  import { Request } from '@sap/cds';
3
- /**
4
- * Backend Errors Implementation
5
- * Defines typed errors for backend communication issues
6
- */
7
- /**
8
- * BackendError Base class for all backend-related errors
9
- */
3
+ /** Typed errors for backend communication and request validation. */
4
+ /** Base class for all backend-related errors. */
10
5
  export declare class BackendError extends Error {
11
6
  readonly statusCode: number;
12
7
  readonly code: ErrorCode;
13
8
  readonly backendName?: string | undefined;
14
9
  readonly originalError?: unknown | undefined;
15
10
  readonly target?: string | undefined;
16
- /** Constructor
17
- * @param message error message string
18
- * @param statusCode error status code
19
- * @param code error code
20
- * @param backendName name of the backend where the error originated
21
- * @param originalError original error object
22
- * @param target target resource (if applicable)
23
- */
24
11
  constructor(message: string, statusCode?: number, code?: ErrorCode, backendName?: string | undefined, originalError?: unknown | undefined, target?: string | undefined);
25
12
  }
26
- /**
27
- * NotFoundError - Resource not found in backend (404)
28
- * This is NOT a provider error - it's a valid response indicating the resource doesn't exist
29
- * Examples: transaction hash not found, address has no UTxOs
30
- */
13
+ /** Resource not found (404); a valid response, not a provider fault. */
31
14
  export declare class NotFoundError extends BackendError {
32
- /** Constructor
33
- * @param resource name of the resource that was not found
34
- * @param backendName name of the backend where the error originated
35
- * @param originalError original error object
36
- */
37
15
  constructor(resource: string, backendName?: string, originalError?: unknown);
38
16
  }
39
- /**
40
- * TransactionValidationError - Transaction failed validation (400)
41
- * Indicates that the transaction failed validation checks
42
- * Examples: wrong signature, tampered CBOR, invalid witnesses
43
- */
17
+ /** Transaction failed validation (400): wrong signature, tampered CBOR, invalid witnesses. `code` may be `TX_PARSE_FAILED`. */
44
18
  export declare class TransactionValidationError extends BackendError {
45
- /** Constructor
46
- * @param message detailed validation failure message
47
- * @param originalError original error object
48
- * @param code optional override (e.g. `TX_PARSE_FAILED` for CBOR decode failures);
49
- * defaults to `TX_VALIDATION_FAILED`.
50
- */
51
19
  constructor(message: string, originalError?: unknown, code?: ErrorCode);
52
20
  }
53
- /**
54
- * ScriptValidationError - Plutus script validation failed on the ledger (400)
55
- * Distinguishes a clean ledger rejection (PlutusFailure, CekError, overspent
56
- * budget, script hash mismatch) from provider outages (503). The transaction
57
- * was well-formed enough to reach phase-2 validation — retrying against a
58
- * different provider will not help; the tx shape itself is the problem.
59
- */
21
+ /** Ledger phase-2 script rejection (400): PlutusFailure, CekError, budget, hash mismatch. Not retryable on another provider. */
60
22
  export declare class ScriptValidationError extends BackendError {
61
- /** Constructor
62
- * @param message detailed script failure message (typically from ledger)
63
- * @param originalError original error object
64
- */
65
23
  constructor(message: string, originalError?: unknown);
66
24
  }
67
- /**
68
- * TransactionAlreadySubmittedError - Transaction already exists (409)
69
- * Indicates that the transaction has already been submitted (duplicate/replay)
70
- * Examples: same txHash already in mempool or on chain
71
- */
25
+ /** Transaction already in mempool or on chain (409). */
72
26
  export declare class TransactionAlreadySubmittedError extends BackendError {
73
27
  readonly txHash: string;
74
- /** Constructor
75
- * @param txHash the transaction hash that was already submitted
76
- * @param originalError original error object
77
- */
78
28
  constructor(txHash: string, originalError?: unknown);
79
29
  }
80
30
  /**
81
- * InsufficientFundsError - Not enough funds or assets available (400)
82
- * Indicates that the address does not have enough of a specific asset to complete the transaction
83
- * Examples: trying to send more ADA than available, not enough native tokens
31
+ * Not enough of an asset for the transaction (400). `required`/`available` are 0n when unknown;
32
+ * `detail` then replaces the amounts in the message.
84
33
  */
85
34
  export declare class InsufficientFundsError extends BackendError {
86
35
  readonly assetUnit: string;
87
36
  readonly required: bigint;
88
37
  readonly available: bigint;
89
- /** Constructor
90
- * @param assetUnit the asset unit that is insufficient (e.g., "lovelace" or "policyId.assetName")
91
- * @param required the required amount (0n when unknown)
92
- * @param available the available amount (0n when unknown)
93
- * @param originalError original error object
94
- * @param detail human-readable cause shown INSTEAD of the amounts — use when
95
- * the amounts are unknown; "required 0, available 0" reads as
96
- * nonsense from the consumer's perspective
97
- */
98
38
  constructor(assetUnit: string, required: bigint, available: bigint, originalError?: unknown, detail?: string);
99
39
  }
100
- /**
101
- * MixedAssetsError - UTxO contains mixed assets when pure ADA is required (400)
102
- * Indicates that a UTxO contains native assets in addition to ADA, but the operation requires ADA-only UTxOs
103
- */
40
+ /** UTxO carries native assets where ADA-only is required (400). `utxoRef` is `txHash#outputIndex`. */
104
41
  export declare class MixedAssetsError extends BackendError {
105
42
  readonly utxoRef: string;
106
43
  readonly assets: string[];
107
- /** Constructor
108
- * @param utxoRef UTxO reference (txHash#outputIndex)
109
- * @param assets list of non-ADA assets found in the UTxO
110
- * @param originalError original error object
111
- */
112
44
  constructor(utxoRef: string, assets: string[], originalError?: unknown);
113
45
  }
114
- /**
115
- * ProviderUnavailableError - Provider unavailable or timeout (503)
116
- * Indicates a temporary issue - retrying may help
117
- * Examples: network timeout, 5xx errors, service down
118
- */
46
+ /** Provider unavailable or timed out (503); retryable. `timeoutMs` is appended to the message. */
119
47
  export declare class ProviderUnavailableError extends BackendError {
120
- /** Constructor
121
- * @param message error message string
122
- * @param backendName name of the backend where the error originated
123
- * @param timeoutMs optional timeout duration in milliseconds
124
- * @param originalError original error object
125
- */
126
48
  constructor(message: string, backendName?: string, timeoutMs?: number, originalError?: unknown);
127
49
  }
128
- /**
129
- * RateLimitError - Provider rate limit exceeded (429)
130
- * Indicates too many requests - client should back off and retry later
131
- * Examples: Blockfrost 10 req/sec limit, Koios tier limits
132
- */
50
+ /** Provider rate limit exceeded (429). `retryAfter` is in seconds. */
133
51
  export declare class RateLimitError extends BackendError {
134
- /** Constructor
135
- * @param message error message string
136
- * @param backendName name of the backend where the error originated
137
- * @param retryAfter optional retry-after duration in seconds
138
- * @param originalError original error object
139
- */
140
52
  constructor(message: string, backendName?: string, retryAfter?: number, originalError?: unknown);
141
53
  }
142
- /**
143
- * AllBackendsFailedError - All backends failed
144
- * Aggregates multiple backend errors and returns the most relevant status
145
- */
54
+ /** Every backend failed; carries the last error's status, or 503 when all were skipped. */
146
55
  export declare class AllBackendsFailedError extends BackendError {
147
56
  readonly errors: BackendError[];
148
- /** Constructor
149
- * @param errors array of backend errors
150
- * @param originalError original error object
151
- */
152
57
  constructor(errors: BackendError[], originalError?: unknown);
153
58
  }
154
59
  /**
155
- * True when the error proves the resource is absent on EVERY backend that was
156
- * consulted: either a direct NotFoundError, or an AllBackendsFailedError whose
157
- * collected per-backend errors are all 404s. CardanoClient's failover wraps
158
- * per-backend errors (including 404s) into AllBackendsFailedError, so callers
159
- * that need "definitively not found" (e.g. the wallet-worker's dropped-tx
160
- * detection) must use this instead of `instanceof NotFoundError`. A mixed
161
- * result (one backend 404, another 500) is NOT proof of absence.
60
+ * True when the resource is absent on every consulted backend: a NotFoundError, or an
61
+ * AllBackendsFailedError whose per-backend errors are all 404. A mixed result is not proof of absence.
162
62
  */
163
63
  export declare function isNotFoundOnAllBackends(err: unknown): boolean;
164
- /**
165
- * HttpErrorLike - Simplified interface for HTTP errors from various libraries
166
- */
64
+ /** Simplified shape of HTTP errors from various client libraries. */
167
65
  export interface HttpErrorLike {
168
66
  message?: string;
169
67
  code?: string;
@@ -181,112 +79,52 @@ export interface HttpErrorLike {
181
79
  }
182
80
  /** True when a PostgREST error body's `code` denotes a provider-side SQL fault. */
183
81
  export declare function isPostgrestServerErrorCode(code: unknown): boolean;
184
- /**
185
- * Utility functions to extract status and message from HttpErrorLike
186
- * @param err error object
187
- * @returns {number} status code
188
- */
82
+ /** HTTP status of an HttpErrorLike, default 500. */
189
83
  export declare function getErrorStatus(err: HttpErrorLike | unknown): number;
190
- /**
191
- * Utility functions to extract status and message from HttpErrorLike
192
- * @param err error object
193
- * @returns {string} error message
194
- */
84
+ /** Message of an HttpErrorLike: `response.data.error` (Koios), else `message`. */
195
85
  export declare function getErrorMessage(err: HttpErrorLike | unknown): string;
196
86
  /**
197
- * Normalizes any backend error into a typed BackendError
198
- *
199
- * Priority (checked in order):
200
- * 1. TX Submission — Already submitted/duplicate → 409
201
- * 2. TX Submission — Plutus script validation failure → 400 (ScriptValidationError)
202
- * 3. TX Submission — Validation/Signature errors → 400
203
- * 4. Message indicates "not found" → 404 (even if provider returns 5xx)
204
- * 5. Rate limiting (status 429 or message patterns) → 429
205
- * 6. Explicit 404 status → 404
206
- * 7. 5xx errors → 503 (Provider unavailable, retry-able)
207
- * 8. Other 4xx → 503
208
- * 9. Unknown/network errors → 503 (default fallback)
87
+ * Normalizes any backend error into a typed BackendError. Message hints are checked in priority
88
+ * order (already submitted, script failure, validation, not found, rate limit) before the HTTP status.
209
89
  */
210
90
  export declare function normalizeBackendError(err: unknown, backendName?: string): BackendError;
211
- /**
212
- * HsmError - Error related to HSM operations (signing, session, key access)
213
- * Indicates that the Hardware Security Module is unavailable or signing failed
214
- */
91
+ /** HSM operation failed (session, key access, signing). */
215
92
  export declare class HsmError extends BackendError {
216
93
  constructor(message: string, statusCode?: number, code?: ErrorCode, originalError?: unknown);
217
94
  }
218
- /**
219
- * ConfigError - Error in configuration settings
220
- * Captures configuration-related issues
221
- */
95
+ /** Configuration error. */
222
96
  export declare class ConfigError extends Error {
223
97
  constructor(message: string);
224
98
  }
225
99
  /**
226
- * ChainSyncFrameError - Ogmios delivered a frame the client cannot turn into an object.
227
- *
228
- * Raised by the frame guard (see `backends/ogmios-frame-guard.ts`) once the client's parser
229
- * and the depth-safe fallback have both failed. The block is named so `lastError` points at
230
- * it instead of leaving an empty status behind, and so the crawler can take that one block
231
- * through the paginating backend instead of waiting on a stream that will never deliver it.
100
+ * Ogmios chain-sync frame that could not be parsed. Names the block (when readable from the raw
101
+ * text) so the crawler can fetch that one block through the paginating backend instead.
232
102
  */
233
103
  export declare class ChainSyncFrameError extends BackendError {
234
104
  readonly height: number | null;
235
105
  readonly id: string | null;
236
- /** Constructor
237
- * @param height block height the frame belonged to, when it could be read off the raw text
238
- * @param id block hash, when readable
239
- * @param reason why the frame could not be parsed
240
- */
241
106
  constructor(height: number | null, id: string | null, reason: string);
242
107
  }
243
- /**
244
- * BackendInitError - Error initializing a specific backend
245
- * Captures backend name and original error
246
- */
108
+ /** A backend failed to initialize. */
247
109
  export declare class BackendInitError extends BackendError {
248
110
  constructor(backendName: string, originalError: unknown);
249
111
  }
250
- /**
251
- * AllBackendsInitFailedError - All backends failed to initialize
252
- * Aggregates multiple backend initialization errors
253
- */
112
+ /** Every backend failed to initialize. */
254
113
  export declare class AllBackendsInitFailedError extends Error {
255
114
  readonly errors: BackendInitError[];
256
115
  constructor(errors: BackendInitError[]);
257
116
  }
258
- /**
259
- * Function to reject requests with standardized error messages
260
- * @param req - The incoming request
261
- * @param ctx - Context string for the error
262
- * @param message - Detailed error message
263
- * @param target - Optional target resource
264
- * @throws {BackendError} BackendError with 400 status code
265
- */
117
+ /** Throws a 400 INVALID_INPUT BackendError `<ctx>: <message>`. */
266
118
  export declare function rejectInvalid(req: Request, ctx: string, message: string, target?: string): never;
267
- /**
268
- * Function to reject requests for missing required fields
269
- * @param req - The incoming request
270
- * @param ctx - Context string for the error
271
- * @param field - Name of the missing field
272
- * @throws {BackendError} BackendError with 400 status code
273
- */
119
+ /** Throws a 400 INVALID_INPUT BackendError for a missing required field. */
274
120
  export declare function rejectMissing(req: Request, ctx: string, field: string): never;
275
- /**
276
- * Validation error from validators.ts
277
- */
121
+ /** Validation error from validators.ts */
278
122
  interface ValidationError {
279
123
  type: 'missing' | 'invalid';
280
124
  field: string;
281
125
  message: string;
282
126
  }
283
- /**
284
- * Throw BackendError for the first validation error in the list
285
- * @param req - The incoming request
286
- * @param ctx - Context string for the error
287
- * @param errors - Array of validation errors from validateTransactionInputs
288
- * @throws {BackendError} if errors array is not empty
289
- */
127
+ /** Throws a BackendError for the first validation error, if any. */
290
128
  export declare function throwIfValidationErrors(req: Request, ctx: string, errors: ValidationError[]): void;
291
129
  export {};
292
130
  //# sourceMappingURL=errors.d.ts.map