@waves/node-api-js 1.2.8 → 1.2.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/cjs/api-node/assets/index.d.ts +1 -0
- package/cjs/api-node/assets/index.js +6 -1
- package/cjs/api-node/assets/index.js.map +1 -1
- package/cjs/create.d.ts +365 -21
- package/cjs/tools/adresses/getAssetIdListByTx.d.ts +2 -3
- package/cjs/tools/adresses/getAssetIdListByTx.js +1 -0
- package/cjs/tools/adresses/getAssetIdListByTx.js.map +1 -1
- package/cjs/tools/adresses/getAssetsByTransaction.d.ts +2 -3
- package/cjs/tools/adresses/getAssetsByTransaction.js.map +1 -1
- package/cjs/tools/transactions/transactions.d.ts +0 -60
- package/cjs/tools/transactions/transactions.js +0 -117
- package/cjs/tools/transactions/transactions.js.map +1 -1
- package/dist/0.node-api.js +13 -1
- package/dist/node-api.js +8 -2
- package/dist/node-api.min.js +5 -5
- package/dist/node-api.min.js.LICENSE.txt +17 -0
- package/dist/node_fs-node_path.node-api.js +23 -0
- package/dist/vendors-node_modules_node-fetch_src_utils_multipart-parser_js.node-api.js +599 -0
- package/es/api-node/assets/index.d.ts +1 -0
- package/es/api-node/assets/index.js +4 -0
- package/es/api-node/assets/index.js.map +1 -1
- package/es/create.d.ts +365 -21
- package/es/tools/adresses/getAssetIdListByTx.d.ts +2 -3
- package/es/tools/adresses/getAssetIdListByTx.js +1 -0
- package/es/tools/adresses/getAssetIdListByTx.js.map +1 -1
- package/es/tools/adresses/getAssetsByTransaction.d.ts +2 -3
- package/es/tools/adresses/getAssetsByTransaction.js.map +1 -1
- package/es/tools/transactions/transactions.d.ts +0 -60
- package/es/tools/transactions/transactions.js +1 -99
- package/es/tools/transactions/transactions.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,100 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { TRANSACTION_TYPE } from "@waves/ts-types/";
|
|
3
|
-
export function addStateUpdateField(transaction) {
|
|
4
|
-
if (transaction.type === TRANSACTION_TYPE.INVOKE_SCRIPT || transaction.type === TRANSACTION_TYPE.INVOKE_EXPRESSION && transaction.stateChanges.invokes && transaction.stateChanges.invokes.length) {
|
|
5
|
-
const payments = transaction.payment ? transaction.payment.map((p) => ({
|
|
6
|
-
assetId: p.assetId,
|
|
7
|
-
amount: p.amount
|
|
8
|
-
})) : [];
|
|
9
|
-
}
|
|
10
|
-
if (transaction.type === TRANSACTION_TYPE.ETHEREUM && transaction.payload.type === 'invocation' && transaction.payload.stateChanges.invokes && transaction.payload.stateChanges.invokes.length) {
|
|
11
|
-
const payments = transaction.payload.payment ? transaction.payload.payment.map((p) => ({
|
|
12
|
-
assetId: p.assetId,
|
|
13
|
-
amount: p.amount
|
|
14
|
-
})) : [];
|
|
15
|
-
const dApp = transaction.payload.dApp || '';
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
return Object.defineProperty(transaction, 'stateUpdate', { get: () => makeStateUpdate(transaction.payload.stateChanges, payments, dApp, transaction.sender) });
|
|
18
|
-
}
|
|
19
|
-
else
|
|
20
|
-
return transaction;
|
|
21
|
-
}
|
|
22
|
-
export function makeStateUpdate(stateChanges, payment, dApp, sender) {
|
|
23
|
-
const payments = payment.map(payment => ({ payment, dApp, sender }));
|
|
24
|
-
const addField = (array, fieldName) => array.map(item => (Object.assign(Object.assign({}, item), { [fieldName]: dApp })));
|
|
25
|
-
const transfers = addField(stateChanges.transfers, 'sender');
|
|
26
|
-
const leases = addField(stateChanges.leases, 'sender');
|
|
27
|
-
const issues = addField(stateChanges.issues, 'address');
|
|
28
|
-
const data = addField(stateChanges.data, 'address');
|
|
29
|
-
const reissues = addField(stateChanges.reissues, 'address');
|
|
30
|
-
const burns = addField(stateChanges.burns, 'address');
|
|
31
|
-
const sponsorFees = addField(stateChanges.sponsorFees, 'address');
|
|
32
|
-
const leaseCancels = addField(stateChanges.leaseCancels, 'address');
|
|
33
|
-
const stateUpdate = {
|
|
34
|
-
payments,
|
|
35
|
-
data,
|
|
36
|
-
transfers,
|
|
37
|
-
reissues,
|
|
38
|
-
issues,
|
|
39
|
-
burns,
|
|
40
|
-
sponsorFees,
|
|
41
|
-
leases,
|
|
42
|
-
leaseCancels,
|
|
43
|
-
};
|
|
44
|
-
const recursiveFunction = (stateChanges, sender) => {
|
|
45
|
-
if (stateChanges.invokes.length) {
|
|
46
|
-
stateChanges.invokes.forEach((x) => {
|
|
47
|
-
//payments
|
|
48
|
-
if (x.payment)
|
|
49
|
-
x.payment.forEach(y => {
|
|
50
|
-
const index = payments.findIndex(z => (z.payment.assetId === y.assetId) && (z.dApp === x.dApp) && (sender === x.dApp));
|
|
51
|
-
index !== -1
|
|
52
|
-
? payments[index].payment.amount = (new BigNumber(payments[index].payment.amount)).add(y.amount).toNumber()
|
|
53
|
-
: payments.push({
|
|
54
|
-
payment: y,
|
|
55
|
-
sender: sender,
|
|
56
|
-
dApp: x.dApp
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
//data
|
|
60
|
-
x.stateChanges.data.forEach(y => {
|
|
61
|
-
const index = stateUpdate.data.findIndex(z => z.key === y.key && z.address === x.dApp);
|
|
62
|
-
index !== -1 ? stateUpdate.data[index] = Object.assign(Object.assign({}, y), { address: x.dApp }) : stateUpdate.data.push(Object.assign(Object.assign({}, y), { address: x.dApp }));
|
|
63
|
-
});
|
|
64
|
-
//burns
|
|
65
|
-
x.stateChanges.burns.forEach(y => {
|
|
66
|
-
const index = stateUpdate.burns.findIndex(z => z.assetId === y.assetId);
|
|
67
|
-
index !== -1 ? stateUpdate.burns[index].quantity += y.quantity : stateUpdate.burns.push(Object.assign(Object.assign({}, y), { address: x.dApp }));
|
|
68
|
-
});
|
|
69
|
-
//issues
|
|
70
|
-
x.stateChanges.issues.forEach(y => stateUpdate.issues.push(Object.assign(Object.assign({}, y), { address: x.dApp })));
|
|
71
|
-
//reissues
|
|
72
|
-
x.stateChanges.reissues.forEach(y => {
|
|
73
|
-
const index = stateUpdate.reissues.findIndex(z => z.assetId === y.assetId);
|
|
74
|
-
index !== -1 ? stateUpdate.reissues[index].quantity += y.quantity : stateUpdate.reissues.push(Object.assign(Object.assign({}, y), { address: x.dApp }));
|
|
75
|
-
});
|
|
76
|
-
//transfers
|
|
77
|
-
x.stateChanges.transfers.forEach(y => {
|
|
78
|
-
const index = stateUpdate.transfers.findIndex(z => (z.asset === y.asset) && (z.address === y.address) && (x.dApp === z.sender));
|
|
79
|
-
index !== -1
|
|
80
|
-
? stateUpdate.transfers[index].amount = (new BigNumber(stateUpdate.transfers[index].amount)).add(y.amount).toNumber()
|
|
81
|
-
: stateUpdate.transfers.push(Object.assign(Object.assign({}, y), { sender: x.dApp }));
|
|
82
|
-
});
|
|
83
|
-
//sponsorFees
|
|
84
|
-
x.stateChanges.sponsorFees.forEach(y => {
|
|
85
|
-
const index = stateUpdate.sponsorFees.findIndex(z => (z.assetId === y.assetId) && (z.address === x.dApp));
|
|
86
|
-
index !== -1
|
|
87
|
-
? stateUpdate.sponsorFees[index] = Object.assign(Object.assign({}, y), { address: x.dApp })
|
|
88
|
-
: stateUpdate.sponsorFees.push(Object.assign(Object.assign({}, y), { address: x.dApp }));
|
|
89
|
-
});
|
|
90
|
-
//lease and leaseCancels
|
|
91
|
-
x.stateChanges.leases.forEach(y => stateUpdate.leases.push(Object.assign(Object.assign({}, y), { sender: x.dApp })));
|
|
92
|
-
x.stateChanges.leaseCancels.forEach(y => stateUpdate.leaseCancels.push(Object.assign(Object.assign({}, y), { address: x.dApp })));
|
|
93
|
-
recursiveFunction(x.stateChanges, x.dApp);
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
recursiveFunction(stateChanges, sender);
|
|
98
|
-
return stateUpdate;
|
|
99
|
-
}
|
|
1
|
+
"use strict";
|
|
100
2
|
//# sourceMappingURL=transactions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactions.js","sourceRoot":"","sources":["../../../src/tools/transactions/transactions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transactions.js","sourceRoot":"","sources":["../../../src/tools/transactions/transactions.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waves/node-api-js",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.9",
|
|
4
4
|
"main": "cjs/index.js",
|
|
5
5
|
"types": "cjs/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@types/node-fetch": "^2.5.4",
|
|
14
14
|
"@waves/bignumber": "^1.1.1",
|
|
15
|
-
"@waves/ts-types": "^1.0.
|
|
15
|
+
"@waves/ts-types": "^1.0.12",
|
|
16
16
|
"node-fetch": "^2.6.7",
|
|
17
17
|
"typed-ts-events": "^1.1.1"
|
|
18
18
|
},
|