@certik/skynet 0.10.66 → 0.11.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/.eslintrc.json +21 -0
- package/.prettierrc.json +4 -0
- package/CHANGELOG.md +10 -0
- package/abi.js +237 -242
- package/ably.d.ts +1 -0
- package/ably.js +5 -10
- package/address.d.ts +1 -1
- package/address.js +2 -7
- package/api.d.ts +1 -1
- package/api.js +8 -9
- package/app.js +12 -11
- package/availability.js +3 -9
- package/block.js +6 -7
- package/bun.lockb +0 -0
- package/cli.js +3 -3
- package/const.js +2 -2
- package/date.js +2 -2
- package/deploy.js +12 -15
- package/distributed-lock.js +1 -5
- package/dns.js +2 -4
- package/dynamodb.js +64 -47
- package/env.js +1 -1
- package/examples/{api → api.js} +1 -1
- package/examples/{consumer → consumer.js} +1 -1
- package/examples/{indexer → indexer.js} +3 -3
- package/examples/{mode-indexer → mode-indexer.js} +1 -1
- package/examples/{producer → producer.js} +1 -1
- package/graphql.d.ts +0 -2
- package/graphql.js +1 -7
- package/indexer.js +12 -10
- package/kafka.js +12 -11
- package/log.js +1 -1
- package/metric.js +3 -8
- package/monitor.js +9 -8
- package/opensearch.js +3 -8
- package/opsgenie.js +2 -5
- package/package.json +26 -21
- package/price.js +10 -12
- package/primitive.js +2 -1
- package/proxy.d.ts +0 -2
- package/proxy.js +1 -4
- package/s3.js +23 -20
- package/scan.js +3 -4
- package/selector.js +1 -1
- package/slack.js +2 -2
- package/snowflake.js +4 -4
- package/sqs.js +3 -5
- package/token.js +4 -4
- package/transaction.js +3 -4
- package/util.js +1 -1
- package/web3.js +5 -5
- package/.eslintrc.js +0 -13
- package/.prettierrc.js +0 -3
package/graphql.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
const fetch = require("node-fetch");
|
|
2
|
-
|
|
3
1
|
const GRAPHQL_API_KEY = process.env.SKYNET_GRAPHQL_API_KEY || process.env.GRAPHQL_API_KEY;
|
|
4
2
|
|
|
5
|
-
async function gql(url, query, variables = {}) {
|
|
3
|
+
export async function gql(url, query, variables = {}) {
|
|
6
4
|
const res = await fetch(url, {
|
|
7
5
|
method: "POST",
|
|
8
6
|
headers: {
|
|
@@ -24,7 +22,3 @@ async function gql(url, query, variables = {}) {
|
|
|
24
22
|
throw new Error(await res.text());
|
|
25
23
|
}
|
|
26
24
|
}
|
|
27
|
-
|
|
28
|
-
module.exports = {
|
|
29
|
-
gql,
|
|
30
|
-
};
|
package/indexer.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import meow from "meow";
|
|
2
|
+
import { createRecord, getRecordByKey } from "./dynamodb.js";
|
|
3
|
+
import { getEnvironment } from "./env.js";
|
|
4
|
+
import { exponentialRetry } from "./availability.js";
|
|
5
|
+
import { range as numberRange, fillRange as fillNumberRange } from "./util.js";
|
|
6
|
+
import { getSelectorFlags, getSelectorDesc, toSelectorString } from "./selector.js";
|
|
7
|
+
import { getBinaryName } from "./cli.js";
|
|
8
|
+
import { inline } from "./log.js";
|
|
9
|
+
import { findDateAfter, dateRange, daysInRange as fillDateRange } from "./date.js";
|
|
10
10
|
|
|
11
11
|
const STATE_TABLE_NAME = "skynet-" + getEnvironment() + "-indexer-state";
|
|
12
12
|
|
|
@@ -506,6 +506,7 @@ ${getSelectorDesc(selector)}
|
|
|
506
506
|
--verbose Output debug messages
|
|
507
507
|
`,
|
|
508
508
|
{
|
|
509
|
+
importMeta: import.meta,
|
|
509
510
|
description: false,
|
|
510
511
|
version: false,
|
|
511
512
|
flags: {
|
|
@@ -562,6 +563,7 @@ ${getSelectorDesc(selector)}
|
|
|
562
563
|
--verbose Output debug messages
|
|
563
564
|
`,
|
|
564
565
|
{
|
|
566
|
+
importMeta: import.meta,
|
|
565
567
|
description: false,
|
|
566
568
|
version: false,
|
|
567
569
|
flags: {
|
|
@@ -623,7 +625,7 @@ ${getSelectorDesc(selector)}
|
|
|
623
625
|
return { run };
|
|
624
626
|
}
|
|
625
627
|
|
|
626
|
-
|
|
628
|
+
export {
|
|
627
629
|
increaseId,
|
|
628
630
|
createModeIndexerApp,
|
|
629
631
|
createIndexerApp,
|
package/kafka.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const { inline } = require("./log");
|
|
1
|
+
import meow from "meow";
|
|
2
|
+
import { Kafka, logLevel } from "kafkajs";
|
|
3
|
+
import { getEnvironment, getEnvOrThrow } from "./env.js";
|
|
4
|
+
import { getJobName, getSelectorFlags, getSelectorDesc, toSelectorString } from "./selector.js";
|
|
5
|
+
import { createRecord, getRecordByKey, deleteRecordsByHashKey } from "./dynamodb.js";
|
|
6
|
+
import { wait, exponentialRetry } from "./availability.js";
|
|
7
|
+
import { useLock } from "./distributed-lock.js";
|
|
8
|
+
import { getBinaryName } from "./cli.js";
|
|
9
|
+
import { inline } from "./log.js";
|
|
11
10
|
|
|
12
11
|
const STATE_TABLE_NAME = "skynet-" + getEnvironment() + "-indexer-state";
|
|
13
12
|
|
|
@@ -169,6 +168,7 @@ ${getSelectorDesc(selector)}
|
|
|
169
168
|
--reset restart producer
|
|
170
169
|
`,
|
|
171
170
|
{
|
|
171
|
+
importMeta: import.meta,
|
|
172
172
|
description: false,
|
|
173
173
|
version: false,
|
|
174
174
|
flags: {
|
|
@@ -358,6 +358,7 @@ ${getSelectorDesc(selector)}
|
|
|
358
358
|
--verbose Output debug messages
|
|
359
359
|
`,
|
|
360
360
|
{
|
|
361
|
+
importMeta: import.meta,
|
|
361
362
|
description: false,
|
|
362
363
|
version: false,
|
|
363
364
|
flags: {
|
|
@@ -438,7 +439,7 @@ ${getSelectorDesc(selector)}
|
|
|
438
439
|
return { run };
|
|
439
440
|
}
|
|
440
441
|
|
|
441
|
-
|
|
442
|
+
export {
|
|
442
443
|
createProducerApp,
|
|
443
444
|
createConsumerApp,
|
|
444
445
|
produceMessages,
|
package/log.js
CHANGED
package/metric.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { getDocClient } from "./dynamodb.js";
|
|
2
2
|
|
|
3
3
|
/* Assume table has name/timestamp/value fields */
|
|
4
4
|
|
|
5
|
-
async function getMetricAt(tableName, name, timestamp) {
|
|
5
|
+
export async function getMetricAt(tableName, name, timestamp) {
|
|
6
6
|
const docClient = getDocClient();
|
|
7
7
|
|
|
8
8
|
const query = await docClient
|
|
@@ -31,7 +31,7 @@ async function getMetricAt(tableName, name, timestamp) {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
async function getMetricPreviousValue(tableName, name, timestamp) {
|
|
34
|
+
export async function getMetricPreviousValue(tableName, name, timestamp) {
|
|
35
35
|
const docClient = getDocClient();
|
|
36
36
|
|
|
37
37
|
const query = await docClient
|
|
@@ -58,8 +58,3 @@ async function getMetricPreviousValue(tableName, name, timestamp) {
|
|
|
58
58
|
return value;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
module.exports = {
|
|
63
|
-
getMetricAt,
|
|
64
|
-
getMetricPreviousValue
|
|
65
|
-
}
|
package/monitor.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const { getJobName } = require("./deploy");
|
|
1
|
+
import meow from "meow";
|
|
2
|
+
import { getSelectorFlags, getSelectorDesc, toSelectorString } from "./selector.js";
|
|
3
|
+
import { getBinaryName } from "./cli.js";
|
|
4
|
+
import { exponentialRetry } from "./availability.js";
|
|
5
|
+
import { postGenieMessage } from "./opsgenie.js";
|
|
6
|
+
import { getJobName } from "./deploy.js";
|
|
8
7
|
|
|
9
8
|
const ERROR_LEVEL = {
|
|
10
9
|
INFO: "Info",
|
|
@@ -49,6 +48,7 @@ async function getMostRecentJobLaunch(name) {
|
|
|
49
48
|
const recentFinishedJob = jobs.reverse().find((job) => {
|
|
50
49
|
// filter out monitor job
|
|
51
50
|
return job.ID.indexOf("-monitor") === -1 && job.Status === "dead";
|
|
51
|
+
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
if (!recentFinishedJob) {
|
|
@@ -86,6 +86,7 @@ ${
|
|
|
86
86
|
--verbose Output debug messages
|
|
87
87
|
`,
|
|
88
88
|
{
|
|
89
|
+
importMeta: import.meta,
|
|
89
90
|
description: false,
|
|
90
91
|
version: false,
|
|
91
92
|
flags: {
|
|
@@ -193,4 +194,4 @@ ${
|
|
|
193
194
|
return { monitor };
|
|
194
195
|
}
|
|
195
196
|
|
|
196
|
-
|
|
197
|
+
export { createMonitor, ERROR_LEVEL, LEVEL_EMOJI };
|
package/opensearch.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { Client } from "@opensearch-project/opensearch";
|
|
2
2
|
|
|
3
3
|
// newOpensearchClient creates a new opensearch client with the given endpoint, key, secret and extra opensearch client options.
|
|
4
|
-
function newOpensearchClient(endpoint, key, secret, options = {}) {
|
|
4
|
+
export function newOpensearchClient(endpoint, key, secret, options = {}) {
|
|
5
5
|
return new Client({
|
|
6
6
|
node: endpoint,
|
|
7
7
|
auth: {
|
|
@@ -18,7 +18,7 @@ function newOpensearchClient(endpoint, key, secret, options = {}) {
|
|
|
18
18
|
// the index from growing too large.
|
|
19
19
|
// Returns an object with status and result properties. The status is either "ok" or "error". The result is the response from opensearch
|
|
20
20
|
// if the status is "ok" or the error message if the status is "error".
|
|
21
|
-
async function sendToOpensearch(client, appName, index, record, indexSuffixes = []) {
|
|
21
|
+
export async function sendToOpensearch(client, appName, index, record, indexSuffixes = []) {
|
|
22
22
|
try {
|
|
23
23
|
const result = await client.index({
|
|
24
24
|
index: indexSuffixes ? [index, ...indexSuffixes].join("-") : index,
|
|
@@ -32,8 +32,3 @@ async function sendToOpensearch(client, appName, index, record, indexSuffixes =
|
|
|
32
32
|
return { status: "error", result: err.stack ? err.stack : err };
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
module.exports = {
|
|
37
|
-
newOpensearchClient,
|
|
38
|
-
sendToOpensearch,
|
|
39
|
-
};
|
package/opsgenie.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
const md5 = require("md5");
|
|
1
|
+
import md5 from "md5";
|
|
3
2
|
|
|
4
3
|
function getGenieKey(key) {
|
|
5
4
|
return key || process.env.OPSGENIE_API_KEY;
|
|
@@ -9,7 +8,7 @@ function getGenieEndPoint() {
|
|
|
9
8
|
return process.env.OPSGENIE_END_POINT || "https://api.opsgenie.com/v2/alerts";
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
async function postGenieMessage(body, apiKey, verbose) {
|
|
11
|
+
export async function postGenieMessage(body, apiKey, verbose) {
|
|
13
12
|
try {
|
|
14
13
|
const genieKey = apiKey || getGenieKey();
|
|
15
14
|
const genieEndPoint = getGenieEndPoint(genieKey);
|
|
@@ -45,5 +44,3 @@ async function postGenieMessage(body, apiKey, verbose) {
|
|
|
45
44
|
throw error;
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
|
-
|
|
49
|
-
module.exports = { postGenieMessage };
|
package/package.json
CHANGED
|
@@ -1,42 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@certik/skynet",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "Skynet Shared JS library",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "index.js",
|
|
6
7
|
"author": "CertiK Engineering",
|
|
7
8
|
"scripts": {
|
|
8
9
|
"lint": "eslint *.js test",
|
|
9
|
-
"test": "doppler run -- ava",
|
|
10
|
+
"test": "doppler run -- ava --timeout=1m",
|
|
10
11
|
"format": "prettier --write '*.js' '**/*.js'",
|
|
11
12
|
"pub": "npm publish --access public"
|
|
12
13
|
},
|
|
13
14
|
"engines": {
|
|
14
|
-
"node": ">=
|
|
15
|
+
"node": ">= 18"
|
|
15
16
|
},
|
|
16
17
|
"dependencies": {
|
|
18
|
+
"@aws-sdk/client-dynamodb": "^3.409.0",
|
|
19
|
+
"@aws-sdk/client-s3": "^3.409.0",
|
|
20
|
+
"@aws-sdk/client-sqs": "^3.409.0",
|
|
21
|
+
"@aws-sdk/lib-dynamodb": "^3.409.0",
|
|
17
22
|
"@opensearch-project/opensearch": "^2.3.1",
|
|
18
|
-
"@slack/web-api": "^6.
|
|
19
|
-
"ably": "^1.2.
|
|
20
|
-
"abort-controller": "^3.0.0",
|
|
21
|
-
"aws-sdk": "^2.1164.0",
|
|
23
|
+
"@slack/web-api": "^6.9.0",
|
|
24
|
+
"ably": "^1.2.44",
|
|
22
25
|
"bottleneck": "^2.19.5",
|
|
23
|
-
"chalk": "^
|
|
24
|
-
"execa": "^
|
|
25
|
-
"express": "^4.18.
|
|
26
|
-
"kafkajs": "^2.
|
|
26
|
+
"chalk": "^5.3.0",
|
|
27
|
+
"execa": "^8.0.1",
|
|
28
|
+
"express": "^4.18.2",
|
|
29
|
+
"kafkajs": "^2.2.4",
|
|
27
30
|
"md5": "^2.3.0",
|
|
28
|
-
"meow": "^
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"which": "^2.0.2"
|
|
31
|
+
"meow": "^12.1.1",
|
|
32
|
+
"snowflake-sdk": "^1.8.0",
|
|
33
|
+
"web3": "^4.1.1",
|
|
34
|
+
"which": "^4.0.0"
|
|
33
35
|
},
|
|
34
36
|
"devDependencies": {
|
|
35
|
-
"ava": "^5.
|
|
36
|
-
"eslint": "^8.
|
|
37
|
-
"eslint-plugin-import": "^2.
|
|
37
|
+
"ava": "^5.3.1",
|
|
38
|
+
"eslint": "^8.49.0",
|
|
39
|
+
"eslint-plugin-import": "^2.28.1",
|
|
38
40
|
"prettier": "^3.0.3",
|
|
39
|
-
"sinon": "^
|
|
41
|
+
"sinon": "^15.2.0"
|
|
40
42
|
},
|
|
41
|
-
"license": "MIT"
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
}
|
|
42
47
|
}
|
package/price.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
import { QueryCommand } from "@aws-sdk/lib-dynamodb";
|
|
2
|
+
import { getDocClient } from "./dynamodb.js";
|
|
2
3
|
|
|
3
4
|
async function queryPrice(tableName, address, timestamp, op = "<") {
|
|
4
5
|
const docClient = getDocClient();
|
|
5
6
|
|
|
6
|
-
return await docClient
|
|
7
|
-
|
|
7
|
+
return await docClient.send(
|
|
8
|
+
new QueryCommand({
|
|
8
9
|
TableName: tableName,
|
|
9
10
|
KeyConditionExpression: `#address = :address and #timestamp ${op} :timestamp`,
|
|
10
11
|
ExpressionAttributeNames: {
|
|
11
12
|
"#timestamp": "timestamp",
|
|
12
|
-
"#address": "address"
|
|
13
|
+
"#address": "address",
|
|
13
14
|
},
|
|
14
15
|
ExpressionAttributeValues: {
|
|
15
16
|
":timestamp": timestamp,
|
|
16
|
-
":address": address
|
|
17
|
+
":address": address,
|
|
17
18
|
},
|
|
18
19
|
Limit: 1,
|
|
19
|
-
ScanIndexForward: false
|
|
20
|
-
})
|
|
21
|
-
|
|
20
|
+
ScanIndexForward: false,
|
|
21
|
+
}),
|
|
22
|
+
);
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
async function getPricePreviousRecord(tableName, address, timestamp) {
|
|
@@ -42,7 +43,4 @@ async function getPriceClosestTo(tableName, address, timestamp) {
|
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
getPriceClosestTo,
|
|
47
|
-
getPricePreviousRecord
|
|
48
|
-
};
|
|
46
|
+
export { getPriceClosestTo, getPricePreviousRecord };
|
package/primitive.js
CHANGED
package/proxy.d.ts
CHANGED
package/proxy.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
const fetch = require("node-fetch");
|
|
2
|
-
const AbortController = require("abort-controller");
|
|
3
|
-
|
|
4
1
|
const PROXY_INSTANCES = [
|
|
5
2
|
"https://uer87capga.execute-api.us-east-1.amazonaws.com/", // 0
|
|
6
3
|
"https://t7utq0a5hb.execute-api.us-east-1.amazonaws.com/",
|
|
@@ -154,4 +151,4 @@ async function proxyFetch(url, options = {}) {
|
|
|
154
151
|
}
|
|
155
152
|
}
|
|
156
153
|
|
|
157
|
-
|
|
154
|
+
export default proxyFetch;
|
package/s3.js
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
S3Client,
|
|
3
|
+
GetObjectCommand,
|
|
4
|
+
HeadObjectCommand,
|
|
5
|
+
PutObjectCommand,
|
|
6
|
+
DeleteObjectCommand,
|
|
7
|
+
ListObjectsV2Command,
|
|
8
|
+
NotFound,
|
|
9
|
+
} from "@aws-sdk/client-s3";
|
|
10
|
+
import { getAWSAccessKeyId, getAWSSecretAccessKey, getAWSRegion } from "./env.js";
|
|
3
11
|
|
|
4
12
|
function getS3() {
|
|
5
|
-
return new
|
|
6
|
-
|
|
7
|
-
|
|
13
|
+
return new S3Client({
|
|
14
|
+
credentials: {
|
|
15
|
+
accessKeyId: getAWSAccessKeyId(),
|
|
16
|
+
secretAccessKey: getAWSSecretAccessKey(),
|
|
17
|
+
},
|
|
8
18
|
region: getAWSRegion(),
|
|
9
19
|
});
|
|
10
20
|
}
|
|
@@ -15,8 +25,8 @@ async function readFile(bucketName, key, verbose = false) {
|
|
|
15
25
|
const params = { Bucket: bucketName, Key: key };
|
|
16
26
|
|
|
17
27
|
try {
|
|
18
|
-
const result = await s3.
|
|
19
|
-
return result.Body.
|
|
28
|
+
const result = await s3.send(new GetObjectCommand(params));
|
|
29
|
+
return result.Body.transformToString();
|
|
20
30
|
} catch (noSuchKeyErr) {
|
|
21
31
|
if (verbose) {
|
|
22
32
|
console.log("no such bucket or key", bucketName, key);
|
|
@@ -30,11 +40,11 @@ async function hasFile(bucketName, key) {
|
|
|
30
40
|
const s3 = getS3();
|
|
31
41
|
|
|
32
42
|
try {
|
|
33
|
-
await s3.
|
|
43
|
+
await s3.send(new HeadObjectCommand({ Bucket: bucketName, Key: key }));
|
|
34
44
|
|
|
35
45
|
return true;
|
|
36
46
|
} catch (headErr) {
|
|
37
|
-
if (headErr
|
|
47
|
+
if (headErr instanceof NotFound) {
|
|
38
48
|
return false;
|
|
39
49
|
}
|
|
40
50
|
|
|
@@ -67,7 +77,7 @@ async function writeFile(bucketName, key, body, options = {}) {
|
|
|
67
77
|
console.log("uploading", key);
|
|
68
78
|
}
|
|
69
79
|
|
|
70
|
-
await s3.
|
|
80
|
+
await s3.send(new PutObjectCommand(params));
|
|
71
81
|
}
|
|
72
82
|
|
|
73
83
|
async function deleteFile(bucketName, key, verbose = false) {
|
|
@@ -76,7 +86,7 @@ async function deleteFile(bucketName, key, verbose = false) {
|
|
|
76
86
|
const params = { Bucket: bucketName, Key: key };
|
|
77
87
|
|
|
78
88
|
try {
|
|
79
|
-
await s3.
|
|
89
|
+
await s3.send(new DeleteObjectCommand(params));
|
|
80
90
|
} catch (noSuchKeyErr) {
|
|
81
91
|
if (verbose) {
|
|
82
92
|
console.log("no such bucket or key", bucketName, key);
|
|
@@ -95,7 +105,7 @@ async function listKeys(bucketname, prefix, continuationToken) {
|
|
|
95
105
|
|
|
96
106
|
let data = null;
|
|
97
107
|
try {
|
|
98
|
-
data = await s3.
|
|
108
|
+
data = await s3.send(new ListObjectsV2Command(params));
|
|
99
109
|
} catch (err) {
|
|
100
110
|
if (err.statusCode && err.statusCode === 400) {
|
|
101
111
|
return null;
|
|
@@ -112,11 +122,4 @@ async function listKeys(bucketname, prefix, continuationToken) {
|
|
|
112
122
|
return res;
|
|
113
123
|
}
|
|
114
124
|
|
|
115
|
-
|
|
116
|
-
getS3,
|
|
117
|
-
hasFile,
|
|
118
|
-
readFile,
|
|
119
|
-
writeFile,
|
|
120
|
-
deleteFile,
|
|
121
|
-
listKeys,
|
|
122
|
-
};
|
|
125
|
+
export { getS3, hasFile, readFile, writeFile, deleteFile, listKeys };
|
package/scan.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const fetch = require("node-fetch");
|
|
1
|
+
import { exponentialRetry, wait } from "./availability.js";
|
|
2
|
+
import { PROTOCOLS } from "./const.js";
|
|
4
3
|
|
|
5
4
|
const BATCH_SIZE = 10_000; // Max number of transactions fetched from scan api at once
|
|
6
5
|
|
|
@@ -72,4 +71,4 @@ async function streamTxs(address, since, to, callback, verbose) {
|
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
73
|
|
|
75
|
-
|
|
74
|
+
export { streamTxs, fetchTxs, fetchTxsWithRetry };
|
package/selector.js
CHANGED
package/slack.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { WebClient } from "@slack/web-api";
|
|
2
2
|
|
|
3
3
|
function getToken() {
|
|
4
4
|
return process.env.SKYNET_SLACK_TOKEN;
|
|
@@ -89,4 +89,4 @@ async function postMessage(channel, message, verbose) {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
export { getClient, findConversation, postMessage };
|
package/snowflake.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import snowflake from "snowflake-sdk";
|
|
2
|
+
import { promisify } from "util";
|
|
3
|
+
import { ensureAndGet } from "./env.js";
|
|
4
4
|
|
|
5
5
|
async function getConnection(options) {
|
|
6
6
|
const connection = snowflake.createConnection({
|
|
@@ -30,7 +30,7 @@ async function executeSql(options, sql, binds) {
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
export {
|
|
34
34
|
getConnection,
|
|
35
35
|
executeSql,
|
|
36
36
|
};
|
package/sqs.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { SQS } from "@aws-sdk/client-sqs";
|
|
2
|
+
import { getAWSAccessKeyId, getAWSSecretAccessKey, getAWSRegion } from "./env.js";
|
|
3
3
|
|
|
4
|
-
function getSQS() {
|
|
4
|
+
export function getSQS() {
|
|
5
5
|
return new SQS({
|
|
6
6
|
accessKeyId: getAWSAccessKeyId(),
|
|
7
7
|
secretAccessKey: getAWSSecretAccessKey(),
|
|
8
8
|
region: getAWSRegion(),
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
module.exports = { getSQS };
|
package/token.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { getEnvironment } from "./env.js";
|
|
2
|
+
import { getPriceClosestTo } from "./price.js";
|
|
3
|
+
import BigNumber from "bignumber.js";
|
|
4
4
|
|
|
5
5
|
const TOKEN_PRICE_TABLE_NAME = `skynet-${getEnvironment()}-token-prices`;
|
|
6
6
|
const TOKEN_PRICE_CACHE = {};
|
|
@@ -39,7 +39,7 @@ function toHumanDecimal(bigNumber, decimals) {
|
|
|
39
39
|
return new BigNumber(bigNumber).dividedBy(dividend);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
export {
|
|
43
43
|
getTokenPriceAt,
|
|
44
44
|
toNativeDecimal,
|
|
45
45
|
toHumanDecimal,
|
package/transaction.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const { exponentialRetry } = require("./availability");
|
|
1
|
+
import { PROTOCOLS } from "./const.js";
|
|
2
|
+
import { exponentialRetry } from "./availability.js";
|
|
4
3
|
|
|
5
4
|
async function getTxReceipt(protocol, txHash, verbose = false) {
|
|
6
5
|
const { endpoint } = PROTOCOLS[protocol];
|
|
@@ -38,6 +37,6 @@ async function getTxReceipt(protocol, txHash, verbose = false) {
|
|
|
38
37
|
return result;
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
|
|
40
|
+
export {
|
|
42
41
|
getTxReceipt
|
|
43
42
|
};
|
package/util.js
CHANGED
package/web3.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { Web3 } from "web3";
|
|
2
|
+
import { PROTOCOLS } from "./const.js";
|
|
3
|
+
import { MULTICALL } from "./abi.js";
|
|
4
|
+
import { chunk } from "./util.js";
|
|
5
5
|
const MULTICALL_CHUNK_SIZE = 400;
|
|
6
6
|
|
|
7
7
|
function newWeb3ByProtocol(protocol) {
|
|
@@ -110,7 +110,7 @@ async function multiCall({ protocol, limiter = null, target, abi, calls }) {
|
|
|
110
110
|
return { actualCallCount: callChunks.length, output: responses };
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
export {
|
|
114
114
|
newWeb3ByProtocol,
|
|
115
115
|
singleCall,
|
|
116
116
|
multiCall,
|
package/.eslintrc.js
DELETED
package/.prettierrc.js
DELETED