@ocap/resolver 1.20.8 → 1.20.10

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 CHANGED
@@ -685,7 +685,7 @@ module.exports = class OCAPResolver {
685
685
  return { validators: [] };
686
686
  }
687
687
 
688
- const rollup = await this.runAsLambda((txn) => this.statedb.rollup.get(args.rollupAddress, { txn }));
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.runAsLambda((txn) => this.statedb.stake.get(stakeAddress, { txn }));
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.runAsLambda((txn) => this.statedb.chain.get(CHAIN_ADDR, { txn }));
804
+ return this.statedb.chain.get(CHAIN_ADDR);
805
805
  }
806
806
 
807
807
  getToken(id) {
808
- return this.runAsLambda((txn) => this.statedb.token.get(id, { txn }));
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
- const existToken = await this.getToken(this.tokenItx.address);
840
- if (!existToken) {
841
- await this.runAsLambda(
842
- async (txn) => {
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
- { commitMessage: 'initialize token' }
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.runAsLambda((txn) => this.statedb[table].get(unified, { txn, ...extraParams }));
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.runAsLambda((txn) =>
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.runAsLambda((txn) =>
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.8",
6
+ "version": "1.20.10",
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.10",
18
+ "@ocap/statedb-memory": "1.20.10"
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.8",
23
- "@arcblock/did-util": "1.20.8",
24
- "@arcblock/validator": "1.20.8",
25
- "@ocap/config": "1.20.8",
26
- "@ocap/indexdb": "1.20.8",
27
- "@ocap/mcrypto": "1.20.8",
28
- "@ocap/state": "1.20.8",
29
- "@ocap/tx-protocols": "1.20.8",
30
- "@ocap/util": "1.20.8",
31
- "@ocap/message": "1.20.8",
32
- "@ocap/wallet": "1.20.8",
33
- "@ocap/statedb-memory": "1.20.8",
34
- "@ocap/indexdb-memory": "1.20.8",
35
- "@arcblock/did-ext": "1.20.8"
24
+ "@arcblock/did": "1.20.10",
25
+ "@arcblock/did-ext": "1.20.10",
26
+ "@arcblock/did-util": "1.20.10",
27
+ "@arcblock/validator": "1.20.10",
28
+ "@ocap/indexdb": "1.20.10",
29
+ "@ocap/mcrypto": "1.20.10",
30
+ "@ocap/message": "1.20.10",
31
+ "@ocap/state": "1.20.10",
32
+ "@ocap/tx-protocols": "1.20.10",
33
+ "@ocap/config": "1.20.10",
34
+ "@ocap/util": "1.20.10",
35
+ "@ocap/wallet": "1.20.10"
36
36
  },
37
37
  "scripts": {
38
38
  "lint": "eslint tests lib",