@ocap/resolver 1.29.3 → 1.29.5
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/index.d.mts +1 -0
- package/esm/index.mjs +4 -2
- package/lib/index.cjs +4 -2
- package/lib/index.d.cts +1 -0
- package/package.json +17 -17
package/esm/index.d.mts
CHANGED
|
@@ -22,6 +22,7 @@ declare class OCAPResolver implements IResolver {
|
|
|
22
22
|
logger: IPipelineLogger;
|
|
23
23
|
migrationChain?: MigrationChainManager;
|
|
24
24
|
formatTx: (tx: IResolverTransaction | null, ctx?: IResolverContext) => Promise<IResolverTransaction | null>;
|
|
25
|
+
private initializationPromise;
|
|
25
26
|
/**
|
|
26
27
|
* Creates an instance of OCAPResolver.
|
|
27
28
|
* @param params Parameters to bootstrap the resolver
|
package/esm/index.mjs
CHANGED
|
@@ -277,7 +277,7 @@ var OCAPResolver = class {
|
|
|
277
277
|
this.formatTx = this._formatTx.bind(this);
|
|
278
278
|
if (validateTokenConfig) this.validateTokenConfig();
|
|
279
279
|
this.connectIndexDB();
|
|
280
|
-
this.initializeStateDB().catch((err) => {
|
|
280
|
+
this.initializationPromise = this.initializeStateDB().catch((err) => {
|
|
281
281
|
this.logger.error("Failed to initialize statedb:", err.message);
|
|
282
282
|
process.exit(1);
|
|
283
283
|
});
|
|
@@ -304,6 +304,7 @@ var OCAPResolver = class {
|
|
|
304
304
|
return new Promise((resolve, reject) => {
|
|
305
305
|
const task = async () => {
|
|
306
306
|
try {
|
|
307
|
+
await this.initializationPromise;
|
|
307
308
|
resolve((await this.executor.execute(context)).txHash);
|
|
308
309
|
} catch (err) {
|
|
309
310
|
reject(err);
|
|
@@ -825,7 +826,7 @@ var OCAPResolver = class {
|
|
|
825
826
|
}, { commitMessage: "initialize chain" });
|
|
826
827
|
if (this.tokenItx) {
|
|
827
828
|
await this.runAsLambda(async (txn) => {
|
|
828
|
-
const existToken = await this.statedb.token.get(this.tokenItx.address);
|
|
829
|
+
const existToken = await this.statedb.token.get(this.tokenItx.address, { txn });
|
|
829
830
|
if (!existToken) {
|
|
830
831
|
const state = tokenState.create(this.tokenItx, context);
|
|
831
832
|
const result = await tokenDB.create(this.tokenItx.address, state, { txn });
|
|
@@ -1108,6 +1109,7 @@ var OCAPResolver = class {
|
|
|
1108
1109
|
const tasks = Object.keys(tokens).map((address) => this.tokenCache.get(address));
|
|
1109
1110
|
const tokenStates = await Promise.all(tasks);
|
|
1110
1111
|
return Object.keys(tokens).map((address) => ({
|
|
1112
|
+
address,
|
|
1111
1113
|
value: tokens[address],
|
|
1112
1114
|
...extractTokenMeta(address, tokenStates)
|
|
1113
1115
|
}));
|
package/lib/index.cjs
CHANGED
|
@@ -291,7 +291,7 @@ var OCAPResolver = class {
|
|
|
291
291
|
this.formatTx = this._formatTx.bind(this);
|
|
292
292
|
if (validateTokenConfig) this.validateTokenConfig();
|
|
293
293
|
this.connectIndexDB();
|
|
294
|
-
this.initializeStateDB().catch((err) => {
|
|
294
|
+
this.initializationPromise = this.initializeStateDB().catch((err) => {
|
|
295
295
|
this.logger.error("Failed to initialize statedb:", err.message);
|
|
296
296
|
process.exit(1);
|
|
297
297
|
});
|
|
@@ -318,6 +318,7 @@ var OCAPResolver = class {
|
|
|
318
318
|
return new Promise((resolve, reject) => {
|
|
319
319
|
const task = async () => {
|
|
320
320
|
try {
|
|
321
|
+
await this.initializationPromise;
|
|
321
322
|
resolve((await this.executor.execute(context)).txHash);
|
|
322
323
|
} catch (err) {
|
|
323
324
|
reject(err);
|
|
@@ -839,7 +840,7 @@ var OCAPResolver = class {
|
|
|
839
840
|
}, { commitMessage: "initialize chain" });
|
|
840
841
|
if (this.tokenItx) {
|
|
841
842
|
await this.runAsLambda(async (txn) => {
|
|
842
|
-
const existToken = await this.statedb.token.get(this.tokenItx.address);
|
|
843
|
+
const existToken = await this.statedb.token.get(this.tokenItx.address, { txn });
|
|
843
844
|
if (!existToken) {
|
|
844
845
|
const state = tokenState.create(this.tokenItx, context);
|
|
845
846
|
const result = await tokenDB.create(this.tokenItx.address, state, { txn });
|
|
@@ -1122,6 +1123,7 @@ var OCAPResolver = class {
|
|
|
1122
1123
|
const tasks = Object.keys(tokens).map((address) => this.tokenCache.get(address));
|
|
1123
1124
|
const tokenStates = await Promise.all(tasks);
|
|
1124
1125
|
return Object.keys(tokens).map((address) => ({
|
|
1126
|
+
address,
|
|
1125
1127
|
value: tokens[address],
|
|
1126
1128
|
...extractTokenMeta(address, tokenStates)
|
|
1127
1129
|
}));
|
package/lib/index.d.cts
CHANGED
|
@@ -22,6 +22,7 @@ declare class OCAPResolver implements IResolver {
|
|
|
22
22
|
logger: IPipelineLogger;
|
|
23
23
|
migrationChain?: MigrationChainManager;
|
|
24
24
|
formatTx: (tx: IResolverTransaction | null, ctx?: IResolverContext) => Promise<IResolverTransaction | null>;
|
|
25
|
+
private initializationPromise;
|
|
25
26
|
/**
|
|
26
27
|
* Creates an instance of OCAPResolver.
|
|
27
28
|
* @param params Parameters to bootstrap the resolver
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.29.
|
|
6
|
+
"version": "1.29.5",
|
|
7
7
|
"description": "GraphQL resolver built upon ocap statedb and GQL layer",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "./lib/index.cjs",
|
|
@@ -42,29 +42,29 @@
|
|
|
42
42
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
43
43
|
"license": "MIT",
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@arcblock/jwt": "1.29.
|
|
46
|
-
"@ocap/indexdb-memory": "1.29.
|
|
47
|
-
"@ocap/statedb-memory": "1.29.
|
|
45
|
+
"@arcblock/jwt": "1.29.5",
|
|
46
|
+
"@ocap/indexdb-memory": "1.29.5",
|
|
47
|
+
"@ocap/statedb-memory": "1.29.5",
|
|
48
48
|
"@types/express": "^4.17.23",
|
|
49
49
|
"@types/lodash": "^4.17.16",
|
|
50
50
|
"@types/node": "^20.10.0",
|
|
51
51
|
"tsdown": "^0.18.4"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@arcblock/did": "1.29.
|
|
55
|
-
"@arcblock/did-ext": "1.29.
|
|
56
|
-
"@arcblock/did-util": "1.29.
|
|
54
|
+
"@arcblock/did": "1.29.5",
|
|
55
|
+
"@arcblock/did-ext": "1.29.5",
|
|
56
|
+
"@arcblock/did-util": "1.29.5",
|
|
57
57
|
"@arcblock/nft-display": "^3.2.3",
|
|
58
|
-
"@arcblock/validator": "1.29.
|
|
59
|
-
"@ocap/config": "1.29.
|
|
60
|
-
"@ocap/indexdb": "1.29.
|
|
61
|
-
"@ocap/mcrypto": "1.29.
|
|
62
|
-
"@ocap/message": "1.29.
|
|
63
|
-
"@ocap/state": "1.29.
|
|
64
|
-
"@ocap/tx-protocols": "1.29.
|
|
65
|
-
"@ocap/types": "1.29.
|
|
66
|
-
"@ocap/util": "1.29.
|
|
67
|
-
"@ocap/wallet": "1.29.
|
|
58
|
+
"@arcblock/validator": "1.29.5",
|
|
59
|
+
"@ocap/config": "1.29.5",
|
|
60
|
+
"@ocap/indexdb": "1.29.5",
|
|
61
|
+
"@ocap/mcrypto": "1.29.5",
|
|
62
|
+
"@ocap/message": "1.29.5",
|
|
63
|
+
"@ocap/state": "1.29.5",
|
|
64
|
+
"@ocap/tx-protocols": "1.29.5",
|
|
65
|
+
"@ocap/types": "1.29.5",
|
|
66
|
+
"@ocap/util": "1.29.5",
|
|
67
|
+
"@ocap/wallet": "1.29.5",
|
|
68
68
|
"debug": "^4.4.3",
|
|
69
69
|
"express": "^4.22.1",
|
|
70
70
|
"lodash": "^4.17.23",
|