From a764dfa789ba44e519371b4a1e4569db7f551fb7 Mon Sep 17 00:00:00 2001 From: fragosti Date: Thu, 18 Oct 2018 10:43:41 -0700 Subject: feat: MVP of passing in sraApiUrl, assetData and other settings from render method --- .../instant/src/data/asset_data_network_mapping.ts | 25 ++++++++++++++++++++++ packages/instant/src/data/asset_meta_data.ts | 15 ------------- packages/instant/src/data/asset_meta_data_map.ts | 14 ++++++++++++ 3 files changed, 39 insertions(+), 15 deletions(-) create mode 100644 packages/instant/src/data/asset_data_network_mapping.ts delete mode 100644 packages/instant/src/data/asset_meta_data.ts create mode 100644 packages/instant/src/data/asset_meta_data_map.ts (limited to 'packages/instant/src/data') diff --git a/packages/instant/src/data/asset_data_network_mapping.ts b/packages/instant/src/data/asset_data_network_mapping.ts new file mode 100644 index 000000000..9e14462f8 --- /dev/null +++ b/packages/instant/src/data/asset_data_network_mapping.ts @@ -0,0 +1,25 @@ +import * as _ from 'lodash'; + +import { Network } from '../types'; + +interface AssetDataByNetwork { + [Network.Kovan]?: string; + [Network.Mainnet]?: string; +} + +const sameAssetDatas: AssetDataByNetwork[] = [ + { + [Network.Mainnet]: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498', + [Network.Kovan]: '0xf47261b00000000000000000000000002002d3812f58e35f0ea1ffbf80a75a38c32175fa', + }, +]; + +export const assetDataNetworkMapping = { + getAssociatedAssetDataIfExists: (assetData: string, network: Network): string | undefined => { + const assetDataGroupIfExists = _.find(sameAssetDatas, value => value[network] === assetData); + if (_.isUndefined(assetDataGroupIfExists)) { + return; + } + return assetDataGroupIfExists[Network.Mainnet]; + }, +}; diff --git a/packages/instant/src/data/asset_meta_data.ts b/packages/instant/src/data/asset_meta_data.ts deleted file mode 100644 index e4d3e8f73..000000000 --- a/packages/instant/src/data/asset_meta_data.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { AssetProxyId, ObjectMap } from '@0xproject/types'; - -import { zrxAssetData } from '../constants'; -import { AssetMetaData } from '../types'; - -// Map from assetData string to AssetMetaData object -// TODO: import this from somewhere else. -export const assetMetaData: ObjectMap = { - [zrxAssetData]: { - assetProxyId: AssetProxyId.ERC20, - decimals: 18, - primaryColor: 'rgb(54, 50, 60)', - symbol: 'zrx', - }, -}; diff --git a/packages/instant/src/data/asset_meta_data_map.ts b/packages/instant/src/data/asset_meta_data_map.ts new file mode 100644 index 000000000..7d83865f1 --- /dev/null +++ b/packages/instant/src/data/asset_meta_data_map.ts @@ -0,0 +1,14 @@ +import { AssetProxyId, ObjectMap } from '@0xproject/types'; + +import { AssetMetaData } from '../types'; + +// Map from assetData string to AssetMetaData object +// TODO: import this from somewhere else. +export const assetMetaDataMap: ObjectMap = { + '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498': { + assetProxyId: AssetProxyId.ERC20, + decimals: 18, + primaryColor: 'rgb(54, 50, 60)', + symbol: 'zrx', + }, +}; -- cgit