@ocap/state 1.13.59 → 1.13.63

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.
@@ -24,6 +24,8 @@ const schema = Joi.object({
24
24
  burnedAmount: Joi.BN().min(0).optional().default('0'),
25
25
  rewardAmount: Joi.BN().min(0).optional().default('0'),
26
26
 
27
+ minReward: Joi.BN().min(0).required(),
28
+
27
29
  context: Joi.contextSchema,
28
30
  data: Joi.any().optional(),
29
31
  }).options({ stripUnknown: true, noDefaults: false });
@@ -44,6 +46,7 @@ const create = (attrs, context) => {
44
46
  'mintedAmount',
45
47
  'burnedAmount',
46
48
  'rewardAmount',
49
+ 'minReward',
47
50
  'data',
48
51
  ]),
49
52
  };
@@ -57,7 +57,9 @@ const schema = Joi.object({
57
57
  blockHash: Joi.string().regex(Joi.hashRegexp).optional().allow(''),
58
58
  issuer: Joi.DID().optional(),
59
59
 
60
- leaveWaitingPeriod: Joi.number().integer().min(0).default(0),
60
+ leaveWaitingPeriod: Joi.number().integer().min(Joi.ref('minBlockInterval')).default(0),
61
+ publishWaitingPeriod: Joi.number().integer().min(Joi.ref('minBlockInterval')).default(0),
62
+ publishSlashRate: Joi.number().integer().min(1).max(10000).required(),
61
63
 
62
64
  context: Joi.contextSchema,
63
65
  data: Joi.any().optional(),
@@ -96,6 +98,8 @@ const create = (attrs, context) => {
96
98
  'minWithdrawFee',
97
99
  'maxWithdrawFee',
98
100
  'leaveWaitingPeriod',
101
+ 'publishWaitingPeriod',
102
+ 'publishSlashRate',
99
103
  'issuer',
100
104
  'data',
101
105
  ]),
@@ -155,6 +159,9 @@ const update = (state, updates, context) => {
155
159
  'maxWithdrawFee',
156
160
  'blockHeight',
157
161
  'blockHash',
162
+ 'leaveWaitingPeriod',
163
+ 'publishWaitingPeriod',
164
+ 'publishSlashRate',
158
165
  'data',
159
166
  ]),
160
167
  context: updateStateContext(state.context, context),
package/lib/states/tx.js CHANGED
@@ -1,4 +1,6 @@
1
1
  const get = require('lodash/get');
2
+ const pick = require('lodash/pick');
3
+ const merge = require('lodash/merge');
2
4
  const groupBy = require('lodash/groupBy');
3
5
  const upperFirst = require('lodash/upperFirst');
4
6
  const camelCase = require('lodash/camelCase');
@@ -9,7 +11,6 @@ const getListField = require('@ocap/util/lib/get-list-field');
9
11
  const ZERO = new BN(0);
10
12
 
11
13
  // Receiver = Whose asset have net gain
12
- // TODO: let's deprecate this, since it's not used anymore
13
14
  const getTxReceiver = ({ tx, itx, typeUrl }) => {
14
15
  switch (typeUrl) {
15
16
  case 'TransferTx':
@@ -386,7 +387,7 @@ const getTxReceipts = ({ tx, code }, ctx = {}) => {
386
387
  };
387
388
 
388
389
  const create = (context, code = 'OK') => {
389
- const { txHash, txTime, tx } = context;
390
+ const { txHash, txTime, tx, itxExtras = {} } = context;
390
391
  const itx = decodeAny(tx.itx).value; // we should decode here because `context.itx` maybe changed
391
392
  const typeUrl = fromTypeUrl(tx.itx.typeUrl);
392
393
  const typeName = tx.itx.typeUrl.split(':').pop();
@@ -418,6 +419,7 @@ const create = (context, code = 'OK') => {
418
419
  encoded_value: tx.itx.value,
419
420
  type_url: tx.itx.typeUrl,
420
421
  ...itxJson,
422
+ ...itxExtras,
421
423
  data: itx.data || null,
422
424
  },
423
425
  },
@@ -428,8 +430,12 @@ const create = (context, code = 'OK') => {
428
430
  return result;
429
431
  };
430
432
 
433
+ // Only a few props are allowed to be changed in tx state
434
+ const update = (state, updates) => merge(state, pick(updates, ['finalized', 'tx.itxJson.actualFee']));
435
+
431
436
  module.exports = {
432
437
  create,
438
+ update,
433
439
  getTxReceiver,
434
440
  getTxSender,
435
441
  getTxReceipts,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.13.59",
6
+ "version": "1.13.63",
7
7
  "description": "",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -16,21 +16,21 @@
16
16
  "coverage": "npm run test -- --coverage"
17
17
  },
18
18
  "dependencies": {
19
- "@arcblock/did": "1.13.59",
20
- "@ocap/contract": "1.13.59",
21
- "@ocap/message": "1.13.59",
22
- "@ocap/util": "1.13.59",
19
+ "@arcblock/did": "1.13.63",
20
+ "@ocap/contract": "1.13.63",
21
+ "@ocap/message": "1.13.63",
22
+ "@ocap/util": "1.13.63",
23
23
  "bloom-filters": "^1.3.1",
24
24
  "debug": "^4.3.2",
25
25
  "joi": "^17.4.2",
26
26
  "lodash": "^4.17.21"
27
27
  },
28
28
  "devDependencies": {
29
- "@ocap/mcrypto": "1.13.59",
29
+ "@ocap/mcrypto": "1.13.63",
30
30
  "jest": "^27.3.1"
31
31
  },
32
32
  "keywords": [],
33
33
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
34
34
  "license": "MIT",
35
- "gitHead": "534ed3e0856fa239d2962c4f4e2d636351940a91"
35
+ "gitHead": "7e40f22f90f4f5ac08fde3d4d3b7194aa792c95d"
36
36
  }