@odatano/core 2.0.0-rc.23 → 2.0.0-rc.24
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/CardanoBackendService/index.d.ts +357 -0
- package/@cds-models/CardanoBackendService/index.js +40 -0
- package/package.json +3 -2
- package/srv/blockchain/backends/odatano-backend.d.ts +59 -0
- package/srv/blockchain/backends/odatano-backend.js +154 -0
- package/srv/blockchain/cardano-client.d.ts +12 -4
- package/srv/blockchain/cardano-client.js +27 -10
- package/srv/blockchain/cardano-indexer.d.ts +20 -2
- package/srv/blockchain/cardano-indexer.js +75 -15
- package/srv/blockchain/cardano-tx-builder.js +2 -2
- package/srv/blockchain/stored-chain.d.ts +30 -0
- package/srv/blockchain/stored-chain.js +208 -0
- package/srv/cardano-backend-service.cds +52 -0
- package/srv/cardano-backend-service.d.ts +2 -0
- package/srv/cardano-backend-service.js +217 -0
- package/srv/server.js +16 -1
- package/srv/utils/agent-grants.js +7 -0
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
// This is an automatically generated file. Please do not change its contents manually!
|
|
2
|
+
import * as __ from './../_';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Cardano Backend Service
|
|
6
|
+
*
|
|
7
|
+
* The data a CardanoBackend needs, for another ODATANO instance that uses this one as its
|
|
8
|
+
* backend (`backends: ["odatano"]`). Every operation answers the provider shape as a JSON
|
|
9
|
+
* string (`value`), so the caller maps it exactly like a Koios or Blockfrost answer.
|
|
10
|
+
* Stored blocks and transactions come from this instance's index; everything else goes
|
|
11
|
+
* through its own backends and crawled data, as the read service does. Nothing is persisted
|
|
12
|
+
* for the caller.
|
|
13
|
+
*/
|
|
14
|
+
export default class {
|
|
15
|
+
static readonly GetTransaction: typeof GetTransaction;
|
|
16
|
+
static readonly GetTransactionsBatch: typeof GetTransactionsBatch;
|
|
17
|
+
static readonly GetTransactionMetadata: typeof GetTransactionMetadata;
|
|
18
|
+
static readonly GetBlock: typeof GetBlock;
|
|
19
|
+
static readonly GetBlockByHeight: typeof GetBlockByHeight;
|
|
20
|
+
static readonly GetNextBlocks: typeof GetNextBlocks;
|
|
21
|
+
static readonly GetBlockTransactions: typeof GetBlockTransactions;
|
|
22
|
+
static readonly GetLatestBlock: typeof GetLatestBlock;
|
|
23
|
+
static readonly GetCurrentSlot: typeof GetCurrentSlot;
|
|
24
|
+
static readonly GetEpoch: typeof GetEpoch;
|
|
25
|
+
static readonly GetLatestEpoch: typeof GetLatestEpoch;
|
|
26
|
+
static readonly GetAddress: typeof GetAddress;
|
|
27
|
+
static readonly GetAddressUtxos: typeof GetAddressUtxos;
|
|
28
|
+
static readonly GetAddressTransactions: typeof GetAddressTransactions;
|
|
29
|
+
static readonly GetAddressTransactionHashes: typeof GetAddressTransactionHashes;
|
|
30
|
+
static readonly GetCredentialUtxos: typeof GetCredentialUtxos;
|
|
31
|
+
static readonly IsUtxoUnspent: typeof IsUtxoUnspent;
|
|
32
|
+
static readonly GetUnspentOutputs: typeof GetUnspentOutputs;
|
|
33
|
+
static readonly GetAccount: typeof GetAccount;
|
|
34
|
+
static readonly GetPool: typeof GetPool;
|
|
35
|
+
static readonly GetPoolIds: typeof GetPoolIds;
|
|
36
|
+
static readonly GetPools: typeof GetPools;
|
|
37
|
+
static readonly GetDrep: typeof GetDrep;
|
|
38
|
+
static readonly GetDrepIds: typeof GetDrepIds;
|
|
39
|
+
static readonly GetDreps: typeof GetDreps;
|
|
40
|
+
static readonly GetAssetInfo: typeof GetAssetInfo;
|
|
41
|
+
static readonly GetAssetHistory: typeof GetAssetHistory;
|
|
42
|
+
static readonly GetNetworkInformation: typeof GetNetworkInformation;
|
|
43
|
+
static readonly GetProtocolParameters: typeof GetProtocolParameters;
|
|
44
|
+
static readonly EvaluateTransaction: typeof EvaluateTransaction;
|
|
45
|
+
static readonly SubmitTransaction: typeof SubmitTransaction;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
export declare const GetTransaction: {
|
|
50
|
+
// positional
|
|
51
|
+
(hash: string | null): globalThis.Promise<string | null> | string | null
|
|
52
|
+
// named
|
|
53
|
+
({hash}: {hash?: string | null}): globalThis.Promise<string | null> | string | null
|
|
54
|
+
// metadata (do not use)
|
|
55
|
+
__parameters: {hash?: string | null}, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
56
|
+
kind: 'action'
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export declare const GetTransactionsBatch: {
|
|
60
|
+
// positional
|
|
61
|
+
(hashes: string | null): globalThis.Promise<string | null> | string | null
|
|
62
|
+
// named
|
|
63
|
+
({hashes}: {hashes?: string | null}): globalThis.Promise<string | null> | string | null
|
|
64
|
+
// metadata (do not use)
|
|
65
|
+
__parameters: {hashes?: string | null}, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
66
|
+
kind: 'action'
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export declare const GetTransactionMetadata: {
|
|
70
|
+
// positional
|
|
71
|
+
(hash: string | null): globalThis.Promise<string | null> | string | null
|
|
72
|
+
// named
|
|
73
|
+
({hash}: {hash?: string | null}): globalThis.Promise<string | null> | string | null
|
|
74
|
+
// metadata (do not use)
|
|
75
|
+
__parameters: {hash?: string | null}, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
76
|
+
kind: 'action'
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export declare const GetBlock: {
|
|
80
|
+
// positional
|
|
81
|
+
(hash: string | null): globalThis.Promise<string | null> | string | null
|
|
82
|
+
// named
|
|
83
|
+
({hash}: {hash?: string | null}): globalThis.Promise<string | null> | string | null
|
|
84
|
+
// metadata (do not use)
|
|
85
|
+
__parameters: {hash?: string | null}, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
86
|
+
kind: 'action'
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export declare const GetBlockByHeight: {
|
|
90
|
+
// positional
|
|
91
|
+
(height: number | null): globalThis.Promise<string | null> | string | null
|
|
92
|
+
// named
|
|
93
|
+
({height}: {height?: number | null}): globalThis.Promise<string | null> | string | null
|
|
94
|
+
// metadata (do not use)
|
|
95
|
+
__parameters: {height?: number | null}, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
96
|
+
kind: 'action'
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export declare const GetNextBlocks: {
|
|
100
|
+
// positional
|
|
101
|
+
(afterHash: string | null, count: number | null, afterHeight: number | null): globalThis.Promise<string | null> | string | null
|
|
102
|
+
// named
|
|
103
|
+
({afterHash, count, afterHeight}: {afterHash?: string | null, count?: number | null, afterHeight?: number | null}): globalThis.Promise<string | null> | string | null
|
|
104
|
+
// metadata (do not use)
|
|
105
|
+
__parameters: {afterHash?: string | null, count?: number | null, afterHeight?: number | null}, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
106
|
+
kind: 'action'
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export declare const GetBlockTransactions: {
|
|
110
|
+
// positional
|
|
111
|
+
(blockHash: string | null): globalThis.Promise<string | null> | string | null
|
|
112
|
+
// named
|
|
113
|
+
({blockHash}: {blockHash?: string | null}): globalThis.Promise<string | null> | string | null
|
|
114
|
+
// metadata (do not use)
|
|
115
|
+
__parameters: {blockHash?: string | null}, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
116
|
+
kind: 'action'
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export declare const GetLatestBlock: {
|
|
120
|
+
// positional
|
|
121
|
+
(): globalThis.Promise<string | null> | string | null
|
|
122
|
+
// named
|
|
123
|
+
({}: globalThis.Record<never, never>): globalThis.Promise<string | null> | string | null
|
|
124
|
+
// metadata (do not use)
|
|
125
|
+
__parameters: globalThis.Record<never, never>, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
126
|
+
kind: 'action'
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export declare const GetCurrentSlot: {
|
|
130
|
+
// positional
|
|
131
|
+
(): globalThis.Promise<string | null> | string | null
|
|
132
|
+
// named
|
|
133
|
+
({}: globalThis.Record<never, never>): globalThis.Promise<string | null> | string | null
|
|
134
|
+
// metadata (do not use)
|
|
135
|
+
__parameters: globalThis.Record<never, never>, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
136
|
+
kind: 'action'
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export declare const GetEpoch: {
|
|
140
|
+
// positional
|
|
141
|
+
(epoch: number | null): globalThis.Promise<string | null> | string | null
|
|
142
|
+
// named
|
|
143
|
+
({epoch}: {epoch?: number | null}): globalThis.Promise<string | null> | string | null
|
|
144
|
+
// metadata (do not use)
|
|
145
|
+
__parameters: {epoch?: number | null}, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
146
|
+
kind: 'action'
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export declare const GetLatestEpoch: {
|
|
150
|
+
// positional
|
|
151
|
+
(): globalThis.Promise<string | null> | string | null
|
|
152
|
+
// named
|
|
153
|
+
({}: globalThis.Record<never, never>): globalThis.Promise<string | null> | string | null
|
|
154
|
+
// metadata (do not use)
|
|
155
|
+
__parameters: globalThis.Record<never, never>, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
156
|
+
kind: 'action'
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export declare const GetAddress: {
|
|
160
|
+
// positional
|
|
161
|
+
(address: string | null): globalThis.Promise<string | null> | string | null
|
|
162
|
+
// named
|
|
163
|
+
({address}: {address?: string | null}): globalThis.Promise<string | null> | string | null
|
|
164
|
+
// metadata (do not use)
|
|
165
|
+
__parameters: {address?: string | null}, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
166
|
+
kind: 'action'
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export declare const GetAddressUtxos: {
|
|
170
|
+
// positional
|
|
171
|
+
(address: string | null): globalThis.Promise<string | null> | string | null
|
|
172
|
+
// named
|
|
173
|
+
({address}: {address?: string | null}): globalThis.Promise<string | null> | string | null
|
|
174
|
+
// metadata (do not use)
|
|
175
|
+
__parameters: {address?: string | null}, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
176
|
+
kind: 'action'
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export declare const GetAddressTransactions: {
|
|
180
|
+
// positional
|
|
181
|
+
(address: string | null, limit: number | null): globalThis.Promise<string | null> | string | null
|
|
182
|
+
// named
|
|
183
|
+
({address, limit}: {address?: string | null, limit?: number | null}): globalThis.Promise<string | null> | string | null
|
|
184
|
+
// metadata (do not use)
|
|
185
|
+
__parameters: {address?: string | null, limit?: number | null}, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
186
|
+
kind: 'action'
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export declare const GetAddressTransactionHashes: {
|
|
190
|
+
// positional
|
|
191
|
+
(address: string | null, limit: number | null): globalThis.Promise<string | null> | string | null
|
|
192
|
+
// named
|
|
193
|
+
({address, limit}: {address?: string | null, limit?: number | null}): globalThis.Promise<string | null> | string | null
|
|
194
|
+
// metadata (do not use)
|
|
195
|
+
__parameters: {address?: string | null, limit?: number | null}, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
196
|
+
kind: 'action'
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export declare const GetCredentialUtxos: {
|
|
200
|
+
// positional
|
|
201
|
+
(credential: string | null): globalThis.Promise<string | null> | string | null
|
|
202
|
+
// named
|
|
203
|
+
({credential}: {credential?: string | null}): globalThis.Promise<string | null> | string | null
|
|
204
|
+
// metadata (do not use)
|
|
205
|
+
__parameters: {credential?: string | null}, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
206
|
+
kind: 'action'
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export declare const IsUtxoUnspent: {
|
|
210
|
+
// positional
|
|
211
|
+
(txHash: string | null, outputIndex: number | null): globalThis.Promise<string | null> | string | null
|
|
212
|
+
// named
|
|
213
|
+
({txHash, outputIndex}: {txHash?: string | null, outputIndex?: number | null}): globalThis.Promise<string | null> | string | null
|
|
214
|
+
// metadata (do not use)
|
|
215
|
+
__parameters: {txHash?: string | null, outputIndex?: number | null}, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
216
|
+
kind: 'action'
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export declare const GetUnspentOutputs: {
|
|
220
|
+
// positional
|
|
221
|
+
(refs: string | null): globalThis.Promise<string | null> | string | null
|
|
222
|
+
// named
|
|
223
|
+
({refs}: {refs?: string | null}): globalThis.Promise<string | null> | string | null
|
|
224
|
+
// metadata (do not use)
|
|
225
|
+
__parameters: {refs?: string | null}, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
226
|
+
kind: 'action'
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export declare const GetAccount: {
|
|
230
|
+
// positional
|
|
231
|
+
(stakeAddress: string | null): globalThis.Promise<string | null> | string | null
|
|
232
|
+
// named
|
|
233
|
+
({stakeAddress}: {stakeAddress?: string | null}): globalThis.Promise<string | null> | string | null
|
|
234
|
+
// metadata (do not use)
|
|
235
|
+
__parameters: {stakeAddress?: string | null}, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
236
|
+
kind: 'action'
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export declare const GetPool: {
|
|
240
|
+
// positional
|
|
241
|
+
(poolId: string | null): globalThis.Promise<string | null> | string | null
|
|
242
|
+
// named
|
|
243
|
+
({poolId}: {poolId?: string | null}): globalThis.Promise<string | null> | string | null
|
|
244
|
+
// metadata (do not use)
|
|
245
|
+
__parameters: {poolId?: string | null}, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
246
|
+
kind: 'action'
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export declare const GetPoolIds: {
|
|
250
|
+
// positional
|
|
251
|
+
(): globalThis.Promise<string | null> | string | null
|
|
252
|
+
// named
|
|
253
|
+
({}: globalThis.Record<never, never>): globalThis.Promise<string | null> | string | null
|
|
254
|
+
// metadata (do not use)
|
|
255
|
+
__parameters: globalThis.Record<never, never>, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
256
|
+
kind: 'action'
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export declare const GetPools: {
|
|
260
|
+
// positional
|
|
261
|
+
(ids: string | null): globalThis.Promise<string | null> | string | null
|
|
262
|
+
// named
|
|
263
|
+
({ids}: {ids?: string | null}): globalThis.Promise<string | null> | string | null
|
|
264
|
+
// metadata (do not use)
|
|
265
|
+
__parameters: {ids?: string | null}, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
266
|
+
kind: 'action'
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export declare const GetDrep: {
|
|
270
|
+
// positional
|
|
271
|
+
(drepId: string | null): globalThis.Promise<string | null> | string | null
|
|
272
|
+
// named
|
|
273
|
+
({drepId}: {drepId?: string | null}): globalThis.Promise<string | null> | string | null
|
|
274
|
+
// metadata (do not use)
|
|
275
|
+
__parameters: {drepId?: string | null}, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
276
|
+
kind: 'action'
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export declare const GetDrepIds: {
|
|
280
|
+
// positional
|
|
281
|
+
(): globalThis.Promise<string | null> | string | null
|
|
282
|
+
// named
|
|
283
|
+
({}: globalThis.Record<never, never>): globalThis.Promise<string | null> | string | null
|
|
284
|
+
// metadata (do not use)
|
|
285
|
+
__parameters: globalThis.Record<never, never>, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
286
|
+
kind: 'action'
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export declare const GetDreps: {
|
|
290
|
+
// positional
|
|
291
|
+
(ids: string | null): globalThis.Promise<string | null> | string | null
|
|
292
|
+
// named
|
|
293
|
+
({ids}: {ids?: string | null}): globalThis.Promise<string | null> | string | null
|
|
294
|
+
// metadata (do not use)
|
|
295
|
+
__parameters: {ids?: string | null}, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
296
|
+
kind: 'action'
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export declare const GetAssetInfo: {
|
|
300
|
+
// positional
|
|
301
|
+
(unit: string | null): globalThis.Promise<string | null> | string | null
|
|
302
|
+
// named
|
|
303
|
+
({unit}: {unit?: string | null}): globalThis.Promise<string | null> | string | null
|
|
304
|
+
// metadata (do not use)
|
|
305
|
+
__parameters: {unit?: string | null}, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
306
|
+
kind: 'action'
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export declare const GetAssetHistory: {
|
|
310
|
+
// positional
|
|
311
|
+
(unit: string | null, limit: number | null): globalThis.Promise<string | null> | string | null
|
|
312
|
+
// named
|
|
313
|
+
({unit, limit}: {unit?: string | null, limit?: number | null}): globalThis.Promise<string | null> | string | null
|
|
314
|
+
// metadata (do not use)
|
|
315
|
+
__parameters: {unit?: string | null, limit?: number | null}, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
316
|
+
kind: 'action'
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export declare const GetNetworkInformation: {
|
|
320
|
+
// positional
|
|
321
|
+
(): globalThis.Promise<string | null> | string | null
|
|
322
|
+
// named
|
|
323
|
+
({}: globalThis.Record<never, never>): globalThis.Promise<string | null> | string | null
|
|
324
|
+
// metadata (do not use)
|
|
325
|
+
__parameters: globalThis.Record<never, never>, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
326
|
+
kind: 'action'
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export declare const GetProtocolParameters: {
|
|
330
|
+
// positional
|
|
331
|
+
(): globalThis.Promise<string | null> | string | null
|
|
332
|
+
// named
|
|
333
|
+
({}: globalThis.Record<never, never>): globalThis.Promise<string | null> | string | null
|
|
334
|
+
// metadata (do not use)
|
|
335
|
+
__parameters: globalThis.Record<never, never>, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
336
|
+
kind: 'action'
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
export declare const EvaluateTransaction: {
|
|
340
|
+
// positional
|
|
341
|
+
(cbor: string | null): globalThis.Promise<string | null> | string | null
|
|
342
|
+
// named
|
|
343
|
+
({cbor}: {cbor?: string | null}): globalThis.Promise<string | null> | string | null
|
|
344
|
+
// metadata (do not use)
|
|
345
|
+
__parameters: {cbor?: string | null}, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
346
|
+
kind: 'action'
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export declare const SubmitTransaction: {
|
|
350
|
+
// positional
|
|
351
|
+
(cbor: string | null): globalThis.Promise<string | null> | string | null
|
|
352
|
+
// named
|
|
353
|
+
({cbor}: {cbor?: string | null}): globalThis.Promise<string | null> | string | null
|
|
354
|
+
// metadata (do not use)
|
|
355
|
+
__parameters: {cbor?: string | null}, __returns: globalThis.Promise<string | null> | string | null, __self: never
|
|
356
|
+
kind: 'action'
|
|
357
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// This is an automatically generated file. Please do not change its contents manually!
|
|
2
|
+
const { createEntityProxy } = require('./../_')
|
|
3
|
+
// service
|
|
4
|
+
const CardanoBackendService = { name: 'CardanoBackendService' }
|
|
5
|
+
module.exports = CardanoBackendService
|
|
6
|
+
module.exports.CardanoBackendService = CardanoBackendService
|
|
7
|
+
// events
|
|
8
|
+
// actions
|
|
9
|
+
module.exports.GetTransaction = 'GetTransaction'
|
|
10
|
+
module.exports.GetTransactionsBatch = 'GetTransactionsBatch'
|
|
11
|
+
module.exports.GetTransactionMetadata = 'GetTransactionMetadata'
|
|
12
|
+
module.exports.GetBlock = 'GetBlock'
|
|
13
|
+
module.exports.GetBlockByHeight = 'GetBlockByHeight'
|
|
14
|
+
module.exports.GetNextBlocks = 'GetNextBlocks'
|
|
15
|
+
module.exports.GetBlockTransactions = 'GetBlockTransactions'
|
|
16
|
+
module.exports.GetLatestBlock = 'GetLatestBlock'
|
|
17
|
+
module.exports.GetCurrentSlot = 'GetCurrentSlot'
|
|
18
|
+
module.exports.GetEpoch = 'GetEpoch'
|
|
19
|
+
module.exports.GetLatestEpoch = 'GetLatestEpoch'
|
|
20
|
+
module.exports.GetAddress = 'GetAddress'
|
|
21
|
+
module.exports.GetAddressUtxos = 'GetAddressUtxos'
|
|
22
|
+
module.exports.GetAddressTransactions = 'GetAddressTransactions'
|
|
23
|
+
module.exports.GetAddressTransactionHashes = 'GetAddressTransactionHashes'
|
|
24
|
+
module.exports.GetCredentialUtxos = 'GetCredentialUtxos'
|
|
25
|
+
module.exports.IsUtxoUnspent = 'IsUtxoUnspent'
|
|
26
|
+
module.exports.GetUnspentOutputs = 'GetUnspentOutputs'
|
|
27
|
+
module.exports.GetAccount = 'GetAccount'
|
|
28
|
+
module.exports.GetPool = 'GetPool'
|
|
29
|
+
module.exports.GetPoolIds = 'GetPoolIds'
|
|
30
|
+
module.exports.GetPools = 'GetPools'
|
|
31
|
+
module.exports.GetDrep = 'GetDrep'
|
|
32
|
+
module.exports.GetDrepIds = 'GetDrepIds'
|
|
33
|
+
module.exports.GetDreps = 'GetDreps'
|
|
34
|
+
module.exports.GetAssetInfo = 'GetAssetInfo'
|
|
35
|
+
module.exports.GetAssetHistory = 'GetAssetHistory'
|
|
36
|
+
module.exports.GetNetworkInformation = 'GetNetworkInformation'
|
|
37
|
+
module.exports.GetProtocolParameters = 'GetProtocolParameters'
|
|
38
|
+
module.exports.EvaluateTransaction = 'EvaluateTransaction'
|
|
39
|
+
module.exports.SubmitTransaction = 'SubmitTransaction'
|
|
40
|
+
// enums
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@odatano/core",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.24",
|
|
4
4
|
"description": "SAP CAP plugin for Cardano blockchain OData V4 integration",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#cds-models/*": "./@cds-models/*/index.js"
|
|
@@ -149,7 +149,8 @@
|
|
|
149
149
|
"test:unit": "vitest run --project unit",
|
|
150
150
|
"watch-odatano": "cds watch --open odatano/index.html?sap-ui-xx-viewCache=false --livereload false",
|
|
151
151
|
"watch-wallet": "cds watch --open wallet/webapp/index.html",
|
|
152
|
-
"release:check": "node scripts/release-check.mjs"
|
|
152
|
+
"release:check": "node scripts/release-check.mjs",
|
|
153
|
+
"prepublishOnly": "node scripts/publish-guard.mjs"
|
|
153
154
|
},
|
|
154
155
|
"sapux": [
|
|
155
156
|
"app/odatano"
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { CardanoBackend, EvaluatingBackend, PaginatingBackend, EnumeratingBackend } from './cardano-backend';
|
|
2
|
+
import type { Transaction, Address, UTxO, NetworkInformation, EpochData, MetadataLabelTx, BlockData, PoolData, DrepData, AccountData, AssetInfo, AssetHistoryEntry, LedgerProtocolParameters, ScriptEvaluationResult } from '../../utils/types';
|
|
3
|
+
import { Network } from '../cardano-client';
|
|
4
|
+
/** Public ODATANO API per network (ACCESS gateway); mainnet has no default and needs `odatanoUrl`. */
|
|
5
|
+
export declare const ODATANO_API_URLS: Partial<Record<Network, string>>;
|
|
6
|
+
/**
|
|
7
|
+
* Backend over another ODATANO instance (typically the hosted API behind the ACCESS gateway),
|
|
8
|
+
* speaking its `CardanoBackendService`. Answers arrive in the provider shape, so everything above
|
|
9
|
+
* this class treats it like Koios. The key goes as `Authorization: Bearer`.
|
|
10
|
+
*/
|
|
11
|
+
export declare class OdatanoBackend implements CardanoBackend, EvaluatingBackend, PaginatingBackend, EnumeratingBackend {
|
|
12
|
+
readonly name = "odatano";
|
|
13
|
+
private readonly api;
|
|
14
|
+
/** Units left on the key, from the gateway's `x-access-units-left` header; null when not reported. */
|
|
15
|
+
unitsLeft: number | null;
|
|
16
|
+
constructor(network: Network, timeoutMs: number, url: string | undefined, apiKey: string | undefined);
|
|
17
|
+
/** Probe the remote instance with its cheapest call. */
|
|
18
|
+
init(): Promise<boolean>;
|
|
19
|
+
getTransaction(txHash: string): Promise<Transaction>;
|
|
20
|
+
getAddress(address: string): Promise<Address>;
|
|
21
|
+
getAddressUtxos(address: string): Promise<UTxO[]>;
|
|
22
|
+
getAddressTransactions(address: string, limit: number): Promise<Transaction[]>;
|
|
23
|
+
getAddressTransactionHashes(address: string, limit: number): Promise<string[]>;
|
|
24
|
+
getTransactionsBatch(txHashes: string[]): Promise<Map<string, Transaction>>;
|
|
25
|
+
getCredentialUtxos(credHash: string): Promise<UTxO[]>;
|
|
26
|
+
getNetworkInformation(): Promise<NetworkInformation>;
|
|
27
|
+
getTransactionMetadata(txHash: string): Promise<MetadataLabelTx[]>;
|
|
28
|
+
getBlock(blockHash: string): Promise<BlockData>;
|
|
29
|
+
getEpoch(epochNumber: number): Promise<EpochData>;
|
|
30
|
+
getLatestEpoch(): Promise<EpochData>;
|
|
31
|
+
getLatestBlock(): Promise<BlockData>;
|
|
32
|
+
getCurrentSlot(): Promise<number>;
|
|
33
|
+
isUtxoUnspent(txHash: string, outputIndex: number): Promise<boolean>;
|
|
34
|
+
getPool(poolId: string): Promise<PoolData>;
|
|
35
|
+
getDrep(drepId: string): Promise<DrepData>;
|
|
36
|
+
getAccount(stakeAddress: string): Promise<AccountData>;
|
|
37
|
+
getAssetInfo(unit: string): Promise<AssetInfo>;
|
|
38
|
+
getAssetHistory(unit: string, limit?: number): Promise<AssetHistoryEntry[]>;
|
|
39
|
+
getProtocolParameters(): Promise<LedgerProtocolParameters>;
|
|
40
|
+
submitTransaction(signedTxCbor: string): Promise<string>;
|
|
41
|
+
evaluateTransaction(unsignedTxCbor: string): Promise<ScriptEvaluationResult[]>;
|
|
42
|
+
getBlockByHeight(height: number): Promise<BlockData>;
|
|
43
|
+
getNextBlocks(afterHash: string, count: number, afterHeight?: number): Promise<BlockData[]>;
|
|
44
|
+
getBlockTransactions(blockHash: string): Promise<Transaction[]>;
|
|
45
|
+
getPoolIds(): Promise<string[]>;
|
|
46
|
+
getPools(poolIds: string[]): Promise<PoolData[]>;
|
|
47
|
+
getDrepIds(): Promise<string[]>;
|
|
48
|
+
getDreps(drepIds: string[]): Promise<DrepData[]>;
|
|
49
|
+
shutdown(): Promise<void>;
|
|
50
|
+
private batched;
|
|
51
|
+
/**
|
|
52
|
+
* POST one operation, parse the JSON string it answers (safeJSON keeps big integers) and map
|
|
53
|
+
* HTTP failures to the backend error classes. The remote message is kept verbatim, so markers
|
|
54
|
+
* such as `CHAIN_POINT_MISMATCH:` reach the crawler unchanged.
|
|
55
|
+
*/
|
|
56
|
+
private call;
|
|
57
|
+
private mapError;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=odatano-backend.d.ts.map
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.OdatanoBackend = exports.ODATANO_API_URLS = void 0;
|
|
7
|
+
const cds_1 = __importDefault(require("@sap/cds"));
|
|
8
|
+
const axios_1 = __importDefault(require("axios"));
|
|
9
|
+
const client_1 = require("@cardano-ogmios/client");
|
|
10
|
+
const errors_1 = require("../../utils/errors");
|
|
11
|
+
const logger = cds_1.default.log('OdatanoBackend');
|
|
12
|
+
/** Public ODATANO API per network (ACCESS gateway); mainnet has no default and needs `odatanoUrl`. */
|
|
13
|
+
exports.ODATANO_API_URLS = {
|
|
14
|
+
preview: 'https://api.preview.odatano.dev',
|
|
15
|
+
preprod: 'https://api.preprod.odatano.dev',
|
|
16
|
+
};
|
|
17
|
+
const SERVICE_PATH = '/odata/v4/cardano-backend';
|
|
18
|
+
/** Ids per GetPools / GetDreps call, below the service's list cap. */
|
|
19
|
+
const ENUMERATION_BATCH = 200;
|
|
20
|
+
/**
|
|
21
|
+
* Backend over another ODATANO instance (typically the hosted API behind the ACCESS gateway),
|
|
22
|
+
* speaking its `CardanoBackendService`. Answers arrive in the provider shape, so everything above
|
|
23
|
+
* this class treats it like Koios. The key goes as `Authorization: Bearer`.
|
|
24
|
+
*/
|
|
25
|
+
class OdatanoBackend {
|
|
26
|
+
name = 'odatano';
|
|
27
|
+
api;
|
|
28
|
+
/** Units left on the key, from the gateway's `x-access-units-left` header; null when not reported. */
|
|
29
|
+
unitsLeft = null;
|
|
30
|
+
constructor(network, timeoutMs, url, apiKey) {
|
|
31
|
+
const baseURL = (url || exports.ODATANO_API_URLS[network] || '').replace(/\/+$/, '');
|
|
32
|
+
if (!baseURL) {
|
|
33
|
+
throw new errors_1.BackendInitError('odatano', new Error(`odatanoUrl is required on ${network}`));
|
|
34
|
+
}
|
|
35
|
+
if (!/^https?:\/\//i.test(baseURL)) {
|
|
36
|
+
throw new errors_1.BackendInitError('odatano', new Error(`odatanoUrl must be an http(s) URL, got "${baseURL}"`));
|
|
37
|
+
}
|
|
38
|
+
this.api = axios_1.default.create({
|
|
39
|
+
baseURL: baseURL + SERVICE_PATH,
|
|
40
|
+
timeout: timeoutMs,
|
|
41
|
+
headers: {
|
|
42
|
+
'Content-Type': 'application/json',
|
|
43
|
+
...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {}),
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/** Probe the remote instance with its cheapest call. */
|
|
48
|
+
async init() {
|
|
49
|
+
await this.call('GetCurrentSlot');
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
// --- CardanoBackend ------------------------------------------------------------------------
|
|
53
|
+
getTransaction(txHash) { return this.call('GetTransaction', { hash: txHash }); }
|
|
54
|
+
getAddress(address) { return this.call('GetAddress', { address }); }
|
|
55
|
+
getAddressUtxos(address) { return this.call('GetAddressUtxos', { address }); }
|
|
56
|
+
getAddressTransactions(address, limit) {
|
|
57
|
+
return this.call('GetAddressTransactions', { address, limit });
|
|
58
|
+
}
|
|
59
|
+
getAddressTransactionHashes(address, limit) {
|
|
60
|
+
return this.call('GetAddressTransactionHashes', { address, limit });
|
|
61
|
+
}
|
|
62
|
+
async getTransactionsBatch(txHashes) {
|
|
63
|
+
const out = new Map();
|
|
64
|
+
for (let i = 0; i < txHashes.length; i += ENUMERATION_BATCH) {
|
|
65
|
+
const found = await this.call('GetTransactionsBatch', {
|
|
66
|
+
hashes: JSON.stringify(txHashes.slice(i, i + ENUMERATION_BATCH)),
|
|
67
|
+
});
|
|
68
|
+
for (const [hash, tx] of Object.entries(found ?? {}))
|
|
69
|
+
out.set(hash, tx);
|
|
70
|
+
}
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
getCredentialUtxos(credHash) { return this.call('GetCredentialUtxos', { credential: credHash }); }
|
|
74
|
+
getNetworkInformation() { return this.call('GetNetworkInformation'); }
|
|
75
|
+
getTransactionMetadata(txHash) { return this.call('GetTransactionMetadata', { hash: txHash }); }
|
|
76
|
+
getBlock(blockHash) { return this.call('GetBlock', { hash: blockHash }); }
|
|
77
|
+
getEpoch(epochNumber) { return this.call('GetEpoch', { epoch: epochNumber }); }
|
|
78
|
+
getLatestEpoch() { return this.call('GetLatestEpoch'); }
|
|
79
|
+
getLatestBlock() { return this.call('GetLatestBlock'); }
|
|
80
|
+
getCurrentSlot() { return this.call('GetCurrentSlot'); }
|
|
81
|
+
isUtxoUnspent(txHash, outputIndex) {
|
|
82
|
+
return this.call('IsUtxoUnspent', { txHash, outputIndex });
|
|
83
|
+
}
|
|
84
|
+
getPool(poolId) { return this.call('GetPool', { poolId }); }
|
|
85
|
+
getDrep(drepId) { return this.call('GetDrep', { drepId }); }
|
|
86
|
+
getAccount(stakeAddress) { return this.call('GetAccount', { stakeAddress }); }
|
|
87
|
+
getAssetInfo(unit) { return this.call('GetAssetInfo', { unit }); }
|
|
88
|
+
getAssetHistory(unit, limit = 100) { return this.call('GetAssetHistory', { unit, limit }); }
|
|
89
|
+
getProtocolParameters() { return this.call('GetProtocolParameters'); }
|
|
90
|
+
submitTransaction(signedTxCbor) { return this.call('SubmitTransaction', { cbor: signedTxCbor }); }
|
|
91
|
+
// --- EvaluatingBackend -----------------------------------------------------------------------
|
|
92
|
+
evaluateTransaction(unsignedTxCbor) {
|
|
93
|
+
return this.call('EvaluateTransaction', { cbor: unsignedTxCbor });
|
|
94
|
+
}
|
|
95
|
+
// --- PaginatingBackend (crawler source) ------------------------------------------------------
|
|
96
|
+
getBlockByHeight(height) { return this.call('GetBlockByHeight', { height }); }
|
|
97
|
+
getNextBlocks(afterHash, count, afterHeight) {
|
|
98
|
+
return this.call('GetNextBlocks', { afterHash, count, afterHeight: afterHeight ?? null });
|
|
99
|
+
}
|
|
100
|
+
getBlockTransactions(blockHash) { return this.call('GetBlockTransactions', { blockHash }); }
|
|
101
|
+
// --- EnumeratingBackend (epoch snapshots) -----------------------------------------------------
|
|
102
|
+
getPoolIds() { return this.call('GetPoolIds'); }
|
|
103
|
+
getPools(poolIds) { return this.batched('GetPools', poolIds); }
|
|
104
|
+
getDrepIds() { return this.call('GetDrepIds'); }
|
|
105
|
+
getDreps(drepIds) { return this.batched('GetDreps', drepIds); }
|
|
106
|
+
async shutdown() { }
|
|
107
|
+
async batched(operation, ids) {
|
|
108
|
+
const out = [];
|
|
109
|
+
for (let i = 0; i < ids.length; i += ENUMERATION_BATCH) {
|
|
110
|
+
out.push(...await this.call(operation, { ids: JSON.stringify(ids.slice(i, i + ENUMERATION_BATCH)) }));
|
|
111
|
+
}
|
|
112
|
+
return out;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* POST one operation, parse the JSON string it answers (safeJSON keeps big integers) and map
|
|
116
|
+
* HTTP failures to the backend error classes. The remote message is kept verbatim, so markers
|
|
117
|
+
* such as `CHAIN_POINT_MISMATCH:` reach the crawler unchanged.
|
|
118
|
+
*/
|
|
119
|
+
async call(operation, body = {}) {
|
|
120
|
+
try {
|
|
121
|
+
const res = await this.api.post(`/${operation}`, body);
|
|
122
|
+
const left = Number(res.headers?.['x-access-units-left']);
|
|
123
|
+
if (Number.isFinite(left))
|
|
124
|
+
this.unitsLeft = left;
|
|
125
|
+
const value = res.data?.value;
|
|
126
|
+
return (typeof value === 'string' ? client_1.safeJSON.parse(value) : value);
|
|
127
|
+
}
|
|
128
|
+
catch (err) {
|
|
129
|
+
throw this.mapError(operation, err);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
mapError(operation, err) {
|
|
133
|
+
const ax = err;
|
|
134
|
+
if (!ax?.isAxiosError)
|
|
135
|
+
return err instanceof Error ? err : new Error(String(err));
|
|
136
|
+
const status = ax.response?.status;
|
|
137
|
+
const message = ax.response?.data?.error?.message ?? ax.message;
|
|
138
|
+
// NotFoundError appends " not found" itself; the remote message already ends with it
|
|
139
|
+
if (status === 404)
|
|
140
|
+
return new errors_1.NotFoundError(message.replace(/ not found$/, ''), this.name);
|
|
141
|
+
if (status === 429) {
|
|
142
|
+
const retryAfter = Number(ax.response?.headers?.['retry-after']);
|
|
143
|
+
return new errors_1.RateLimitError(message, this.name, Number.isFinite(retryAfter) ? retryAfter : undefined);
|
|
144
|
+
}
|
|
145
|
+
if (status === 400)
|
|
146
|
+
return new errors_1.TransactionValidationError(message);
|
|
147
|
+
if (status === 401 || status === 402 || status === 403) {
|
|
148
|
+
logger.error(`${operation}: the remote ODATANO refused the key (${status}): ${message}`);
|
|
149
|
+
}
|
|
150
|
+
return new errors_1.ProviderUnavailableError(message, this.name);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.OdatanoBackend = OdatanoBackend;
|
|
154
|
+
//# sourceMappingURL=odatano-backend.js.map
|