@certik/skynet 0.10.2 → 0.10.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.5
4
+
5
+ - BREAKING Changed the signature of `postGenieMessage` function in `opsgenie` to make it more customizable
6
+
7
+ ## 0.10.4
8
+
9
+ - Fixed typo in coinmarketcap ids in `PROTOCOLS` in `const`
10
+
11
+ ## 0.10.3
12
+
13
+ - Added coinmarketcap ids to `PROTOCOLS` in `const`
14
+
3
15
  ## 0.10.2
4
16
 
5
17
  - Added opsgenie api key to check job automatically so it is not required to be defined in jobs
package/const.js CHANGED
@@ -17,6 +17,7 @@ const PROTOCOLS = {
17
17
  nativeTokenAddress: "eth:0x0000000000000000000000000000000000000000",
18
18
  nativeTokenLogo: `https://token-logo.certik-assets.com/eth:0x0000000000000000000000000000000000000000.png`,
19
19
  nativeTokenCoinGeckoId: "ethereum",
20
+ nativeTokenCmcId: 1027,
20
21
  endpoint: "https://eth-full-node.certik-skynet.com",
21
22
  archiveEndpoint: "https://eth-node.certik-skynet.com",
22
23
  tokenStandard: "ERC20",
@@ -34,6 +35,7 @@ const PROTOCOLS = {
34
35
  nativeTokenAddress: "bsc:0x0000000000000000000000000000000000000000",
35
36
  nativeTokenLogo: `https://token-logo.certik-assets.com/bsc:0x0000000000000000000000000000000000000000.png`,
36
37
  nativeTokenCoinGeckoId: "binance-coin",
38
+ nativeTokenCmcId: 1839,
37
39
  endpoint: "https://bsc-full-node.certik-skynet.com",
38
40
  archiveEndpoint: `https://bsc-mainnet.nodereal.io/v1/${getNodeRealApiKey("BSC")}`,
39
41
  tokenStandard: "BEP20",
@@ -51,6 +53,7 @@ const PROTOCOLS = {
51
53
  nativeTokenAddress: "polygon:0x0000000000000000000000000000000000000000",
52
54
  nativeTokenLogo: `https://token-logo.certik-assets.com/polygon:0x0000000000000000000000000000000000000000.png`,
53
55
  nativeTokenCoinGeckoId: "matic-network",
56
+ nativeTokenCmcId: 3890,
54
57
  endpoint: `https://poly-full-node.certik-skynet.com`,
55
58
  backupEndpoint: `https://matic.getblock.io/mainnet/?api_key=${getGetBlockApiKey()}`,
56
59
  archiveEndpoint: `https://polygon-mainnet.g.alchemy.com/v2/${getAlchemyApiKey("POLYGON")}`,
package/deploy.js CHANGED
@@ -91,7 +91,8 @@ const genConfig = ({
91
91
  port "http" {
92
92
  static = ${service.port}
93
93
  }
94
- }` : ""
94
+ }`
95
+ : ""
95
96
  }
96
97
 
97
98
  task "log-shipper" {
@@ -437,6 +438,7 @@ function createModeDeploy({
437
438
  SKYNET_NOMAD_PRODUCTION_ADDR: null,
438
439
  SKYNET_SLACK_TOKEN: null,
439
440
  OPSGENIE_API_KEY: null,
441
+ OPSGENIE_END_POINT: null,
440
442
  },
441
443
  region,
442
444
  cmd: `${check.bin} ${args} ${production ? "--production" : ""}`,
@@ -596,6 +598,7 @@ function createDeploy({
596
598
  SKYNET_NOMAD_PRODUCTION_ADDR: null,
597
599
  SKYNET_SLACK_TOKEN: null,
598
600
  OPSGENIE_API_KEY: null,
601
+ OPSGENIE_END_POINT: null,
599
602
  },
600
603
  region,
601
604
  cmd: `${check.bin} ${args} ${production ? "--production" : ""}`,
package/monitor.js CHANGED
@@ -153,12 +153,14 @@ ${
153
153
 
154
154
  // alert on opsgenie
155
155
  await postGenieMessage(
156
- `Failed Service Check: ${jobName}`,
157
- `<p><b>Service:</b><a href="${nomadAddr}/ui/jobs/${jobName}" target="_blank">${jobName}</a></p><p><b>Issues</b></p><ul>${sortErrors(
158
- result
159
- )
160
- .map((m) => `<li><b>${m.type}:</b> ${m.message}</li>`)
161
- .join("")}</ul>`,
156
+ {
157
+ message: `Failed Service Check: ${jobName}`,
158
+ description: `<p><b>Service:</b><a href="${nomadAddr}/ui/jobs/${jobName}" target="_blank">${jobName}</a></p><p><b>Issues</b></p><ul>${sortErrors(
159
+ result
160
+ )
161
+ .map((m) => `<li><b>${m.type}:</b> ${m.message}</li>`)
162
+ .join("")}</ul>`,
163
+ },
162
164
  verbose
163
165
  );
164
166
  } else {
package/opsgenie.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const fetch = require("node-fetch");
2
- const hash = require("object-hash");
2
+ const md5 = require("md5");
3
3
 
4
4
  function getGenieKey() {
5
5
  return process.env.OPSGENIE_API_KEY;
@@ -15,32 +15,28 @@ function getGenieEndPoint() {
15
15
  return process.env.OPSGENIE_END_POINT;
16
16
  }
17
17
 
18
- async function postGenieMessage(msg, desc, verbose) {
18
+ async function postGenieMessage(body, verbose) {
19
19
  try {
20
20
  const genieKey = getGenieKey();
21
21
  const genieEndPoint = getGenieEndPoint();
22
22
 
23
- const body = {
24
- message: msg,
25
- description: desc
26
- };
27
-
28
23
  // Prevents duplicate alerts (See Opsgenie doc about alias)
29
- const bodyHash = hash(body);
30
- body.alias = bodyHash;
24
+ if (!body.alias) {
25
+ body.alias = md5(body.message);
26
+ }
31
27
 
32
28
  if (verbose) {
33
- console.log(`Making API call to Opsgenie ${msg} (${desc}):`, JSON.stringify(body, null, 2));
29
+ console.log(`Making API call to Opsgenie`, JSON.stringify(body, null, 2));
34
30
  }
35
31
 
36
32
  // Makes the call using fetch and ENV variables
37
33
  const response = await fetch(genieEndPoint, {
38
34
  method: "POST",
39
35
  headers: {
40
- "Content-Type": "application/json",
41
- "Authorization": "GenieKey " + genieKey
36
+ "Content-Type": "application/json",
37
+ Authorization: `GenieKey ${genieKey}`,
42
38
  },
43
- body: JSON.stringify(body)
39
+ body: JSON.stringify(body),
44
40
  });
45
41
 
46
42
  const result = await response.json();
@@ -48,8 +44,7 @@ async function postGenieMessage(msg, desc, verbose) {
48
44
  console.log(`Result of API call to Opsgenie... ${result}`);
49
45
  }
50
46
 
51
- return result
52
-
47
+ return result;
53
48
  } catch (error) {
54
49
  console.error("Failed to make opsgenie API call", error);
55
50
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@certik/skynet",
3
- "version": "0.10.2",
3
+ "version": "0.10.5",
4
4
  "description": "Skynet Shared JS library",
5
5
  "main": "index.js",
6
6
  "author": "CertiK Engineering",
@@ -18,9 +18,9 @@
18
18
  "execa": "^5.0.0",
19
19
  "express": "^4.18.1",
20
20
  "kafkajs": "^1.15.0",
21
+ "md5": "^2.3.0",
21
22
  "meow": "^7.0.1",
22
23
  "node-fetch": "^2.6.1",
23
- "object-hash": "^2.2.0",
24
24
  "snowflake-sdk": "^1.6.3",
25
25
  "web3": "^1.3.5",
26
26
  "which": "^2.0.2"