@ocap/indexdb 1.28.6 → 1.28.8

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/README.md CHANGED
@@ -9,7 +9,7 @@ Defines the abstract interface of OCAP IndexDB, must be implemented with an actu
9
9
  ## Usage
10
10
 
11
11
  ```shell
12
- pnpm install @ocap/statedb-memory
12
+ bun install @ocap/statedb-memory
13
13
  ```
14
14
 
15
15
  Then:
package/lib/db.js CHANGED
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-unused-vars */
2
1
  const { Ready } = require('@ocap/util/lib/ready');
3
2
  const { indexes } = require('@ocap/state');
4
3
 
@@ -6,7 +5,7 @@ class BaseIndexDB extends Ready {
6
5
  constructor() {
7
6
  super();
8
7
 
9
- this.readyMarks = indexes.reduce((acc, x) => ({ ...acc, [x]: false }), {});
8
+ this.readyMarks = Object.fromEntries(indexes.map((x) => [x, false]));
10
9
  this.readyListenersAttached = false;
11
10
  }
12
11
 
@@ -26,27 +25,27 @@ class BaseIndexDB extends Ready {
26
25
  this.readyListenersAttached = true;
27
26
  }
28
27
 
29
- listTransactions({ addressFilter = {}, paging = {}, timeFilter = {}, typeFilter = {} } = {}) {
28
+ listTransactions({ _addressFilter = {}, _paging = {}, _timeFilter = {}, _typeFilter = {} } = {}) {
30
29
  throw new Error('listTransactions should be implemented in adapter');
31
30
  }
32
31
 
33
- listAssets({ ownerAddress, paging } = {}) {
32
+ listAssets({ _ownerAddress, _paging } = {}) {
34
33
  throw new Error('listAssets should be implemented in adapter');
35
34
  }
36
35
 
37
- listFactories({ ownerAddress, paging } = {}) {
36
+ listFactories({ _ownerAddress, _paging } = {}) {
38
37
  throw new Error('listFactories should be implemented in adapter');
39
38
  }
40
39
 
41
- listTopAccounts({ paging, tokenAddress } = {}) {
40
+ listTopAccounts({ _paging, _tokenAddress } = {}) {
42
41
  throw new Error('listTopAccounts should be implemented in adapter');
43
42
  }
44
43
 
45
- listTokens({ paging } = {}) {
44
+ listTokens({ _paging } = {}) {
46
45
  throw new Error('listTokens should be implemented in adapter');
47
46
  }
48
47
 
49
- listStakes({ paging = {}, addressFilter = {}, timeFilter = {}, assetFilter = {} } = {}) {
48
+ listStakes({ _paging = {}, _addressFilter = {}, _timeFilter = {}, _assetFilter = {} } = {}) {
50
49
  throw new Error('listStakes should be implemented in adapter');
51
50
  }
52
51
 
@@ -54,7 +53,7 @@ class BaseIndexDB extends Ready {
54
53
  return [];
55
54
  }
56
55
 
57
- listDelegations({ from, to, paging = {}, timeFilter = {} } = {}) {
56
+ listDelegations({ _from, _to, _paging = {}, _timeFilter = {} } = {}) {
58
57
  throw new Error('listDelegations should be implemented in adapter');
59
58
  }
60
59
  }
package/lib/index.js CHANGED
@@ -1,5 +1,4 @@
1
- /* eslint-disable no-underscore-dangle */
2
- const crypto = require('crypto');
1
+ const crypto = require('node:crypto');
3
2
  const Kareem = require('kareem');
4
3
  const omit = require('lodash/omit');
5
4
  const { Ready } = require('@ocap/util/lib/ready');
@@ -40,23 +39,19 @@ class BaseIndex extends Ready {
40
39
  throw new Error('`count` must be implemented in sub indexdb');
41
40
  }
42
41
 
43
- // eslint-disable-next-line no-unused-vars
44
- _insert(attrs, context) {
42
+ _insert(_attrs, _context) {
45
43
  throw new Error('`_insert` must be implemented in sub indexdb');
46
44
  }
47
45
 
48
- // eslint-disable-next-line no-unused-vars
49
- _get(id, context) {
46
+ _get(_id, _context) {
50
47
  throw new Error('`_get` must be implemented in sub indexdb');
51
48
  }
52
49
 
53
- // eslint-disable-next-line no-unused-vars
54
- _update(id, updates, context) {
50
+ _update(_id, _updates, _context) {
55
51
  throw new Error('`_update` must be implemented in sub indexdb');
56
52
  }
57
53
 
58
- // eslint-disable-next-line no-unused-vars
59
- _reset(context) {
54
+ _reset(_context) {
60
55
  throw new Error('`_reset` must be implemented in sub indexdb');
61
56
  }
62
57
 
package/lib/util.js CHANGED
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-restricted-globals */
2
1
  const get = require('lodash/get');
3
2
  const uniq = require('lodash/uniq');
4
3
  const pick = require('lodash/pick');
@@ -39,7 +38,7 @@ const createIndexedAccount = async (x, getTokenFn) => {
39
38
  renaissanceTime: x.context.renaissanceTime,
40
39
  tokens: Object.keys(x.tokens || {}).map((address) =>
41
40
  formatTokenMeta({ address, balance: x.tokens[address] }, tokenStates)
42
- ), // eslint-disable-line function-paren-newline
41
+ ),
43
42
  genesisTime: x.context.genesisTime,
44
43
  migratedTo: x.migratedTo[0] || '',
45
44
  migratedFrom: x.migratedFrom[0] || '',
@@ -159,7 +158,7 @@ const createIndexedFactory = (factory, context) => {
159
158
  ]),
160
159
  tokens: Object.keys(factory.tokens || {}).map((address) =>
161
160
  formatTokenMeta({ address, balance: factory.tokens[address] }, context.tokenStates)
162
- ), // eslint-disable-line function-paren-newline
161
+ ),
163
162
  genesisTime: factory.context.genesisTime,
164
163
  renaissanceTime: factory.context.renaissanceTime,
165
164
  };
@@ -486,7 +485,7 @@ const parseDateTime = (str) => {
486
485
  }
487
486
 
488
487
  const parsed = Date.parse(str);
489
- if (isNaN(parsed)) {
488
+ if (Number.isNaN(parsed)) {
490
489
  return '';
491
490
  }
492
491
 
package/package.json CHANGED
@@ -3,31 +3,29 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.28.6",
6
+ "version": "1.28.8",
7
7
  "description": "Defines the basic interface for OCAP IndexDB",
8
8
  "main": "lib/main.js",
9
9
  "files": [
10
10
  "lib"
11
11
  ],
12
+ "scripts": {
13
+ "lint": "biome check",
14
+ "lint:fix": "biome check --write",
15
+ "test": "bun test",
16
+ "coverage": "npm run test -- --coverage"
17
+ },
12
18
  "keywords": [],
13
19
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
14
20
  "contributors": [
15
21
  "wangshijun <shijun@arcblock.io> (https://github.com/wangshijun)"
16
22
  ],
17
23
  "license": "MIT",
18
- "devDependencies": {
19
- "jest": "^29.7.0"
20
- },
24
+ "devDependencies": {},
21
25
  "dependencies": {
26
+ "@ocap/state": "1.28.8",
27
+ "@ocap/util": "1.28.8",
22
28
  "kareem": "^2.4.1",
23
- "lodash": "^4.17.21",
24
- "@ocap/state": "1.28.6",
25
- "@ocap/util": "1.28.6"
26
- },
27
- "scripts": {
28
- "lint": "eslint tests lib",
29
- "lint:fix": "eslint --fix tests lib",
30
- "test": "jest --forceExit --detectOpenHandles",
31
- "coverage": "npm run test -- --coverage"
29
+ "lodash": "^4.17.21"
32
30
  }
33
- }
31
+ }
package/LICENSE DELETED
@@ -1,13 +0,0 @@
1
- Copyright 2018-2025 ArcBlock
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
6
-
7
- http://www.apache.org/licenses/LICENSE-2.0
8
-
9
- Unless required by applicable law or agreed to in writing, software
10
- distributed under the License is distributed on an "AS IS" BASIS,
11
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- See the License for the specific language governing permissions and
13
- limitations under the License.