@ocap/tx-protocols 1.19.7 → 1.19.9
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
CHANGED
|
@@ -3,7 +3,6 @@ const states = require('@ocap/state');
|
|
|
3
3
|
const transferV2 = require('./protocols/trade/transfer-v2');
|
|
4
4
|
const transferV3 = require('./protocols/trade/transfer-v3');
|
|
5
5
|
const exchangeV2 = require('./protocols/trade/exchange-v2');
|
|
6
|
-
const declare = require('./protocols/account/declare');
|
|
7
6
|
const migrate = require('./protocols/account/migrate');
|
|
8
7
|
const delegate = require('./protocols/account/delegate');
|
|
9
8
|
const revokeDelegate = require('./protocols/account/revoke-delegate');
|
|
@@ -44,7 +43,6 @@ const createExecutor = ({ filter, runAsLambda }) => {
|
|
|
44
43
|
exchangeV2,
|
|
45
44
|
|
|
46
45
|
// account
|
|
47
|
-
declare,
|
|
48
46
|
accountMigrate: migrate,
|
|
49
47
|
delegate,
|
|
50
48
|
revokeDelegate,
|
|
@@ -188,7 +188,11 @@ runner.use(
|
|
|
188
188
|
// update receiver
|
|
189
189
|
receiverState
|
|
190
190
|
? Promise.resolve(receiverState)
|
|
191
|
-
: statedb.account.create(
|
|
191
|
+
: statedb.account.create(
|
|
192
|
+
receiver,
|
|
193
|
+
account.create({ address: receiver, tokens: { [context.config.token.address]: '0' } }, context),
|
|
194
|
+
context
|
|
195
|
+
),
|
|
192
196
|
|
|
193
197
|
delegationState
|
|
194
198
|
? statedb.delegation.update(itx.address, delegation.update(delegationState, { ...itx, from: sender, ops: merged }, context), context) // prettier-ignore
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.19.
|
|
6
|
+
"version": "1.19.9",
|
|
7
7
|
"description": "Predefined tx pipeline sets to execute certain type of transactions",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -21,18 +21,18 @@
|
|
|
21
21
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@arcblock/did": "1.19.
|
|
25
|
-
"@arcblock/did-util": "1.19.
|
|
26
|
-
"@arcblock/jwt": "1.19.
|
|
27
|
-
"@arcblock/validator": "1.19.
|
|
28
|
-
"@ocap/asset": "1.19.
|
|
29
|
-
"@ocap/mcrypto": "1.19.
|
|
30
|
-
"@ocap/merkle-tree": "1.19.
|
|
31
|
-
"@ocap/message": "1.19.
|
|
32
|
-
"@ocap/state": "1.19.
|
|
33
|
-
"@ocap/tx-pipeline": "1.19.
|
|
34
|
-
"@ocap/util": "1.19.
|
|
35
|
-
"@ocap/wallet": "1.19.
|
|
24
|
+
"@arcblock/did": "1.19.9",
|
|
25
|
+
"@arcblock/did-util": "1.19.9",
|
|
26
|
+
"@arcblock/jwt": "1.19.9",
|
|
27
|
+
"@arcblock/validator": "1.19.9",
|
|
28
|
+
"@ocap/asset": "1.19.9",
|
|
29
|
+
"@ocap/mcrypto": "1.19.9",
|
|
30
|
+
"@ocap/merkle-tree": "1.19.9",
|
|
31
|
+
"@ocap/message": "1.19.9",
|
|
32
|
+
"@ocap/state": "1.19.9",
|
|
33
|
+
"@ocap/tx-pipeline": "1.19.9",
|
|
34
|
+
"@ocap/util": "1.19.9",
|
|
35
|
+
"@ocap/wallet": "1.19.9",
|
|
36
36
|
"debug": "^4.3.6",
|
|
37
37
|
"deep-diff": "^1.0.2",
|
|
38
38
|
"empty-value": "^1.0.1",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"jest": "^29.7.0",
|
|
48
48
|
"start-server-and-test": "^1.14.0"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "ae520a0097cfc29d45d5f481da8e4d9bdb3fbe81"
|
|
51
51
|
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
const { CustomError: Error } = require('@ocap/util/lib/error');
|
|
2
|
-
const { Joi } = require('@arcblock/validator');
|
|
3
|
-
const { Runner, pipes } = require('@ocap/tx-pipeline');
|
|
4
|
-
const { account } = require('@ocap/state');
|
|
5
|
-
const { toBase58 } = require('@ocap/util');
|
|
6
|
-
|
|
7
|
-
const runner = new Runner();
|
|
8
|
-
|
|
9
|
-
runner.use(pipes.VerifyMultiSig(0));
|
|
10
|
-
|
|
11
|
-
// verify itx
|
|
12
|
-
const schema = Joi.object({
|
|
13
|
-
issuer: Joi.DID().prefix().optional().allow(''),
|
|
14
|
-
moniker: Joi.string()
|
|
15
|
-
.regex(/^[a-zA-Z0-9][-a-zA-Z0-9_]{2,128}$/)
|
|
16
|
-
.required(),
|
|
17
|
-
data: Joi.any().optional(),
|
|
18
|
-
}).options({ stripUnknown: true, noDefaults: false });
|
|
19
|
-
runner.use(({ itx }, next) => {
|
|
20
|
-
const { error } = schema.validate(itx);
|
|
21
|
-
if (error) {
|
|
22
|
-
return next(new Error('INVALID_TX', `Invalid itx: ${error.message}`));
|
|
23
|
-
}
|
|
24
|
-
return next();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
// Ensure sender does not exist
|
|
28
|
-
runner.use(pipes.ExtractState({ from: 'tx.from', to: 'senderState' }));
|
|
29
|
-
runner.use(pipes.VerifySender({ state: 'senderState' }));
|
|
30
|
-
runner.use(pipes.VerifyAccountMigration({ stateKey: 'senderState', addressKey: 'tx.from' }));
|
|
31
|
-
|
|
32
|
-
// The issuer must exist in the ledger
|
|
33
|
-
runner.use(pipes.ExtractState({ from: 'itx.issuer', to: 'issuerState', status: 'INVALID_TX' }));
|
|
34
|
-
|
|
35
|
-
// Save context snapshot before updating states
|
|
36
|
-
runner.use(pipes.TakeStateSnapshot());
|
|
37
|
-
|
|
38
|
-
// Create account state
|
|
39
|
-
runner.use(
|
|
40
|
-
async (context, next) => {
|
|
41
|
-
const { tx, itx, statedb } = context;
|
|
42
|
-
const tokens = { [context.config.token.address]: '0' };
|
|
43
|
-
|
|
44
|
-
const [senderState] = await Promise.all([
|
|
45
|
-
statedb.account.create(
|
|
46
|
-
tx.from,
|
|
47
|
-
account.create({ address: tx.from, pk: toBase58(tx.pk), nonce: tx.nonce, tokens, ...itx }, context),
|
|
48
|
-
context
|
|
49
|
-
),
|
|
50
|
-
]);
|
|
51
|
-
|
|
52
|
-
context.senderState = senderState;
|
|
53
|
-
|
|
54
|
-
next();
|
|
55
|
-
},
|
|
56
|
-
{ persistError: true }
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
runner.use(pipes.VerifyStateDiff());
|
|
60
|
-
|
|
61
|
-
module.exports = runner;
|