diff --git a/README.md b/README.md index e3a32edaff..2da0609cee 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Ethereum Contract Icons [![CircleCI](https://circleci.com/gh/MetaMask/ethereum-contract-icons.svg?style=svg)](https://circleci.com/gh/MetaMask/ethereum-contract-icons) +# Ethereum Contract Metadata [![CircleCI](https://circleci.com/gh/MetaMask/ethereum-contract-icons.svg?style=svg)](https://circleci.com/gh/MetaMask/ethereum-contract-icons) -A mapping of checksummed ethereum addresses to images of those addresses' logos. +A mapping of checksummed ethereum addresses to metadata, like names, and images of those addresses' logos. All address keys follow the [EIP 55 address checksum format](https://github.com/ethereum/EIPs/issues/55). @@ -8,7 +8,7 @@ Submit PRs to add valid logos, and obviously valid logos will be merged. ## Usage -You can install from npm with `npm install ethereum-contract-icons` and use it in your code like this: +You can install from npm with `npm install eth-contract-metadata` and use it in your code like this: ```javascript const iconMap = require('ethereum-contract-icons') @@ -28,10 +28,19 @@ function imageElFor (address) { 1. Fork this repository. 2. Add your logo image in a web-safe format to the `images` folder. -3. Add an entry to the `icon-map.json` file with the specified address as the key, and the image file's name as the value. +3. Add an entry to the `contract-map.json` file with the specified address as the key, and the image file's name as the value. Criteria: - The icon should be small, but high resolution, ideally a vector/svg. - Do not add your entry to the end of the JSON map, messing with the trailing comma. Your pull request should only be an addition of lines, and any line removals should be deliberate deprecations of those logos. +A sample submission: +```json +{ + "0x6090A6e47849629b7245Dfa1Ca21D94cd15878Ef": { + "name": "ENS Registrar", + "logo": "ens.svg" + } +} +``` diff --git a/contract-map.json b/contract-map.json new file mode 100644 index 0000000000..93187dde4c --- /dev/null +++ b/contract-map.json @@ -0,0 +1,6 @@ +{ + "0x6090A6e47849629b7245Dfa1Ca21D94cd15878Ef": { + "logo": "ens.svg", + "name": "ENS Registrar" + } +} diff --git a/icon-map.json b/icon-map.json deleted file mode 100644 index 420e0e848b..0000000000 --- a/icon-map.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "0x6090A6e47849629b7245Dfa1Ca21D94cd15878Ef": "ens.svg" -} diff --git a/index.js b/index.js index 416928a69c..695e220423 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -module.exports = require('./icon-map.json') +module.exports = require('./contract-map.json') diff --git a/package.json b/package.json index 3ce59d75bc..d108fc27a8 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "ethereum-contract-icons", + "name": "eth-contract-metadata", "version": "1.0.0", "description": "A mapping of ethereum contract addresses to broadly accepted icons for those addresses.", "main": "index.js", diff --git a/test/index.js b/test/index.js index cd555bcc6f..623b47b1e5 100644 --- a/test/index.js +++ b/test/index.js @@ -1,27 +1,30 @@ const test = require('tape') -const iconMap = require('../') +const contractMap = require('../') const util = require('ethereumjs-util') const fs = require('fs') const path = require('path') test('the object is parsable', function (t) { - t.equal(typeof iconMap, 'object', 'is an object') + t.equal(typeof contractMap, 'object', 'is an object') t.end() }) test('the accounts are valid checksum addresses', function (t) { - Object.keys(iconMap).forEach(address => { + Object.keys(contractMap).forEach(address => { t.ok(util.isValidChecksumAddress(address), `Address should be valid: ${address}`) }) t.end() }) -test('value should correspond to a web image file', function (t) { - Object.keys(iconMap).forEach(address => { - const fileName = iconMap[address] - t.ok(fs.existsSync(path.join(__dirname, '..', 'images', fileName)), `file exists: ${fileName}`) +test('logos should correspond to an included web image file', function (t) { + Object.keys(contractMap).forEach(address => { + const contract = contractMap[address] + if ('logo' in contract) { + const fileName = contract.logo + t.ok(fs.existsSync(path.join(__dirname, '..', 'images', fileName)), `file exists: ${fileName}`) + } }) t.end()