Skip to content
This repository has been archived by the owner on Aug 12, 2023. It is now read-only.

Commit

Permalink
Improve metadata in app definitions (#452)
Browse files Browse the repository at this point in the history
* Improve metadata in app definitions

* Fix tests
  • Loading branch information
cbovis authored Aug 23, 2020
1 parent ea792f3 commit 563448d
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 18 deletions.
3 changes: 2 additions & 1 deletion src/apps/definitions/0x-api.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"id": "052b4862-2142-4532-bdc0-416814b0a5fe",
"name": "0x API",
"logoUrl": "https://resources.0xtracker.com/logos/0x.png",
"description": "Built by the 0x core team – 0x API makes accessing DEX liquidity easy through the use of smart order routing which aggregates liquidity from 0x Mesh, Kyber, Uniswap, and more.",
"logo": "0x-api.png",
"urlSlug": "0x-api",
"websiteUrl": "https://0x.org/api",
"mappings": [
Expand Down
3 changes: 2 additions & 1 deletion src/apps/definitions/1inch-exchange.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"id": "8fc6beb5-3019-45f7-a55a-9a4c6b4b6513",
"name": "1inch Exchange",
"logoUrl": "https://resources.0xtracker.com/logos/1inch-exchange.png",
"description": "1inch Exchange is a popular DEX aggregator which sources liquidity from 0x protocol in addition to relaying limit orders.",
"logo": "1inch-exchange.png",
"urlSlug": "1inch-exchange",
"websiteUrl": "https://1inch.exchange",
"mappings": [
Expand Down
3 changes: 2 additions & 1 deletion src/apps/definitions/defi-saver.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"id": "b986d2ba-77bf-420b-99e3-28e592d476e2",
"name": "DeFi Saver",
"logoUrl": "https://resources.0xtracker.com/logos/defi-saver.png",
"description": "DeFi Saver is a crypto-portfolio manager which sources liquidity from the 0x ecosystem.",
"logo": "defi-saver.png",
"urlSlug": "defi-saver",
"websiteUrl": "https://defisaver.com/",
"mappings": [
Expand Down
3 changes: 2 additions & 1 deletion src/apps/definitions/matcha.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"id": "5067df8b-f9cd-4a34-aee1-38d607100145",
"name": "Matcha",
"logoUrl": "https://resources.0xtracker.com/logos/matcha.png",
"description": "Built by the 0x core team – Matcha is a DEX aggregator built on top of 0x API which allows users to easily swap tokens and place limit orders.",
"logo": "matcha.png",
"urlSlug": "matcha",
"websiteUrl": "https://matcha.xyz",
"mappings": [
Expand Down
3 changes: 2 additions & 1 deletion src/apps/definitions/paraswap.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"id": "4c3854b7-95c3-4714-83ab-a8ed53d2967e",
"name": "Paraswap",
"logoUrl": "https://resources.0xtracker.com/logos/paraswap.png",
"description": "Paraswap is a DEX aggregator which sources liquidity from various DEX protocols (including 0x) to offer users better prices.",
"logo": "paraswap.png",
"urlSlug": "paraswap",
"websiteUrl": "https://paraswap.io",
"mappings": [
Expand Down
Binary file added src/apps/logos/0x-api.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/apps/logos/1inch-exchange.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/apps/logos/defi-saver.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/apps/logos/matcha.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/apps/logos/paraswap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions src/apps/sync-app-definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ const transformMappings = mappings =>
const createApp = async definition => {
const App = getModel('App');
const app = {
..._.omit(definition, 'id', 'mappings'),
..._.omit(definition, 'id', 'mappings', 'logo'),
_id: definition.id,
logoUrl: `https://cdn.staticaly.com/gh/0xTracker/0x-tracker-worker/master/src/apps/logos/${definition.logo}`,
mappings: transformMappings(definition.mappings),
};

Expand All @@ -53,7 +54,10 @@ const compareMappings = (currentMappings, definitionMappings) => {
};

const updateApp = async (app, definition) => {
const metadata = _.omit(definition, 'id', 'mappings');
const metadata = {
..._.omit(definition, 'id', 'mappings', 'logo'),
logoUrl: `https://cdn.staticaly.com/gh/0xTracker/0x-tracker-worker/master/src/apps/logos/${definition.logo}`,
};

Object.keys(metadata).forEach(metadataKey => {
app.set(metadataKey, metadata[metadataKey]);
Expand Down
45 changes: 35 additions & 10 deletions src/apps/sync-app-definitions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ describe('apps/syncAppDefinitions', () => {
expect(matcha).toMatchObject({
_id: '5067df8b-f9cd-4a34-aee1-38d607100145',
categories: ['dex-aggregator', 'exchange'],
logoUrl: 'https://resources.0xtracker.com/logos/matcha.png',
logoUrl:
'https://cdn.staticaly.com/gh/0xTracker/0x-tracker-worker/master/src/apps/logos/matcha.png',
mappings: [
{
type: 0,
Expand All @@ -60,7 +61,9 @@ describe('apps/syncAppDefinitions', () => {
{
id: '5067df8b-f9cd-4a34-aee1-38d607100145',
name: 'Matcha',
logoUrl: 'https://resources.0xtracker.com/logos/matcha.png',
description:
'Built by the 0x core team – Matcha is a DEX aggregator built on top of 0x API which allows users to easily swap tokens and place limit orders.',
logo: 'matcha.png',
urlSlug: 'matcha',
websiteUrl: 'https://matcha.xyz',
mappings: [
Expand All @@ -80,7 +83,10 @@ describe('apps/syncAppDefinitions', () => {
await getModel('App').create({
_id: '5067df8b-f9cd-4a34-aee1-38d607100145',
categories: ['asset-swapper'],
logoUrl: 'https://resources.0xtracker.com/logos/matcha-xyz.png',
description:
'Built by the 0x core team – Matcha is a DEX aggregator built on top of 0x API which allows users to easily swap tokens and place limit orders.',
logoUrl:
'https://cdn.staticaly.com/gh/0xTracker/0x-tracker-worker/master/src/apps/logos/matcha-xyz.png',
mappings: [
{
type: 1,
Expand All @@ -105,7 +111,10 @@ describe('apps/syncAppDefinitions', () => {
expect(matcha).toMatchObject({
_id: '5067df8b-f9cd-4a34-aee1-38d607100145',
categories: ['dex-aggregator', 'exchange'],
logoUrl: 'https://resources.0xtracker.com/logos/matcha.png',
description:
'Built by the 0x core team – Matcha is a DEX aggregator built on top of 0x API which allows users to easily swap tokens and place limit orders.',
logoUrl:
'https://cdn.staticaly.com/gh/0xTracker/0x-tracker-worker/master/src/apps/logos/matcha.png',
mappings: [
{
type: 1,
Expand All @@ -127,7 +136,9 @@ describe('apps/syncAppDefinitions', () => {
{
id: '5067df8b-f9cd-4a34-aee1-38d607100145',
name: 'Matcha',
logoUrl: 'https://resources.0xtracker.com/logos/matcha.png',
description:
'Built by the 0x core team – Matcha is a DEX aggregator built on top of 0x API which allows users to easily swap tokens and place limit orders.',
logo: 'matcha.png',
urlSlug: 'matcha',
websiteUrl: 'https://matcha.xyz',
mappings: [
Expand All @@ -147,7 +158,10 @@ describe('apps/syncAppDefinitions', () => {
await getModel('App').create({
_id: '5067df8b-f9cd-4a34-aee1-38d607100145',
categories: ['dex-aggregator', 'exchange'],
logoUrl: 'https://resources.0xtracker.com/logos/matcha.png',
description:
'Built by the 0x core team – Matcha is a DEX aggregator built on top of 0x API which allows users to easily swap tokens and place limit orders.',
logoUrl:
'https://cdn.staticaly.com/gh/0xTracker/0x-tracker-worker/master/src/apps/logos/matcha.png',
mappings: [
{
type: 1,
Expand All @@ -172,7 +186,10 @@ describe('apps/syncAppDefinitions', () => {
expect(matcha).toMatchObject({
_id: '5067df8b-f9cd-4a34-aee1-38d607100145',
categories: ['dex-aggregator', 'exchange'],
logoUrl: 'https://resources.0xtracker.com/logos/matcha.png',
description:
'Built by the 0x core team – Matcha is a DEX aggregator built on top of 0x API which allows users to easily swap tokens and place limit orders.',
logoUrl:
'https://cdn.staticaly.com/gh/0xTracker/0x-tracker-worker/master/src/apps/logos/matcha.png',
mappings: [
{
type: 1,
Expand All @@ -194,7 +211,9 @@ describe('apps/syncAppDefinitions', () => {
{
id: '5067df8b-f9cd-4a34-aee1-38d607100145',
name: 'Matcha',
logoUrl: 'https://resources.0xtracker.com/logos/matcha.png',
description:
'Built by the 0x core team – Matcha is a DEX aggregator built on top of 0x API which allows users to easily swap tokens and place limit orders.',
logo: 'matcha.png',
urlSlug: 'matcha',
websiteUrl: 'https://matcha.xyz',
mappings: [
Expand All @@ -214,7 +233,10 @@ describe('apps/syncAppDefinitions', () => {
await getModel('App').create({
_id: '5067df8b-f9cd-4a34-aee1-38d607100145',
categories: ['dex-aggregator', 'exchange'],
logoUrl: 'https://resources.0xtracker.com/logos/matcha.png',
description:
'Built by the 0x core team – Matcha is a DEX aggregator built on top of 0x API which allows users to easily swap tokens and place limit orders.',
logoUrl:
'https://cdn.staticaly.com/gh/0xTracker/0x-tracker-worker/master/src/apps/logos/matcha.png',
mappings: [
{
type: 1,
Expand All @@ -239,7 +261,10 @@ describe('apps/syncAppDefinitions', () => {
expect(matcha).toMatchObject({
_id: '5067df8b-f9cd-4a34-aee1-38d607100145',
categories: ['dex-aggregator', 'exchange'],
logoUrl: 'https://resources.0xtracker.com/logos/matcha.png',
description:
'Built by the 0x core team – Matcha is a DEX aggregator built on top of 0x API which allows users to easily swap tokens and place limit orders.',
logoUrl:
'https://cdn.staticaly.com/gh/0xTracker/0x-tracker-worker/master/src/apps/logos/matcha.png',
mappings: [
{
type: 1,
Expand Down
3 changes: 2 additions & 1 deletion src/apps/validate-app-definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ const schema = Joi.object({
)
.unique()
.required(),
description: Joi.string().required(),
id: Joi.string()
.uuid({ version: ['uuidv4'] })
.id()
.required(),
logoUrl: Joi.string().uri({ scheme: 'https' }),
logo: Joi.string().required(),
mappings: Joi.array()
.items(
Joi.object({
Expand Down
1 change: 1 addition & 0 deletions src/model/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const mongoose = require('mongoose');
const schema = mongoose.Schema({
_id: { required: true, type: String },
categories: [{ required: true, type: String }],
description: { required: true, type: String },
logoUrl: { required: true, type: String },
mappings: [
{
Expand Down

0 comments on commit 563448d

Please sign in to comment.