@leofcoin/workers 1.4.4 → 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 +1 -1
- package/src/machine-worker.js +11 -10
package/package.json
CHANGED
package/src/machine-worker.js
CHANGED
|
@@ -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 (
|
|
135
|
+
block.transactions.map(async (transaction) => {
|
|
135
136
|
if (!block.loaded) {
|
|
136
|
-
const { from, to, method, params } =
|
|
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 (
|
|
142
|
+
if (to === nativeToken) {
|
|
142
143
|
nativeCalls += 1
|
|
143
|
-
if (
|
|
144
|
-
if (
|
|
145
|
-
if (
|
|
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
|
|
154
|
-
nonce: String(
|
|
153
|
+
hash: await new TransactionMessage(transaction).hash(),
|
|
154
|
+
from,
|
|
155
|
+
nonce: String(nonce)
|
|
155
156
|
}
|
|
156
157
|
})
|
|
157
158
|
} catch (error) {
|