@ocap/state 1.22.2 → 1.23.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.
- package/lib/states/tx.js +34 -26
- package/package.json +9 -9
package/lib/states/tx.js
CHANGED
|
@@ -341,25 +341,24 @@ const getCreateTokenReceipts = (tx) => {
|
|
|
341
341
|
};
|
|
342
342
|
|
|
343
343
|
const getMintTokenReceipts = (tx, ctx) => {
|
|
344
|
-
const {
|
|
345
|
-
const
|
|
344
|
+
const { inputChanges, tokenFactoryState } = ctx;
|
|
345
|
+
const { reserveAddress, tokenAddress, owner } = tokenFactoryState;
|
|
346
|
+
const hasFee = new BN(ctx.reserveFee || '0').gt(ZERO);
|
|
346
347
|
|
|
347
|
-
|
|
348
|
-
{
|
|
349
|
-
address:
|
|
348
|
+
const inputReceipts = inputChanges.map((input) => {
|
|
349
|
+
return {
|
|
350
|
+
address: input.address,
|
|
350
351
|
changes: [
|
|
351
352
|
{
|
|
352
353
|
target: reserveAddress,
|
|
353
354
|
action: 'swap',
|
|
354
|
-
value:
|
|
355
|
+
value: input.delta,
|
|
355
356
|
},
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
].filter(Boolean),
|
|
362
|
-
},
|
|
357
|
+
],
|
|
358
|
+
};
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
return inputReceipts.concat([
|
|
363
362
|
{
|
|
364
363
|
address: tx.itxJson.receiver,
|
|
365
364
|
changes: [
|
|
@@ -374,30 +373,39 @@ const getMintTokenReceipts = (tx, ctx) => {
|
|
|
374
373
|
address: owner,
|
|
375
374
|
changes: hasFee ? [{ target: reserveAddress, action: 'fee', value: `${ctx.reserveFee}` }] : [],
|
|
376
375
|
},
|
|
377
|
-
];
|
|
376
|
+
]);
|
|
378
377
|
};
|
|
379
378
|
|
|
380
379
|
const getBurnTokenReceipts = (tx, ctx) => {
|
|
381
|
-
const {
|
|
382
|
-
const
|
|
380
|
+
const { inputChanges, tokenFactoryState } = ctx;
|
|
381
|
+
const { reserveAddress, tokenAddress, owner } = tokenFactoryState;
|
|
383
382
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
383
|
+
const fee = new BN(ctx.reserveFee || '0');
|
|
384
|
+
const receiveAmount = new BN(ctx.reserveAmount).sub(fee).toString();
|
|
385
|
+
|
|
386
|
+
const inputReceipts = inputChanges.map((input) => {
|
|
387
|
+
return {
|
|
388
|
+
address: input.address,
|
|
387
389
|
changes: [
|
|
388
|
-
{
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
390
|
+
{
|
|
391
|
+
target: tokenAddress,
|
|
392
|
+
action: 'burn',
|
|
393
|
+
value: input.delta,
|
|
394
|
+
},
|
|
395
|
+
],
|
|
396
|
+
};
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
return inputReceipts.concat([
|
|
392
400
|
{
|
|
393
401
|
address: tx.itxJson.receiver,
|
|
394
|
-
changes: [{ target: reserveAddress, action: 'swap', value:
|
|
402
|
+
changes: [{ target: reserveAddress, action: 'swap', value: receiveAmount }],
|
|
395
403
|
},
|
|
396
404
|
{
|
|
397
405
|
address: owner,
|
|
398
|
-
changes:
|
|
406
|
+
changes: fee.gt(ZERO) ? [{ target: reserveAddress, action: 'fee', value: `${ctx.reserveFee}` }] : [],
|
|
399
407
|
},
|
|
400
|
-
];
|
|
408
|
+
]);
|
|
401
409
|
};
|
|
402
410
|
|
|
403
411
|
// Following only exist for legacy support purpose
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.23.0",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -12,18 +12,18 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"bloom-filters": "^1.3.9",
|
|
14
14
|
"lodash": "^4.17.21",
|
|
15
|
-
"@arcblock/did": "1.
|
|
16
|
-
"@arcblock/validator": "1.
|
|
17
|
-
"@ocap/
|
|
18
|
-
"@ocap/
|
|
19
|
-
"@ocap/
|
|
20
|
-
"@ocap/
|
|
21
|
-
"@ocap/
|
|
15
|
+
"@arcblock/did": "1.23.0",
|
|
16
|
+
"@arcblock/validator": "1.23.0",
|
|
17
|
+
"@ocap/contract": "1.23.0",
|
|
18
|
+
"@ocap/mcrypto": "1.23.0",
|
|
19
|
+
"@ocap/util": "1.23.0",
|
|
20
|
+
"@ocap/wallet": "1.23.0",
|
|
21
|
+
"@ocap/message": "1.23.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"jest": "^29.7.0",
|
|
25
25
|
"start-server-and-test": "^1.14.0",
|
|
26
|
-
"@ocap/e2e-test": "1.
|
|
26
|
+
"@ocap/e2e-test": "1.23.0"
|
|
27
27
|
},
|
|
28
28
|
"keywords": [],
|
|
29
29
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|