@ocap/tx-protocols 1.28.6 → 1.28.7

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.
Files changed (47) hide show
  1. package/README.md +1 -1
  2. package/lib/execute.js +0 -3
  3. package/lib/pipes/ensure-cost.js +0 -1
  4. package/lib/pipes/ensure-gas.js +0 -1
  5. package/lib/protocols/account/delegate.js +3 -5
  6. package/lib/protocols/account/migrate.js +1 -2
  7. package/lib/protocols/account/revoke-delegate.js +6 -3
  8. package/lib/protocols/asset/acquire-v2.js +26 -8
  9. package/lib/protocols/asset/acquire-v3.js +27 -12
  10. package/lib/protocols/asset/calls/transfer-token.js +0 -1
  11. package/lib/protocols/asset/calls/transfer.js +0 -1
  12. package/lib/protocols/asset/consume.js +9 -4
  13. package/lib/protocols/asset/create.js +6 -4
  14. package/lib/protocols/asset/mint.js +22 -6
  15. package/lib/protocols/asset/pipes/exec-mint-hook.js +0 -1
  16. package/lib/protocols/asset/pipes/verify-itx-assets.js +0 -1
  17. package/lib/protocols/asset/update.js +3 -2
  18. package/lib/protocols/factory/create.js +20 -7
  19. package/lib/protocols/governance/claim-stake.js +9 -4
  20. package/lib/protocols/governance/return-stake.js +9 -4
  21. package/lib/protocols/governance/revoke-stake.js +9 -4
  22. package/lib/protocols/governance/slash-stake.js +17 -5
  23. package/lib/protocols/governance/stake.js +12 -5
  24. package/lib/protocols/rollup/claim-reward.js +18 -8
  25. package/lib/protocols/rollup/close.js +6 -2
  26. package/lib/protocols/rollup/create-block.js +12 -6
  27. package/lib/protocols/rollup/create.js +14 -5
  28. package/lib/protocols/rollup/join.js +0 -2
  29. package/lib/protocols/rollup/leave.js +0 -2
  30. package/lib/protocols/rollup/migrate.js +6 -2
  31. package/lib/protocols/rollup/pause.js +6 -2
  32. package/lib/protocols/rollup/pipes/verify-evidence.js +0 -1
  33. package/lib/protocols/rollup/pipes/verify-signers.js +1 -2
  34. package/lib/protocols/rollup/resume.js +6 -2
  35. package/lib/protocols/rollup/update.js +5 -2
  36. package/lib/protocols/token/create.js +3 -2
  37. package/lib/protocols/token/deposit-v2.js +9 -5
  38. package/lib/protocols/token/withdraw-v2.js +9 -6
  39. package/lib/protocols/token-factory/burn.js +3 -1
  40. package/lib/protocols/token-factory/create.js +3 -2
  41. package/lib/protocols/token-factory/mint.js +4 -1
  42. package/lib/protocols/token-factory/update.js +3 -2
  43. package/lib/protocols/trade/exchange-v2.js +12 -5
  44. package/lib/protocols/trade/transfer-v3.js +4 -7
  45. package/lib/util.js +4 -1
  46. package/package.json +27 -29
  47. package/LICENSE +0 -13
@@ -1,5 +1,5 @@
1
1
  const pick = require('lodash/pick');
2
- const { promisify } = require('util');
2
+ const { promisify } = require('node:util');
3
3
  const isEmpty = require('empty-value');
4
4
  const { Joi, schemas } = require('@arcblock/validator');
5
5
  const { CustomError: Error } = require('@ocap/util/lib/error');
@@ -8,7 +8,6 @@ const { Runner, pipes } = require('@ocap/tx-pipeline');
8
8
  const { toStakeAddress } = require('@arcblock/did-util');
9
9
  const { account, asset, stake } = require('@ocap/state');
10
10
 
11
- // eslint-disable-next-line global-require
12
11
  const debug = require('debug')(`${require('../../../package.json').name}:stake`);
13
12
 
14
13
  const { applyTokenUpdates, applyTokenChange, isGasStakeAddress, isGasStakeInput } = require('../../util');
@@ -78,7 +77,9 @@ runner.use(pipes.ExtractState({ from: 'itx.address', to: 'stakeState', status: '
78
77
 
79
78
  // 5. verify sender & signer & receiver
80
79
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'OK', table: 'account' }));
81
- runner.use(pipes.ExtractState({ from: 'senders', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })); // prettier-ignore
80
+ runner.use(
81
+ pipes.ExtractState({ from: 'senders', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })
82
+ );
82
83
  runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
83
84
  runner.use(pipes.ExtractState({ from: 'itx.receiver', to: 'receiverState', status: 'INVALID_RECEIVER_STATE' })); // can by any type
84
85
  runner.use(pipes.VerifyBlocked({ stateKeys: ['signerStates', 'receiverState'] }));
@@ -108,7 +109,6 @@ runner.use(async (context, next) => {
108
109
  const signer = signerStates.find((x) => x.address === owner);
109
110
 
110
111
  try {
111
- // eslint-disable-next-line no-await-in-loop
112
112
  await verifyAssetOwner({ assets: states, owner: signer });
113
113
  } catch (err) {
114
114
  return next(err);
@@ -119,7 +119,14 @@ runner.use(async (context, next) => {
119
119
  });
120
120
 
121
121
  // ensure slashers exist and not migrated
122
- runner.use(pipes.ExtractState({ from: 'itx.slashersList', to: 'slasherStates', status: 'INVALID_SLASHER_STATE', table: 'account' })); // prettier-ignore
122
+ runner.use(
123
+ pipes.ExtractState({
124
+ from: 'itx.slashersList',
125
+ to: 'slasherStates',
126
+ status: 'INVALID_SLASHER_STATE',
127
+ table: 'account',
128
+ })
129
+ );
123
130
  runner.use(pipes.VerifyAccountMigration({ stateKey: 'slasherStates', addressKey: 'itx.slashersList' }));
124
131
 
125
132
  // 8. handle tx gas stakes
@@ -7,7 +7,6 @@ const { BN } = require('@ocap/util');
7
7
  const { Runner, pipes } = require('@ocap/tx-pipeline');
8
8
  const { account, stake, evidence, rollupBlock } = require('@ocap/state');
9
9
 
10
- // eslint-disable-next-line global-require
11
10
  const debug = require('debug')(`${require('../../../package.json').name}:claim-block-reward`);
12
11
 
13
12
  const { toStakeAddress } = require('@arcblock/did-util');
@@ -62,7 +61,9 @@ runner.use(({ evidenceSeen, blockClaimed }, next) => {
62
61
  runner.use(pipes.ExtractState({ from: 'itx.rollup', to: 'rollupState', status: 'INVALID_ROLLUP', table: 'rollup' }));
63
62
  runner.use(EnsureValidator());
64
63
  runner.use(VerifyStatus({ closed: false }));
65
- runner.use(pipes.ExtractState({ from: 'itx.blockHash', to: 'blockState', status: 'INVALID_ROLLUP_BLOCK', table: 'rollupBlock' })); // prettier-ignore
64
+ runner.use(
65
+ pipes.ExtractState({ from: 'itx.blockHash', to: 'blockState', status: 'INVALID_ROLLUP_BLOCK', table: 'rollupBlock' })
66
+ );
66
67
  runner.use((context, next) => {
67
68
  const { blockState, rollupState, itx } = context;
68
69
  if (blockState.rollup !== rollupState.address) {
@@ -91,16 +92,26 @@ runner.use(VerifySigners({ signersKey: 'tx.signaturesList', allowSender: true })
91
92
  runner.use(pipes.VerifyMultiSigV2({ signersKey: 'signers' }));
92
93
 
93
94
  // 5. verify block reward locker
94
- runner.use(pipes.ExtractState({ from: 'lockerAddress', to: 'lockerState', status: 'INVALID_LOCKER_STATE', table: 'stake' })); // prettier-ignore
95
- runner.use(pipes.ExtractState({ from: 'producerStake', to: 'stakeState', status: 'INVALID_STAKE_STATE', table: 'stake' })); // prettier-ignore
95
+ runner.use(
96
+ pipes.ExtractState({ from: 'lockerAddress', to: 'lockerState', status: 'INVALID_LOCKER_STATE', table: 'stake' })
97
+ );
98
+ runner.use(
99
+ pipes.ExtractState({ from: 'producerStake', to: 'stakeState', status: 'INVALID_STAKE_STATE', table: 'stake' })
100
+ );
96
101
 
97
102
  // 6. verify sender and signer states
98
- runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
99
- runner.use(pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })); // prettier-ignore
103
+ runner.use(
104
+ pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
105
+ );
106
+ runner.use(
107
+ pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })
108
+ );
100
109
  runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
101
110
 
102
111
  // 7. verify token state
103
- runner.use(pipes.ExtractState({ from: 'rollupState.tokenAddress', to: 'tokenState', status: 'INVALID_TOKEN', table: 'token' })); // prettier-ignore
112
+ runner.use(
113
+ pipes.ExtractState({ from: 'rollupState.tokenAddress', to: 'tokenState', status: 'INVALID_TOKEN', table: 'token' })
114
+ );
104
115
 
105
116
  // 8. split and aggregate block reward for each tx and the block
106
117
  runner.use(pipes.ExtractState({ from: 'blockState.txs', to: 'txs', status: 'INVALID_TX', table: 'tx' }));
@@ -203,7 +214,6 @@ runner.use((context, next) => {
203
214
  const requiredAccounts = Object.keys(updates.account);
204
215
  const knownAccounts = { [senderState.address]: senderState };
205
216
 
206
- // eslint-disable-next-line no-return-assign
207
217
  signerStates.forEach((x) => (knownAccounts[x.address] = x));
208
218
 
209
219
  context.missingAccounts = requiredAccounts.filter((x) => !knownAccounts[x]);
@@ -37,8 +37,12 @@ runner.use(VerifySigners({ signersKey: 'tx.signaturesList', allowSender: true })
37
37
  runner.use(pipes.VerifyMultiSigV2({ signersKey: 'signers' }));
38
38
 
39
39
  // 4. verify sender and signer states
40
- runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
41
- runner.use(pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })); // prettier-ignore
40
+ runner.use(
41
+ pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
42
+ );
43
+ runner.use(
44
+ pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })
45
+ );
42
46
  runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
43
47
 
44
48
  // 5. extract validator stake stakes
@@ -1,4 +1,3 @@
1
- /* eslint-disable indent */
2
1
  const pick = require('lodash/pick');
3
2
  const cloneDeep = require('lodash/cloneDeep');
4
3
  const { CustomError: Error } = require('@ocap/util/lib/error');
@@ -9,7 +8,6 @@ const { toStakeAddress } = require('@arcblock/did-util');
9
8
  const { Runner, pipes } = require('@ocap/tx-pipeline');
10
9
  const { account, stake, rollup, rollupBlock, tx: Tx } = require('@ocap/state');
11
10
 
12
- // eslint-disable-next-line global-require
13
11
  const debug = require('debug')(`${require('../../../package.json').name}:create-rollup-block`);
14
12
 
15
13
  const VerifySigners = require('./pipes/verify-signers');
@@ -134,8 +132,12 @@ runner.use(VerifySigners({ signersKey: 'tx.signaturesList', allowSender: true })
134
132
  runner.use(pipes.VerifyMultiSigV2({ signersKey: 'signers' }));
135
133
 
136
134
  // 4. verify sender and signer states
137
- runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
138
- runner.use(pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })); // prettier-ignore
135
+ runner.use(
136
+ pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
137
+ );
138
+ runner.use(
139
+ pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })
140
+ );
139
141
  runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
140
142
 
141
143
  // 5. verify previous block
@@ -271,7 +273,9 @@ runner.use((context, next) => {
271
273
 
272
274
  return next();
273
275
  });
274
- runner.use(pipes.ExtractState({ from: 'stakeAddress', to: 'stakeStates', status: 'INVALID_STAKE_STATE', table: 'stake' })); // prettier-ignore
276
+ runner.use(
277
+ pipes.ExtractState({ from: 'stakeAddress', to: 'stakeStates', status: 'INVALID_STAKE_STATE', table: 'stake' })
278
+ );
275
279
 
276
280
  // 10. ensure block reward and dynamic tx fees
277
281
  runner.use((context, next) => {
@@ -285,7 +289,9 @@ runner.use((context, next) => {
285
289
  return next(err);
286
290
  }
287
291
  });
288
- runner.use(pipes.ExtractState({ from: 'senders', to: 'senderStates', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
292
+ runner.use(
293
+ pipes.ExtractState({ from: 'senders', to: 'senderStates', status: 'INVALID_SENDER_STATE', table: 'account' })
294
+ );
289
295
 
290
296
  // Ensure tx fee and gas
291
297
  runner.use(
@@ -1,4 +1,3 @@
1
- /* eslint-disable indent */
2
1
  const isEmpty = require('empty-value');
3
2
  const cloneDeep = require('lodash/cloneDeep');
4
3
  const { CustomError: Error } = require('@ocap/util/lib/error');
@@ -8,7 +7,6 @@ const { formatMessage } = require('@ocap/message');
8
7
  const { isFromPublicKey, isEthereumDid } = require('@arcblock/did');
9
8
  const { toRollupAddress } = require('@arcblock/did-util');
10
9
 
11
- // eslint-disable-next-line global-require
12
10
  const debug = require('debug')(`${require('../../../package.json').name}:create-rollup`);
13
11
 
14
12
  const { decodeAnySafe, getDelegationRequirements } = require('../../util');
@@ -68,9 +66,20 @@ runner.use(
68
66
  );
69
67
 
70
68
  // 1. ensure sender, validators, delegation
71
- runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
72
- runner.use(pipes.ExtractState({ from: 'seedValidators', to: 'validatorStates', status: 'INVALID_VALIDATOR_STATE', table: 'account' })); // prettier-ignore
73
- runner.use(pipes.VerifyAccountMigration({ signerKey: 'validatorStates', stateKey: 'senderState', addressKey: 'tx.from' })); // prettier-ignore
69
+ runner.use(
70
+ pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
71
+ );
72
+ runner.use(
73
+ pipes.ExtractState({
74
+ from: 'seedValidators',
75
+ to: 'validatorStates',
76
+ status: 'INVALID_VALIDATOR_STATE',
77
+ table: 'account',
78
+ })
79
+ );
80
+ runner.use(
81
+ pipes.VerifyAccountMigration({ signerKey: 'validatorStates', stateKey: 'senderState', addressKey: 'tx.from' })
82
+ );
74
83
  runner.use(pipes.ExtractState({ from: 'tx.delegator', to: 'delegatorState', status: 'OK', table: 'account' }));
75
84
  runner.use(pipes.VerifyAccountMigration({ stateKey: 'delegatorState', addressKey: 'tx.delegator' }));
76
85
  runner.use(
@@ -1,4 +1,3 @@
1
- /* eslint-disable indent */
2
1
  const MerkleTree = require('@ocap/merkle-tree');
3
2
  const joinUrl = require('url-join');
4
3
  const { CustomError: Error } = require('@ocap/util/lib/error');
@@ -9,7 +8,6 @@ const { account, rollup, stake, evidence } = require('@ocap/state');
9
8
  const { toStakeAddress } = require('@arcblock/did-util');
10
9
  const { isEthereumDid } = require('@arcblock/did');
11
10
 
12
- // eslint-disable-next-line global-require
13
11
  const debug = require('debug')(`${require('../../../package.json').name}:join-rollup`);
14
12
 
15
13
  const VerifySigners = require('./pipes/verify-signers');
@@ -1,4 +1,3 @@
1
- /* eslint-disable indent */
2
1
  const MerkleTree = require('@ocap/merkle-tree');
3
2
  const { CustomError: Error } = require('@ocap/util/lib/error');
4
3
  const { Joi, schemas, patterns } = require('@arcblock/validator');
@@ -6,7 +5,6 @@ const { Runner, pipes } = require('@ocap/tx-pipeline');
6
5
  const { account, rollup, stake, evidence } = require('@ocap/state');
7
6
  const { toStakeAddress } = require('@arcblock/did-util');
8
7
 
9
- // eslint-disable-next-line global-require
10
8
  const debug = require('debug')(`${require('../../../package.json').name}:leave-rollup`);
11
9
 
12
10
  const VerifySigners = require('./pipes/verify-signers');
@@ -34,8 +34,12 @@ runner.use(VerifySigners({ signersKey: 'tx.signaturesList', allowSender: true })
34
34
  runner.use(pipes.VerifyMultiSigV2({ signersKey: 'signers' }));
35
35
 
36
36
  // 4. verify sender and signer states
37
- runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
38
- runner.use(pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })); // prettier-ignore
37
+ runner.use(
38
+ pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
39
+ );
40
+ runner.use(
41
+ pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })
42
+ );
39
43
  runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
40
44
 
41
45
  // Ensure tx fee and gas
@@ -31,8 +31,12 @@ runner.use(VerifySigners({ signersKey: 'tx.signaturesList', allowSender: true })
31
31
  runner.use(pipes.VerifyMultiSigV2({ signersKey: 'signers' }));
32
32
 
33
33
  // 4. verify sender and signer states
34
- runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
35
- runner.use(pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })); // prettier-ignore
34
+ runner.use(
35
+ pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
36
+ );
37
+ runner.use(
38
+ pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })
39
+ );
36
40
  runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
37
41
 
38
42
  // Ensure tx fee and gas
@@ -22,7 +22,6 @@ module.exports = function CreateVerifyEvidencePipe({ evidenceKey, signaturesKey,
22
22
  const wallet = fromPublicKey(pk, toTypeInfo(address));
23
23
 
24
24
  try {
25
- // eslint-disable-next-line no-await-in-loop
26
25
  if ((await wallet[verifyMethod](toHex(evidence), toHex(signature))) === false) {
27
26
  return next(new Error('INVALID_SIGNATURE', `Signature for evidence from ${address} is not valid`));
28
27
  }
@@ -4,8 +4,7 @@ const { CustomError: Error } = require('@ocap/util/lib/error');
4
4
  module.exports = function CreateVerifySignersPipe({ signersKey, allowSender = true, allowShrink = false }) {
5
5
  return (context, next) => {
6
6
  const { tx, rollupState } = context;
7
- // eslint-disable-next-line prefer-const
8
- let { minSignerCount, maxSignerCount } = rollupState;
7
+ const { minSignerCount, maxSignerCount } = rollupState;
9
8
 
10
9
  const signatures = get(context, signersKey);
11
10
  const signerCount = signatures.length;
@@ -31,8 +31,12 @@ runner.use(VerifySigners({ signersKey: 'tx.signaturesList', allowSender: true })
31
31
  runner.use(pipes.VerifyMultiSigV2({ signersKey: 'signers' }));
32
32
 
33
33
  // 4. verify sender and signer states
34
- runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
35
- runner.use(pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })); // prettier-ignore
34
+ runner.use(
35
+ pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
36
+ );
37
+ runner.use(
38
+ pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })
39
+ );
36
40
  runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
37
41
 
38
42
  // Ensure tx fee and gas
@@ -3,7 +3,6 @@ const { Joi } = require('@arcblock/validator');
3
3
  const { Runner, pipes } = require('@ocap/tx-pipeline');
4
4
  const { account, rollup } = require('@ocap/state');
5
5
 
6
- // eslint-disable-next-line global-require
7
6
  const debug = require('debug')(`${require('../../../package.json').name}:update-rollup`);
8
7
 
9
8
  const VerifySigners = require('./pipes/verify-signers');
@@ -29,7 +28,11 @@ const schema = Joi.object({
29
28
  minBlockSize: Joi.number().integer().min(1).required(),
30
29
  maxBlockSize: Joi.number().integer().min(1).max(10).greater(Joi.ref('minBlockSize')).required(),
31
30
 
32
- minBlockInterval: Joi.number().integer().min(1).max(60 * 60).required(), // prettier-ignore
31
+ minBlockInterval: Joi.number()
32
+ .integer()
33
+ .min(1)
34
+ .max(60 * 60)
35
+ .required(),
33
36
  minBlockConfirmation: Joi.number().integer().min(1).max(100).required(),
34
37
 
35
38
  minDepositAmount: Joi.BN().positive().required(),
@@ -8,7 +8,6 @@ const { account, token, delegation } = require('@ocap/state');
8
8
  const { toTokenAddress } = require('@arcblock/did-util');
9
9
  const { fromTokenToUnit } = require('@ocap/util');
10
10
 
11
- // eslint-disable-next-line global-require
12
11
  const debug = require('debug')(`${require('../../../package.json').name}:create-token`);
13
12
  const { decodeAnySafe, getDelegationRequirements } = require('../../util');
14
13
 
@@ -72,7 +71,9 @@ runner.use(
72
71
  );
73
72
 
74
73
  // Ensure sender exist
75
- runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
74
+ runner.use(
75
+ pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
76
+ );
76
77
  runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
77
78
 
78
79
  // Ensure delegation
@@ -1,4 +1,3 @@
1
- /* eslint-disable indent */
2
1
  const { CustomError: Error } = require('@ocap/util/lib/error');
3
2
  const { Joi, schemas, patterns } = require('@arcblock/validator');
4
3
  const { getListField } = require('@ocap/util/lib/get-list-field');
@@ -7,7 +6,6 @@ const { Runner, pipes } = require('@ocap/tx-pipeline');
7
6
  const { account, stake, evidence } = require('@ocap/state');
8
7
  const { toStakeAddress } = require('@arcblock/did-util');
9
8
 
10
- // eslint-disable-next-line global-require
11
9
  const debug = require('debug')(`${require('../../../package.json').name}:deposit-token`);
12
10
 
13
11
  const EnsureTxGas = require('../../pipes/ensure-gas');
@@ -87,7 +85,9 @@ runner.use(VerifySigners({ signersKey: 'tx.signaturesList', allowSender: true })
87
85
  runner.use(pipes.VerifyMultiSigV2({ signersKey: 'signers' }));
88
86
 
89
87
  // 5. verify token state
90
- runner.use(pipes.ExtractState({ from: 'itx.token.address', to: 'tokenState', status: 'INVALID_TOKEN', table: 'token' })); // prettier-ignore
88
+ runner.use(
89
+ pipes.ExtractState({ from: 'itx.token.address', to: 'tokenState', status: 'INVALID_TOKEN', table: 'token' })
90
+ );
91
91
 
92
92
  // 6. verify staking: get address, extract state, verify amount
93
93
  runner.use((context, next) => {
@@ -97,7 +97,9 @@ runner.use((context, next) => {
97
97
  return next();
98
98
  });
99
99
  runner.use(pipes.ExtractState({ from: 'lockerAddress', to: 'lockerState', status: 'OK', table: 'stake' }));
100
- runner.use(pipes.ExtractState({ from: 'stakeAddress', to: 'stakeState', status: 'INVALID_STAKE_STATE', table: 'stake' })); // prettier-ignore
100
+ runner.use(
101
+ pipes.ExtractState({ from: 'stakeAddress', to: 'stakeState', status: 'INVALID_STAKE_STATE', table: 'stake' })
102
+ );
101
103
  runner.use((context, next) => {
102
104
  const { itx, stakeState, tokenState, rollupState } = context;
103
105
  if (stakeState.revocable === true) {
@@ -160,7 +162,9 @@ runner.use((context, next) => {
160
162
 
161
163
  // 7. verify sender and signer exists and not migrated
162
164
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'OK', table: 'account' }));
163
- runner.use(pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })); // prettier-ignore
165
+ runner.use(
166
+ pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })
167
+ );
164
168
  runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
165
169
 
166
170
  // Ensure tx fee and gas
@@ -1,4 +1,3 @@
1
- /* eslint-disable indent */
2
1
  const { CustomError: Error } = require('@ocap/util/lib/error');
3
2
  const { Joi, schemas } = require('@arcblock/validator');
4
3
  const { getListField } = require('@ocap/util/lib/get-list-field');
@@ -7,7 +6,6 @@ const { Runner, pipes } = require('@ocap/tx-pipeline');
7
6
  const { account, stake } = require('@ocap/state');
8
7
  const { toStakeAddress } = require('@arcblock/did-util');
9
8
 
10
- // eslint-disable-next-line global-require
11
9
  const debug = require('debug')(`${require('../../../package.json').name}:withdraw-token`);
12
10
 
13
11
  const EnsureTxGas = require('../../pipes/ensure-gas');
@@ -57,10 +55,14 @@ runner.use((context, next) => {
57
55
  });
58
56
 
59
57
  // 3. verify token state
60
- runner.use(pipes.ExtractState({ from: 'itx.token.address', to: 'tokenState', status: 'INVALID_TOKEN', table: 'token' })); // prettier-ignore
58
+ runner.use(
59
+ pipes.ExtractState({ from: 'itx.token.address', to: 'tokenState', status: 'INVALID_TOKEN', table: 'token' })
60
+ );
61
61
 
62
62
  // 4. verify sender and signer states
63
- runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
63
+ runner.use(
64
+ pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
65
+ );
64
66
 
65
67
  // 5. verify amount
66
68
  runner.use((context, next) => {
@@ -120,7 +122,6 @@ runner.use((context, next) => {
120
122
  });
121
123
 
122
124
  // 7. verify maxFee and conditional multi-sig
123
- // eslint-disable-next-line consistent-return
124
125
  runner.use((context, next) => {
125
126
  const { tx, itx } = context;
126
127
  const isFixedFee = new BN(itx.maxFee).isZero();
@@ -146,7 +147,9 @@ runner.use((context, next) => {
146
147
  });
147
148
 
148
149
  // 7. verify signers (sender + proposer)
149
- runner.use(pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })); // prettier-ignore
150
+ runner.use(
151
+ pipes.ExtractState({ from: 'signers', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })
152
+ );
150
153
  runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
151
154
 
152
155
  // 8. verify staking: user withdraw is locked in stake
@@ -88,7 +88,9 @@ runner.use((context, next) => {
88
88
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'OK', table: 'account' }));
89
89
  runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
90
90
 
91
- runner.use(pipes.ExtractState({ from: 'senders', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })); // prettier-ignore
91
+ runner.use(
92
+ pipes.ExtractState({ from: 'senders', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })
93
+ );
92
94
  runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
93
95
 
94
96
  // ensure receiver
@@ -8,7 +8,6 @@ const { account, token, tokenFactory, delegation, stake } = require('@ocap/state
8
8
  const { toTokenFactoryAddress, toTokenAddress, toStakeAddress } = require('@arcblock/did-util');
9
9
  const { BN, fromTokenToUnit, fromUnitToToken } = require('@ocap/util');
10
10
 
11
- // eslint-disable-next-line global-require, import/order
12
11
  const debug = require('debug')(`${require('../../../package.json').name}:create-token-factory`);
13
12
  const { applyTokenChange, decodeAnySafe, getDelegationRequirements } = require('../../util');
14
13
 
@@ -162,7 +161,9 @@ runner.use(
162
161
  );
163
162
 
164
163
  // Ensure sender exist
165
- runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
164
+ runner.use(
165
+ pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
166
+ );
166
167
  runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
167
168
 
168
169
  runner.use(pipes.VerifyBlocked({ stateKeys: ['senderState'] }));
@@ -93,7 +93,10 @@ runner.use(
93
93
 
94
94
  // ensure sender
95
95
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'OK', table: 'account' }));
96
- runner.use(pipes.ExtractState({ from: 'senders', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' }), { shouldSkip: ({ tokenFactoryState }) => !tokenFactoryState.curve, }); // prettier-ignore
96
+ runner.use(
97
+ pipes.ExtractState({ from: 'senders', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' }),
98
+ { shouldSkip: ({ tokenFactoryState }) => !tokenFactoryState.curve }
99
+ );
97
100
  runner.use(
98
101
  pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }),
99
102
  { shouldSkip: ({ tokenFactoryState }) => !tokenFactoryState.curve }
@@ -4,7 +4,6 @@ const { Runner, pipes } = require('@ocap/tx-pipeline');
4
4
  const { account, tokenFactory, delegation, token } = require('@ocap/state');
5
5
  const { applyTokenChange, getDelegationRequirements, decodeAnySafe } = require('../../util');
6
6
 
7
- // eslint-disable-next-line global-require, import/order
8
7
  const debug = require('debug')(`${require('../../../package.json').name}:update-token-factory`);
9
8
 
10
9
  const EnsureTxGas = require('../../pipes/ensure-gas');
@@ -91,7 +90,9 @@ runner.use((context, next) => {
91
90
  runner.use(verifyOwnership({ tokenKey: 'itxToken' }));
92
91
 
93
92
  // Ensure sender
94
- runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
93
+ runner.use(
94
+ pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
95
+ );
95
96
  runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
96
97
  runner.use(pipes.VerifyBlocked({ stateKeys: ['senderState'] }));
97
98
 
@@ -8,7 +8,6 @@ const { BN } = require('@ocap/util');
8
8
  const { Runner, pipes } = require('@ocap/tx-pipeline');
9
9
  const { account } = require('@ocap/state');
10
10
 
11
- // eslint-disable-next-line global-require
12
11
  const debug = require('debug')(`${require('../../../package.json').name}:exchange-v2`);
13
12
 
14
13
  const EnsureTxGas = require('../../pipes/ensure-gas');
@@ -87,7 +86,9 @@ runner.use(pipes.VerifySigner({ signer: 'itx.to' }));
87
86
  runner.use(pipes.VerifyListSize({ listKey: ['senderAssets', 'receiverAssets'] }));
88
87
  runner.use(pipes.VerifyListSize({ listKey: ['senderTokens', 'receiverTokens'] }));
89
88
 
90
- runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })); // prettier-ignore
89
+ runner.use(
90
+ pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
91
+ );
91
92
  runner.use(pipes.ExtractState({ from: 'tx.delegator', to: 'delegatorState', status: 'OK', table: 'account' }));
92
93
  runner.use(pipes.VerifyDelegation({ type: 'signature', signerKey: 'senderState', delegatorKey: 'delegatorState' }));
93
94
  runner.use(pipes.ExtractSigner({ signerKey: 'signerStates', delegatorKey: 'delegatorStates' }));
@@ -104,7 +105,9 @@ runner.use(
104
105
 
105
106
  runner.use(pipes.ExtractState({ from: 'tokenAddress', to: 'tokenStates', status: 'INVALID_TOKEN', table: 'token' }));
106
107
 
107
- runner.use(pipes.ExtractState({ from: 'receiver', to: 'receiverState', status: 'INVALID_RECEIVER_STATE', table: 'account' })); // prettier-ignore
108
+ runner.use(
109
+ pipes.ExtractState({ from: 'receiver', to: 'receiverState', status: 'INVALID_RECEIVER_STATE', table: 'account' })
110
+ );
108
111
  runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
109
112
  runner.use((context, next) => {
110
113
  context.senderTokenConditions = {
@@ -131,11 +134,15 @@ runner.use(
131
134
  })
132
135
  );
133
136
 
134
- runner.use(pipes.ExtractState({ from: 'senderAssets', to: 'priv.senderAssets', status: 'INVALID_ASSET', table: 'asset' })); // prettier-ignore
137
+ runner.use(
138
+ pipes.ExtractState({ from: 'senderAssets', to: 'priv.senderAssets', status: 'INVALID_ASSET', table: 'asset' })
139
+ );
135
140
  runner.use(pipes.VerifyTransferrable({ assets: 'priv.senderAssets' }));
136
141
  runner.use(pipes.VerifyUpdater({ assetKey: 'priv.senderAssets', ownerKey: 'senderState' }));
137
142
 
138
- runner.use(pipes.ExtractState({ from: 'receiverAssets', to: 'priv.receiverAssets', status: 'INVALID_ASSET', table: 'asset' })); // prettier-ignore
143
+ runner.use(
144
+ pipes.ExtractState({ from: 'receiverAssets', to: 'priv.receiverAssets', status: 'INVALID_ASSET', table: 'asset' })
145
+ );
139
146
  runner.use(pipes.VerifyTransferrable({ assets: 'priv.receiverAssets' }));
140
147
  runner.use(pipes.VerifyUpdater({ assetKey: 'priv.receiverAssets', ownerKey: 'receiverState' }));
141
148
 
@@ -1,7 +1,4 @@
1
- /* eslint-disable function-paren-newline */
2
- /* eslint-disable prefer-object-spread */
3
- /* eslint-disable no-restricted-syntax */
4
- const { promisify } = require('util');
1
+ const { promisify } = require('node:util');
5
2
  const isEqual = require('lodash/isEqual');
6
3
  const { CustomError: Error } = require('@ocap/util/lib/error');
7
4
  const { Joi, schemas } = require('@arcblock/validator');
@@ -10,7 +7,6 @@ const { Runner, pipes } = require('@ocap/tx-pipeline');
10
7
  const { account, asset } = require('@ocap/state');
11
8
  const { getRelatedAddresses } = require('@ocap/util/lib/get-related-addr');
12
9
 
13
- // eslint-disable-next-line global-require
14
10
  const debug = require('debug')(`${require('../../../package.json').name}:transfer-v2`);
15
11
 
16
12
  const EnsureTxGas = require('../../pipes/ensure-gas');
@@ -146,7 +142,9 @@ runner.use((context, next) => {
146
142
 
147
143
  // 4. verify sender & signer & receiver
148
144
  runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'OK', table: 'account' }));
149
- runner.use(pipes.ExtractState({ from: 'senders', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })); // prettier-ignore
145
+ runner.use(
146
+ pipes.ExtractState({ from: 'senders', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })
147
+ );
150
148
  runner.use(pipes.ExtractState({ from: 'receivers', to: 'receiverStates', status: 'OK', table: 'account' }));
151
149
  runner.use(pipes.VerifyBlocked({ stateKeys: ['signerStates', 'receiverStates'] }));
152
150
  runner.use(pipes.AntiLandAttack({ senderState: 'signerStates', receiverState: 'receiverStates' }));
@@ -174,7 +172,6 @@ runner.use(async (context, next) => {
174
172
  const signer = signerStates.find((x) => x.address === owner);
175
173
 
176
174
  try {
177
- // eslint-disable-next-line no-await-in-loop
178
175
  await verifyAssetOwner({ assets: states, owner: signer });
179
176
  } catch (err) {
180
177
  return next(err);
package/lib/util.js CHANGED
@@ -221,7 +221,10 @@ const splitTxFee = ({ total, shares = {}, stringify = true, rateBase = RATE_BASE
221
221
  };
222
222
 
223
223
  const getRewardLocker = (rollupAddress) => toStakeAddress(rollupAddress, rollupAddress);
224
- const getBNSum = (...args) => flattenDeep(args).reduce((sum, x) => sum.add(new BN(x)), new BN(0)).toString(10); // prettier-ignore
224
+ const getBNSum = (...args) =>
225
+ flattenDeep(args)
226
+ .reduce((sum, x) => sum.add(new BN(x)), new BN(0))
227
+ .toString(10);
225
228
  const isGovernanceTx = (x) => ['pause_rollup', 'resume_rollup', 'migrate_rollup'].includes(x.type);
226
229
  const isFixedFee = (x) => !x.tx.itxJson.maxFee || new BN(x.tx.itxJson.maxFee).isZero();
227
230