@ocap/indexdb-memory 1.18.67 → 1.18.69
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 +20 -1
- package/package.json +5 -5
package/lib/db/base.js
CHANGED
|
@@ -134,6 +134,22 @@ class LocalBaseIndexDB extends BaseIndexDB {
|
|
|
134
134
|
return { transactions, paging: nextPaging };
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
async getRelatedAddresses(address) {
|
|
138
|
+
let account = await this.account.get(address);
|
|
139
|
+
if (!account) {
|
|
140
|
+
return [];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const related = [address];
|
|
144
|
+
while (account && account.migratedFrom && related.length <= 8) {
|
|
145
|
+
related.push(account.migratedFrom);
|
|
146
|
+
// eslint-disable-next-line no-await-in-loop
|
|
147
|
+
account = await this.account.get(account.migratedFrom);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return related;
|
|
151
|
+
}
|
|
152
|
+
|
|
137
153
|
async listAssets({ ownerAddress, factoryAddress, paging, timeFilter = {} } = {}) {
|
|
138
154
|
if (!ownerAddress && !factoryAddress) {
|
|
139
155
|
return { assets: [], account: null };
|
|
@@ -152,7 +168,10 @@ class LocalBaseIndexDB extends BaseIndexDB {
|
|
|
152
168
|
|
|
153
169
|
const query = this.asset.collection.chain();
|
|
154
170
|
if (ownerAddress) {
|
|
155
|
-
|
|
171
|
+
const possibleOwners = await this.getRelatedAddresses(ownerAddress);
|
|
172
|
+
if (possibleOwners.length) {
|
|
173
|
+
query.where((x) => possibleOwners.includes(x.owner));
|
|
174
|
+
}
|
|
156
175
|
}
|
|
157
176
|
if (factoryAddress) {
|
|
158
177
|
query.where((x) => x.parent === factoryAddress);
|
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.18.
|
|
4
|
+
"version": "1.18.69",
|
|
5
5
|
"author": "wangshijun <shijun@arcblock.io> (https://www.arcblock.io)",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/ArcBlock/asset-chain/issues",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"test": "jest --forceExit --detectOpenHandles",
|
|
38
38
|
"coverage": "npm run test -- --coverage"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "464d72d0a7107cb6f81afa78b74361018ecdc2e4",
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@arcblock/did": "1.18.
|
|
43
|
-
"@ocap/indexdb": "1.18.
|
|
44
|
-
"@ocap/util": "1.18.
|
|
42
|
+
"@arcblock/did": "1.18.69",
|
|
43
|
+
"@ocap/indexdb": "1.18.69",
|
|
44
|
+
"@ocap/util": "1.18.69",
|
|
45
45
|
"debug": "^4.3.4",
|
|
46
46
|
"empty-value": "^1.0.1",
|
|
47
47
|
"lodash": "^4.17.21",
|