@ocap/tx-protocols 1.23.1 → 1.24.0
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.
|
@@ -30,6 +30,10 @@ const schema = Joi.object({
|
|
|
30
30
|
icon: Joi.string().optional().allow(null).valid(''),
|
|
31
31
|
totalSupply: Joi.BN().greater(0).max(MAX_TOTAL_SUPPLY).required(),
|
|
32
32
|
initialSupply: Joi.BN().greater(0).max(Joi.ref('totalSupply')).required(),
|
|
33
|
+
maxTotalSupply: Joi.alternatives()
|
|
34
|
+
.try(Joi.BN().greater(0).max(Joi.ref('totalSupply')), Joi.string().valid(''))
|
|
35
|
+
.optional()
|
|
36
|
+
.allow(null),
|
|
33
37
|
foreignToken: schemas.foreignToken.optional().allow(null).default(null),
|
|
34
38
|
tokenFactoryAddress: Joi.forbidden(),
|
|
35
39
|
data: Joi.any().optional().allow(null),
|
|
@@ -31,6 +31,7 @@ const schema = Joi.object({
|
|
|
31
31
|
unit: Joi.string().min(1).max(6).lowercase().required(),
|
|
32
32
|
decimal: Joi.number().min(6).max(18).required(),
|
|
33
33
|
icon: Joi.string().optional().allow(null).valid(''),
|
|
34
|
+
maxTotalSupply: Joi.alternatives().try(Joi.BN().greater(0), Joi.string().valid('')).optional().allow(null),
|
|
34
35
|
}).required(),
|
|
35
36
|
data: Joi.any().optional().allow(null),
|
|
36
37
|
}).options({ stripUnknown: true, noDefaults: false });
|
|
@@ -81,10 +82,10 @@ runner.use(
|
|
|
81
82
|
|
|
82
83
|
// Ensure symbol is not internal
|
|
83
84
|
runner.use((context, next) => {
|
|
84
|
-
const {
|
|
85
|
+
const { reservedSymbols } = context.config;
|
|
85
86
|
const { symbol } = context.itx.token;
|
|
86
87
|
|
|
87
|
-
if (
|
|
88
|
+
if (reservedSymbols.includes(symbol.toUpperCase())) {
|
|
88
89
|
return next(new Error('INVALID_SYMBOL', `Token symbol can not be ${symbol}`));
|
|
89
90
|
}
|
|
90
91
|
|
|
@@ -116,6 +116,26 @@ runner.use(
|
|
|
116
116
|
})
|
|
117
117
|
);
|
|
118
118
|
|
|
119
|
+
// verify max supply
|
|
120
|
+
runner.use((context, next) => {
|
|
121
|
+
const { tokenState, itx } = context;
|
|
122
|
+
|
|
123
|
+
if (tokenState.maxTotalSupply) {
|
|
124
|
+
const availableSupply = new BN(tokenState.maxTotalSupply).sub(new BN(tokenState.totalSupply));
|
|
125
|
+
|
|
126
|
+
if (new BN(itx.amount).gt(availableSupply)) {
|
|
127
|
+
return next(
|
|
128
|
+
new Error(
|
|
129
|
+
'INVALID_TOKEN',
|
|
130
|
+
`Maximum mintable tokens are ${fromUnitToToken(availableSupply, tokenState.decimal)} ${tokenState.symbol}`
|
|
131
|
+
)
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
next();
|
|
137
|
+
});
|
|
138
|
+
|
|
119
139
|
// verify slippage
|
|
120
140
|
runner.use((context, next) => {
|
|
121
141
|
const { reserveAmount, reserveFee, inputs, tokenFactoryState } = context;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.24.0",
|
|
7
7
|
"description": "Predefined tx pipeline sets to execute certain type of transactions",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -18,19 +18,19 @@
|
|
|
18
18
|
"empty-value": "^1.0.1",
|
|
19
19
|
"lodash": "^4.17.21",
|
|
20
20
|
"url-join": "^4.0.1",
|
|
21
|
-
"@arcblock/did": "1.
|
|
22
|
-
"@arcblock/
|
|
23
|
-
"@
|
|
24
|
-
"@arcblock/validator": "1.
|
|
25
|
-
"@ocap/
|
|
26
|
-
"@ocap/
|
|
27
|
-
"@ocap/
|
|
28
|
-
"@ocap/
|
|
29
|
-
"@
|
|
30
|
-
"@ocap/state": "1.
|
|
31
|
-
"@ocap/tx-pipeline": "1.
|
|
32
|
-
"@ocap/util": "1.
|
|
33
|
-
"@ocap/wallet": "1.
|
|
21
|
+
"@arcblock/did": "1.24.0",
|
|
22
|
+
"@arcblock/jwt": "1.24.0",
|
|
23
|
+
"@ocap/asset": "1.24.0",
|
|
24
|
+
"@arcblock/validator": "1.24.0",
|
|
25
|
+
"@ocap/client": "1.24.0",
|
|
26
|
+
"@ocap/mcrypto": "1.24.0",
|
|
27
|
+
"@ocap/merkle-tree": "1.24.0",
|
|
28
|
+
"@ocap/message": "1.24.0",
|
|
29
|
+
"@arcblock/did-util": "1.24.0",
|
|
30
|
+
"@ocap/state": "1.24.0",
|
|
31
|
+
"@ocap/tx-pipeline": "1.24.0",
|
|
32
|
+
"@ocap/util": "1.24.0",
|
|
33
|
+
"@ocap/wallet": "1.24.0"
|
|
34
34
|
},
|
|
35
35
|
"resolutions": {
|
|
36
36
|
"bn.js": "5.2.1",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"jest": "^29.7.0",
|
|
41
41
|
"start-server-and-test": "^1.14.0",
|
|
42
|
-
"@ocap/e2e-test": "1.
|
|
43
|
-
"@ocap/statedb-memory": "1.
|
|
42
|
+
"@ocap/e2e-test": "1.24.0",
|
|
43
|
+
"@ocap/statedb-memory": "1.24.0"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"lint": "eslint tests lib",
|