├── .DS_Store ├── .eslintrc.js ├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── config └── default.json ├── jsdoc.conf ├── package-lock.json ├── package.json ├── patches └── hyperswarm+4.8.4.patch ├── src ├── BlockDownloader.mjs ├── RestModule.mjs ├── TapProtocol.mjs ├── TracManager.mjs ├── WebsocketModule.mjs └── main.mjs └── test └── restmodule.test.js /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trac-Systems/tap-reader/6eed3e648c010037fda84b020929a9cd5da8631e/.DS_Store -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "env": { 3 | "commonjs": true, 4 | "es2021": true, 5 | "node": true 6 | }, 7 | "extends": "eslint:recommended", 8 | "overrides": [ 9 | { 10 | "env": { 11 | "node": true 12 | }, 13 | "files": [ 14 | ".eslintrc.{js,cjs}" 15 | ], 16 | "parserOptions": { 17 | "sourceType": "script" 18 | } 19 | } 20 | ], 21 | "parserOptions": { 22 | "ecmaVersion": "latest", 23 | "sourceType": "module", 24 | }, 25 | "rules": { 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | /tap-reader/ 3 | tapstore/ 4 | node_modules/ 5 | /cert/ 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2024 Trac Systems 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | 9 | Join Us 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Trac Core Reader for TAP Protocol 2 | 3 | Trac Core Reader for TAP Protocol is a NodeJS-based application that provides decentralized access to indexed TAP Protocol data. 4 | 5 | The reader basically represents a decentralized API to build upon Bitcoin Ordinal's TAP Protocol. 6 | 7 | It sits on top of Holepunch (https://github.com/holepunchto), a set of libraries that enables decentralized data-storage and distribution. 8 | 9 | You may run this reader within various restricted networks. Through holepunching, it will try to connect with its peers on the network through any means necessary, helping to maintain steady availability. 10 | 11 | As a project/developer, you may use this reader in 3 different ways: 12 | 13 | - Utilizing the TracManager's native methods (see below) 14 | - Enabling REST Endpoints 15 | - Using websocket-based streaming 16 | - ... or all of the above combined. 17 | 18 | If you do not intend to develop with this package but want to support the project, you may just run it in the background to help strengthen the network. 19 | 20 | Trac Core Reader for TAP Protocol is open-source (MIT license) and in beta state, use it on your own risk as stated in the license. 21 | 22 | ## How it works 23 | 24 | The reader connects to the Trac network by subscribing to a channel to request indexing data. Currently the indexers behind this channel are not part of the entire Trac Core release yet but will be released at a later point (the actual writers). 25 | 26 | Once a channel has been picked (in the config or upon start), the reader will try to look for peers and starts to share data, similar to how it works with for example with Bittorrent. 27 | 28 | This data can then be used through the different APIs that this package provides for further processing within your apps. 29 | 30 | ## Channel Hopping 31 | 32 | Should indexer upgrades require a new channel to hop on, the new channel will be broadcasted through different means by the Trac project. 33 | 34 | Ultimately, Trac will carefully roll out an entire system that allows for automated channel hopping as well as decentralized upgrade broadcasts. 35 | 36 | The most recent channel is always pre-defined in the reader's config of this repo. 37 | 38 | ## Requirements 39 | 40 | - Linux, Windows, MacOS 41 | - NodeJS 20+ 42 | - 2-4 CPU Cores, 8GB RAM 43 | - 150GB SSD drive (make sure it's a good one) 44 | 45 | Should work perfectly on Pi 4-5 and low Watts. 46 | 47 | ## Installation 48 | 49 | Either download this package using git clone or install it through npmjs (if you use npmjs, you'll need to specify your entry point yourself): 50 | 51 | ``` 52 | git clone https://github.com/Trac-Systems/tap-reader.git 53 | cd tap-reader 54 | npm i 55 | npm start 56 | ``` 57 | 58 | ## Running in background 59 | 60 | There are several different ways to run readers in the background. We recommend to use PM2 to run and organize your readers, especially if you are running multiple instances: 61 | 62 | https://pm2.keymetrics.io/ 63 | 64 | ## API Usage 65 | 66 | Either use the reader diretly like so from within your application (please note that your app process will have exclusive access to the reader's db): 67 | 68 | ```js 69 | import TracManager from "./TracManager.mjs"; 70 | 71 | // Create an instance of TracManager 72 | let tracCore = new TracManager(); 73 | 74 | // Initialize the reader for the TAP Protocol 75 | await tracCore.initReader(); 76 | 77 | // Example: Retrieve transfer amount by inscription 78 | let amount = await tracCore.tapProtocol.getTransferAmountByInscription('1b8e21761557bbf66c06ae3d8109764d0d8ec5d431b8291160b59ef28ffaab7ai0'); 79 | 80 | ``` 81 | 82 | If rest is enabled, you can instead use the exposed endpoints. You may test these endpoints like this if REST is enabled in the config: 83 | 84 | ``` 85 | http://localhost:5099/docs 86 | ``` 87 | 88 | In case websockets are enabled, you can access their endpoints according to this documentation: 89 | 90 | https://github.com/BennyTheDev/trac-tap-public-endpoint 91 | 92 | Just swap out the given domain in that endpoint example above with your websocket url and port. 93 | 94 | ## Configuration File 95 | > Defaults to ./config/default.json file, enabling websocket server if needed. 96 | 97 | ```json 98 | { 99 | "enableRest": true, 100 | "enableRestApiDocs": true, 101 | "restPort": 5099, 102 | "restCacheControl": { 103 | "maxAge": 1, 104 | "public": false 105 | }, 106 | "enableRestSSL" : false, 107 | "sslCert" : { 108 | "cert" : "/path/to/cert.crt", 109 | "key" : "/path/to/cert.key" 110 | }, 111 | "restHeaders": [ 112 | { "name": "X-Powered-By", "value": "TracCore" }, 113 | { "name": "Access-Control-Allow-Origin", "value": "*" } 114 | ], 115 | "enableWebsockets": false, 116 | "websocketPort": 5095, 117 | "websocketCORS": "*", 118 | "channel": "53b2c0e70485790d7f086edbbbb8e624a165667bc74b12034d9774c2f3ce503c", 119 | "enableBlockDownloader": false, 120 | "host" : "0.0.0.0" 121 | } 122 | ``` 123 | 124 | ## Bitcoin 125 | 126 | > Distributed MAINNET Data Channel "53b2c0e70485790d7f086edbbbb8e624a165667bc74b12034d9774c2f3ce503c" is the currently active LIVE channel for TAP Protocol. 127 | 128 | > Distributed TESTNET Data Channel "f505c35965a89d62cb4144f9523fc4ede43186c7c37a66b77388eaede210e051" is the currently active TEST channel for TAP Protocol. 129 | 130 | > Distributed SIGNET Data Channel "3665c09b9e6c173ba0302bee91ad036981d66a6dd9b51d83bc443c8ec2a6efd8" is the currently active TEST channel for TAP Protocol. 131 | 132 | ## Doge 133 | 134 | > Distributed MAINNET Data Channel "42b96d26080afde178b621fbe9a1680250c18811fb52356acc6580256abb781e" is the currently active LIVE channel for TAP Protocol. 135 | 136 | ## Trac Core Manager API 137 | 138 |
139 |
initReader([server], [client], [rangeStart], [rangeEnd])Promise.<void>
140 |

Initializes the reader for the TAP Protocol, setting up corestore and hyperswarm. 141 | Also configures the Hyperbee database and, optionally, a websocket and REST server.

142 |
143 |
initHyperswarm(server, client)Promise.<void>
144 |

Initializes a Hyperswarm network connection for data synchronization.

145 |
146 | 147 |
148 | 149 | 150 | 151 | ## initReader([server], [client], [rangeStart], [rangeEnd]) ⇒ Promise.<void> 152 | Initializes the reader for the TAP Protocol, setting up corestore and hyperswarm. 153 | Also configures the Hyperbee database and, optionally, a websocket server. 154 | 155 | **Kind**: global function 156 | **Returns**: Promise.<void> - A promise that resolves when initialization is complete. 157 | 158 | | Param | Type | Default | Description | 159 | | --- | --- | --- | --- | 160 | | [server] | boolean | true | Whether to start as a server in the Hyperswarm network. | 161 | | [client] | boolean | true | Whether to start as a client in the Hyperswarm network. | 162 | | [rangeStart] | number | -1 | The starting index for range-based data download. | 163 | | [rangeEnd] | number | -1 | The ending index for range-based data download. | 164 | 165 | 166 | 167 | ## initHyperswarm(server, client) ⇒ Promise.<void> 168 | Initializes a Hyperswarm network connection for data synchronization. 169 | 170 | **Kind**: global function 171 | **Returns**: Promise.<void> - A promise that resolves when the network is initialized. 172 | 173 | | Param | Type | Description | 174 | | --- | --- | --- | 175 | | server | boolean | Indicates if this instance should act as a server. | 176 | | client | boolean | Indicates if this instance should act as a client. | 177 | 178 | # Tap Protocol API 179 | 180 |
181 |
getSyncStatus()Promise.<(Number|null)>
182 |

Retrieves the current synchronization status, indicating the percentage of blocks that have been successfully synced.

183 |
184 | 185 |
186 |
getReorgs()Promise.<(Array|null)>
187 |

Retrieves a list of blockchain reorganizations detected by the connected writer.

188 |
189 | 190 |
getDmtMintWalletHistoricListLength(address)Promise.<number>
191 |

Retrieves the total number of historic DMT Mints for a specific address.

192 |
193 | 194 |
getDmtMintWalletHistoricList(address, offset, max)Promise.<(Object[]|string)>
195 |

Fetches a historical list of DMT Mints ownership for a specific address.

196 |
197 | 198 |
getDmtMintHoldersHistoryListLength(inscription_id)Promise.<number>
199 |

Determines the number of holder changes for a specific DMT Mint.

200 |
201 | 202 |
getDmtMintHoldersHistoryList(inscription_id, offset, max)Promise.<(Object[]|string)>
203 |

Retrieves the ownership history of a DMT Mint.

204 |
205 | 206 |
getDmtMintHolderByBlock(block)Promise.<(Object|null)>
207 |

Provides a history object based on a given block number.

208 |
209 | 210 |
getDmtMintHolder(inscription_id)Promise.<(Object|null)>
211 |

Fetches a history object for a specific DMT Mint.

212 |
213 | 214 |
getTransferAmountByInscription(inscription_id)Promise.<(number|null)>
215 |

Retrieves the transfer amount for a given inscription ID.

216 |
217 |
getDeploymentsLength()Promise.<number>
218 |

Gets the total number of deployments.

219 |
220 |
getDeployments([offset], [max])Promise.<Array>
221 |

Retrieves a list of deployments.

222 |
223 |
getDeployment(ticker)Promise.<(Object|null)>
224 |

Retrieves details of a specific deployment based on its ticker.

225 |
226 |
getMintTokensLeft(ticker)Promise.<(number|null)>
227 |

Gets the remaining number of tokens that can be minted for a given ticker.

228 |
229 |
getBalance(address, ticker)Promise.<(number|null)>
230 |

Retrieves the balance of a specific address for a given ticker.

231 |
232 |
getTransferable(address, ticker)Promise.<(number|null)>
233 |

Retrieves the transferable amount for a specific address and ticker.

234 |
235 |
getHoldersLength(ticker)Promise.<number>
236 |

Gets the total number of holders for a given ticker.

237 |
238 |
getHolders(ticker, [offset], [max])Promise.<Array>
239 |

Retrieves a list of holders for a specific ticker.

240 |
241 |
getAccountTokensLength(address)Promise.<number>
242 |

Gets the total number of tokens held by a specific address.

243 |
244 |
getAccountTokens(address, [offset], [max])Promise.<Array>
245 |

Retrieves a list of tokens held by a specific address.

246 |
247 |
getDmtElementsListLength()Promise.<number>
248 |

Gets the total number of DMT elements.

249 |
250 |
getDmtElementsList([offset], [max])Promise.<Array>
251 |

Retrieves a list of DMT elements.

252 |
253 |
getAccountMintListLength(address, ticker)Promise.<number>
254 |

Gets the total number of mints performed by a specific address for a given ticker.

255 |
256 |
getAccountMintList(address, ticker)Promise.<number>
257 |

Gets the total number of mints performed by a specific address for a given ticker.

258 |
259 |
getTickerMintListLength(ticker)Promise.<number>
260 |

Gets the total number of mints performed by a specific address for a given ticker.

261 |
262 |
getTickerMintList(ticker, [offset], [max])Promise.<Array>
263 |

Retrieves a list of mint records for a specific address and ticker.

264 |
265 |
getMintListLength(ticker)Promise.<number>
266 |

Gets the total number of mints for a given ticker.

267 |
268 |
getMintList([offset], [max])Promise.<Array>
269 |

Retrieves a list of all mint records across all tickers.

270 |
271 |
getTrade(inscription_id)Promise.<(Object|null)>
272 |

Retrieves details of a specific trade based on its inscription ID.

273 |
274 |
getAccountTradesListLength(address, ticker)Promise.<number>
275 |

Gets the total number of trades for a specific address and ticker.

276 |
277 |
getAccountTradesList(address, ticker, [offset], [max])Promise.<Array>
278 |

Retrieves a list of trades for a specific address and ticker.

279 |
280 |
getAuthCancelled(inscription_id)Promise.<boolean>
281 |

Checks if a given token-auth inscription has been cancelled.

282 |
283 |
getAuthHashExists(hash)Promise.<boolean>
284 |

Checks if a given hash exists in the token-auth system.

285 |
286 |
getRedeemListLength()Promise.<number>
287 |

Gets the total number of redeems across all tokens.

288 |
289 |
getRedeemList([offset], [max])Promise.<Array>
290 |

Retrieves a list of all redeem records across all tokens.

291 |
292 |
getAccountRedeemListLength(address)Promise.<number>
293 |

Gets the total number of redeems performed by a specific address.

294 |
295 |
getAccountRedeemList(address, [offset], [max])Promise.<Array>
296 |

Retrieves a list of redeem records for a specific address.

297 |
298 |
getAccountAuthListLength(address)Promise.<number>
299 |

Gets the total number of token auth records for a specific address.

300 |
301 |
getAccountAuthList(address, [offset], [max])Promise.<Array>
302 |

Retrieves a list of token auth records for a specific address.

303 |
304 |
getAuthListLength()Promise.<number>
305 |

Gets the total number of token auth records across all addresses.

306 |
307 |
getAuthList([offset], [max])Promise.<Array>
308 |

Retrieves a list of all token auth records across all addresses.

309 |
310 | 311 |
getAccountgetPrivilegeAuthListAuthListLength(address)Promise.<number>
312 |

Gets the total number of privilege auth records for a specific address.

313 |
314 |
getAccountgetPrivilegeAuthListAuthList(address, [offset], [max])Promise.<Array>
315 |

Retrieves a list of privilege auth records for a specific address.

316 |
317 |
getgetPrivilegeAuthListAuthListLength()Promise.<number>
318 |

Gets the total number of privilege auth records across all addresses.

319 |
320 |
getgetPrivilegeAuthListAuthList([offset], [max])Promise.<Array>
321 |

Retrieves a list of all privilege auth records across all addresses.

322 |
323 | 324 | 325 |
getTickerTradesListLength(ticker)Promise.<number>
326 |

Gets the total number of trades for a specific ticker.

327 |
328 |
getTickerTradesList(ticker, [offset], [max])Promise.<Array>
329 |

Retrieves a list of trades for a specific ticker.

330 |
331 |
getTradesListLength()Promise.<number>
332 |

Gets the total number of trades across all tickers.

333 |
334 |
getTradesList([offset], [max])Promise.<Array>
335 |

Retrieves a list of all trade records across all tickers.

336 |
337 |
getAccountTransferListLength(address, ticker)Promise.<number>
338 |

Gets the total number of transfers for a specific address and ticker.

339 |
340 |
getAccountTransferList(address, ticker, [offset], [max])Promise.<Array>
341 |

Retrieves a list of transfer records for a specific address and ticker.

342 |
343 |
getTickerTransferListLength(ticker)Promise.<number>
344 |

Gets the total number of transfers for a given ticker.

345 |
346 |
getTickerTransferList(ticker, [offset], [max])Promise.<Array>
347 |

Retrieves a list of transfer records for a specific ticker.

348 |
349 |
getTransferListLength()Promise.<number>
350 |

Gets the total number of transfers across all tickers.

351 |
352 |
getTransferList([offset], [max])Promise.<Array>
353 |

Retrieves a list of all transfer records across all tickers.

354 |
355 |
getAccountSentListLength(address, ticker)Promise.<number>
356 |

Gets the total number of sent transactions for a specific address and ticker.

357 |
358 |
getAccountSentList(address, ticker, [offset], [max])Promise.<Array>
359 |

Retrieves a list of sent transaction records for a specific address and ticker.

360 |
361 |
getAccountReceiveTradesFilledListLength(address, ticker)Promise.<number>
362 |

Gets the total number of received trades filled for a specific address and ticker.

363 |
364 |
getAccountReceiveTradesFilledList(address, ticker, [offset], [max])Promise.<Array>
365 |

Retrieves a list of received trades filled for a specific address and ticker.

366 |
367 |
getAccountTradesFilledListLength(address, ticker)Promise.<number>
368 |

Gets the total number of trades filled for a specific address and ticker.

369 |
370 |
getAccountTradesFilledList(address, ticker, [offset], [max])Promise.<Array>
371 |

Retrieves a list of trades filled for a specific address and ticker.

372 |
373 |
getTickerTradesFilledListLength(ticker)Promise.<number>
374 |

Gets the total number of trades filled for a specific ticker.

375 |
376 |
getTickerTradesFilledList(ticker, [offset], [max])Promise.<Array>
377 |

Retrieves a list of filled trade records for a specific ticker.

378 |
379 |
getTradesFilledListLength()Promise.<number>
380 |

Gets the total number of filled trades across all tickers.

381 |
382 |
getTradesFilledList([offset], [max])Promise.<(Array|Object)>
383 |

Asynchronously retrieves a list of trades that have been filled.

384 |
385 |
getAccountReceiveListLength(address, ticker)Promise.<number>
386 |

Gets the length of the account receive list for a given address and ticker.

387 |
388 |
getAccountReceiveList(address, ticker, [offset], [max])Promise.<(Array|Object)>
389 |

Retrieves a list of received transactions for a specific account and ticker.

390 |
391 |
getTickerSentListLength(ticker)Promise.<number>
392 |

Gets the length of the sent list for a specific ticker.

393 |
394 |
getTickerSentList(ticker, [offset], [max])Promise.<(Array|Object)>
395 |

Retrieves a list of sent transactions for a specific ticker.

396 |
397 |
getSentListLength()Promise.<number>
398 |

Gets the total length of the sent transactions list.

399 |
400 |
getSentList([offset], [max])Promise.<(Array|Object)>
401 |

Retrieves the list of all sent transactions.

402 |
403 |
getAccumulator(inscription)Promise.<(Object|null)>
404 |

Retrieves the accumulator object for a given inscription.

405 |
406 |
getAccountAccumulatorListLength(address)Promise.<number>
407 |

Gets the total number of accumulator entries for a specific Bitcoin address.

408 |
409 |
getAccountAccumulatorList(address, [offset], [max])Promise.<(Array|Object)>
410 |

Retrieves a list of accumulator records for a specified address.

411 |
412 |
getAccumulatorListLength()Promise.<number>
413 |

Retrieves the total length of the accumulator list.

414 |
415 |
getAccumulatorList([offset], [max])Promise.<(Array|Object)>
416 |

Retrieves a list of accumulators.

417 |
418 |
getListRecords(length_key, iterator_key, offset, max, return_json)Promise.<(Array|Object|string)>
419 |

Asynchronously retrieves a batch of list records based on specified keys and limits.

420 |
421 |
getLength(length_key)Promise.<number>
422 |

Gets the length of a list based on a specified key.

423 |
424 |
425 | 426 | 427 | 428 | ## getSyncStatus() ⇒ `Promise` 429 | 430 | Retrieves the current synchronization status, indicating the percentage of blocks that have been successfully synced. 431 | 432 | **Returns**: `Promise` - A number representing the percentage of blocks synced. If the block downloader is not active, returns null. 433 | 434 | 435 | 436 | ## getReorgs() ⇒ `Promise` 437 | 438 | Retrieves a list of blockchain reorganizations detected by the connected writer, crucial for maintaining data integrity after blockchain reorgs. 439 | 440 | **Returns**: `Promise` - An array of detected reorgs, or `null` if none were found. 441 | 442 | 443 | 444 | ## getDmtMintWalletHistoricListLength(address) ⇒ `Promise` 445 | 446 | Retrieves the total number of historic DMT Mints for a specific address. This function is essential for understanding the historical interactions of an address with DMT Mints. 447 | 448 | **Returns**: `Promise` - The number of historic DMT Mints associated with the given address. 449 | | Param | Type | Description | 450 | | --- | --- | --- | 451 | | address | `string` | The address to query. | 452 | 453 | 454 | 455 | ## getDmtMintWalletHistoricList(address, offset, max) ⇒ `Promise` 456 | 457 | Fetches a historical list of DMT Mints ownership for a specific address. This list should be compared with current ownership data for accuracy. 458 | 459 | **Returns**: `Promise` - An array of historic DMT Mint ownership records or an error message. 460 | 461 | | Param | Type | Description | 462 | | --- | --- | --- | 463 | | address | `string` | The address to query. | 464 | | offset | `int` | The starting index for pagination. Optional, default `0`. | 465 | | max | `int` | The maximum number of records to retrieve. Optional, default `500`. | 466 | 467 | 468 | 469 | ## getDmtMintHoldersHistoryListLength(inscription_id) ⇒ `Promise` 470 | 471 | Determines the number of holder changes for a specific DMT Mint, providing insight into its trading history. 472 | 473 | **Returns**: `Promise` - The number of holder changes for the specified DMT Mint. 474 | 475 | | Param | Type | Description | 476 | | --- | --- | --- | 477 | | inscription_id | `string` | The ID of the DMT Mint to query. | 478 | 479 | 480 | 481 | ## getDmtMintHoldersHistoryList(inscription_id, offset, max) ⇒ `Promise` 482 | 483 | Retrieves the ownership history of a DMT Mint, including details of each transaction and ownership change. 484 | 485 | **Returns**: `Promise` - An array of DMT Mint ownership history records or an error message. 486 | 487 | | Param | Type | Description | 488 | | --- | --- | --- | 489 | | inscription_id | `string` | The ID of the DMT Mint to query. | 490 | | offset | `int` | The starting index for pagination. Optional, default `0`. | 491 | | max | `int` | The maximum number of records to retrieve. Optional, default `500`. | 492 | 493 | 494 | 495 | ## getDmtMintHolderByBlock(block) ⇒ `Promise` 496 | 497 | Provides a history object containing element, owner, and block data based on a given block number instead of an inscription ID. 498 | 499 | **Returns**: `Promise` - A history object with element, owner, and block data, or `null` if not found. 500 | 501 | | Param | Type | Description | 502 | | --- | --- | --- | 503 | | block | `int` | The block number to query. | 504 | 505 | 506 | 507 | ## getDmtMintHolder(inscription_id) ⇒ `Promise` 508 | 509 | Fetches a history object containing details about the holder, element, and associated block data for a specific DMT Mint. 510 | 511 | **Returns**: `Promise` - A history object with holder, element, and block data, or `null` if not found. 512 | 513 | | Param | Type | Description | 514 | | --- | --- | --- | 515 | | inscription_id | `string` | The ID of the DMT Mint to query. | 516 | 517 | 518 | 519 | ## getTransferAmountByInscription(inscription_id) ⇒ Promise.<(number\|null)> 520 | Retrieves the transfer amount for a given inscription ID. 521 | 522 | **Kind**: global function 523 | **Returns**: Promise.<(number\|null)> - The transfer amount or null if not found. 524 | 525 | | Param | Type | Description | 526 | | --- | --- | --- | 527 | | inscription_id | string | The ID of the inscription to query. | 528 | 529 | 530 | 531 | ## getDeploymentsLength() ⇒ Promise.<number> 532 | Gets the total number of deployments. 533 | 534 | **Kind**: global function 535 | **Returns**: Promise.<number> - The total number of deployments. 536 | 537 | 538 | ## getDeployments([offset], [max]) ⇒ Promise.<Array> 539 | Retrieves a list of deployments. 540 | 541 | **Kind**: global function 542 | **Returns**: Promise.<Array> - An array of deployment records. 543 | 544 | | Param | Type | Default | Description | 545 | | --- | --- | --- | --- | 546 | | [offset] | number | 0 | The starting index for retrieving deployments. | 547 | | [max] | number | 500 | The maximum number of deployments to retrieve. | 548 | 549 | 550 | 551 | ## getDeployment(ticker) ⇒ Promise.<(Object\|null)> 552 | Retrieves details of a specific deployment based on its ticker. 553 | 554 | **Kind**: global function 555 | **Returns**: Promise.<(Object\|null)> - Deployment details or null if not found. 556 | 557 | | Param | Type | Description | 558 | | --- | --- | --- | 559 | | ticker | string | The ticker of the deployment to retrieve. | 560 | 561 | 562 | 563 | ## getMintTokensLeft(ticker) ⇒ Promise.<(number\|null)> 564 | Gets the remaining number of tokens that can be minted for a given ticker. 565 | 566 | **Kind**: global function 567 | **Returns**: Promise.<(number\|null)> - The number of tokens left to mint or null if not available. 568 | 569 | | Param | Type | Description | 570 | | --- | --- | --- | 571 | | ticker | string | The ticker for which to retrieve the remaining mintable tokens. | 572 | 573 | 574 | 575 | ## getBalance(address, ticker) ⇒ Promise.<(number\|null)> 576 | Retrieves the balance of a specific address for a given ticker. 577 | 578 | **Kind**: global function 579 | **Returns**: Promise.<(number\|null)> - The balance of the address or null if not found. 580 | 581 | | Param | Type | Description | 582 | | --- | --- | --- | 583 | | address | string | The address for which to retrieve the balance. | 584 | | ticker | string | The ticker of the token. | 585 | 586 | 587 | 588 | ## getTransferable(address, ticker) ⇒ Promise.<(number\|null)> 589 | Retrieves the transferable amount for a specific address and ticker. 590 | 591 | **Kind**: global function 592 | **Returns**: Promise.<(number\|null)> - The transferable amount or null if not found. 593 | 594 | | Param | Type | Description | 595 | | --- | --- | --- | 596 | | address | string | The address for which to retrieve the transferable amount. | 597 | | ticker | string | The ticker of the token. | 598 | 599 | 600 | 601 | ## getHoldersLength(ticker) ⇒ Promise.<number> 602 | Gets the total number of holders for a given ticker. 603 | 604 | **Kind**: global function 605 | **Returns**: Promise.<number> - The number of holders for the specified ticker. 606 | 607 | | Param | Type | Description | 608 | | --- | --- | --- | 609 | | ticker | string | The ticker for which to retrieve the number of holders. | 610 | 611 | 612 | 613 | ## getHolders(ticker, [offset], [max]) ⇒ Promise.<Array> 614 | Retrieves a list of holders for a specific ticker. 615 | 616 | **Kind**: global function 617 | **Returns**: Promise.<Array> - An array of holder records. 618 | 619 | | Param | Type | Default | Description | 620 | | --- | --- | --- | --- | 621 | | ticker | string | | The ticker for which to retrieve holders. | 622 | | [offset] | number | 0 | The starting index for retrieving holders. | 623 | | [max] | number | 500 | The maximum number of holders to retrieve. | 624 | 625 | 626 | 627 | ## getAccountTokensLength(address) ⇒ Promise.<number> 628 | Gets the total number of tokens held by a specific address. 629 | 630 | **Kind**: global function 631 | **Returns**: Promise.<number> - The number of tokens held by the specified address. 632 | 633 | | Param | Type | Description | 634 | | --- | --- | --- | 635 | | address | string | The address for which to retrieve the token count. | 636 | 637 | 638 | 639 | ## getAccountTokens(address, [offset], [max]) ⇒ Promise.<Array> 640 | Retrieves a list of tokens held by a specific address. 641 | 642 | **Kind**: global function 643 | **Returns**: Promise.<Array> - An array of token tickers. 644 | 645 | | Param | Type | Default | Description | 646 | | --- | --- | --- | --- | 647 | | address | string | | The address for which to retrieve tokens. | 648 | | [offset] | number | 0 | The starting index for retrieving tokens. | 649 | | [max] | number | 500 | The maximum number of tokens to retrieve. | 650 | 651 | 652 | 653 | ## getDmtElementsListLength() ⇒ Promise.<number> 654 | Gets the total number of DMT elements. 655 | 656 | **Kind**: global function 657 | **Returns**: Promise.<number> - The total number of DMT elements. 658 | 659 | 660 | ## getDmtElementsList([offset], [max]) ⇒ Promise.<Array> 661 | Retrieves a list of DMT elements. 662 | 663 | **Kind**: global function 664 | **Returns**: Promise.<Array> - An array of DMT element records. 665 | 666 | | Param | Type | Default | Description | 667 | | --- | --- | --- | --- | 668 | | [offset] | number | 0 | The starting index for retrieving DMT elements. | 669 | | [max] | number | 500 | The maximum number of DMT elements to retrieve. | 670 | 671 | 672 | 673 | ## getAccountMintListLength(address, ticker) ⇒ Promise.<number> 674 | Gets the total number of mints performed by a specific address for a given ticker. 675 | 676 | **Kind**: global function 677 | **Returns**: Promise.<number> - The number of mints performed by the address for the specified ticker. 678 | 679 | | Param | Type | Description | 680 | | --- | --- | --- | 681 | | address | string | The address for which to retrieve the mint count. | 682 | | ticker | string | The ticker of the token. | 683 | 684 | 685 | 686 | ## getAccountMintList(address, ticker) ⇒ Promise.<number> 687 | Gets the total number of mints performed by a specific address for a given ticker. 688 | 689 | **Kind**: global function 690 | **Returns**: Promise.<number> - The number of mints performed by the address for the specified ticker. 691 | 692 | | Param | Type | Description | 693 | | --- | --- | --- | 694 | | address | string | The address for which to retrieve the mint count. | 695 | | ticker | string | The ticker of the token. | 696 | 697 | 698 | 699 | ## getTickerMintListLength(address, ticker) ⇒ Promise.<number> 700 | Gets the total number of mints performed by a specific address for a given ticker. 701 | 702 | **Kind**: global function 703 | **Returns**: Promise.<number> - The number of mints performed by the address for the specified ticker. 704 | 705 | | Param | Type | Description | 706 | | --- | --- | --- | 707 | | address | string | The address for which to retrieve the mint count. | 708 | | ticker | string | The ticker of the token. | 709 | 710 | 711 | 712 | ## getTickerMintList(address, ticker, [offset], [max]) ⇒ Promise.<Array> 713 | Retrieves a list of mint records for a specific address and ticker. 714 | 715 | **Kind**: global function 716 | **Returns**: Promise.<Array> - An array of mint records. 717 | 718 | | Param | Type | Default | Description | 719 | | --- | --- | --- | --- | 720 | | address | string | | The address for which to retrieve mint records. | 721 | | ticker | string | | The ticker of the token. | 722 | | [offset] | number | 0 | The starting index for retrieving mint records. | 723 | | [max] | number | 500 | The maximum number of mint records to retrieve. | 724 | 725 | 726 | 727 | ## getMintListLength(ticker) ⇒ Promise.<number> 728 | Gets the total number of mints for a given ticker. 729 | 730 | **Kind**: global function 731 | **Returns**: Promise.<number> - The number of mints for the specified ticker. 732 | 733 | | Param | Type | Description | 734 | | --- | --- | --- | 735 | | ticker | string | The ticker for which to retrieve the mint count. | 736 | 737 | 738 | 739 | ## getMintList([offset], [max]) ⇒ Promise.<Array> 740 | Retrieves a list of all mint records across all tickers. 741 | 742 | **Kind**: global function 743 | **Returns**: Promise.<Array> - An array of mint records. 744 | 745 | | Param | Type | Default | Description | 746 | | --- | --- | --- | --- | 747 | | [offset] | number | 0 | The starting index for retrieving mint records. | 748 | | [max] | number | 500 | The maximum number of mint records to retrieve. | 749 | 750 | 751 | 752 | ## getTrade(inscription_id) ⇒ Promise.<(Object\|null)> 753 | Retrieves details of a specific trade based on its inscription ID. 754 | 755 | **Kind**: global function 756 | **Returns**: Promise.<(Object\|null)> - Trade details or null if not found. 757 | 758 | | Param | Type | Description | 759 | | --- | --- | --- | 760 | | inscription_id | string | The ID of the trade inscription to query. | 761 | 762 | 763 | 764 | ## getAccountTradesListLength(address, ticker) ⇒ Promise.<number> 765 | Gets the total number of trades for a specific address and ticker. 766 | 767 | **Kind**: global function 768 | **Returns**: Promise.<number> - The number of trades for the specified address and ticker. 769 | 770 | | Param | Type | Description | 771 | | --- | --- | --- | 772 | | address | string | The address for which to retrieve the trade count. | 773 | | ticker | string | The ticker of the token. | 774 | 775 | 776 | 777 | ## getAccountTradesList(address, ticker, [offset], [max]) ⇒ Promise.<Array> 778 | Retrieves a list of trades for a specific address and ticker. 779 | 780 | **Kind**: global function 781 | **Returns**: Promise.<Array> - An array of trade records. 782 | 783 | | Param | Type | Default | Description | 784 | | --- | --- | --- | --- | 785 | | address | string | | The address for which to retrieve trades. | 786 | | ticker | string | | The ticker of the token. | 787 | | [offset] | number | 0 | The starting index for retrieving trades. | 788 | | [max] | number | 500 | The maximum number of trades to retrieve. | 789 | 790 | 791 | 792 | ## getAuthCancelled(inscription_id) ⇒ Promise.<boolean> 793 | Checks if a given token-auth inscription has been cancelled. 794 | 795 | **Kind**: global function 796 | **Returns**: Promise.<boolean> - True if the inscription is cancelled, false otherwise. 797 | 798 | | Param | Type | Description | 799 | | --- | --- | --- | 800 | | inscription_id | string | The ID of the token-auth inscription to check. | 801 | 802 | 803 | 804 | ## getAuthHashExists(hash) ⇒ Promise.<boolean> 805 | Checks if a given hash exists in the token-auth system. 806 | 807 | **Kind**: global function 808 | **Returns**: Promise.<boolean> - True if the hash exists, false otherwise. 809 | 810 | | Param | Type | Description | 811 | | --- | --- | --- | 812 | | hash | string | The hash to check for existence. | 813 | 814 | 815 | 816 | ## getRedeemListLength() ⇒ Promise.<number> 817 | Gets the total number of redeems across all tokens. 818 | 819 | **Kind**: global function 820 | **Returns**: Promise.<number> - The total number of redeems. 821 | 822 | 823 | ## getRedeemList([offset], [max]) ⇒ Promise.<Array> 824 | Retrieves a list of all redeem records across all tokens. 825 | 826 | **Kind**: global function 827 | **Returns**: Promise.<Array> - An array of redeem records. 828 | 829 | | Param | Type | Default | Description | 830 | | --- | --- | --- | --- | 831 | | [offset] | number | 0 | The starting index for retrieving redeem records. | 832 | | [max] | number | 500 | The maximum number of redeem records to retrieve. | 833 | 834 | 835 | 836 | ## getAccountRedeemListLength(address) ⇒ Promise.<number> 837 | Gets the total number of redeems performed by a specific address. 838 | 839 | **Kind**: global function 840 | **Returns**: Promise.<number> - The number of redeems performed by the specified address. 841 | 842 | | Param | Type | Description | 843 | | --- | --- | --- | 844 | | address | string | The address for which to retrieve the redeem count. | 845 | 846 | 847 | 848 | ## getAccountRedeemList(address, [offset], [max]) ⇒ Promise.<Array> 849 | Retrieves a list of redeem records for a specific address. 850 | 851 | **Kind**: global function 852 | **Returns**: Promise.<Array> - An array of redeem records for the specified address. 853 | 854 | | Param | Type | Default | Description | 855 | | --- | --- | --- | --- | 856 | | address | string | | The address for which to retrieve redeem records. | 857 | | [offset] | number | 0 | The starting index for retrieving redeem records. | 858 | | [max] | number | 500 | The maximum number of redeem records to retrieve. | 859 | 860 | 861 | 862 | ## getAccountAuthListLength(address) ⇒ Promise.<number> 863 | Gets the total number of auth records for a specific address. 864 | 865 | **Kind**: global function 866 | **Returns**: Promise.<number> - The number of auth records for the specified address. 867 | 868 | | Param | Type | Description | 869 | | --- | --- | --- | 870 | | address | string | The address for which to retrieve the auth count. | 871 | 872 | 873 | 874 | ## getAccountAuthList(address, [offset], [max]) ⇒ Promise.<Array> 875 | Retrieves a list of auth records for a specific address. 876 | 877 | **Kind**: global function 878 | **Returns**: Promise.<Array> - An array of auth records for the specified address. 879 | 880 | | Param | Type | Default | Description | 881 | | --- | --- | --- | --- | 882 | | address | string | | The address for which to retrieve auth records. | 883 | | [offset] | number | 0 | The starting index for retrieving auth records. | 884 | | [max] | number | 500 | The maximum number of auth records to retrieve. | 885 | 886 | 887 | 888 | ## getAuthListLength() ⇒ Promise.<number> 889 | Gets the total number of auth records across all addresses. 890 | 891 | **Kind**: global function 892 | **Returns**: Promise.<number> - The total number of auth records. 893 | 894 | 895 | ## getAuthList([offset], [max]) ⇒ Promise.<Array> 896 | Retrieves a list of all auth records across all addresses. 897 | 898 | **Kind**: global function 899 | **Returns**: Promise.<Array> - An array of auth records. 900 | 901 | | Param | Type | Default | Description | 902 | | --- | --- | --- | --- | 903 | | [offset] | number | 0 | The starting index for retrieving auth records. | 904 | | [max] | number | 500 | The maximum number of auth records to retrieve. | 905 | 906 | 907 | 908 | 909 | 910 | 911 | ## getAccountPrivilegeAuthListLength(address) ⇒ Promise.<number> 912 | Gets the total number of auth records for a specific address. 913 | 914 | **Kind**: global function 915 | **Returns**: Promise.<number> - The number of auth records for the specified address. 916 | 917 | | Param | Type | Description | 918 | | --- | --- | --- | 919 | | address | string | The address for which to retrieve the auth count. | 920 | 921 | 922 | 923 | ## getAccountPrivilegeAuthList(address, [offset], [max]) ⇒ Promise.<Array> 924 | Retrieves a list of auth records for a specific address. 925 | 926 | **Kind**: global function 927 | **Returns**: Promise.<Array> - An array of auth records for the specified address. 928 | 929 | | Param | Type | Default | Description | 930 | | --- | --- | --- | --- | 931 | | address | string | | The address for which to retrieve auth records. | 932 | | [offset] | number | 0 | The starting index for retrieving auth records. | 933 | | [max] | number | 500 | The maximum number of auth records to retrieve. | 934 | 935 | 936 | 937 | ## getPrivilegeAuthListLength() ⇒ Promise.<number> 938 | Gets the total number of auth records across all addresses. 939 | 940 | **Kind**: global function 941 | **Returns**: Promise.<number> - The total number of auth records. 942 | 943 | 944 | ## getPrivilegeAuthList([offset], [max]) ⇒ Promise.<Array> 945 | Retrieves a list of all auth records across all addresses. 946 | 947 | **Kind**: global function 948 | **Returns**: Promise.<Array> - An array of auth records. 949 | 950 | | Param | Type | Default | Description | 951 | | --- | --- | --- | --- | 952 | | [offset] | number | 0 | The starting index for retrieving auth records. | 953 | | [max] | number | 500 | The maximum number of auth records to retrieve. | 954 | 955 | 956 | 957 | 958 | 959 | 960 | ## getTickerTradesListLength(ticker) ⇒ Promise.<number> 961 | Gets the total number of trades for a specific ticker. 962 | 963 | **Kind**: global function 964 | **Returns**: Promise.<number> - The number of trades for the specified ticker. 965 | 966 | | Param | Type | Description | 967 | | --- | --- | --- | 968 | | ticker | string | The ticker for which to retrieve the trade count. | 969 | 970 | 971 | 972 | ## getTickerTradesList(ticker, [offset], [max]) ⇒ Promise.<Array> 973 | Retrieves a list of trades for a specific ticker. 974 | 975 | **Kind**: global function 976 | **Returns**: Promise.<Array> - An array of trade records for the specified ticker. 977 | 978 | | Param | Type | Default | Description | 979 | | --- | --- | --- | --- | 980 | | ticker | string | | The ticker for which to retrieve trades. | 981 | | [offset] | number | 0 | The starting index for retrieving trades. | 982 | | [max] | number | 500 | The maximum number of trades to retrieve. | 983 | 984 | 985 | 986 | ## getTradesListLength() ⇒ Promise.<number> 987 | Gets the total number of trades across all tickers. 988 | 989 | **Kind**: global function 990 | **Returns**: Promise.<number> - The total number of trades. 991 | 992 | 993 | ## getTradesList([offset], [max]) ⇒ Promise.<Array> 994 | Retrieves a list of all trade records across all tickers. 995 | 996 | **Kind**: global function 997 | **Returns**: Promise.<Array> - An array of all trade records. 998 | 999 | | Param | Type | Default | Description | 1000 | | --- | --- | --- | --- | 1001 | | [offset] | number | 0 | The starting index for retrieving trade records. | 1002 | | [max] | number | 500 | The maximum number of trade records to retrieve. | 1003 | 1004 | 1005 | 1006 | ## getAccountTransferListLength(address, ticker) ⇒ Promise.<number> 1007 | Gets the total number of transfers for a specific address and ticker. 1008 | 1009 | **Kind**: global function 1010 | **Returns**: Promise.<number> - The number of transfers for the specified address and ticker. 1011 | 1012 | | Param | Type | Description | 1013 | | --- | --- | --- | 1014 | | address | string | The address for which to retrieve the transfer count. | 1015 | | ticker | string | The ticker of the token. | 1016 | 1017 | 1018 | 1019 | ## getAccountTransferList(address, ticker, [offset], [max]) ⇒ Promise.<Array> 1020 | Retrieves a list of transfer records for a specific address and ticker. 1021 | 1022 | **Kind**: global function 1023 | **Returns**: Promise.<Array> - An array of transfer records for the specified address and ticker. 1024 | 1025 | | Param | Type | Default | Description | 1026 | | --- | --- | --- | --- | 1027 | | address | string | | The address for which to retrieve transfer records. | 1028 | | ticker | string | | The ticker of the token. | 1029 | | [offset] | number | 0 | The starting index for retrieving transfer records. | 1030 | | [max] | number | 500 | The maximum number of transfer records to retrieve. | 1031 | 1032 | 1033 | 1034 | ## getTickerTransferListLength(ticker) ⇒ Promise.<number> 1035 | Gets the total number of transfers for a given ticker. 1036 | 1037 | **Kind**: global function 1038 | **Returns**: Promise.<number> - The number of transfers for the specified ticker. 1039 | 1040 | | Param | Type | Description | 1041 | | --- | --- | --- | 1042 | | ticker | string | The ticker for which to retrieve the transfer count. | 1043 | 1044 | 1045 | 1046 | ## getTickerTransferList(ticker, [offset], [max]) ⇒ Promise.<Array> 1047 | Retrieves a list of transfer records for a specific ticker. 1048 | 1049 | **Kind**: global function 1050 | **Returns**: Promise.<Array> - An array of transfer records for the specified ticker. 1051 | 1052 | | Param | Type | Default | Description | 1053 | | --- | --- | --- | --- | 1054 | | ticker | string | | The ticker for which to retrieve transfer records. | 1055 | | [offset] | number | 0 | The starting index for retrieving transfer records. | 1056 | | [max] | number | 500 | The maximum number of transfer records to retrieve. | 1057 | 1058 | 1059 | 1060 | ## getTransferListLength() ⇒ Promise.<number> 1061 | Gets the total number of transfers across all tickers. 1062 | 1063 | **Kind**: global function 1064 | **Returns**: Promise.<number> - The total number of transfers. 1065 | 1066 | 1067 | ## getTransferList([offset], [max]) ⇒ Promise.<Array> 1068 | Retrieves a list of all transfer records across all tickers. 1069 | 1070 | **Kind**: global function 1071 | **Returns**: Promise.<Array> - An array of all transfer records. 1072 | 1073 | | Param | Type | Default | Description | 1074 | | --- | --- | --- | --- | 1075 | | [offset] | number | 0 | The starting index for retrieving transfer records. | 1076 | | [max] | number | 500 | The maximum number of transfer records to retrieve. | 1077 | 1078 | 1079 | 1080 | ## getAccountSentListLength(address, ticker) ⇒ Promise.<number> 1081 | Gets the total number of sent transactions for a specific address and ticker. 1082 | 1083 | **Kind**: global function 1084 | **Returns**: Promise.<number> - The number of sent transactions for the specified address and ticker. 1085 | 1086 | | Param | Type | Description | 1087 | | --- | --- | --- | 1088 | | address | string | The address for which to retrieve the sent count. | 1089 | | ticker | string | The ticker of the token. | 1090 | 1091 | 1092 | 1093 | ## getAccountSentList(address, ticker, [offset], [max]) ⇒ Promise.<Array> 1094 | Retrieves a list of sent transaction records for a specific address and ticker. 1095 | 1096 | **Kind**: global function 1097 | **Returns**: Promise.<Array> - An array of sent transaction records for the specified address and ticker. 1098 | 1099 | | Param | Type | Default | Description | 1100 | | --- | --- | --- | --- | 1101 | | address | string | | The address for which to retrieve sent transaction records. | 1102 | | ticker | string | | The ticker of the token. | 1103 | | [offset] | number | 0 | The starting index for retrieving sent transaction records. | 1104 | | [max] | number | 500 | The maximum number of sent transaction records to retrieve. | 1105 | 1106 | 1107 | 1108 | ## getAccountReceiveTradesFilledListLength(address, ticker) ⇒ Promise.<number> 1109 | Gets the total number of received trades filled for a specific address and ticker. 1110 | 1111 | **Kind**: global function 1112 | **Returns**: Promise.<number> - The number of received trades filled for the specified address and ticker. 1113 | 1114 | | Param | Type | Description | 1115 | | --- | --- | --- | 1116 | | address | string | The address for which to retrieve the count. | 1117 | | ticker | string | The ticker of the token. | 1118 | 1119 | 1120 | 1121 | ## getAccountReceiveTradesFilledList(address, ticker, [offset], [max]) ⇒ Promise.<Array> 1122 | Retrieves a list of received trades filled for a specific address and ticker. 1123 | 1124 | **Kind**: global function 1125 | **Returns**: Promise.<Array> - An array of received trades filled records for the specified address and ticker. 1126 | 1127 | | Param | Type | Default | Description | 1128 | | --- | --- | --- | --- | 1129 | | address | string | | The address for which to retrieve records. | 1130 | | ticker | string | | The ticker of the token. | 1131 | | [offset] | number | 0 | The starting index for retrieving records. | 1132 | | [max] | number | 500 | The maximum number of records to retrieve. | 1133 | 1134 | 1135 | 1136 | ## getAccountTradesFilledListLength(address, ticker) ⇒ Promise.<number> 1137 | Gets the total number of trades filled for a specific address and ticker. 1138 | 1139 | **Kind**: global function 1140 | **Returns**: Promise.<number> - The number of trades filled for the specified address and ticker. 1141 | 1142 | | Param | Type | Description | 1143 | | --- | --- | --- | 1144 | | address | string | The address for which to retrieve the trade count. | 1145 | | ticker | string | The ticker of the token. | 1146 | 1147 | 1148 | 1149 | ## getAccountTradesFilledList(address, ticker, [offset], [max]) ⇒ Promise.<Array> 1150 | Retrieves a list of trades filled for a specific address and ticker. 1151 | 1152 | **Kind**: global function 1153 | **Returns**: Promise.<Array> - An array of filled trade records for the specified address and ticker. 1154 | 1155 | | Param | Type | Default | Description | 1156 | | --- | --- | --- | --- | 1157 | | address | string | | The address for which to retrieve filled trades. | 1158 | | ticker | string | | The ticker of the token. | 1159 | | [offset] | number | 0 | The starting index for retrieving filled trades. | 1160 | | [max] | number | 500 | The maximum number of filled trades to retrieve. | 1161 | 1162 | 1163 | 1164 | ## getTickerTradesFilledListLength(ticker) ⇒ Promise.<number> 1165 | Gets the total number of trades filled for a specific ticker. 1166 | 1167 | **Kind**: global function 1168 | **Returns**: Promise.<number> - The number of filled trades for the specified ticker. 1169 | 1170 | | Param | Type | Description | 1171 | | --- | --- | --- | 1172 | | ticker | string | The ticker for which to retrieve the filled trade count. | 1173 | 1174 | 1175 | 1176 | ## getTickerTradesFilledList(ticker, [offset], [max]) ⇒ Promise.<Array> 1177 | Retrieves a list of filled trade records for a specific ticker. 1178 | 1179 | **Kind**: global function 1180 | **Returns**: Promise.<Array> - An array of filled trade records for the specified ticker. 1181 | 1182 | | Param | Type | Default | Description | 1183 | | --- | --- | --- | --- | 1184 | | ticker | string | | The ticker for which to retrieve filled trades. | 1185 | | [offset] | number | 0 | The starting index for retrieving filled trade records. | 1186 | | [max] | number | 500 | The maximum number of filled trade records to retrieve. | 1187 | 1188 | 1189 | 1190 | ## getTradesFilledListLength() ⇒ Promise.<number> 1191 | Gets the total number of filled trades across all tickers. 1192 | 1193 | **Kind**: global function 1194 | **Returns**: Promise.<number> - The total number of filled trades. 1195 | 1196 | 1197 | ## getTradesFilledList([offset], [max]) ⇒ Promise.<(Array\|Object)> 1198 | Asynchronously retrieves a list of trades that have been filled. 1199 | 1200 | **Kind**: global function 1201 | **Returns**: Promise.<(Array\|Object)> - A promise that resolves to an array of trade records. 1202 | 1203 | | Param | Type | Default | Description | 1204 | | --- | --- | --- | --- | 1205 | | [offset] | number | 0 | The starting index for retrieving records. | 1206 | | [max] | number | 500 | The maximum number of records to retrieve. | 1207 | 1208 | 1209 | 1210 | ## getAccountReceiveListLength(address, ticker) ⇒ Promise.<number> 1211 | Gets the length of the account receive list for a given address and ticker. 1212 | 1213 | **Kind**: global function 1214 | **Returns**: Promise.<number> - A promise that resolves to the length of the receive list. 1215 | 1216 | | Param | Type | Description | 1217 | | --- | --- | --- | 1218 | | address | string | The Bitcoin address to query. | 1219 | | ticker | string | The ticker symbol for the token. | 1220 | 1221 | 1222 | 1223 | ## getAccountReceiveList(address, ticker, [offset], [max]) ⇒ Promise.<(Array\|Object)> 1224 | Retrieves a list of received transactions for a specific account and ticker. 1225 | 1226 | **Kind**: global function 1227 | **Returns**: Promise.<(Array\|Object)> - A promise that resolves to an array of receive transaction records. 1228 | 1229 | | Param | Type | Default | Description | 1230 | | --- | --- | --- | --- | 1231 | | address | string | | The Bitcoin address to query. | 1232 | | ticker | string | | The ticker symbol for the token. | 1233 | | [offset] | number | 0 | The starting index for retrieving records. | 1234 | | [max] | number | 500 | The maximum number of records to retrieve. | 1235 | 1236 | 1237 | 1238 | ## getTickerSentListLength(ticker) ⇒ Promise.<number> 1239 | Gets the length of the sent list for a specific ticker. 1240 | 1241 | **Kind**: global function 1242 | **Returns**: Promise.<number> - A promise that resolves to the length of the sent list. 1243 | 1244 | | Param | Type | Description | 1245 | | --- | --- | --- | 1246 | | ticker | string | The ticker symbol for the token. | 1247 | 1248 | 1249 | 1250 | ## getTickerSentList(ticker, [offset], [max]) ⇒ Promise.<(Array\|Object)> 1251 | Retrieves a list of sent transactions for a specific ticker. 1252 | 1253 | **Kind**: global function 1254 | **Returns**: Promise.<(Array\|Object)> - A promise that resolves to an array of sent transaction records. 1255 | 1256 | | Param | Type | Default | Description | 1257 | | --- | --- | --- | --- | 1258 | | ticker | string | | The ticker symbol for the token. | 1259 | | [offset] | number | 0 | The starting index for retrieving records. | 1260 | | [max] | number | 500 | The maximum number of records to retrieve. | 1261 | 1262 | 1263 | 1264 | ## getSentListLength() ⇒ Promise.<number> 1265 | Gets the total length of the sent transactions list. 1266 | 1267 | **Kind**: global function 1268 | **Returns**: Promise.<number> - A promise that resolves to the total length of the sent list. 1269 | 1270 | 1271 | ## getSentList([offset], [max]) ⇒ Promise.<(Array\|Object)> 1272 | Retrieves the list of all sent transactions. 1273 | 1274 | **Kind**: global function 1275 | **Returns**: Promise.<(Array\|Object)> - A promise that resolves to an array of all sent transaction records. 1276 | 1277 | | Param | Type | Default | Description | 1278 | | --- | --- | --- | --- | 1279 | | [offset] | number | 0 | The starting index for retrieving records. | 1280 | | [max] | number | 500 | The maximum number of records to retrieve. | 1281 | 1282 | 1283 | 1284 | ## getAccumulator(inscription) ⇒ Promise.<(Object\|null)> 1285 | Retrieves the accumulator object for a given inscription. 1286 | 1287 | **Kind**: global function 1288 | **Returns**: Promise.<(Object\|null)> - A promise that resolves to the accumulator object, or null if not found. 1289 | 1290 | | Param | Type | Description | 1291 | | --- | --- | --- | 1292 | | inscription | string | The inscription identifier. | 1293 | 1294 | 1295 | 1296 | ## getAccountAccumulatorListLength(address) ⇒ Promise.<number> 1297 | Gets the total number of accumulator entries for a specific Bitcoin address. 1298 | 1299 | **Kind**: global function 1300 | **Returns**: Promise.<number> - A promise that resolves to the number of accumulator entries. 1301 | 1302 | | Param | Type | Description | 1303 | | --- | --- | --- | 1304 | | address | string | The Bitcoin address to query. | 1305 | 1306 | 1307 | 1308 | ## getAccountAccumulatorList(address, [offset], [max]) ⇒ Promise.<(Array\|Object)> 1309 | Retrieves a list of accumulator records for a specified address. 1310 | 1311 | **Kind**: global function 1312 | **Returns**: Promise.<(Array\|Object)> - A promise that resolves to an array of accumulator records. 1313 | If an error occurs, returns the error object. 1314 | 1315 | | Param | Type | Default | Description | 1316 | | --- | --- | --- | --- | 1317 | | address | string | | The Bitcoin address to query. | 1318 | | [offset] | number | 0 | The starting index for retrieving records. | 1319 | | [max] | number | 500 | The maximum number of records to retrieve. | 1320 | 1321 | 1322 | 1323 | ## getAccumulatorListLength() ⇒ Promise.<number> 1324 | Retrieves the total length of the accumulator list. 1325 | 1326 | **Kind**: global function 1327 | **Returns**: Promise.<number> - A promise that resolves to the total length of the accumulator list. 1328 | 1329 | 1330 | ## getAccumulatorList([offset], [max]) ⇒ Promise.<(Array\|Object)> 1331 | Retrieves a list of accumulators. 1332 | 1333 | **Kind**: global function 1334 | **Returns**: Promise.<(Array\|Object)> - A promise that resolves to an array of accumulator records. 1335 | If an error occurs, returns the error object. 1336 | 1337 | | Param | Type | Default | Description | 1338 | | --- | --- | --- | --- | 1339 | | [offset] | number | 0 | The starting index for retrieving accumulator records. | 1340 | | [max] | number | 500 | The maximum number of accumulators to retrieve. | 1341 | 1342 | 1343 | 1344 | ## getListRecords(length_key, iterator_key, offset, max, return_json) ⇒ Promise.<(Array\|Object\|string)> 1345 | Asynchronously retrieves a batch of list records based on specified keys and limits. 1346 | 1347 | **Kind**: global function 1348 | **Returns**: Promise.<(Array\|Object\|string)> - A promise that resolves to an array of records, an error object, or a string message in case of invalid parameters. 1349 | 1350 | | Param | Type | Description | 1351 | | --- | --- | --- | 1352 | | length_key | string | The key to determine the length of the list. | 1353 | | iterator_key | string | The key used for iterating over the list. | 1354 | | offset | number | The starting index for retrieving records. | 1355 | | max | number | The maximum number of records to retrieve. | 1356 | | return_json | boolean | Whether to return the records as JSON objects. | 1357 | 1358 | 1359 | 1360 | ## getLength(length_key) ⇒ Promise.<number> 1361 | Gets the length of a list based on a specified key. 1362 | 1363 | **Kind**: global function 1364 | **Returns**: Promise.<number> - A promise that resolves to the length of the list. 1365 | 1366 | | Param | Type | Description | 1367 | | --- | --- | --- | 1368 | | length_key | string | The key to determine the length of the list. | 1369 | 1370 | -------------------------------------------------------------------------------- /config/default.json: -------------------------------------------------------------------------------- 1 | { 2 | "enableRest": true, 3 | "enableRestApiDocs": true, 4 | "restPort": 5099, 5 | "restCacheControl": { 6 | "maxAge": 1, 7 | "public": false 8 | }, 9 | "enableRestSSL" : false, 10 | "sslCert" : { 11 | "cert" : "/path/to/cert.crt", 12 | "key" : "/path/to/cert.key" 13 | }, 14 | "restHeaders": [ 15 | { "name": "X-Powered-By", "value": "TracCore" }, 16 | { "name": "Access-Control-Allow-Origin", "value": "*" } 17 | ], 18 | "enableWebsockets": true, 19 | "websocketPort": 5095, 20 | "websocketCORS": "*", 21 | "channel": "53b2c0e70485790d7f086edbbbb8e624a165667bc74b12034d9774c2f3ce503c", 22 | "enableBlockDownloader": true, 23 | "host" : "0.0.0.0" 24 | } -------------------------------------------------------------------------------- /jsdoc.conf: -------------------------------------------------------------------------------- 1 | { 2 | "source": { 3 | "includePattern": ".+\\.(js(doc|x)?|mjs)$" 4 | } 5 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@trac-network/tap-reader", 3 | "author": "Trac Systems", 4 | "version": "0.15.10", 5 | "description": "decentralized trac core module", 6 | "main": "src/main.mjs", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1", 9 | "start": "node src/main.mjs", 10 | "postinstall": "patch-package" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git+https://github.com/Trac-Systems/tap-reader.git" 15 | }, 16 | "keywords": [ 17 | "holepunch", 18 | "hypercore", 19 | "tap", 20 | "ordinals", 21 | "indexer" 22 | ], 23 | "jest": { 24 | "transform": {} 25 | }, 26 | "license": "MIT", 27 | "bugs": { 28 | "url": "https://github.com/Trac-Systems/tap-reader/issues" 29 | }, 30 | "homepage": "https://github.com/Trac-Systems/tap-reader#readme", 31 | "dependencies": { 32 | "@cmdcode/crypto-utils": "^2.2.12", 33 | "@cmdcode/tapscript": "1.4.0", 34 | "@fastify/swagger": "^8.14.0", 35 | "@fastify/swagger-ui": "^2.1.0", 36 | "@noble/secp256k1": "^2.0.0", 37 | "config": "^3.3.10", 38 | "corestore": "6.18.4", 39 | "crypto": "^1.0.1", 40 | "crypto-utils": "^0.1.3", 41 | "fastify": "^4.25.2", 42 | "figlet": "^1.7.0", 43 | "graceful-fs": "^4.2.11", 44 | "graceful-goodbye": "^1.2.1", 45 | "hyperbee": "2.20.7", 46 | "hypercore": "10.38.1", 47 | "hyperdht": "6.20.1", 48 | "hyperdrive": "11.13.3", 49 | "hyperswarm": "4.8.4", 50 | "localdrive": "2.0.0", 51 | "socket.io": "^4.7.4" 52 | }, 53 | "devDependencies": { 54 | "@jest/globals": "^29.7.0", 55 | "eslint": "^8.56.0", 56 | "jest": "^29.7.0", 57 | "patch-package": "^8.0.0" 58 | }, 59 | "directories": { 60 | "test": "test" 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /patches/hyperswarm+4.8.4.patch: -------------------------------------------------------------------------------- 1 | diff --git a/node_modules/hyperswarm/index.js b/node_modules/hyperswarm/index.js 2 | index cbe2250..e905617 100644 3 | --- a/node_modules/hyperswarm/index.js 4 | +++ b/node_modules/hyperswarm/index.js 5 | @@ -306,7 +306,10 @@ module.exports = class Hyperswarm extends EventEmitter { 6 | const keepNew = existingIsOutdated || (expectedInitiator === conn.isInitiator) 7 | 8 | if (keepNew === false) { 9 | - existing.sendKeepAlive() 10 | + if(typeof existing.sendKeepAlive == 'function') 11 | + { 12 | + existing.sendKeepAlive() 13 | + } 14 | conn.on('error', noop) 15 | conn.destroy(new Error(ERR_DUPLICATE)) 16 | return 17 | @@ -399,7 +402,10 @@ module.exports = class Hyperswarm extends EventEmitter { 18 | async _handleNetworkChange () { 19 | // prioritize figuring out if existing connections are dead 20 | for (const conn of this._allConnections) { 21 | - conn.sendKeepAlive() 22 | + if(typeof conn.sendKeepAlive == 'function') 23 | + { 24 | + conn.sendKeepAlive() 25 | + } 26 | } 27 | 28 | const refreshes = [] 29 | -------------------------------------------------------------------------------- /src/BlockDownloader.mjs: -------------------------------------------------------------------------------- 1 | export default class BlockDownloader { 2 | constructor(core) { 3 | this.core = core; 4 | this.downloadedBlocks = []; 5 | this.totalBlocks; 6 | this.progress = 0; 7 | this.chunkSize = 100; 8 | } 9 | 10 | // Method to dynamically calculate total downloaded size 11 | calculateTotalDownloadedSize() { 12 | return this.downloadedBlocks.reduce((acc, [start, end]) => acc + (end - start), 0); 13 | } 14 | async startRangeDownload() { 15 | 16 | console.log("Starting random chunk download. Core length:", this.core.length); 17 | this.totalBlocks = this.core.length; 18 | 19 | while (true) { 20 | 21 | if(this.progress >= 95){ 22 | console.log(`Reached 95% block downloads. Done. Restarting.`); 23 | this.progress = 0; 24 | this.downloadedBlocks = []; 25 | this.startRangeDownload(); 26 | break; 27 | } 28 | 29 | let start = this.getRandomBlockStart(this.core.length); 30 | let end = Math.min(start + this.chunkSize, this.core.length); 31 | 32 | [start, end] = this.findNonOverlappingRange(start, end); 33 | 34 | if (start < end) { 35 | this.downloadedBlocks.push([start, end]); 36 | 37 | const range = this.core.download({ start: start, end: end }); 38 | await range.done(); 39 | console.log("☑ Downloaded chunk from:", start, "to", end); 40 | 41 | // Dynamically calculate total downloaded size 42 | const totalDownloadedSize = this.calculateTotalDownloadedSize(); 43 | // Update progress 44 | this.progress = (totalDownloadedSize / this.totalBlocks) * 100; 45 | console.log(`Progress: ${this.progress}%`); 46 | } 47 | await this.sleep(10); 48 | } 49 | } 50 | findNonOverlappingRange(start, end) { 51 | for (let [downloadedStart, downloadedEnd] of this.downloadedBlocks) { 52 | if (start < downloadedEnd && end > downloadedStart) { 53 | start = downloadedEnd; 54 | } 55 | } 56 | return [start, end]; 57 | } 58 | getRandomBlockStart(coreLength) { 59 | const biasFactor = 1.5; 60 | let weightedIndex = Math.pow(Math.random(), biasFactor) * coreLength; 61 | return Math.floor(weightedIndex); 62 | } 63 | async sleep(ms) { 64 | return new Promise((resolve) => setTimeout(resolve, ms)); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/TapProtocol.mjs: -------------------------------------------------------------------------------- 1 | export default class TapProtocol { 2 | constructor(tracManager) { 3 | this.tracManager = tracManager; 4 | } 5 | 6 | /** 7 | * Returns the amount of HISTORIC DMT Mints of an address. 8 | * 9 | * @param {string} address 10 | * @returns {Promise} 11 | */ 12 | async getDmtMintWalletHistoricListLength(address) { 13 | return this.getLength( 14 | "dmtmwl/" + address 15 | ); 16 | } 17 | 18 | /** 19 | * Returns the HISTORICAL ownership of an address of DMT Mints. 20 | * The result should be compared with the actual ownership for each item 21 | * using getDmtMintHolder() for real-time ownership. 22 | * 23 | * @param {string} address 24 | * @param {int} offset 25 | * @param {max} max 26 | * @returns {Promise} 27 | */ 28 | async getDmtMintWalletHistoricList(address, offset = 0, max = 500) { 29 | 30 | let out = []; 31 | let records = await this.getListRecords( 32 | "dmtmwl/" + address, 33 | "dmtmwli/" + address, 34 | offset, 35 | max, 36 | false 37 | ); 38 | 39 | if (!Array.isArray(records)) { 40 | return records; 41 | } 42 | 43 | for (let i = 0; i < records.length; i++) { 44 | out.push(records[i]); 45 | } 46 | 47 | return out; 48 | } 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | /** 60 | * Returns the length of actual transferred inscriptions and internally sent tokens of a given tx hash. 61 | * 62 | * @param {string} transaction_hash 63 | * @returns {Promise} 64 | */ 65 | async getTransferredListLength(transaction_hash) { 66 | return this.getLength( 67 | "tx/snd/" + transaction_hash 68 | ); 69 | } 70 | 71 | /** 72 | * Returns actual transferred inscriptions and internally sent tokens of a given tx hash. 73 | * 74 | * @param {string} transaction_hash 75 | * @param {int} offset 76 | * @param {int} max 77 | * @returns {Promise} 78 | */ 79 | async getTransferredList(transaction_hash, offset = 0, max = 500) { 80 | 81 | let out = []; 82 | let records = await this.getListRecords( 83 | "tx/snd/" + transaction_hash, 84 | "txi/snd/" + transaction_hash, 85 | offset, 86 | max, 87 | false 88 | ); 89 | 90 | if (!Array.isArray(records)) { 91 | return records; 92 | } 93 | 94 | for (let i = 0; i < records.length; i++) { 95 | let entry = await this.tracManager.bee.get(records[i]); 96 | if(entry !== null) 97 | { 98 | out.push(JSON.parse(entry.value)); 99 | } 100 | } 101 | 102 | return out; 103 | } 104 | 105 | /** 106 | * Returns the length of actual transferred inscriptions and internally sent tokens of a given ticker and tx hash. 107 | * 108 | * @param {string} ticker 109 | * @param {string} transaction_hash 110 | * @returns {Promise} 111 | */ 112 | async getTickerTransferredListLength(ticker, transaction_hash) { 113 | return this.getLength( 114 | "txt/snd/" + JSON.stringify(ticker.toLowerCase()) + '/' + transaction_hash 115 | ); 116 | } 117 | 118 | /** 119 | * Returns actual transferred inscriptions and internally sent tokens of a given ticker and tx hash. 120 | * 121 | * @param {string} ticker 122 | * @param {string} transaction_hash 123 | * @param {int} offset 124 | * @param {int} max 125 | * @returns {Promise} 126 | */ 127 | async getTickerTransferredList(ticker, transaction_hash, offset = 0, max = 500) { 128 | 129 | let out = []; 130 | let records = await this.getListRecords( 131 | "txt/snd/" + JSON.stringify(ticker.toLowerCase()) + '/' + transaction_hash, 132 | "txti/snd/" + JSON.stringify(ticker.toLowerCase()) + '/' + transaction_hash, 133 | offset, 134 | max, 135 | false 136 | ); 137 | 138 | if (!Array.isArray(records)) { 139 | return records; 140 | } 141 | 142 | for (let i = 0; i < records.length; i++) { 143 | let entry = await this.tracManager.bee.get(records[i]); 144 | if(entry !== null) 145 | { 146 | out.push(JSON.parse(entry.value)); 147 | } 148 | } 149 | 150 | return out; 151 | } 152 | 153 | /** 154 | * Returns the length of actual transferred inscriptions and internally sent tokens of a given ticker and block. 155 | * 156 | * @param {string} ticker 157 | * @param {int} block 158 | * @param {string} transaction_hash 159 | * @returns {Promise} 160 | */ 161 | async getTickerTransferredListByBlockLength(ticker, block) { 162 | return this.getLength( 163 | "blckt/snd/" + JSON.stringify(ticker.toLowerCase()) + '/' + block 164 | ); 165 | } 166 | 167 | /** 168 | * Returns actual transferred inscriptions and internally sent tokens of a given ticker and block. 169 | * 170 | * @param {string} ticker 171 | * @param {string} transaction_hash 172 | * @param {int} offset 173 | * @param {int} max 174 | * @returns {Promise} 175 | */ 176 | async getTickerTransferredListByBlock(ticker, block, offset = 0, max = 500) { 177 | 178 | let out = []; 179 | let records = await this.getListRecords( 180 | "blckt/snd/" + JSON.stringify(ticker.toLowerCase()) + '/' + block, 181 | "blckti/snd/" + JSON.stringify(ticker.toLowerCase()) + '/' + block, 182 | offset, 183 | max, 184 | false 185 | ); 186 | 187 | if (!Array.isArray(records)) { 188 | return records; 189 | } 190 | 191 | for (let i = 0; i < records.length; i++) { 192 | let entry = await this.tracManager.bee.get(records[i]); 193 | if(entry !== null) 194 | { 195 | out.push(JSON.parse(entry.value)); 196 | } 197 | } 198 | 199 | return out; 200 | } 201 | 202 | /** 203 | * Returns the length of actual transferred inscriptions and internally sent tokens of a given block. 204 | * 205 | * @param {int} block 206 | * @returns {Promise} 207 | */ 208 | async getTransferredListByBlockLength(block) { 209 | return this.getLength( 210 | "blck/snd/" + block 211 | ); 212 | } 213 | 214 | /** 215 | * Returns actual transferred inscriptions and internally sent tokens of a given block. 216 | * 217 | * @param {int} block 218 | * @param {int} offset 219 | * @param {int} max 220 | * @returns {Promise} 221 | */ 222 | async getTransferredListByBlock(block, offset = 0, max = 500) { 223 | 224 | let out = []; 225 | let records = await this.getListRecords( 226 | "blck/snd/" + block, 227 | "blcki/snd/" + block, 228 | offset, 229 | max, 230 | false 231 | ); 232 | 233 | if (!Array.isArray(records)) { 234 | return records; 235 | } 236 | 237 | for (let i = 0; i < records.length; i++) { 238 | let entry = await this.tracManager.bee.get(records[i]); 239 | if(entry !== null) 240 | { 241 | out.push(JSON.parse(entry.value)); 242 | } 243 | } 244 | 245 | return out; 246 | } 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | /** 256 | * Returns the length of mint inscriptions of a given tx hash. 257 | * 258 | * @param {string} transaction_hash 259 | * @returns {Promise} 260 | */ 261 | async getMintedListLength(transaction_hash) { 262 | return this.getLength( 263 | "tx/mnt/" + transaction_hash 264 | ); 265 | } 266 | 267 | /** 268 | * Returns mint inscriptions of a given tx hash. 269 | * 270 | * @param {string} transaction_hash 271 | * @param {int} offset 272 | * @param {int} max 273 | * @returns {Promise} 274 | */ 275 | async getMintedList(transaction_hash, offset = 0, max = 500) { 276 | 277 | let out = []; 278 | let records = await this.getListRecords( 279 | "tx/mnt/" + transaction_hash, 280 | "txi/mnt/" + transaction_hash, 281 | offset, 282 | max, 283 | false 284 | ); 285 | 286 | if (!Array.isArray(records)) { 287 | return records; 288 | } 289 | 290 | for (let i = 0; i < records.length; i++) { 291 | let entry = await this.tracManager.bee.get(records[i]); 292 | if(entry !== null) 293 | { 294 | out.push(JSON.parse(entry.value)); 295 | } 296 | } 297 | 298 | return out; 299 | } 300 | 301 | /** 302 | * Returns the length of mint inscriptions of a given ticker and tx hash. 303 | * 304 | * @param {string} ticker 305 | * @param {string} transaction_hash 306 | * @returns {Promise} 307 | */ 308 | async getTickerMintedListLength(ticker, transaction_hash) { 309 | return this.getLength( 310 | "txt/mnt/" + JSON.stringify(ticker.toLowerCase()) + '/' + transaction_hash 311 | ); 312 | } 313 | 314 | /** 315 | * Returns mint inscriptions of a given ticker and tx hash. 316 | * 317 | * @param {string} ticker 318 | * @param {string} transaction_hash 319 | * @param {int} offset 320 | * @param {int} max 321 | * @returns {Promise} 322 | */ 323 | async getTickerMintedList(ticker, transaction_hash, offset = 0, max = 500) { 324 | 325 | let out = []; 326 | let records = await this.getListRecords( 327 | "txt/mnt/" + JSON.stringify(ticker.toLowerCase()) + '/' + transaction_hash, 328 | "txti/mnt/" + JSON.stringify(ticker.toLowerCase()) + '/' + transaction_hash, 329 | offset, 330 | max, 331 | false 332 | ); 333 | 334 | if (!Array.isArray(records)) { 335 | return records; 336 | } 337 | 338 | for (let i = 0; i < records.length; i++) { 339 | let entry = await this.tracManager.bee.get(records[i]); 340 | if(entry !== null) 341 | { 342 | out.push(JSON.parse(entry.value)); 343 | } 344 | } 345 | 346 | return out; 347 | } 348 | 349 | /** 350 | * Returns the length of mint inscriptions of a given ticker and block. 351 | * 352 | * @param {string} ticker 353 | * @param {int} block 354 | * @param {string} transaction_hash 355 | * @returns {Promise} 356 | */ 357 | async getTickerMintedListByBlockLength(ticker, block) { 358 | return this.getLength( 359 | "blckt/mnt/" + JSON.stringify(ticker.toLowerCase()) + '/' + block 360 | ); 361 | } 362 | 363 | /** 364 | * Returns mint inscriptions of a given ticker and block. 365 | * 366 | * @param {string} ticker 367 | * @param {string} transaction_hash 368 | * @param {int} offset 369 | * @param {int} max 370 | * @returns {Promise} 371 | */ 372 | async getTickerMintedListByBlock(ticker, block, offset = 0, max = 500) { 373 | 374 | let out = []; 375 | let records = await this.getListRecords( 376 | "blckt/mnt/" + JSON.stringify(ticker.toLowerCase()) + '/' + block, 377 | "blckti/mnt/" + JSON.stringify(ticker.toLowerCase()) + '/' + block, 378 | offset, 379 | max, 380 | false 381 | ); 382 | 383 | if (!Array.isArray(records)) { 384 | return records; 385 | } 386 | 387 | for (let i = 0; i < records.length; i++) { 388 | let entry = await this.tracManager.bee.get(records[i]); 389 | if(entry !== null) 390 | { 391 | out.push(JSON.parse(entry.value)); 392 | } 393 | } 394 | 395 | return out; 396 | } 397 | 398 | /** 399 | * Returns the length of mint inscriptions of a given block. 400 | * 401 | * @param {int} block 402 | * @returns {Promise} 403 | */ 404 | async getMintedListByBlockLength(block) { 405 | return this.getLength( 406 | "blck/mnt/" + block 407 | ); 408 | } 409 | 410 | /** 411 | * Returns mint inscriptions of a given block. 412 | * 413 | * @param {int} block 414 | * @param {int} offset 415 | * @param {int} max 416 | * @returns {Promise} 417 | */ 418 | async getMintedListByBlock(block, offset = 0, max = 500) { 419 | 420 | let out = []; 421 | let records = await this.getListRecords( 422 | "blck/mnt/" + block, 423 | "blcki/mnt/" + block, 424 | offset, 425 | max, 426 | false 427 | ); 428 | 429 | if (!Array.isArray(records)) { 430 | return records; 431 | } 432 | 433 | for (let i = 0; i < records.length; i++) { 434 | let entry = await this.tracManager.bee.get(records[i]); 435 | if(entry !== null) 436 | { 437 | out.push(JSON.parse(entry.value)); 438 | } 439 | } 440 | 441 | return out; 442 | } 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | /** 454 | * Returns the length of deployments of a given tx hash. 455 | * 456 | * @param {string} transaction_hash 457 | * @returns {Promise} 458 | */ 459 | async getDeployedListLength(transaction_hash) { 460 | return this.getLength( 461 | "tx/dpl/" + transaction_hash 462 | ); 463 | } 464 | 465 | /** 466 | * Returns deployments of a given tx hash. 467 | * 468 | * @param {string} transaction_hash 469 | * @param {int} offset 470 | * @param {int} max 471 | * @returns {Promise} 472 | */ 473 | async getDeployedList(transaction_hash, offset = 0, max = 500) { 474 | 475 | let out = []; 476 | let records = await this.getListRecords( 477 | "tx/dpl/" + transaction_hash, 478 | "txi/dpl/" + transaction_hash, 479 | offset, 480 | max, 481 | false 482 | ); 483 | 484 | if (!Array.isArray(records)) { 485 | return records; 486 | } 487 | 488 | for (let i = 0; i < records.length; i++) { 489 | let entry = await this.tracManager.bee.get(records[i]); 490 | if(entry !== null) 491 | { 492 | let dpl = await this.getDeployment(entry.value); 493 | if(dpl !== null) 494 | { 495 | out.push(dpl); 496 | } 497 | } 498 | } 499 | 500 | return out; 501 | } 502 | 503 | /** 504 | * Returns the length deployments of a given ticker and tx hash. 505 | * 506 | * @param {string} ticker 507 | * @param {string} transaction_hash 508 | * @returns {Promise} 509 | */ 510 | async getTickerDeployedListLength(ticker, transaction_hash) { 511 | return this.getLength( 512 | "txt/dpl/" + JSON.stringify(ticker.toLowerCase()) + '/' + transaction_hash 513 | ); 514 | } 515 | 516 | /** 517 | * Returns deployments of a given ticker and tx hash. 518 | * 519 | * @param {string} ticker 520 | * @param {string} transaction_hash 521 | * @param {int} offset 522 | * @param {int} max 523 | * @returns {Promise} 524 | */ 525 | async getTickerDeployedList(ticker, transaction_hash, offset = 0, max = 500) { 526 | 527 | let out = []; 528 | let records = await this.getListRecords( 529 | "txt/dpl/" + JSON.stringify(ticker.toLowerCase()) + '/' + transaction_hash, 530 | "txti/dpl/" + JSON.stringify(ticker.toLowerCase()) + '/' + transaction_hash, 531 | offset, 532 | max, 533 | false 534 | ); 535 | 536 | if (!Array.isArray(records)) { 537 | return records; 538 | } 539 | 540 | for (let i = 0; i < records.length; i++) { 541 | let entry = await this.tracManager.bee.get(records[i]); 542 | if(entry !== null) 543 | { 544 | let dpl = await this.getDeployment(entry.value); 545 | if(dpl !== null) 546 | { 547 | out.push(dpl); 548 | } 549 | } 550 | } 551 | 552 | return out; 553 | } 554 | 555 | /** 556 | * Returns the length of deployments of a given ticker and block. 557 | * 558 | * @param {string} ticker 559 | * @param {int} block 560 | * @param {string} transaction_hash 561 | * @returns {Promise} 562 | */ 563 | async getTickerDeployedListByBlockLength(ticker, block) { 564 | return this.getLength( 565 | "blckt/dpl/" + JSON.stringify(ticker.toLowerCase()) + '/' + block 566 | ); 567 | } 568 | 569 | /** 570 | * Returns deployments of a given ticker and block. 571 | * 572 | * @param {string} ticker 573 | * @param {string} transaction_hash 574 | * @param {int} offset 575 | * @param {int} max 576 | * @returns {Promise} 577 | */ 578 | async getTickerDeployedListByBlock(ticker, block, offset = 0, max = 500) { 579 | 580 | let out = []; 581 | let records = await this.getListRecords( 582 | "blckt/dpl/" + JSON.stringify(ticker.toLowerCase()) + '/' + block, 583 | "blckti/dpl/" + JSON.stringify(ticker.toLowerCase()) + '/' + block, 584 | offset, 585 | max, 586 | false 587 | ); 588 | 589 | if (!Array.isArray(records)) { 590 | return records; 591 | } 592 | 593 | for (let i = 0; i < records.length; i++) { 594 | let entry = await this.tracManager.bee.get(records[i]); 595 | if(entry !== null) 596 | { 597 | let dpl = await this.getDeployment(entry.value); 598 | if(dpl !== null) 599 | { 600 | out.push(dpl); 601 | } 602 | } 603 | } 604 | 605 | return out; 606 | } 607 | 608 | /** 609 | * Returns the length of deployments of a given block. 610 | * 611 | * @param {int} block 612 | * @returns {Promise} 613 | */ 614 | async getDeployedListByBlockLength(block) { 615 | return this.getLength( 616 | "blck/dpl/" + block 617 | ); 618 | } 619 | 620 | /** 621 | * Returns deployments of a given block. 622 | * 623 | * @param {int} block 624 | * @param {int} offset 625 | * @param {int} max 626 | * @returns {Promise} 627 | */ 628 | async getDeployedListByBlock(block, offset = 0, max = 500) { 629 | 630 | let out = []; 631 | let records = await this.getListRecords( 632 | "blck/dpl/" + block, 633 | "blcki/dpl/" + block, 634 | offset, 635 | max, 636 | false 637 | ); 638 | 639 | if (!Array.isArray(records)) { 640 | return records; 641 | } 642 | 643 | for (let i = 0; i < records.length; i++) { 644 | let entry = await this.tracManager.bee.get(records[i]); 645 | if(entry !== null) 646 | { 647 | let dpl = await this.getDeployment(entry.value); 648 | if(dpl !== null) 649 | { 650 | out.push(dpl); 651 | } 652 | } 653 | } 654 | return out; 655 | } 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | /** 668 | * Returns the length of transfer-inscriptions of a given tx hash. 669 | * 670 | * @param {string} transaction_hash 671 | * @returns {Promise} 672 | */ 673 | async getInscribeTransferListLength(transaction_hash) { 674 | return this.getLength( 675 | "tx/trf/" + transaction_hash 676 | ); 677 | } 678 | 679 | /** 680 | * Returns transfer-inscriptions of a given tx hash. 681 | * 682 | * @param {string} transaction_hash 683 | * @param {int} offset 684 | * @param {int} max 685 | * @returns {Promise} 686 | */ 687 | async getInscribeTransferList(transaction_hash, offset = 0, max = 500) { 688 | 689 | let out = []; 690 | let records = await this.getListRecords( 691 | "tx/trf/" + transaction_hash, 692 | "txi/trf/" + transaction_hash, 693 | offset, 694 | max, 695 | false 696 | ); 697 | 698 | if (!Array.isArray(records)) { 699 | return records; 700 | } 701 | 702 | for (let i = 0; i < records.length; i++) { 703 | let entry = await this.tracManager.bee.get(records[i]); 704 | if(entry !== null) 705 | { 706 | out.push(JSON.parse(entry.value)); 707 | } 708 | } 709 | 710 | return out; 711 | } 712 | 713 | /** 714 | * Returns the length of transfer-inscriptions of a given ticker and tx hash. 715 | * 716 | * @param {string} ticker 717 | * @param {string} transaction_hash 718 | * @returns {Promise} 719 | */ 720 | async getTickerInscribeTransferListLength(ticker, transaction_hash) { 721 | return this.getLength( 722 | "txt/trf/" + JSON.stringify(ticker.toLowerCase()) + '/' + transaction_hash 723 | ); 724 | } 725 | 726 | /** 727 | * Returns transfer-inscriptions of a given ticker and tx hash. 728 | * 729 | * @param {string} ticker 730 | * @param {string} transaction_hash 731 | * @param {int} offset 732 | * @param {int} max 733 | * @returns {Promise} 734 | */ 735 | async getTickerInscribeTransferList(ticker, transaction_hash, offset = 0, max = 500) { 736 | 737 | let out = []; 738 | let records = await this.getListRecords( 739 | "txt/trf/" + JSON.stringify(ticker.toLowerCase()) + '/' + transaction_hash, 740 | "txti/trf/" + JSON.stringify(ticker.toLowerCase()) + '/' + transaction_hash, 741 | offset, 742 | max, 743 | false 744 | ); 745 | 746 | if (!Array.isArray(records)) { 747 | return records; 748 | } 749 | 750 | for (let i = 0; i < records.length; i++) { 751 | let entry = await this.tracManager.bee.get(records[i]); 752 | if(entry !== null) 753 | { 754 | out.push(JSON.parse(entry.value)); 755 | } 756 | } 757 | 758 | return out; 759 | } 760 | 761 | /** 762 | * Returns the length of transfer-inscriptions of a given ticker and block. 763 | * 764 | * @param {string} ticker 765 | * @param {int} block 766 | * @param {string} transaction_hash 767 | * @returns {Promise} 768 | */ 769 | async getTickerInscribeTransferListByBlockLength(ticker, block) { 770 | return this.getLength( 771 | "blckt/trf/" + JSON.stringify(ticker.toLowerCase()) + '/' + block 772 | ); 773 | } 774 | 775 | /** 776 | * Returns transfer-inscriptions of a given ticker and tx hash. 777 | * 778 | * @param {string} ticker 779 | * @param {string} transaction_hash 780 | * @param {int} offset 781 | * @param {int} max 782 | * @returns {Promise} 783 | */ 784 | async getTickerInscribeTransferListByBlock(ticker, block, offset = 0, max = 500) { 785 | 786 | let out = []; 787 | let records = await this.getListRecords( 788 | "blckt/trf/" + JSON.stringify(ticker.toLowerCase()) + '/' + block, 789 | "blckti/trf/" + JSON.stringify(ticker.toLowerCase()) + '/' + block, 790 | offset, 791 | max, 792 | false 793 | ); 794 | 795 | if (!Array.isArray(records)) { 796 | return records; 797 | } 798 | 799 | for (let i = 0; i < records.length; i++) { 800 | let entry = await this.tracManager.bee.get(records[i]); 801 | if(entry !== null) 802 | { 803 | out.push(JSON.parse(entry.value)); 804 | } 805 | } 806 | 807 | return out; 808 | } 809 | 810 | /** 811 | * Returns the length of transfer-inscriptions of a given block. 812 | * 813 | * @param {int} block 814 | * @returns {Promise} 815 | */ 816 | async getInscribeTransferListByBlockLength(block) { 817 | return this.getLength( 818 | "blck/trf/" + block 819 | ); 820 | } 821 | 822 | /** 823 | * Returns transfer-inscriptions of a given block. 824 | * 825 | * @param {int} block 826 | * @param {int} offset 827 | * @param {int} max 828 | * @returns {Promise} 829 | */ 830 | async getInscribeTransferListByBlock(block, offset = 0, max = 500) { 831 | 832 | let out = []; 833 | let records = await this.getListRecords( 834 | "blck/trf/" + block, 835 | "blcki/trf/" + block, 836 | offset, 837 | max, 838 | false 839 | ); 840 | 841 | if (!Array.isArray(records)) { 842 | return records; 843 | } 844 | 845 | for (let i = 0; i < records.length; i++) { 846 | let entry = await this.tracManager.bee.get(records[i]); 847 | if(entry !== null) 848 | { 849 | out.push(JSON.parse(entry.value)); 850 | } 851 | } 852 | 853 | return out; 854 | } 855 | 856 | /** 857 | * Returns the amount of holder changes for a given DMT Mint. 858 | * 859 | * @param {string} inscription_id 860 | * @returns {Promise} 861 | */ 862 | async getDmtMintHoldersHistoryListLength(inscription_id) { 863 | return this.getLength( 864 | "dmtmhl/" + inscription_id 865 | ); 866 | } 867 | 868 | /** 869 | * Returns the ownership history of a DMT Mint inscriptions. 870 | * 871 | * @param {string} inscription_id 872 | * @param {int} offset 873 | * @param {int} max 874 | * @returns {Promise} 875 | */ 876 | async getDmtMintHoldersHistoryList(inscription_id, offset = 0, max = 500) { 877 | 878 | let out = []; 879 | let records = await this.getListRecords( 880 | "dmtmhl/" + inscription_id, 881 | "dmtmhli/" + inscription_id, 882 | offset, 883 | max, 884 | true 885 | ); 886 | 887 | if (!Array.isArray(records)) { 888 | return records; 889 | } 890 | 891 | for (let i = 0; i < records.length; i++) { 892 | records[i].elem = JSON.parse(records[i].elem); 893 | out.push(records[i]); 894 | } 895 | 896 | return out; 897 | } 898 | 899 | /** 900 | * Returns if a certain verification signature has been verified by a given authority. 901 | * 902 | * @param privilege_inscription_id 903 | * @param collection_name 904 | * @param verified_hash 905 | * @param sequence 906 | * @returns {Promise} 907 | */ 908 | async getPrivilegeAuthorityVerifiedInscription(privilege_inscription_id, collection_name, verified_hash, sequence) 909 | { 910 | let verified = await this.tracManager.bee.get('prvins/' + privilege_inscription_id + '/' + JSON.stringify(collection_name) + '/' + verified_hash + '/' + sequence); 911 | if (verified !== null) { 912 | return verified.value; 913 | } 914 | return null; 915 | } 916 | 917 | async getPrivilegeAuthorityVerifiedByInscription(verified_inscription_id) 918 | { 919 | let verified = await this.tracManager.bee.get('prvins/' + verified_inscription_id); 920 | if (verified !== null) { 921 | return verified.value; 922 | } 923 | return null; 924 | } 925 | 926 | async getPrivilegeAuthorityIsVerified(privilege_inscription_id, collection_name, verified_hash, sequence) 927 | { 928 | let verified = await this.tracManager.bee.get('prvvrfd/' + privilege_inscription_id + '/' + JSON.stringify(collection_name) + '/' + verified_hash + '/' + sequence); 929 | if (verified !== null) { 930 | return true; 931 | } 932 | return false; 933 | } 934 | 935 | /** 936 | * Get the length of all verifications done by an authority 937 | * 938 | * @param privilege_inscription_id 939 | * @returns {Promise} 940 | */ 941 | async getPrivilegeAuthorityListLength(privilege_inscription_id) { 942 | return this.getLength( 943 | "prv/" + privilege_inscription_id 944 | ); 945 | } 946 | 947 | /** 948 | * Get the verifications done by an authority 949 | * 950 | * @param privilege_inscription_id 951 | * @param offset 952 | * @param max 953 | * @returns {Promise<*[]|string>} 954 | */ 955 | async getPrivilegeAuthorityList(privilege_inscription_id, offset = 0, max = 500) { 956 | 957 | let out = []; 958 | let records = await this.getListRecords( 959 | "prv/" + privilege_inscription_id, 960 | "prvi/" + privilege_inscription_id, 961 | offset, 962 | max, 963 | false 964 | ); 965 | 966 | if (!Array.isArray(records)) { 967 | return records; 968 | } 969 | 970 | for (let i = 0; i < records.length; i++) { 971 | let entry = await this.tracManager.bee.get(records[i]); 972 | if(entry !== null) 973 | { 974 | out.push(JSON.parse(entry.value)); 975 | } 976 | } 977 | 978 | return out; 979 | } 980 | 981 | /** 982 | * Get the length of the verified items of a collection verified by a privilege authority 983 | * 984 | * @param privilege_inscription_id 985 | * @param collection_name 986 | * @returns {Promise} 987 | */ 988 | async getPrivilegeAuthorityCollectionListLength(privilege_inscription_id, collection_name) { 989 | return this.getLength( 990 | 'prvcol/' + privilege_inscription_id+ '/' + JSON.stringify(collection_name) 991 | ); 992 | } 993 | 994 | /** 995 | * Get the verified items of a collection verified by a privilege authority 996 | * 997 | * @param privilege_inscription_id 998 | * @param collection_name 999 | * @param offset 1000 | * @param max 1001 | * @returns {Promise<*[]|string>} 1002 | */ 1003 | async getPrivilegeAuthorityCollectionList(privilege_inscription_id, collection_name, offset = 0, max = 500) { 1004 | 1005 | let out = []; 1006 | let records = await this.getListRecords( 1007 | 'prvcol/' + privilege_inscription_id+ '/' + JSON.stringify(collection_name), 1008 | "prvcoli/" + privilege_inscription_id+ '/' + JSON.stringify(collection_name), 1009 | offset, 1010 | max, 1011 | false 1012 | ); 1013 | 1014 | if (!Array.isArray(records)) { 1015 | return records; 1016 | } 1017 | 1018 | for (let i = 0; i < records.length; i++) { 1019 | let entry = await this.tracManager.bee.get(records[i]); 1020 | if(entry !== null) 1021 | { 1022 | out.push(JSON.parse(entry.value)); 1023 | } 1024 | } 1025 | 1026 | return out; 1027 | } 1028 | 1029 | async getPrivilegeAuthorityEventByPrivColBlockLength(privilege_authority_inscription_id, collection_name, block) { 1030 | let col_key = JSON.stringify(collection_name); 1031 | return this.getLength( 1032 | "blckpc/pravth/" + privilege_authority_inscription_id + '/' + col_key + '/' + block 1033 | ); 1034 | } 1035 | 1036 | async getPrivilegeAuthorityEventByPrivColBlock(privilege_authority_inscription_id, collection_name, block, offset = 0, max = 500) { 1037 | 1038 | let col_key = JSON.stringify(collection_name); 1039 | let out = []; 1040 | let records = await this.getListRecords( 1041 | "blckpc/pravth/" + privilege_authority_inscription_id + '/' + col_key + '/' + block, 1042 | "blckpci/pravth/" + privilege_authority_inscription_id + '/' + col_key + '/' + block, 1043 | offset, 1044 | max, 1045 | false 1046 | ); 1047 | 1048 | if (!Array.isArray(records)) { 1049 | return records; 1050 | } 1051 | 1052 | for (let i = 0; i < records.length; i++) { 1053 | let entry = await this.tracManager.bee.get(records[i]); 1054 | if(entry !== null) 1055 | { 1056 | out.push(JSON.parse(entry.value)); 1057 | } 1058 | } 1059 | 1060 | return out; 1061 | } 1062 | 1063 | async getPrivilegeAuthorityEventByPrivBlockLength(privilege_authority_inscription_id, block) { 1064 | return this.getLength( 1065 | "blckp/pravth/" + privilege_authority_inscription_id + '/' + block 1066 | ); 1067 | } 1068 | 1069 | async getPrivilegeAuthorityEventByPrivBlock(privilege_authority_inscription_id, block, offset = 0, max = 500) { 1070 | let out = []; 1071 | let records = await this.getListRecords( 1072 | "blckp/pravth/" + privilege_authority_inscription_id + '/' + block, 1073 | "blckpi/pravth/" + privilege_authority_inscription_id + '/' + block, 1074 | offset, 1075 | max, 1076 | false 1077 | ); 1078 | 1079 | if (!Array.isArray(records)) { 1080 | return records; 1081 | } 1082 | 1083 | for (let i = 0; i < records.length; i++) { 1084 | let entry = await this.tracManager.bee.get(records[i]); 1085 | if(entry !== null) 1086 | { 1087 | out.push(JSON.parse(entry.value)); 1088 | } 1089 | } 1090 | 1091 | return out; 1092 | } 1093 | 1094 | async getPrivilegeAuthorityEventByBlockLength(block) { 1095 | return this.getLength( 1096 | "blck/pravth/" + block 1097 | ); 1098 | } 1099 | 1100 | async getPrivilegeAuthorityEventByBlock(block, offset = 0, max = 500) { 1101 | 1102 | let out = []; 1103 | let records = await this.getListRecords( 1104 | "blck/pravth/" + block, 1105 | "blcki/pravth/" + block, 1106 | offset, 1107 | max, 1108 | false 1109 | ); 1110 | 1111 | if (!Array.isArray(records)) { 1112 | return records; 1113 | } 1114 | 1115 | for (let i = 0; i < records.length; i++) { 1116 | let entry = await this.tracManager.bee.get(records[i]); 1117 | if(entry !== null) 1118 | { 1119 | out.push(JSON.parse(entry.value)); 1120 | } 1121 | } 1122 | 1123 | return out; 1124 | } 1125 | 1126 | /** 1127 | * Returns a history object with element, owner and block data but based on a given ticker and block instead of an inscription id. 1128 | * 1129 | * @param {string} ticker 1130 | * @param {int} block 1131 | * @returns {Promise} 1132 | */ 1133 | async getDmtMintHolderByBlock(ticker, block) 1134 | { 1135 | let holder = await this.tracManager.bee.get('dmtmhb/'+JSON.stringify(ticker.toLowerCase())+'/'+parseInt(block)); 1136 | if (holder !== null) { 1137 | holder = await this.tracManager.bee.get(holder.value); 1138 | if(holder !== null) 1139 | { 1140 | holder = JSON.parse(holder.value); 1141 | holder.elem = JSON.parse(holder.elem); 1142 | return holder; 1143 | } 1144 | return null; 1145 | } 1146 | return null; 1147 | } 1148 | 1149 | /** 1150 | * Returns a history object with element, owner and block data. 1151 | * 1152 | * @param {string} inscription_id 1153 | * @returns {Promise} 1154 | */ 1155 | async getDmtMintHolder(inscription_id) 1156 | { 1157 | let holder = await this.tracManager.bee.get('dmtmh/'+inscription_id); 1158 | if (holder !== null) { 1159 | holder = JSON.parse(holder.value); 1160 | holder.elem = JSON.parse(holder.elem); 1161 | return holder; 1162 | } 1163 | return null; 1164 | } 1165 | 1166 | 1167 | async getBitmap(bitmap_block) 1168 | { 1169 | let bm = await this.tracManager.bee.get('bm/'+bitmap_block); 1170 | if (bm !== null) { 1171 | return JSON.parse(bm.value); 1172 | } 1173 | return null; 1174 | } 1175 | 1176 | async getBitmapByInscription(inscription_id) 1177 | { 1178 | let bm = await this.tracManager.bee.get('bmh/'+inscription_id); 1179 | if (bm !== null) { 1180 | bm = bm.value; 1181 | bm = await this.tracManager.bee.get(bm); 1182 | if(bm !== null) 1183 | { 1184 | return JSON.parse(bm.value); 1185 | } 1186 | } 1187 | return null; 1188 | } 1189 | 1190 | async getBitmapEventByBlockLength(block) { 1191 | return this.getLength( 1192 | "blck/bm/" + block 1193 | ); 1194 | } 1195 | 1196 | async getBitmapEventByBlock(block, offset = 0, max = 500) { 1197 | 1198 | let out = []; 1199 | let records = await this.getListRecords( 1200 | "blck/bm/" + block, 1201 | "blcki/bm/" + block, 1202 | offset, 1203 | max, 1204 | false 1205 | ); 1206 | 1207 | if (!Array.isArray(records)) { 1208 | return records; 1209 | } 1210 | 1211 | for (let i = 0; i < records.length; i++) { 1212 | let entry = await this.tracManager.bee.get(records[i]); 1213 | if(entry !== null) 1214 | { 1215 | out.push(JSON.parse(entry.value)); 1216 | } 1217 | } 1218 | 1219 | return out; 1220 | } 1221 | 1222 | async getDmtEventByBlockLength(block) { 1223 | return this.getLength( 1224 | "blck/dmt-md/" + block 1225 | ); 1226 | } 1227 | 1228 | async getDmtEventByBlock(block, offset = 0, max = 500) { 1229 | 1230 | let out = []; 1231 | let records = await this.getListRecords( 1232 | "blck/dmt-md/" + block, 1233 | "blcki/dmt-md/" + block, 1234 | offset, 1235 | max, 1236 | false 1237 | ); 1238 | 1239 | if (!Array.isArray(records)) { 1240 | return records; 1241 | } 1242 | 1243 | for (let i = 0; i < records.length; i++) { 1244 | let entry = await this.tracManager.bee.get(records[i]); 1245 | if(entry !== null) 1246 | { 1247 | out.push(JSON.parse(entry.value)); 1248 | } 1249 | } 1250 | 1251 | return out; 1252 | } 1253 | 1254 | async getBitmapWalletHistoricListLength(address) { 1255 | return this.getLength( 1256 | "bml/" + address 1257 | ); 1258 | } 1259 | 1260 | async getBitmapWalletHistoricList(address, offset = 0, max = 500) { 1261 | 1262 | let out = []; 1263 | let records = await this.getListRecords( 1264 | "bml/" + address, 1265 | "bmli/" + address, 1266 | offset, 1267 | max, 1268 | false 1269 | ); 1270 | 1271 | if (!Array.isArray(records)) { 1272 | return records; 1273 | } 1274 | 1275 | for (let i = 0; i < records.length; i++) { 1276 | out.push(records[i]); 1277 | } 1278 | 1279 | return out; 1280 | } 1281 | 1282 | /** 1283 | * Retrieves the current synchronization status, indicating the percentage of blocks that have been successfully synced 1284 | * 1285 | * @returns {Promise} 1286 | */ 1287 | async getSyncStatus() { 1288 | if(this.tracManager.blockDownloader){ 1289 | return this.tracManager.blockDownloader.progress; 1290 | } else { 1291 | return null; 1292 | } 1293 | } 1294 | /** 1295 | * Returns a list of reorgs that occured over the lifetime of the connected writer. 1296 | * 1297 | * Clients are advised to check for NEW reorgs upon every new block and wipe their local databases (if any in use) 1298 | * for current block height - 8 and re-populate. 1299 | * 1300 | * @returns {Promise} 1301 | */ 1302 | async getReorgs() { 1303 | let reorgs = await this.tracManager.bee.get('reorgs'); 1304 | if (reorgs !== null) { 1305 | return JSON.parse(reorgs.value); 1306 | } 1307 | return null; 1308 | } 1309 | 1310 | /** 1311 | * Returns the current block of the indexer state. 1312 | * 1313 | * @returns {Promise} 1314 | */ 1315 | async getCurrentBlock() { 1316 | let reorgs = await this.tracManager.bee.get('block'); 1317 | if (reorgs !== null) { 1318 | return JSON.parse(reorgs.value); 1319 | } 1320 | return null; 1321 | } 1322 | 1323 | /** 1324 | * Retrieves the transfer amount for a given inscription ID. 1325 | * @param {string} inscription_id - The ID of the inscription to query. 1326 | * @returns {Promise} The transfer amount or null if not found. 1327 | */ 1328 | async getTransferAmountByInscription(inscription_id) { 1329 | let amount = await this.tracManager.bee.get("tamt/" + inscription_id); 1330 | if (amount !== null) { 1331 | return amount.value; 1332 | } 1333 | return null; 1334 | } 1335 | /** 1336 | * Gets the total number of deployments. 1337 | * @returns {Promise} The total number of deployments. 1338 | */ 1339 | async getDeploymentsLength() { 1340 | return this.getLength("dl"); 1341 | } 1342 | /** 1343 | * Retrieves a list of deployments. 1344 | * @param {number} [offset=0] - The starting index for retrieving deployments. 1345 | * @param {number} [max=500] - The maximum number of deployments to retrieve. 1346 | * @returns {Promise} An array of deployment records. 1347 | */ 1348 | async getDeployments(offset = 0, max = 500) { 1349 | let out = []; 1350 | let records = await this.getListRecords("dl", "dli", offset, max, false); 1351 | 1352 | if (!Array.isArray(records)) { 1353 | return records; 1354 | } 1355 | 1356 | for (let i = 0; i < records.length; i++) { 1357 | out.push(await this.getDeployment(records[i])); 1358 | await this.sleep(1); 1359 | } 1360 | 1361 | return out; 1362 | } 1363 | /** 1364 | * Retrieves details of a specific deployment based on its ticker. 1365 | * @param {string} ticker - The ticker of the deployment to retrieve. 1366 | * @returns {Promise} Deployment details or null if not found. 1367 | */ 1368 | 1369 | async getDeployment(ticker) { 1370 | let deployment = await this.tracManager.bee.get( 1371 | "d/" + JSON.stringify(ticker.toLowerCase()) 1372 | ); 1373 | 1374 | if (deployment !== null) { 1375 | return JSON.parse(deployment.value); 1376 | } 1377 | 1378 | return null; 1379 | } 1380 | /** 1381 | * Gets the remaining number of tokens that can be minted for a given ticker. 1382 | * @param {string} ticker - The ticker for which to retrieve the remaining mintable tokens. 1383 | * @returns {Promise} The number of tokens left to mint or null if not available. 1384 | */ 1385 | 1386 | async getMintTokensLeft(ticker) { 1387 | let tokens_left = await this.tracManager.bee.get( 1388 | "dc/" + JSON.stringify(ticker.toLowerCase()) 1389 | ); 1390 | 1391 | if (tokens_left !== null) { 1392 | return tokens_left.value; 1393 | } 1394 | return null; 1395 | } 1396 | 1397 | /// BALANCE & HOLDERS 1398 | /** 1399 | * Retrieves the balance of a specific address for a given ticker. 1400 | * @param {string} address - The address for which to retrieve the balance. 1401 | * @param {string} ticker - The ticker of the token. 1402 | * @returns {Promise} The balance of the address or null if not found. 1403 | */ 1404 | 1405 | async getBalance(address, ticker) { 1406 | let balance = await this.tracManager.bee.get( 1407 | "b/" + address + "/" + JSON.stringify(ticker.toLowerCase()) 1408 | ); 1409 | 1410 | if (balance !== null) { 1411 | return balance.value; 1412 | } 1413 | return null; 1414 | } 1415 | /** 1416 | * Retrieves the transferable amount for a specific address and ticker. 1417 | * @param {string} address - The address for which to retrieve the transferable amount. 1418 | * @param {string} ticker - The ticker of the token. 1419 | * @returns {Promise} The transferable amount or null if not found. 1420 | */ 1421 | 1422 | async getTransferable(address, ticker) { 1423 | let transferable = await this.tracManager.bee.get( 1424 | "t/" + address + "/" + JSON.stringify(ticker.toLowerCase()) 1425 | ); 1426 | 1427 | if (transferable !== null) { 1428 | return transferable.value; 1429 | } 1430 | return null; 1431 | } 1432 | 1433 | async getSingleTransferable(inscription_id) { 1434 | let transferable = await this.tracManager.bee.get('tamt/' + inscription_id); 1435 | if (transferable !== null) { 1436 | return transferable.value; 1437 | } 1438 | return null; 1439 | } 1440 | 1441 | /** 1442 | * Gets the total number of holders for a given ticker. 1443 | * @param {string} ticker - The ticker for which to retrieve the number of holders. 1444 | * @returns {Promise} The number of holders for the specified ticker. 1445 | */ 1446 | async getHoldersLength(ticker) { 1447 | return this.getLength("h/" + JSON.stringify(ticker.toLowerCase())); 1448 | } 1449 | 1450 | async getHistoricHoldersLength(ticker) { 1451 | return await this.getHoldersLength(ticker); 1452 | } 1453 | 1454 | /** 1455 | * Retrieves a list of holders for a specific ticker. 1456 | * @param {string} ticker - The ticker for which to retrieve holders. 1457 | * @param {number} [offset=0] - The starting index for retrieving holders. 1458 | * @param {number} [max=500] - The maximum number of holders to retrieve. 1459 | * @returns {Promise} An array of holder records. 1460 | */ 1461 | async getHolders(ticker, offset = 0, max = 500) { 1462 | let _ticker = JSON.stringify(ticker.toLowerCase()); 1463 | 1464 | let out = []; 1465 | let records = await this.getListRecords( 1466 | "h/" + _ticker, 1467 | "hi/" + _ticker, 1468 | offset, 1469 | max, 1470 | false 1471 | ); 1472 | 1473 | if (!Array.isArray(records)) { 1474 | return records; 1475 | } 1476 | 1477 | for (let i = 0; i < records.length; i++) { 1478 | out.push({ 1479 | address: records[i], 1480 | balance: await this.getBalance(records[i], ticker), 1481 | transferable: await this.getTransferable(records[i], ticker), 1482 | }); 1483 | await this.sleep(1); 1484 | } 1485 | 1486 | return out; 1487 | } 1488 | 1489 | async getHistoricHolders(ticker, offset = 0, max = 500) { 1490 | return await this.getHolders(ticker, offset, max); 1491 | } 1492 | 1493 | async getAccountBlockedTransferables(address) { 1494 | if(null !== await this.tracManager.bee.get("bltr/" + address)){ 1495 | return true; 1496 | } 1497 | return false; 1498 | } 1499 | 1500 | /** 1501 | * Gets the total number of tokens held by a specific address. 1502 | * @param {string} address - The address for which to retrieve the token count. 1503 | * @returns {Promise} The number of tokens held by the specified address. 1504 | */ 1505 | async getAccountTokensLength(address) { 1506 | return this.getLength("atl/" + address); 1507 | } 1508 | /** 1509 | * Retrieves a list of tokens held by a specific address. 1510 | * @param {string} address - The address for which to retrieve tokens. 1511 | * @param {number} [offset=0] - The starting index for rich etrieving tokens. 1512 | * @param {number} [max=500] - The maximum number of tokens to retrieve. 1513 | * @returns {Promise} An array of token tickers. 1514 | */ 1515 | async getAccountTokens(address, offset = 0, max = 500) { 1516 | let out = []; 1517 | let records = await this.getListRecords( 1518 | "atl/" + address, 1519 | "atli/" + address, 1520 | offset, 1521 | max, 1522 | false 1523 | ); 1524 | 1525 | if (!Array.isArray(records)) { 1526 | return records; 1527 | } 1528 | 1529 | for (let i = 0; i < records.length; i++) { 1530 | out.push(records[i].toLowerCase()); 1531 | } 1532 | 1533 | return out; 1534 | } 1535 | 1536 | /** 1537 | * Retrieves a list of tokens and total balance, transferable of each by an address 1538 | * @param {string} address - The address for which to retrieve tokens. 1539 | * @param {number} [offset=0] - The starting index for rich retieving tokens. 1540 | * @param {number} [max=500] - The maximum number of tokens to retrieve. 1541 | * @returns {Promise<{ total: number, list:[ ]}>} Have total tokens and an array of token tickers with balance. 1542 | */ 1543 | async getAccountTokensWithBalance(address, offset = 0, max = 500) { 1544 | const total = await this.getAccountTokensLength(address); 1545 | const tokens = await this.getAccountTokens(address, offset, max); 1546 | 1547 | const list = await Promise.all( 1548 | tokens.map(async (token) => { 1549 | const overallBalance = await this.getBalance(address, token); 1550 | const transferableBalance = await this.getTransferable(address, token); 1551 | return { 1552 | ticker: token, 1553 | overallBalance, 1554 | transferableBalance, 1555 | }; 1556 | }) 1557 | ); 1558 | return { 1559 | total, 1560 | list, 1561 | }; 1562 | } 1563 | 1564 | /** 1565 | * Retrieve token info , total balance, transferable balance, tokens transfers list (include sent or not) by specific token of an account 1566 | * @param {string} address - The address for which to retrieve tokens. 1567 | * @param {string} ticker - The ticker for which to retrieve tokens. 1568 | * @returns {Promise<{Object}>} Have token info and balance. 1569 | */ 1570 | async getAccountTokenDetail(address, ticker) { 1571 | const tokenInfo = await this.getDeployment(ticker); 1572 | if (!tokenInfo) return null; 1573 | const overallBalance = await this.getBalance(address, ticker); 1574 | const transferableBalance = await this.getTransferable(address, ticker); 1575 | 1576 | const transferList = await this.getAccountTransferList(address, ticker); 1577 | const tokenBalance = { 1578 | ticker, 1579 | overallBalance, 1580 | transferableBalance, 1581 | }; 1582 | return { 1583 | tokenInfo, 1584 | tokenBalance, 1585 | transferList, 1586 | }; 1587 | } 1588 | 1589 | /** 1590 | * Gets the total number of DMT elements. 1591 | * @returns {Promise} The total number of DMT elements. 1592 | */ 1593 | async getDmtElementsListLength() { 1594 | return this.getLength("dmt-ell"); 1595 | } 1596 | 1597 | /** 1598 | * Retrieves a list of DMT elements. 1599 | * @param {number} [offset=0] - The starting index for retrieving DMT elements. 1600 | * @param {number} [max=500] - The maximum number of DMT elements to retrieve. 1601 | * @returns {Promise} An array of DMT element records. 1602 | */ 1603 | async getDmtElementsList(offset = 0, max = 500) { 1604 | let out = []; 1605 | let records = await this.getListRecords( 1606 | "dmt-ell", 1607 | "dmt-elli", 1608 | offset, 1609 | max, 1610 | false 1611 | ); 1612 | 1613 | for (let i = 0; i < records.length; i++) { 1614 | let element = await this.tracManager.bee.get( 1615 | "dmt-el/" + JSON.stringify(records[i]) 1616 | ); 1617 | if (element !== null) { 1618 | out.push(JSON.parse(element.value)); 1619 | } 1620 | } 1621 | 1622 | return out; 1623 | } 1624 | 1625 | /** 1626 | * Gets the total number of mints performed by a specific address for a given ticker. 1627 | * @param {string} address - The address for which to retrieve the mint count. 1628 | * @param {string} ticker - The ticker of the token. 1629 | * @returns {Promise} The number of mints performed by the address for the specified ticker. 1630 | */ 1631 | async getAccountMintListLength(address, ticker) { 1632 | return this.getLength( 1633 | "aml/" + address + "/" + JSON.stringify(ticker.toLowerCase()) 1634 | ); 1635 | } 1636 | /** 1637 | * Gets the total number of mints performed by a specific address for a given ticker. 1638 | * @param {string} address - The address for which to retrieve the mint count. 1639 | * @param {string} ticker - The ticker of the token. 1640 | * @returns {Promise} The number of mints performed by the address for the specified ticker. 1641 | */ 1642 | async getAccountMintList(address, ticker, offset = 0, max = 500) { 1643 | ticker = JSON.stringify(ticker.toLowerCase()); 1644 | let out = []; 1645 | let records = await this.getListRecords( 1646 | "aml/" + address + "/" + ticker, 1647 | "amli/" + address + "/" + ticker, 1648 | offset, 1649 | max, 1650 | true 1651 | ); 1652 | 1653 | if (!Array.isArray(records)) { 1654 | return records; 1655 | } 1656 | 1657 | for (let i = 0; i < records.length; i++) { 1658 | out.push(records[i]); 1659 | } 1660 | 1661 | return out; 1662 | } 1663 | /** 1664 | * Retrieves the length of the mint list for a specific ticker. 1665 | * @param {string} ticker - The ticker of the token. 1666 | * @returns {Promise} A promise that resolves with the length of the mint list. 1667 | */ 1668 | async getTickerMintListLength(ticker) { 1669 | return this.getLength("fml/" + JSON.stringify(ticker.toLowerCase())); 1670 | } 1671 | /** 1672 | * Retrieves a list of mint records for a specific address and ticker. 1673 | * @param {string} address - The address for which to retrieve mint records. 1674 | * @param {string} ticker - The ticker of the token. 1675 | * @param {number} [offset=0] - The starting index for retrieving mint records. 1676 | * @param {number} [max=500] - The maximum number of mint records to retrieve. 1677 | * @returns {Promise} An array of mint records. 1678 | */ 1679 | async getTickerMintList(ticker, offset = 0, max = 500) { 1680 | ticker = JSON.stringify(ticker.toLowerCase()); 1681 | let out = []; 1682 | let records = await this.getListRecords( 1683 | "fml/" + ticker, 1684 | "fmli/" + ticker, 1685 | offset, 1686 | max, 1687 | true 1688 | ); 1689 | 1690 | if (!Array.isArray(records)) { 1691 | return records; 1692 | } 1693 | 1694 | for (let i = 0; i < records.length; i++) { 1695 | out.push(records[i]); 1696 | } 1697 | 1698 | return out; 1699 | } 1700 | /** 1701 | * Gets the total number of mints for a given ticker. 1702 | * @param {string} ticker - The ticker for which to retrieve the mint count. 1703 | * @returns {Promise} The number of mints for the specified ticker. 1704 | */ 1705 | async getMintListLength() { 1706 | return this.getLength("sfml"); 1707 | } 1708 | /** 1709 | * Retrieves a list of all mint records across all tickers. 1710 | * @param {number} [offset=0] - The starting index for retrieving mint records. 1711 | * @param {number} [max=500] - The maximum number of mint records to retrieve. 1712 | * @returns {Promise} An array of mint records. 1713 | */ 1714 | async getMintList(offset = 0, max = 500) { 1715 | let out = []; 1716 | let records = await this.getListRecords("sfml", "sfmli", offset, max, true); 1717 | 1718 | if (!Array.isArray(records)) { 1719 | return records; 1720 | } 1721 | 1722 | for (let i = 0; i < records.length; i++) { 1723 | out.push(records[i]); 1724 | } 1725 | 1726 | return out; 1727 | } 1728 | 1729 | /** 1730 | * Retrieves details of a specific trade based on its inscription ID. 1731 | * @param {string} inscription_id - The ID of the trade inscription to query. 1732 | * @returns {Promise} Trade details or null if not found. 1733 | */ 1734 | async getTrade(inscription_id) { 1735 | let trade = await this.tracManager.bee.get("tol/" + inscription_id); 1736 | 1737 | if (trade !== null) { 1738 | return JSON.parse(trade.value); 1739 | } 1740 | return null; 1741 | } 1742 | /** 1743 | * Gets the total number of trades for a specific address and ticker. 1744 | * @param {string} address - The address for which to retrieve the trade count. 1745 | * @param {string} ticker - The ticker of the token. 1746 | * @returns {Promise} The number of trades for the specified address and ticker. 1747 | */ 1748 | async getAccountTradesListLength(address, ticker) { 1749 | return this.getLength( 1750 | "atrof/" + address + "/" + JSON.stringify(ticker.toLowerCase()) 1751 | ); 1752 | } 1753 | /** 1754 | * Retrieves a list of trades for a specific address and ticker. 1755 | * @param {string} address - The address for which to retrieve trades. 1756 | * @param {string} ticker - The ticker of the token. 1757 | * @param {number} [offset=0] - The starting index for retrieving trades. 1758 | * @param {number} [max=500] - The maximum number of trades to retrieve. 1759 | * @returns {Promise} An array of trade records. 1760 | */ 1761 | 1762 | async getAccountTradesList(address, ticker, offset = 0, max = 500) { 1763 | ticker = JSON.stringify(ticker.toLowerCase()); 1764 | let out = []; 1765 | let records = await this.getListRecords( 1766 | "atrof/" + address + "/" + ticker, 1767 | "atrofi/" + address + "/" + ticker, 1768 | offset, 1769 | max, 1770 | true 1771 | ); 1772 | 1773 | if (!Array.isArray(records)) { 1774 | return records; 1775 | } 1776 | 1777 | for (let i = 0; i < records.length; i++) { 1778 | out.push(records[i]); 1779 | } 1780 | 1781 | return out; 1782 | } 1783 | /** 1784 | * Checks if a given token-auth inscription has been cancelled. 1785 | * @param {string} inscription_id - The ID of the token-auth inscription to check. 1786 | * @returns {Promise} True if the inscription is cancelled, false otherwise. 1787 | */ 1788 | 1789 | async getAuthCancelled(inscription_id) { 1790 | const cancelled = await this.tracManager.bee.get("tac/" + inscription_id); 1791 | 1792 | if (cancelled !== null) { 1793 | return true; 1794 | } 1795 | return false; 1796 | } 1797 | /** 1798 | * Checks if a given privilege-auth inscription has been cancelled. 1799 | * @param {string} inscription_id - The ID of the token-auth inscription to check. 1800 | * @returns {Promise} True if the inscription is cancelled, false otherwise. 1801 | */ 1802 | 1803 | async getPrivilegeAuthCancelled(inscription_id) { 1804 | const cancelled = await this.tracManager.bee.get("prac/" + inscription_id); 1805 | 1806 | if (cancelled !== null) { 1807 | return true; 1808 | } 1809 | return false; 1810 | } 1811 | /** 1812 | * Checks if a given hash exists in the token-auth system. 1813 | * @param {string} hash - The hash to check for existence. 1814 | * @returns {Promise} True if the hash exists, false otherwise. 1815 | */ 1816 | 1817 | async getAuthHashExists(hash) { 1818 | hash = await this.tracManager.bee.get("tah/" + hash.trim().toLowerCase()); 1819 | 1820 | if (hash !== null) { 1821 | return true; 1822 | } 1823 | return false; 1824 | } 1825 | 1826 | async getAuthCompactHexExists(hash) { 1827 | hash = await this.tracManager.bee.get("tah/" + hash.trim().toLowerCase()); 1828 | 1829 | if (hash !== null) { 1830 | return true; 1831 | } 1832 | return false; 1833 | } 1834 | 1835 | /** 1836 | * Checks if a given hash exists in the privilege-auth system. 1837 | * @param {string} hash - The hash to check for existence. 1838 | * @returns {Promise} True if the hash exists, false otherwise. 1839 | */ 1840 | 1841 | async getPrivilegeAuthHashExists(hash) { 1842 | hash = await this.tracManager.bee.get("prah/" + hash.trim().toLowerCase()); 1843 | 1844 | if (hash !== null) { 1845 | return true; 1846 | } 1847 | return false; 1848 | } 1849 | 1850 | async getPrivilegeAuthCompactHexExists(hash) { 1851 | hash = await this.tracManager.bee.get("prah/" + hash.trim().toLowerCase()); 1852 | 1853 | if (hash !== null) { 1854 | return true; 1855 | } 1856 | return false; 1857 | } 1858 | 1859 | /** 1860 | * Gets the total number of redeems across all tokens. 1861 | * @returns {Promise} The total number of redeems. 1862 | */ 1863 | 1864 | async getRedeemListLength() { 1865 | return this.getLength("sftr"); 1866 | } 1867 | /** 1868 | * Retrieves a list of all redeem records across all tokens. 1869 | * @param {number} [offset=0] - The starting index for retrieving redeem records. 1870 | * @param {number} [max=500] - The maximum number of redeem records to retrieve. 1871 | * @returns {Promise} An array of redeem records. 1872 | */ 1873 | 1874 | async getRedeemList(offset = 0, max = 500) { 1875 | let out = []; 1876 | let records = await this.getListRecords("sftr", "sftri", offset, max, true); 1877 | 1878 | if (!Array.isArray(records)) { 1879 | return records; 1880 | } 1881 | 1882 | for (let i = 0; i < records.length; i++) { 1883 | out.push(records[i]); 1884 | } 1885 | 1886 | return out; 1887 | } 1888 | /** 1889 | * Gets the total number of redeems performed by a specific address. 1890 | * @param {string} address - The address for which to retrieve the redeem count. 1891 | * @returns {Promise} The number of redeems performed by the specified address. 1892 | */ 1893 | async getAccountRedeemListLength(address) { 1894 | return this.getLength("tr/" + address); 1895 | } 1896 | /** 1897 | * Retrieves a list of redeem records for a specific address. 1898 | * @param {string} address - The address for which to retrieve redeem records. 1899 | * @param {number} [offset=0] - The starting index for retrieving redeem records. 1900 | * @param {number} [max=500] - The maximum number of redeem records to retrieve. 1901 | * @returns {Promise} An array of redeem records for the specified address. 1902 | */ 1903 | async getAccountRedeemList(address, offset = 0, max = 500) { 1904 | let out = []; 1905 | let records = await this.getListRecords( 1906 | "tr/" + address, 1907 | "tri/" + address, 1908 | offset, 1909 | max, 1910 | true 1911 | ); 1912 | 1913 | if (!Array.isArray(records)) { 1914 | return records; 1915 | } 1916 | 1917 | for (let i = 0; i < records.length; i++) { 1918 | out.push(records[i]); 1919 | } 1920 | 1921 | return out; 1922 | } 1923 | /** 1924 | * Gets the total number of token auth records for a specific address. 1925 | * @param {string} address - The address for which to retrieve the auth count. 1926 | * @returns {Promise} The number of auth records for the specified address. 1927 | */ 1928 | async getAccountAuthListLength(address) { 1929 | return this.getLength("ta/" + address); 1930 | } 1931 | /** 1932 | * Gets the total number of privilege auth records for a specific address. 1933 | * @param {string} address - The address for which to retrieve the auth count. 1934 | * @returns {Promise} The number of auth records for the specified address. 1935 | */ 1936 | async getAccountPrivilegeAuthListLength(address) { 1937 | return this.getLength("pra/" + address); 1938 | } 1939 | /** 1940 | * Retrieves a list of token auth records for a specific address. 1941 | * @param {string} address - The address for which to retrieve auth records. 1942 | * @param {number} [offset=0] - The starting index for retrieving auth records. 1943 | * @param {number} [max=500] - The maximum number of auth records to retrieve. 1944 | * @returns {Promise} An array of auth records for the specified address. 1945 | */ 1946 | async getAccountAuthList(address, offset = 0, max = 500) { 1947 | let out = []; 1948 | let records = await this.getListRecords( 1949 | "ta/" + address, 1950 | "tai/" + address, 1951 | offset, 1952 | max, 1953 | true 1954 | ); 1955 | 1956 | if (!Array.isArray(records)) { 1957 | return records; 1958 | } 1959 | 1960 | for (let i = 0; i < records.length; i++) { 1961 | out.push(records[i]); 1962 | } 1963 | 1964 | return out; 1965 | } 1966 | /** 1967 | * Retrieves a list of privilege auth records for a specific address. 1968 | * @param {string} address - The address for which to retrieve auth records. 1969 | * @param {number} [offset=0] - The starting index for retrieving auth records. 1970 | * @param {number} [max=500] - The maximum number of auth records to retrieve. 1971 | * @returns {Promise} An array of auth records for the specified address. 1972 | */ 1973 | async getAccountPrivilegeAuthList(address, offset = 0, max = 500) { 1974 | let out = []; 1975 | let records = await this.getListRecords( 1976 | "pra/" + address, 1977 | "prai/" + address, 1978 | offset, 1979 | max, 1980 | true 1981 | ); 1982 | 1983 | if (!Array.isArray(records)) { 1984 | return records; 1985 | } 1986 | 1987 | for (let i = 0; i < records.length; i++) { 1988 | out.push(records[i]); 1989 | } 1990 | 1991 | return out; 1992 | } 1993 | /** 1994 | * Gets the total number of token auth records across all addresses. 1995 | * @returns {Promise} The total number of auth records. 1996 | */ 1997 | async getAuthListLength() { 1998 | return this.getLength("sfta"); 1999 | } 2000 | /** 2001 | * Gets the total number of privilege auth records across all addresses. 2002 | * @returns {Promise} The total number of auth records. 2003 | */ 2004 | async getPrivilegeAuthListLength() { 2005 | return this.getLength("sfpra"); 2006 | } 2007 | /** 2008 | * Retrieves a list of all token auth records across all addresses. 2009 | * @param {number} [offset=0] - The starting index for retrieving auth records. 2010 | * @param {number} [max=500] - The maximum number of auth records to retrieve. 2011 | * @returns {Promise} An array of auth records. 2012 | */ 2013 | async getAuthList(offset = 0, max = 500) { 2014 | let out = []; 2015 | let records = await this.getListRecords("sfta", "sftai", offset, max, true); 2016 | 2017 | if (!Array.isArray(records)) { 2018 | return records; 2019 | } 2020 | 2021 | for (let i = 0; i < records.length; i++) { 2022 | out.push(records[i]); 2023 | } 2024 | 2025 | return out; 2026 | } 2027 | /** 2028 | * Retrieves a list of all privilege auth records across all addresses. 2029 | * @param {number} [offset=0] - The starting index for retrieving auth records. 2030 | * @param {number} [max=500] - The maximum number of auth records to retrieve. 2031 | * @returns {Promise} An array of auth records. 2032 | */ 2033 | async getPrivilegeAuthList(offset = 0, max = 500) { 2034 | let out = []; 2035 | let records = await this.getListRecords("sfpra", "sfprai", offset, max, true); 2036 | 2037 | if (!Array.isArray(records)) { 2038 | return records; 2039 | } 2040 | 2041 | for (let i = 0; i < records.length; i++) { 2042 | out.push(records[i]); 2043 | } 2044 | 2045 | return out; 2046 | } 2047 | /** 2048 | * Gets the total number of trades for a specific ticker. 2049 | * @param {string} ticker - The ticker for which to retrieve the trade count. 2050 | * @returns {Promise} The number of trades for the specified ticker. 2051 | */ 2052 | async getTickerTradesListLength(ticker) { 2053 | return this.getLength("fatrof/" + JSON.stringify(ticker.toLowerCase())); 2054 | } 2055 | /** 2056 | * Retrieves a list of trades for a specific ticker. 2057 | * @param {string} ticker - The ticker for which to retrieve trades. 2058 | * @param {number} [offset=0] - The starting index for retrieving trades. 2059 | * @param {number} [max=500] - The maximum number of trades to retrieve. 2060 | * @returns {Promise} An array of trade records for the specified ticker. 2061 | */ 2062 | async getTickerTradesList(ticker, offset = 0, max = 500) { 2063 | ticker = JSON.stringify(ticker.toLowerCase()); 2064 | let out = []; 2065 | let records = await this.getListRecords( 2066 | "fatrof/" + ticker, 2067 | "fatrofi/" + ticker, 2068 | offset, 2069 | max, 2070 | true 2071 | ); 2072 | 2073 | if (!Array.isArray(records)) { 2074 | return records; 2075 | } 2076 | 2077 | for (let i = 0; i < records.length; i++) { 2078 | out.push(records[i]); 2079 | } 2080 | 2081 | return out; 2082 | } 2083 | /** 2084 | * Gets the total number of trades across all tickers. 2085 | * @returns {Promise} The total number of trades. 2086 | */ 2087 | async getTradesListLength() { 2088 | return this.getLength("sfatrof"); 2089 | } 2090 | /** 2091 | * Retrieves a list of all trade records across all tickers. 2092 | * @param {number} [offset=0] - The starting index for retrieving trade records. 2093 | * @param {number} [max=500] - The maximum number of trade records to retrieve. 2094 | * @returns {Promise} An array of all trade records. 2095 | */ 2096 | async getTradesList(offset = 0, max = 500) { 2097 | let out = []; 2098 | let records = await this.getListRecords( 2099 | "sfatrof", 2100 | "sfatrofi", 2101 | offset, 2102 | max, 2103 | true 2104 | ); 2105 | 2106 | if (!Array.isArray(records)) { 2107 | return records; 2108 | } 2109 | 2110 | for (let i = 0; i < records.length; i++) { 2111 | out.push(records[i]); 2112 | } 2113 | 2114 | return out; 2115 | } 2116 | /** 2117 | * Gets the total number of transfers for a specific address and ticker. 2118 | * @param {string} address - The address for which to retrieve the transfer count. 2119 | * @param {string} ticker - The ticker of the token. 2120 | * @returns {Promise} The number of transfers for the specified address and ticker. 2121 | */ 2122 | async getAccountTransferListLength(address, ticker) { 2123 | return this.getLength( 2124 | "atrl/" + address + "/" + JSON.stringify(ticker.toLowerCase()) 2125 | ); 2126 | } 2127 | /** 2128 | * Retrieves a list of transfer records for a specific address and ticker. 2129 | * @param {string} address - The address for which to retrieve transfer records. 2130 | * @param {string} ticker - The ticker of the token. 2131 | * @param {number} [offset=0] - The starting index for retrieving transfer records. 2132 | * @param {number} [max=500] - The maximum number of transfer records to retrieve. 2133 | * @returns {Promise} An array of transfer records for the specified address and ticker. 2134 | */ 2135 | async getAccountTransferList(address, ticker, offset = 0, max = 500) { 2136 | ticker = JSON.stringify(ticker.toLowerCase()); 2137 | let out = []; 2138 | let records = await this.getListRecords( 2139 | "atrl/" + address + "/" + ticker, 2140 | "atrli/" + address + "/" + ticker, 2141 | offset, 2142 | max, 2143 | true 2144 | ); 2145 | 2146 | if (!Array.isArray(records)) { 2147 | return records; 2148 | } 2149 | 2150 | for (let i = 0; i < records.length; i++) { 2151 | out.push(records[i]); 2152 | } 2153 | 2154 | return out; 2155 | } 2156 | /** 2157 | * Gets the total number of transfers for a given ticker. 2158 | * @param {string} ticker - The ticker for which to retrieve the transfer count. 2159 | * @returns {Promise} The number of transfers for the specified ticker. 2160 | */ 2161 | async getTickerTransferListLength(ticker) { 2162 | return this.getLength("ftrl/" + JSON.stringify(ticker.toLowerCase())); 2163 | } 2164 | /** 2165 | * Retrieves a list of transfer records for a specific ticker. 2166 | * @param {string} ticker - The ticker for which to retrieve transfer records. 2167 | * @param {number} [offset=0] - The starting index for retrieving transfer records. 2168 | * @param {number} [max=500] - The maximum number of transfer records to retrieve. 2169 | * @returns {Promise} An array of transfer records for the specified ticker. 2170 | */ 2171 | async getTickerTransferList(ticker, offset = 0, max = 500) { 2172 | ticker = JSON.stringify(ticker.toLowerCase()); 2173 | let out = []; 2174 | let records = await this.getListRecords( 2175 | "ftrl/" + ticker, 2176 | "ftrli/" + ticker, 2177 | offset, 2178 | max, 2179 | true 2180 | ); 2181 | 2182 | if (!Array.isArray(records)) { 2183 | return records; 2184 | } 2185 | 2186 | for (let i = 0; i < records.length; i++) { 2187 | out.push(records[i]); 2188 | } 2189 | 2190 | return out; 2191 | } 2192 | /** 2193 | * Gets the total number of transfers across all tickers. 2194 | * @returns {Promise} The total number of transfers. 2195 | */ 2196 | async getTransferListLength() { 2197 | return this.getLength("sftrl"); 2198 | } 2199 | /** 2200 | * Retrieves a list of all transfer records across all tickers. 2201 | * @param {number} [offset=0] - The starting index for retrieving transfer records. 2202 | * @param {number} [max=500] - The maximum number of transfer records to retrieve. 2203 | * @returns {Promise} An array of all transfer records. 2204 | */ 2205 | async getTransferList(offset = 0, max = 500) { 2206 | let out = []; 2207 | let records = await this.getListRecords( 2208 | "sftrl", 2209 | "sftrli", 2210 | offset, 2211 | max, 2212 | true 2213 | ); 2214 | 2215 | if (!Array.isArray(records)) { 2216 | return records; 2217 | } 2218 | 2219 | for (let i = 0; i < records.length; i++) { 2220 | out.push(records[i]); 2221 | } 2222 | 2223 | return out; 2224 | } 2225 | /** 2226 | * Gets the total number of sent transactions for a specific address and ticker. 2227 | * @param {string} address - The address for which to retrieve the sent count. 2228 | * @param {string} ticker - The ticker of the token. 2229 | * @returns {Promise} The number of sent transactions for the specified address and ticker. 2230 | */ 2231 | async getAccountSentListLength(address, ticker) { 2232 | return this.getLength( 2233 | "strl/" + address + "/" + JSON.stringify(ticker.toLowerCase()) 2234 | ); 2235 | } 2236 | /** 2237 | * Retrieves a list of sent transaction records for a specific address and ticker. 2238 | * @param {string} address - The address for which to retrieve sent transaction records. 2239 | * @param {string} ticker - The ticker of the token. 2240 | * @param {number} [offset=0] - The starting index for retrieving sent transaction records. 2241 | * @param {number} [max=500] - The maximum number of sent transaction records to retrieve. 2242 | * @returns {Promise} An array of sent transaction records for the specified address and ticker. 2243 | */ 2244 | async getAccountSentList(address, ticker, offset = 0, max = 500) { 2245 | ticker = JSON.stringify(ticker.toLowerCase()); 2246 | let out = []; 2247 | let records = await this.getListRecords( 2248 | "strl/" + address + "/" + ticker, 2249 | "strli/" + address + "/" + ticker, 2250 | offset, 2251 | max, 2252 | true 2253 | ); 2254 | 2255 | if (!Array.isArray(records)) { 2256 | return records; 2257 | } 2258 | 2259 | for (let i = 0; i < records.length; i++) { 2260 | out.push(records[i]); 2261 | } 2262 | 2263 | return out; 2264 | } 2265 | /** 2266 | * Gets the total number of received trades filled for a specific address and ticker. 2267 | * @param {string} address - The address for which to retrieve the count. 2268 | * @param {string} ticker - The ticker of the token. 2269 | * @returns {Promise} The number of received trades filled for the specified address and ticker. 2270 | */ 2271 | async getAccountReceiveTradesFilledListLength(address, ticker) { 2272 | return this.getLength( 2273 | "rbtrof/" + address + "/" + JSON.stringify(ticker.toLowerCase()) 2274 | ); 2275 | } 2276 | /** 2277 | * Retrieves a list of received trades filled for a specific address and ticker. 2278 | * @param {string} address - The address for which to retrieve records. 2279 | * @param {string} ticker - The ticker of the token. 2280 | * @param {number} [offset=0] - The starting index for retrieving records. 2281 | * @param {number} [max=500] - The maximum number of records to retrieve. 2282 | * @returns {Promise} An array of received trades filled records for the specified address and ticker. 2283 | */ 2284 | async getAccountReceiveTradesFilledList( 2285 | address, 2286 | ticker, 2287 | offset = 0, 2288 | max = 500 2289 | ) { 2290 | ticker = JSON.stringify(ticker.toLowerCase()); 2291 | let out = []; 2292 | let records = await this.getListRecords( 2293 | "rbtrof/" + address + "/" + ticker, 2294 | "rbtrofi/" + address + "/" + ticker, 2295 | offset, 2296 | max, 2297 | true 2298 | ); 2299 | 2300 | if (!Array.isArray(records)) { 2301 | return records; 2302 | } 2303 | 2304 | for (let i = 0; i < records.length; i++) { 2305 | out.push(records[i]); 2306 | } 2307 | 2308 | return out; 2309 | } 2310 | /** 2311 | * Gets the total number of trades filled for a specific address and ticker. 2312 | * @param {string} address - The address for which to retrieve the trade count. 2313 | * @param {string} ticker - The ticker of the token. 2314 | * @returns {Promise} The number of trades filled for the specified address and ticker. 2315 | */ 2316 | async getAccountTradesFilledListLength(address, ticker) { 2317 | return this.getLength( 2318 | "btrof/" + address + "/" + JSON.stringify(ticker.toLowerCase()) 2319 | ); 2320 | } 2321 | /** 2322 | * Retrieves a list of trades filled for a specific address and ticker. 2323 | * @param {string} address - The address for which to retrieve filled trades. 2324 | * @param {string} ticker - The ticker of the token. 2325 | * @param {number} [offset=0] - The starting index for retrieving filled trades. 2326 | * @param {number} [max=500] - The maximum number of filled trades to retrieve. 2327 | * @returns {Promise} An array of filled trade records for the specified address and ticker. 2328 | */ 2329 | async getAccountTradesFilledList(address, ticker, offset = 0, max = 500) { 2330 | ticker = JSON.stringify(ticker.toLowerCase()); 2331 | let out = []; 2332 | let records = await this.getListRecords( 2333 | "btrof/" + address + "/" + ticker, 2334 | "btrofi/" + address + "/" + ticker, 2335 | offset, 2336 | max, 2337 | true 2338 | ); 2339 | 2340 | if (!Array.isArray(records)) { 2341 | return records; 2342 | } 2343 | 2344 | for (let i = 0; i < records.length; i++) { 2345 | out.push(records[i]); 2346 | } 2347 | 2348 | return out; 2349 | } 2350 | /** 2351 | * Gets the total number of trades filled for a specific ticker. 2352 | * @param {string} ticker - The ticker for which to retrieve the filled trade count. 2353 | * @returns {Promise} The number of filled trades for the specified ticker. 2354 | */ 2355 | async getTickerTradesFilledListLength(ticker) { 2356 | return this.getLength("fbtrof/" + JSON.stringify(ticker.toLowerCase())); 2357 | } 2358 | /** 2359 | * Retrieves a list of filled trade records for a specific ticker. 2360 | * @param {string} ticker - The ticker for which to retrieve filled trades. 2361 | * @param {number} [offset=0] - The starting index for retrieving filled trade records. 2362 | * @param {number} [max=500] - The maximum number of filled trade records to retrieve. 2363 | * @returns {Promise} An array of filled trade records for the specified ticker. 2364 | */ 2365 | async getTickerTradesFilledList(ticker, offset = 0, max = 500) { 2366 | ticker = JSON.stringify(ticker.toLowerCase()); 2367 | let out = []; 2368 | let records = await this.getListRecords( 2369 | "fbtrof/" + ticker, 2370 | "fbtrofi/" + ticker, 2371 | offset, 2372 | max, 2373 | true 2374 | ); 2375 | 2376 | if (!Array.isArray(records)) { 2377 | return records; 2378 | } 2379 | 2380 | for (let i = 0; i < records.length; i++) { 2381 | out.push(records[i]); 2382 | } 2383 | 2384 | return out; 2385 | } 2386 | /** 2387 | * Gets the total number of filled trades across all tickers. 2388 | * @returns {Promise} The total number of filled trades. 2389 | */ 2390 | async getTradesFilledListLength() { 2391 | return this.getLength("sfbtrof"); 2392 | } 2393 | /** 2394 | * Asynchronously retrieves a list of trades that have been filled. 2395 | * @async 2396 | * @param {number} [offset=0] - The starting index for retrieving records. 2397 | * @param {number} [max=500] - The maximum number of records to retrieve. 2398 | * @returns {Promise} A promise that resolves to an array of trade records. 2399 | */ 2400 | async getTradesFilledList(offset = 0, max = 500) { 2401 | let out = []; 2402 | let records = await this.getListRecords( 2403 | "sfbtrof", 2404 | "sfbtrofi", 2405 | offset, 2406 | max, 2407 | true 2408 | ); 2409 | 2410 | if (!Array.isArray(records)) { 2411 | return records; 2412 | } 2413 | 2414 | for (let i = 0; i < records.length; i++) { 2415 | out.push(records[i]); 2416 | } 2417 | 2418 | return out; 2419 | } 2420 | 2421 | /** 2422 | * Gets the length of the account receive list for a given address and ticker. 2423 | * @async 2424 | * @param {string} address - The Bitcoin address to query. 2425 | * @param {string} ticker - The ticker symbol for the token. 2426 | * @returns {Promise} A promise that resolves to the length of the receive list. 2427 | */ 2428 | async getAccountReceiveListLength(address, ticker) { 2429 | return this.getLength( 2430 | "rstrl/" + address + "/" + JSON.stringify(ticker.toLowerCase()) 2431 | ); 2432 | } 2433 | /** 2434 | * Retrieves a list of received transactions for a specific account and ticker. 2435 | * @async 2436 | * @param {string} address - The Bitcoin address to query. 2437 | * @param {string} ticker - The ticker symbol for the token. 2438 | * @param {number} [offset=0] - The starting index for retrieving records. 2439 | * @param {number} [max=500] - The maximum number of records to retrieve. 2440 | * @returns {Promise} A promise that resolves to an array of receive transaction records. 2441 | */ 2442 | async getAccountReceiveList(address, ticker, offset = 0, max = 500) { 2443 | ticker = JSON.stringify(ticker.toLowerCase()); 2444 | let out = []; 2445 | let records = await this.getListRecords( 2446 | "rstrl/" + address + "/" + ticker, 2447 | "rstrli/" + address + "/" + ticker, 2448 | offset, 2449 | max, 2450 | true 2451 | ); 2452 | 2453 | if (!Array.isArray(records)) { 2454 | return records; 2455 | } 2456 | 2457 | for (let i = 0; i < records.length; i++) { 2458 | out.push(records[i]); 2459 | } 2460 | 2461 | return out; 2462 | } 2463 | /** 2464 | * Gets the length of the sent list for a specific ticker. 2465 | * @async 2466 | * @param {string} ticker - The ticker symbol for the token. 2467 | * @returns {Promise} A promise that resolves to the length of the sent list. 2468 | */ 2469 | async getTickerSentListLength(ticker) { 2470 | return this.getLength("fstrl/" + JSON.stringify(ticker.toLowerCase())); 2471 | } 2472 | /** 2473 | * Retrieves a list of sent transactions for a specific ticker. 2474 | * @async 2475 | * @param {string} ticker - The ticker symbol for the token. 2476 | * @param {number} [offset=0] - The starting index for retrieving records. 2477 | * @param {number} [max=500] - The maximum number of records to retrieve. 2478 | * @returns {Promise} A promise that resolves to an array of sent transaction records. 2479 | */ 2480 | async getTickerSentList(ticker, offset = 0, max = 500) { 2481 | ticker = JSON.stringify(ticker.toLowerCase()); 2482 | let out = []; 2483 | let records = await this.getListRecords( 2484 | "fstrl/" + ticker, 2485 | "fstrli/" + ticker, 2486 | offset, 2487 | max, 2488 | true 2489 | ); 2490 | 2491 | if (!Array.isArray(records)) { 2492 | return records; 2493 | } 2494 | 2495 | for (let i = 0; i < records.length; i++) { 2496 | out.push(records[i]); 2497 | } 2498 | 2499 | return out; 2500 | } 2501 | /** 2502 | * Gets the total length of the sent transactions list. 2503 | * 2504 | * @async 2505 | * @returns {Promise} A promise that resolves to the total length of the sent list. 2506 | */ 2507 | async getSentListLength() { 2508 | return this.getLength("sfstrl"); 2509 | } 2510 | /** 2511 | * Retrieves the list of all sent transactions. 2512 | * 2513 | * @async 2514 | * @param {number} [offset=0] - The starting index for retrieving records. 2515 | * @param {number} [max=500] - The maximum number of records to retrieve. 2516 | * @returns {Promise} A promise that resolves to an array of all sent transaction records. 2517 | */ 2518 | async getSentList(offset = 0, max = 500) { 2519 | let out = []; 2520 | let records = await this.getListRecords( 2521 | "sfstrl", 2522 | "sfstrli", 2523 | offset, 2524 | max, 2525 | true 2526 | ); 2527 | 2528 | if (!Array.isArray(records)) { 2529 | return records; 2530 | } 2531 | 2532 | for (let i = 0; i < records.length; i++) { 2533 | out.push(records[i]); 2534 | } 2535 | 2536 | return out; 2537 | } 2538 | /** 2539 | * Retrieves the accumulator object for a given inscription. 2540 | * @async 2541 | * @param {string} inscription - The inscription identifier. 2542 | * @returns {Promise} A promise that resolves to the accumulator object, or null if not found. 2543 | */ 2544 | async getAccumulator(inscription) { 2545 | const accumulator = await this.tracManager.bee.get("a/" + inscription); 2546 | if (accumulator !== null) { 2547 | return JSON.parse(accumulator.value); 2548 | } 2549 | return null; 2550 | } 2551 | /** 2552 | * Gets the total number of accumulator entries for a specific Bitcoin address. 2553 | * @async 2554 | * @param {string} address - The Bitcoin address to query. 2555 | * @returns {Promise} A promise that resolves to the number of accumulator entries. 2556 | */ 2557 | async getAccountAccumulatorListLength(address) { 2558 | return this.getLength("al/" + address); 2559 | } 2560 | /** 2561 | * Retrieves a list of accumulator records for a specified address. 2562 | * @async 2563 | * @param {string} address - The Bitcoin address to query. 2564 | * @param {number} [offset=0] - The starting index for retrieving records. 2565 | * @param {number} [max=500] - The maximum number of records to retrieve. 2566 | * @returns {Promise} A promise that resolves to an array of accumulator records. 2567 | * If an error occurs, returns the error object. 2568 | */ 2569 | async getAccountAccumulatorList(address, offset = 0, max = 500) { 2570 | let out = []; 2571 | let records = await this.getListRecords( 2572 | "al/" + address, 2573 | "ali/" + address, 2574 | offset, 2575 | max, 2576 | true 2577 | ); 2578 | 2579 | if (!Array.isArray(records)) { 2580 | return records; 2581 | } 2582 | 2583 | for (let i = 0; i < records.length; i++) { 2584 | out.push(records[i]); 2585 | } 2586 | 2587 | return out; 2588 | } 2589 | /** 2590 | * Retrieves the total length of the accumulator list. 2591 | * @async 2592 | * @returns {Promise} A promise that resolves to the total length of the accumulator list. 2593 | */ 2594 | async getAccumulatorListLength() { 2595 | return this.getLength("al"); 2596 | } 2597 | /** 2598 | * Retrieves a list of accumulators. 2599 | * @async 2600 | * @param {number} [offset=0] - The starting index for retrieving accumulator records. 2601 | * @param {number} [max=500] - The maximum number of accumulators to retrieve. 2602 | * @returns {Promise} A promise that resolves to an array of accumulator records. 2603 | * If an error occurs, returns the error object. 2604 | */ 2605 | async getAccumulatorList(offset = 0, max = 500) { 2606 | let out = []; 2607 | let records = await this.getListRecords("al", "ali", offset, max, true); 2608 | 2609 | if (!Array.isArray(records)) { 2610 | return records; 2611 | } 2612 | 2613 | for (let i = 0; i < records.length; i++) { 2614 | out.push(records[i]); 2615 | } 2616 | 2617 | return out; 2618 | } 2619 | /** 2620 | * Asynchronously retrieves a batch of list records based on specified keys and limits. 2621 | * 2622 | * @async 2623 | * @param {string} length_key - The key to determine the length of the list. 2624 | * @param {string} iterator_key - The key used for iterating over the list. 2625 | * @param {number} offset - The starting index for retrieving records. 2626 | * @param {number} max - The maximum number of records to retrieve. 2627 | * @param {boolean} return_json - Whether to return the records as JSON objects. 2628 | * @returns {Promise} A promise that resolves to an array of records, an error object, or a string message in case of invalid parameters. 2629 | */ 2630 | async getListRecords(length_key, iterator_key, offset, max, return_json) { 2631 | if(typeof offset === "string" && this.isNumeric(offset)) { 2632 | offset = parseInt(''+offset); 2633 | } 2634 | 2635 | if(typeof max === "string" && this.isNumeric(max)) { 2636 | max = parseInt(''+max); 2637 | } 2638 | 2639 | if(typeof offset !== "string" && !this.isNumeric(offset)) { 2640 | return null; 2641 | } 2642 | 2643 | if(typeof max !== "string" && !this.isNumeric(max)) { 2644 | return null; 2645 | } 2646 | 2647 | if (max > 500) { 2648 | return "request too large"; 2649 | } 2650 | 2651 | if (offset < 0) { 2652 | return "invalid offset"; 2653 | } 2654 | 2655 | let out = []; 2656 | const batch = this.tracManager.bee; 2657 | 2658 | let length = await batch.get(length_key); 2659 | if (length === null) { 2660 | length = 0; 2661 | } else { 2662 | length = parseInt(length.value); 2663 | } 2664 | let j = 0; 2665 | for (let i = offset; i < length; i++) { 2666 | if (j < max) { 2667 | let entry = await batch.get(iterator_key + "/" + i); 2668 | if (return_json) { 2669 | entry = JSON.parse(entry.value); 2670 | } else { 2671 | entry = entry.value; 2672 | } 2673 | out.push(entry); 2674 | } else { 2675 | break; 2676 | } 2677 | j++; 2678 | } 2679 | 2680 | return out; 2681 | } 2682 | /** 2683 | * Gets the length of a list based on a specified key. 2684 | * @async 2685 | * @param {string} length_key - The key to determine the length of the list. 2686 | * @returns {Promise} A promise that resolves to the length of the list. 2687 | */ 2688 | async getLength(length_key) { 2689 | let length = await this.tracManager.bee.get(length_key); 2690 | if (length === null) { 2691 | length = 0; 2692 | } else { 2693 | length = parseInt(length.value); 2694 | } 2695 | return length; 2696 | } 2697 | 2698 | isNumeric(str) { 2699 | return !isNaN(str) && 2700 | !isNaN(parseFloat(str)) 2701 | } 2702 | 2703 | sleep(ms) { 2704 | return new Promise((resolve) => setTimeout(resolve, ms)); 2705 | } 2706 | } 2707 | -------------------------------------------------------------------------------- /src/TracManager.mjs: -------------------------------------------------------------------------------- 1 | import Corestore from "corestore"; 2 | import Hyperswarm from "hyperswarm"; 3 | import Hyperbee from "hyperbee"; 4 | import HyperDHT from "hyperdht"; 5 | import goodbye from "graceful-goodbye"; 6 | import config from "config"; 7 | import figlet from "figlet"; 8 | import WebsocketModule from "./WebsocketModule.mjs"; 9 | import RestModule from "./RestModule.mjs"; 10 | import TapProtocol from "./TapProtocol.mjs"; 11 | import BlockDownloader from "./BlockDownloader.mjs"; 12 | // import { Node } from "hyperbee/lib/messages.js"; 13 | 14 | /** 15 | * The TracManager class manages connections and data synchronization 16 | * using Corestore, Hyperswarm, and Hyperbee technologies. It is designed 17 | * to initialize and handle TAP protocol interactions and data streams. 18 | */ 19 | export default class TracManager { 20 | /** 21 | * Creates an instance of TracManager. 22 | * Sets up Corestore and Hyperswarm and prepares for data synchronization. 23 | */ 24 | /** 25 | * @property {TapProtocol} tapProtocol - Instance of TapProtocol to manage TAP interactions and data streams. 26 | */ 27 | tapProtocol; 28 | /** 29 | * @property {RestModule} restServer - Instance of RestModule for REST API access. 30 | */ 31 | restServer; 32 | constructor() { 33 | const dht = new HyperDHT({ 34 | // Optionally overwrite the default bootstrap servers, just need to be an array of any known dht node(s) 35 | // Defaults to ['node1.hyperdht.org:49737', 'node2.hyperdht.org:49737', 'node3.hyperdht.org:49737'] 36 | bootstrap: ['116.202.214.143:10001','116.202.214.149:10001','node1.hyperdht.org:49737', 'node2.hyperdht.org:49737', 'node3.hyperdht.org:49737'] 37 | }); 38 | this.store = new Corestore("./tapstore"); 39 | this.swarm = new Hyperswarm({maxPeers : 1024, maxParallel: 512, maxServerConnections : 256, dht : dht}); 40 | this.bee = null; 41 | this.tapProtocol = new TapProtocol(this); 42 | 43 | goodbye(() => { 44 | this.swarm.destroy(); 45 | }); 46 | } 47 | /** 48 | * Initializes the reader for the TAP Protocol, setting up corestore and hyperswarm. 49 | * Also configures the Hyperbee database and, optionally, a websocket server. 50 | * 51 | * @param {boolean} [server=true] - Whether to start as a server in the Hyperswarm network. 52 | * @param {boolean} [client=true] - Whether to start as a client in the Hyperswarm network. 53 | * @param {number} [rangeStart=-1] - The starting index for range-based data download. 54 | * @param {number} [rangeEnd=-1] - The ending index for range-based data download. 55 | * @returns {Promise} A promise that resolves when initialization is complete. 56 | */ 57 | async initReader( 58 | server = true, 59 | client = true, 60 | rangeStart = -1, 61 | rangeEnd = -1 62 | ) { 63 | // Initialize Corestore and Hyperswarm 64 | console.log(figlet.textSync("Trac Core Reader")); 65 | console.log("Protocol: Ordinals/TAP"); 66 | 67 | this.core = this.store.get({ 68 | key: process.argv[2] 69 | ? Buffer.from(process.argv[2], "hex") 70 | : Buffer.from(config.get("channel"), "hex"), 71 | sparse: true, 72 | }); 73 | 74 | console.log("Channel:", this.core.key.toString("hex")); 75 | 76 | await this.core.ready(); 77 | await this.initHyperswarm(server, client); 78 | 79 | this.bee = new Hyperbee(this.core, { 80 | keyEncoding: "utf-8", 81 | valueEncoding: "utf-8", 82 | }); 83 | 84 | await this.bee.ready(); 85 | 86 | if (config.get("enableWebsockets")) { 87 | console.log("Enabling websocket"); 88 | this.websocketServer = new WebsocketModule(this); 89 | } 90 | 91 | if (config.get("enableRest")) { 92 | console.log("Enabling REST endpoint"); 93 | this.restServer = new RestModule(this); 94 | this.restServer.start(); 95 | } 96 | 97 | if(config.get("enableBlockDownloader")) { 98 | this.blockDownloader = new BlockDownloader(this.core); 99 | this.blockDownloader.startRangeDownload() 100 | } 101 | 102 | // if (rangeStart > -1) { 103 | // // TODO: range download is not very fast & efficient and should be replaced with non-sparse downloads instead 104 | // this.startRangeDownload(rangeStart, rangeEnd); 105 | // } 106 | 107 | // await this.sleep(30 * 1000); 108 | } 109 | /** 110 | * Initializes a Hyperswarm network connection for data synchronization. 111 | * 112 | * @param {boolean} server - Indicates if this instance should act as a server. 113 | * @param {boolean} client - Indicates if this instance should act as a client. 114 | * @returns {Promise} A promise that resolves when the network is initialized. 115 | */ 116 | async initHyperswarm(server, client) { 117 | this.swarm.on("connection", (connection, peerInfo) => { 118 | 119 | console.log( 120 | "Connected to peer:", 121 | connection.remotePublicKey.toString("hex") 122 | ); 123 | 124 | 125 | this.core.replicate(connection); 126 | }); 127 | 128 | const discovery = this.swarm.join(this.core.discoveryKey, { 129 | server: server, 130 | client: client, 131 | }); 132 | 133 | await discovery.flushed(); 134 | const foundPeers = this.store.findingPeers(); 135 | await this.swarm.flush(); 136 | await foundPeers(); 137 | } 138 | /** 139 | * Starts downloading data within a specified range. 140 | * 141 | * @param {number} start - The starting index for the data download. 142 | * @param {number} end - The ending index for the data download. 143 | * @returns {Promise} A promise that resolves when the download is complete. 144 | */ 145 | async startRangeDownload(start, end) { 146 | console.log("Starting chunk download. Core length:", this.core.length); 147 | 148 | if (end < 0) { 149 | end = this.core.length; 150 | } 151 | 152 | let chunk_size = 20000; 153 | 154 | for (let i = start; i < end; i++) { 155 | console.log("Next chunk", i, i + chunk_size); 156 | const range = this.core.download({ start: i, end: i + chunk_size }); 157 | await range.done(); 158 | i = i + chunk_size - 1; 159 | start = i; 160 | } 161 | 162 | if (end == -1) { 163 | // const discovery = this.swarm.refresh({ server: true, client: true }); // hardcoded for now, does this need to be configurable? 164 | // await discovery.flushed(); 165 | // const foundPeers = this.store.findingPeers(); 166 | // await this.swarm.flush(); 167 | // await foundPeers(); 168 | // await this.sleep(1000); 169 | this.startRangeDownload(start, end); 170 | } 171 | } 172 | /** 173 | * A utility method for creating a delay. 174 | * 175 | * @param {number} ms - The number of milliseconds to delay. 176 | * @returns {Promise} A promise that resolves after the specified delay. 177 | */ 178 | sleep(ms) { 179 | return new Promise((resolve) => setTimeout(resolve, ms)); 180 | } 181 | } 182 | -------------------------------------------------------------------------------- /src/WebsocketModule.mjs: -------------------------------------------------------------------------------- 1 | import { createServer } from "http"; 2 | import { Server } from "socket.io"; 3 | import config from "config"; 4 | 5 | export default class WebsocketModule { 6 | /** 7 | * Creates an instance of WebsocketModule for Trac Core 8 | * @param {Object} tracManager - An object managing Trac Core. 9 | */ 10 | constructor(tracManager) { 11 | this.tracManager = tracManager; 12 | 13 | this.socket_port = config.get("websocketPort"); 14 | this.httpServer = createServer(); 15 | this.httpServer.maxConnections = 1000; 16 | 17 | console.log("Starting socket.io"); 18 | this.io = new Server(this.httpServer, { 19 | cors: { 20 | origin: config.get("websocketCORS"), 21 | }, 22 | }).listen(this.socket_port); 23 | 24 | this.io.on("connection", (socket) => { 25 | socket.on("get", async (cmd) => { 26 | if (!this.validCmd(cmd, socket)) return; 27 | let result = null; 28 | 29 | try { 30 | switch (cmd.func) { 31 | 32 | case "transferredListLength": 33 | if (cmd.args.length != 1) { 34 | this.invalidCmd(cmd, socket); 35 | return; 36 | } 37 | result = await this.tracManager.tapProtocol.getTransferredListLength( 38 | cmd.args[0] 39 | ); 40 | break; 41 | 42 | case "transferredList": 43 | if (cmd.args.length != 3) { 44 | this.invalidCmd(cmd, socket); 45 | return; 46 | } 47 | result = await this.tracManager.tapProtocol.getTransferredList( 48 | cmd.args[0], 49 | cmd.args[1], 50 | cmd.args[2] 51 | ); 52 | break; 53 | 54 | case "tickerTransferredListLength": 55 | if (cmd.args.length != 2) { 56 | this.invalidCmd(cmd, socket); 57 | return; 58 | } 59 | result = await this.tracManager.tapProtocol.getTickerTransferredListLength( 60 | cmd.args[0], 61 | cmd.args[1] 62 | ); 63 | break; 64 | 65 | case "tickerTransferredList": 66 | if (cmd.args.length != 4) { 67 | this.invalidCmd(cmd, socket); 68 | return; 69 | } 70 | result = await this.tracManager.tapProtocol.getTickerTransferredList( 71 | cmd.args[0], 72 | cmd.args[1], 73 | cmd.args[2], 74 | cmd.args[3] 75 | ); 76 | break; 77 | 78 | case "tickerTransferredListByBlockLength": 79 | if (cmd.args.length != 2) { 80 | this.invalidCmd(cmd, socket); 81 | return; 82 | } 83 | result = await this.tracManager.tapProtocol.getTickerTransferredListByBlockLength( 84 | cmd.args[0], 85 | cmd.args[1] 86 | ); 87 | break; 88 | 89 | case "tickerTransferredListByBlock": 90 | if (cmd.args.length != 4) { 91 | this.invalidCmd(cmd, socket); 92 | return; 93 | } 94 | result = await this.tracManager.tapProtocol.getTickerTransferredListByBlock( 95 | cmd.args[0], 96 | cmd.args[1], 97 | cmd.args[2], 98 | cmd.args[3] 99 | ); 100 | break; 101 | 102 | case "transferredListByBlockLength": 103 | if (cmd.args.length != 1) { 104 | this.invalidCmd(cmd, socket); 105 | return; 106 | } 107 | result = await this.tracManager.tapProtocol.getTransferredListByBlockLength( 108 | cmd.args[0] 109 | ); 110 | break; 111 | 112 | case "transferredListByBlock": 113 | if (cmd.args.length != 3) { 114 | this.invalidCmd(cmd, socket); 115 | return; 116 | } 117 | result = await this.tracManager.tapProtocol.getTransferredListByBlock( 118 | cmd.args[0], 119 | cmd.args[1], 120 | cmd.args[2] 121 | ); 122 | break; 123 | 124 | case "mintedListLength": 125 | if (cmd.args.length != 1) { 126 | this.invalidCmd(cmd, socket); 127 | return; 128 | } 129 | result = await this.tracManager.tapProtocol.getMintedListLength( 130 | cmd.args[0] 131 | ); 132 | break; 133 | 134 | case "mintedList": 135 | if (cmd.args.length != 3) { 136 | this.invalidCmd(cmd, socket); 137 | return; 138 | } 139 | result = await this.tracManager.tapProtocol.getMintedList( 140 | cmd.args[0], 141 | cmd.args[1], 142 | cmd.args[2] 143 | ); 144 | break; 145 | 146 | case "tickerMintedListLength": 147 | if (cmd.args.length != 2) { 148 | this.invalidCmd(cmd, socket); 149 | return; 150 | } 151 | result = await this.tracManager.tapProtocol.getTickerMintedListLength( 152 | cmd.args[0], 153 | cmd.args[1] 154 | ); 155 | break; 156 | 157 | case "tickerMintedList": 158 | if (cmd.args.length != 4) { 159 | this.invalidCmd(cmd, socket); 160 | return; 161 | } 162 | result = await this.tracManager.tapProtocol.getTickerMintedList( 163 | cmd.args[0], 164 | cmd.args[1], 165 | cmd.args[2], 166 | cmd.args[3] 167 | ); 168 | break; 169 | 170 | case "tickerMintedListByBlockLength": 171 | if (cmd.args.length != 2) { 172 | this.invalidCmd(cmd, socket); 173 | return; 174 | } 175 | result = await this.tracManager.tapProtocol.getTickerMintedListByBlockLength( 176 | cmd.args[0], 177 | cmd.args[1] 178 | ); 179 | break; 180 | 181 | case "tickerMintedListByBlock": 182 | if (cmd.args.length != 4) { 183 | this.invalidCmd(cmd, socket); 184 | return; 185 | } 186 | result = await this.tracManager.tapProtocol.getTickerMintedListByBlock( 187 | cmd.args[0], 188 | cmd.args[1], 189 | cmd.args[2], 190 | cmd.args[3] 191 | ); 192 | break; 193 | 194 | case "mintedListByBlockLength": 195 | if (cmd.args.length != 1) { 196 | this.invalidCmd(cmd, socket); 197 | return; 198 | } 199 | result = await this.tracManager.tapProtocol.getMintedListByBlockLength( 200 | cmd.args[0] 201 | ); 202 | break; 203 | 204 | case "mintedListByBlock": 205 | if (cmd.args.length != 3) { 206 | this.invalidCmd(cmd, socket); 207 | return; 208 | } 209 | result = await this.tracManager.tapProtocol.getMintedListByBlock( 210 | cmd.args[0], 211 | cmd.args[1], 212 | cmd.args[2] 213 | ); 214 | break; 215 | 216 | case "deployedListLength": 217 | if (cmd.args.length != 1) { 218 | this.invalidCmd(cmd, socket); 219 | return; 220 | } 221 | result = await this.tracManager.tapProtocol.getDeployedListLength( 222 | cmd.args[0] 223 | ); 224 | break; 225 | 226 | case "deployedList": 227 | if (cmd.args.length != 3) { 228 | this.invalidCmd(cmd, socket); 229 | return; 230 | } 231 | result = await this.tracManager.tapProtocol.getDeployedList( 232 | cmd.args[0], 233 | cmd.args[1], 234 | cmd.args[2] 235 | ); 236 | break; 237 | 238 | case "tickerDeployedListLength": 239 | if (cmd.args.length != 2) { 240 | this.invalidCmd(cmd, socket); 241 | return; 242 | } 243 | result = await this.tracManager.tapProtocol.getTickerDeployedListLength( 244 | cmd.args[0], 245 | cmd.args[1] 246 | ); 247 | break; 248 | 249 | case "tickerDeployedList": 250 | if (cmd.args.length != 4) { 251 | this.invalidCmd(cmd, socket); 252 | return; 253 | } 254 | result = await this.tracManager.tapProtocol.getTickerDeployedList( 255 | cmd.args[0], 256 | cmd.args[1], 257 | cmd.args[2], 258 | cmd.args[3] 259 | ); 260 | break; 261 | 262 | case "tickerDeployedListByBlockLength": 263 | if (cmd.args.length != 2) { 264 | this.invalidCmd(cmd, socket); 265 | return; 266 | } 267 | result = await this.tracManager.tapProtocol.getTickerDeployedListByBlockLength( 268 | cmd.args[0], 269 | cmd.args[1] 270 | ); 271 | break; 272 | 273 | case "tickerDeployedListByBlock": 274 | if (cmd.args.length != 4) { 275 | this.invalidCmd(cmd, socket); 276 | return; 277 | } 278 | result = await this.tracManager.tapProtocol.getTickerDeployedListByBlock( 279 | cmd.args[0], 280 | cmd.args[1], 281 | cmd.args[2], 282 | cmd.args[3] 283 | ); 284 | break; 285 | 286 | case "deployedListByBlockLength": 287 | if (cmd.args.length != 1) { 288 | this.invalidCmd(cmd, socket); 289 | return; 290 | } 291 | result = await this.tracManager.tapProtocol.getDeployedListByBlockLength( 292 | cmd.args[0] 293 | ); 294 | break; 295 | 296 | case "deployedListByBlock": 297 | if (cmd.args.length != 3) { 298 | this.invalidCmd(cmd, socket); 299 | return; 300 | } 301 | result = await this.tracManager.tapProtocol.getDeployedListByBlock( 302 | cmd.args[0], 303 | cmd.args[1], 304 | cmd.args[2] 305 | ); 306 | break; 307 | 308 | case "getInscribeTransferListLength": 309 | if (cmd.args.length != 1) { 310 | this.invalidCmd(cmd, socket); 311 | return; 312 | } 313 | result = await this.tracManager.tapProtocol.getInscribeTransferListLength( 314 | cmd.args[0] 315 | ); 316 | break; 317 | 318 | case "inscribeTransferList": 319 | if (cmd.args.length != 3) { 320 | this.invalidCmd(cmd, socket); 321 | return; 322 | } 323 | result = await this.tracManager.tapProtocol.getInscribeTransferList( 324 | cmd.args[0], 325 | cmd.args[1], 326 | cmd.args[2] 327 | ); 328 | break; 329 | 330 | case "tickerInscribeTransferListLength": 331 | if (cmd.args.length != 2) { 332 | this.invalidCmd(cmd, socket); 333 | return; 334 | } 335 | result = await this.tracManager.tapProtocol.getTickerInscribeTransferListLength( 336 | cmd.args[0], 337 | cmd.args[1] 338 | ); 339 | break; 340 | 341 | case "tickerInscribeTransferList": 342 | if (cmd.args.length != 4) { 343 | this.invalidCmd(cmd, socket); 344 | return; 345 | } 346 | result = await this.tracManager.tapProtocol.getTickerInscribeTransferList( 347 | cmd.args[0], 348 | cmd.args[1], 349 | cmd.args[2], 350 | cmd.args[3] 351 | ); 352 | break; 353 | 354 | case "tickerInscribeTransferListByBlockLength": 355 | if (cmd.args.length != 2) { 356 | this.invalidCmd(cmd, socket); 357 | return; 358 | } 359 | result = await this.tracManager.tapProtocol.getTickerInscribeTransferListByBlockLength( 360 | cmd.args[0], 361 | cmd.args[1] 362 | ); 363 | break; 364 | 365 | case "tickerInscribeTransferListByBlock": 366 | if (cmd.args.length != 4) { 367 | this.invalidCmd(cmd, socket); 368 | return; 369 | } 370 | result = await this.tracManager.tapProtocol.getTickerInscribeTransferListByBlock( 371 | cmd.args[0], 372 | cmd.args[1], 373 | cmd.args[2], 374 | cmd.args[3] 375 | ); 376 | break; 377 | 378 | case "inscribeTransferListByBlockLength": 379 | if (cmd.args.length != 1) { 380 | this.invalidCmd(cmd, socket); 381 | return; 382 | } 383 | result = await this.tracManager.tapProtocol.getInscribeTransferListByBlockLength( 384 | cmd.args[0] 385 | ); 386 | break; 387 | 388 | case "inscribeTransferListByBlock": 389 | if (cmd.args.length != 3) { 390 | this.invalidCmd(cmd, socket); 391 | return; 392 | } 393 | result = await this.tracManager.tapProtocol.getInscribeTransferListByBlock( 394 | cmd.args[0], 395 | cmd.args[1], 396 | cmd.args[2] 397 | ); 398 | break; 399 | 400 | 401 | case "dmtMintHolder": 402 | if (cmd.args.length != 1) { 403 | this.invalidCmd(cmd, socket); 404 | return; 405 | } 406 | result = await this.tracManager.tapProtocol.getDmtMintHolder( 407 | cmd.args[0] 408 | ); 409 | break; 410 | 411 | case "dmtMintHolderByBlock": 412 | if (cmd.args.length != 2) { 413 | this.invalidCmd(cmd, socket); 414 | return; 415 | } 416 | result = await this.tracManager.tapProtocol.getDmtMintHolderByBlock( 417 | cmd.args[0], 418 | cmd.args[1] 419 | ); 420 | break; 421 | 422 | case "reorgs": 423 | if (cmd.args.length != 0) { 424 | this.invalidCmd(cmd, socket); 425 | return; 426 | } 427 | result = 428 | await this.tracManager.tapProtocol.getReorgs(); 429 | break; 430 | 431 | case "currentBlock": 432 | if (cmd.args.length != 0) { 433 | this.invalidCmd(cmd, socket); 434 | return; 435 | } 436 | result = 437 | await this.tracManager.tapProtocol.getCurrentBlock(); 438 | break; 439 | 440 | case "dmtMintHoldersHistoryListLength": 441 | if (cmd.args.length != 1) { 442 | this.invalidCmd(cmd, socket); 443 | return; 444 | } 445 | result = await this.tracManager.tapProtocol.getDmtMintHoldersHistoryListLength( 446 | cmd.args[0] 447 | ); 448 | break; 449 | 450 | case "dmtMintHoldersHistoryList": 451 | if (cmd.args.length != 3) { 452 | this.invalidCmd(cmd, socket); 453 | return; 454 | } 455 | result = await this.tracManager.tapProtocol.getDmtMintHoldersHistoryList( 456 | cmd.args[0], 457 | cmd.args[1], 458 | cmd.args[2] 459 | ); 460 | break; 461 | 462 | case "dmtMintWalletHistoricListLength": 463 | if (cmd.args.length != 1) { 464 | this.invalidCmd(cmd, socket); 465 | return; 466 | } 467 | result = await this.tracManager.tapProtocol.getDmtMintWalletHistoricListLength( 468 | cmd.args[0] 469 | ); 470 | break; 471 | 472 | case "dmtMintWalletHistoricList": 473 | if (cmd.args.length != 3) { 474 | this.invalidCmd(cmd, socket); 475 | return; 476 | } 477 | result = await this.tracManager.tapProtocol.getDmtMintWalletHistoricList( 478 | cmd.args[0], 479 | cmd.args[1], 480 | cmd.args[2] 481 | ); 482 | break; 483 | 484 | 485 | case "deployments": 486 | if (cmd.args.length != 2) { 487 | this.invalidCmd(cmd, socket); 488 | return; 489 | } 490 | result = await this.tracManager.tapProtocol.getDeployments( 491 | cmd.args[0], 492 | cmd.args[1] 493 | ); 494 | break; 495 | case "deployment": 496 | if (cmd.args.length != 1) { 497 | this.invalidCmd(cmd, socket); 498 | return; 499 | } 500 | result = await this.tracManager.tapProtocol.getDeployment( 501 | cmd.args[0] 502 | ); 503 | break; 504 | case "deploymentsLength": 505 | if (cmd.args.length != 0) { 506 | this.invalidCmd(cmd, socket); 507 | return; 508 | } 509 | result = 510 | await this.tracManager.tapProtocol.getDeploymentsLength(); 511 | break; 512 | case "mintTokensLeft": 513 | if (cmd.args.length != 1) { 514 | this.invalidCmd(cmd, socket); 515 | return; 516 | } 517 | result = await this.tracManager.tapProtocol.getMintTokensLeft( 518 | cmd.args[0] 519 | ); 520 | break; 521 | case "balance": 522 | if (cmd.args.length != 2) { 523 | this.invalidCmd(cmd, socket); 524 | return; 525 | } 526 | result = await this.tracManager.tapProtocol.getBalance( 527 | cmd.args[0], 528 | cmd.args[1] 529 | ); 530 | break; 531 | case "transferable": 532 | if (cmd.args.length != 2) { 533 | this.invalidCmd(cmd, socket); 534 | return; 535 | } 536 | result = await this.tracManager.tapProtocol.getTransferable( 537 | cmd.args[0], 538 | cmd.args[1] 539 | ); 540 | break; 541 | case "holdersLength": 542 | if (cmd.args.length != 1) { 543 | this.invalidCmd(cmd, socket); 544 | return; 545 | } 546 | result = await this.tracManager.tapProtocol.getHoldersLength( 547 | cmd.args[0] 548 | ); 549 | break; 550 | case "holders": 551 | if (cmd.args.length != 3) { 552 | this.invalidCmd(cmd, socket); 553 | return; 554 | } 555 | result = await this.tracManager.tapProtocol.getHolders( 556 | cmd.args[0], 557 | cmd.args[1], 558 | cmd.args[2] 559 | ); 560 | break; 561 | case "accountTokensLength": 562 | if (cmd.args.length != 1) { 563 | this.invalidCmd(cmd, socket); 564 | return; 565 | } 566 | result = 567 | await this.tracManager.tapProtocol.getAccountTokensLength( 568 | cmd.args[0] 569 | ); 570 | break; 571 | case "accountTokens": 572 | if (cmd.args.length != 3) { 573 | this.invalidCmd(cmd, socket); 574 | return; 575 | } 576 | result = await this.tracManager.tapProtocol.getAccountTokens( 577 | cmd.args[0], 578 | cmd.args[1], 579 | cmd.args[2] 580 | ); 581 | break; 582 | case "accountMintList": 583 | if (cmd.args.length != 4) { 584 | this.invalidCmd(cmd, socket); 585 | return; 586 | } 587 | result = await this.tracManager.tapProtocol.getAccountMintList( 588 | cmd.args[0], 589 | cmd.args[1], 590 | cmd.args[2], 591 | cmd.args[3] 592 | ); 593 | break; 594 | case "accountMintListLength": 595 | if (cmd.args.length != 2) { 596 | this.invalidCmd(cmd, socket); 597 | return; 598 | } 599 | result = 600 | await this.tracManager.tapProtocol.getAccountMintListLength( 601 | cmd.args[0], 602 | cmd.args[1] 603 | ); 604 | break; 605 | case "tickerMintList": 606 | if (cmd.args.length != 3) { 607 | this.invalidCmd(cmd, socket); 608 | return; 609 | } 610 | result = await this.tracManager.tapProtocol.getTickerMintList( 611 | cmd.args[0], 612 | cmd.args[1], 613 | cmd.args[2] 614 | ); 615 | break; 616 | case "tickerMintListLength": 617 | if (cmd.args.length != 1) { 618 | this.invalidCmd(cmd, socket); 619 | return; 620 | } 621 | result = 622 | await this.tracManager.tapProtocol.getTickerMintListLength( 623 | cmd.args[0] 624 | ); 625 | break; 626 | case "mintList": 627 | if (cmd.args.length != 2) { 628 | this.invalidCmd(cmd, socket); 629 | return; 630 | } 631 | result = await this.tracManager.tapProtocol.getMintList( 632 | cmd.args[0], 633 | cmd.args[1] 634 | ); 635 | break; 636 | case "mintListLength": 637 | if (cmd.args.length != 0) { 638 | this.invalidCmd(cmd, socket); 639 | return; 640 | } 641 | result = await this.tracManager.tapProtocol.getMintListLength(); 642 | break; 643 | case "accountTransferList": 644 | if (cmd.args.length != 4) { 645 | this.invalidCmd(cmd, socket); 646 | return; 647 | } 648 | result = 649 | await this.tracManager.tapProtocol.getAccountTransferList( 650 | cmd.args[0], 651 | cmd.args[1], 652 | cmd.args[2], 653 | cmd.args[3] 654 | ); 655 | break; 656 | case "accountTransferListLength": 657 | if (cmd.args.length != 2) { 658 | this.invalidCmd(cmd, socket); 659 | return; 660 | } 661 | result = 662 | await this.tracManager.tapProtocol.getAccountTransferListLength( 663 | cmd.args[0], 664 | cmd.args[1] 665 | ); 666 | break; 667 | case "tickerTransferList": 668 | if (cmd.args.length != 3) { 669 | this.invalidCmd(cmd, socket); 670 | return; 671 | } 672 | result = await this.tracManager.tapProtocol.getTickerTransferList( 673 | cmd.args[0], 674 | cmd.args[1], 675 | cmd.args[2] 676 | ); 677 | break; 678 | case "tickerTransferListLength": 679 | if (cmd.args.length != 1) { 680 | this.invalidCmd(cmd, socket); 681 | return; 682 | } 683 | result = 684 | await this.tracManager.tapProtocol.getTickerTransferListLength( 685 | cmd.args[0] 686 | ); 687 | break; 688 | case "transferList": 689 | if (cmd.args.length != 2) { 690 | this.invalidCmd(cmd, socket); 691 | return; 692 | } 693 | result = await this.tracManager.tapProtocol.getTransferList( 694 | cmd.args[0], 695 | cmd.args[1] 696 | ); 697 | break; 698 | case "transferListLength": 699 | if (cmd.args.length != 0) { 700 | this.invalidCmd(cmd, socket); 701 | return; 702 | } 703 | result = 704 | await this.tracManager.tapProtocol.getTransferListLength(); 705 | break; 706 | case "accountSentList": 707 | if (cmd.args.length != 4) { 708 | this.invalidCmd(cmd, socket); 709 | return; 710 | } 711 | result = await this.tracManager.tapProtocol.getAccountSentList( 712 | cmd.args[0], 713 | cmd.args[1], 714 | cmd.args[2], 715 | cmd.args[3] 716 | ); 717 | break; 718 | case "accountSentListLength": 719 | if (cmd.args.length != 2) { 720 | this.invalidCmd(cmd, socket); 721 | return; 722 | } 723 | result = 724 | await this.tracManager.tapProtocol.getAccountSentListLength( 725 | cmd.args[0], 726 | cmd.args[1] 727 | ); 728 | break; 729 | case "tickerSentList": 730 | if (cmd.args.length != 3) { 731 | this.invalidCmd(cmd, socket); 732 | return; 733 | } 734 | result = await this.tracManager.tapProtocol.getTickerSentList( 735 | cmd.args[0], 736 | cmd.args[1], 737 | cmd.args[2] 738 | ); 739 | break; 740 | case "tickerSentListLength": 741 | if (cmd.args.length != 1) { 742 | this.invalidCmd(cmd, socket); 743 | return; 744 | } 745 | result = 746 | await this.tracManager.tapProtocol.getTickerSentListLength( 747 | cmd.args[0] 748 | ); 749 | break; 750 | case "sentList": 751 | if (cmd.args.length != 2) { 752 | this.invalidCmd(cmd, socket); 753 | return; 754 | } 755 | result = await this.tracManager.tapProtocol.getSentList( 756 | cmd.args[0], 757 | cmd.args[1] 758 | ); 759 | break; 760 | case "sentListLength": 761 | if (cmd.args.length != 0) { 762 | this.invalidCmd(cmd, socket); 763 | return; 764 | } 765 | result = await this.tracManager.tapProtocol.getSentListLength(); 766 | break; 767 | case "accountReceiveList": 768 | if (cmd.args.length != 4) { 769 | this.invalidCmd(cmd, socket); 770 | return; 771 | } 772 | result = await this.tracManager.tapProtocol.getAccountReceiveList( 773 | cmd.args[0], 774 | cmd.args[1], 775 | cmd.args[2], 776 | cmd.args[3] 777 | ); 778 | break; 779 | case "accountReceiveListLength": 780 | if (cmd.args.length != 2) { 781 | this.invalidCmd(cmd, socket); 782 | return; 783 | } 784 | result = 785 | await this.tracManager.tapProtocol.getAccountReceiveListLength( 786 | cmd.args[0], 787 | cmd.args[1] 788 | ); 789 | break; 790 | case "accumulator": 791 | if (cmd.args.length != 1) { 792 | this.invalidCmd(cmd, socket); 793 | return; 794 | } 795 | result = await this.tracManager.tapProtocol.getAccumulator( 796 | cmd.args[0] 797 | ); 798 | break; 799 | case "accountAccumulatorList": 800 | if (cmd.args.length != 3) { 801 | this.invalidCmd(cmd, socket); 802 | return; 803 | } 804 | result = 805 | await this.tracManager.tapProtocol.getAccountAccumulatorList( 806 | cmd.args[0], 807 | cmd.args[1], 808 | cmd.args[2] 809 | ); 810 | break; 811 | case "accountAccumulatorListLength": 812 | if (cmd.args.length != 1) { 813 | this.invalidCmd(cmd, socket); 814 | return; 815 | } 816 | result = 817 | await this.tracManager.tapProtocol.getAccountAccumulatorListLength( 818 | cmd.args[0] 819 | ); 820 | break; 821 | case "accumulatorList": 822 | if (cmd.args.length != 2) { 823 | this.invalidCmd(cmd, socket); 824 | return; 825 | } 826 | result = await this.tracManager.tapProtocol.getAccumulatorList( 827 | cmd.args[0], 828 | cmd.args[1] 829 | ); 830 | break; 831 | case "getAccumulatorListLength": 832 | if (cmd.args.length != 0) { 833 | this.invalidCmd(cmd, socket); 834 | return; 835 | } 836 | result = 837 | await this.tracManager.tapProtocol.getAccumulatorListLength(); 838 | break; 839 | case "accountTradesList": 840 | if (cmd.args.length != 4) { 841 | this.invalidCmd(cmd, socket); 842 | return; 843 | } 844 | result = await this.tracManager.tapProtocol.getAccountTradesList( 845 | cmd.args[0], 846 | cmd.args[1], 847 | cmd.args[2], 848 | cmd.args[3] 849 | ); 850 | break; 851 | case "accountTradesListLength": 852 | if (cmd.args.length != 2) { 853 | this.invalidCmd(cmd, socket); 854 | return; 855 | } 856 | result = 857 | await this.tracManager.tapProtocol.getAccountTradesListLength( 858 | cmd.args[0], 859 | cmd.args[1] 860 | ); 861 | break; 862 | case "tickerTradesList": 863 | if (cmd.args.length != 3) { 864 | this.invalidCmd(cmd, socket); 865 | return; 866 | } 867 | result = await this.tracManager.tapProtocol.getTickerTradesList( 868 | cmd.args[0], 869 | cmd.args[2], 870 | cmd.args[3] 871 | ); 872 | break; 873 | case "tickerTradesListLength": 874 | if (cmd.args.length != 1) { 875 | this.invalidCmd(cmd, socket); 876 | return; 877 | } 878 | result = 879 | await this.tracManager.tapProtocol.getTickerTradesListLength( 880 | cmd.args[0] 881 | ); 882 | break; 883 | case "tradesList": 884 | if (cmd.args.length != 2) { 885 | this.invalidCmd(cmd, socket); 886 | return; 887 | } 888 | result = await this.tracManager.tapProtocol.getTradesList( 889 | cmd.args[0], 890 | cmd.args[1] 891 | ); 892 | break; 893 | case "tradesListLength": 894 | if (cmd.args.length != 0) { 895 | this.invalidCmd(cmd, socket); 896 | return; 897 | } 898 | result = await this.tracManager.tapProtocol.getTradesListLength(); 899 | break; 900 | case "accountReceiveTradesFilledList": 901 | if (cmd.args.length != 4) { 902 | this.invalidCmd(cmd, socket); 903 | return; 904 | } 905 | result = 906 | await this.tracManager.tapProtocol.getAccountReceiveTradesFilledList( 907 | cmd.args[0], 908 | cmd.args[1], 909 | cmd.args[2], 910 | cmd.args[3] 911 | ); 912 | break; 913 | case "accountReceiveTradesFilledListLength": 914 | if (cmd.args.length != 2) { 915 | this.invalidCmd(cmd, socket); 916 | return; 917 | } 918 | result = 919 | await this.tracManager.tapProtocol.getAccountReceiveTradesFilledListLength( 920 | cmd.args[0], 921 | cmd.args[1] 922 | ); 923 | break; 924 | case "accountTradesFilledList": 925 | if (cmd.args.length != 4) { 926 | this.invalidCmd(cmd, socket); 927 | return; 928 | } 929 | result = 930 | await this.tracManager.tapProtocol.getAccountTradesFilledList( 931 | cmd.args[0], 932 | cmd.args[1], 933 | cmd.args[2], 934 | cmd.args[3] 935 | ); 936 | break; 937 | case "accountTradesFilledListLength": 938 | if (cmd.args.length != 2) { 939 | this.invalidCmd(cmd, socket); 940 | return; 941 | } 942 | result = 943 | await this.tracManager.tapProtocol.getAccountTradesFilledListLength( 944 | cmd.args[0], 945 | cmd.args[1] 946 | ); 947 | break; 948 | case "tickerTradesFilledList": 949 | if (cmd.args.length != 3) { 950 | this.invalidCmd(cmd, socket); 951 | return; 952 | } 953 | result = 954 | await this.tracManager.tapProtocol.getTickerTradesFilledList( 955 | cmd.args[0], 956 | cmd.args[2], 957 | cmd.args[3] 958 | ); 959 | break; 960 | case "tickerTradesFilledListLength": 961 | if (cmd.args.length != 1) { 962 | this.invalidCmd(cmd, socket); 963 | return; 964 | } 965 | result = 966 | await this.tracManager.tapProtocol.getTickerTradesFilledListLength( 967 | cmd.args[0] 968 | ); 969 | break; 970 | case "tradesFilledList": 971 | if (cmd.args.length != 2) { 972 | this.invalidCmd(cmd, socket); 973 | return; 974 | } 975 | result = await this.tracManager.tapProtocol.getTradesFilledList( 976 | cmd.args[0], 977 | cmd.args[1] 978 | ); 979 | break; 980 | case "tradesFilledListLength": 981 | if (cmd.args.length != 0) { 982 | this.invalidCmd(cmd, socket); 983 | return; 984 | } 985 | result = 986 | await this.tracManager.tapProtocol.getTradesFilledListLength(); 987 | break; 988 | case "trade": 989 | if (cmd.args.length != 1) { 990 | this.invalidCmd(cmd, socket); 991 | return; 992 | } 993 | result = await this.tracManager.tapProtocol.getTrade(cmd.args[0]); 994 | break; 995 | case "privilegeAuthIsVerified": 996 | if (cmd.args.length != 4) { 997 | this.invalidCmd(cmd, socket); 998 | return; 999 | } 1000 | result = 1001 | await this.tracManager.tapProtocol.getPrivilegeAuthIsVerified( 1002 | cmd.args[0], 1003 | cmd.args[1], 1004 | cmd.args[2], 1005 | cmd.args[3] 1006 | ); 1007 | break; 1008 | case "privilegeAuthorityListLength": 1009 | if (cmd.args.length != 1) { 1010 | this.invalidCmd(cmd, socket); 1011 | return; 1012 | } 1013 | result = 1014 | await this.tracManager.tapProtocol.getPrivilegeAuthorityListLength( 1015 | cmd.args[0] 1016 | ); 1017 | break; 1018 | case "privilegeAuthorityList": 1019 | if (cmd.args.length != 3) { 1020 | this.invalidCmd(cmd, socket); 1021 | return; 1022 | } 1023 | result = await this.tracManager.tapProtocol.getPrivilegeAuthorityList( 1024 | cmd.args[0], 1025 | cmd.args[1], 1026 | cmd.args[2] 1027 | ); 1028 | break; 1029 | case "privilegeAuthorityCollectionListLength": 1030 | if (cmd.args.length != 2) { 1031 | this.invalidCmd(cmd, socket); 1032 | return; 1033 | } 1034 | result = 1035 | await this.tracManager.tapProtocol.getPrivilegeAuthorityCollectionListLength( 1036 | cmd.args[0], 1037 | cmd.args[1] 1038 | ); 1039 | break; 1040 | case "privilegeAuthorityCollectionList": 1041 | if (cmd.args.length != 3) { 1042 | this.invalidCmd(cmd, socket); 1043 | return; 1044 | } 1045 | result = await this.tracManager.tapProtocol.getPrivilegeAuthorityCollectionList( 1046 | cmd.args[0], 1047 | cmd.args[1], 1048 | cmd.args[2], 1049 | cmd.args[3] 1050 | ); 1051 | break; 1052 | case "accountAuthList": 1053 | if (cmd.args.length != 3) { 1054 | this.invalidCmd(cmd, socket); 1055 | return; 1056 | } 1057 | result = await this.tracManager.tapProtocol.getAccountAuthList( 1058 | cmd.args[0], 1059 | cmd.args[1], 1060 | cmd.args[2] 1061 | ); 1062 | break; 1063 | case "accountPrivilegeAuthList": 1064 | if (cmd.args.length != 3) { 1065 | this.invalidCmd(cmd, socket); 1066 | return; 1067 | } 1068 | result = await this.tracManager.tapProtocol.getAccountPrivilegeAuthList( 1069 | cmd.args[0], 1070 | cmd.args[1], 1071 | cmd.args[2] 1072 | ); 1073 | break; 1074 | case "accountAuthListLength": 1075 | if (cmd.args.length != 1) { 1076 | this.invalidCmd(cmd, socket); 1077 | return; 1078 | } 1079 | result = 1080 | await this.tracManager.tapProtocol.getAccountAuthListLength( 1081 | cmd.args[0] 1082 | ); 1083 | break; 1084 | case "accountPrivilegeAuthListLength": 1085 | if (cmd.args.length != 1) { 1086 | this.invalidCmd(cmd, socket); 1087 | return; 1088 | } 1089 | result = 1090 | await this.tracManager.tapProtocol.getAccountPrivilegeAuthListLength( 1091 | cmd.args[0] 1092 | ); 1093 | break; 1094 | case "authList": 1095 | if (cmd.args.length != 2) { 1096 | this.invalidCmd(cmd, socket); 1097 | return; 1098 | } 1099 | result = await this.tracManager.tapProtocol.getAuthList( 1100 | cmd.args[0], 1101 | cmd.args[1] 1102 | ); 1103 | break; 1104 | case "privilegeAuthList": 1105 | if (cmd.args.length != 2) { 1106 | this.invalidCmd(cmd, socket); 1107 | return; 1108 | } 1109 | result = await this.tracManager.tapProtocol.getPrivilegeAuthList( 1110 | cmd.args[0], 1111 | cmd.args[1] 1112 | ); 1113 | break; 1114 | case "authListLength": 1115 | if (cmd.args.length != 0) { 1116 | this.invalidCmd(cmd, socket); 1117 | return; 1118 | } 1119 | result = await this.tracManager.tapProtocol.getAuthListLength(); 1120 | break; 1121 | case "privilegeAuthListLength": 1122 | if (cmd.args.length != 0) { 1123 | this.invalidCmd(cmd, socket); 1124 | return; 1125 | } 1126 | result = await this.tracManager.tapProtocol.getPrivilegeAuthListLength(); 1127 | break; 1128 | case "accountRedeemList": 1129 | if (cmd.args.length != 3) { 1130 | this.invalidCmd(cmd, socket); 1131 | return; 1132 | } 1133 | result = await this.tracManager.tapProtocol.getAccountRedeemList( 1134 | cmd.args[0], 1135 | cmd.args[1], 1136 | cmd.args[2] 1137 | ); 1138 | break; 1139 | case "accountRedeemListLength": 1140 | if (cmd.args.length != 1) { 1141 | this.invalidCmd(cmd, socket); 1142 | return; 1143 | } 1144 | result = 1145 | await this.tracManager.tapProtocol.getAccountRedeemListLength( 1146 | cmd.args[0] 1147 | ); 1148 | break; 1149 | case "redeemList": 1150 | if (cmd.args.length != 2) { 1151 | this.invalidCmd(cmd, socket); 1152 | return; 1153 | } 1154 | result = await this.tracManager.tapProtocol.getRedeemList( 1155 | cmd.args[0], 1156 | cmd.args[1] 1157 | ); 1158 | break; 1159 | case "redeemListLength": 1160 | if (cmd.args.length != 0) { 1161 | this.invalidCmd(cmd, socket); 1162 | return; 1163 | } 1164 | result = await this.tracManager.tapProtocol.getRedeemListLength(); 1165 | break; 1166 | case "authHashExists": 1167 | if (cmd.args.length != 1) { 1168 | this.invalidCmd(cmd, socket); 1169 | return; 1170 | } 1171 | result = await this.tracManager.tapProtocol.getAuthHashExists( 1172 | cmd.args[0] 1173 | ); 1174 | break; 1175 | case "privilegeAuthHashExists": 1176 | if (cmd.args.length != 1) { 1177 | this.invalidCmd(cmd, socket); 1178 | return; 1179 | } 1180 | result = await this.tracManager.tapProtocol.getPrivilegeAuthHashExists( 1181 | cmd.args[0] 1182 | ); 1183 | break; 1184 | case "authCancelled": 1185 | if (cmd.args.length != 1) { 1186 | this.invalidCmd(cmd, socket); 1187 | return; 1188 | } 1189 | result = await this.tracManager.tapProtocol.getAuthCancelled( 1190 | cmd.args[0] 1191 | ); 1192 | break; 1193 | case "privilegeAuthCancelled": 1194 | if (cmd.args.length != 1) { 1195 | this.invalidCmd(cmd, socket); 1196 | return; 1197 | } 1198 | result = await this.tracManager.tapProtocol.getPrivilegeAuthCancelled( 1199 | cmd.args[0] 1200 | ); 1201 | break; 1202 | case "dmtElementsList": 1203 | if (cmd.args.length != 2) { 1204 | this.invalidCmd(cmd, socket); 1205 | return; 1206 | } 1207 | result = await this.tracManager.tapProtocol.getDmtElementsList( 1208 | cmd.args[0], 1209 | cmd.args[1] 1210 | ); 1211 | break; 1212 | case "dmtElementsListLength": 1213 | if (cmd.args.length != 0) { 1214 | this.invalidCmd(cmd, socket); 1215 | return; 1216 | } 1217 | result = 1218 | await this.tracManager.tapProtocol.getDmtElementsListLength(); 1219 | break; 1220 | case "transferAmountByInscription": 1221 | if (cmd.args.length != 1) { 1222 | this.invalidCmd(cmd, socket); 1223 | return; 1224 | } 1225 | result = 1226 | await this.tracManager.tapProtocol.getTransferAmountByInscription( 1227 | cmd.args[0] 1228 | ); 1229 | break; 1230 | } 1231 | } catch (e) { 1232 | // if this happened, then something really bad happened 1233 | console.log(e); 1234 | this.invalidCmd(cmd, socket); 1235 | return; 1236 | } 1237 | 1238 | const response = { 1239 | error: "", 1240 | func: cmd.func, 1241 | args: cmd.args, 1242 | call_id: cmd.call_id, 1243 | result: result, 1244 | }; 1245 | 1246 | this.io.to(socket.id).emit("response", { 1247 | error: "", 1248 | func: cmd.func, 1249 | args: cmd.args, 1250 | call_id: cmd.call_id, 1251 | result: result, 1252 | }); 1253 | 1254 | console.log("Served response", response); 1255 | }); 1256 | }); 1257 | } 1258 | /** 1259 | * Handles an invalid command by emitting an error to the socket. 1260 | * @param {Object} cmd - The invalid command object. 1261 | * @param {Socket} socket - The WebSocket socket object. 1262 | */ 1263 | invalidCmd(cmd, socket) { 1264 | this.io.to(socket.id).emit("error", { error: "invalid command", cmd: cmd }); 1265 | } 1266 | /** 1267 | * Validates if a given command is valid. 1268 | * @param {Object} cmd - The command object to validate. 1269 | * @param {Socket} socket - The WebSocket socket object. 1270 | * @returns {boolean} - True if the command is valid, false otherwise. 1271 | */ 1272 | validCmd(cmd, socket) { 1273 | if ( 1274 | typeof cmd.call_id == "undefined" || 1275 | typeof cmd.func == "undefined" || 1276 | typeof cmd.args == "undefined" || 1277 | !Array.isArray(cmd.args) 1278 | ) { 1279 | this.invalidCmd(cmd, socket); 1280 | return false; 1281 | } 1282 | 1283 | return true; 1284 | } 1285 | } 1286 | -------------------------------------------------------------------------------- /src/main.mjs: -------------------------------------------------------------------------------- 1 | import TracManager from "./TracManager.mjs"; 2 | 3 | let tracCore = new TracManager(); 4 | await tracCore.initReader(); 5 | 6 | // example call if used without rest or websockets 7 | //console.log( await tracCore.tapProtocol.getHolders( 'dmt-nat', 111, 111) ); -------------------------------------------------------------------------------- /test/restmodule.test.js: -------------------------------------------------------------------------------- 1 | import TracManager from "../src/TracManager"; 2 | import {jest} from '@jest/globals'; 3 | 4 | jest.describe("RestModule Integration Tests", () => { 5 | let tracCore; 6 | let server; 7 | 8 | // Setup before all tests 9 | jest.beforeAll(async () => { 10 | tracCore = new TracManager(); 11 | await tracCore.initReader(true, true, -1, -1); 12 | await tracCore.restServer.fastify.ready(); 13 | }); 14 | 15 | // Teardown after all tests 16 | jest.afterAll(async () => { 17 | await server.close(); 18 | }); 19 | 20 | // Test for /getDeployments/ route 21 | jest.describe("/getDeployments/ route", () => { 22 | jest.it("should return data with the correct structure", async () => { 23 | const response = await tracCore.restServer.fastify.inject({ 24 | method: "GET", 25 | url: "/getDeployments/", 26 | }); 27 | 28 | jest.expect(response.statusCode).toBe(200); 29 | const jsonResponse = response.json(); 30 | 31 | // Checking the overall structure 32 | jest.expect(jsonResponse).toEqual( 33 | jest.expect.objectContaining({ 34 | result: jest.expect.any(Array), 35 | }) 36 | ); 37 | 38 | // Checking the structure of each item in the result array 39 | jsonResponse.result.forEach((item) => { 40 | jest.expect(item).toEqual( 41 | jest.expect.objectContaining({ 42 | tick: jest.expect.any(String), 43 | max: jest.expect.any(String), 44 | lim: jest.expect.any(String), 45 | dec: jest.expect.any(Number), 46 | blck: jest.expect.any(Number), 47 | tx: jest.expect.any(String), 48 | ins: jest.expect.any(String), 49 | num: jest.expect.any(Number), 50 | ts: jest.expect.any(Number), 51 | addr: jest.expect.any(String), 52 | crsd: jest.expect.any(Boolean), 53 | dmt: jest.expect.any(Boolean), 54 | elem: jest.expect.anything(), // can be null or any value 55 | prj: jest.expect.anything(), // can be null or any value 56 | dim: jest.expect.anything(), // can be null or any value 57 | dt: jest.expect.anything(), // can be null or any value 58 | }) 59 | ); 60 | }); 61 | }); 62 | }); 63 | 64 | // Additional tests for other routes and scenarios 65 | }); 66 | --------------------------------------------------------------------------------