@ocap/tx-protocols 1.18.83 → 1.18.84
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.
|
@@ -5,7 +5,7 @@ const { Joi, schemas } = require('@arcblock/validator');
|
|
|
5
5
|
const { account, asset, factory } = require('@ocap/state');
|
|
6
6
|
|
|
7
7
|
// eslint-disable-next-line global-require
|
|
8
|
-
const debug = require('debug')(`${require('../../../package.json').name}:
|
|
8
|
+
const debug = require('debug')(`${require('../../../package.json').name}:mint-asset`);
|
|
9
9
|
|
|
10
10
|
const verifyMintLimit = require('./pipes/verify-mint-limit');
|
|
11
11
|
const verifyItxVariables = require('./pipes/verify-itx-variables');
|
|
@@ -60,7 +60,6 @@ runner.use(pipes.ExtractState({ from: 'factoryState.owner', to: 'factoryOwnerSta
|
|
|
60
60
|
// Ensure issuer exist: read them here because some maybe migrated
|
|
61
61
|
runner.use(pipes.ExtractState({ from: 'factoryState.trustedIssuers', to: 'issuerStates', status: 'INVALID_ISSUER_STATE' , table: 'account'})); // prettier-ignore
|
|
62
62
|
|
|
63
|
-
// Ensure factory owner exist and equal to sender
|
|
64
63
|
runner.use(pipes.ExtractState({ from: 'itx.owner', to: 'ownerState', status: 'OK', table: 'account' }));
|
|
65
64
|
runner.use(
|
|
66
65
|
pipes.VerifyInfo([
|
|
@@ -124,10 +123,9 @@ runner.use(
|
|
|
124
123
|
senderUpdates,
|
|
125
124
|
assetStates = [],
|
|
126
125
|
updateVaults,
|
|
126
|
+
ownerAddress,
|
|
127
127
|
} = context;
|
|
128
128
|
|
|
129
|
-
const owner = ownerState ? ownerState.address : itx.owner;
|
|
130
|
-
|
|
131
129
|
const factoryUpdates = { numMinted: factoryState.numMinted + 1 };
|
|
132
130
|
|
|
133
131
|
const [newSenderState, newReceiverState, assetState, newFactoryState, newAssetStates] = await Promise.all([
|
|
@@ -141,12 +139,12 @@ runner.use(
|
|
|
141
139
|
// create receiver if not exist: asset owner
|
|
142
140
|
ownerState
|
|
143
141
|
? Promise.resolve(ownerState)
|
|
144
|
-
: statedb.account.create(
|
|
142
|
+
: statedb.account.create(ownerAddress, account.create({ address: ownerAddress }, context), context),
|
|
145
143
|
|
|
146
144
|
// create asset
|
|
147
145
|
statedb.asset.create(
|
|
148
146
|
itx.address,
|
|
149
|
-
asset.create({ ...mintedAsset, owner, address: mintedAddress }, context),
|
|
147
|
+
asset.create({ ...mintedAsset, owner: ownerAddress, address: mintedAddress }, context),
|
|
150
148
|
context
|
|
151
149
|
),
|
|
152
150
|
|
|
@@ -4,7 +4,7 @@ const { mintFromFactory } = require('@ocap/asset');
|
|
|
4
4
|
const debug = require('debug')('@ocap/tx-protocols:pipes:verify-itx-address');
|
|
5
5
|
|
|
6
6
|
module.exports = (mode) => (context, next) => {
|
|
7
|
-
const { itx, senderState,
|
|
7
|
+
const { itx, senderState, factoryState, delegatorState, factoryInputs } = context;
|
|
8
8
|
|
|
9
9
|
let issuer = null;
|
|
10
10
|
let owner = null;
|
|
@@ -14,10 +14,10 @@ module.exports = (mode) => (context, next) => {
|
|
|
14
14
|
issuer = itx.issuer;
|
|
15
15
|
context.assetOwner = owner;
|
|
16
16
|
} else if (mode === 'acquire-v3') {
|
|
17
|
-
owner =
|
|
17
|
+
owner = { address: itx.owner };
|
|
18
18
|
issuer = itx.issuer;
|
|
19
19
|
} else if (mode === 'mint') {
|
|
20
|
-
owner =
|
|
20
|
+
owner = { address: itx.owner };
|
|
21
21
|
issuer = {
|
|
22
22
|
id: senderState.address,
|
|
23
23
|
pk: senderState.pk,
|
|
@@ -41,12 +41,12 @@ module.exports = (mode) => (context, next) => {
|
|
|
41
41
|
factoryInputs,
|
|
42
42
|
factoryState,
|
|
43
43
|
senderState,
|
|
44
|
-
ownerState,
|
|
45
44
|
delegatorState,
|
|
46
45
|
});
|
|
47
46
|
return next(new Error('INVALID_ASSET', 'Invalid itx.address: does not match with minted asset address'));
|
|
48
47
|
}
|
|
49
48
|
|
|
49
|
+
context.ownerAddress = owner.address;
|
|
50
50
|
context.mintedAsset = minted.asset;
|
|
51
51
|
context.mintedAddress = minted.address;
|
|
52
52
|
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.18.
|
|
6
|
+
"version": "1.18.84",
|
|
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.18.
|
|
25
|
-
"@arcblock/did-util": "1.18.
|
|
26
|
-
"@arcblock/jwt": "1.18.
|
|
27
|
-
"@arcblock/validator": "1.18.
|
|
28
|
-
"@ocap/asset": "1.18.
|
|
29
|
-
"@ocap/mcrypto": "1.18.
|
|
30
|
-
"@ocap/merkle-tree": "1.18.
|
|
31
|
-
"@ocap/message": "1.18.
|
|
32
|
-
"@ocap/state": "1.18.
|
|
33
|
-
"@ocap/tx-pipeline": "1.18.
|
|
34
|
-
"@ocap/util": "1.18.
|
|
35
|
-
"@ocap/wallet": "1.18.
|
|
24
|
+
"@arcblock/did": "1.18.84",
|
|
25
|
+
"@arcblock/did-util": "1.18.84",
|
|
26
|
+
"@arcblock/jwt": "1.18.84",
|
|
27
|
+
"@arcblock/validator": "1.18.84",
|
|
28
|
+
"@ocap/asset": "1.18.84",
|
|
29
|
+
"@ocap/mcrypto": "1.18.84",
|
|
30
|
+
"@ocap/merkle-tree": "1.18.84",
|
|
31
|
+
"@ocap/message": "1.18.84",
|
|
32
|
+
"@ocap/state": "1.18.84",
|
|
33
|
+
"@ocap/tx-pipeline": "1.18.84",
|
|
34
|
+
"@ocap/util": "1.18.84",
|
|
35
|
+
"@ocap/wallet": "1.18.84",
|
|
36
36
|
"debug": "^4.3.4",
|
|
37
37
|
"deep-diff": "^1.0.2",
|
|
38
38
|
"empty-value": "^1.0.1",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"jest": "^27.5.1",
|
|
48
48
|
"start-server-and-test": "^1.14.0"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "ae4342de4c0be784cae2421246167e0b982b0bc1"
|
|
51
51
|
}
|