@certik/skynet 0.7.13 → 0.7.14

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,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.14
4
+
5
+ - Fix missing require in `labelling.js`
6
+ - Only keep distinct tags in `labelling.js`
7
+
3
8
  ## 0.7.13
4
9
 
5
10
  - Update `labelling.js` to support auto db entry creation and address label fetching.
package/labelling.js CHANGED
@@ -1,3 +1,4 @@
1
+ const fetch = require("node-fetch");
1
2
  const { getRecordByKey, updateRecordByKey } = require("./dynamodb");
2
3
  const { getEnvironment } = require("./env");
3
4
 
@@ -34,7 +35,7 @@ async function addTagsToAddress(address, tags, verbose) {
34
35
  const response = await fetch(url);
35
36
  const json = await response.json();
36
37
  if (!json.type) {
37
- throw new Error("Unknown address type in inquiry response");
38
+ throw new Error(`Unknown address type in inquiry response: ${address}`);
38
39
  }
39
40
  const { type } = json;
40
41
  tableName = type === "EOA" ? ADDRESSES_TABLE_NAME : SMART_CONTRACTS_TABLE_NAME;
@@ -56,6 +57,11 @@ async function addTagsToAddress(address, tags, verbose) {
56
57
 
57
58
  updateItemTags = [...updateItemTags, ...newTags];
58
59
 
60
+ // keep distinct tags
61
+ updateItemTags = updateItemTags.filter(
62
+ (value, index, self) => self.findIndex((t) => t.type === value.type && t.label === value.label) === index
63
+ );
64
+
59
65
  await updateRecordByKey(tableName, { address: address }, { tags: updateItemTags }, null, verbose);
60
66
  }
61
67
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@certik/skynet",
3
- "version": "0.7.13",
3
+ "version": "0.7.14",
4
4
  "description": "Skynet Shared JS library",
5
5
  "main": "index.js",
6
6
  "author": "CertiK Engineering",