@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.
- package/README.md +1 -1
- package/lib/execute.js +0 -3
- package/lib/pipes/ensure-cost.js +0 -1
- package/lib/pipes/ensure-gas.js +0 -1
- package/lib/protocols/account/delegate.js +3 -5
- package/lib/protocols/account/migrate.js +1 -2
- package/lib/protocols/account/revoke-delegate.js +6 -3
- package/lib/protocols/asset/acquire-v2.js +26 -8
- package/lib/protocols/asset/acquire-v3.js +27 -12
- package/lib/protocols/asset/calls/transfer-token.js +0 -1
- package/lib/protocols/asset/calls/transfer.js +0 -1
- package/lib/protocols/asset/consume.js +9 -4
- package/lib/protocols/asset/create.js +6 -4
- package/lib/protocols/asset/mint.js +22 -6
- package/lib/protocols/asset/pipes/exec-mint-hook.js +0 -1
- package/lib/protocols/asset/pipes/verify-itx-assets.js +0 -1
- package/lib/protocols/asset/update.js +3 -2
- package/lib/protocols/factory/create.js +20 -7
- package/lib/protocols/governance/claim-stake.js +9 -4
- package/lib/protocols/governance/return-stake.js +9 -4
- package/lib/protocols/governance/revoke-stake.js +9 -4
- package/lib/protocols/governance/slash-stake.js +17 -5
- package/lib/protocols/governance/stake.js +12 -5
- package/lib/protocols/rollup/claim-reward.js +18 -8
- package/lib/protocols/rollup/close.js +6 -2
- package/lib/protocols/rollup/create-block.js +12 -6
- package/lib/protocols/rollup/create.js +14 -5
- package/lib/protocols/rollup/join.js +0 -2
- package/lib/protocols/rollup/leave.js +0 -2
- package/lib/protocols/rollup/migrate.js +6 -2
- package/lib/protocols/rollup/pause.js +6 -2
- package/lib/protocols/rollup/pipes/verify-evidence.js +0 -1
- package/lib/protocols/rollup/pipes/verify-signers.js +1 -2
- package/lib/protocols/rollup/resume.js +6 -2
- package/lib/protocols/rollup/update.js +5 -2
- package/lib/protocols/token/create.js +3 -2
- package/lib/protocols/token/deposit-v2.js +9 -5
- package/lib/protocols/token/withdraw-v2.js +9 -6
- package/lib/protocols/token-factory/burn.js +3 -1
- package/lib/protocols/token-factory/create.js +3 -2
- package/lib/protocols/token-factory/mint.js +4 -1
- package/lib/protocols/token-factory/update.js +3 -2
- package/lib/protocols/trade/exchange-v2.js +12 -5
- package/lib/protocols/trade/transfer-v3.js +4 -7
- package/lib/util.js +4 -1
- package/package.json +27 -29
- package/LICENSE +0 -13
package/README.md
CHANGED
package/lib/execute.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable consistent-return */
|
|
2
1
|
const get = require('lodash/get');
|
|
3
2
|
const pick = require('lodash/pick');
|
|
4
3
|
const merge = require('lodash/merge');
|
|
@@ -90,7 +89,6 @@ module.exports = ({ filter, runAsLambda }) => {
|
|
|
90
89
|
});
|
|
91
90
|
};
|
|
92
91
|
|
|
93
|
-
// eslint-disable-next-line require-await
|
|
94
92
|
const execute = async (context, protocols, isRetrySupported = false) =>
|
|
95
93
|
new Promise((resolve, reject) => {
|
|
96
94
|
pre.run(context, (err) => {
|
|
@@ -109,7 +107,6 @@ module.exports = ({ filter, runAsLambda }) => {
|
|
|
109
107
|
return reject(new Error('UNSUPPORTED_TX', `Unsupported tx type ${context.txType}`));
|
|
110
108
|
}
|
|
111
109
|
|
|
112
|
-
// eslint-disable-next-line no-shadow
|
|
113
110
|
protocol.run(context, async (error) => {
|
|
114
111
|
if (isRetrySupported) {
|
|
115
112
|
if (error) {
|
package/lib/pipes/ensure-cost.js
CHANGED
|
@@ -6,7 +6,6 @@ const { account } = require('@ocap/state');
|
|
|
6
6
|
const { toAddress } = require('@arcblock/did');
|
|
7
7
|
const { toStakeAddress } = require('@arcblock/did-util');
|
|
8
8
|
|
|
9
|
-
// eslint-disable-next-line global-require
|
|
10
9
|
const debug = require('debug')(`${require('../../package.json').name}:pipes:ensure-cost`);
|
|
11
10
|
|
|
12
11
|
const { applyTokenUpdates, isGasStakeValid } = require('../util');
|
package/lib/pipes/ensure-gas.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable max-len */
|
|
2
1
|
const get = require('lodash/get');
|
|
3
2
|
const cloneDeep = require('lodash/cloneDeep');
|
|
4
3
|
const pick = require('lodash/pick');
|
|
@@ -9,7 +8,6 @@ const { Runner, pipes } = require('@ocap/tx-pipeline');
|
|
|
9
8
|
const { toDelegateAddress } = require('@arcblock/did-util');
|
|
10
9
|
const { formatMessage } = require('@ocap/message');
|
|
11
10
|
|
|
12
|
-
// eslint-disable-next-line global-require
|
|
13
11
|
const debug = require('debug')(`${require('../../../package.json').name}:delegate`);
|
|
14
12
|
|
|
15
13
|
const EnsureTxGas = require('../../pipes/ensure-gas');
|
|
@@ -101,7 +99,7 @@ runner.use(
|
|
|
101
99
|
);
|
|
102
100
|
|
|
103
101
|
// Ensure sender exist and not migrated
|
|
104
|
-
runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'OK', table: 'account' }));
|
|
102
|
+
runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'OK', table: 'account' }));
|
|
105
103
|
runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
|
|
106
104
|
|
|
107
105
|
// Ensure receiver exist and not migrated
|
|
@@ -202,8 +200,8 @@ runner.use(
|
|
|
202
200
|
),
|
|
203
201
|
|
|
204
202
|
delegationState
|
|
205
|
-
? statedb.delegation.update(itx.address, delegation.update(delegationState, { ...itx, from: sender, ops: merged }, context), context)
|
|
206
|
-
: statedb.delegation.create(itx.address, delegation.create({ ...itx, from: sender, ops: merged }, context), context),
|
|
203
|
+
? statedb.delegation.update(itx.address, delegation.update(delegationState, { ...itx, from: sender, ops: merged }, context), context)
|
|
204
|
+
: statedb.delegation.create(itx.address, delegation.create({ ...itx, from: sender, ops: merged }, context), context),
|
|
207
205
|
]);
|
|
208
206
|
|
|
209
207
|
await updateVaults();
|
|
@@ -10,7 +10,6 @@ const {
|
|
|
10
10
|
types: { RoleType },
|
|
11
11
|
} = require('@ocap/mcrypto');
|
|
12
12
|
|
|
13
|
-
// eslint-disable-next-line global-require
|
|
14
13
|
const debug = require('debug')(`${require('../../../package.json').name}:migrate`);
|
|
15
14
|
|
|
16
15
|
const EnsureTxGas = require('../../pipes/ensure-gas');
|
|
@@ -45,7 +44,7 @@ runner.use(
|
|
|
45
44
|
);
|
|
46
45
|
|
|
47
46
|
// Ensure sender exist
|
|
48
|
-
runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'OK', table: 'account' }));
|
|
47
|
+
runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'OK', table: 'account' }));
|
|
49
48
|
runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
|
|
50
49
|
|
|
51
50
|
// Ensure tx fee and gas
|
|
@@ -7,7 +7,6 @@ const { Runner, pipes } = require('@ocap/tx-pipeline');
|
|
|
7
7
|
const { delegation, account } = require('@ocap/state');
|
|
8
8
|
const { toDelegateAddress } = require('@arcblock/did-util');
|
|
9
9
|
|
|
10
|
-
// eslint-disable-next-line global-require
|
|
11
10
|
const debug = require('debug')(`${require('../../../package.json').name}:delegate`);
|
|
12
11
|
|
|
13
12
|
const EnsureTxGas = require('../../pipes/ensure-gas');
|
|
@@ -57,8 +56,12 @@ runner.use(
|
|
|
57
56
|
);
|
|
58
57
|
|
|
59
58
|
// Ensure sender/receiver/delegation exist
|
|
60
|
-
runner.use(
|
|
61
|
-
|
|
59
|
+
runner.use(
|
|
60
|
+
pipes.ExtractState({ from: 'itx.address', to: 'delegationState', status: 'INVALID_DELEGATION', table: 'delegation' })
|
|
61
|
+
);
|
|
62
|
+
runner.use(
|
|
63
|
+
pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
|
|
64
|
+
);
|
|
62
65
|
runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
|
|
63
66
|
|
|
64
67
|
// Ensure tx fee and gas
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
const { promisify } = require('util');
|
|
1
|
+
const { promisify } = require('node:util');
|
|
3
2
|
const { Runner, pipes } = require('@ocap/tx-pipeline');
|
|
4
3
|
const { account, asset, factory, delegation } = require('@ocap/state');
|
|
5
4
|
const { CustomError: Error } = require('@ocap/util/lib/error');
|
|
6
5
|
const { Joi, schemas } = require('@arcblock/validator');
|
|
7
6
|
|
|
8
|
-
// eslint-disable-next-line global-require
|
|
9
7
|
const debug = require('debug')(`${require('../../../package.json').name}:acquire-asset-v2`);
|
|
10
8
|
|
|
11
9
|
// custom pipes
|
|
@@ -57,11 +55,15 @@ runner.use(
|
|
|
57
55
|
])
|
|
58
56
|
);
|
|
59
57
|
|
|
60
|
-
runner.use(
|
|
58
|
+
runner.use(
|
|
59
|
+
pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
|
|
60
|
+
);
|
|
61
61
|
runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
|
|
62
62
|
|
|
63
63
|
runner.use(pipes.ExtractState({ from: 'tx.delegator', to: 'delegatorState', status: 'OK' }));
|
|
64
|
-
runner.use(
|
|
64
|
+
runner.use(
|
|
65
|
+
pipes.ExtractState({ from: 'itx.factory', to: 'factoryState', status: 'INVALID_FACTORY_STATE', table: 'factory' })
|
|
66
|
+
);
|
|
65
67
|
runner.use(
|
|
66
68
|
pipes.VerifyDelegation({
|
|
67
69
|
type: 'signature',
|
|
@@ -71,9 +73,25 @@ runner.use(
|
|
|
71
73
|
})
|
|
72
74
|
);
|
|
73
75
|
|
|
74
|
-
runner.use(
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
runner.use(
|
|
77
|
+
pipes.ExtractState({
|
|
78
|
+
from: 'factoryState.owner',
|
|
79
|
+
to: 'factoryOwnerState',
|
|
80
|
+
status: 'INVALID_OWNER_STATE',
|
|
81
|
+
table: 'account',
|
|
82
|
+
})
|
|
83
|
+
);
|
|
84
|
+
runner.use(
|
|
85
|
+
pipes.ExtractState({
|
|
86
|
+
from: 'factoryState.trustedIssuers',
|
|
87
|
+
to: 'issuerStates',
|
|
88
|
+
status: 'INVALID_ISSUER_STATE',
|
|
89
|
+
table: 'account',
|
|
90
|
+
})
|
|
91
|
+
);
|
|
92
|
+
runner.use(
|
|
93
|
+
pipes.ExtractState({ from: 'itx.issuer.id', to: 'issuerState', status: 'INVALID_ISSUER_STATE', table: 'account' })
|
|
94
|
+
);
|
|
77
95
|
runner.use(pipes.VerifyAccountMigration({ stateKey: 'issuerState', addressKey: 'itx.issuer.id' }));
|
|
78
96
|
|
|
79
97
|
runner.use(
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
/* eslint-disable prefer-object-spread */
|
|
3
|
-
/* eslint-disable function-paren-newline */
|
|
4
|
-
const { promisify } = require('util');
|
|
1
|
+
const { promisify } = require('node:util');
|
|
5
2
|
const isEqual = require('lodash/isEqual');
|
|
6
3
|
const { BN } = require('@ocap/util');
|
|
7
4
|
const { Runner, pipes } = require('@ocap/tx-pipeline');
|
|
@@ -9,7 +6,6 @@ const { account, asset, factory } = require('@ocap/state');
|
|
|
9
6
|
const { CustomError: Error } = require('@ocap/util/lib/error');
|
|
10
7
|
const { Joi, schemas } = require('@arcblock/validator');
|
|
11
8
|
|
|
12
|
-
// eslint-disable-next-line global-require
|
|
13
9
|
const debug = require('debug')(`${require('../../../package.json').name}:acquire-asset-v3`);
|
|
14
10
|
|
|
15
11
|
const { applyTokenUpdates, applyTokenChange } = require('../../util');
|
|
@@ -76,10 +72,28 @@ runner.use(pipes.VerifyListSize({ listKey: ['inputs', 'senders', 'tokens', 'asse
|
|
|
76
72
|
runner.use(pipes.VerifyMultiSigV2({ signersKey: 'senders' }));
|
|
77
73
|
|
|
78
74
|
// 4. verify against factory state
|
|
79
|
-
runner.use(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
runner.use(
|
|
75
|
+
runner.use(
|
|
76
|
+
pipes.ExtractState({ from: 'itx.factory', to: 'factoryState', status: 'INVALID_FACTORY_STATE', table: 'factory' })
|
|
77
|
+
);
|
|
78
|
+
runner.use(
|
|
79
|
+
pipes.ExtractState({
|
|
80
|
+
from: 'factoryState.owner',
|
|
81
|
+
to: 'factoryOwnerState',
|
|
82
|
+
status: 'INVALID_OWNER_STATE',
|
|
83
|
+
table: 'account',
|
|
84
|
+
})
|
|
85
|
+
);
|
|
86
|
+
runner.use(
|
|
87
|
+
pipes.ExtractState({
|
|
88
|
+
from: 'factoryState.trustedIssuers',
|
|
89
|
+
to: 'issuerStates',
|
|
90
|
+
status: 'INVALID_ISSUER_STATE',
|
|
91
|
+
table: 'account',
|
|
92
|
+
})
|
|
93
|
+
);
|
|
94
|
+
runner.use(
|
|
95
|
+
pipes.ExtractState({ from: 'itx.issuer.id', to: 'issuerState', status: 'INVALID_ISSUER_STATE', table: 'account' })
|
|
96
|
+
);
|
|
83
97
|
runner.use(pipes.VerifyAccountMigration({ stateKey: 'issuerState', addressKey: 'itx.issuer.id' }));
|
|
84
98
|
runner.use(
|
|
85
99
|
pipes.VerifyInfo([
|
|
@@ -133,8 +147,10 @@ runner.use(
|
|
|
133
147
|
);
|
|
134
148
|
|
|
135
149
|
// 5. verify sender & signer & owner
|
|
136
|
-
runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'OK', table: 'account' }));
|
|
137
|
-
runner.use(
|
|
150
|
+
runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'OK', table: 'account' }));
|
|
151
|
+
runner.use(
|
|
152
|
+
pipes.ExtractState({ from: 'senders', to: 'signerStates', status: 'INVALID_SIGNER_STATE', table: 'account' })
|
|
153
|
+
);
|
|
138
154
|
runner.use(pipes.ExtractState({ from: 'itx.owner', to: 'ownerState', status: 'OK', table: 'account' }));
|
|
139
155
|
runner.use(pipes.VerifyAccountMigration({ signerKey: 'signerStates', stateKey: 'senderState', addressKey: 'tx.from' }));
|
|
140
156
|
runner.use(pipes.VerifyBlocked({ stateKeys: ['signerStates', 'ownerState'] }));
|
|
@@ -153,7 +169,6 @@ runner.use(async (context, next) => {
|
|
|
153
169
|
const signer = signerStates.find((x) => x.address === owner);
|
|
154
170
|
|
|
155
171
|
try {
|
|
156
|
-
// eslint-disable-next-line no-await-in-loop
|
|
157
172
|
await verifyAssetOwner({ assets: states, owner: signer });
|
|
158
173
|
} catch (err) {
|
|
159
174
|
return next(err);
|
|
@@ -2,7 +2,6 @@ const cloneDeep = require('lodash/cloneDeep');
|
|
|
2
2
|
const { BN } = require('@ocap/util');
|
|
3
3
|
const { Runner, pipes } = require('@ocap/tx-pipeline');
|
|
4
4
|
|
|
5
|
-
// eslint-disable-next-line global-require
|
|
6
5
|
const debug = require('debug')(`${require('../../../../package.json').name}:acquire-asset:transfer-token`);
|
|
7
6
|
|
|
8
7
|
const runner = new Runner();
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const { BN } = require('@ocap/util');
|
|
2
2
|
const { Runner, pipes } = require('@ocap/tx-pipeline');
|
|
3
3
|
|
|
4
|
-
// eslint-disable-next-line global-require
|
|
5
4
|
const debug = require('debug')(`${require('../../../../package.json').name}:acquire-asset:transfer`);
|
|
6
5
|
|
|
7
6
|
const runner = new Runner();
|
|
@@ -3,7 +3,6 @@ const { Joi } = require('@arcblock/validator');
|
|
|
3
3
|
const { Runner, pipes } = require('@ocap/tx-pipeline');
|
|
4
4
|
const { account, asset } = require('@ocap/state');
|
|
5
5
|
|
|
6
|
-
// eslint-disable-next-line global-require
|
|
7
6
|
const debug = require('debug')(`${require('../../../package.json').name}:consume-asset`);
|
|
8
7
|
|
|
9
8
|
const EnsureTxGas = require('../../pipes/ensure-gas');
|
|
@@ -43,12 +42,18 @@ runner.use((context, next) => {
|
|
|
43
42
|
});
|
|
44
43
|
|
|
45
44
|
// Ensure sender exist
|
|
46
|
-
runner.use(
|
|
45
|
+
runner.use(
|
|
46
|
+
pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
|
|
47
|
+
);
|
|
47
48
|
runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
|
|
48
49
|
|
|
49
50
|
// Ensure owner/issuer exist
|
|
50
|
-
runner.use(
|
|
51
|
-
|
|
51
|
+
runner.use(
|
|
52
|
+
pipes.ExtractState({ from: 'assetState.issuer', to: 'issuerState', status: 'INVALID_ISSUER_STATE', table: 'account' })
|
|
53
|
+
);
|
|
54
|
+
runner.use(
|
|
55
|
+
pipes.ExtractState({ from: 'assetState.owner', to: 'ownerState', status: 'INVALID_OWNER_STATE', table: 'account' })
|
|
56
|
+
);
|
|
52
57
|
runner.use((context, next) => {
|
|
53
58
|
context.signerStates = [context.ownerState, context.issuerState];
|
|
54
59
|
context.signers = [context.ownerState.address, context.issuerState.address];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable indent */
|
|
2
1
|
const { CustomError: Error } = require('@ocap/util/lib/error');
|
|
3
2
|
const cloneDeep = require('lodash/cloneDeep');
|
|
4
3
|
const { Runner, pipes } = require('@ocap/tx-pipeline');
|
|
@@ -6,7 +5,6 @@ const { account, asset, delegation } = require('@ocap/state');
|
|
|
6
5
|
const { formatMessage } = require('@ocap/message');
|
|
7
6
|
const { toAssetAddress } = require('@arcblock/did-util');
|
|
8
7
|
|
|
9
|
-
// eslint-disable-next-line global-require
|
|
10
8
|
const debug = require('debug')(`${require('../../../package.json').name}:create-asset`);
|
|
11
9
|
|
|
12
10
|
const { decodeAnySafe, getDelegationRequirements } = require('../../util');
|
|
@@ -61,11 +59,15 @@ runner.use(
|
|
|
61
59
|
);
|
|
62
60
|
|
|
63
61
|
// Ensure issuer exist
|
|
64
|
-
runner.use(
|
|
62
|
+
runner.use(
|
|
63
|
+
pipes.ExtractState({ from: 'itx.issuer', to: 'issuerState', status: 'INVALID_ISSUER_STATE', table: 'account' })
|
|
64
|
+
);
|
|
65
65
|
runner.use(pipes.VerifyAccountMigration({ signerKey: 'issuerState' }));
|
|
66
66
|
|
|
67
67
|
// Ensure sender exist
|
|
68
|
-
runner.use(
|
|
68
|
+
runner.use(
|
|
69
|
+
pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
|
|
70
|
+
);
|
|
69
71
|
runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
|
|
70
72
|
|
|
71
73
|
// Ensure delegation
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
/* eslint-disable function-paren-newline */
|
|
2
1
|
const { Runner, pipes } = require('@ocap/tx-pipeline');
|
|
3
2
|
const { CustomError: Error } = require('@ocap/util/lib/error');
|
|
4
3
|
const { Joi, schemas } = require('@arcblock/validator');
|
|
5
4
|
const { account, asset, factory } = require('@ocap/state');
|
|
6
5
|
|
|
7
|
-
// eslint-disable-next-line global-require
|
|
8
6
|
const debug = require('debug')(`${require('../../../package.json').name}:mint-asset`);
|
|
9
7
|
|
|
10
8
|
const verifyMintLimit = require('./pipes/verify-mint-limit');
|
|
@@ -50,15 +48,33 @@ runner.use(
|
|
|
50
48
|
);
|
|
51
49
|
|
|
52
50
|
// Ensure sender exist
|
|
53
|
-
runner.use(
|
|
51
|
+
runner.use(
|
|
52
|
+
pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
|
|
53
|
+
);
|
|
54
54
|
runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
|
|
55
55
|
|
|
56
56
|
// Ensure factory exist
|
|
57
|
-
runner.use(
|
|
58
|
-
|
|
57
|
+
runner.use(
|
|
58
|
+
pipes.ExtractState({ from: 'itx.factory', to: 'factoryState', status: 'INVALID_FACTORY_STATE', table: 'factory' })
|
|
59
|
+
);
|
|
60
|
+
runner.use(
|
|
61
|
+
pipes.ExtractState({
|
|
62
|
+
from: 'factoryState.owner',
|
|
63
|
+
to: 'factoryOwnerState',
|
|
64
|
+
status: 'INVALID_ISSUER_STATE',
|
|
65
|
+
table: 'account',
|
|
66
|
+
})
|
|
67
|
+
);
|
|
59
68
|
|
|
60
69
|
// Ensure issuer exist: read them here because some maybe migrated
|
|
61
|
-
runner.use(
|
|
70
|
+
runner.use(
|
|
71
|
+
pipes.ExtractState({
|
|
72
|
+
from: 'factoryState.trustedIssuers',
|
|
73
|
+
to: 'issuerStates',
|
|
74
|
+
status: 'INVALID_ISSUER_STATE',
|
|
75
|
+
table: 'account',
|
|
76
|
+
})
|
|
77
|
+
);
|
|
62
78
|
|
|
63
79
|
runner.use(pipes.ExtractState({ from: 'itx.owner', to: 'ownerState', status: 'OK', table: 'account' }));
|
|
64
80
|
runner.use(pipes.VerifyBlocked({ stateKeys: ['ownerState'] }));
|
|
@@ -33,7 +33,6 @@ module.exports = (context, next) => {
|
|
|
33
33
|
|
|
34
34
|
// For specific assets, they must not be consumed
|
|
35
35
|
// For factory, they must exist on chain
|
|
36
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
37
36
|
for (const address of expectedAssets) {
|
|
38
37
|
const plainAsset = actualAssetStates.find((x) => x.address === address);
|
|
39
38
|
if (plainAsset) {
|
|
@@ -4,7 +4,6 @@ const { Joi } = require('@arcblock/validator');
|
|
|
4
4
|
const { Runner, pipes } = require('@ocap/tx-pipeline');
|
|
5
5
|
const { account, asset } = require('@ocap/state');
|
|
6
6
|
|
|
7
|
-
// eslint-disable-next-line global-require
|
|
8
7
|
const debug = require('debug')(`${require('../../../package.json').name}:update-asset`);
|
|
9
8
|
|
|
10
9
|
const { decodeAnySafe } = require('../../util');
|
|
@@ -42,7 +41,9 @@ runner.use(pipes.ExtractState({ from: 'itx.address', to: 'assetState', status: '
|
|
|
42
41
|
runner.use(pipes.ExtractState({ from: 'assetState.issuer', to: 'issuerState', status: 'OK', table: 'account' }));
|
|
43
42
|
|
|
44
43
|
// Ensure sender exist
|
|
45
|
-
runner.use(
|
|
44
|
+
runner.use(
|
|
45
|
+
pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
|
|
46
|
+
);
|
|
46
47
|
runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
|
|
47
48
|
|
|
48
49
|
// Ensure asset owned by sender and can be modified
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable indent */
|
|
2
1
|
const get = require('lodash/get');
|
|
3
2
|
const isEmpty = require('empty-value');
|
|
4
3
|
const cloneDeep = require('lodash/cloneDeep');
|
|
@@ -10,7 +9,6 @@ const { BN } = require('@ocap/util');
|
|
|
10
9
|
const { account, factory, delegation } = require('@ocap/state');
|
|
11
10
|
const { toFactoryAddress } = require('@arcblock/did-util');
|
|
12
11
|
|
|
13
|
-
// eslint-disable-next-line global-require
|
|
14
12
|
const debug = require('debug')(`${require('../../../package.json').name}:create-factory`);
|
|
15
13
|
|
|
16
14
|
const { decodeAnySafe, getDelegationRequirements } = require('../../util');
|
|
@@ -81,7 +79,9 @@ runner.use(
|
|
|
81
79
|
);
|
|
82
80
|
|
|
83
81
|
// Ensure sender exist
|
|
84
|
-
runner.use(
|
|
82
|
+
runner.use(
|
|
83
|
+
pipes.ExtractState({ from: 'tx.from', to: 'senderState', table: 'account', status: 'INVALID_SENDER_STATE' })
|
|
84
|
+
);
|
|
85
85
|
runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
|
|
86
86
|
|
|
87
87
|
// Ensure delegation
|
|
@@ -97,11 +97,17 @@ runner.use(
|
|
|
97
97
|
);
|
|
98
98
|
|
|
99
99
|
// Ensure tokens exist if we are creating an factory that consume tokens
|
|
100
|
-
runner.use(
|
|
100
|
+
runner.use(
|
|
101
|
+
pipes.ExtractState({ from: 'factoryTokens', to: 'tokenStates', table: 'token', status: 'INVALID_FACTORY_INPUT' })
|
|
102
|
+
);
|
|
101
103
|
|
|
102
104
|
// ensure input.assets all exist on chain
|
|
103
|
-
runner.use(
|
|
104
|
-
|
|
105
|
+
runner.use(
|
|
106
|
+
pipes.ExtractState({ from: 'factoryProps.input.assets', to: 'inputAssetStates', table: 'asset', status: 'OK' })
|
|
107
|
+
);
|
|
108
|
+
runner.use(
|
|
109
|
+
pipes.ExtractState({ from: 'factoryProps.input.assets', to: 'inputFactoryStates', table: 'factory', status: 'OK' })
|
|
110
|
+
);
|
|
105
111
|
runner.use((context, next) => {
|
|
106
112
|
const { inputAssetStates = [], inputFactoryStates = [], factoryProps } = context;
|
|
107
113
|
if (inputAssetStates.some((x) => !!x.consumedTime)) {
|
|
@@ -116,7 +122,14 @@ runner.use((context, next) => {
|
|
|
116
122
|
});
|
|
117
123
|
|
|
118
124
|
// ensure issuer exists and not migrated
|
|
119
|
-
runner.use(
|
|
125
|
+
runner.use(
|
|
126
|
+
pipes.ExtractState({
|
|
127
|
+
from: 'factoryProps.trustedIssuers',
|
|
128
|
+
to: 'issuerStates',
|
|
129
|
+
table: 'account',
|
|
130
|
+
status: 'INVALID_ISSUER_STATE',
|
|
131
|
+
})
|
|
132
|
+
);
|
|
120
133
|
runner.use(pipes.VerifyAccountMigration({ stateKey: 'issuerStates', addressKey: 'factoryProps.trustedIssuers' }));
|
|
121
134
|
|
|
122
135
|
// Ensure tx fee and gas
|
|
@@ -5,7 +5,6 @@ const { Runner, pipes } = require('@ocap/tx-pipeline');
|
|
|
5
5
|
const { account, asset, stake, evidence } = require('@ocap/state');
|
|
6
6
|
const { getRelatedAddresses } = require('@ocap/util/lib/get-related-addr');
|
|
7
7
|
|
|
8
|
-
// eslint-disable-next-line global-require
|
|
9
8
|
const debug = require('debug')(`${require('../../../package.json').name}:claim-stake`);
|
|
10
9
|
|
|
11
10
|
const { applyTokenUpdates, applyTokenChange } = require('../../util');
|
|
@@ -30,8 +29,12 @@ runner.use(({ itx }, next) => {
|
|
|
30
29
|
});
|
|
31
30
|
|
|
32
31
|
// 2. verify stake state & sender state
|
|
33
|
-
runner.use(
|
|
34
|
-
|
|
32
|
+
runner.use(
|
|
33
|
+
pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
|
|
34
|
+
);
|
|
35
|
+
runner.use(
|
|
36
|
+
pipes.ExtractState({ from: 'itx.address', to: 'stakeState', status: 'INVALID_STAKE_STATE', table: 'stake' })
|
|
37
|
+
);
|
|
35
38
|
runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
|
|
36
39
|
runner.use(
|
|
37
40
|
pipes.VerifyInfo([
|
|
@@ -98,7 +101,9 @@ runner.use(
|
|
|
98
101
|
);
|
|
99
102
|
|
|
100
103
|
// 6. verify receiver states
|
|
101
|
-
runner.use(
|
|
104
|
+
runner.use(
|
|
105
|
+
pipes.ExtractState({ from: 'receivers', to: 'receiverStates', status: 'INVALID_RECEIVER_STATE', table: 'account' })
|
|
106
|
+
);
|
|
102
107
|
|
|
103
108
|
// 7. verify token state and balance
|
|
104
109
|
runner.use(pipes.ExtractState({ from: 'tokens', to: 'tokenStates', status: 'INVALID_TOKEN', table: 'token' }));
|
|
@@ -6,7 +6,6 @@ const { Runner, pipes } = require('@ocap/tx-pipeline');
|
|
|
6
6
|
const { account, stake, asset } = require('@ocap/state');
|
|
7
7
|
const { getRelatedAddresses } = require('@ocap/util/lib/get-related-addr');
|
|
8
8
|
|
|
9
|
-
// eslint-disable-next-line global-require
|
|
10
9
|
const debug = require('debug')(`${require('../../../package.json').name}:return-stake`);
|
|
11
10
|
|
|
12
11
|
const { applyTokenUpdates, applyTokenChange } = require('../../util');
|
|
@@ -55,13 +54,19 @@ runner.use(
|
|
|
55
54
|
runner.use(pipes.VerifyListSize({ listKey: ['outputs', 'receivers', 'tokens', 'assets'] }));
|
|
56
55
|
|
|
57
56
|
// 4. verify sender & receiver
|
|
58
|
-
runner.use(
|
|
59
|
-
|
|
57
|
+
runner.use(
|
|
58
|
+
pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
|
|
59
|
+
);
|
|
60
|
+
runner.use(
|
|
61
|
+
pipes.ExtractState({ from: 'receivers', to: 'receiverStates', status: 'INVALID_RECEIVER_STATE', table: 'account' })
|
|
62
|
+
);
|
|
60
63
|
runner.use(pipes.VerifyBlocked({ stateKeys: ['receiverStates'] }));
|
|
61
64
|
runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
|
|
62
65
|
|
|
63
66
|
// 5. verify stake state
|
|
64
|
-
runner.use(
|
|
67
|
+
runner.use(
|
|
68
|
+
pipes.ExtractState({ from: 'itx.address', to: 'stakeState', status: 'INVALID_STAKE_STATE', table: 'stake' })
|
|
69
|
+
);
|
|
65
70
|
runner.use(
|
|
66
71
|
pipes.VerifyInfo([
|
|
67
72
|
{
|
|
@@ -6,7 +6,6 @@ const { Runner, pipes } = require('@ocap/tx-pipeline');
|
|
|
6
6
|
const { account, stake } = require('@ocap/state');
|
|
7
7
|
const { getRelatedAddresses } = require('@ocap/util/lib/get-related-addr');
|
|
8
8
|
|
|
9
|
-
// eslint-disable-next-line global-require
|
|
10
9
|
const debug = require('debug')(`${require('../../../package.json').name}:revoke-stake`);
|
|
11
10
|
|
|
12
11
|
const { applyTokenUpdates } = require('../../util');
|
|
@@ -54,13 +53,19 @@ runner.use(
|
|
|
54
53
|
runner.use(pipes.VerifyListSize({ listKey: ['outputs', 'receivers', 'tokens', 'assets'] }));
|
|
55
54
|
|
|
56
55
|
// 4. verify sender & receiver
|
|
57
|
-
runner.use(
|
|
58
|
-
|
|
56
|
+
runner.use(
|
|
57
|
+
pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
|
|
58
|
+
);
|
|
59
|
+
runner.use(
|
|
60
|
+
pipes.ExtractState({ from: 'receivers', to: 'receiverStates', status: 'INVALID_RECEIVER_STATE', table: 'account' })
|
|
61
|
+
);
|
|
59
62
|
runner.use(pipes.VerifyBlocked({ stateKeys: ['receiverStates'] }));
|
|
60
63
|
runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
|
|
61
64
|
|
|
62
65
|
// 5. verify stake state
|
|
63
|
-
runner.use(
|
|
66
|
+
runner.use(
|
|
67
|
+
pipes.ExtractState({ from: 'itx.address', to: 'stakeState', status: 'INVALID_STAKE_STATE', table: 'stake' })
|
|
68
|
+
);
|
|
64
69
|
runner.use(
|
|
65
70
|
pipes.VerifyInfo([
|
|
66
71
|
{
|
|
@@ -6,7 +6,6 @@ const { Runner, pipes } = require('@ocap/tx-pipeline');
|
|
|
6
6
|
const { account, stake, asset } = require('@ocap/state');
|
|
7
7
|
const { getRelatedAddresses } = require('@ocap/util/lib/get-related-addr');
|
|
8
8
|
|
|
9
|
-
// eslint-disable-next-line global-require
|
|
10
9
|
const debug = require('debug')(`${require('../../../package.json').name}:slash-stake`);
|
|
11
10
|
|
|
12
11
|
const { applyTokenUpdates, applyTokenChange } = require('../../util');
|
|
@@ -55,14 +54,27 @@ runner.use(
|
|
|
55
54
|
runner.use(pipes.VerifyListSize({ listKey: ['outputs', 'receivers', 'tokens', 'assets'] }));
|
|
56
55
|
|
|
57
56
|
// 4. verify sender & receiver
|
|
58
|
-
runner.use(
|
|
59
|
-
|
|
57
|
+
runner.use(
|
|
58
|
+
pipes.ExtractState({ from: 'tx.from', to: 'senderState', status: 'INVALID_SENDER_STATE', table: 'account' })
|
|
59
|
+
);
|
|
60
|
+
runner.use(
|
|
61
|
+
pipes.ExtractState({ from: 'receivers', to: 'receiverStates', status: 'INVALID_RECEIVER_STATE', table: 'account' })
|
|
62
|
+
);
|
|
60
63
|
runner.use(pipes.VerifyBlocked({ stateKeys: ['receiverStates'] }));
|
|
61
64
|
runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
|
|
62
65
|
|
|
63
66
|
// 5. verify stake state
|
|
64
|
-
runner.use(
|
|
65
|
-
|
|
67
|
+
runner.use(
|
|
68
|
+
pipes.ExtractState({ from: 'itx.address', to: 'stakeState', status: 'INVALID_STAKE_STATE', table: 'stake' })
|
|
69
|
+
);
|
|
70
|
+
runner.use(
|
|
71
|
+
pipes.ExtractState({
|
|
72
|
+
from: 'stakeState.slashers',
|
|
73
|
+
to: 'slasherStates',
|
|
74
|
+
status: 'INVALID_SLASH_STATE',
|
|
75
|
+
table: 'account',
|
|
76
|
+
})
|
|
77
|
+
);
|
|
66
78
|
runner.use(
|
|
67
79
|
pipes.VerifyInfo([
|
|
68
80
|
{
|