@odatano/nightgate 0.1.0 → 0.1.1
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/README.md +2 -1
- package/db/schema.cds +196 -327
- package/package.json +8 -1
- package/src/index.js +34 -15
- package/src/plugin.d.ts +4 -0
- package/src/plugin.js +37 -4
- package/srv/crawler/BlockProcessor.d.ts +8 -0
- package/srv/crawler/BlockProcessor.js +193 -5
- package/srv/crawler/Crawler.js +56 -53
- package/srv/crawler/index.d.ts +4 -0
- package/srv/crawler/index.js +20 -1
- package/srv/nightgate-indexer-service.cds +47 -10
- package/srv/nightgate-indexer-service.d.ts +2 -0
- package/srv/nightgate-indexer-service.js +144 -1
- package/srv/nightgate-service.cds +192 -134
- package/srv/nightgate-service.js +27 -0
- package/srv/providers/MidnightNodeProvider.js +13 -1
- package/srv/utils/scale.d.ts +25 -24
- package/srv/utils/scale.js +167 -89
package/db/schema.cds
CHANGED
|
@@ -1,141 +1,97 @@
|
|
|
1
1
|
namespace midnight;
|
|
2
2
|
|
|
3
|
-
using {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// Enum for Transaction Type
|
|
23
|
-
type TransactionType : String enum {
|
|
24
|
-
REGULAR;
|
|
25
|
-
SYSTEM;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Enum for Contract Action Type
|
|
29
|
-
type ContractActionType : String enum {
|
|
30
|
-
DEPLOY;
|
|
31
|
-
CALL;
|
|
32
|
-
UPDATE;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Enum for Dust Ledger Event Type
|
|
36
|
-
type DustLedgerEventType : String enum {
|
|
37
|
-
DTIME_UPDATE;
|
|
38
|
-
INITIAL_UTXO;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Enum for detailed Transaction Type Classification (from Crawler)
|
|
42
|
-
type TxType : String(30) enum {
|
|
43
|
-
night_transfer;
|
|
44
|
-
shielded_transfer;
|
|
45
|
-
contract_deploy;
|
|
46
|
-
contract_call;
|
|
47
|
-
contract_update;
|
|
48
|
-
dust_registration;
|
|
49
|
-
dust_generation;
|
|
50
|
-
governance;
|
|
51
|
-
system;
|
|
52
|
-
unknown;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Enum for Indexer Sync Status
|
|
56
|
-
type SyncStatus : String(20) enum {
|
|
57
|
-
syncing;
|
|
58
|
-
synced;
|
|
59
|
-
error;
|
|
60
|
-
stopped;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Enum for Token Category
|
|
64
|
-
type TokenCategory : String(25) enum {
|
|
65
|
-
ledger_shielded;
|
|
66
|
-
ledger_unshielded;
|
|
67
|
-
contract_shielded;
|
|
68
|
-
contract_unshielded;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// ============================================================================
|
|
72
|
-
// Core Entities
|
|
73
|
-
// ============================================================================
|
|
3
|
+
using {
|
|
4
|
+
cuid,
|
|
5
|
+
managed
|
|
6
|
+
} from '@sap/cds/common';
|
|
7
|
+
using {
|
|
8
|
+
HexEncoded,
|
|
9
|
+
UnshieldedAddr,
|
|
10
|
+
CardanoRewardAddr,
|
|
11
|
+
DustAddr,
|
|
12
|
+
BigInt,
|
|
13
|
+
TransactionResultStatus,
|
|
14
|
+
TransactionType,
|
|
15
|
+
ContractActionType,
|
|
16
|
+
DustLedgerEventType,
|
|
17
|
+
TxType,
|
|
18
|
+
SyncStatus,
|
|
19
|
+
TokenCategory
|
|
20
|
+
} from './types.cds';
|
|
74
21
|
|
|
75
22
|
/**
|
|
76
23
|
* Represents a block in the Midnight blockchain
|
|
77
24
|
*/
|
|
78
25
|
entity Blocks : cuid, managed {
|
|
79
|
-
hash
|
|
80
|
-
height
|
|
81
|
-
protocolVersion
|
|
82
|
-
timestamp
|
|
83
|
-
author
|
|
84
|
-
ledgerParameters
|
|
26
|
+
hash : HexEncoded not null;
|
|
27
|
+
height : Integer64 not null;
|
|
28
|
+
protocolVersion : Integer not null;
|
|
29
|
+
timestamp : Integer not null; // UNIX timestamp
|
|
30
|
+
author : HexEncoded;
|
|
31
|
+
ledgerParameters : HexEncoded not null;
|
|
85
32
|
|
|
86
33
|
// Associations
|
|
87
|
-
parent
|
|
88
|
-
transactions
|
|
89
|
-
|
|
34
|
+
parent : Association to Blocks;
|
|
35
|
+
transactions : Composition of many Transactions
|
|
36
|
+
on transactions.block = $self;
|
|
37
|
+
systemParameters : Association to SystemParameters;
|
|
90
38
|
}
|
|
91
39
|
|
|
92
40
|
/**
|
|
93
41
|
* Represents a transaction in the Midnight blockchain
|
|
94
42
|
*/
|
|
95
43
|
entity Transactions : cuid, managed {
|
|
96
|
-
transactionId
|
|
97
|
-
hash
|
|
98
|
-
protocolVersion
|
|
99
|
-
raw
|
|
100
|
-
transactionType
|
|
44
|
+
transactionId : Integer not null; // index within block
|
|
45
|
+
hash : HexEncoded not null;
|
|
46
|
+
protocolVersion : Integer not null;
|
|
47
|
+
raw : LargeBinary; // hex-encoded serialized content
|
|
48
|
+
transactionType : TransactionType not null;
|
|
101
49
|
|
|
102
50
|
// Regular Transaction specific fields
|
|
103
|
-
merkleTreeRoot
|
|
104
|
-
startIndex
|
|
105
|
-
endIndex
|
|
106
|
-
identifiers
|
|
51
|
+
merkleTreeRoot : HexEncoded;
|
|
52
|
+
startIndex : Integer64; // zswap state start index
|
|
53
|
+
endIndex : Integer64; // zswap state end index
|
|
54
|
+
identifiers : LargeString; // JSON array of HexEncoded identifiers
|
|
107
55
|
|
|
108
56
|
// Classification fields (populated by Crawler / BlockProcessor)
|
|
109
|
-
txType
|
|
110
|
-
isShielded
|
|
111
|
-
senderAddress
|
|
112
|
-
receiverAddress
|
|
113
|
-
nightAmount
|
|
114
|
-
dustConsumed
|
|
115
|
-
hasProof
|
|
116
|
-
proofHash
|
|
117
|
-
contractAddress
|
|
118
|
-
circuitName
|
|
119
|
-
size
|
|
57
|
+
txType : TxType;
|
|
58
|
+
isShielded : Boolean default false;
|
|
59
|
+
senderAddress : String(256); // For unshielded TXs
|
|
60
|
+
receiverAddress : String(256); // For unshielded TXs
|
|
61
|
+
nightAmount : BigInt; // NIGHT amount transferred
|
|
62
|
+
dustConsumed : BigInt; // DUST consumed in fees
|
|
63
|
+
hasProof : Boolean default false;
|
|
64
|
+
proofHash : HexEncoded;
|
|
65
|
+
contractAddress : HexEncoded; // Contract address if contract TX
|
|
66
|
+
circuitName : String(100); // Entry point / circuit name for contract calls
|
|
67
|
+
size : Integer; // TX size in bytes
|
|
120
68
|
|
|
121
69
|
// Associations
|
|
122
|
-
block
|
|
123
|
-
transactionResult
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
70
|
+
block : Association to Blocks not null;
|
|
71
|
+
transactionResult : Composition of one TransactionResults
|
|
72
|
+
on transactionResult.transaction = $self;
|
|
73
|
+
transactionFees : Composition of one TransactionFees
|
|
74
|
+
on transactionFees.transaction = $self;
|
|
75
|
+
contractActions : Composition of many ContractActions
|
|
76
|
+
on contractActions.transaction = $self;
|
|
77
|
+
unshieldedCreatedOutputs : Composition of many UnshieldedUtxos
|
|
78
|
+
on unshieldedCreatedOutputs.createdAtTransaction = $self;
|
|
79
|
+
unshieldedSpentOutputs : Association to many UnshieldedUtxos
|
|
80
|
+
on unshieldedSpentOutputs.spentAtTransaction = $self;
|
|
81
|
+
zswapLedgerEvents : Composition of many ZswapLedgerEvents
|
|
82
|
+
on zswapLedgerEvents.transaction = $self;
|
|
83
|
+
dustLedgerEvents : Composition of many DustLedgerEvents
|
|
84
|
+
on dustLedgerEvents.transaction = $self;
|
|
130
85
|
}
|
|
131
86
|
|
|
132
87
|
/**
|
|
133
88
|
* Transaction execution result
|
|
134
89
|
*/
|
|
135
90
|
entity TransactionResults : cuid {
|
|
136
|
-
status
|
|
137
|
-
transaction
|
|
138
|
-
segments
|
|
91
|
+
status : TransactionResultStatus not null;
|
|
92
|
+
transaction : Association to Transactions;
|
|
93
|
+
segments : Composition of many TransactionSegments
|
|
94
|
+
on segments.transactionResult = $self;
|
|
139
95
|
}
|
|
140
96
|
|
|
141
97
|
/**
|
|
@@ -151,9 +107,9 @@ entity TransactionSegments : cuid {
|
|
|
151
107
|
* Transaction fee information
|
|
152
108
|
*/
|
|
153
109
|
entity TransactionFees : cuid {
|
|
154
|
-
paidFees
|
|
155
|
-
estimatedFees
|
|
156
|
-
transaction
|
|
110
|
+
paidFees : BigInt not null; // actual fees in DUST
|
|
111
|
+
estimatedFees : BigInt not null; // estimated fees in DUST
|
|
112
|
+
transaction : Association to Transactions;
|
|
157
113
|
}
|
|
158
114
|
|
|
159
115
|
// ============================================================================
|
|
@@ -164,25 +120,26 @@ entity TransactionFees : cuid {
|
|
|
164
120
|
* Contract actions (Deploy, Call, Update)
|
|
165
121
|
*/
|
|
166
122
|
entity ContractActions : cuid, managed {
|
|
167
|
-
address
|
|
168
|
-
state
|
|
169
|
-
zswapState
|
|
170
|
-
actionType
|
|
171
|
-
entryPoint
|
|
123
|
+
address : HexEncoded not null;
|
|
124
|
+
state : LargeBinary; // hex-encoded serialized state
|
|
125
|
+
zswapState : LargeBinary; // contract-specific zswap state
|
|
126
|
+
actionType : ContractActionType not null;
|
|
127
|
+
entryPoint : String(256); // only for CALL actions
|
|
172
128
|
|
|
173
129
|
// Associations
|
|
174
|
-
transaction
|
|
175
|
-
deploy
|
|
176
|
-
unshieldedBalances : Composition of many ContractBalances
|
|
130
|
+
transaction : Association to Transactions not null;
|
|
131
|
+
deploy : Association to ContractActions; // for CALL actions, reference to deployment
|
|
132
|
+
unshieldedBalances : Composition of many ContractBalances
|
|
133
|
+
on unshieldedBalances.contractAction = $self;
|
|
177
134
|
}
|
|
178
135
|
|
|
179
136
|
/**
|
|
180
137
|
* Token balances for contracts
|
|
181
138
|
*/
|
|
182
139
|
entity ContractBalances : cuid {
|
|
183
|
-
tokenType
|
|
184
|
-
amount
|
|
185
|
-
contractAction
|
|
140
|
+
tokenType : HexEncoded not null;
|
|
141
|
+
amount : BigInt not null; // balance as string (u128)
|
|
142
|
+
contractAction : Association to ContractActions;
|
|
186
143
|
}
|
|
187
144
|
|
|
188
145
|
// ============================================================================
|
|
@@ -193,18 +150,18 @@ entity ContractBalances : cuid {
|
|
|
193
150
|
* Unshielded Unspent Transaction Outputs
|
|
194
151
|
*/
|
|
195
152
|
entity UnshieldedUtxos : cuid, managed {
|
|
196
|
-
owner
|
|
197
|
-
tokenType
|
|
198
|
-
value
|
|
199
|
-
intentHash
|
|
200
|
-
outputIndex
|
|
201
|
-
ctime
|
|
202
|
-
initialNonce
|
|
153
|
+
owner : UnshieldedAddr not null; // Bech32m-encoded
|
|
154
|
+
tokenType : HexEncoded not null;
|
|
155
|
+
value : BigInt not null; // UTXO quantity (u128)
|
|
156
|
+
intentHash : HexEncoded not null;
|
|
157
|
+
outputIndex : Integer not null;
|
|
158
|
+
ctime : Integer; // creation timestamp (seconds)
|
|
159
|
+
initialNonce : HexEncoded not null; // for DUST tracking
|
|
203
160
|
registeredForDustGeneration : Boolean default false;
|
|
204
161
|
|
|
205
162
|
// Associations
|
|
206
|
-
createdAtTransaction
|
|
207
|
-
spentAtTransaction
|
|
163
|
+
createdAtTransaction : Association to Transactions not null;
|
|
164
|
+
spentAtTransaction : Association to Transactions;
|
|
208
165
|
}
|
|
209
166
|
|
|
210
167
|
// ============================================================================
|
|
@@ -215,25 +172,25 @@ entity UnshieldedUtxos : cuid, managed {
|
|
|
215
172
|
* Zswap Ledger Events
|
|
216
173
|
*/
|
|
217
174
|
entity ZswapLedgerEvents : cuid {
|
|
218
|
-
eventId
|
|
219
|
-
raw
|
|
220
|
-
maxId
|
|
221
|
-
transaction
|
|
175
|
+
eventId : Integer not null;
|
|
176
|
+
raw : LargeBinary; // hex-encoded serialized event
|
|
177
|
+
maxId : Integer not null;
|
|
178
|
+
transaction : Association to Transactions not null;
|
|
222
179
|
}
|
|
223
180
|
|
|
224
181
|
/**
|
|
225
182
|
* DUST Ledger Events
|
|
226
183
|
*/
|
|
227
184
|
entity DustLedgerEvents : cuid {
|
|
228
|
-
eventId
|
|
229
|
-
raw
|
|
230
|
-
maxId
|
|
231
|
-
eventType
|
|
185
|
+
eventId : Integer not null;
|
|
186
|
+
raw : LargeBinary; // hex-encoded serialized event
|
|
187
|
+
maxId : Integer not null;
|
|
188
|
+
eventType : DustLedgerEventType not null;
|
|
232
189
|
|
|
233
190
|
// For INITIAL_UTXO events
|
|
234
|
-
dustOutputNonce
|
|
191
|
+
dustOutputNonce : HexEncoded; // 32-byte nonce
|
|
235
192
|
|
|
236
|
-
transaction
|
|
193
|
+
transaction : Association to Transactions not null;
|
|
237
194
|
}
|
|
238
195
|
|
|
239
196
|
// ============================================================================
|
|
@@ -244,38 +201,38 @@ entity DustLedgerEvents : cuid {
|
|
|
244
201
|
* System-wide parameters
|
|
245
202
|
*/
|
|
246
203
|
entity SystemParameters : cuid, managed {
|
|
247
|
-
validFrom
|
|
248
|
-
validTo
|
|
204
|
+
validFrom : Timestamp not null;
|
|
205
|
+
validTo : Timestamp;
|
|
249
206
|
|
|
250
207
|
// D-Parameter (validator committee composition)
|
|
251
208
|
numPermissionedCandidates : Integer not null;
|
|
252
209
|
numRegisteredCandidates : Integer not null;
|
|
253
210
|
|
|
254
211
|
// Terms and Conditions
|
|
255
|
-
termsHash
|
|
256
|
-
termsUrl
|
|
212
|
+
termsHash : HexEncoded;
|
|
213
|
+
termsUrl : String(2048);
|
|
257
214
|
}
|
|
258
215
|
|
|
259
216
|
/**
|
|
260
217
|
* D-Parameter history for governance tracking
|
|
261
218
|
*/
|
|
262
219
|
entity DParameterHistory : cuid, managed {
|
|
263
|
-
effectiveFrom
|
|
264
|
-
effectiveTo
|
|
220
|
+
effectiveFrom : Timestamp not null;
|
|
221
|
+
effectiveTo : Timestamp;
|
|
265
222
|
numPermissionedCandidates : Integer not null;
|
|
266
223
|
numRegisteredCandidates : Integer not null;
|
|
267
|
-
block
|
|
224
|
+
block : Association to Blocks;
|
|
268
225
|
}
|
|
269
226
|
|
|
270
227
|
/**
|
|
271
228
|
* Terms and Conditions history
|
|
272
229
|
*/
|
|
273
230
|
entity TermsAndConditionsHistory : cuid, managed {
|
|
274
|
-
effectiveFrom
|
|
275
|
-
effectiveTo
|
|
276
|
-
hash
|
|
277
|
-
url
|
|
278
|
-
block
|
|
231
|
+
effectiveFrom : Timestamp not null;
|
|
232
|
+
effectiveTo : Timestamp;
|
|
233
|
+
hash : HexEncoded not null;
|
|
234
|
+
url : String(2048) not null;
|
|
235
|
+
block : Association to Blocks;
|
|
279
236
|
}
|
|
280
237
|
|
|
281
238
|
// ============================================================================
|
|
@@ -287,14 +244,14 @@ entity TermsAndConditionsHistory : cuid, managed {
|
|
|
287
244
|
*/
|
|
288
245
|
entity DustGenerationStatus : cuid, managed {
|
|
289
246
|
cardanoRewardAddress : CardanoRewardAddr not null;
|
|
290
|
-
dustAddress : DustAddr;
|
|
247
|
+
dustAddress : DustAddr; // Bech32m-encoded
|
|
291
248
|
registered : Boolean default false;
|
|
292
|
-
nightBalance : BigInt not null;
|
|
293
|
-
generationRate : BigInt not null;
|
|
294
|
-
maxCapacity : BigInt not null;
|
|
295
|
-
currentCapacity : BigInt not null;
|
|
296
|
-
utxoTxHash : HexEncoded;
|
|
297
|
-
utxoOutputIndex : Integer;
|
|
249
|
+
nightBalance : BigInt not null; // NIGHT backing (STAR)
|
|
250
|
+
generationRate : BigInt not null; // SPECK per second
|
|
251
|
+
maxCapacity : BigInt not null; // maximum SPECK capacity
|
|
252
|
+
currentCapacity : BigInt not null; // current SPECK capacity
|
|
253
|
+
utxoTxHash : HexEncoded; // Cardano UTXO tx hash
|
|
254
|
+
utxoOutputIndex : Integer; // Cardano UTXO output index
|
|
298
255
|
}
|
|
299
256
|
|
|
300
257
|
// ============================================================================
|
|
@@ -305,12 +262,12 @@ entity DustGenerationStatus : cuid, managed {
|
|
|
305
262
|
* Wallet sessions for authenticated access
|
|
306
263
|
*/
|
|
307
264
|
entity WalletSessions : cuid, managed {
|
|
308
|
-
viewingKeyHash : String(64);
|
|
309
|
-
encryptedViewingKey : LargeString;
|
|
265
|
+
viewingKeyHash : String(64); // SHA-256 of viewing key (for lookup/dedup)
|
|
266
|
+
encryptedViewingKey : LargeString; // AES-256-GCM encrypted viewing key
|
|
310
267
|
sessionId : UUID not null;
|
|
311
268
|
connectedAt : Timestamp not null;
|
|
312
269
|
disconnectedAt : Timestamp;
|
|
313
|
-
expiresAt : Timestamp;
|
|
270
|
+
expiresAt : Timestamp; // Session TTL
|
|
314
271
|
isActive : Boolean default true;
|
|
315
272
|
}
|
|
316
273
|
|
|
@@ -322,44 +279,44 @@ entity WalletSessions : cuid, managed {
|
|
|
322
279
|
* Indexer sync status — singleton table tracking crawler progress
|
|
323
280
|
*/
|
|
324
281
|
entity SyncState {
|
|
325
|
-
key ID
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
282
|
+
key ID : String(10) default 'SINGLETON';
|
|
283
|
+
networkId : String(30);
|
|
284
|
+
|
|
285
|
+
// Sync position
|
|
286
|
+
lastIndexedHeight : Integer64 default 0;
|
|
287
|
+
lastIndexedHash : HexEncoded;
|
|
288
|
+
lastIndexedAt : Timestamp;
|
|
289
|
+
|
|
290
|
+
// Finality tracking
|
|
291
|
+
lastFinalizedHeight : Integer64 default 0;
|
|
292
|
+
lastFinalizedHash : HexEncoded;
|
|
293
|
+
|
|
294
|
+
// Node info
|
|
295
|
+
nodeUrl : String(200);
|
|
296
|
+
chainHeight : Integer64 default 0;
|
|
297
|
+
|
|
298
|
+
// Status
|
|
299
|
+
syncStatus : SyncStatus default 'stopped';
|
|
300
|
+
syncProgress : Decimal(5, 2) default 0;
|
|
301
|
+
blocksPerSecond : Decimal(10, 2) default 0;
|
|
302
|
+
|
|
303
|
+
// Errors
|
|
304
|
+
lastError : String(500);
|
|
305
|
+
lastErrorAt : Timestamp;
|
|
306
|
+
consecutiveErrors : Integer default 0;
|
|
350
307
|
}
|
|
351
308
|
|
|
352
309
|
/**
|
|
353
310
|
* Reorg history — tracks blockchain reorganizations detected by the crawler
|
|
354
311
|
*/
|
|
355
312
|
entity ReorgLog : cuid, managed {
|
|
356
|
-
detectedAt
|
|
357
|
-
forkHeight
|
|
358
|
-
oldTipHash
|
|
359
|
-
newTipHash
|
|
360
|
-
blocksRolledBack
|
|
361
|
-
blocksReIndexed
|
|
362
|
-
status
|
|
313
|
+
detectedAt : Timestamp not null;
|
|
314
|
+
forkHeight : Integer64 not null;
|
|
315
|
+
oldTipHash : HexEncoded not null;
|
|
316
|
+
newTipHash : HexEncoded not null;
|
|
317
|
+
blocksRolledBack : Integer default 0;
|
|
318
|
+
blocksReIndexed : Integer default 0;
|
|
319
|
+
status : String(20); // 'completed', 'failed'
|
|
363
320
|
}
|
|
364
321
|
|
|
365
322
|
// ============================================================================
|
|
@@ -370,29 +327,29 @@ entity ReorgLog : cuid, managed {
|
|
|
370
327
|
* Unshielded NIGHT token balances per address
|
|
371
328
|
*/
|
|
372
329
|
entity NightBalances {
|
|
373
|
-
key address
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
330
|
+
key address : String(256);
|
|
331
|
+
balance : Decimal(20, 0) default 0;
|
|
332
|
+
utxoCount : Integer default 0;
|
|
333
|
+
|
|
334
|
+
// Activity tracking
|
|
335
|
+
firstSeenHeight : Integer64;
|
|
336
|
+
firstSeenAt : Timestamp;
|
|
337
|
+
lastActivityHeight : Integer64;
|
|
338
|
+
lastActivityAt : Timestamp;
|
|
339
|
+
|
|
340
|
+
// TX statistics
|
|
341
|
+
txSentCount : Integer default 0;
|
|
342
|
+
txReceivedCount : Integer default 0;
|
|
343
|
+
totalSent : Decimal(20, 0) default 0;
|
|
344
|
+
totalReceived : Decimal(20, 0) default 0;
|
|
345
|
+
|
|
346
|
+
// DUST linkage
|
|
347
|
+
dustAddress : DustAddr;
|
|
348
|
+
isDustRegistered : Boolean default false;
|
|
349
|
+
|
|
350
|
+
// Indexer metadata
|
|
351
|
+
lastUpdatedHeight : Integer64;
|
|
352
|
+
lastUpdatedAt : Timestamp;
|
|
396
353
|
}
|
|
397
354
|
|
|
398
355
|
/**
|
|
@@ -400,126 +357,38 @@ entity NightBalances {
|
|
|
400
357
|
*/
|
|
401
358
|
entity DustRegistrations : cuid, managed {
|
|
402
359
|
// Cardano side
|
|
403
|
-
cardanoStakeKey
|
|
404
|
-
cardanoTxHash
|
|
360
|
+
cardanoStakeKey : String(66) not null;
|
|
361
|
+
cardanoTxHash : HexEncoded not null;
|
|
405
362
|
|
|
406
363
|
// Midnight side
|
|
407
|
-
dustPublicKey
|
|
408
|
-
nightAddress
|
|
364
|
+
dustPublicKey : HexEncoded not null;
|
|
365
|
+
nightAddress : String(256) not null;
|
|
409
366
|
|
|
410
367
|
// Status
|
|
411
|
-
isActive
|
|
412
|
-
registeredAt
|
|
413
|
-
deregisteredAt
|
|
368
|
+
isActive : Boolean default true;
|
|
369
|
+
registeredAt : Timestamp not null;
|
|
370
|
+
deregisteredAt : Timestamp;
|
|
414
371
|
|
|
415
372
|
// NIGHT amount backing DUST generation
|
|
416
|
-
nightAmount
|
|
373
|
+
nightAmount : Decimal(20, 0);
|
|
417
374
|
}
|
|
418
375
|
|
|
419
376
|
/**
|
|
420
377
|
* Token type registry — tracks all known token types on the Midnight network
|
|
421
378
|
*/
|
|
422
379
|
entity TokenTypes {
|
|
423
|
-
key tokenTypeId
|
|
424
|
-
|
|
425
|
-
|
|
380
|
+
key tokenTypeId : HexEncoded;
|
|
381
|
+
tokenName : String(100);
|
|
382
|
+
tokenCategory : TokenCategory;
|
|
426
383
|
|
|
427
|
-
|
|
428
|
-
|
|
384
|
+
// For contract-created tokens
|
|
385
|
+
contractAddress : HexEncoded;
|
|
429
386
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
387
|
+
// Metadata
|
|
388
|
+
decimals : Integer;
|
|
389
|
+
totalSupply : Decimal(30, 0);
|
|
433
390
|
|
|
434
|
-
|
|
435
|
-
|
|
391
|
+
firstSeenHeight : Integer64;
|
|
392
|
+
firstSeenAt : Timestamp;
|
|
436
393
|
}
|
|
437
394
|
|
|
438
|
-
// ============================================================================
|
|
439
|
-
// Annotations
|
|
440
|
-
// ============================================================================
|
|
441
|
-
|
|
442
|
-
annotate Blocks with @(
|
|
443
|
-
Capabilities: {
|
|
444
|
-
InsertRestrictions: { Insertable: false },
|
|
445
|
-
UpdateRestrictions: { Updatable: false },
|
|
446
|
-
DeleteRestrictions: { Deletable: false }
|
|
447
|
-
}
|
|
448
|
-
) {
|
|
449
|
-
hash @title: 'Block Hash';
|
|
450
|
-
height @title: 'Block Height';
|
|
451
|
-
};
|
|
452
|
-
|
|
453
|
-
annotate Transactions with @(
|
|
454
|
-
Capabilities: {
|
|
455
|
-
InsertRestrictions: { Insertable: false },
|
|
456
|
-
UpdateRestrictions: { Updatable: false },
|
|
457
|
-
DeleteRestrictions: { Deletable: false }
|
|
458
|
-
}
|
|
459
|
-
) {
|
|
460
|
-
hash @title: 'Transaction Hash';
|
|
461
|
-
};
|
|
462
|
-
|
|
463
|
-
annotate ContractActions with @(
|
|
464
|
-
Capabilities: {
|
|
465
|
-
InsertRestrictions: { Insertable: false },
|
|
466
|
-
UpdateRestrictions: { Updatable: false },
|
|
467
|
-
DeleteRestrictions: { Deletable: false }
|
|
468
|
-
}
|
|
469
|
-
) {
|
|
470
|
-
address @title: 'Contract Address';
|
|
471
|
-
};
|
|
472
|
-
|
|
473
|
-
annotate UnshieldedUtxos with @(
|
|
474
|
-
Capabilities: {
|
|
475
|
-
InsertRestrictions: { Insertable: false },
|
|
476
|
-
UpdateRestrictions: { Updatable: false },
|
|
477
|
-
DeleteRestrictions: { Deletable: false }
|
|
478
|
-
}
|
|
479
|
-
);
|
|
480
|
-
|
|
481
|
-
annotate DustGenerationStatus with {
|
|
482
|
-
cardanoRewardAddress @title: 'Cardano Reward Address';
|
|
483
|
-
nightBalance @title: 'NIGHT Balance';
|
|
484
|
-
generationRate @title: 'Generation Rate';
|
|
485
|
-
};
|
|
486
|
-
|
|
487
|
-
annotate SyncState with @(
|
|
488
|
-
Capabilities: {
|
|
489
|
-
InsertRestrictions: { Insertable: false },
|
|
490
|
-
DeleteRestrictions: { Deletable: false }
|
|
491
|
-
}
|
|
492
|
-
) {
|
|
493
|
-
syncStatus @title: 'Sync Status';
|
|
494
|
-
lastIndexedHeight @title: 'Last Indexed Height';
|
|
495
|
-
};
|
|
496
|
-
|
|
497
|
-
annotate NightBalances with @(
|
|
498
|
-
Capabilities: {
|
|
499
|
-
InsertRestrictions: { Insertable: false },
|
|
500
|
-
UpdateRestrictions: { Updatable: false },
|
|
501
|
-
DeleteRestrictions: { Deletable: false }
|
|
502
|
-
}
|
|
503
|
-
) {
|
|
504
|
-
address @title: 'Address';
|
|
505
|
-
balance @title: 'NIGHT Balance';
|
|
506
|
-
};
|
|
507
|
-
|
|
508
|
-
annotate ReorgLog with @(
|
|
509
|
-
Capabilities: {
|
|
510
|
-
InsertRestrictions: { Insertable: false },
|
|
511
|
-
UpdateRestrictions: { Updatable: false },
|
|
512
|
-
DeleteRestrictions: { Deletable: false }
|
|
513
|
-
}
|
|
514
|
-
);
|
|
515
|
-
|
|
516
|
-
annotate TokenTypes with @(
|
|
517
|
-
Capabilities: {
|
|
518
|
-
InsertRestrictions: { Insertable: false },
|
|
519
|
-
UpdateRestrictions: { Updatable: false },
|
|
520
|
-
DeleteRestrictions: { Deletable: false }
|
|
521
|
-
}
|
|
522
|
-
) {
|
|
523
|
-
tokenTypeId @title: 'Token Type ID';
|
|
524
|
-
tokenName @title: 'Token Name';
|
|
525
|
-
};
|