@leofcoin/chain 1.4.15 → 1.4.16

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/chain",
3
- "version": "1.4.15",
3
+ "version": "1.4.16",
4
4
  "description": "Official javascript implementation",
5
5
  "main": "./dist/node.js",
6
6
  "module": "./dist/chain.esm",
package/src/chain.js CHANGED
@@ -282,7 +282,7 @@ export default class Chain extends Contract {
282
282
  }
283
283
 
284
284
  async #syncChain(lastBlock) {
285
- if (this.#chainSyncing) return
285
+ if (this.#chainSyncing || !lastBlock || !lastBlock.hash || !lastBlock.hash) return
286
286
 
287
287
  if (!this.lastBlock || Number(this.lastBlock.index) < Number(lastBlock.index)) {
288
288
  this.#chainSyncing = true
@@ -304,12 +304,8 @@ export default class Chain extends Contract {
304
304
  async #peerConnected(peer) {
305
305
  let node = await new peernet.protos['peernet-request']({request: 'lastBlock'})
306
306
  node = await peernet.prepareMessage(node)
307
- console.log(node);
308
307
  let response = await peer.request(node.encoded)
309
- console.log(response);
310
- console.log(new TextDecoder().decode(response));
311
308
  response = await new globalThis.peernet.protos['peernet-response'](response)
312
- console.log(response);
313
309
  let lastBlock = response.decoded.response
314
310
  this.#syncChain(lastBlock)
315
311
  }
@@ -318,7 +314,7 @@ export default class Chain extends Contract {
318
314
 
319
315
 
320
316
  async #lastBlockHandler() {
321
- return new peernet.protos['peernet-response']({response: new TextEncoder().encode(JSON.stringify({ hash: this.#lastBlock?.hash, index: this.#lastBlock?.index }))})
317
+ return new peernet.protos['peernet-response']({response: { hash: this.#lastBlock?.hash, index: this.#lastBlock?.index }})
322
318
  }
323
319
 
324
320
  async resolveBlock(hash) {
package/test/chain.js CHANGED
@@ -30,13 +30,13 @@ const job = async () => {
30
30
  // console.log({e});
31
31
  // }
32
32
 
33
- try {
34
- tx = await chain.createTransaction(chain.nativeToken, 'mint', [peernet.selectedAccount, chain.utils.parseUnits('100000000000000').toString()])
33
+ // try {
34
+ // tx = await chain.createTransaction(chain.nativeToken, 'mint', [peernet.selectedAccount, chain.utils.parseUnits('100000000000000').toString()])
35
35
 
36
- await tx.wait
37
- } catch (e) {
38
- console.log({e});
39
- }
36
+ // await tx.wait
37
+ // } catch (e) {
38
+ // console.log({e});
39
+ // }
40
40
  return
41
41
  console.log({nonce});
42
42
  let balances = await chain.balances