@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 +5 -0
- package/labelling.js +7 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
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(
|
|
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
|
|