diff --git a/README.md b/README.md index 43422d4..a73c323 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ The content of the file should be like this: ```JSON { + "address": "0xADDRESS", "labels": [{ "type": "info", "value": "LlamaFolio" }], "links": { "twitter": "https://twitter.com/llamafolio" diff --git a/index.ts b/index.ts index dac7071..39e40b4 100644 --- a/index.ts +++ b/index.ts @@ -30,6 +30,7 @@ export interface Label { type SocialLabel = "twitter" | "telegram" | "github"; export interface AddressLabels { + address: string labels: Label[]; links: { [k in SocialLabel]: string }; } @@ -41,6 +42,7 @@ export function getLabel(address: string, ensName?: string): AddressLabels { const registryLabels = registry[address]; const labelt = { + address, links: registryLabels?.links ?? {}, labels: registryLabels?.labels ?? [], }; @@ -60,3 +62,47 @@ export function getLabel(address: string, ensName?: string): AddressLabels { return labelt; } + +const searchRegistry: Array = (function() { + const requireContext = require.context("./labels", false, /.json$/); + const keys = requireContext.keys(); + const values = keys.map(requireContext) as Array + + return values +})() + + +export interface SearchLabels extends Omit { + links: Array<{ name: SocialLabel, value: string }> +} + +/** + * @param address lowercase string. ex: "founder" + */ +export function searchLabel(searchTerm: string): Array { + const results = searchRegistry.map(addressLabels => { + const labels = addressLabels.labels.filter(label => label.value.toLowerCase().includes(searchTerm)) + + const links = (Object.keys(addressLabels.links) as Array).reduce((acc, key) => { + const socialValue = addressLabels.links[key] + + if (socialValue.toLowerCase().includes(searchTerm)) { + acc.push({name: key, value: socialValue }) + } + + return acc + }, [] as SearchLabels['links']) + + if (labels.length || Object.keys(links).length) { + return { + address: addressLabels.address, + labels, + links + } + } + + return null + }).filter((result): result is SearchLabels => !!result) + + return results || [] +} diff --git a/labels/0x0035fc5208ef989c28d47e552e92b0c507d2b318.json b/labels/0x0035fc5208ef989c28d47e552e92b0c507d2b318.json index bed19fb..95b0ff0 100644 --- a/labels/0x0035fc5208ef989c28d47e552e92b0c507d2b318.json +++ b/labels/0x0035fc5208ef989c28d47e552e92b0c507d2b318.json @@ -1,4 +1,5 @@ { + "address": "0x0035fc5208ef989c28d47e552e92b0c507d2b318", "labels": [ { "type": "info", "value": "Banteg" }, { "type": "info", "value": "Builder" }, diff --git a/labels/0x070341aa5ed571f0fb2c4a5641409b1a46b4961b.json b/labels/0x070341aa5ed571f0fb2c4a5641409b1a46b4961b.json index a4807a4..5c1a9e4 100644 --- a/labels/0x070341aa5ed571f0fb2c4a5641409b1a46b4961b.json +++ b/labels/0x070341aa5ed571f0fb2c4a5641409b1a46b4961b.json @@ -1,4 +1,5 @@ { + "address": "0x070341aa5ed571f0fb2c4a5641409b1a46b4961b", "labels": [ { "type": "info", "value": "Penn Blockchain" }, { "type": "info", "value": "University" }, diff --git a/labels/0x11e4857bb9993a50c685a79afad4e6f65d518dda.json b/labels/0x11e4857bb9993a50c685a79afad4e6f65d518dda.json index dc7258e..66dd63c 100644 --- a/labels/0x11e4857bb9993a50c685a79afad4e6f65d518dda.json +++ b/labels/0x11e4857bb9993a50c685a79afad4e6f65d518dda.json @@ -1,4 +1,5 @@ { + "address": "0x11e4857bb9993a50c685a79afad4e6f65d518dda", "labels": [ { "type": "info", "value": "Hayden Adams" }, { "type": "info", "value": "Builder" }, diff --git a/labels/0x2d407ddb06311396fe14d4b49da5f0471447d45c.json b/labels/0x2d407ddb06311396fe14d4b49da5f0471447d45c.json index 2482e8c..34af74d 100644 --- a/labels/0x2d407ddb06311396fe14d4b49da5f0471447d45c.json +++ b/labels/0x2d407ddb06311396fe14d4b49da5f0471447d45c.json @@ -1,4 +1,5 @@ { + "address": "0x2d407ddb06311396fe14d4b49da5f0471447d45c", "labels": [ { "type": "info", "value": "Andre Cronje" }, { "type": "info", "value": "Founder" }, diff --git a/labels/0x2ef2d6e5d34b5f3b465adfa1b38204dbd274b32a.json b/labels/0x2ef2d6e5d34b5f3b465adfa1b38204dbd274b32a.json index 511dc60..2e86933 100644 --- a/labels/0x2ef2d6e5d34b5f3b465adfa1b38204dbd274b32a.json +++ b/labels/0x2ef2d6e5d34b5f3b465adfa1b38204dbd274b32a.json @@ -1,4 +1,5 @@ { + "address": "0x2ef2d6e5d34b5f3b465adfa1b38204dbd274b32a", "labels": [ { "type": "info", diff --git a/labels/0x3ddfa8ec3052539b6c9549f12cea2c295cff5296.json b/labels/0x3ddfa8ec3052539b6c9549f12cea2c295cff5296.json index a3bf1da..45bfad3 100644 --- a/labels/0x3ddfa8ec3052539b6c9549f12cea2c295cff5296.json +++ b/labels/0x3ddfa8ec3052539b6c9549f12cea2c295cff5296.json @@ -1,4 +1,5 @@ { + "address": "0x3ddfa8ec3052539b6c9549f12cea2c295cff5296d", "labels": [ { "type": "info", diff --git a/labels/0x42f9134e9d3bf7eee1f8a5ac2a4328b059e7468c.json b/labels/0x42f9134e9d3bf7eee1f8a5ac2a4328b059e7468c.json index 97844c3..e540fdf 100644 --- a/labels/0x42f9134e9d3bf7eee1f8a5ac2a4328b059e7468c.json +++ b/labels/0x42f9134e9d3bf7eee1f8a5ac2a4328b059e7468c.json @@ -1,4 +1,5 @@ { + "address": "0x42f9134e9d3bf7eee1f8a5ac2a4328b059e7468c", "labels": [ { "type": "info", "value": "Kain Warwick" }, { "type": "info", "value": "Founder" }, diff --git a/labels/0x489a8756c18c0b8b24ec2a2b9ff3d4d447f79bec.json b/labels/0x489a8756c18c0b8b24ec2a2b9ff3d4d447f79bec.json index 46505e6..e6ac91b 100644 --- a/labels/0x489a8756c18c0b8b24ec2a2b9ff3d4d447f79bec.json +++ b/labels/0x489a8756c18c0b8b24ec2a2b9ff3d4d447f79bec.json @@ -1,4 +1,5 @@ { + "address": "0x489a8756c18c0b8b24ec2a2b9ff3d4d447f79bec", "labels": [ { "type": "danger", "value": "Binance Bridge Exploiter" }, { "type": "danger", "value": "Hack" } diff --git a/labels/0x50495480cce225c8476e90466d8615a9e6a5e004.json b/labels/0x50495480cce225c8476e90466d8615a9e6a5e004.json index 7117d22..dd00eae 100644 --- a/labels/0x50495480cce225c8476e90466d8615a9e6a5e004.json +++ b/labels/0x50495480cce225c8476e90466d8615a9e6a5e004.json @@ -1,4 +1,5 @@ { + "address": "0x50495480cce225c8476e90466d8615a9e6a5e004", "labels": [ { "type": "info", "value": "Dragonfly Capital" }, { "type": "info", "value": "VCs" }, diff --git a/labels/0x61258f12c459984f32b83c86a6cc10aa339396de.json b/labels/0x61258f12c459984f32b83c86a6cc10aa339396de.json index e727ca6..3824460 100644 --- a/labels/0x61258f12c459984f32b83c86a6cc10aa339396de.json +++ b/labels/0x61258f12c459984f32b83c86a6cc10aa339396de.json @@ -1,4 +1,5 @@ { + "address": "0x61258f12c459984f32b83c86a6cc10aa339396de", "labels": [ { "type": "info", "value": "Bain Capital Ventures" }, { "type": "info", "value": "VCs" }, diff --git a/labels/0x6626593c237f530d15ae9980a95ef938ac15c35c.json b/labels/0x6626593c237f530d15ae9980a95ef938ac15c35c.json index b12932d..05751e7 100644 --- a/labels/0x6626593c237f530d15ae9980a95ef938ac15c35c.json +++ b/labels/0x6626593c237f530d15ae9980a95ef938ac15c35c.json @@ -1,4 +1,5 @@ { + "address": "0x6626593c237f530d15ae9980a95ef938ac15c35c", "labels": [ { "type": "info", "value": "Gauntlet" }, { "type": "info", "value": "VCs" }, diff --git a/labels/0x683a4f9915d6216f73d6df50151725036bd26c02.json b/labels/0x683a4f9915d6216f73d6df50151725036bd26c02.json index b12932d..276b5b1 100644 --- a/labels/0x683a4f9915d6216f73d6df50151725036bd26c02.json +++ b/labels/0x683a4f9915d6216f73d6df50151725036bd26c02.json @@ -1,4 +1,5 @@ { + "address": "0x683a4f9915d6216f73d6df50151725036bd26c02", "labels": [ { "type": "info", "value": "Gauntlet" }, { "type": "info", "value": "VCs" }, diff --git a/labels/0x7a16ff8270133f063aab6c9977183d9e72835428.json b/labels/0x7a16ff8270133f063aab6c9977183d9e72835428.json index 4ff05e8..60a8ca7 100644 --- a/labels/0x7a16ff8270133f063aab6c9977183d9e72835428.json +++ b/labels/0x7a16ff8270133f063aab6c9977183d9e72835428.json @@ -1,4 +1,5 @@ { + "address": "0x7a16ff8270133f063aab6c9977183d9e72835428", "labels": [ { "type": "info", diff --git a/labels/0x7ae109a63ff4dc852e063a673b40bed85d22e585.json b/labels/0x7ae109a63ff4dc852e063a673b40bed85d22e585.json index 5e8d785..894180e 100644 --- a/labels/0x7ae109a63ff4dc852e063a673b40bed85d22e585.json +++ b/labels/0x7ae109a63ff4dc852e063a673b40bed85d22e585.json @@ -1,4 +1,5 @@ { + "address": "0x7ae109a63ff4dc852e063a673b40bed85d22e585", "labels": [ { "type": "info", "value": "Blockchain at Berkeley" }, { "type": "info", "value": "University" }, diff --git a/labels/0x8169522c2c57883e8ef80c498aab7820da539806.json b/labels/0x8169522c2c57883e8ef80c498aab7820da539806.json index 81a07d4..76aff95 100644 --- a/labels/0x8169522c2c57883e8ef80c498aab7820da539806.json +++ b/labels/0x8169522c2c57883e8ef80c498aab7820da539806.json @@ -1,4 +1,5 @@ { + "address": "0x8169522c2c57883e8ef80c498aab7820da539806", "labels": [ { "type": "info", "value": "Geoffrey Hayes" }, { "type": "info", "value": "Compound Delegate" } diff --git a/labels/0x88fb3d509fc49b515bfeb04e23f53ba339563981.json b/labels/0x88fb3d509fc49b515bfeb04e23f53ba339563981.json index e230f96..b4a5b9a 100644 --- a/labels/0x88fb3d509fc49b515bfeb04e23f53ba339563981.json +++ b/labels/0x88fb3d509fc49b515bfeb04e23f53ba339563981.json @@ -1,4 +1,5 @@ { + "address": "0x88fb3d509fc49b515bfeb04e23f53ba339563981", "labels": [ { "type": "info", "value": "Robert Leshner" }, { "type": "info", "value": "Angel" }, diff --git a/labels/0x8d07d225a769b7af3a923481e1fdf49180e6a265.json b/labels/0x8d07d225a769b7af3a923481e1fdf49180e6a265.json index c318adc..68a7a58 100644 --- a/labels/0x8d07d225a769b7af3a923481e1fdf49180e6a265.json +++ b/labels/0x8d07d225a769b7af3a923481e1fdf49180e6a265.json @@ -1,4 +1,5 @@ { + "address": "0x8d07d225a769b7af3a923481e1fdf49180e6a265", "labels": [ { "type": "info", "value": "Monet Supply" }, { "type": "info", "value": "Governance Participant" }, diff --git a/labels/0x9aa835bc7b8ce13b9b0c9764a52fbf71ac62ccf1.json b/labels/0x9aa835bc7b8ce13b9b0c9764a52fbf71ac62ccf1.json index d1689bb..e007ecd 100644 --- a/labels/0x9aa835bc7b8ce13b9b0c9764a52fbf71ac62ccf1.json +++ b/labels/0x9aa835bc7b8ce13b9b0c9764a52fbf71ac62ccf1.json @@ -1,4 +1,5 @@ { + "address": "0x9aa835bc7b8ce13b9b0c9764a52fbf71ac62ccf1", "labels": [ { "type": "info", "value": "a16z" }, { "type": "info", "value": "VCs" }, diff --git a/labels/0x9b68c14e936104e9a7a24c712beecdc220002984.json b/labels/0x9b68c14e936104e9a7a24c712beecdc220002984.json index ba5f595..c638c52 100644 --- a/labels/0x9b68c14e936104e9a7a24c712beecdc220002984.json +++ b/labels/0x9b68c14e936104e9a7a24c712beecdc220002984.json @@ -1,4 +1,5 @@ { + "address": "0x9b68c14e936104e9a7a24c712beecdc220002984", "labels": [ { "type": "info", "value": "Getty Hill" }, { "type": "info", "value": "GFX Labs" }, diff --git a/labels/0x9c5083dd4838e120dbeac44c052179692aa5dac5.json b/labels/0x9c5083dd4838e120dbeac44c052179692aa5dac5.json index 045c237..448b88f 100644 --- a/labels/0x9c5083dd4838e120dbeac44c052179692aa5dac5.json +++ b/labels/0x9c5083dd4838e120dbeac44c052179692aa5dac5.json @@ -1,4 +1,5 @@ { + "address": "0x9c5083dd4838e120dbeac44c052179692aa5dac5", "labels": [{ "type": "info", "value": "Tetranode" }], "links": { "twitter": "https://twitter.com/Tetranode" diff --git a/labels/0xa1b61405791170833070c0ea61ed28728a840241.json b/labels/0xa1b61405791170833070c0ea61ed28728a840241.json index a424ecb..0d924ab 100644 --- a/labels/0xa1b61405791170833070c0ea61ed28728a840241.json +++ b/labels/0xa1b61405791170833070c0ea61ed28728a840241.json @@ -1,4 +1,5 @@ { + "address": "0xa1b61405791170833070c0ea61ed28728a840241", "labels": [ { "type": "info", "value": "Paradigm" }, { "type": "info", "value": "VCs" }, diff --git a/labels/0xab5801a7d398351b8be11c439e05c5b3259aec9b.json b/labels/0xab5801a7d398351b8be11c439e05c5b3259aec9b.json index 9be9356..210a00d 100644 --- a/labels/0xab5801a7d398351b8be11c439e05c5b3259aec9b.json +++ b/labels/0xab5801a7d398351b8be11c439e05c5b3259aec9b.json @@ -1,4 +1,5 @@ { + "address": "0xab5801a7d398351b8be11c439e05c5b3259aec9b", "labels": [{ "type": "info", "value": "Vitalik Buterin" }], "links": { "twitter": "https://twitter.com/VitalikButerin" diff --git a/labels/0xc95c558daa63b1a79331b2ab4a2a7af375384d3b.json b/labels/0xc95c558daa63b1a79331b2ab4a2a7af375384d3b.json index d7e6f40..1414e25 100644 --- a/labels/0xc95c558daa63b1a79331b2ab4a2a7af375384d3b.json +++ b/labels/0xc95c558daa63b1a79331b2ab4a2a7af375384d3b.json @@ -1,4 +1,5 @@ { + "address": "0xc95c558daa63b1a79331b2ab4a2a7af375384d3b", "labels": [{ "type": "info", "value": "samczsun" }], "links": { "twitter": "https://twitter.com/samczsun", diff --git a/labels/0xd8da6bf26964af9d7eed9e03e53415d37aa96045.json b/labels/0xd8da6bf26964af9d7eed9e03e53415d37aa96045.json index 9be9356..d14d941 100644 --- a/labels/0xd8da6bf26964af9d7eed9e03e53415d37aa96045.json +++ b/labels/0xd8da6bf26964af9d7eed9e03e53415d37aa96045.json @@ -1,4 +1,5 @@ { + "address": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", "labels": [{ "type": "info", "value": "Vitalik Buterin" }], "links": { "twitter": "https://twitter.com/VitalikButerin" diff --git a/labels/0xdc1f98682f4f8a5c6d54f345f448437b83f5e432.json b/labels/0xdc1f98682f4f8a5c6d54f345f448437b83f5e432.json index d30d33b..13c0e8d 100644 --- a/labels/0xdc1f98682f4f8a5c6d54f345f448437b83f5e432.json +++ b/labels/0xdc1f98682f4f8a5c6d54f345f448437b83f5e432.json @@ -1,4 +1,5 @@ { + "address": "0xdc1f98682f4f8a5c6d54f345f448437b83f5e432", "labels": [ { "type": "info", "value": "Blockchain at Colombia" }, { "type": "info", "value": "University" }, diff --git a/labels/0xe74b28c2eae8679e3ccc3a94d5d0de83ccb84705.json b/labels/0xe74b28c2eae8679e3ccc3a94d5d0de83ccb84705.json index cb2bc1f..209822b 100644 --- a/labels/0xe74b28c2eae8679e3ccc3a94d5d0de83ccb84705.json +++ b/labels/0xe74b28c2eae8679e3ccc3a94d5d0de83ccb84705.json @@ -1,4 +1,5 @@ { + "address": "0xe74b28c2eae8679e3ccc3a94d5d0de83ccb84705", "labels": [ { "type": "danger", diff --git a/labels/0xea6c3db2e7fca00ea9d7211a03e83f568fc13bf7.json b/labels/0xea6c3db2e7fca00ea9d7211a03e83f568fc13bf7.json index a94f41c..69ce71a 100644 --- a/labels/0xea6c3db2e7fca00ea9d7211a03e83f568fc13bf7.json +++ b/labels/0xea6c3db2e7fca00ea9d7211a03e83f568fc13bf7.json @@ -1,4 +1,5 @@ { + "address": "0xea6c3db2e7fca00ea9d7211a03e83f568fc13bf7", "labels": [ { "type": "info", "value": "Polychain Capital" }, { "type": "info", "value": "VCs" }, diff --git a/schemas/label.json b/schemas/label.json index 5528c5c..ef00131 100644 --- a/schemas/label.json +++ b/schemas/label.json @@ -5,6 +5,11 @@ "title": "LlamaFolio Label Schema", "required": ["labels", "links"], "properties": { + "address:": { + "type": "string", + "default": " ", + "example": "0x0000000000000000000000000000000000000000" + }, "labels": { "type": "array", "default": [],