@ocap/resolver 1.20.7 → 1.20.9
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/index.js +17 -17
- package/lib/token-distribution.js +1 -4
- package/package.json +16 -16
package/lib/index.js
CHANGED
|
@@ -685,7 +685,7 @@ module.exports = class OCAPResolver {
|
|
|
685
685
|
return { validators: [] };
|
|
686
686
|
}
|
|
687
687
|
|
|
688
|
-
const rollup = await this.
|
|
688
|
+
const rollup = await this.statedb.rollup.get(args.rollupAddress);
|
|
689
689
|
if (!rollup) {
|
|
690
690
|
return { validators: [] };
|
|
691
691
|
}
|
|
@@ -695,7 +695,7 @@ module.exports = class OCAPResolver {
|
|
|
695
695
|
await Promise.all(
|
|
696
696
|
result.validators.map((x) => {
|
|
697
697
|
const stakeAddress = toStakeAddress(x.address, args.rollupAddress);
|
|
698
|
-
return this.
|
|
698
|
+
return this.statedb.stake.get(stakeAddress);
|
|
699
699
|
})
|
|
700
700
|
)
|
|
701
701
|
).filter(Boolean);
|
|
@@ -801,11 +801,11 @@ module.exports = class OCAPResolver {
|
|
|
801
801
|
}
|
|
802
802
|
|
|
803
803
|
getChain() {
|
|
804
|
-
return this.
|
|
804
|
+
return this.statedb.chain.get(CHAIN_ADDR);
|
|
805
805
|
}
|
|
806
806
|
|
|
807
807
|
getToken(id) {
|
|
808
|
-
return this.
|
|
808
|
+
return this.statedb.token.get(id);
|
|
809
809
|
}
|
|
810
810
|
|
|
811
811
|
async initializeStateDB() {
|
|
@@ -817,9 +817,10 @@ module.exports = class OCAPResolver {
|
|
|
817
817
|
|
|
818
818
|
// Auto persist config to chain state
|
|
819
819
|
// Will throw error if immutable chain config are updated
|
|
820
|
-
const info = await this.getChain();
|
|
821
820
|
await this.runAsLambda(
|
|
822
821
|
async (txn) => {
|
|
822
|
+
const info = await this.statedb.chain.get(CHAIN_ADDR, { txn });
|
|
823
|
+
|
|
823
824
|
if (!info) {
|
|
824
825
|
const state = chainState.create({ ...this.config, address: CHAIN_ADDR }, context);
|
|
825
826
|
const result = await chainDB.create(CHAIN_ADDR, state, { txn });
|
|
@@ -836,18 +837,19 @@ module.exports = class OCAPResolver {
|
|
|
836
837
|
// Auto persist token state, just once
|
|
837
838
|
// Since the token info should not be changed after restart
|
|
838
839
|
if (this.tokenItx) {
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
840
|
+
await this.runAsLambda(
|
|
841
|
+
async (txn) => {
|
|
842
|
+
const existToken = await this.statedb.token.get(this.tokenItx.address);
|
|
843
|
+
|
|
844
|
+
if (!existToken) {
|
|
843
845
|
const state = tokenState.create(this.tokenItx, context);
|
|
844
846
|
const result = await tokenDB.create(this.tokenItx.address, state, { txn });
|
|
845
847
|
tokenDB.emit('create', result, { txn });
|
|
846
848
|
this.logger.debug('create token state', { address: result?.address });
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
849
|
+
}
|
|
850
|
+
},
|
|
851
|
+
{ commitMessage: 'initialize token' }
|
|
852
|
+
);
|
|
851
853
|
|
|
852
854
|
// Auto populate token holder accounts if not exist
|
|
853
855
|
await this.runAsLambda(
|
|
@@ -952,7 +954,7 @@ module.exports = class OCAPResolver {
|
|
|
952
954
|
}
|
|
953
955
|
|
|
954
956
|
const unified = isValidDid(id) ? toAddress(id) : id;
|
|
955
|
-
const state = await this.
|
|
957
|
+
const state = await this.statedb[table].get(unified, { ...extraParams });
|
|
956
958
|
if (state) {
|
|
957
959
|
if (dataKey) {
|
|
958
960
|
set(state, dataKey, formatData(get(state, dataKey)));
|
|
@@ -1050,9 +1052,7 @@ module.exports = class OCAPResolver {
|
|
|
1050
1052
|
}
|
|
1051
1053
|
|
|
1052
1054
|
if (typeUrl === 'fg:t:account_migrate') {
|
|
1053
|
-
const fromState = await this.
|
|
1054
|
-
this.statedb.account.get(tx.tx.from, { txn, traceMigration: false })
|
|
1055
|
-
);
|
|
1055
|
+
const fromState = await this.statedb.account.get(tx.tx.from, { traceMigration: false });
|
|
1056
1056
|
if (fromState) {
|
|
1057
1057
|
tx.receipts = getTxReceipts(tx, { config: this.config, fromState });
|
|
1058
1058
|
}
|
|
@@ -347,10 +347,7 @@ class TokenDistributionManager {
|
|
|
347
347
|
}
|
|
348
348
|
|
|
349
349
|
async getStakeState(address, ctx) {
|
|
350
|
-
const stakeState = await this.resolver.
|
|
351
|
-
this.resolver.statedb.stake.get(address, { ...ctx, txn })
|
|
352
|
-
);
|
|
353
|
-
|
|
350
|
+
const stakeState = await this.resolver.statedb.stake.get(address, ctx);
|
|
354
351
|
return stakeState;
|
|
355
352
|
}
|
|
356
353
|
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.20.
|
|
6
|
+
"version": "1.20.9",
|
|
7
7
|
"description": "GraphQL resolver built upon ocap statedb and GQL layer",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -13,26 +13,26 @@
|
|
|
13
13
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"jest": "^29.7.0"
|
|
16
|
+
"jest": "^29.7.0",
|
|
17
|
+
"@ocap/indexdb-memory": "1.20.9",
|
|
18
|
+
"@ocap/statedb-memory": "1.20.9"
|
|
17
19
|
},
|
|
18
20
|
"dependencies": {
|
|
19
21
|
"debug": "^4.3.6",
|
|
20
22
|
"lodash": "^4.17.21",
|
|
21
23
|
"queue": "^6",
|
|
22
|
-
"@arcblock/did": "1.20.
|
|
23
|
-
"@arcblock/did-
|
|
24
|
-
"@arcblock/
|
|
25
|
-
"@
|
|
26
|
-
"@ocap/
|
|
27
|
-
"@ocap/
|
|
28
|
-
"@ocap/
|
|
29
|
-
"@ocap/message": "1.20.
|
|
30
|
-
"@ocap/
|
|
31
|
-
"@ocap/
|
|
32
|
-
"@ocap/
|
|
33
|
-
"@ocap/
|
|
34
|
-
"@arcblock/did-ext": "1.20.7",
|
|
35
|
-
"@ocap/util": "1.20.7"
|
|
24
|
+
"@arcblock/did": "1.20.9",
|
|
25
|
+
"@arcblock/did-ext": "1.20.9",
|
|
26
|
+
"@arcblock/did-util": "1.20.9",
|
|
27
|
+
"@arcblock/validator": "1.20.9",
|
|
28
|
+
"@ocap/config": "1.20.9",
|
|
29
|
+
"@ocap/indexdb": "1.20.9",
|
|
30
|
+
"@ocap/mcrypto": "1.20.9",
|
|
31
|
+
"@ocap/message": "1.20.9",
|
|
32
|
+
"@ocap/state": "1.20.9",
|
|
33
|
+
"@ocap/tx-protocols": "1.20.9",
|
|
34
|
+
"@ocap/util": "1.20.9",
|
|
35
|
+
"@ocap/wallet": "1.20.9"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"lint": "eslint tests lib",
|