@ocap/resolver 1.13.62 → 1.13.66
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 +27 -22
- package/package.json +12 -11
package/lib/index.js
CHANGED
|
@@ -9,6 +9,7 @@ const isEqual = require('lodash/isEqual');
|
|
|
9
9
|
const uniqBy = require('lodash/unionBy');
|
|
10
10
|
const Config = require('@ocap/config');
|
|
11
11
|
const states = require('@ocap/state');
|
|
12
|
+
const Joi = require('@ocap/validator');
|
|
12
13
|
const md5 = require('@ocap/util/lib/md5');
|
|
13
14
|
const CustomError = require('@ocap/util/lib/error');
|
|
14
15
|
const { types } = require('@ocap/mcrypto');
|
|
@@ -166,7 +167,7 @@ module.exports = class OCAPResolver {
|
|
|
166
167
|
}
|
|
167
168
|
|
|
168
169
|
getTx({ hash }, ctx) {
|
|
169
|
-
if (
|
|
170
|
+
if (Joi.patterns.txHash.test(hash)) {
|
|
170
171
|
return this._getState({
|
|
171
172
|
table: 'tx',
|
|
172
173
|
id: hash.toUpperCase(),
|
|
@@ -437,8 +438,9 @@ module.exports = class OCAPResolver {
|
|
|
437
438
|
}
|
|
438
439
|
|
|
439
440
|
getForgeState() {
|
|
441
|
+
const { accounts, token, transaction } = this.config;
|
|
440
442
|
return Promise.resolve({
|
|
441
|
-
accountConfig:
|
|
443
|
+
accountConfig: accounts,
|
|
442
444
|
address: 'forge_state',
|
|
443
445
|
consensus: {
|
|
444
446
|
maxBytes: '150000',
|
|
@@ -449,25 +451,13 @@ module.exports = class OCAPResolver {
|
|
|
449
451
|
validatorChanged: false,
|
|
450
452
|
},
|
|
451
453
|
data: null,
|
|
452
|
-
gas: [],
|
|
453
|
-
protocols: [],
|
|
454
|
-
stakeSummary: [],
|
|
455
454
|
tasks: [],
|
|
456
|
-
token
|
|
457
|
-
tokenSwapConfig: {
|
|
458
|
-
commissionHolderAddress: '',
|
|
459
|
-
commissionRate: 0,
|
|
460
|
-
maxCommission: null,
|
|
461
|
-
minCommission: null,
|
|
462
|
-
revokeCommissionRate: 0,
|
|
463
|
-
},
|
|
455
|
+
token,
|
|
464
456
|
txConfig: {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
},
|
|
470
|
-
...this.config.transaction,
|
|
457
|
+
...transaction,
|
|
458
|
+
txFee: Object.keys(transaction.txFee)
|
|
459
|
+
.filter((x) => x !== 'default')
|
|
460
|
+
.map((x) => ({ typeUrl: x, fee: fromTokenToUnit(transaction.txFee[x], token.decimal).toString(10) })),
|
|
471
461
|
},
|
|
472
462
|
upgradeInfo: null,
|
|
473
463
|
});
|
|
@@ -602,7 +592,7 @@ module.exports = class OCAPResolver {
|
|
|
602
592
|
return result ? { type, id: keyword } : null;
|
|
603
593
|
};
|
|
604
594
|
|
|
605
|
-
if (
|
|
595
|
+
if (Joi.patterns.txHash.test(args.keyword)) {
|
|
606
596
|
const results = await Promise.all([
|
|
607
597
|
doSearch('tx', args.keyword.toUpperCase()),
|
|
608
598
|
doSearch('rollupBlock', args.keyword),
|
|
@@ -901,7 +891,14 @@ module.exports = class OCAPResolver {
|
|
|
901
891
|
return [];
|
|
902
892
|
}
|
|
903
893
|
|
|
904
|
-
const rollupTxs = [
|
|
894
|
+
const rollupTxs = [
|
|
895
|
+
'DepositTokenV2Tx',
|
|
896
|
+
'WithdrawTokenV2Tx',
|
|
897
|
+
'JoinRollupTx',
|
|
898
|
+
'LeaveRollupTx',
|
|
899
|
+
'CreateRollupBlockTx',
|
|
900
|
+
'ClaimBlockRewardTx',
|
|
901
|
+
];
|
|
905
902
|
const typeUrl = formatTxType(tx.tx.itxJson._type);
|
|
906
903
|
const tokens = [];
|
|
907
904
|
|
|
@@ -924,13 +921,21 @@ module.exports = class OCAPResolver {
|
|
|
924
921
|
'address'
|
|
925
922
|
).filter((x) => x.address)
|
|
926
923
|
);
|
|
927
|
-
} else if (
|
|
924
|
+
} else if (typeUrl === 'RevokeStakeTx') {
|
|
928
925
|
tokens.push(
|
|
929
926
|
...uniqBy(
|
|
930
927
|
tx.tx.itxJson.outputs.reduce((acc, x) => acc.concat(x.tokens), []),
|
|
931
928
|
'address'
|
|
932
929
|
).filter((x) => x.address)
|
|
933
930
|
);
|
|
931
|
+
} else if (typeUrl === 'ClaimStakeTx') {
|
|
932
|
+
const revokeTx = await this.indexdb.tx.get(tx.tx.itxJson.evidence.hash);
|
|
933
|
+
tokens.push(
|
|
934
|
+
...uniqBy(
|
|
935
|
+
revokeTx.tx.itxJson.outputs.reduce((acc, x) => acc.concat(x.tokens), []),
|
|
936
|
+
'address'
|
|
937
|
+
).filter((x) => x.address)
|
|
938
|
+
);
|
|
934
939
|
} else if (rollupTxs.includes(typeUrl)) {
|
|
935
940
|
const rollup = await this.indexdb.rollup.get(tx.tx.itxJson.rollup);
|
|
936
941
|
tokens.push({ address: rollup.tokenAddress, value: '0' });
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.13.
|
|
6
|
+
"version": "1.13.66",
|
|
7
7
|
"description": "GraphQL resolver built upon ocap statedb and GQL layer",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -22,17 +22,18 @@
|
|
|
22
22
|
"jest": "^27.3.1"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@arcblock/did": "1.13.
|
|
26
|
-
"@arcblock/did-util": "1.13.
|
|
27
|
-
"@ocap/config": "1.13.
|
|
28
|
-
"@ocap/indexdb": "1.13.
|
|
29
|
-
"@ocap/mcrypto": "1.13.
|
|
30
|
-
"@ocap/message": "1.13.
|
|
31
|
-
"@ocap/state": "1.13.
|
|
32
|
-
"@ocap/tx-protocols": "1.13.
|
|
33
|
-
"@ocap/util": "1.13.
|
|
25
|
+
"@arcblock/did": "1.13.66",
|
|
26
|
+
"@arcblock/did-util": "1.13.66",
|
|
27
|
+
"@ocap/config": "1.13.66",
|
|
28
|
+
"@ocap/indexdb": "1.13.66",
|
|
29
|
+
"@ocap/mcrypto": "1.13.66",
|
|
30
|
+
"@ocap/message": "1.13.66",
|
|
31
|
+
"@ocap/state": "1.13.66",
|
|
32
|
+
"@ocap/tx-protocols": "1.13.66",
|
|
33
|
+
"@ocap/util": "1.13.66",
|
|
34
|
+
"@ocap/validator": "1.13.66",
|
|
34
35
|
"debug": "^4.3.2",
|
|
35
36
|
"lodash": "^4.17.21"
|
|
36
37
|
},
|
|
37
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "1395a8dccee398dd0aed47c2b54a2c6e350d8621"
|
|
38
39
|
}
|