@leofcoin/workers 1.4.2 → 1.4.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/workers",
3
- "version": "1.4.2",
3
+ "version": "1.4.3",
4
4
  "description": "Workers used in @leofcoin/chain",
5
5
  "type": "module",
6
6
  "exports": {
@@ -8,6 +8,15 @@ const contractFactoryMessage = bytecodes.contractFactory
8
8
  const nativeTokenMessage = bytecodes.nativeToken
9
9
  const nameServiceMessage = bytecodes.nameService
10
10
  const validatorsMessage = bytecodes.validators
11
+ let nativeCalls = 0
12
+ let nativeBurns = 0
13
+ let nativeMints = 0
14
+ let nativeTransfers = 0
15
+ let totalTransactions = 0
16
+
17
+ let totalBurnAmount = 0
18
+ let totalMintAmount = 0
19
+ let totalTransferAmount = 0
11
20
 
12
21
  globalThis.BigNumber = BigNumber
13
22
  globalThis.contracts = {}
@@ -129,6 +138,22 @@ const _init = async ({ contracts, blocks, peerid }) => {
129
138
 
130
139
  try {
131
140
  await execute(to, method, params)
141
+ if (transaction.decoded.to === nativeToken) {
142
+ nativeCalls += 1
143
+ if (transaction.decoded.method === 'burn') nativeBurns += 1
144
+ if (transaction.decoded.method === 'mint') nativeMints += 1
145
+ if (transaction.decoded.method === 'transfer') nativeTransfers += 1
146
+ }
147
+ totalTransactions += 1
148
+
149
+ postMessage({
150
+ type: 'transactionLoaded',
151
+ result: {
152
+ hash: await transaction.hash(),
153
+ from: transaction.decoded.from,
154
+ nonce: String(transaction.decoded.nonce)
155
+ }
156
+ })
132
157
  } catch (error) {
133
158
  throw error
134
159
  }
@@ -180,6 +205,36 @@ const tasks = async (e) => {
180
205
  id
181
206
  })
182
207
  }
208
+ } else if (e.type === 'nativeCalls') {
209
+ worker.postMessage({
210
+ type: 'response',
211
+ value: nativeCalls,
212
+ id
213
+ })
214
+ } else if (e.type === 'nativeBurns') {
215
+ worker.postMessage({
216
+ type: 'response',
217
+ value: nativeBurns,
218
+ id
219
+ })
220
+ } else if (e.type === 'nativeMints') {
221
+ worker.postMessage({
222
+ type: 'response',
223
+ value: nativeMints,
224
+ id
225
+ })
226
+ } else if (e.type === 'nativeTransfers') {
227
+ worker.postMessage({
228
+ type: 'response',
229
+ value: nativeTransfers,
230
+ id
231
+ })
232
+ } else if (e.type === 'totalTransfers') {
233
+ worker.postMessage({
234
+ type: 'response',
235
+ value: totalTransfers,
236
+ id
237
+ })
183
238
  }
184
239
  if (e.type === 'has') {
185
240
  try {