-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpresets.mjs
More file actions
388 lines (382 loc) · 17.1 KB
/
presets.mjs
File metadata and controls
388 lines (382 loc) · 17.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
export const presets = {
'presets': {
'accountBalance': {
'description': 'Retrieve current balance of given account.',
'input': {
'query': {
'cmd': "query q($publicKey: PublicKey!) {\naccount(publicKey: $publicKey) {\nbalance {\nblockHeight\ntotal\nstateHash\n}nonce\n}}",
'schema': 'proxy'
},
'variables': {
'publicKey': {
'default': {
'berkeley': 'B62qnEdPB1V5YPEcGaETb19naLJV6sWdveCZEjSLhcVyrPcPWHkGGax'
},
'description': 'Set the mina address public key.',
'validation': 'regexs__minaPublicKey',
'required': true
},
}
},
'output': {
'key': 'account',
'type': 'hash'
}
},
'transactionsFromSender': {
'description': 'Retrieve transactions which was sended by given address',
'input': {
'query': {
'cmd': 'query q($senderAddress: String!, $limit: Int!, $sortBy: TransactionSortByInput!) {\n transactions(limit: $limit, sortBy: $sortBy, query: {from: $senderAddress}) {\n from\n to\n amount\n memo\n hash\n dateTime\n block {\n commandTransactionCount\n blockHeight\n }\n nonce\n fee\n }\n}',
'schema': 'standard'
},
'variables': {
'senderAddress': {
'default': {
'berkeley': 'B62qnEdPB1V5YPEcGaETb19naLJV6sWdveCZEjSLhcVyrPcPWHkGGax',
},
'description': 'Set the mina address public key.',
'validation': 'regexs__minaPublicKey',
'required': true
},
'limit': {
'default': {
'berkeley': 2
},
'description': 'Set a limit on how many results will be shown.',
'validation': 'regexs__limit',
'required': false
},
'sortBy': {
'default': {
'berkeley': 'BLOCKHEIGHT_DESC'
},
'description': 'Set the sorting type between ascending and descending.',
'validation': 'regexs__blockHeightSorting',
'required': false
}
}
},
'output': {
'key': 'transactions',
'type': 'array'
}
},
'transactionsFromReceiver': {
'description': 'Retrieve ',
'input': {
'query': {
'cmd': "query q($receiverAddress: String!, $limit: Int!, $sortBy: TransactionSortByInput!) {\n transactions(limit: $limit, sortBy: $sortBy, query: {receiver: {publicKey: $receiverAddress}}) {\n from\n to\n amount\n memo\n hash\n dateTime\n block {\n commandTransactionCount\n blockHeight\n }\n nonce\n }\n}",
'schema': 'standard'
},
'variables': {
'receiverAddress': {
'default': {
'berkeley': 'B62qqhjvvE3dwiX2hF2cZRfmHA7euo8MrzvZhPHgXJNb57vuiWePAWC',
},
'description': 'Set the mina address public key.',
'validation': 'regexs__minaPublicKey',
'required': true
},
'limit': {
'default': {
'berkeley': 2
},
'description': 'Set a limit on how many results will be shown.',
'validation': 'regexs__limit',
'required': false
},
'sortBy': {
'default': {
'berkeley': 'BLOCKHEIGHT_DESC'
},
'description': 'Set the sorting type between ascending and descending.',
'validation': 'regexs__blockHeightSorting',
'required': false
}
}
},
'output': {
'key': 'transactions',
'type': 'array'
}
},
'transactionsSenderToReceiver': {
'description': 'Retrieve transactions which took place between 2 given addresses',
'input': {
'query': {
'cmd': "query q($senderAddress: String!, $receiverAddress: String!, $limit: Int!, $sortBy: TransactionSortByInput!) {\n transactions(limit: $limit, sortBy: $sortBy, query: {from: $senderAddress, to: $receiverAddress}) {\n from\n to\n amount\n memo\n hash\n dateTime\n block {\n commandTransactionCount\n blockHeight\n }\n nonce\n fee\n }\n}",
'schema': 'standard'
},
'variables': {
'senderAddress': {
'default': {
'berkeley': 'B62qqhjvvE3dwiX2hF2cZRfmHA7euo8MrzvZhPHgXJNb57vuiWePAWC'
},
'description': 'Set the mina address public key.',
'validation': 'regexs__minaPublicKey',
'required': true
},
'receiverAddress': {
'default': {
'berkeley': 'B62qkFUnG64NjiRoghwpdFmVGm6fiZiSxiyphmV2juXFypLivqV35S3'
},
'description': 'Set the mina address public key.',
'validation': 'regexs__minaPublicKey',
'required': true
},
'limit': {
'default': {
'berkeley': 2
},
'description': 'Set a limit on how many results will be shown.',
'validation': 'regexs__limit',
'required': false
},
'sortBy': {
'default': {
'berkeley': 'BLOCKHEIGHT_DESC'
},
'description': 'Set the sorting type between ascending and descending.',
'validation': 'regexs__blockHeightSorting',
'required': false
}
}
},
'output': {
'key': 'transactions',
'type': 'array'
}
},
'transactionByHash': {
'description': 'Retrieve transaction data using a given transaction hash.',
'input': {
'query': {
'cmd': "query q($hash: String!) {\n transaction(query: {hash: $hash}) {\n hash\n dateTime\n blockHeight\n from\n nonce\n to\n toAccount {\n token\n }\n }\n}",
'schema': 'standard'
},
'variables': {
'hash': {
'default': {
'berkeley': '5Ju7HSdjQcPpgzkjECVdmErhuri3VMLm2N7b4z2mB6kMbbKnFHx1'
},
'description': 'Set the transaction hash string.',
'validation': 'regexs__transactionHash',
'required': true
}
}
},
'output': {
'key': 'transaction',
'type': 'hash'
}
},
'latestBlockHeight': {
'description': 'Retrieve the most recent block height from the selected blockchain.',
'input': {
'query': {
'cmd': "query q($blockHeight_lt: Int) {\n block(query: {blockHeight_lt: $blockHeight_lt}) {\n blockHeight\n dateTime\n }\n}",
'schema': 'standard'
},
'variables': {
'blockHeight_lt': {
'default': {
'berkeley': 999999999
},
'description': 'Set the highest block height.',
'validation': 'regexs__blockHeight_lt',
'required': false
}
}
},
'output': {
'key': 'block',
'type': 'hash'
}
},
'latestBlockHeights': {
'description': 'Retrieve the most recent block height from the selected blockchain.',
'input': {
'query': {
'cmd': "query q($limit: Int) {\n blocks(limit: $limit, sortBy: BLOCKHEIGHT_DESC) {\n blockHeight\n protocolState {\n consensusState {\n slotSinceGenesis\n slot\n }\n }\n dateTime\n receivedTime\n }\n}",
'schema': 'standard'
},
'variables': {
'limit': {
'default': {
'berkeley': 10
},
'description': 'Set a limit on how many results will be shown.',
'validation': 'regexs__limit',
'required': false
}
}
},
'output': {
'key': 'blocks',
'type': 'array'
}
},
'transactionsFromMemo': {
'description': 'Retrieve transaction which memoHash has not a certain value, can be useful to find not empty memo fields.',
'input': {
'query': {
'cmd': 'query g($memoHash: [String], $limit: Int!, $sortBy: TransactionSortByInput!) {\n transactions(limit: $limit, query: {memo_nin: $memoHash}, sortBy: $sortBy) {\n memo\n hash\n dateTime\n receiver {\n publicKey\n }\n from\n }\n}',
'schema': 'standard'
},
'variables': {
'memoHash': {
'default': {
'berkeley': 'E4Yd67s51QN9DZVDy8JKPEoNGykMsYQ5KRiKpZHiLZTjA8dB9SnFT'
},
'description': 'Expects an encoded base58 string.',
'validation': 'regexs__memoHash',
'required': true
},
'limit': {
'default': {
'berkeley': 3
},
'description': 'Set a limit on how many results will be shown.',
'validation': 'regexs__limit',
'required': false
},
'sortBy': {
'default': {
'berkeley': 'BLOCKHEIGHT_DESC'
},
'description': 'Set the sorting type between ascending and descending.',
'validation': 'regexs__blockHeightSorting',
'required': false
}
}
},
'output': {
'key': 'transactions',
'type': 'array'
}
},
'eventFromTransactionHash': {
'description': 'Retreive the event which is attached to an transaction',
'input': {
'query': {
'cmd': "query q($hash: String!) {\n event(query: {zkAppCommandHash: {hash: $hash}}) {\n dateTime\n blockHeight\n event\n zkAppCommandHash {\n zkappCommand {\n accountUpdates {\n body {\n publicKey\n }\n }\n memo\n feePayer {\n body {\n publicKey\n }\n }\n }\n hash\n }\n }\n}",
'schema': 'standard'
},
'variables': {
'hash': {
'default': {
'berkeley': '5JvLQnkBhcqNNsCi3fVgKdbmYkhykZvE1GZNGixUPngjq3vHyMmf'
},
'description': 'Set the transaction hash string.',
'validation': 'regexs__transactionHash',
'required': true
}
}
},
'output': {
'key': 'event',
'type': 'hash'
}
},
'eventsFromContract': {
'description': 'Retrieve the latest events from a Mina contract.',
'input': {
'query': {
'cmd': "query q($limit: Int!, $blockHeight_lt: Int!, $creator: String!) {\n events(query: {blockHeight_lt: $blockHeight_lt, blockStateHash: {creator: $creator}}, sortBy: BLOCKHEIGHT_DESC, limit: $limit) {\n blockHeight\n dateTime\n event\n blockStateHash {\n creatorAccount {\n publicKey\n }\n }\n }\n}",
'schema': 'standard'
},
'variables': {
'creator': {
'default': {
'berkeley': 'B62qnLVz8wM7MfJsuYbjFf4UWbwrUBEL5ZdawExxxFhnGXB6siqokyM'
},
'description': 'Set the creator\'s address as the minimum address.',
'validation': 'regexs__minaPublicKey',
'required': true
},
'limit': {
'default': {
'berkeley': 10
},
'description': 'Set a limit on how many results will be shown.',
'validation': 'regexs__limit',
'required': false
},
'blockHeight_lt': {
'default': {
'berkeley': 999999999
},
'description': 'highest block',
'validation': 'regexs__blockHeight_lt',
'required': false
}
}
},
'output': {
'key': 'events',
'type': 'array'
}
}
},
'regexs': {
'transactionHash': {
'regex': /^[a-zA-Z0-9]{52}$/,
'description': 'Allowed is only a string consisting of 52 alphanumeric characters, including both letters and numbers.',
'post': 'string'
},
'memoString': {
'regex': '',
'desciption': '',
'post': 'string'
},
'memoHash': {
'regex': /^E4[1-9A-HJ-NP-Za-km-z]{51}$/,
'description': 'Allowed are only strings that start with "E4" followed by exactly 51 characters from the base58 set, which excludes the numbers 0, and the letters O, I, and l.',
'post': 'string'
},
'blockHeight_lt': {
'regex': /^(0|[1-9]\d{0,8})$/,
'description': 'Allowed is only a non-negative integer up to 9 digits long, not starting with any zeros unless it is the number zero itself.',
'post': 'integer'
},
'limit': {
'regex': /[0-9]{0,2}/,
'description': 'Allowed is only a number up to two digits long, which can be any value from 0 to 99.',
'post': 'integer'
},
'minaPublicKey': {
'regex': /^B62[1-9A-HJ-NP-Za-km-z]{52}$/,
'description': 'Allowed is only a string that starts with \'B62\' followed by a sequence of base58 characters, with no specified maximum length.',
'post': 'string'
},
'blockHeightSorting': {
'regex': /^(BLOCKHEIGHT_DESC|BLOCKHEIGHT_ASC)$/,
'description': "Allowed is only the specific text 'BLOCKHEIGHT_DESC' or 'BLOCKHEIGHT_ASC', representing sorting directions for block height.",
'post': 'string'
}
}
}
/*
function getPresets() {
return Object
.entries( templates['presets'] )
.reduce( ( acc, a, index ) => {
const [ key, value ] = a
acc[ key ] = value
acc[ key ]['input']['variables'] = Object
.entries( acc[ key ]['input']['variables'] )
.reduce( ( abb, b, rindex ) => {
const [ _key, _value ] = b
abb[ _key ] = _value
abb[ _key ]['regex'] = keyPathToValue( {
'data': templates,
'keyPath': abb[ _key ]['regex']
} )
return abb
}, {} )
return acc
}, {} )
}
export const presets = getPresets()
*/