@certik/skynet 0.22.0 → 0.22.1

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/dist/cli.js CHANGED
@@ -1,86 +1,37 @@
1
- // @bun
2
- var __create = Object.create;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __toESM = (mod, isNodeMode, target) => {
9
- target = mod != null ? __create(__getProtoOf(mod)) : {};
10
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
11
- for (let key of __getOwnPropNames(mod))
12
- if (!__hasOwnProp.call(to, key))
13
- __defProp(to, key, {
14
- get: () => mod[key],
15
- enumerable: true
16
- });
17
- return to;
18
- };
19
- var __moduleCache = /* @__PURE__ */ new WeakMap;
20
- var __toCommonJS = (from) => {
21
- var entry = __moduleCache.get(from), desc;
22
- if (entry)
23
- return entry;
24
- entry = __defProp({}, "__esModule", { value: true });
25
- if (from && typeof from === "object" || typeof from === "function")
26
- __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
27
- get: () => from[key],
28
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
29
- }));
30
- __moduleCache.set(from, entry);
31
- return entry;
32
- };
33
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
34
- var __export = (target, all) => {
35
- for (var name in all)
36
- __defProp(target, name, {
37
- get: all[name],
38
- enumerable: true,
39
- configurable: true,
40
- set: (newValue) => all[name] = () => newValue
41
- });
42
- };
43
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
44
- var __require = import.meta.require;
45
-
46
- // cli.ts
47
1
  import path from "path";
48
2
  import fs from "fs";
49
3
  function getBinaryName() {
50
- const binaryNameParts = process.argv[1].split(path.sep);
51
- const binaryName = binaryNameParts[binaryNameParts.length - 1];
52
- return binaryName;
4
+ const binaryNameParts = process.argv[1].split(path.sep);
5
+ const binaryName = binaryNameParts[binaryNameParts.length - 1];
6
+ return binaryName;
53
7
  }
54
8
  function detectSkynetDirectory() {
55
- return detectDirectory(process.argv[1], "SkynetAPIDefinitions.yml");
9
+ return detectDirectory(process.argv[1], "SkynetAPIDefinitions.yml");
56
10
  }
57
11
  function detectWorkingDirectory() {
58
- const wd = detectDirectory(process.argv[1], "package.json");
59
- const skynetd = detectDirectory(process.argv[1], "SkynetAPIDefinitions.yml");
60
- return wd.slice(skynetd.length + path.sep.length).replace(path.sep, "/");
12
+ const wd = detectDirectory(process.argv[1], "package.json");
13
+ const skynetd = detectDirectory(process.argv[1], "SkynetAPIDefinitions.yml");
14
+ return wd.slice(skynetd.length + path.sep.length).replace(path.sep, "/");
61
15
  }
62
16
  function detectDirectory(fullBinPath, sentinel = "package.json") {
63
- let parentFolder = path.dirname(fullBinPath);
64
- while (parentFolder) {
65
- const sentinelPath = path.join(parentFolder, sentinel);
66
- if (fs.existsSync(sentinelPath)) {
67
- return parentFolder;
17
+ let parentFolder = path.dirname(fullBinPath);
18
+ while (parentFolder) {
19
+ // check if parentFolder length is greater than 0
20
+ const sentinelPath = path.join(parentFolder, sentinel);
21
+ if (fs.existsSync(sentinelPath)) {
22
+ return parentFolder;
23
+ }
24
+ const newParentFolder = path.dirname(parentFolder);
25
+ if (newParentFolder === parentFolder) {
26
+ // we have reached the root folder
27
+ break;
28
+ }
29
+ parentFolder = newParentFolder;
68
30
  }
69
- const newParentFolder = path.dirname(parentFolder);
70
- if (newParentFolder === parentFolder) {
71
- break;
72
- }
73
- parentFolder = newParentFolder;
74
- }
75
- throw new Error("Cannot detect current working directory");
31
+ throw new Error("Cannot detect current working directory");
76
32
  }
77
33
  function detectBin() {
78
- const wd = detectDirectory(process.argv[1], "package.json");
79
- return process.argv[1].slice(wd.length + path.sep.length).replace(path.sep, "/");
34
+ const wd = detectDirectory(process.argv[1], "package.json");
35
+ return process.argv[1].slice(wd.length + path.sep.length).replace(path.sep, "/");
80
36
  }
81
- export {
82
- getBinaryName,
83
- detectWorkingDirectory,
84
- detectSkynetDirectory,
85
- detectBin
86
- };
37
+ export { getBinaryName, detectSkynetDirectory, detectWorkingDirectory, detectBin };
package/dist/const.js CHANGED
@@ -1,207 +1,141 @@
1
- // @bun
2
- var __create = Object.create;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __toESM = (mod, isNodeMode, target) => {
9
- target = mod != null ? __create(__getProtoOf(mod)) : {};
10
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
11
- for (let key of __getOwnPropNames(mod))
12
- if (!__hasOwnProp.call(to, key))
13
- __defProp(to, key, {
14
- get: () => mod[key],
15
- enumerable: true
16
- });
17
- return to;
18
- };
19
- var __moduleCache = /* @__PURE__ */ new WeakMap;
20
- var __toCommonJS = (from) => {
21
- var entry = __moduleCache.get(from), desc;
22
- if (entry)
23
- return entry;
24
- entry = __defProp({}, "__esModule", { value: true });
25
- if (from && typeof from === "object" || typeof from === "function")
26
- __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
27
- get: () => from[key],
28
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
29
- }));
30
- __moduleCache.set(from, entry);
31
- return entry;
32
- };
33
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
34
- var __export = (target, all) => {
35
- for (var name in all)
36
- __defProp(target, name, {
37
- get: all[name],
38
- enumerable: true,
39
- configurable: true,
40
- set: (newValue) => all[name] = () => newValue
41
- });
42
- };
43
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
44
- var __require = import.meta.require;
45
-
46
- // env.ts
47
- function ensureAndGet(envName, defaultValue) {
48
- return process.env[envName] || defaultValue;
49
- }
50
- function getEnvironment() {
51
- return ensureAndGet("SKYNET_ENVIRONMENT", "dev");
52
- }
53
- function getEnvOrThrow(envName) {
54
- if (!process.env[envName]) {
55
- throw new Error(`Must set environment variable ${envName}`);
56
- }
57
- return process.env[envName];
58
- }
59
- function isProduction() {
60
- return getEnvironment() === "prd";
61
- }
62
- function isDev() {
63
- return getEnvironment() === "dev";
64
- }
65
- // const.ts
1
+ import { ensureAndGet } from "./env";
66
2
  function getNodeRealApiKey(identifier) {
67
- return ensureAndGet(`SKYNET_NODEREAL_API_${identifier.toUpperCase()}_KEY`) ?? ensureAndGet("SKYNET_NODEREAL_API_KEY");
3
+ // NodeReal API keys are different for each NodeReal app
4
+ return ensureAndGet(`SKYNET_NODEREAL_API_${identifier.toUpperCase()}_KEY`) ?? ensureAndGet("SKYNET_NODEREAL_API_KEY");
68
5
  }
69
- var PROTOCOLS = {
70
- eth: {
71
- nativeTokenName: "Ethereum",
72
- nativeTokenSymbol: "ETH",
73
- nativeTokenDecimals: 18,
74
- nativeTokenAddress: "eth:0x0000000000000000000000000000000000000000",
75
- nativeTokenLogo: `https://d1w63vqp8iwj2x.cloudfront.net/eth:0x0000000000000000000000000000000000000000.png`,
76
- nativeTokenCoinGeckoId: "ethereum",
77
- nativeTokenCmcId: 1027,
78
- endpoint: `https://eth-mainnet.nodereal.io/v1/${getNodeRealApiKey("ETH")}`,
79
- archiveEndpoint: `https://eth-mainnet.nodereal.io/v1/${getNodeRealApiKey("ETH")}`,
80
- tokenStandard: "ERC20",
81
- scanApi: {
82
- endpoint: "https://api.etherscan.io/api",
83
- key: ensureAndGet("SKYNET_ETHER_SCAN_API_KEY")
6
+ const PROTOCOLS = {
7
+ eth: {
8
+ nativeTokenName: "Ethereum",
9
+ nativeTokenSymbol: "ETH",
10
+ nativeTokenDecimals: 18,
11
+ nativeTokenAddress: "eth:0x0000000000000000000000000000000000000000",
12
+ nativeTokenLogo: `https://d1w63vqp8iwj2x.cloudfront.net/eth:0x0000000000000000000000000000000000000000.png`, // TODO: Can replace domain if needed
13
+ nativeTokenCoinGeckoId: "ethereum",
14
+ nativeTokenCmcId: 1027,
15
+ endpoint: `https://eth-mainnet.nodereal.io/v1/${getNodeRealApiKey("ETH")}`,
16
+ archiveEndpoint: `https://eth-mainnet.nodereal.io/v1/${getNodeRealApiKey("ETH")}`,
17
+ tokenStandard: "ERC20",
18
+ scanApi: {
19
+ endpoint: "https://api.etherscan.io/api",
20
+ key: ensureAndGet("SKYNET_ETHER_SCAN_API_KEY"),
21
+ },
22
+ multiCallProvider: "0xCa731e0f33Afbcfa9363d6F7449d1f5447d10C80",
23
+ scanUrl: "https://etherscan.io/",
24
+ chainId: 1,
84
25
  },
85
- multiCallProvider: "0xCa731e0f33Afbcfa9363d6F7449d1f5447d10C80",
86
- scanUrl: "https://etherscan.io/",
87
- chainId: 1
88
- },
89
- bsc: {
90
- nativeTokenName: "Binance Coin",
91
- nativeTokenSymbol: "BNB",
92
- nativeTokenDecimals: 18,
93
- nativeTokenAddress: "bsc:0x0000000000000000000000000000000000000000",
94
- nativeTokenLogo: `https://d1w63vqp8iwj2x.cloudfront.net/bsc:0x0000000000000000000000000000000000000000.png`,
95
- nativeTokenCoinGeckoId: "binance-coin",
96
- nativeTokenCmcId: 1839,
97
- endpoint: `https://bsc-mainnet.nodereal.io/v1/${getNodeRealApiKey("BSC")}`,
98
- archiveEndpoint: `https://bsc-mainnet.nodereal.io/v1/${getNodeRealApiKey("BSC")}`,
99
- tokenStandard: "BEP20",
100
- scanApi: {
101
- endpoint: "https://api.bscscan.com/api",
102
- key: ensureAndGet("SKYNET_BSC_SCAN_API_KEY")
26
+ bsc: {
27
+ nativeTokenName: "Binance Coin",
28
+ nativeTokenSymbol: "BNB",
29
+ nativeTokenDecimals: 18,
30
+ nativeTokenAddress: "bsc:0x0000000000000000000000000000000000000000",
31
+ nativeTokenLogo: `https://d1w63vqp8iwj2x.cloudfront.net/bsc:0x0000000000000000000000000000000000000000.png`, // TODO: Can replace domain if needed
32
+ nativeTokenCoinGeckoId: "binance-coin",
33
+ nativeTokenCmcId: 1839,
34
+ endpoint: `https://bsc-mainnet.nodereal.io/v1/${getNodeRealApiKey("BSC")}`,
35
+ archiveEndpoint: `https://bsc-mainnet.nodereal.io/v1/${getNodeRealApiKey("BSC")}`,
36
+ tokenStandard: "BEP20",
37
+ scanApi: {
38
+ endpoint: "https://api.bscscan.com/api",
39
+ key: ensureAndGet("SKYNET_BSC_SCAN_API_KEY"),
40
+ },
41
+ multiCallProvider: "0xe7144e57d832c9005D252f415d205b4b8D78228e",
42
+ scanUrl: "https://bscscan.com/",
43
+ chainId: 56,
103
44
  },
104
- multiCallProvider: "0xe7144e57d832c9005D252f415d205b4b8D78228e",
105
- scanUrl: "https://bscscan.com/",
106
- chainId: 56
107
- },
108
- polygon: {
109
- nativeTokenName: "Polygon",
110
- nativeTokenSymbol: "MATIC",
111
- nativeTokenDecimals: 18,
112
- nativeTokenAddress: "polygon:0x0000000000000000000000000000000000000000",
113
- nativeTokenLogo: `https://d1w63vqp8iwj2x.cloudfront.net/polygon:0x0000000000000000000000000000000000000000.png`,
114
- nativeTokenCoinGeckoId: "matic-network",
115
- nativeTokenCmcId: 3890,
116
- endpoint: `https://polygon-mainnet.nodereal.io/v1/${getNodeRealApiKey("POLYGON")}`,
117
- archiveEndpoint: `https://polygon-mainnet.nodereal.io/v1/${getNodeRealApiKey("POLYGON")}`,
118
- backupEndpoint: `https://polygon-mainnet.nodereal.io/v1/${getNodeRealApiKey("POLYGON")}`,
119
- tokenStandard: "ERC20",
120
- scanApi: {
121
- endpoint: "https://api.polygonscan.com/api",
122
- key: ensureAndGet("SKYNET_POLYGON_SCAN_API_KEY")
45
+ polygon: {
46
+ nativeTokenName: "Polygon",
47
+ nativeTokenSymbol: "MATIC",
48
+ nativeTokenDecimals: 18,
49
+ nativeTokenAddress: "polygon:0x0000000000000000000000000000000000000000",
50
+ nativeTokenLogo: `https://d1w63vqp8iwj2x.cloudfront.net/polygon:0x0000000000000000000000000000000000000000.png`, // TODO: Can replace domain if needed
51
+ nativeTokenCoinGeckoId: "matic-network",
52
+ nativeTokenCmcId: 3890,
53
+ endpoint: `https://polygon-mainnet.nodereal.io/v1/${getNodeRealApiKey("POLYGON")}`,
54
+ archiveEndpoint: `https://polygon-mainnet.nodereal.io/v1/${getNodeRealApiKey("POLYGON")}`,
55
+ backupEndpoint: `https://polygon-mainnet.nodereal.io/v1/${getNodeRealApiKey("POLYGON")}`,
56
+ tokenStandard: "ERC20",
57
+ scanApi: {
58
+ endpoint: "https://api.polygonscan.com/api",
59
+ key: ensureAndGet("SKYNET_POLYGON_SCAN_API_KEY"),
60
+ },
61
+ multiCallProvider: "0x8eC86392e0aDB57d00fDffbA39b8870e107c0757",
62
+ scanUrl: "https://polygonscan.com/",
63
+ chainId: 137,
123
64
  },
124
- multiCallProvider: "0x8eC86392e0aDB57d00fDffbA39b8870e107c0757",
125
- scanUrl: "https://polygonscan.com/",
126
- chainId: 137
127
- },
128
- heco: {
129
- nativeTokenName: "Heco",
130
- nativeTokenSymbol: "HT",
131
- nativeTokenDecimals: 18,
132
- nativeTokenAddress: "heco:0x0000000000000000000000000000000000000000",
133
- endpoint: `https://http-mainnet.hecochain.com`,
134
- tokenStandard: "HRC20",
135
- multiCallProvider: "0xe7144e57d832c9005d252f415d205b4b8d78228e",
136
- scanUrl: "https://hecoinfo.com/",
137
- chainId: 128
138
- },
139
- avax: {
140
- nativeTokenName: "Avalanche",
141
- nativeTokenSymbol: "AVAX",
142
- nativeTokenDecimals: 18,
143
- nativeTokenAddress: "avax:0x0000000000000000000000000000000000000000",
144
- nativeTokenLogo: `https://d1w63vqp8iwj2x.cloudfront.net/avax:0x0000000000000000000000000000000000000000.png`,
145
- nativeTokenCoinGeckoId: "avalanche-2",
146
- nativeTokenCmcId: 5805,
147
- endpoint: `https://api.avax.network/ext/bc/C/rpc`,
148
- tokenStandard: "ARC20",
149
- scanApi: {
150
- endpoint: "https://api.snowtrace.io/api",
151
- key: ensureAndGet("SKYNET_AVASCAN_API_KEY")
65
+ heco: {
66
+ nativeTokenName: "Heco",
67
+ nativeTokenSymbol: "HT",
68
+ nativeTokenDecimals: 18,
69
+ nativeTokenAddress: "heco:0x0000000000000000000000000000000000000000",
70
+ endpoint: `https://http-mainnet.hecochain.com`, // use heco public RPC node
71
+ tokenStandard: "HRC20",
72
+ multiCallProvider: "0xe7144e57d832c9005d252f415d205b4b8d78228e",
73
+ scanUrl: "https://hecoinfo.com/",
74
+ chainId: 128,
152
75
  },
153
- scanUrl: "https://snowtrace.io/",
154
- chainId: 43114
155
- },
156
- ftm: {
157
- nativeTokenName: "Fantom",
158
- nativeTokenSymbol: "FTM",
159
- nativeTokenDecimals: 18,
160
- nativeTokenAddress: "ftm:0x0000000000000000000000000000000000000000",
161
- nativeTokenLogo: `https://d1w63vqp8iwj2x.cloudfront.net/ftm:0x0000000000000000000000000000000000000000.png`,
162
- nativeTokenCoinGeckoId: "fantom",
163
- nativeTokenCmcId: 3513,
164
- endpoint: `https://rpcapi.fantom.network`,
165
- tokenStandard: "ERC20",
166
- scanApi: {
167
- endpoint: "https://api.ftmscan.com/api",
168
- key: ensureAndGet("SKYNET_FTMSCAN_API_KEY")
76
+ avax: {
77
+ nativeTokenName: "Avalanche",
78
+ nativeTokenSymbol: "AVAX",
79
+ nativeTokenDecimals: 18,
80
+ nativeTokenAddress: "avax:0x0000000000000000000000000000000000000000",
81
+ nativeTokenLogo: `https://d1w63vqp8iwj2x.cloudfront.net/avax:0x0000000000000000000000000000000000000000.png`, // TODO: Can replace domain if needed
82
+ nativeTokenCoinGeckoId: "avalanche-2",
83
+ nativeTokenCmcId: 5805,
84
+ endpoint: `https://api.avax.network/ext/bc/C/rpc`,
85
+ tokenStandard: "ARC20",
86
+ scanApi: {
87
+ endpoint: "https://api.snowtrace.io/api",
88
+ key: ensureAndGet("SKYNET_AVASCAN_API_KEY"),
89
+ },
90
+ scanUrl: "https://snowtrace.io/",
91
+ chainId: 43114,
92
+ },
93
+ ftm: {
94
+ nativeTokenName: "Fantom",
95
+ nativeTokenSymbol: "FTM",
96
+ nativeTokenDecimals: 18,
97
+ nativeTokenAddress: "ftm:0x0000000000000000000000000000000000000000",
98
+ nativeTokenLogo: `https://d1w63vqp8iwj2x.cloudfront.net/ftm:0x0000000000000000000000000000000000000000.png`, // TODO: Can replace domain if needed
99
+ nativeTokenCoinGeckoId: "fantom",
100
+ nativeTokenCmcId: 3513,
101
+ endpoint: `https://rpcapi.fantom.network`,
102
+ tokenStandard: "ERC20",
103
+ scanApi: {
104
+ endpoint: "https://api.ftmscan.com/api",
105
+ key: ensureAndGet("SKYNET_FTMSCAN_API_KEY"),
106
+ },
107
+ scanUrl: "https://ftmscan.com/",
108
+ chainId: 250,
109
+ },
110
+ algo: {
111
+ nativeTokenName: "Algorand",
112
+ nativeTokenSymbol: "ALGO",
113
+ nativeTokenDecimals: 6,
114
+ nativeTokenAddress: "algo:native",
115
+ nativeTokenLogo: `https://d1w63vqp8iwj2x.cloudfront.net/algo:native.png`,
116
+ nativeTokenCoinGeckoId: "algorand",
117
+ nativeTokenCmcId: 4030,
118
+ endpoint: "https://algo-node.certik-skynet.com/",
119
+ tokenStandard: "ASA",
120
+ chainId: 1300,
169
121
  },
170
- scanUrl: "https://ftmscan.com/",
171
- chainId: 250
172
- },
173
- algo: {
174
- nativeTokenName: "Algorand",
175
- nativeTokenSymbol: "ALGO",
176
- nativeTokenDecimals: 6,
177
- nativeTokenAddress: "algo:native",
178
- nativeTokenLogo: `https://d1w63vqp8iwj2x.cloudfront.net/algo:native.png`,
179
- nativeTokenCoinGeckoId: "algorand",
180
- nativeTokenCmcId: 4030,
181
- endpoint: "https://algo-node.certik-skynet.com/",
182
- tokenStandard: "ASA",
183
- chainId: 1300
184
- }
185
- };
186
- var TIME = {
187
- BY_MS: {
188
- SECOND: 1000,
189
- MINUTE: 1000 * 60,
190
- HOUR: 1000 * 60 * 60,
191
- DAY: 1000 * 60 * 60 * 24,
192
- WEEK: 1000 * 60 * 60 * 24 * 7,
193
- YEAR: 1000 * 60 * 60 * 24 * 365
194
- },
195
- BY_S: {
196
- SECOND: 1,
197
- MINUTE: 60,
198
- HOUR: 60 * 60,
199
- DAY: 60 * 60 * 24,
200
- WEEK: 60 * 60 * 24 * 7,
201
- YEAR: 60 * 60 * 24 * 365
202
- }
203
122
  };
204
- export {
205
- TIME,
206
- PROTOCOLS
123
+ const TIME = {
124
+ BY_MS: {
125
+ SECOND: 1000,
126
+ MINUTE: 1000 * 60,
127
+ HOUR: 1000 * 60 * 60,
128
+ DAY: 1000 * 60 * 60 * 24,
129
+ WEEK: 1000 * 60 * 60 * 24 * 7,
130
+ YEAR: 1000 * 60 * 60 * 24 * 365,
131
+ },
132
+ BY_S: {
133
+ SECOND: 1,
134
+ MINUTE: 60,
135
+ HOUR: 60 * 60,
136
+ DAY: 60 * 60 * 24,
137
+ WEEK: 60 * 60 * 24 * 7,
138
+ YEAR: 60 * 60 * 24 * 365,
139
+ },
207
140
  };
141
+ export { PROTOCOLS, TIME };