@ocap/indexdb-memory 1.21.3 → 1.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/db/base.js +43 -0
- package/lib/db/index.js +1 -0
- package/package.json +5 -5
package/lib/db/base.js
CHANGED
@@ -26,6 +26,7 @@ class LocalBaseIndexDB extends BaseIndexDB {
|
|
26
26
|
rollupFilter = {},
|
27
27
|
stakeFilter = {},
|
28
28
|
delegationFilter = {},
|
29
|
+
tokenFactoryFilter = {},
|
29
30
|
} = {}) {
|
30
31
|
const query = this.tx.collection.chain();
|
31
32
|
|
@@ -39,6 +40,8 @@ class LocalBaseIndexDB extends BaseIndexDB {
|
|
39
40
|
const { rollups = [] } = rollupFilter;
|
40
41
|
const { stakes = [] } = stakeFilter;
|
41
42
|
const { delegations = [] } = delegationFilter;
|
43
|
+
const { tokenFactories = [] } = tokenFactoryFilter;
|
44
|
+
|
42
45
|
let { startDateTime, endDateTime } = timeFilter;
|
43
46
|
startDateTime = parseDateTime(startDateTime);
|
44
47
|
endDateTime = parseDateTime(endDateTime);
|
@@ -106,6 +109,10 @@ class LocalBaseIndexDB extends BaseIndexDB {
|
|
106
109
|
query.where((x) => x.accounts.some((f) => accounts.includes(f)));
|
107
110
|
}
|
108
111
|
|
112
|
+
if (tokenFactories.length) {
|
113
|
+
query.where((x) => x.tokenFactories.some((f) => tokenFactories.includes(f)));
|
114
|
+
}
|
115
|
+
|
109
116
|
if (startDateTime && endDateTime) {
|
110
117
|
query.where((x) => x.time > startDateTime && x.time <= endDateTime);
|
111
118
|
} else if (startDateTime) {
|
@@ -303,6 +310,42 @@ class LocalBaseIndexDB extends BaseIndexDB {
|
|
303
310
|
return { tokens, paging: formatNextPagination(total, pagination) };
|
304
311
|
}
|
305
312
|
|
313
|
+
async listTokenFactories({ owner, reserveAddress, tokenAddress, paging } = {}) {
|
314
|
+
const conditions = {};
|
315
|
+
|
316
|
+
if (owner) {
|
317
|
+
conditions.owner = owner;
|
318
|
+
}
|
319
|
+
|
320
|
+
if (reserveAddress) {
|
321
|
+
conditions.reserveAddress = reserveAddress;
|
322
|
+
}
|
323
|
+
|
324
|
+
if (tokenAddress) {
|
325
|
+
conditions.tokenAddress = tokenAddress;
|
326
|
+
}
|
327
|
+
|
328
|
+
const pagination = formatPagination({
|
329
|
+
paging,
|
330
|
+
defaultSortField: 'renaissanceTime',
|
331
|
+
supportedSortFields: ['genesisTime', 'renaissanceTime', 'reserveBalance', 'currentSupply'],
|
332
|
+
});
|
333
|
+
|
334
|
+
debug('listTokenFactories', { owner, reserveAddress, tokenAddress, paging, conditions, pagination });
|
335
|
+
|
336
|
+
const tokenFactories = this.tokenFactory.collection
|
337
|
+
.chain()
|
338
|
+
.find(conditions)
|
339
|
+
.simplesort(pagination.order.field, pagination.order.type === 'desc')
|
340
|
+
.offset(pagination.cursor)
|
341
|
+
.limit(pagination.size)
|
342
|
+
.data();
|
343
|
+
|
344
|
+
const total = this.tokenFactory.count(Object.keys(conditions).length ? conditions : undefined);
|
345
|
+
|
346
|
+
return { tokenFactories, paging: formatNextPagination(total, pagination) };
|
347
|
+
}
|
348
|
+
|
306
349
|
async listFactories({ ownerAddress, addressList, paging } = {}) {
|
307
350
|
const conditions = {};
|
308
351
|
if (ownerAddress) {
|
package/lib/db/index.js
CHANGED
@@ -27,6 +27,7 @@ class MemoryIndexDB extends BaseIndexDB {
|
|
27
27
|
this.rollupValidator = new Table('rollupValidator', 'address');
|
28
28
|
this.tokenDistribution = new Table('tokenDistribution', 'tokenAddress');
|
29
29
|
this.balance = new Table('balance', ['address', 'tokenAddress']);
|
30
|
+
this.tokenFactory = new Table('tokenFactory', 'address');
|
30
31
|
|
31
32
|
this.attachReadyListeners();
|
32
33
|
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ocap/indexdb-memory",
|
3
3
|
"description": "OCAP indexdb adapter that uses memory as backend, just for test purpose",
|
4
|
-
"version": "1.
|
4
|
+
"version": "1.22.1",
|
5
5
|
"author": "wangshijun <shijun@arcblock.io> (https://www.arcblock.io)",
|
6
6
|
"bugs": {
|
7
7
|
"url": "https://github.com/ArcBlock/blockchain/issues",
|
@@ -15,7 +15,7 @@
|
|
15
15
|
],
|
16
16
|
"devDependencies": {
|
17
17
|
"jest": "^29.7.0",
|
18
|
-
"@ocap/indexdb-test": "1.
|
18
|
+
"@ocap/indexdb-test": "1.22.1"
|
19
19
|
},
|
20
20
|
"homepage": "https://github.com/ArcBlock/blockchain/tree/master/indexdb/memory",
|
21
21
|
"keywords": [
|
@@ -38,9 +38,9 @@
|
|
38
38
|
"empty-value": "^1.0.1",
|
39
39
|
"lodash": "^4.17.21",
|
40
40
|
"lokijs": "^1.5.12",
|
41
|
-
"@arcblock/did": "1.
|
42
|
-
"@ocap/indexdb": "1.
|
43
|
-
"@ocap/util": "1.
|
41
|
+
"@arcblock/did": "1.22.1",
|
42
|
+
"@ocap/indexdb": "1.22.1",
|
43
|
+
"@ocap/util": "1.22.1"
|
44
44
|
},
|
45
45
|
"scripts": {
|
46
46
|
"lint": "eslint tests lib",
|