@certik/skynet 0.10.23 → 0.10.26

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,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.26
4
+
5
+ - Improved support for AVAX and FTM in const.js
6
+ - Added `beforeListen` parameter to `api` library
7
+
8
+ ## 0.10.25
9
+
10
+ - Added support for AVAX and FTM in const.js
11
+
12
+ ## 0.10.24
13
+
14
+ - Added type definitions
15
+
3
16
  ## 0.10.23
4
17
 
5
18
  - Fixed nomad API log elapse time
package/abi.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ type ContractIO = {
2
+ name: string;
3
+ type: string;
4
+ internalType: string | undefined;
5
+ components: ContractIO[];
6
+ };
7
+
8
+ type ABI = {
9
+ constant: boolean;
10
+ inputs: ContractIO[];
11
+ name: string;
12
+ outputs: ContractIO[];
13
+ payable: boolean;
14
+ stateMutability: string;
15
+ type: string;
16
+ }[];
17
+
18
+ export const ERC20: ABI;
19
+ export const MULTICALL: ABI;
20
+ export const BEP20: ABI;
package/ably.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import Bottleneck from "bottleneck";
2
+ export function publishMessage(channel: string, messageName: string, messageData: any): Promise<void>;
3
+ export const rateLimitedPublishMessage: Bottleneck;
package/address.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export function parseAddress(address: string): [string, string];
2
+ export function composeAddress(protocol: string, addr: string): string;
package/api.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ import { Selector } from "./selector";
2
+
3
+ export function startApiApp(params: {
4
+ binaryName: string;
5
+ name: string;
6
+ selector: Selector;
7
+ routes: string[];
8
+ serve: {
9
+ port: string | undefined;
10
+ apiKey: string;
11
+ prefix: string | undefined;
12
+ };
13
+ beforeListen: () => void;
14
+ }): void;
package/api.js CHANGED
@@ -65,7 +65,7 @@ const apiKeyMiddleware = (key) => {
65
65
  return requireAPIKey;
66
66
  };
67
67
 
68
- async function startApiApp({ binaryName, name, selector = {}, routes, serve }) {
68
+ async function startApiApp({ binaryName, name, selector = {}, routes, serve, beforeListen }) {
69
69
  const app = express();
70
70
  app.use(express.json());
71
71
 
@@ -133,6 +133,10 @@ ${getSelectorDesc(selector)}
133
133
  }
134
134
  }
135
135
 
136
+ if (beforeListen) {
137
+ await beforeListen({ app });
138
+ }
139
+
136
140
  app.listen(serve.port, () => {
137
141
  if (isProduction()) {
138
142
  inline.log(`${name} listening at https://api.certik-skynet.com${serve.prefix}`);
package/app.d.ts ADDED
@@ -0,0 +1,159 @@
1
+ import { ERROR_LEVEL } from "./monitor";
2
+ import { Selector } from "./selector";
3
+
4
+ export type Env = {
5
+ [key: string]: string | null
6
+ }
7
+
8
+ export type Route = {
9
+ method: "POST" | "PUT" | "PATCH" | "GET" | "POST" | "DELETE" | "OPTIONS";
10
+ path: string;
11
+ handler: ({ req, res }: { req: any, res: any }) => Promise<void>;
12
+ protected: boolean;
13
+ }
14
+
15
+ export type Serve = {
16
+ prefix: string;
17
+ port: number;
18
+ apiKey: string;
19
+ cpu: number;
20
+ mem: number;
21
+ }
22
+
23
+ export type Consume = {
24
+ func: ({ protocol, messages, verbose }: {
25
+ protocol: string;
26
+ messages: any;
27
+ verbose: boolean;
28
+ }) => Promise<void>;
29
+ topic: ({ protocol }: { protocol: string }) => string;
30
+ maxRetry: number;
31
+ cpu: number;
32
+ mem: number;
33
+ }
34
+
35
+ export type State = {
36
+ type: string;
37
+ updateInterval: ({ protocol }: { protocol: string }) => number;
38
+ getMinId: () => Promise<number>;
39
+ getMaxId: ({ protocol }: { protocol: string }) => Promise<number>;
40
+ }
41
+
42
+ export type Produce = {
43
+ func: ({ protocol, from, to, verbose, send }: {
44
+ protocol: string;
45
+ from: number;
46
+ to: number;
47
+ verbose: boolean;
48
+ send: (items: { id: string, name: string }[]) => Promise<void>;
49
+ }) => Promise<void>;
50
+ topic: ({ protocol }) => string;
51
+ deadLetterTopic: ({ protocol }) => string;
52
+ batchSize: number;
53
+ maxRetry: number;
54
+ cpu: number;
55
+ mem: number;
56
+ }
57
+
58
+ export type Check = {
59
+ func: ({ protocol, state, verbose }: { protocol: string, state: string, verbose: boolean })
60
+ => ({ type: string, message: string });
61
+ schedule: string;
62
+ slackChannel: string;
63
+ }
64
+
65
+ export type Build = {
66
+ func: ({ protocol, from, to, verbose }: { protocol: string, from: number, to: number, verbose: boolean })
67
+ => void;
68
+ batchSize: number;
69
+ schedule: string;
70
+ cpu: number;
71
+ mem: number;
72
+ }
73
+
74
+ export type Restart = {
75
+ attempts: number | undefined;
76
+ mode: string | undefined;
77
+ interval: string | undefined;
78
+ delay: string | undefined
79
+ }
80
+
81
+ export type Validate = {
82
+ func: ({ protocol, from, to, verbose }: { protocol: string, from: number, to: number, verbose: boolean })
83
+ => void;
84
+ batchSize: number;
85
+ schedule: string;
86
+ cpu: number;
87
+ mem: number;
88
+ }
89
+
90
+ type BuildWithConcurrency = Build | { concurrency: number | undefined };
91
+
92
+ type ValidateWithConcurrency = Validate | { concurrency: number | undefined };
93
+
94
+ export const SENSITIVE_VALUE: null;
95
+
96
+ export { ERROR_LEVEL };
97
+
98
+ export function every(n: number | undefined): {
99
+ second: string
100
+ seconds: string,
101
+ minute: string,
102
+ minutes: string,
103
+ hour: string,
104
+ hours: string,
105
+ day: string,
106
+ days: string,
107
+ week: string,
108
+ weeks: string,
109
+ }
110
+
111
+ export function api(apiParams: {
112
+ name: string;
113
+ routes: Route[];
114
+ serve: Serve;
115
+ env: Env | undefined;
116
+ region: string | undefined;
117
+ beforeListen: () => void;
118
+ }): () => void;
119
+
120
+ export function consumer(consumerParams: {
121
+ name: string;
122
+ selector: Selector;
123
+ consume: Consume;
124
+ check: Check;
125
+ env: Env | undefined;
126
+ region: string | undefined;
127
+ }): () => void;
128
+
129
+ export function producer(producerParams: {
130
+ name: string;
131
+ selector: Selector;
132
+ produce: Produce;
133
+ check: Check;
134
+ state: State;
135
+ env: Env | undefined;
136
+ region: string | undefined;
137
+ }): () => void;
138
+
139
+ export function indexer(indexerParams: {
140
+ name: string;
141
+ selector: Selector;
142
+ state: State;
143
+ build: Build | { restart: Restart | undefined };
144
+ validate: Validate;
145
+ check: Check;
146
+ env: Env | undefined;
147
+ region: string | undefined;
148
+ }): () => void;
149
+
150
+ export function modeIndexer(modeIndexerParams: {
151
+ name: string;
152
+ selector: Selector;
153
+ state: State;
154
+ build: BuildWithConcurrency;
155
+ validate: ValidateWithConcurrency;
156
+ check: Check;
157
+ env: Env | undefined;
158
+ region: string | undefined;
159
+ }): () => void;
package/app.js CHANGED
@@ -600,7 +600,7 @@ function checkApiRoutesParameter(routes) {
600
600
  return errors;
601
601
  }
602
602
 
603
- function api({ name, routes, serve, env = {}, region = "us-east-1" }) {
603
+ function api({ name, routes, serve, beforeListen, env = {}, region = "us-east-1" }) {
604
604
  // do not support selector for now
605
605
  const selector = {};
606
606
 
@@ -641,6 +641,7 @@ function api({ name, routes, serve, env = {}, region = "us-east-1" }) {
641
641
  selector,
642
642
  routes,
643
643
  serve,
644
+ beforeListen,
644
645
  });
645
646
  },
646
647
  onDeploy: () => {
@@ -0,0 +1,11 @@
1
+ export function wait(time: number | undefined): Promise<void>;
2
+ export function retry(times: number, verbose: boolean, func: Function): Promise<void>;
3
+ export function exponentialRetry<T>(func: () => Promise<T>, { maxRetry, initialDuration, growFactor, test, verbose }:
4
+ {
5
+ maxRetry: number,
6
+ initialDuration: number | undefined,
7
+ growFactor: number | undefined,
8
+ test: (result: T) => boolean,
9
+ verbose: boolean
10
+ }
11
+ ): Promise<T>;
package/block.d.ts ADDED
@@ -0,0 +1,49 @@
1
+ // See https://www.quicknode.com/docs/ethereum/eth_getBlockByNumber for a complete reference.
2
+
3
+ type Transaction = {
4
+ blockHash: string;
5
+ blockNumber: string;
6
+ hash: string;
7
+ to: string;
8
+ from: string;
9
+ transactionIndex: string;
10
+ value: string | undefined;
11
+ nonce: string;
12
+ gas: string;
13
+ gasPrice: string;
14
+ input: string;
15
+ type: string;
16
+ chainId: string | undefined;
17
+ v: string;
18
+ r: string;
19
+ s: string;
20
+ }
21
+
22
+ type BlockInfo = {
23
+ number: string;
24
+ timestamp: string;
25
+ difficulty: string;
26
+ extraData: string;
27
+ gasLimit: string;
28
+ gasUsed: string;
29
+ hash: string;
30
+ logsBloom: string;
31
+ miner: string;
32
+ mixHash: string;
33
+ nonce: string;
34
+ parentHash: string;
35
+ receiptsRoot: string;
36
+ sha3Uncles: string;
37
+ size: string;
38
+ stateRoot: string;
39
+ totalDifficulty: string;
40
+ transactions: Transaction[];
41
+ transactionsRoot: string;
42
+ uncles: string[];
43
+ }
44
+
45
+ export function getLatestBlockHeight(protocol: string): Promise<number>;
46
+ export function getBlock(protocol: string, height: number): Promise<BlockInfo>;
47
+ export function getBlockS3Path(protocol: string, height: number): string;
48
+ export function getLatestS3BlockHeight(protocol: string): Promise<number>;
49
+ export function getBlockFromS3(protocol: string, height: number): Promise<BlockInfo>;
package/cli.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export function getBinaryName(): string;
2
+ export function detectSkynetDirectory(): string;
3
+ export function detectWorkingDirectory(): string;
4
+ export function detectBin(): string;
package/const.d.ts ADDED
@@ -0,0 +1,40 @@
1
+ type Protocol = {
2
+ nativeTokenName: string,
3
+ nativeTokenSymbol: string,
4
+ nativeTokenDecimals: number,
5
+ nativeTokenAddress: string,
6
+ nativeTokenLogo: string,
7
+ nativeTokenCoinGeckoId: string,
8
+ nativeTokenCmcId: number,
9
+ endpoint: string,
10
+ archiveEndpoint: string,
11
+ tokenStandard: string,
12
+ scanApi: {
13
+ endpoint: string,
14
+ key: string,
15
+ },
16
+ multiCallProvider: string,
17
+ scanUrl: string,
18
+ }
19
+
20
+ type TimeIntervals = {
21
+ MINUTE: number,
22
+ HOUR: number,
23
+ DAY: number,
24
+ WEEK: number,
25
+ YEAR: number,
26
+ }
27
+
28
+ export const SKYNET_API_PREFIX: string;
29
+ export const PROTOCOLS: {
30
+ eth: Protocol,
31
+ bsc: Protocol,
32
+ polygon: Protocol,
33
+ heco: Protocol,
34
+ avax: Protocol,
35
+ ftm: Protocol,
36
+ }
37
+ export const TIME: {
38
+ BY_MS: TimeIntervals,
39
+ BY_S: TimeIntervals,
40
+ }
package/const.js CHANGED
@@ -1,7 +1,5 @@
1
1
  const {
2
- getEtherScanApiKey,
3
- getBscScanApiKey,
4
- getPolygonScanApiKey,
2
+ getEnvironment,
5
3
  getGetBlockApiKey,
6
4
  getAlchemyApiKey,
7
5
  getNodeRealApiKey,
@@ -23,7 +21,7 @@ const PROTOCOLS = {
23
21
  tokenStandard: "ERC20",
24
22
  scanApi: {
25
23
  endpoint: "https://api.etherscan.io/api",
26
- key: getEtherScanApiKey(),
24
+ key: getEnvironment("SKYNET_ETHER_SCAN_API_KEY"),
27
25
  },
28
26
  multiCallProvider: "0xCa731e0f33Afbcfa9363d6F7449d1f5447d10C80",
29
27
  scanUrl: "https://etherscan.io/",
@@ -41,7 +39,7 @@ const PROTOCOLS = {
41
39
  tokenStandard: "BEP20",
42
40
  scanApi: {
43
41
  endpoint: "https://api.bscscan.com/api",
44
- key: getBscScanApiKey(),
42
+ key: getEnvironment("SKYNET_BSC_SCAN_API_KEY"),
45
43
  },
46
44
  multiCallProvider: "0xe7144e57d832c9005D252f415d205b4b8D78228e",
47
45
  scanUrl: "https://bscscan.com/",
@@ -60,7 +58,7 @@ const PROTOCOLS = {
60
58
  tokenStandard: "ERC20",
61
59
  scanApi: {
62
60
  endpoint: "https://api.polygonscan.com/api",
63
- key: getPolygonScanApiKey(),
61
+ key: getEnvironment("SKYNET_POLYGON_SCAN_API_KEY"),
64
62
  },
65
63
  multiCallProvider: "0x8eC86392e0aDB57d00fDffbA39b8870e107c0757",
66
64
  scanUrl: "https://polygonscan.com/",
@@ -74,6 +72,32 @@ const PROTOCOLS = {
74
72
  tokenStandard: "HRC20",
75
73
  multiCallProvider: "0xe7144e57d832c9005d252f415d205b4b8d78228e",
76
74
  scanUrl: "https://hecoinfo.com/"
75
+ },
76
+ avax: {
77
+ nativeTokenName: "Avalanche",
78
+ nativeTokenSymbol: "AVAX",
79
+ nativeTokenDecimals: 18,
80
+ nativeTokenAddress: "avax:0x0000000000000000000000000000000000000000",
81
+ endpoint: `https://api.avax.network/ext/bc/C/rpc`,
82
+ tokenStandard: "ARC20",
83
+ scanApi: {
84
+ endpoint: "https://api.snowtrace.io",
85
+ key: getEnvironment("SKYNET_AVASCAN_API_KEY"),
86
+ },
87
+ scanUrl: "https://snowtrace.io/"
88
+ },
89
+ ftm: {
90
+ nativeTokenName: "Fantom",
91
+ nativeTokenSymbol: "FTM",
92
+ nativeTokenDecimals: 18,
93
+ nativeTokenAddress: "ftm:0x0000000000000000000000000000000000000000",
94
+ endpoint: `https://rpcapi.fantom.network`,
95
+ tokenStandard: "ERC20",
96
+ scanApi: {
97
+ endpoint: "https://api.ftmscan.com",
98
+ key: getEnvironment("SKYNET_FTMSCAN_API_KEY"),
99
+ },
100
+ scanUrl: "https://ftmscan.com/"
77
101
  }
78
102
  };
79
103
 
package/deploy.d.ts ADDED
@@ -0,0 +1,41 @@
1
+ import { getJobName } from "./selector";
2
+ import { Env, Selector, Check, Restart } from "./app";
3
+
4
+ type Service = {
5
+ prefix: string;
6
+ port: number;
7
+ }
8
+
9
+ type CreateDeployBaseParams = {
10
+ binaryName: string,
11
+ name: string,
12
+ workingDirectory: string,
13
+ bin: string | undefined,
14
+ selector: Selector | undefined,
15
+ env: Env | undefined,
16
+ region: string | undefined,
17
+ check: Check,
18
+ }
19
+
20
+ export { getJobName };
21
+
22
+ export function getNomadAddr(isProduction: boolean): Promise<string | undefined>;
23
+
24
+ export function createModeDeploy(createModeDeployParams: CreateDeployBaseParams | {
25
+ deltaSchedule: string,
26
+ validateSchedule: string,
27
+ deltaCpu: number,
28
+ deltaMem: number,
29
+ rebuildCpu: number,
30
+ rebuildMem: number,
31
+ validateCpu: number,
32
+ validateMem: number,
33
+ }): { deploy: () => void };
34
+
35
+ export function createDeploy(createDeployParams: CreateDeployBaseParams | {
36
+ schedule: string,
37
+ restart: Restart | undefined,
38
+ cpu: number,
39
+ mem: number,
40
+ service: Service,
41
+ }): { deploy: () => void };
@@ -0,0 +1 @@
1
+ export function useLock(useLockParams: { name: string, ttl: string, verbose: boolean }): Promise<string | null>
package/dynamodb.d.ts ADDED
@@ -0,0 +1,67 @@
1
+ import { DynamoDB } from "aws-sdk";
2
+
3
+ type Keys = { [key: string]: any };
4
+
5
+ type Fields = { [key: string]: any };
6
+
7
+ export function getDocClient(): DynamoDB.DocumentClient;
8
+
9
+ export function scanWholeTable(options: DynamoDB.DocumentClient.ScanInput):
10
+ Promise<{
11
+ Items: any[];
12
+ Count: number;
13
+ ScannedCount: number;
14
+ }>;
15
+
16
+ export function batchCreateRecords(
17
+ tableName: string,
18
+ records: any[],
19
+ maxWritingCapacity: number,
20
+ verbose: boolean | undefined
21
+ ): Promise<void>;
22
+
23
+ export function createRecord(
24
+ tableName: string,
25
+ fields: Fields,
26
+ verbose: boolean | undefined
27
+ ): Promise<void>;
28
+
29
+ export function getRecordsByKey(
30
+ tableName: string,
31
+ keys: Keys,
32
+ indexName: string
33
+ ): Promise<DynamoDB.DocumentClient.ItemList | null | undefined>;
34
+
35
+ export function getRecordByKey(
36
+ tableName: string,
37
+ keys: Keys,
38
+ indexName: string
39
+ ): Promise<DynamoDB.DocumentClient.AttributeMap | null>;
40
+
41
+ export function updateRecordByKey(
42
+ tableName: string,
43
+ idKey: Keys,
44
+ fields: Fields,
45
+ conditionExpressions: string | undefined,
46
+ verbose: boolean | undefined
47
+ ): Promise<DynamoDB.DocumentClient.AttributeMap | undefined>;
48
+
49
+ export function batchDeleteRecords(
50
+ tableName: string,
51
+ keys: Keys
52
+ ): Promise<void>;
53
+
54
+ export function deleteRecordsByHashKey(
55
+ tableName: string,
56
+ indexName: string | undefined,
57
+ hashKeyValue: string,
58
+ verbose: boolean | undefined
59
+ ): Promise<number>;
60
+
61
+ export function createTableIfNotExist(
62
+ tableName: string,
63
+ attributeDefinitions: DynamoDB.AttributeDefinitions,
64
+ keySchema: DynamoDB.KeySchema,
65
+ options: DynamoDB.DocumentClient.CreateTableInput,
66
+ verbose: boolean | undefined
67
+ ): Promise<void>
package/env.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ export function ensureAndGet<T>(envName: string, defaultValue: T): string | T;
2
+ export function getEnvOrThrow(envName: string): string;
3
+ export function getAWSAccessKeyId(): string | undefined;
4
+ export function getAWSSecretAccessKey(): string | undefined;
5
+ export function getAWSRegion(): string;
6
+ export function getEnvironment(): string;
7
+ export function getGetBlockApiKey(): string | undefined;
8
+ export function getAlchemyApiKey(identifier: string): string | undefined;
9
+ export function getNodeRealApiKey(identifier: string): string | undefined;
10
+ export function isProduction(): boolean;
11
+ export function isDev(): boolean;
package/env.js CHANGED
@@ -14,18 +14,6 @@ function getEnvironment() {
14
14
  return ensureAndGet("SKYNET_ENVIRONMENT", "dev");
15
15
  }
16
16
 
17
- function getEtherScanApiKey() {
18
- return ensureAndGet("SKYNET_ETHER_SCAN_API_KEY");
19
- }
20
-
21
- function getBscScanApiKey() {
22
- return ensureAndGet("SKYNET_BSC_SCAN_API_KEY");
23
- }
24
-
25
- function getPolygonScanApiKey() {
26
- return ensureAndGet("SKYNET_POLYGON_SCAN_API_KEY");
27
- }
28
-
29
17
  function getGetBlockApiKey() {
30
18
  return ensureAndGet("SKYNET_GETBLOCK_API_KEY");
31
19
  }
@@ -81,9 +69,6 @@ module.exports = {
81
69
  getEnvironment,
82
70
  isProduction,
83
71
  isDev,
84
- getEtherScanApiKey,
85
- getBscScanApiKey,
86
- getPolygonScanApiKey,
87
72
  getGetBlockApiKey,
88
73
  getAlchemyApiKey,
89
74
  getNodeRealApiKey,
package/indexer.d.ts ADDED
@@ -0,0 +1,30 @@
1
+ // module.exports = {
2
+ // getIndexerValidatedId,
3
+ // };
4
+ import { Build, State, Validate } from "./app";
5
+ import { SelectorFlags, Selector } from "./selector";
6
+
7
+ type CreateIndexerAppBaseParams = {
8
+ binaryName: string,
9
+ name: string,
10
+ selector: Selector | undefined,
11
+ build: Build,
12
+ maxRetry: number
13
+ }
14
+
15
+ export function createModeIndexerApp(createModeIndexerAppParams: {
16
+ buildBatchSize: number | undefined,
17
+ buildConcurrency: number | undefined,
18
+ validate: Validate,
19
+ validateBatchSize: number | undefined,
20
+ validateConcurrency: number | undefined,
21
+ state: State,
22
+ } | CreateIndexerAppBaseParams): { run: () => void };
23
+
24
+ export function createIndexerApp(createModeIndexerAppParams: CreateIndexerAppBaseParams): { run: () => void };
25
+
26
+ export function getIndexerState(name: string, selectorFlags: SelectorFlags): Promise<string>;
27
+
28
+ export function getIndexerLatestId(name: string, selectorFlags: SelectorFlags): Promise<number>;
29
+
30
+ export function getIndexerValidatedId(name: string, selectorFlags: SelectorFlags): Promise<number>;
package/inquiry.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { Response } from "node-fetch";
2
+
3
+ export function createAddressRecord(address: string): Promise<Response>;
package/kafka.d.ts ADDED
@@ -0,0 +1,39 @@
1
+ import { KafkaMessage } from "kafkajs";
2
+ import { Producer, State } from "./app";
3
+ import { SelectorFlags, Selector } from "./selector";
4
+
5
+ export function createProducerApp(createProducerAppParams: {
6
+ binaryName: string,
7
+ name: string,
8
+ selector: Selector | undefined,
9
+ producer: Producer,
10
+ state: State
11
+ }): { run: () => Promise<void> };
12
+
13
+ export function createConsumerApp(createConsumerAppParams: {
14
+ binaryName: string,
15
+ name: string,
16
+ selector: Selector | undefined,
17
+ consumer: Consumer
18
+ }): { run: () => Promise<void> };
19
+
20
+ export function produceMessages(
21
+ producerId: string,
22
+ callback: (
23
+ send: (topic: any, messages: any) => Promise<void>
24
+ ) => Promise<void>
25
+ ): Promise<void>;
26
+
27
+ export function consumeMessages(
28
+ consumerId: string,
29
+ topic: string | RegExp,
30
+ callback: (
31
+ message: KafkaMessage,
32
+ stopConsumeMessages: () => Promise<void>
33
+ ) => Promise<void>
34
+ ): Promise<() => Promise<void>>;
35
+
36
+ export function getProducerLatestId(
37
+ name: string,
38
+ selectorFlags: SelectorFlags
39
+ ): Promise<number>;
package/labelling.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ type Tag = {
2
+ type: string;
3
+ label: string;
4
+ }
5
+
6
+ export function addTagsToAddress(
7
+ address: string,
8
+ tags: Tag[],
9
+ verbose: boolean
10
+ ): Promise<{
11
+ tableName: string;
12
+ updateItemTags: Tag[];
13
+ } | undefined>;
14
+
15
+ export function queryAddressTags(address: string): Promise<Tag[]>;
package/log.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export function print(o: any): string;
2
+ export const inline: {
3
+ log: (...args: any[]) => void,
4
+ error: (...args: any[]) => void
5
+ };
package/metric.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ export function getMetricAt(
2
+ tableName: string,
3
+ name: string,
4
+ timestamp: number
5
+ ): Promise<any>;
6
+ export function getMetricPreviousValue(
7
+ tableName: string,
8
+ name: string,
9
+ timestamp: number
10
+ ): Promise<any>;
package/monitor.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ import { Check } from "./app";
2
+ import { SelectorFlags, Selector } from "./selector";
3
+
4
+ export const ERROR_LEVEL: {
5
+ INFO: string,
6
+ CRITICAL: string,
7
+ WARNING: string
8
+ };
9
+
10
+ export const LEVEL_EMOJI: {
11
+ Info: string,
12
+ Critical: string,
13
+ Warning: string
14
+ };
15
+
16
+ export function createMonitor(createMonitorParams: {
17
+ binaryName: string,
18
+ name: string,
19
+ getState: ((name: string, selectorFlags: SelectorFlags) => Promise<void>) | undefined,
20
+ mode: boolean | undefined,
21
+ selector: Selector,
22
+ check: Check,
23
+ maxRetry: number | undefined
24
+ }): { monitor: () => void };
package/opsgenie.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export function postGenieMessage(
2
+ body: any | {
3
+ alias: string,
4
+ message: string
5
+ },
6
+ verbose: boolean
7
+ ): Promise<{ result: string }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@certik/skynet",
3
- "version": "0.10.23",
3
+ "version": "0.10.26",
4
4
  "description": "Skynet Shared JS library",
5
5
  "main": "index.js",
6
6
  "author": "CertiK Engineering",
package/price.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ type PricePreviousRecord = {
2
+ address: string;
3
+ price: number;
4
+ timestamp: number;
5
+ }
6
+
7
+ export function getPriceClosestTo(tableName: string, address: string, timestamp: number): Promise<number>;
8
+ export function getPricePreviousRecord(tableName: string, address: string, timestamp: number): Promise<PricePreviousRecord | null>;
package/primitive.d.ts ADDED
@@ -0,0 +1,29 @@
1
+ import { DynamoDB } from "aws-sdk";
2
+
3
+ type Issue = {
4
+ code: string;
5
+ link: string;
6
+ reduction: number;
7
+ title: string;
8
+ }
9
+
10
+ export function getOverrides(
11
+ docClient: DynamoDB.DocumentClient,
12
+ projectId: string,
13
+ address: string,
14
+ log: (...data: any[]) => void,
15
+ primitive: string
16
+ ): Promise<string[] | null>;
17
+
18
+ export function overrideScoreAndIssues(
19
+ docClient: DynamoDB.DocumentClient,
20
+ projectId: string,
21
+ address: string,
22
+ score: number,
23
+ issues: Issue[],
24
+ log: (...data: any[]) => void,
25
+ primitive: string
26
+ ): Promise<{
27
+ score: number;
28
+ issues: Issue[];
29
+ }>
package/proxy.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { RequestInit, Response } from "node-fetch";
2
+
3
+ type Options = {
4
+ verbose: boolean;
5
+ timeout: number;
6
+ headers: {
7
+ [header: string]: string;
8
+ }
9
+ } | RequestInit;
10
+
11
+ export default function proxyFetch(url: string, options: Partial<Options> | undefined): Promise<Response>;
package/rateLimit.d.ts ADDED
@@ -0,0 +1 @@
1
+ export function isRateLimited(name: string, unitTime: number, maxAccess: number): Promise<boolean>;
package/s3.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ import { S3 } from "aws-sdk";
2
+
3
+ type WriteOptions = {
4
+ verbose: boolean;
5
+ acl: string;
6
+ skipIfExists: boolean;
7
+ }
8
+
9
+ export function getS3(): S3;
10
+ export function readFile(bucketName: string, key: string, verbose: boolean | undefined): Promise<string | null>;
11
+ export function hasFile(bucketName: string, key: string): Promise<boolean>;
12
+ export function writeFile(bucketName: string, key: string, body: any, options: Partial<WriteOptions> | undefined): Promise<void>;
13
+ export function deleteFile(bucketName: string, key: string, verbose: boolean | undefined): Promise<void>;
14
+ export function listKeys(bucketname: string, prefix: string, continuationToken: string | undefined): Promise<{
15
+ keys: (string | undefined)[];
16
+ } | null>;
package/scan.d.ts ADDED
@@ -0,0 +1,47 @@
1
+ type Transaction = {
2
+ blockNumber: string,
3
+ timeStamp: string,
4
+ hash: string,
5
+ nonce: string,
6
+ blockHash: string,
7
+ transactionIndex: string,
8
+ from: string,
9
+ to: string,
10
+ value: string | undefined,
11
+ gas: string,
12
+ gasPrice: string,
13
+ isError: string,
14
+ txreceipt_status: string,
15
+ input: string,
16
+ contractAddress: string,
17
+ cumulativeGasUsed: string,
18
+ gasUsed: string,
19
+ confirmations: string,
20
+ methodId: string,
21
+ functionName: string
22
+ }
23
+
24
+ export function streamTxs(
25
+ address: string,
26
+ since: number | undefined,
27
+ to: number | undefined,
28
+ callback: (tx: Transaction) => void,
29
+ verbose: boolean
30
+ ): Promise<void>;
31
+
32
+ export function fetchTxs(
33
+ protocol: string,
34
+ addr: string,
35
+ since: number | undefined,
36
+ to: number | undefined,
37
+ offset: number | undefined,
38
+ ): Promise<Transaction[] | null>;
39
+
40
+ export function fetchTxsWithRetry(
41
+ protocol: string,
42
+ addr: string,
43
+ since: number | undefined,
44
+ to: number | undefined,
45
+ offset: number | undefined,
46
+ verbose: boolean
47
+ ): Promise<Transaction[] | null>
package/selector.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ export type SelectorFlags = {
2
+ [flag: string]: string;
3
+ }
4
+
5
+ export type Selector = {
6
+ [key: string]: {
7
+ type: string;
8
+ description: string | undefined;
9
+ desc: string | undefined;
10
+ alias: string | undefined,
11
+ isRequired: boolean | undefined,
12
+ default: string | boolean | undefined;
13
+ }
14
+ }
15
+
16
+ export function getJobName(name: string, selectorFlags: SelectorFlags, mode: string | undefined): string;
17
+ export function getSelectorDesc(selector: Selector): string;
18
+ export function getSelectorFlags(selector: Selector): SelectorFlags;
19
+ export function toSelectorString(selectorFlags: SelectorFlags, delim: string | undefined): string;
package/slack.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { WebClient } from "@slack/web-api";
2
+
3
+ export function getClient(): WebClient;
4
+ export function findConversation(client: WebClient, name: string): Promise<string | null>;
5
+ export function postMessage(channel: string, message: any, verbose: boolean): Promise<void>;
package/snowflake.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import { ConnectionOptions, Connection, Binds } from "snowflake-sdk";
2
+
3
+ export function getConnection(options: ConnectionOptions): Promise<Connection>;
4
+ export function executeSql(options: ConnectionOptions, sql: string, binds: Binds): Promise<any[]>;
package/sqs.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { SQS } from "aws-sdk";
2
+
3
+ export function getSQS(): SQS;
package/token.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { BigNumber } from "bignumber.js";
2
+
3
+ export function getTokenPriceAt(tokenAddress: string, timestamp: number, useCache: boolean | undefined): Promise<number>;
4
+ export function toNativeDecimal(bigNumber: BigNumber, decimals: number): Promise<BigNumber>;
5
+ export function toHumanDecimal(bigNumber: BigNumber, decimals: number): Promise<BigNumber>;
@@ -0,0 +1,30 @@
1
+ type Log = {
2
+ address: string,
3
+ topics: string[],
4
+ data: string,
5
+ blockNumber: string,
6
+ transactionHash: string,
7
+ transactionIndex: string,
8
+ blockHash: string,
9
+ logIndex: string,
10
+ removed: boolean
11
+ }
12
+
13
+ type TransactionReceipt = {
14
+ blockHash: string,
15
+ blockNumber: string,
16
+ contractAddress: string | null,
17
+ cumulativeGasUsed: string,
18
+ effectiveGasPrice: string,
19
+ from: string,
20
+ gasUsed: string,
21
+ logs: Log[],
22
+ logsBloom: string,
23
+ status: string,
24
+ to: string,
25
+ transactionHash: string,
26
+ transactionIndex: string,
27
+ type: string
28
+ }
29
+
30
+ export function getTxReceipt(protocol: string, txHash: string, verbose: boolean): Promise<TransactionReceipt | null>;
package/util.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export function arrayGroup<T>(array:T[], groupSize: number): T[][];
2
+ export function partition(startAt: number, endAt: number, numGroups: number): [number, number][];
3
+ export function range(startAt: number, endAt: number, step: number): [number, number][];
4
+ export function fillRange(startAt: number, endAt: number): number[];
5
+ export function chunk<T>(array: T[], count: number): T[][];
package/web3.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ import Bottleneck from "bottleneck";
2
+ import Web3 from "web3";
3
+ import { ABI } from "./abi";
4
+
5
+ type Call = {
6
+ params: any | any[],
7
+ functionName: string | undefined,
8
+ target: string | undefined
9
+ } | any[];
10
+
11
+ export function newWeb3ByProtocol(protocol: string): Web3
12
+ export function singleCall(protocol: string, abi: ABI, target: string, params: any[]): Promise<any>;
13
+ export function multiCall(multiCallParams: {
14
+ protocol: string;
15
+ limiter: Bottleneck | undefined;
16
+ target: string;
17
+ abi: ABI;
18
+ calls: Call[];
19
+ }): Promise<{
20
+ callCount: number;
21
+ actualCallCount: number | undefined;
22
+ output: any[];
23
+ }>;