@leofcoin/workers 1.4.3 → 1.4.5

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.3",
3
+ "version": "1.4.5",
4
4
  "description": "Workers used in @leofcoin/chain",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,7 +1,8 @@
1
- import { BlockMessage, ContractMessage } from '@leofcoin/messages'
1
+ import { BlockMessage, ContractMessage, TransactionMessage } from '@leofcoin/messages'
2
2
  import { formatBytes, BigNumber } from '@leofcoin/utils'
3
3
  import bytecodes from '@leofcoin/lib/bytecodes' assert { type: 'json' }
4
4
  import EasyWorker from '@vandeurenglenn/easy-worker'
5
+ import { nativeToken } from '@leofcoin/addresses'
5
6
  const worker = new EasyWorker()
6
7
 
7
8
  const contractFactoryMessage = bytecodes.contractFactory
@@ -131,27 +132,27 @@ const _init = async ({ contracts, blocks, peerid }) => {
131
132
  for (const block of blocks) {
132
133
  try {
133
134
  await Promise.all(
134
- block.transactions.map(async (message) => {
135
+ block.transactions.map(async (transaction) => {
135
136
  if (!block.loaded) {
136
- const { from, to, method, params } = message
137
+ const { from, to, method, params, nonce } = transaction
137
138
  globalThis.msg = createMessage(from)
138
139
 
139
140
  try {
140
141
  await execute(to, method, params)
141
- if (transaction.decoded.to === nativeToken) {
142
+ if (to === nativeToken) {
142
143
  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
144
+ if (method === 'burn') nativeBurns += 1
145
+ if (method === 'mint') nativeMints += 1
146
+ if (method === 'transfer') nativeTransfers += 1
146
147
  }
147
148
  totalTransactions += 1
148
149
 
149
150
  postMessage({
150
151
  type: 'transactionLoaded',
151
152
  result: {
152
- hash: await transaction.hash(),
153
- from: transaction.decoded.from,
154
- nonce: String(transaction.decoded.nonce)
153
+ hash: await new TransactionMessage(transaction).hash(),
154
+ from,
155
+ nonce: String(nonce)
155
156
  }
156
157
  })
157
158
  } catch (error) {