@leofcoin/workers 1.4.13 → 1.4.14
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/CHANGELOG.md +13 -0
- package/package.json +5 -5
- package/src/machine-worker.js +10 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @leofcoin/workers
|
|
2
2
|
|
|
3
|
+
## 1.4.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d239d6b: Bump
|
|
8
|
+
- d239d6b: set to public
|
|
9
|
+
- Updated dependencies [d239d6b]
|
|
10
|
+
- Updated dependencies [d239d6b]
|
|
11
|
+
- @leofcoin/addresses@1.0.19
|
|
12
|
+
- @leofcoin/lib@1.2.39
|
|
13
|
+
- @leofcoin/messages@1.4.9
|
|
14
|
+
- @leofcoin/utils@1.1.14
|
|
15
|
+
|
|
3
16
|
## 1.4.13
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/workers",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.14",
|
|
4
4
|
"description": "Workers used in @leofcoin/chain",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"author": "",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@leofcoin/addresses": "^1.0.
|
|
23
|
-
"@leofcoin/lib": "^1.2.
|
|
24
|
-
"@leofcoin/messages": "^1.
|
|
22
|
+
"@leofcoin/addresses": "^1.0.19",
|
|
23
|
+
"@leofcoin/lib": "^1.2.39",
|
|
24
|
+
"@leofcoin/messages": "^1.4.9",
|
|
25
25
|
"@leofcoin/storage": "^3.3.2",
|
|
26
|
-
"@leofcoin/utils": "^1.1.
|
|
26
|
+
"@leofcoin/utils": "^1.1.14",
|
|
27
27
|
"@vandeurenglenn/easy-worker": "^1.0.2"
|
|
28
28
|
}
|
|
29
29
|
}
|
package/src/machine-worker.js
CHANGED
|
@@ -77,7 +77,7 @@ _.runContract = async ({ decoded, hash, encoded }, state) => {
|
|
|
77
77
|
|
|
78
78
|
if (state) params.push(state)
|
|
79
79
|
|
|
80
|
-
globalThis.msg = createMessage(decoded.creator)
|
|
80
|
+
globalThis.msg = createMessage(decoded.creator, hash)
|
|
81
81
|
contracts[hash] = await new Contract(...params)
|
|
82
82
|
|
|
83
83
|
debug(`loaded contract: ${hash} size: ${formatBytes(encoded.length)}`)
|
|
@@ -94,6 +94,7 @@ _.runContract = async ({ decoded, hash, encoded }, state) => {
|
|
|
94
94
|
_.execute = async ({ contract, method, params }) => {
|
|
95
95
|
try {
|
|
96
96
|
let result
|
|
97
|
+
|
|
97
98
|
// don't execute the method on a proxy
|
|
98
99
|
if (contracts[contract].fallback) {
|
|
99
100
|
result = await contracts[contract].fallback(method, params)
|
|
@@ -103,6 +104,7 @@ _.execute = async ({ contract, method, params }) => {
|
|
|
103
104
|
// state.put(result)
|
|
104
105
|
return result
|
|
105
106
|
} catch (e) {
|
|
107
|
+
console.log({ e })
|
|
106
108
|
throw new Error(
|
|
107
109
|
`error: ${e.message}
|
|
108
110
|
contract: ${contract}
|
|
@@ -113,8 +115,9 @@ _.execute = async ({ contract, method, params }) => {
|
|
|
113
115
|
}
|
|
114
116
|
}
|
|
115
117
|
|
|
116
|
-
const createMessage = (sender = globalThis.peerid) => {
|
|
118
|
+
const createMessage = (sender = globalThis.peerid, contract) => {
|
|
117
119
|
return {
|
|
120
|
+
contract,
|
|
118
121
|
sender,
|
|
119
122
|
call: _.execute,
|
|
120
123
|
staticCall: get
|
|
@@ -153,6 +156,7 @@ const _executeTransaction = async (transaction) => {
|
|
|
153
156
|
_.init = async (message) => {
|
|
154
157
|
let { peerid, fromState, state } = message
|
|
155
158
|
globalThis.peerid = peerid
|
|
159
|
+
console.log({ fromState })
|
|
156
160
|
if (fromState) {
|
|
157
161
|
lastBlock = message.lastBlock
|
|
158
162
|
const setState = async (address, state) => {
|
|
@@ -185,15 +189,13 @@ _.init = async (message) => {
|
|
|
185
189
|
// )
|
|
186
190
|
await Promise.all(promises)
|
|
187
191
|
} else {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
contracts = await Promise.all(
|
|
191
|
-
contracts.map(async (contract) => {
|
|
192
|
+
await Promise.all(
|
|
193
|
+
[contractFactoryMessage, nativeTokenMessage, nameServiceMessage, validatorsMessage].map(async (contract) => {
|
|
192
194
|
contract = await new ContractMessage(new Uint8Array(contract.split(',')))
|
|
193
|
-
|
|
194
|
-
return contract
|
|
195
|
+
return _.runContract({ decoded: contract.decoded, encoded: contract.encoded, hash: await contract.hash() })
|
|
195
196
|
})
|
|
196
197
|
)
|
|
198
|
+
console.log({ blocks: message.blocks })
|
|
197
199
|
if (message.blocks?.length > 0) {
|
|
198
200
|
let pre
|
|
199
201
|
|