@ocap/statedb-fs 1.14.22 → 1.14.25
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/table/account.js +17 -2
- package/lib/table/base.js +1 -1
- package/package.json +4 -3
package/lib/table/account.js
CHANGED
|
@@ -1,15 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
const { ensureChecksumAddress } = require('@ocap/state/lib/states/account');
|
|
2
|
+
const debug = require('debug')(require('../../package.json').name);
|
|
2
3
|
const FsTable = require('./base');
|
|
3
4
|
|
|
4
5
|
class AccountTable extends FsTable {
|
|
5
6
|
async _get(address, { final = true } = {}) {
|
|
6
|
-
const current = await this.collection.by(this.uniqIndex, address);
|
|
7
|
+
const current = await this.collection.by(this.uniqIndex, ensureChecksumAddress(address));
|
|
7
8
|
if (current && final && Array.isArray(current.migratedTo) && current.migratedTo.length) {
|
|
8
9
|
return this.collection.by(this.uniqIndex, current.migratedTo[0]);
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
return current;
|
|
12
13
|
}
|
|
14
|
+
|
|
15
|
+
async _create(key, attrs) {
|
|
16
|
+
const doc = await this._get(key);
|
|
17
|
+
if (doc) {
|
|
18
|
+
throw new Error(`${this.name} already exists: ${key}`);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
debug(`insert ${this.name}`, attrs);
|
|
22
|
+
const newDoc = { [this.uniqIndex]: key, ...attrs };
|
|
23
|
+
newDoc[this.uniqIndex] = ensureChecksumAddress(newDoc[this.uniqIndex]);
|
|
24
|
+
const result = await this.collection.insert(newDoc);
|
|
25
|
+
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
13
28
|
}
|
|
14
29
|
|
|
15
30
|
module.exports = AccountTable;
|
package/lib/table/base.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ocap/statedb-fs",
|
|
3
3
|
"description": "OCAP statedb adapter that uses fs as backend",
|
|
4
|
-
"version": "1.14.
|
|
4
|
+
"version": "1.14.25",
|
|
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,9 +37,10 @@
|
|
|
37
37
|
"test": "jest --forceExit --detectOpenHandles",
|
|
38
38
|
"coverage": "npm run test -- --coverage & exit 0"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "52a5499e4794af7f973a6e61dea78cb2e61c10a4",
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@ocap/
|
|
42
|
+
"@ocap/state": "1.14.25",
|
|
43
|
+
"@ocap/statedb": "1.14.25",
|
|
43
44
|
"debug": "^4.3.3",
|
|
44
45
|
"lodash": "^4.17.21",
|
|
45
46
|
"lokijs": "^1.5.11"
|