@paimaexample/npm-midnight-indexer 0.3.43 → 0.3.45

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/binary.js CHANGED
@@ -4,6 +4,11 @@ const axios = require("axios");
4
4
  const extract = require("extract-zip");
5
5
  const path = require("path");
6
6
 
7
+ const CURRENT_BINARY_VERSION = "v2.1.4";
8
+
9
+ /*
10
+ @returns {string} The platform and architecture of the current machine. Example: "linux-amd64"
11
+ */
7
12
  function getPlatform() {
8
13
  const platform = os.platform();
9
14
  const arch = os.arch();
@@ -24,6 +29,9 @@ function getPlatform() {
24
29
  }
25
30
  }
26
31
 
32
+ /*
33
+ @returns {string} The URL to download the binary for the current platform.
34
+ */
27
35
  function getBinaryUrl() {
28
36
  const platform = getPlatform();
29
37
  const supportedPlatforms = require("./package.json").supportedPlatforms;
@@ -31,9 +39,12 @@ function getBinaryUrl() {
31
39
  if (!supportedPlatforms.includes(platform)) {
32
40
  throw new Error(`Unsupported platform: ${platform}`);
33
41
  }
34
- return `https://paima-midnight.nyc3.cdn.digitaloceanspaces.com/binaries/indexer-standalone-${platform}.zip`;
42
+ return `https://paima-midnight.nyc3.cdn.digitaloceanspaces.com/binaries/indexer-standalone-${platform}-${CURRENT_BINARY_VERSION}.zip`;
35
43
  }
36
44
 
45
+ /*
46
+ @returns {Promise<void>} Downloads and saves the binary for the current platform.
47
+ */
37
48
  async function downloadAndSaveBinary() {
38
49
  const url = getBinaryUrl();
39
50
  try {
@@ -55,10 +66,15 @@ async function downloadAndSaveBinary() {
55
66
  }
56
67
  }
57
68
 
69
+ /*
70
+ @returns {Promise<void>} Unzips the binary for the current platform.
71
+ */
58
72
  async function unzipBinary() {
59
- await extract(path.join(__dirname, "indexer-standalone.zip"), {
60
- dir: path.join(__dirname, "indexer-standalone"),
61
- });
73
+ const dir = path.join(__dirname, "indexer-standalone");
74
+ if (!fs.existsSync(dir)) {
75
+ fs.mkdirSync(dir, { recursive: true });
76
+ }
77
+ await extract(path.join(__dirname, "indexer-standalone.zip"), { dir });
62
78
  fs.unlinkSync(path.join(__dirname, "indexer-standalone.zip"));
63
79
 
64
80
  const platform = getPlatform();
package/index.js CHANGED
@@ -11,9 +11,7 @@ const os = require("os");
11
11
  function checkIfBinaryExists() {
12
12
  const platform = getPlatform();
13
13
  const parts = platform.split("-");
14
- const binaryName = (parts[0] === "linux")
15
- ? `indexer-standalone-${platform}`
16
- : `indexer-standalone`;
14
+ const binaryName = `indexer-standalone-${platform}`;
17
15
  return fs.existsSync(
18
16
  path.join(__dirname, "indexer-standalone", binaryName),
19
17
  );
@@ -0,0 +1,44 @@
1
+ run_migrations: true
2
+ network_id: &network_id "Undeployed"
3
+
4
+ chain_indexer_application:
5
+ network_id: *network_id
6
+ blocks_buffer: 60
7
+ save_zswap_state_after: 1000
8
+ caught_up_max_distance: 60
9
+ caught_up_leeway: 30
10
+
11
+ wallet_indexer_application:
12
+ network_id: *network_id
13
+ active_wallets_repeat_delay: "100ms"
14
+ active_wallets_ttl: "30m"
15
+ transaction_batch_size: 10
16
+ # Number of cores by default.
17
+ # parallelism:
18
+
19
+ infra:
20
+ node:
21
+ url: "ws://localhost:9944"
22
+ reconnect_max_delay: "10s" # 10ms, 100ms, 1s, 10s
23
+ reconnect_max_attempts: 30 # Roughly 5m
24
+
25
+ storage:
26
+ cnn_url: "./data/indexer.sqlite"
27
+
28
+ api:
29
+ address: "127.0.0.1"
30
+ port: 8088
31
+ request_body_limit: "1MiB"
32
+ max_complexity: 200
33
+ max_depth: 15
34
+ network_id: *network_id
35
+
36
+ telemetry:
37
+ tracing:
38
+ enabled: false
39
+ service_name: "indexer"
40
+ otlp_exporter_endpoint: "http://localhost:4317"
41
+ metrics:
42
+ enabled: false
43
+ address: "0.0.0.0"
44
+ port: 9000
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paimaexample/npm-midnight-indexer",
3
- "version": "0.3.43",
3
+ "version": "0.3.45",
4
4
  "description": "Downloads and runs the Midnight Indexer. It needs a running Midnight Node",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -112,9 +112,7 @@ function handleCleanFlag(env, workingDir) {
112
112
  function runMidnightIndexer(env = process.env, args = []) {
113
113
  const platform = getPlatform();
114
114
  const parts = platform.split("-");
115
- const binaryName = (parts[0] === "linux")
116
- ? `indexer-standalone-${platform}`
117
- : "indexer-standalone";
115
+ const binaryName = `indexer-standalone-${platform}`;
118
116
  const binaryPath = path.join(
119
117
  __dirname,
120
118
  "indexer-standalone",