@ocap/resolver 1.17.23 → 1.18.1
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/hooks.js +3 -1
- package/lib/index.js +9 -4
- package/package.json +12 -12
package/lib/hooks.js
CHANGED
|
@@ -188,7 +188,9 @@ const onClaimBlockReward = async (tx, ctx, indexdb) => {
|
|
|
188
188
|
|
|
189
189
|
const receipt = tx.receipts.find((x) => x.address === signer);
|
|
190
190
|
if (receipt) {
|
|
191
|
-
const change = receipt.changes.find(
|
|
191
|
+
const change = receipt.changes.find(
|
|
192
|
+
(x) => x.target === rollupState.tokenAddress && new BN(x.value).isNeg() === false
|
|
193
|
+
);
|
|
192
194
|
doc.totalGain = new BN(doc.totalGain).add(new BN(change.value).abs()).toString(10);
|
|
193
195
|
await indexdb.rollupValidator.update(signer, doc);
|
|
194
196
|
debug('update rollup validator on claim reward', signer);
|
package/lib/index.js
CHANGED
|
@@ -156,7 +156,7 @@ module.exports = class OCAPResolver {
|
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
async sendTx({ tx: txBase64 }) {
|
|
159
|
+
async sendTx({ tx: txBase64 }, ctx = {}) {
|
|
160
160
|
debug('sendTx', txBase64);
|
|
161
161
|
|
|
162
162
|
if (process.env.CHAIN_MODE === 'readonly') {
|
|
@@ -164,7 +164,7 @@ module.exports = class OCAPResolver {
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
// 0. create new context
|
|
167
|
-
const context = { txBase64, statedb: this.statedb, indexdb: this.indexdb, config: this.config };
|
|
167
|
+
const context = { ...ctx, txBase64, statedb: this.statedb, indexdb: this.indexdb, config: this.config };
|
|
168
168
|
|
|
169
169
|
// 1. execute and persist the transaction
|
|
170
170
|
const result = await this.executor.execute(context);
|
|
@@ -474,6 +474,11 @@ module.exports = class OCAPResolver {
|
|
|
474
474
|
token,
|
|
475
475
|
txConfig: {
|
|
476
476
|
...transaction,
|
|
477
|
+
txGas: {
|
|
478
|
+
...transaction.txGas,
|
|
479
|
+
minStake: fromTokenToUnit(transaction.txGas.minStake, token.decimal).toString(10),
|
|
480
|
+
maxStake: fromTokenToUnit(transaction.txGas.maxStake, token.decimal).toString(10),
|
|
481
|
+
},
|
|
477
482
|
txFee: Object.keys(transaction.txFee)
|
|
478
483
|
.filter((x) => x !== 'default')
|
|
479
484
|
.map((x) => ({ typeUrl: x, fee: fromTokenToUnit(transaction.txFee[x], token.decimal).toString(10) })),
|
|
@@ -687,13 +692,13 @@ module.exports = class OCAPResolver {
|
|
|
687
692
|
|
|
688
693
|
// Auto populate token holder accounts if not exist
|
|
689
694
|
for (let i = 0; i < accounts.length; i++) {
|
|
690
|
-
const { address, balance } = accounts[i];
|
|
695
|
+
const { address, balance, moniker } = accounts[i];
|
|
691
696
|
try {
|
|
692
697
|
const existAccount = await accountDB.get(address, ctx);
|
|
693
698
|
if (!existAccount) {
|
|
694
699
|
const balanceStr = fromTokenToUnit(balance, token.decimal).toString(10);
|
|
695
700
|
const state = accountState.create(
|
|
696
|
-
{ address, tokens: { [this.tokenItx.address]: balanceStr }, moniker: 'token-holder' },
|
|
701
|
+
{ address, tokens: { [this.tokenItx.address]: balanceStr }, moniker: moniker || 'token-holder' },
|
|
697
702
|
context
|
|
698
703
|
);
|
|
699
704
|
const result = await accountDB.create(address, state, ctx);
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.18.1",
|
|
7
7
|
"description": "GraphQL resolver built upon ocap statedb and GQL layer",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -22,18 +22,18 @@
|
|
|
22
22
|
"jest": "^27.5.1"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@arcblock/did": "1.
|
|
26
|
-
"@arcblock/did-util": "1.
|
|
27
|
-
"@arcblock/validator": "1.
|
|
28
|
-
"@ocap/config": "1.
|
|
29
|
-
"@ocap/indexdb": "1.
|
|
30
|
-
"@ocap/mcrypto": "1.
|
|
31
|
-
"@ocap/message": "1.
|
|
32
|
-
"@ocap/state": "1.
|
|
33
|
-
"@ocap/tx-protocols": "1.
|
|
34
|
-
"@ocap/util": "1.
|
|
25
|
+
"@arcblock/did": "1.18.1",
|
|
26
|
+
"@arcblock/did-util": "1.18.1",
|
|
27
|
+
"@arcblock/validator": "1.18.1",
|
|
28
|
+
"@ocap/config": "1.18.1",
|
|
29
|
+
"@ocap/indexdb": "1.18.1",
|
|
30
|
+
"@ocap/mcrypto": "1.18.1",
|
|
31
|
+
"@ocap/message": "1.18.1",
|
|
32
|
+
"@ocap/state": "1.18.1",
|
|
33
|
+
"@ocap/tx-protocols": "1.18.1",
|
|
34
|
+
"@ocap/util": "1.18.1",
|
|
35
35
|
"debug": "^4.3.4",
|
|
36
36
|
"lodash": "^4.17.21"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "7735e4243a1ba253eb14d960ca272974eaf94623"
|
|
39
39
|
}
|