@leofcoin/workers 1.4.13 → 1.4.15

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 CHANGED
@@ -1,5 +1,30 @@
1
1
  # @leofcoin/workers
2
2
 
3
+ ## 1.4.15
4
+
5
+ ### Patch Changes
6
+
7
+ - fb4e9c7: Bump
8
+ - Updated dependencies [fb4e9c7]
9
+ - Updated dependencies [1da023a]
10
+ - @leofcoin/addresses@1.0.20
11
+ - @leofcoin/messages@1.4.10
12
+ - @leofcoin/utils@1.1.15
13
+ - @leofcoin/lib@1.2.40
14
+
15
+ ## 1.4.14
16
+
17
+ ### Patch Changes
18
+
19
+ - d239d6b: Bump
20
+ - d239d6b: set to public
21
+ - Updated dependencies [d239d6b]
22
+ - Updated dependencies [d239d6b]
23
+ - @leofcoin/addresses@1.0.19
24
+ - @leofcoin/lib@1.2.39
25
+ - @leofcoin/messages@1.4.9
26
+ - @leofcoin/utils@1.1.14
27
+
3
28
  ## 1.4.13
4
29
 
5
30
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/workers",
3
- "version": "1.4.13",
3
+ "version": "1.4.15",
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.18",
23
- "@leofcoin/lib": "^1.2.38",
24
- "@leofcoin/messages": "^1.2.0",
22
+ "@leofcoin/addresses": "^1.0.20",
23
+ "@leofcoin/lib": "^1.2.40",
24
+ "@leofcoin/messages": "^1.4.10",
25
25
  "@leofcoin/storage": "^3.3.2",
26
- "@leofcoin/utils": "^1.1.5",
26
+ "@leofcoin/utils": "^1.1.15",
27
27
  "@vandeurenglenn/easy-worker": "^1.0.2"
28
28
  }
29
29
  }
@@ -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
- contracts = [contractFactoryMessage, nativeTokenMessage, nameServiceMessage, validatorsMessage]
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
- await _.runContract({ decoded: contract.decoded, encoded: contract.encoded, hash: await contract.hash() })
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