@mentaproject/client 0.0.9 → 0.0.10

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.
@@ -36,7 +36,9 @@ export class Block {
36
36
  ;
37
37
  async toJSON(depth = 1) {
38
38
  return await toJSON({
39
- obj: this,
39
+ obj: {
40
+ ...this,
41
+ },
40
42
  depth
41
43
  });
42
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mentaproject/client",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "High level EVM library used into the Menta App to facilitate Blockchain interactions. ",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -29,7 +29,7 @@
29
29
  "author": "@mentaproject",
30
30
  "license": "ISC",
31
31
  "dependencies": {
32
- "@mentaproject/contracts": "^0.0.8",
32
+ "@mentaproject/contracts": "^0.0.9",
33
33
  "@mentaproject/core": "^0.0.4",
34
34
  "@shazow/whatsabi": "^0.21.1"
35
35
  },
package/test.ts CHANGED
@@ -7,22 +7,30 @@ import { writeFileSync } from "fs";
7
7
 
8
8
  const viemAccount = privateKeyToAccount(generatePrivateKey());
9
9
 
10
+ let time = Date.now();
11
+
10
12
  const client = new MentaClient({
11
13
  account: viemAccount,
12
14
  transport: http("https://red-nameless-panorama.quiknode.pro/0f30278c4c66afdc9f8679975e13cd5a92c7d937/", {
13
15
  batch: {
14
- batchSize: 15,
15
- wait: 1000
16
+ batchSize: 6,
17
+ wait: 500,
18
+ waitAsRateLimit: true
19
+ },
20
+ onFetchRequest: async (r) => {
21
+ const delay = Date.now() - time;
22
+ time = Date.now();
23
+
24
+ console.log(`>> ${r.url}\n>> ${(await r.json()).map(j => j.method).join(', ')}\n>> ${delay / 1000}s\n`)
16
25
  },
17
- onFetchRequest: (r) => console.log(`>>: ${r.url}`),
18
26
  // onFetchResponse: (r) => console.log(`<<: ${r.url}`),
19
27
  }),
20
28
  chain: mainnet
21
29
  });
22
30
 
23
31
  (async () => {
24
- const firstTx = await client.transactions.get({ hash: "0xeae261aeada2db19fee5cc4dfd47d575ff2380a5fb6a4039685d5044fdc8e2bb" });
25
- const json = await firstTx.toJSON(3);
32
+ const firstTx = await client.transactions.get({ hash: "0x48e6f527c659c6e2c5a504864fc269599047e151dd35fc509387599fe4b82370" });
33
+ const json = await firstTx.toJSON(1);
26
34
 
27
35
  writeFileSync("./test.json", JSON.stringify(json, null, 2));
28
36
  })()