@leofcoin/chain 1.8.22 → 1.8.24

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.
@@ -6314,13 +6314,11 @@ class Chain extends VersionControl {
6314
6314
  const node = await this.#prepareRequest(request);
6315
6315
  try {
6316
6316
  let response = await peer.request(node.encoded);
6317
- response = await new globalThis.peernet.protos['peernet-response'](new Uint8Array(Object.values(response)));
6318
- let decoded = response.decoded.response;
6319
- try {
6320
- decoded = JSON.parse(decoded);
6317
+ response = await new globalThis.peernet.protos['peernet-response'](response);
6318
+ if (!(response.decoded.response instanceof Uint8Array)) {
6319
+ console.warn(`Deprecated: ${response.decoded.response} is not an Uint8Array`);
6321
6320
  }
6322
- catch { }
6323
- return decoded;
6321
+ return response.decoded.response;
6324
6322
  }
6325
6323
  catch (error) {
6326
6324
  const peerId = peer?.peerId || peer?.id || peer?.address || 'unknown';
@@ -6329,7 +6327,18 @@ class Chain extends VersionControl {
6329
6327
  }
6330
6328
  }
6331
6329
  async getPeerTransactionPool(peer) {
6332
- const transactionsInPool = await this.#makeRequest(peer, 'transactionPool');
6330
+ let transactionsInPool = await this.#makeRequest(peer, 'transactionPool');
6331
+ if (transactionsInPool instanceof Uint8Array) {
6332
+ try {
6333
+ const text = new TextDecoder().decode(transactionsInPool);
6334
+ transactionsInPool = JSON.parse(text);
6335
+ }
6336
+ catch (e) {
6337
+ return [];
6338
+ }
6339
+ }
6340
+ if (!Array.isArray(transactionsInPool))
6341
+ return [];
6333
6342
  // todo iterate vs getting all keys?
6334
6343
  const transactions = await globalThis.transactionPoolStore.keys();
6335
6344
  const transactionsToGet = [];
package/exports/chain.js CHANGED
@@ -2455,13 +2455,11 @@ class Chain extends VersionControl {
2455
2455
  const node = await this.#prepareRequest(request);
2456
2456
  try {
2457
2457
  let response = await peer.request(node.encoded);
2458
- response = await new globalThis.peernet.protos['peernet-response'](new Uint8Array(Object.values(response)));
2459
- let decoded = response.decoded.response;
2460
- try {
2461
- decoded = JSON.parse(decoded);
2458
+ response = await new globalThis.peernet.protos['peernet-response'](response);
2459
+ if (!(response.decoded.response instanceof Uint8Array)) {
2460
+ console.warn(`Deprecated: ${response.decoded.response} is not an Uint8Array`);
2462
2461
  }
2463
- catch { }
2464
- return decoded;
2462
+ return response.decoded.response;
2465
2463
  }
2466
2464
  catch (error) {
2467
2465
  const peerId = peer?.peerId || peer?.id || peer?.address || 'unknown';
@@ -2470,7 +2468,18 @@ class Chain extends VersionControl {
2470
2468
  }
2471
2469
  }
2472
2470
  async getPeerTransactionPool(peer) {
2473
- const transactionsInPool = await this.#makeRequest(peer, 'transactionPool');
2471
+ let transactionsInPool = await this.#makeRequest(peer, 'transactionPool');
2472
+ if (transactionsInPool instanceof Uint8Array) {
2473
+ try {
2474
+ const text = new TextDecoder().decode(transactionsInPool);
2475
+ transactionsInPool = JSON.parse(text);
2476
+ }
2477
+ catch (e) {
2478
+ return [];
2479
+ }
2480
+ }
2481
+ if (!Array.isArray(transactionsInPool))
2482
+ return [];
2474
2483
  // todo iterate vs getting all keys?
2475
2484
  const transactions = await globalThis.transactionPoolStore.keys();
2476
2485
  const transactionsToGet = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.8.22",
3
+ "version": "1.8.24",
4
4
  "description": "Official javascript implementation",
5
5
  "private": false,
6
6
  "exports": {