@ocap/indexdb-memory 1.30.9 → 1.30.11

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/esm/db/base.mjs CHANGED
@@ -125,15 +125,6 @@ var LocalBaseIndexDB = class extends BaseIndexDB {
125
125
  }
126
126
  async listAssets(params = {}) {
127
127
  const { ownerAddress, factoryAddress, paging, timeFilter = {} } = params;
128
- if (!ownerAddress && !factoryAddress) return {
129
- assets: [],
130
- account: null,
131
- paging: {
132
- cursor: "0",
133
- next: false,
134
- total: 0
135
- }
136
- };
137
128
  const pagination = formatPagination({
138
129
  paging,
139
130
  defaultSortField: "renaissanceTime"
@@ -178,7 +169,7 @@ var LocalBaseIndexDB = class extends BaseIndexDB {
178
169
  const query = getCollection(this.account).chain();
179
170
  const pagination = formatPagination({
180
171
  paging,
181
- defaultSortField: "balance",
172
+ defaultSortField: tokenAddress ? "balance" : "renaissanceTime",
182
173
  supportedSortFields: [
183
174
  "genesisTime",
184
175
  "renaissanceTime",
@@ -186,6 +177,7 @@ var LocalBaseIndexDB = class extends BaseIndexDB {
186
177
  "moniker"
187
178
  ]
188
179
  });
180
+ if (pagination.order.field === "balance" && !tokenAddress) throw new Error("tokenAddress is required when order.field is balance");
189
181
  debug("listTopAccounts", {
190
182
  tokenAddress,
191
183
  paging,
@@ -418,14 +410,6 @@ var LocalBaseIndexDB = class extends BaseIndexDB {
418
410
  }
419
411
  listDelegations(params = {}) {
420
412
  const { from, to, paging = {}, timeFilter = {} } = params;
421
- if (!from && !to) return {
422
- delegations: [],
423
- paging: {
424
- cursor: "0",
425
- next: false,
426
- total: 0
427
- }
428
- };
429
413
  const query = getCollection(this.delegation).chain();
430
414
  const pagination = formatPagination({
431
415
  paging,
package/lib/db/base.cjs CHANGED
@@ -129,15 +129,6 @@ var LocalBaseIndexDB = class extends _ocap_indexdb.BaseIndexDB {
129
129
  }
130
130
  async listAssets(params = {}) {
131
131
  const { ownerAddress, factoryAddress, paging, timeFilter = {} } = params;
132
- if (!ownerAddress && !factoryAddress) return {
133
- assets: [],
134
- account: null,
135
- paging: {
136
- cursor: "0",
137
- next: false,
138
- total: 0
139
- }
140
- };
141
132
  const pagination = (0, _ocap_indexdb.formatPagination)({
142
133
  paging,
143
134
  defaultSortField: "renaissanceTime"
@@ -182,7 +173,7 @@ var LocalBaseIndexDB = class extends _ocap_indexdb.BaseIndexDB {
182
173
  const query = getCollection(this.account).chain();
183
174
  const pagination = (0, _ocap_indexdb.formatPagination)({
184
175
  paging,
185
- defaultSortField: "balance",
176
+ defaultSortField: tokenAddress ? "balance" : "renaissanceTime",
186
177
  supportedSortFields: [
187
178
  "genesisTime",
188
179
  "renaissanceTime",
@@ -190,6 +181,7 @@ var LocalBaseIndexDB = class extends _ocap_indexdb.BaseIndexDB {
190
181
  "moniker"
191
182
  ]
192
183
  });
184
+ if (pagination.order.field === "balance" && !tokenAddress) throw new Error("tokenAddress is required when order.field is balance");
193
185
  debug$1("listTopAccounts", {
194
186
  tokenAddress,
195
187
  paging,
@@ -422,14 +414,6 @@ var LocalBaseIndexDB = class extends _ocap_indexdb.BaseIndexDB {
422
414
  }
423
415
  listDelegations(params = {}) {
424
416
  const { from, to, paging = {}, timeFilter = {} } = params;
425
- if (!from && !to) return {
426
- delegations: [],
427
- paging: {
428
- cursor: "0",
429
- next: false,
430
- total: 0
431
- }
432
- };
433
417
  const query = getCollection(this.delegation).chain();
434
418
  const pagination = (0, _ocap_indexdb.formatPagination)({
435
419
  paging,
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.30.9",
4
+ "version": "1.30.11",
5
5
  "type": "module",
6
6
  "author": "wangshijun <shijun@arcblock.io> (https://www.arcblock.io)",
7
7
  "bugs": {
@@ -78,10 +78,10 @@
78
78
  },
79
79
  "gitHead": "87990c8b5e215107fc587c1ced0d6b3e2cd2483e",
80
80
  "dependencies": {
81
- "@arcblock/did": "1.30.9",
82
- "@ocap/indexdb": "1.30.9",
83
- "@ocap/types": "1.30.9",
84
- "@ocap/util": "1.30.9",
81
+ "@arcblock/did": "1.30.11",
82
+ "@ocap/indexdb": "1.30.11",
83
+ "@ocap/types": "1.30.11",
84
+ "@ocap/util": "1.30.11",
85
85
  "debug": "^4.4.3",
86
86
  "lodash": "^4.17.23",
87
87
  "lokijs": "^1.5.12"