@certik/skynet 0.8.6 → 0.8.7

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,13 +1,18 @@
1
1
  # Changelog
2
2
 
3
- ##0.8.6
3
+ ## 0.8.7
4
4
 
5
- - Fixed a const.js error
5
+ - Change polygon node endpoint
6
6
 
7
- ##0.8.5
7
+ ## 0.8.6
8
8
 
9
+ - Fixed a const.js error
9
10
  - support more options in snowflake.js
10
11
 
12
+ ## 0.8.5
13
+
14
+ - Improve cross-OS compatibility of `detectDirectory` function
15
+
11
16
  ## 0.8.4
12
17
 
13
18
  - Added `every` tool to make it easier to build schedule parameter
@@ -34,7 +39,7 @@
34
39
 
35
40
  ## 0.7.18
36
41
 
37
- - Added the configurability for getTokenPriceAt function in `token` library
42
+ - Added the configurability for getTokenPriceAt function in `token` library
38
43
 
39
44
  ## 0.7.17
40
45
 
package/cli.js CHANGED
@@ -16,22 +16,24 @@ function detectWorkingDirectory() {
16
16
  const wd = detectDirectory(process.argv[1], "package.json");
17
17
  const skynetd = detectDirectory(process.argv[1], "SkynetAPIDefinitions.yml");
18
18
 
19
- return wd.slice(skynetd.length + path.sep.length);
19
+ return wd.slice(skynetd.length + path.sep.length).replace(path.sep, "/");
20
20
  }
21
21
 
22
22
  function detectDirectory(fullBinPath, sentinel = "package.json") {
23
- const binaryNameParts = fullBinPath.split(path.sep);
23
+ let parentFolder = path.dirname(fullBinPath);
24
24
 
25
- const parentFolders = [];
26
-
27
- for (let i = binaryNameParts.length - 1; i > 1; i--) {
28
- parentFolders.push(path.join(path.sep, ...binaryNameParts.slice(0, i)));
29
- }
30
-
31
- for (let folder of parentFolders) {
32
- if (fs.existsSync(path.join(folder, sentinel))) {
33
- return folder;
25
+ while (parentFolder) {
26
+ // check if parentFolder length is greater than 0
27
+ const sentinelPath = path.join(parentFolder, sentinel);
28
+ if (fs.existsSync(sentinelPath)) {
29
+ return parentFolder;
30
+ }
31
+ const newParentFolder = path.dirname(parentFolder);
32
+ if (newParentFolder === parentFolder) {
33
+ // we have reached the root folder
34
+ break;
34
35
  }
36
+ parentFolder = newParentFolder;
35
37
  }
36
38
 
37
39
  throw new Error("Cannot detect current working directory");
@@ -40,7 +42,7 @@ function detectDirectory(fullBinPath, sentinel = "package.json") {
40
42
  function detectBin() {
41
43
  const wd = detectDirectory(process.argv[1], "package.json");
42
44
 
43
- return process.argv[1].slice(wd.length + path.sep.length);
45
+ return process.argv[1].slice(wd.length + path.sep.length).replace(path.sep, "/");
44
46
  }
45
47
 
46
48
  module.exports = {
package/const.js CHANGED
@@ -1,4 +1,10 @@
1
- const { getEtherScanApiKey, getBscScanApiKey, getPolygonScanApiKey, getGetBlockApiKey } = require("./env");
1
+ const {
2
+ getEtherScanApiKey,
3
+ getBscScanApiKey,
4
+ getPolygonScanApiKey,
5
+ getGetBlockApiKey,
6
+ getAlchemyApiKey,
7
+ } = require("./env");
2
8
 
3
9
  const SKYNET_API_PREFIX = "https://api.certik-skynet.com";
4
10
 
@@ -42,8 +48,9 @@ const PROTOCOLS = {
42
48
  nativeTokenAddress: "polygon:0x0000000000000000000000000000000000000000",
43
49
  nativeTokenLogo: `https://token-logo.certik-assets.com/polygon:0x0000000000000000000000000000000000000000.png`,
44
50
  nativeTokenCoinGeckoId: "matic-network",
45
- endpoint: `https://matic.getblock.io/mainnet/?api_key=${getGetBlockApiKey()}`,
46
- archiveEndpoint: `https://matic.getblock.io/mainnet/?api_key=${getGetBlockApiKey()}`,
51
+ endpoint: `https://polygon-mainnet.g.alchemy.com/v2/${getAlchemyApiKey("POLYGON")}`,
52
+ backupEndpoint: `https://matic.getblock.io/mainnet/?api_key=${getGetBlockApiKey()}`,
53
+ archiveEndpoint: `https://polygon-mainnet.g.alchemy.com/v2/${getAlchemyApiKey("POLYGON")}`,
47
54
  tokenStandard: "ERC20",
48
55
  scanApi: {
49
56
  endpoint: "https://api.polygonscan.com/api",
package/env.js CHANGED
@@ -30,6 +30,11 @@ function getGetBlockApiKey() {
30
30
  return ensureAndGet("SKYNET_GETBLOCK_API_KEY");
31
31
  }
32
32
 
33
+ function getAlchemyApiKey(identifier) {
34
+ // Alchemy API keys are different for each alchemy app
35
+ return ensureAndGet(`SKYNET_ALCHEMY_API_${identifier.toUpperCase()}_KEY`);
36
+ }
37
+
33
38
  function ensureAndGet(envName, defaultValue) {
34
39
  if (Array.isArray(envName)) {
35
40
  for (let name of envName) {
@@ -75,4 +80,5 @@ module.exports = {
75
80
  getBscScanApiKey,
76
81
  getPolygonScanApiKey,
77
82
  getGetBlockApiKey,
83
+ getAlchemyApiKey,
78
84
  };
package/examples/consumer CHANGED
File without changes
package/examples/indexer CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/examples/producer CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@certik/skynet",
3
- "version": "0.8.6",
3
+ "version": "0.8.7",
4
4
  "description": "Skynet Shared JS library",
5
5
  "main": "index.js",
6
6
  "author": "CertiK Engineering",
@@ -29,4 +29,4 @@
29
29
  "sinon": "^11.1.2"
30
30
  },
31
31
  "license": "MIT"
32
- }
32
+ }