@certik/skynet 0.10.48 → 0.10.50
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 +9 -0
- package/api.js +1 -1
- package/const.js +7 -7
- package/env.js +1 -12
- package/opsgenie.js +5 -11
- package/package.json +1 -1
- package/slack.d.ts +6 -1
- package/slack.js +9 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.50
|
|
4
|
+
|
|
5
|
+
- Update slack postMessage to allow passing channelId directly
|
|
6
|
+
- BREAKING: Added key param for postGenieMessage
|
|
7
|
+
|
|
8
|
+
## 0.10.49
|
|
9
|
+
|
|
10
|
+
- Updated eth/bsc/polygon protocol to use nodereal
|
|
11
|
+
|
|
3
12
|
## 0.10.48
|
|
4
13
|
|
|
5
14
|
- Fixed multiline secret production deployment bug
|
package/api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const osModule = require("os");
|
|
2
2
|
const express = require("express");
|
|
3
3
|
const meow = require("meow");
|
|
4
|
-
const {
|
|
4
|
+
const { getSelectorFlags, getSelectorDesc } = require("./selector");
|
|
5
5
|
const { isProduction } = require("./env");
|
|
6
6
|
const { inline } = require("./log");
|
|
7
7
|
|
package/const.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { getNodeRealApiKey, ensureAndGet } = require("./env");
|
|
2
2
|
|
|
3
3
|
const SKYNET_API_PREFIX = "https://api.certik-skynet.com";
|
|
4
4
|
|
|
@@ -11,8 +11,8 @@ const PROTOCOLS = {
|
|
|
11
11
|
nativeTokenLogo: `https://token-logo.certik-assets.com/eth:0x0000000000000000000000000000000000000000.png`,
|
|
12
12
|
nativeTokenCoinGeckoId: "ethereum",
|
|
13
13
|
nativeTokenCmcId: 1027,
|
|
14
|
-
endpoint:
|
|
15
|
-
archiveEndpoint:
|
|
14
|
+
endpoint: `https://eth-mainnet.nodereal.io/v1/${getNodeRealApiKey("ETH")}`,
|
|
15
|
+
archiveEndpoint: `https://eth-mainnet.nodereal.io/v1/${getNodeRealApiKey("ETH")}`,
|
|
16
16
|
tokenStandard: "ERC20",
|
|
17
17
|
scanApi: {
|
|
18
18
|
endpoint: "https://api.etherscan.io/api",
|
|
@@ -30,7 +30,7 @@ const PROTOCOLS = {
|
|
|
30
30
|
nativeTokenLogo: `https://token-logo.certik-assets.com/bsc:0x0000000000000000000000000000000000000000.png`,
|
|
31
31
|
nativeTokenCoinGeckoId: "binance-coin",
|
|
32
32
|
nativeTokenCmcId: 1839,
|
|
33
|
-
endpoint:
|
|
33
|
+
endpoint: `https://bsc-mainnet.nodereal.io/v1/${getNodeRealApiKey("BSC")}`,
|
|
34
34
|
archiveEndpoint: `https://bsc-mainnet.nodereal.io/v1/${getNodeRealApiKey("BSC")}`,
|
|
35
35
|
tokenStandard: "BEP20",
|
|
36
36
|
scanApi: {
|
|
@@ -49,9 +49,9 @@ const PROTOCOLS = {
|
|
|
49
49
|
nativeTokenLogo: `https://token-logo.certik-assets.com/polygon:0x0000000000000000000000000000000000000000.png`,
|
|
50
50
|
nativeTokenCoinGeckoId: "matic-network",
|
|
51
51
|
nativeTokenCmcId: 3890,
|
|
52
|
-
endpoint: `https://
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
endpoint: `https://polygon-mainnet.nodereal.io/v1/${getNodeRealApiKey("POLYGON")}`,
|
|
53
|
+
archiveEndpoint: `https://polygon-mainnet.nodereal.io/v1/${getNodeRealApiKey("POLYGON")}`,
|
|
54
|
+
backupEndpoint: `https://polygon-mainnet.nodereal.io/v1/${getNodeRealApiKey("POLYGON")}`,
|
|
55
55
|
tokenStandard: "ERC20",
|
|
56
56
|
scanApi: {
|
|
57
57
|
endpoint: "https://api.polygonscan.com/api",
|
package/env.js
CHANGED
|
@@ -14,18 +14,9 @@ function getEnvironment() {
|
|
|
14
14
|
return ensureAndGet("SKYNET_ENVIRONMENT", "dev");
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
function getGetBlockApiKey() {
|
|
18
|
-
return ensureAndGet("SKYNET_GETBLOCK_API_KEY");
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function getAlchemyApiKey(identifier) {
|
|
22
|
-
// Alchemy API keys are different for each alchemy app
|
|
23
|
-
return ensureAndGet(`SKYNET_ALCHEMY_API_${identifier.toUpperCase()}_KEY`);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
17
|
function getNodeRealApiKey(identifier) {
|
|
27
18
|
// NodeReal API keys are different for each NodeReal app
|
|
28
|
-
return ensureAndGet(`SKYNET_NODEREAL_API_${identifier.toUpperCase()}_KEY`);
|
|
19
|
+
return ensureAndGet([`SKYNET_NODEREAL_API_${identifier.toUpperCase()}_KEY`, `SKYNET_NODEREAL_API_KEY`]);
|
|
29
20
|
}
|
|
30
21
|
|
|
31
22
|
function ensureAndGet(envName, defaultValue) {
|
|
@@ -69,7 +60,5 @@ module.exports = {
|
|
|
69
60
|
getEnvironment,
|
|
70
61
|
isProduction,
|
|
71
62
|
isDev,
|
|
72
|
-
getGetBlockApiKey,
|
|
73
|
-
getAlchemyApiKey,
|
|
74
63
|
getNodeRealApiKey,
|
|
75
64
|
};
|
package/opsgenie.js
CHANGED
|
@@ -5,20 +5,14 @@ function getGenieKey() {
|
|
|
5
5
|
return process.env.OPSGENIE_API_KEY;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
function getGenieEndPoint() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (!key) {
|
|
12
|
-
throw new Error("Cannot communicate with opsgenie due to missing API key: process.env.OPSGENIE_API_KEY");
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return process.env.OPSGENIE_END_POINT;
|
|
8
|
+
function getGenieEndPoint(key) {
|
|
9
|
+
return process.env.OPSGENIE_END_POINT || "https://api.opsgenie.com/v2/alerts";
|
|
16
10
|
}
|
|
17
11
|
|
|
18
|
-
async function postGenieMessage(body, verbose) {
|
|
12
|
+
async function postGenieMessage(body, apiKey, verbose) {
|
|
19
13
|
try {
|
|
20
|
-
const genieKey = getGenieKey();
|
|
21
|
-
const genieEndPoint = getGenieEndPoint();
|
|
14
|
+
const genieKey = apiKey || getGenieKey();
|
|
15
|
+
const genieEndPoint = getGenieEndPoint(genieKey);
|
|
22
16
|
|
|
23
17
|
// Prevents duplicate alerts (See Opsgenie doc about alias)
|
|
24
18
|
if (!body.alias) {
|
package/package.json
CHANGED
package/slack.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { WebClient } from "@slack/web-api";
|
|
2
2
|
|
|
3
|
+
type ChannelConfig = {
|
|
4
|
+
name: string;
|
|
5
|
+
id: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
3
8
|
export function getClient(): WebClient;
|
|
4
9
|
export function findConversation(client: WebClient, name: string): Promise<string | null>;
|
|
5
|
-
export function postMessage(channel: string, message: any, verbose: boolean): Promise<void>;
|
|
10
|
+
export function postMessage(channel: string | ChannelConfig, message: any, verbose: boolean): Promise<void>;
|
package/slack.js
CHANGED
|
@@ -4,8 +4,8 @@ function getToken() {
|
|
|
4
4
|
return process.env.SKYNET_SLACK_TOKEN;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
function getClient() {
|
|
8
|
-
const token = getToken();
|
|
7
|
+
function getClient(t) {
|
|
8
|
+
const token = t || getToken();
|
|
9
9
|
|
|
10
10
|
if (!token) {
|
|
11
11
|
throw new Error("Cannot communicate with slack due to missing slack token: process.env.SKYNET_SLACK_TOKEN");
|
|
@@ -49,11 +49,16 @@ async function findConversation(client, name) {
|
|
|
49
49
|
return null;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
function isString(s) {
|
|
53
|
+
return typeof s === "string" || s instanceof String;
|
|
54
|
+
}
|
|
55
|
+
|
|
52
56
|
async function postMessage(channel, message, verbose) {
|
|
53
57
|
try {
|
|
54
|
-
const
|
|
58
|
+
const token = isString(channel) ? null : channel.token;
|
|
59
|
+
const client = getClient(token);
|
|
55
60
|
|
|
56
|
-
|
|
61
|
+
let conversationId = isString(channel) ? await findConversation(client, channel) : channel.id;
|
|
57
62
|
|
|
58
63
|
if (!conversationId) {
|
|
59
64
|
throw new Error(
|