@odatano/core 1.11.0 → 2.0.0-rc.2

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 (111) hide show
  1. package/@cds-models/CardanoIndexerService/index.d.ts +142 -0
  2. package/@cds-models/CardanoIndexerService/index.js +23 -0
  3. package/@cds-models/CardanoODataService/index.d.ts +693 -2172
  4. package/@cds-models/CardanoODataService/index.js +88 -390
  5. package/@cds-models/CardanoSignService/index.d.ts +443 -1574
  6. package/@cds-models/CardanoSignService/index.js +62 -293
  7. package/@cds-models/CardanoTransactionService/index.d.ts +431 -1488
  8. package/@cds-models/CardanoTransactionService/index.js +60 -271
  9. package/@cds-models/CardanoWorkerService/index.d.ts +224 -0
  10. package/@cds-models/CardanoWorkerService/index.js +32 -0
  11. package/@cds-models/_/index.d.ts +70 -40
  12. package/@cds-models/_/index.js +17 -32
  13. package/@cds-models/cds/outbox/index.d.ts +28 -0
  14. package/@cds-models/index.d.ts +225 -522
  15. package/@cds-models/index.js +35 -218
  16. package/@cds-models/odatano/cardano/index.d.ts +896 -2947
  17. package/@cds-models/odatano/cardano/index.js +109 -536
  18. package/@cds-models/sap/common/index.d.ts +196 -600
  19. package/@cds-models/sap/common/index.js +28 -269
  20. package/README.md +36 -2
  21. package/db/schema.cds +283 -1
  22. package/db/types.cds +48 -0
  23. package/package.json +173 -164
  24. package/src/index.d.ts +1 -1
  25. package/src/index.js +10 -2
  26. package/src/plugin.js +12 -2
  27. package/srv/blockchain/backends/blockfrost-backend.d.ts +21 -2
  28. package/srv/blockchain/backends/blockfrost-backend.js +68 -15
  29. package/srv/blockchain/backends/cardano-backend.d.ts +69 -0
  30. package/srv/blockchain/backends/cardano-backend.js +13 -0
  31. package/srv/blockchain/backends/koios-backend.d.ts +26 -2
  32. package/srv/blockchain/backends/koios-backend.js +147 -15
  33. package/srv/blockchain/backends/ogmios-backend.d.ts +37 -6
  34. package/srv/blockchain/backends/ogmios-backend.js +254 -5
  35. package/srv/blockchain/cardano-client.d.ts +19 -0
  36. package/srv/blockchain/cardano-client.js +36 -0
  37. package/srv/blockchain/cardano-indexer.d.ts +50 -1
  38. package/srv/blockchain/cardano-indexer.js +191 -0
  39. package/srv/blockchain/crawler/crawler.d.ts +151 -0
  40. package/srv/blockchain/crawler/crawler.js +677 -0
  41. package/srv/blockchain/crawler/hooks.d.ts +43 -0
  42. package/srv/blockchain/crawler/hooks.js +62 -0
  43. package/srv/blockchain/crawler/index.d.ts +26 -0
  44. package/srv/blockchain/crawler/index.js +135 -0
  45. package/srv/blockchain/crawler/sync-state.d.ts +94 -0
  46. package/srv/blockchain/crawler/sync-state.js +265 -0
  47. package/srv/blockchain/signing/hsm-signer.d.ts +45 -0
  48. package/srv/blockchain/signing/hsm-signer.js +8 -1
  49. package/srv/blockchain/wallet-worker/build-request.d.ts +26 -0
  50. package/srv/blockchain/wallet-worker/build-request.js +341 -0
  51. package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +86 -0
  52. package/srv/blockchain/wallet-worker/confirmation-tracker.js +228 -0
  53. package/srv/blockchain/wallet-worker/index.d.ts +14 -0
  54. package/srv/blockchain/wallet-worker/index.js +80 -0
  55. package/srv/blockchain/wallet-worker/job-store.d.ts +261 -0
  56. package/srv/blockchain/wallet-worker/job-store.js +564 -0
  57. package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +43 -0
  58. package/srv/blockchain/wallet-worker/lease-heartbeat.js +99 -0
  59. package/srv/blockchain/wallet-worker/signers.d.ts +57 -0
  60. package/srv/blockchain/wallet-worker/signers.js +131 -0
  61. package/srv/blockchain/wallet-worker/wallet-worker.d.ts +145 -0
  62. package/srv/blockchain/wallet-worker/wallet-worker.js +542 -0
  63. package/srv/cardano-indexer-service.cds +73 -0
  64. package/srv/cardano-indexer-service.d.ts +2 -0
  65. package/srv/cardano-indexer-service.js +76 -0
  66. package/srv/cardano-service.js +76 -5
  67. package/srv/cardano-tx-service.d.ts +1 -11
  68. package/srv/cardano-tx-service.js +11 -162
  69. package/srv/cardano-worker-service.cds +125 -0
  70. package/srv/cardano-worker-service.d.ts +2 -0
  71. package/srv/cardano-worker-service.js +199 -0
  72. package/srv/server.d.ts +32 -1
  73. package/srv/server.js +229 -36
  74. package/srv/utils/collections.d.ts +13 -0
  75. package/srv/utils/collections.js +24 -0
  76. package/srv/utils/crypto.d.ts +16 -0
  77. package/srv/utils/crypto.js +75 -0
  78. package/srv/utils/error-codes.d.ts +6 -0
  79. package/srv/utils/error-codes.js +6 -0
  80. package/srv/utils/errors.d.ts +12 -0
  81. package/srv/utils/errors.js +45 -0
  82. package/srv/utils/mappers.js +13 -3
  83. package/srv/utils/service-events.d.ts +26 -0
  84. package/srv/utils/service-events.js +46 -0
  85. package/srv/utils/tx-request-parsers.d.ts +58 -0
  86. package/srv/utils/tx-request-parsers.js +170 -0
  87. package/srv/utils/tx-utils.d.ts +2 -1
  88. package/srv/utils/tx-utils.js +3 -2
  89. package/srv/utils/types.d.ts +2 -1
  90. package/@cds-models/CardanoODataService/index.d.ts.map +0 -1
  91. package/@cds-models/CardanoODataService/index.js.map +0 -1
  92. package/@cds-models/CardanoODataService/index.ts +0 -776
  93. package/@cds-models/CardanoSignService/index.d.ts.map +0 -1
  94. package/@cds-models/CardanoSignService/index.js.map +0 -1
  95. package/@cds-models/CardanoSignService/index.ts +0 -569
  96. package/@cds-models/CardanoTransactionService/index.d.ts.map +0 -1
  97. package/@cds-models/CardanoTransactionService/index.js.map +0 -1
  98. package/@cds-models/CardanoTransactionService/index.ts +0 -526
  99. package/@cds-models/_/index.d.ts.map +0 -1
  100. package/@cds-models/_/index.js.map +0 -1
  101. package/@cds-models/_/index.ts +0 -96
  102. package/@cds-models/cds/outbox/index.ts +0 -27
  103. package/@cds-models/index.d.ts.map +0 -1
  104. package/@cds-models/index.js.map +0 -1
  105. package/@cds-models/index.ts +0 -245
  106. package/@cds-models/odatano/cardano/index.d.ts.map +0 -1
  107. package/@cds-models/odatano/cardano/index.js.map +0 -1
  108. package/@cds-models/odatano/cardano/index.ts +0 -789
  109. package/@cds-models/sap/common/index.d.ts.map +0 -1
  110. package/@cds-models/sap/common/index.js.map +0 -1
  111. package/@cds-models/sap/common/index.ts +0 -249
@@ -1,270 +1,29 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.Timezones = exports.Timezone = exports.Currencies = exports.Currency = exports.Countries = exports.Country = exports.Languages = exports.Language = exports.FlowHistory_ = exports.FlowHistory = exports.TextsAspect_ = exports.TextsAspect = exports.CodeList_ = exports.CodeList = void 0;
37
- exports._CodeListAspect = _CodeListAspect;
38
- exports._TextsAspectAspect = _TextsAspectAspect;
39
- exports._FlowHistoryAspect = _FlowHistoryAspect;
40
- exports._LanguageAspect = _LanguageAspect;
41
- exports._CountryAspect = _CountryAspect;
42
- exports._CurrencyAspect = _CurrencyAspect;
43
- exports._TimezoneAspect = _TimezoneAspect;
44
1
  // This is an automatically generated file. Please do not change its contents manually!
45
- const __ = __importStar(require("./../../_"));
46
- // the following represents the CDS aspect 'CodeList'
47
- function _CodeListAspect(Base) {
48
- return class CodeList extends Base {
49
- static kind = 'aspect';
50
- };
51
- }
52
- /**
53
- * Aspect for a code list with name and description
54
- *
55
- * See https://cap.cloud.sap/docs/cds/common#aspect-codelist
56
- */
57
- class CodeList extends _CodeListAspect(__.Entity) {
58
- }
59
- exports.CodeList = CodeList;
60
- /**
61
- * Aspect for a code list with name and description
62
- *
63
- * See https://cap.cloud.sap/docs/cds/common#aspect-codelist
64
- */
65
- class CodeList_ extends Array {
66
- $count;
67
- }
68
- exports.CodeList_ = CodeList_;
69
- Object.defineProperty(CodeList_, 'name', { value: 'sap.common.CodeList' });
70
- // the following represents the CDS aspect 'TextsAspect'
71
- function _TextsAspectAspect(Base) {
72
- return class TextsAspect extends Base {
73
- static kind = 'aspect';
74
- };
75
- }
76
- class TextsAspect extends _TextsAspectAspect(__.Entity) {
77
- }
78
- exports.TextsAspect = TextsAspect;
79
- class TextsAspect_ extends Array {
80
- $count;
81
- }
82
- exports.TextsAspect_ = TextsAspect_;
83
- Object.defineProperty(TextsAspect_, 'name', { value: 'sap.common.TextsAspect' });
84
- // the following represents the CDS aspect 'FlowHistory'
85
- function _FlowHistoryAspect(Base) {
86
- return class FlowHistory extends Base {
87
- static kind = 'aspect';
88
- };
89
- }
90
- class FlowHistory extends _FlowHistoryAspect(__.Entity) {
91
- }
92
- exports.FlowHistory = FlowHistory;
93
- class FlowHistory_ extends Array {
94
- $count;
95
- }
96
- exports.FlowHistory_ = FlowHistory_;
97
- Object.defineProperty(FlowHistory_, 'name', { value: 'sap.common.FlowHistory' });
98
- function _LanguageAspect(Base) {
99
- return class Language extends _CodeListAspect(Base) {
100
- static kind = 'entity';
101
- };
102
- }
103
- /**
104
- * Code list for languages
105
- *
106
- * See https://cap.cloud.sap/docs/cds/common#entity-languages
107
- */
108
- class Language extends _LanguageAspect(__.Entity) {
109
- }
110
- exports.Language = Language;
111
- Object.defineProperty(Language, 'name', { value: 'sap.common.Languages' });
112
- Object.defineProperty(Language, 'is_singular', { value: true });
113
- /**
114
- * Code list for languages
115
- *
116
- * See https://cap.cloud.sap/docs/cds/common#entity-languages
117
- */
118
- class Languages extends Array {
119
- $count;
120
- }
121
- exports.Languages = Languages;
122
- Object.defineProperty(Languages, 'name', { value: 'sap.common.Languages' });
123
- function _CountryAspect(Base) {
124
- return class Country extends _CodeListAspect(Base) {
125
- static kind = 'entity';
126
- };
127
- }
128
- /**
129
- * Code list for countries
130
- *
131
- * See https://cap.cloud.sap/docs/cds/common#entity-countries
132
- */
133
- class Country extends _CountryAspect(__.Entity) {
134
- }
135
- exports.Country = Country;
136
- Object.defineProperty(Country, 'name', { value: 'sap.common.Countries' });
137
- Object.defineProperty(Country, 'is_singular', { value: true });
138
- /**
139
- * Code list for countries
140
- *
141
- * See https://cap.cloud.sap/docs/cds/common#entity-countries
142
- */
143
- class Countries extends Array {
144
- $count;
145
- }
146
- exports.Countries = Countries;
147
- Object.defineProperty(Countries, 'name', { value: 'sap.common.Countries' });
148
- function _CurrencyAspect(Base) {
149
- return class Currency extends _CodeListAspect(Base) {
150
- static kind = 'entity';
151
- };
152
- }
153
- /**
154
- * Code list for currencies
155
- *
156
- * See https://cap.cloud.sap/docs/cds/common#entity-currencies
157
- */
158
- class Currency extends _CurrencyAspect(__.Entity) {
159
- }
160
- exports.Currency = Currency;
161
- Object.defineProperty(Currency, 'name', { value: 'sap.common.Currencies' });
162
- Object.defineProperty(Currency, 'is_singular', { value: true });
163
- /**
164
- * Code list for currencies
165
- *
166
- * See https://cap.cloud.sap/docs/cds/common#entity-currencies
167
- */
168
- class Currencies extends Array {
169
- $count;
170
- }
171
- exports.Currencies = Currencies;
172
- Object.defineProperty(Currencies, 'name', { value: 'sap.common.Currencies' });
173
- function _TimezoneAspect(Base) {
174
- return class Timezone extends _CodeListAspect(Base) {
175
- static kind = 'entity';
176
- };
177
- }
178
- /**
179
- * Code list for time zones
180
- *
181
- * See https://cap.cloud.sap/docs/cds/common#entity-timezones
182
- */
183
- class Timezone extends _TimezoneAspect(__.Entity) {
184
- }
185
- exports.Timezone = Timezone;
186
- Object.defineProperty(Timezone, 'name', { value: 'sap.common.Timezones' });
187
- Object.defineProperty(Timezone, 'is_singular', { value: true });
188
- /**
189
- * Code list for time zones
190
- *
191
- * See https://cap.cloud.sap/docs/cds/common#entity-timezones
192
- */
193
- class Timezones extends Array {
194
- $count;
195
- }
196
- exports.Timezones = Timezones;
197
- Object.defineProperty(Timezones, 'name', { value: 'sap.common.Timezones' });
198
- (function (Languages) {
199
- function _textAspect(Base) {
200
- return class text extends _TextsAspectAspect(Base) {
201
- static kind = 'entity';
202
- };
203
- }
204
- Languages._textAspect = _textAspect;
205
- class text extends _textAspect(__.Entity) {
206
- }
207
- Languages.text = text;
208
- Object.defineProperty(text, 'name', { value: 'sap.common.Languages.texts' });
209
- Object.defineProperty(text, 'is_singular', { value: true });
210
- class texts extends Array {
211
- $count;
212
- }
213
- Languages.texts = texts;
214
- Object.defineProperty(texts, 'name', { value: 'sap.common.Languages.texts' });
215
- })(Languages || (exports.Languages = Languages = {}));
216
- (function (Countries) {
217
- function _textAspect(Base) {
218
- return class text extends _TextsAspectAspect(Base) {
219
- static kind = 'entity';
220
- };
221
- }
222
- Countries._textAspect = _textAspect;
223
- class text extends _textAspect(__.Entity) {
224
- }
225
- Countries.text = text;
226
- Object.defineProperty(text, 'name', { value: 'sap.common.Countries.texts' });
227
- Object.defineProperty(text, 'is_singular', { value: true });
228
- class texts extends Array {
229
- $count;
230
- }
231
- Countries.texts = texts;
232
- Object.defineProperty(texts, 'name', { value: 'sap.common.Countries.texts' });
233
- })(Countries || (exports.Countries = Countries = {}));
234
- (function (Currencies) {
235
- function _textAspect(Base) {
236
- return class text extends _TextsAspectAspect(Base) {
237
- static kind = 'entity';
238
- };
239
- }
240
- Currencies._textAspect = _textAspect;
241
- class text extends _textAspect(__.Entity) {
242
- }
243
- Currencies.text = text;
244
- Object.defineProperty(text, 'name', { value: 'sap.common.Currencies.texts' });
245
- Object.defineProperty(text, 'is_singular', { value: true });
246
- class texts extends Array {
247
- $count;
248
- }
249
- Currencies.texts = texts;
250
- Object.defineProperty(texts, 'name', { value: 'sap.common.Currencies.texts' });
251
- })(Currencies || (exports.Currencies = Currencies = {}));
252
- (function (Timezones) {
253
- function _textAspect(Base) {
254
- return class text extends _TextsAspectAspect(Base) {
255
- static kind = 'entity';
256
- };
257
- }
258
- Timezones._textAspect = _textAspect;
259
- class text extends _textAspect(__.Entity) {
260
- }
261
- Timezones.text = text;
262
- Object.defineProperty(text, 'name', { value: 'sap.common.Timezones.texts' });
263
- Object.defineProperty(text, 'is_singular', { value: true });
264
- class texts extends Array {
265
- $count;
266
- }
267
- Timezones.texts = texts;
268
- Object.defineProperty(texts, 'name', { value: 'sap.common.Timezones.texts' });
269
- })(Timezones || (exports.Timezones = Timezones = {}));
270
- //# sourceMappingURL=index.js.map
2
+ const { createEntityProxy } = require('./../../_')
3
+ // Languages
4
+ module.exports.Language = createEntityProxy(['sap.common', 'Languages'], { target: { is_singular: true } })
5
+ module.exports.Languages = createEntityProxy(['sap.common', 'Languages'], { target: { is_singular: false }})
6
+ // Countries
7
+ module.exports.Country = createEntityProxy(['sap.common', 'Countries'], { target: { is_singular: true } })
8
+ module.exports.Countries = createEntityProxy(['sap.common', 'Countries'], { target: { is_singular: false }})
9
+ // Currencies
10
+ module.exports.Currency = createEntityProxy(['sap.common', 'Currencies'], { target: { is_singular: true } })
11
+ module.exports.Currencies = createEntityProxy(['sap.common', 'Currencies'], { target: { is_singular: false }})
12
+ // Timezones
13
+ module.exports.Timezone = createEntityProxy(['sap.common', 'Timezones'], { target: { is_singular: true } })
14
+ module.exports.Timezones = createEntityProxy(['sap.common', 'Timezones'], { target: { is_singular: false }})
15
+ // Languages.texts
16
+ module.exports.Languages.text = createEntityProxy(['sap.common', 'Languages.texts'], { target: { is_singular: true } })
17
+ module.exports.Languages.texts = createEntityProxy(['sap.common', 'Languages.texts'], { target: { is_singular: false }})
18
+ // Countries.texts
19
+ module.exports.Countries.text = createEntityProxy(['sap.common', 'Countries.texts'], { target: { is_singular: true } })
20
+ module.exports.Countries.texts = createEntityProxy(['sap.common', 'Countries.texts'], { target: { is_singular: false }})
21
+ // Currencies.texts
22
+ module.exports.Currencies.text = createEntityProxy(['sap.common', 'Currencies.texts'], { target: { is_singular: true } })
23
+ module.exports.Currencies.texts = createEntityProxy(['sap.common', 'Currencies.texts'], { target: { is_singular: false }})
24
+ // Timezones.texts
25
+ module.exports.Timezones.text = createEntityProxy(['sap.common', 'Timezones.texts'], { target: { is_singular: true } })
26
+ module.exports.Timezones.texts = createEntityProxy(['sap.common', 'Timezones.texts'], { target: { is_singular: false }})
27
+ // events
28
+ // actions
29
+ // enums
package/README.md CHANGED
@@ -30,19 +30,28 @@ npm install @odatano/core @cap-js/sqlite
30
30
  "db": { "kind": "sqlite" },
31
31
  "odatano-core": {
32
32
  "network": "preview",
33
- "backends": ["blockfrost"],
34
- "blockfrostApiKey": "preview_your_api_key_here"
33
+ "backends": ["blockfrost"]
35
34
  }
36
35
  }
37
36
  }
38
37
  }
39
38
  ```
40
39
 
40
+ Put your API key in a `.env` file in the project root (loaded automatically by `cds serve` / `cds watch`) — don't commit it to `package.json`:
41
+
42
+ ```bash
43
+ # .env
44
+ BLOCKFROST_API_KEY=preview_your_api_key_here
45
+ ```
46
+
41
47
  ```bash
42
48
  cds deploy --to sqlite
43
49
  cds serve
44
50
  ```
45
51
 
52
+ > Config in `cds.requires.odatano-core` takes precedence over environment
53
+ > variables; a `blockfrostApiKey` set there would override the `.env` value.
54
+
46
55
  > **Self-hosted Blockfrost-compatible node?** (Dolos MiniBF, Demeter Self-Hosted)
47
56
  > Set `blockfrostCustomBackend` to the node's base URL (e.g. `http://localhost:3010/api/v0`).
48
57
  > When set, `blockfrostApiKey` becomes optional. See the [Backend Configuration Guide](docs/guides/BACKEND_CONFIGURATION.md#self-hosted-blockfrost-compatible-backends).
@@ -80,6 +89,31 @@ Service available at `http://localhost:4004`. See the [Quick Start Guide](docs/Q
80
89
  >
81
90
  > Production needs the `[production]` profile (`NODE_ENV=production`), which switches to `auth: xsuaa`. Don't expose a dev-mode instance. See the [Security Guide](docs/guides/SECURITY_GUIDE.md#authentication-xsuaa).
82
91
 
92
+ ## Services
93
+
94
+ | Service | Path | Purpose |
95
+ |---|---|---|
96
+ | CardanoODataService | `/odata/v4/cardano-odata/` | Read blockchain data (20 entities, 19 actions) |
97
+ | CardanoTransactionService | `/odata/v4/cardano-transaction/` | Build & submit transactions (13 actions) |
98
+ | CardanoSignService | `/odata/v4/cardano-sign/` | External signing + HSM (9 actions) |
99
+ | CardanoIndexerService | `/odata/v4/cardano-indexer/` | Chain crawler / pre-sync control (v2.0, off by default) |
100
+ | CardanoWorkerService | `/odata/v4/cardano-worker/` | Asynchronous wallet jobs (v2.0, off by default) |
101
+
102
+ Both v2.0 services also publish **CAP events**, so a consumer can subscribe instead of polling —
103
+ in-process, no broker required:
104
+
105
+ ```js
106
+ (await cds.connect.to('CardanoWorkerService')).on('jobConfirmed', ({ data }) => …)
107
+ (await cds.connect.to('CardanoIndexerService')).on('blockIndexed', ({ data }) => …)
108
+ ```
109
+
110
+ ## Requirements
111
+
112
+ - **Node.js >= 22.5** and **@sap/cds >= 10** (peer dependency). CAP 9 hosts cannot load `@odatano/core@2`.
113
+ - Upgrading a consumer from 1.x: run **`cds deploy`**. 2.0 adds four tables (`CardanoSyncState`,
114
+ `CardanoReorgLog`, `CardanoWorkerWallets`, `CardanoWalletJobs`) plus a `dedupKey` column; without
115
+ the redeploy the new services answer `no such table` while the old ones keep working.
116
+
83
117
  ## Documentation
84
118
 
85
119
  | Guide | Description |
package/db/schema.cds CHANGED
@@ -1,5 +1,5 @@
1
1
  using {temporal, } from '@sap/cds/common';
2
- using {Lovelace, Blake2b224, Blake2b256, HexBytes, Bech32, AssetUnit, AssetSlice, SigningStatus,SubmissionStatus, UTxODataSlice, MetadataLabel} from '../db/types';
2
+ using {Lovelace, Blake2b224, Blake2b256, HexBytes, Bech32, AssetUnit, AssetSlice, SigningStatus,SubmissionStatus, UTxODataSlice, MetadataLabel, CrawlSyncStatus, ReorgStatus, WalletJobStatus, WalletJobKind, WorkerSignerType} from '../db/types';
3
3
 
4
4
  namespace odatano.cardano;
5
5
 
@@ -74,6 +74,10 @@ entity Blocks {
74
74
  epoch : Association to Epochs
75
75
  on epoch.epoch = $self.epochNumber;
76
76
 
77
+ @title : 'Block Absolute Slot'
78
+ @description: 'Absolute slot number of the block'
79
+ slot : Integer64;
80
+
77
81
  @title : 'Block Slot within Epoch'
78
82
  @description: 'Slot number within the epoch as integer'
79
83
  epochSlot : Integer;
@@ -1349,3 +1353,281 @@ entity SignatureVerifications {
1349
1353
  @description: 'Timestamp when the verification was performed'
1350
1354
  verifiedAt : Timestamp;
1351
1355
  }
1356
+
1357
+ // -----------------------------------------------------
1358
+ // Chain Crawler / Pre-Sync (v2.0)
1359
+ // -----------------------------------------------------
1360
+
1361
+ @title : 'Cardano Sync State'
1362
+ @description: 'Singleton crawl cursor tracking the pre-sync progress of the chain crawler'
1363
+ entity CardanoSyncState {
1364
+
1365
+ @title : 'Cursor Id (Key)'
1366
+ @description: 'Singleton key — always the literal string SINGLETON'
1367
+ key ID : String(10) default 'SINGLETON';
1368
+
1369
+ @title : 'Network'
1370
+ @description: 'The Cardano network this cursor tracks (mainnet | preprod | preview)'
1371
+ network : String(10);
1372
+
1373
+ @title : 'Start Slot'
1374
+ @description: 'Absolute slot of the configured pre-sync origin (immutable once syncing starts)'
1375
+ startSlot : Integer64;
1376
+
1377
+ @title : 'Start Block Hash'
1378
+ @description: 'Block hash of the configured pre-sync origin'
1379
+ startBlockHash : Blake2b256;
1380
+
1381
+ @title : 'Last Slot'
1382
+ @description: 'Absolute slot of the last indexed block (resume point)'
1383
+ lastSlot : Integer64 default 0;
1384
+
1385
+ @title : 'Last Block Hash'
1386
+ @description: 'Hash of the last indexed block — used for the reorg parent-hash check'
1387
+ lastBlockHash : Blake2b256;
1388
+
1389
+ @title : 'Last Height'
1390
+ @description: 'Block height of the last indexed block'
1391
+ lastHeight : Integer64 default 0;
1392
+
1393
+ @title : 'Last Indexed At'
1394
+ @description: 'Wall-clock timestamp of the last successful block persist'
1395
+ lastIndexedAt : Timestamp;
1396
+
1397
+ @title : 'Tip Slot'
1398
+ @description: 'Latest known chain-tip slot, for lag/progress calculation'
1399
+ tipSlot : Integer64;
1400
+
1401
+ @title : 'Tip Height'
1402
+ @description: 'Latest known chain-tip height'
1403
+ tipHeight : Integer64;
1404
+
1405
+ @title : 'Sync Status'
1406
+ @description: 'Current crawler state (stopped | syncing | synced | error)'
1407
+ syncStatus : CrawlSyncStatus default 'stopped';
1408
+
1409
+ // NOTE: live progress is computed by CardanoIndexerService.getStatus from
1410
+ // lastHeight/tipHeight — deliberately NOT persisted here (a stored copy went
1411
+ // stale immediately and misled OData readers).
1412
+
1413
+ @title : 'Last Error'
1414
+ @description: 'Message of the most recent crawler error (null when healthy)'
1415
+ lastError : String(500);
1416
+
1417
+ @title : 'Last Error At'
1418
+ @description: 'Timestamp of the most recent crawler error'
1419
+ lastErrorAt : Timestamp;
1420
+
1421
+ @title : 'Consecutive Errors'
1422
+ @description: 'Count of back-to-back failures; trips the circuit breaker past its threshold'
1423
+ consecutiveErrors : Integer default 0;
1424
+
1425
+ @title : 'Crawler Desired Running State'
1426
+ @description: 'Cluster-wide operator intent. False fences every crawler instance before its next write.'
1427
+ desiredRunning : Boolean default true;
1428
+
1429
+ @title : 'Crawler Lease Owner'
1430
+ @description: 'Opaque process identifier of the single crawler instance currently allowed to write'
1431
+ leaseOwner : String(128);
1432
+
1433
+ @title : 'Crawler Lease Expiry'
1434
+ @description: 'Lease deadline renewed by the active crawler; another instance may take over only after this time'
1435
+ leaseUntil : Timestamp;
1436
+ }
1437
+
1438
+ @title : 'Cardano Reorg Log'
1439
+ @description: 'Audit trail of chain rollbacks (reorgs) handled by the crawler'
1440
+ entity CardanoReorgLog {
1441
+
1442
+ @title : 'Reorg Id (Key)'
1443
+ @description: 'Unique identifier of the reorg event'
1444
+ key ID : UUID;
1445
+
1446
+ @title : 'Detected At'
1447
+ @description: 'Timestamp when the rollback was detected'
1448
+ detectedAt : Timestamp;
1449
+
1450
+ @title : 'Fork Slot'
1451
+ @description: 'Absolute slot of the common ancestor the chain rolled back to'
1452
+ forkSlot : Integer64;
1453
+
1454
+ @title : 'Fork Height'
1455
+ @description: 'Block height of the common ancestor the chain rolled back to'
1456
+ forkHeight : Integer64;
1457
+
1458
+ @title : 'Old Tip Hash'
1459
+ @description: 'Hash of the abandoned tip before the rollback'
1460
+ oldTipHash : Blake2b256;
1461
+
1462
+ @title : 'New Tip Hash'
1463
+ @description: 'Hash of the block the chain rolled back to'
1464
+ newTipHash : Blake2b256;
1465
+
1466
+ @title : 'Blocks Rolled Back'
1467
+ @description: 'Number of blocks (and their child rows) deleted during rollback'
1468
+ blocksRolledBack : Integer;
1469
+
1470
+ @title : 'Status'
1471
+ @description: 'Lifecycle of the reorg handling (detected | rolling_back | reindexing | completed)'
1472
+ status : ReorgStatus;
1473
+ }
1474
+
1475
+ // -----------------------------------------------------
1476
+ // Wallet Worker / Job Engine (v2.1)
1477
+ // -----------------------------------------------------
1478
+
1479
+ @title : 'Cardano Worker Wallets'
1480
+ @description: 'Operator-registered server-side wallets the wallet worker executes jobs from. No key material is ever stored here.'
1481
+ entity CardanoWorkerWallets {
1482
+
1483
+ @title : 'Wallet Id (Key)'
1484
+ @description: 'Stable operator-chosen handle used in job requests'
1485
+ key walletId : String(50);
1486
+
1487
+ @title : 'Signer Type'
1488
+ @description: 'How this wallet signs (hsm | software)'
1489
+ signerType : WorkerSignerType;
1490
+
1491
+ @title : 'Address'
1492
+ @description: 'Bech32 address derived from the signing key at worker init (informational)'
1493
+ address : Bech32;
1494
+
1495
+ @title : 'Public Key Hash'
1496
+ @description: 'Blake2b-224 hash of the wallet verification key'
1497
+ publicKeyHash : Blake2b224;
1498
+
1499
+ @title : 'Enabled'
1500
+ @description: 'Disabled wallets accept no new jobs and are skipped by the dispatch loop'
1501
+ enabled : Boolean default true;
1502
+
1503
+ @title : 'Wallet Lease Owner'
1504
+ @description: 'Opaque process identifier of the single worker instance currently allowed to execute jobs for this wallet'
1505
+ leaseOwner : String(128);
1506
+
1507
+ @title : 'Wallet Lease Expiry'
1508
+ @description: 'Lease deadline renewed by the executing worker; another instance may take over only after this time'
1509
+ leaseUntil : Timestamp;
1510
+
1511
+ @title : 'Last Job At'
1512
+ @description: 'Timestamp of the most recent job execution for this wallet'
1513
+ lastJobAt : Timestamp;
1514
+
1515
+ @title : 'Jobs Confirmed'
1516
+ @description: 'Rolling count of jobs that reached confirmed state'
1517
+ jobsConfirmed : Integer64 default 0;
1518
+
1519
+ @title : 'Jobs Failed'
1520
+ @description: 'Rolling count of jobs that reached failed state'
1521
+ jobsFailed : Integer64 default 0;
1522
+ }
1523
+
1524
+ @title : 'Cardano Wallet Jobs'
1525
+ @description: 'Asynchronous transaction jobs executed by the wallet worker (build → sign → submit → confirm)'
1526
+ // Idempotency is enforced by the DATABASE, not by a read-before-insert check:
1527
+ // concurrent retries of the same key (two app instances, or two HANA sessions)
1528
+ // can both find no existing job and both insert. The unique constraint makes one
1529
+ // of them lose, and insertJob returns the winner's job to it. See `dedupKey`.
1530
+ // Generates a table UNIQUE constraint on SQLite and a UNIQUE INVERTED INDEX on HANA.
1531
+ @assert.unique.dedup: [
1532
+ walletId,
1533
+ kind,
1534
+ dedupKey
1535
+ ]
1536
+ entity CardanoWalletJobs {
1537
+
1538
+ @title : 'Job Id (Key)'
1539
+ @description: 'Unique identifier of the job, returned by SubmitWalletJob'
1540
+ key ID : UUID;
1541
+
1542
+ @title : 'Wallet Id'
1543
+ @description: 'The worker wallet this job executes from'
1544
+ walletId : String(50);
1545
+
1546
+ @title : 'Job Kind'
1547
+ @description: 'Transaction kind (simpleAda | metadata | multiAsset | mint | plutusSpend | submitSigned)'
1548
+ kind : WalletJobKind;
1549
+
1550
+ @title : 'Status'
1551
+ @description: 'Job lifecycle state (pending | building | submitting | submitted | confirmed | failed | cancelled)'
1552
+ status : WalletJobStatus default 'pending';
1553
+
1554
+ @title : 'Idempotency Key'
1555
+ @description: 'Optional caller-supplied dedup key — a non-failed job with the same (walletId, kind, idempotencyKey) is returned instead of creating a new one'
1556
+ idempotencyKey : String(100);
1557
+
1558
+ @title : 'Dedup Key (internal)'
1559
+ @description: 'Backing value of the unique (walletId, kind, dedupKey) constraint: the caller idempotency key while the job holds it, otherwise the job ID (unique by construction). Keyless jobs and terminated jobs therefore never collide — no reliance on NULL semantics, which differ across databases.'
1560
+ dedupKey : String(100);
1561
+
1562
+ @title : 'Request'
1563
+ @description: 'The build-action payload as JSON, verbatim (validated before insert; never contains key material)'
1564
+ request : LargeString;
1565
+
1566
+ @title : 'Priority'
1567
+ @description: 'Dispatch order within a wallet queue — lower runs sooner (default 100)'
1568
+ priority : Integer default 100;
1569
+
1570
+ @title : 'Not Before'
1571
+ @description: 'Optional earliest execution time (one-shot scheduling)'
1572
+ notBefore : Timestamp;
1573
+
1574
+ @title : 'Attempt'
1575
+ @description: 'Number of execution attempts made so far'
1576
+ attempt : Integer default 0;
1577
+
1578
+ @title : 'Max Attempts'
1579
+ @description: 'Bound for transient-failure retries (build/submit); deterministic rejections fail immediately'
1580
+ maxAttempts : Integer default 3;
1581
+
1582
+ @title : 'Transaction Hash'
1583
+ @description: 'Hash of the signed transaction — persisted before the submit call (status submitting), so a crash mid-submit stays reconcilable'
1584
+ txHash : Blake2b256;
1585
+
1586
+ @title : 'Unsigned Transaction CBOR'
1587
+ @description: 'The built unsigned transaction, kept for diagnosis until the job confirms'
1588
+ unsignedTxCbor : LargeString;
1589
+
1590
+ @title : 'Signed Transaction CBOR'
1591
+ @description: 'The signed transaction, stored before submission — reused verbatim for crash reconciliation and rollback re-submission (never rebuilt)'
1592
+ signedTxCbor : LargeString;
1593
+
1594
+ @title : 'Fee'
1595
+ @description: 'Transaction fee in lovelace, from the build result'
1596
+ fee : Lovelace;
1597
+
1598
+ @title : 'Submitted At'
1599
+ @description: 'Timestamp of the submission attempt (written with the signed tx, before it is sent) — the base for the confirmation timeout'
1600
+ submittedAt : Timestamp;
1601
+
1602
+ @title : 'Confirmed At'
1603
+ @description: 'Timestamp when the configured confirmation depth was reached'
1604
+ confirmedAt : Timestamp;
1605
+
1606
+ @title : 'Confirmed Slot'
1607
+ @description: 'Absolute slot of the block containing the transaction — used for reorg checks'
1608
+ confirmedSlot : Integer64;
1609
+
1610
+ @title : 'Confirmed Height'
1611
+ @description: 'Block height of the block containing the transaction — used for depth calculation'
1612
+ confirmedHeight : Integer64;
1613
+
1614
+ @title : 'Error Code'
1615
+ @description: 'Machine-readable code of the terminal failure (null while healthy)'
1616
+ errorCode : String(50);
1617
+
1618
+ @title : 'Error Message'
1619
+ @description: 'Human-readable message of the terminal failure'
1620
+ errorMessage : String(500);
1621
+
1622
+ @title : 'Created At'
1623
+ @description: 'Timestamp the job was accepted'
1624
+ createdAt : Timestamp;
1625
+
1626
+ @title : 'Created By'
1627
+ @description: 'User id of the caller that submitted the job'
1628
+ createdBy : String(100);
1629
+
1630
+ @title : 'Finished At'
1631
+ @description: 'Timestamp the job reached a terminal state (confirmed | failed | cancelled)'
1632
+ finishedAt : Timestamp;
1633
+ }