@leofcoin/chain 1.4.21 → 1.4.23

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.
Files changed (92) hide show
  1. package/LICENSE +88 -88
  2. package/README.md +4 -4
  3. package/exports/chain.js +1071 -0
  4. package/exports/node.js +23 -0
  5. package/exports/typings/chain.d.ts +83 -0
  6. package/exports/typings/config/config.d.ts +1 -0
  7. package/exports/typings/config/main.d.ts +5 -0
  8. package/exports/typings/config/protocol.d.ts +6 -0
  9. package/exports/typings/contract.d.ts +29 -0
  10. package/exports/typings/fee/config.d.ts +4 -0
  11. package/exports/typings/machine.d.ts +26 -0
  12. package/exports/typings/node.d.ts +9 -0
  13. package/exports/typings/protocol.d.ts +4 -0
  14. package/exports/typings/state.d.ts +5 -0
  15. package/exports/typings/transaction.d.ts +47 -0
  16. package/exports/typings/typer.d.ts +6 -0
  17. package/package.json +77 -75
  18. package/CHANGELOG.md +0 -14
  19. package/block-worker.js +0 -1
  20. package/demo/865.browser.js +0 -10
  21. package/demo/chain.browser.js +0 -66842
  22. package/demo/generate-account.browser.js +0 -50
  23. package/demo/index.html +0 -25
  24. package/demo/messages.browser.js +0 -328
  25. package/demo/multi-wallet.browser.js +0 -15
  26. package/demo/node.browser.js +0 -9858
  27. package/demo/pako.browser.js +0 -6900
  28. package/demo/peernet-swarm.browser.js +0 -839
  29. package/demo/storage.browser.js +0 -3724
  30. package/demo/workers/865.js +0 -10
  31. package/demo/workers/block-worker.js +0 -13175
  32. package/demo/workers/machine-worker.js +0 -13385
  33. package/demo/workers/pool-worker.js +0 -8503
  34. package/demo/workers/transaction-worker.js +0 -8495
  35. package/demo/wrtc.browser.js +0 -28
  36. package/dist/browser/workers/865.js +0 -10
  37. package/dist/browser/workers/block-worker.js +0 -9460
  38. package/dist/browser/workers/machine-worker.js +0 -9670
  39. package/dist/browser/workers/pool-worker.js +0 -4608
  40. package/dist/browser/workers/transaction-worker.js +0 -4600
  41. package/dist/chain.js +0 -10128
  42. package/dist/client-80bc8156.js +0 -491
  43. package/dist/commonjs-7fe3c381.js +0 -270
  44. package/dist/contracts/factory.js +0 -1
  45. package/dist/contracts/name-service.js +0 -1
  46. package/dist/contracts/native-token.js +0 -1
  47. package/dist/contracts/validators.js +0 -1
  48. package/dist/generate-account-445db122.js +0 -46
  49. package/dist/index-57f93805.js +0 -718
  50. package/dist/messages-bce1b91d-81af3b00.js +0 -315
  51. package/dist/module/chain.js +0 -10091
  52. package/dist/module/client-8031ec88.js +0 -489
  53. package/dist/module/commonjs-9005d5c0.js +0 -268
  54. package/dist/module/generate-account-489552b6.js +0 -44
  55. package/dist/module/index-ac2285c4.js +0 -688
  56. package/dist/module/messages-bce1b91d-eaf75d83.js +0 -302
  57. package/dist/module/node.js +0 -7049
  58. package/dist/module/workers/block-worker.js +0 -94
  59. package/dist/module/workers/machine-worker.js +0 -304
  60. package/dist/module/workers/pool-worker.js +0 -55
  61. package/dist/module/workers/transaction-worker.js +0 -47
  62. package/dist/node.js +0 -7061
  63. package/dist/standards/token.js +0 -1
  64. package/dist/workers/machine-worker.js +0 -1
  65. package/dist/workers/pool-worker.js +0 -1
  66. package/dist/workers/transaction-worker.js +0 -1
  67. package/examples/contracts/token.js +0 -7
  68. package/plugins/bundle.js +0 -18
  69. package/rollup.config.js +0 -15
  70. package/src/chain.ts +0 -710
  71. package/src/config/config.js +0 -14
  72. package/src/config/main.js +0 -4
  73. package/src/config/protocol.js +0 -5
  74. package/src/contract.js +0 -52
  75. package/src/fee/config.js +0 -3
  76. package/src/machine.js +0 -215
  77. package/src/node.ts +0 -24
  78. package/src/protocol.js +0 -4
  79. package/src/state.js +0 -31
  80. package/src/transaction.ts +0 -182
  81. package/src/type.index.d.ts +0 -21
  82. package/src/typer.js +0 -19
  83. package/test/chain.js +0 -150
  84. package/test/contracts/token.js +0 -40
  85. package/test/create-genesis.js +0 -66
  86. package/test/index.js +0 -1
  87. package/tsconfig.json +0 -17
  88. package/workers/block-worker.js +0 -40
  89. package/workers/machine-worker.js +0 -219
  90. package/workers/pool-worker.js +0 -28
  91. package/workers/transaction-worker.js +0 -20
  92. package/workers/workers.js +0 -9
package/test/chain.js DELETED
@@ -1,150 +0,0 @@
1
- import { signTransaction } from '@leofcoin/lib'
2
-
3
- globalThis.DEBUG = true
4
- const Chain = await import('./../exports/chain.js');
5
- const Node = await import('./../exports/node.js');
6
- let imp = await import('../../networks/networks.js')
7
- const networks = imp.default
8
- console.log(networks.leofcoin.peach);
9
- const node = await new Node.default({
10
- network: 'leofcoin:peach',
11
- networkName: 'leofcoin:peach',
12
- networkVersion: 'peach',
13
- stars: networks.leofcoin.peach.stars
14
- })
15
- const chain = await new Chain.default()
16
- let start
17
- // console.log(peernet.identity.sign());
18
- await chain.participate(peernet.selectedAccount)
19
- console.log(peernet.selectedAccount);
20
- const job = async () => {
21
-
22
- let nonce = await chain.getNonce(peernet.selectedAccount)
23
- // // setTimeout(async () => {
24
- let tx
25
- // try {
26
- // const rawTransaction = await chain.createTransaction({
27
- // from: peernet.selectedAccount,
28
- // to: chain.nativeToken,
29
- // method: 'grantRole',
30
- // params: [peernet.selectedAccount, 'MINT']
31
- // })
32
- // const transaction = await signTransaction(rawTransaction, peernet.identity)
33
- // tx = await chain.sendTransaction(transaction)
34
- // console.log({tx});
35
- // await tx.wait
36
-
37
- // } catch (e) {
38
- // console.log({e});
39
- // }
40
-
41
- // try {
42
- // const rawTransaction = await chain.createTransaction({
43
- // from: peernet.selectedAccount,
44
- // to: chain.nativeToken,
45
- // method: 'mint',
46
- // params: [peernet.selectedAccount, chain.utils.parseUnits('100000000000000').toString()]
47
- // })
48
- // const transaction = await signTransaction(rawTransaction, peernet.identity)
49
- // tx = await chain.sendTransaction(transaction)
50
- // console.log({tx});
51
- // await tx.wait
52
- // } catch (e) {
53
- // console.log({e});
54
- // }
55
- // return
56
- console.log({nonce});
57
- let balances = await chain.balances
58
- console.log({balances});
59
- // return
60
- // console.log(`balance for ${Object.keys(balances)[0]}:${chain.utils.formatUnits(balances[Object.keys(balances)[0]]).toString()}`);
61
- // console.log(`balance for ${Object.keys(balances)[1]}:${chain.utils.formatUnits(balances[Object.keys(balances)[1]]).toString()}`);
62
- // return
63
- let promises = []
64
- // nonce +=
65
- nonce = await chain.getNonce(peernet.selectedAccount)
66
- for (let i = 0; i < 10; i++) {
67
- // contract , method, from, to, amount, (optional) nonce
68
- nonce += 1
69
- const rawTransaction = await chain.createTransaction({
70
- from: peernet.selectedAccount,
71
- to: chain.nativeToken,
72
- method: 'transfer',
73
- nonce,
74
- params: [peernet.selectedAccount, '6zqut21djrRNJAniaTByovGhnBGs5h9wfkP35mzjZkEBZwnQVo', chain.utils.parseUnits('100').toString()]
75
- })
76
- const transaction = await signTransaction(rawTransaction, peernet.identity)
77
- promises.push(chain.sendTransaction(transaction))
78
- }
79
- promises = await Promise.allSettled(promises)
80
- promises = await Promise.allSettled(promises.map(({value}) => value.wait))
81
-
82
- console.log(`${(new Date().getTime() - start) / 1000} s`);
83
-
84
- balances = await chain.balances
85
- console.log(`balance for ${Object.keys(balances)[0]}:${chain.utils.formatUnits(balances[Object.keys(balances)[0]]).toString()}`);
86
- console.log(`balance for ${Object.keys(balances)[1]}:${chain.utils.formatUnits(balances[Object.keys(balances)[1]]).toString()}`);
87
- // return
88
- // // setTimeout(async () => {
89
- promises = []
90
- nonce = await chain.getNonce(peernet.selectedAccount)
91
- // nonce += 1
92
- for (let i = 0; i < 10; i++) {
93
- // contract , method, from, to, amount, (optional) nonce
94
- nonce += 1
95
- const rawTransaction = await chain.createTransaction({
96
- from: peernet.selectedAccount,
97
- to: chain.nativeToken,
98
- method: 'transfer',
99
- nonce,
100
- params: [peernet.selectedAccount, '6zqut21djrRNJAniaTByovGhnBGs5h9wfkP35mzjZkEBZwnQVo', chain.utils.parseUnits('100').toString()]
101
- })
102
- const transaction = await signTransaction(rawTransaction, peernet.identity)
103
- promises.push(chain.sendTransaction(transaction))
104
- }
105
- promises = await Promise.allSettled(promises)
106
- promises = await Promise.allSettled(promises.map(({value}) => value.wait))
107
- balances = await chain.balances
108
- console.log(`balance for ${Object.keys(balances)[0]}:${chain.utils.formatUnits(balances[Object.keys(balances)[0]]).toString()}`);
109
- console.log(`balance for ${Object.keys(balances)[1]}:${chain.utils.formatUnits(balances[Object.keys(balances)[1]]).toString()}`);
110
-
111
- promises = []
112
- nonce = await chain.getNonce(peernet.selectedAccount)
113
-
114
- const createSignSendTransaction = async (nonce) => {
115
- const rawTransaction = await chain.createTransaction({
116
- from: peernet.selectedAccount,
117
- to: chain.nativeToken,
118
- method: 'transfer',
119
- nonce,
120
- params: [peernet.selectedAccount, '6zqut21djrRNJAniaTByovGhnBGs5h9wfkP35mzjZkEBZwnQVo', chain.utils.parseUnits('100').toString()]
121
- })
122
- const transaction = await signTransaction(rawTransaction, peernet.identity)
123
- return chain.sendTransaction(transaction)
124
- }
125
- // nonce += 1
126
- for (let i = 0; i < 1000; i++) {
127
- nonce += 1
128
- promises.push(createSignSendTransaction(nonce))
129
- }
130
- promises = await Promise.allSettled(promises)
131
- promises = await Promise.allSettled(promises.map(({value}) => value.wait))
132
- balances = await chain.balances
133
- console.log(`balance for ${Object.keys(balances)[0]}:${chain.utils.formatUnits(balances[Object.keys(balances)[0]]).toString()}`);
134
- console.log(`balance for ${Object.keys(balances)[1]}:${chain.utils.formatUnits(balances[Object.keys(balances)[1]]).toString()}`);
135
- // }, 10000);
136
-
137
- // job()
138
- // }, 5000);
139
- }
140
-
141
- // setTimeout(function () {
142
- // start = new Date().getTime()
143
- // console.log(peernet.connections);
144
- // }, 10000);
145
- try {
146
- job()
147
- } catch (e) {
148
- console.warn(e);
149
- }
150
-
@@ -1,40 +0,0 @@
1
- const test = require('tape')
2
-
3
- const Token = require('./../../dist/token');
4
-
5
- class TestToken extends Token {
6
- constructor() {
7
- super('token', 'TKN')
8
- }
9
- }
10
-
11
-
12
- // const token = new TestToken()
13
-
14
- test("can't access private", tape => {
15
- tape.plan(3)
16
- token.holders = 5
17
- token.balances[0] = 100
18
- token.symbol = 'TTT'
19
- console.log(token.symbol);
20
- tape.ok(token.symbol === 'TKN', 'symbol')
21
- tape.ok(Object.keys(token.balances).length === 0, 'balances')
22
- tape.ok(token.holders === 0, 'holders')
23
- })
24
-
25
- // test("transfer", tape => {
26
- // tape.plan(1)
27
- // console.log(token.balances);
28
- // try {
29
- // token.transfer('0', '1', 100)
30
- // } catch (e) {
31
- // console.log(e);
32
- // } finally {
33
- //
34
- // }
35
- // console.log(token.balances);
36
- //
37
- // tape.ok(token.balances[1] === 100)
38
- // })
39
-
40
- // console.log(new NativeToken());
@@ -1,66 +0,0 @@
1
-
2
- console.log('run');
3
-
4
- (async () => {
5
- console.log('run');
6
- const {promisify} = require('util')
7
- const read = promisify(require('fs').readFile)
8
- const write = promisify(require('fs').writeFile)
9
- const {join} = require('path')
10
- console.log('t');
11
- const Chain = require('./../dist/chain');
12
- console.log(Chain);
13
- const Node = require('./../dist/node');
14
- console.log(Node);
15
- console.log(Chain);
16
- const node = await new Node()
17
- console.log(node);
18
- const chain = await new Chain()
19
- console.log(chain);
20
- const createMessage = async (src, params = []) => {
21
- const contract = await read(src)
22
- return chain.createContractMessage(peernet.id, `return ${contract.toString().replace(/export{([A-Z])\w+ as default}/g, '')}`, params)
23
- }
24
- const factory = await createMessage('./dist/contracts/factory.js')
25
- console.log(factory);
26
- if (!await contractStore.has(factory.hash)) {
27
- await contractStore.put(factory.hash, factory.encoded)
28
- }
29
-
30
- const nativeToken = await createMessage('./dist/contracts/nativeToken.js')
31
- if (!await contractStore.has(nativeToken.hash)) {
32
- await contractStore.put(nativeToken.hash, nativeToken.encoded)
33
- }
34
-
35
-
36
- const validators = await createMessage('./dist/contracts/validators.js', [nativeToken.hash])
37
-
38
- if (!await contractStore.has(validators.hash)) {
39
- await contractStore.put(validators.hash, validators.encoded)
40
- }
41
-
42
-
43
- const nameService = await createMessage('./dist/contracts/nameService.js', [factory.hash, nativeToken.hash, validators.hash, BigNumber.from('1000')])
44
-
45
- if (!await contractStore.has(nameService.hash)) {
46
- await contractStore.put(nameService.hash, nameService.encoded)
47
- }
48
- const addresses = {
49
- contractFactory: factory.hash,
50
- nativeToken: nativeToken.hash,
51
- nameService: nameService.hash,
52
- validators: validators.hash
53
- }
54
-
55
-
56
-
57
- const bytecodes = {
58
- contractFactory: await factory.toString(),
59
- nativeToken: await nativeToken.toString(),
60
- nameService: await nameService.toString(),
61
- validators: await validators.toString()
62
- }
63
-
64
- await write(join(process.cwd(), 'src/addresses.json'), JSON.stringify(addresses, null, '\t'))
65
- await write(join(process.cwd(), 'src/bytecodes.json'), JSON.stringify(bytecodes, null, '\t'))
66
- })()
package/test/index.js DELETED
@@ -1 +0,0 @@
1
- import './chain.js'
package/tsconfig.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "es2022",
4
- "target": "es2022",
5
- "outDir": "./exports",
6
- "moduleResolution":"NodeNext",
7
- "declaration": true,
8
- "declarationDir": "./exports/typings",
9
- "allowJs": true,
10
- "allowSyntheticDefaultImports": true,
11
- "resolveJsonModule": true
12
- },
13
- "include": [
14
- "./src/**/*"
15
- ],
16
- "exclude": ["./node_modules"]
17
- }
@@ -1,40 +0,0 @@
1
- import { BlockMessage } from './../../messages/src/messages.js'
2
- import { formatBytes, BigNumber } from './../../utils/src/utils.js'
3
-
4
- import EasyWorker from '@vandeurenglenn/easy-worker'
5
-
6
- const worker = new EasyWorker()
7
-
8
- globalThis.BigNumber = BigNumber
9
-
10
- globalThis.peernet = globalThis.peernet || {}
11
- globalThis.contracts = {}
12
-
13
- const run = async (blocks) => {
14
- blocks = await Promise.all(blocks.map(block => new BlockMessage(block)))
15
- blocks = blocks.sort((a, b) => a.decoded.timestamp - b.decoded.timestamp)
16
-
17
- blocks = await Promise.all(blocks.map(block => new Promise(async (resolve, reject) => {
18
- // todo: tx worker or nah?
19
- const size = block.encoded.length || block.encoded.byteLength
20
- console.log(`loaded block: ${await block.hash} @${block.decoded.index} ${formatBytes(size)}`);
21
- resolve(block)
22
- })))
23
- return blocks
24
- }
25
-
26
- const tasks = async blocks => {
27
- globalThis.peernet.codecs = {
28
- 'block-message': {
29
- codec: parseInt('626d', 16),
30
- hashAlg: 'keccak-256'
31
- }
32
- }
33
-
34
- blocks = await run(blocks)
35
- worker.postMessage(blocks)
36
- }
37
-
38
-
39
- worker.onmessage(data => tasks(data))
40
-
@@ -1,219 +0,0 @@
1
- import { BlockMessage, ContractMessage } from './../../messages/src/messages.js'
2
- import { formatBytes, BigNumber } from './../../utils/src/utils.js'
3
- import bytecodes from './../../lib/src/bytecodes.json' assert {type: 'json'}
4
- import EasyWorker from '@vandeurenglenn/easy-worker'
5
- const worker = new EasyWorker()
6
-
7
- const contractFactoryMessage = bytecodes.contractFactory
8
- const nativeTokenMessage = bytecodes.nativeToken
9
- const nameServiceMessage = bytecodes.nameService
10
- const validatorsMessage = bytecodes.validators
11
-
12
- globalThis.BigNumber = BigNumber
13
-
14
- globalThis.peernet = globalThis.peernet || {}
15
- globalThis.contracts = {}
16
-
17
- const unique = arr => arr.filter((el, pos, arr) => {
18
- return arr.indexOf(el) == pos;
19
- })
20
-
21
- const get = (contract, method, params) => {
22
- let result
23
- if (params?.length > 0) {
24
- result = contracts[contract][method](...params)
25
- } else {
26
- result = contracts[contract][method]
27
- }
28
- return result
29
- }
30
-
31
- const runContract = async ({decoded, hash, encoded}) => {
32
- const params = decoded.constructorParameters
33
- try {
34
-
35
- const func = new Function(decoded.contract)
36
- const Contract = func()
37
-
38
- globalThis.msg = createMessage(decoded.creator)
39
- contracts[hash] = await new Contract(...params)
40
- worker.postMessage({
41
- type: 'debug',
42
- messages: [
43
- `loaded contract: ${hash}`,
44
- `size: ${formatBytes(encoded.length)}`
45
- ]
46
- })
47
- } catch (e) {
48
- console.log(e);
49
- worker.postMessage({
50
- type: 'contractError',
51
- hash: await contractMessage.hash
52
- })
53
- }
54
- }
55
-
56
- const execute = async (contract, method, params) => {
57
- try {
58
- let result
59
- // don't execute the method on a proxy
60
- if (contracts[contract].fallback) {
61
- result = await contracts[contract].fallback(method, params)
62
- } else {
63
- result = await contracts[contract][method](...params)
64
- }
65
- // state.put(result)
66
- return result
67
- } catch (e) {
68
- throw e
69
- }
70
- }
71
-
72
-
73
- const createMessage = (sender = globalThis.peerid) => {
74
- return {
75
- sender,
76
- call: execute,
77
- staticCall: get
78
- }
79
- }
80
-
81
- const _init = async ({ contracts, blocks, peerid })=> {
82
-
83
- globalThis.peernet.codecs = {
84
- 'contract-message': {
85
- codec: parseInt('63636d', 16),
86
- hashAlg: 'keccak-256'
87
- },
88
- 'transaction-message': {
89
- codec: parseInt('746d', 16),
90
- hashAlg: 'keccak-256'
91
- },
92
- 'block-message': {
93
- codec: parseInt('626d', 16),
94
- hashAlg: 'keccak-256'
95
- }
96
- }
97
-
98
- globalThis.peerid = peerid
99
- contracts = [
100
- contractFactoryMessage,
101
- nativeTokenMessage,
102
- nameServiceMessage,
103
- validatorsMessage
104
- ]
105
-
106
- contracts = await Promise.all(contracts.map(async contract => {
107
- contract = await new ContractMessage(new Uint8Array(contract.split(',')))
108
- await runContract({decoded: contract.decoded, encoded: contract.encoded, hash: await contract.hash})
109
- return contract
110
- }))
111
-
112
- let lastBlock = {hash: '0x0'};
113
-
114
- if (blocks?.length > 0) {
115
- const _worker = await new EasyWorker('./workers/block-worker.js', {serialization: 'advanced', type: 'module' })
116
- blocks = await _worker.once([blocks[blocks.length - 1]])
117
-
118
- // blocks = unique(globalThis.blocks ? globalThis : [], blocks)
119
- // for (let i = 0; i < blocks.length; i++) {
120
-
121
- // }
122
- // for (const block of blocks) {
123
- // await Promise.all(block.decoded.transactions.map(async message => {
124
- // if (!block.loaded) {
125
- // const {from, to, method, params} = message;
126
- // globalThis.msg = createMessage(from);
127
-
128
- // await execute(to, method, params);
129
- // block.loaded = true
130
- // }
131
- // }));
132
- // }
133
-
134
- if (blocks.length > 0) {
135
- lastBlock = blocks[blocks.length - 1].decoded;
136
- lastBlock = await new BlockMessage(lastBlock);
137
-
138
- lastBlock = {
139
- ...lastBlock.decoded,
140
- hash: await lastBlock.hash
141
- };
142
- }
143
- globalThis.blocks = blocks
144
- }
145
-
146
-
147
-
148
-
149
- worker.postMessage({type: 'machine-ready', lastBlock});
150
-
151
- // worker.postMessage({blocks});
152
- }
153
-
154
- const tasks = async (e) => {
155
- const id = e.id
156
- if (e.type === 'init') {
157
- try {
158
- await _init(e.input)
159
- } catch (e) {
160
- worker.postMessage({
161
- type: 'initError',
162
- message: e.message,
163
- id
164
- })
165
- }
166
- }
167
- if (e.type === 'run') {
168
- try {
169
- const value = await runContract(e.input)
170
- worker.postMessage({
171
- type: 'response',
172
- id,
173
- value
174
- })
175
- } catch (e) {
176
- worker.postMessage({
177
- type: 'runError',
178
- message: e.message,
179
- id
180
- })
181
- }
182
- }
183
- if (e.type === 'get') {
184
- try {
185
- const value = await get(e.input.contract, e.input.method, e.input.params)
186
- worker.postMessage({
187
- type: 'response',
188
- id,
189
- value
190
- })
191
- } catch (e) {
192
- worker.postMessage({
193
- type: 'fetchError',
194
- message: e.message,
195
- id
196
- })
197
- }
198
-
199
- }
200
- if (e.type === 'execute') {
201
- try {
202
- const value = await execute(e.input.contract, e.input.method, e.input.params)
203
- worker.postMessage({
204
- type: 'response',
205
- id,
206
- value
207
- })
208
- } catch(e) {
209
- worker.postMessage({
210
- type: 'executionError',
211
- message: e.message,
212
- id
213
-
214
- })
215
- }
216
- }
217
- }
218
-
219
- worker.onmessage(data => tasks(data))
@@ -1,28 +0,0 @@
1
- import { TransactionMessage } from './../../messages/src/messages.js'
2
-
3
- import EasyWorker from '@vandeurenglenn/easy-worker'
4
-
5
- globalThis.peernet = globalThis.peernet || {}
6
- globalThis.contracts = {}
7
-
8
- const worker = new EasyWorker()
9
-
10
- const tasks = async transactions => {
11
-
12
- globalThis.peernet.codecs = {
13
- 'transaction-message': {
14
- codec: parseInt('746d', 16),
15
- hashAlg: 'keccak-256'
16
- }
17
- }
18
-
19
- transactions = await Promise.all(transactions.map(async message => {
20
- message = await new TransactionMessage(message)
21
-
22
- return {...message.decoded, hash: await message.hash, size: message.encoded.length}
23
- }))
24
-
25
- worker.postMessage(transactions)
26
-
27
- }
28
- worker.onmessage(data => tasks(data))
@@ -1,20 +0,0 @@
1
- import { TransactionMessage } from './../../messages/src/messages.js'
2
-
3
- globalThis.peernet = globalThis.peernet || {}
4
- globalThis.contracts = {}
5
-
6
- import EasyWorker from '@vandeurenglenn/easy-worker'
7
-
8
- const worker = new EasyWorker()
9
-
10
- worker.onmessage(async (transactions) => {
11
- globalThis.peernet.codecs = {
12
- 'transaction-message': {
13
- codec: parseInt('746d', 16),
14
- hashAlg: 'keccak-256'
15
- }
16
- }
17
- transactions = await Promise.all(transactions.map(async message => new TransactionMessage(message)))
18
-
19
- worker.postMessage(transactions)
20
- })
@@ -1,9 +0,0 @@
1
- import * as transactionWorker from './transaction-worker.js'
2
- import * as blockWorker from './block-worker.js'
3
- import * as poolWorker from './pool-worker.js'
4
- import * as machineWorker from './machine-worker.js'
5
-
6
- export const TransactionWorker = transactionWorker
7
- export const BlockWorker = blockWorker
8
- export const PoolWorker = poolWorker
9
- export const MachineWorker = machineWorker