Skip to content

Commit

Permalink
fix(api): change key and label values
Browse files Browse the repository at this point in the history
  • Loading branch information
gabaldon committed Mar 15, 2022
1 parent bd87878 commit 354190d
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 31 deletions.
14 changes: 1 addition & 13 deletions packages/api/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,6 @@ export type Context = {
export type ConfigByFullName = {
[key: string]: FeedInfo
}
export enum Chain {
Ethereum = 'ethereum',
Avalanche = 'avalanche',
Boba = 'boba',
Conflux = 'conflux',
Celo = 'celo',
Harmony = 'harmony',
Metis = 'metis',
Moonbeam = 'moonbeam',
Polygon = 'polygon',
KCC = 'KCC'
}

export enum Network {
EthereumMainnet = 'ethereum-mainnet',
Expand All @@ -65,7 +53,7 @@ export enum Network {
HarmonyTestnet = 'harmony-testnet',
MetisMainnet = 'metis-mainnet',
MetisRinkeby = 'metis-rinkeby',
MoonbaseAlpha = 'moonbase-alpha',
MoonbeamMoonbase = 'moonbeam-moonbase',
PolygonMainnet = 'polygon-mainnet',
PolygonGoerli = 'polygon-goerli',
KCCMainnet = 'KCC-mainnet',
Expand Down
21 changes: 12 additions & 9 deletions packages/api/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
export function parseNetworkName (value) {
return value
.toLowerCase()
.split(' ')
.split('.')
.join('-')
}
export function parseChainName (value) {
Expand Down Expand Up @@ -40,21 +40,24 @@ export function normalizeNetworkConfig (
const chains: Array<string> = Object.keys(config.chains)

// get list of networks

const networks: any = Object.values(config.chains).map(chain =>
Object.values(chain.networks).map(value => value.name)
Object.values(chain.networks).map((value, index) => {
return {
key: Object.keys(chain.networks)
[index].split('.')
.join('-')
.toLowerCase(),
label: value.name
}
})
)

// add chain to each of the networks

const networkConfig = networks.reduce((networks, network, index) => {
network.map(network => {
networks.push({
label: network
.split(' ')
.join('-')
.toLowerCase(),
key: network,
...network,
chain: chains[index]
})
})
Expand Down Expand Up @@ -113,7 +116,7 @@ export function normalizeConfig (

feedsArray.forEach(feed => {
const chain = parseChainName(config.chain)
const network = parseNetworkName(config.name)
const network = parseNetworkName(config.chain)
const name = parseDataName(feed.key)
const decimals = parseDataDecimals(feed.key)

Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/web3Middleware/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function getProvider (network: Network) {
[Network.HarmonyTestnet]: process.env.HARMONY_TESTNET_PROVIDER,
[Network.KCCTestnet]: process.env.KCC_TESTNET_PROVIDER,
[Network.KCCMainnet]: process.env.KCC_MAINNET_PROVIDER,
[Network.MoonbaseAlpha]: process.env.MOONBASE_ALPHA_PROVIDER,
[Network.MoonbeamMoonbase]: process.env.MOONBASE_ALPHA_PROVIDER,
[Network.PolygonMainnet]: process.env.POLYGON_MAINNET_PROVIDER,
[Network.PolygonGoerli]: process.env.POLYGON_GOERLI_PROVIDER,
[Network.AvalancheFuji]: process.env.AVALANCHE_FUJI_PROVIDER
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/components/DataFeeds.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default {
query: feeds,
variables() {
return {
network: this.network.label.toLowerCase(),
network: this.network.key.toLowerCase(),
}
},
pollInterval: 60000,
Expand Down
7 changes: 3 additions & 4 deletions packages/ui/components/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
</div>
<div
v-for="(option, index) in selected"
:key="option.label"
:key="option.key"
class="list-container"
>
<div class="title light-text bold">{{ option.key }}</div>
<div class="title light-text bold">{{ option.label }}</div>
<DataFeeds
:network="option"
:network-index="index"
Expand Down Expand Up @@ -58,15 +58,14 @@ export default {
},
options() {
if (this.networks) {
console.log(this.networks)
return generateSelectOptions(this.networks)
} else {
return null
}
},
selectedNetworks() {
const result = this.selected.map((option) => {
return option.key
return option.label
})
return result.join(', ').replace(/, ([^,]*)$/, ' and $1')
},
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/components/breadcrumbs/BreadCrumbs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="breadcrumbs container">
<nuxt-link
v-for="option in breadCumbsOptions"
:key="option.label"
:key="option.key"
:class="{ selected: option.selected }"
:to="localeRoute(option.path)"
class="breadcrumbs-link"
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/store/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const state = () => ({
selectedNetwork: [
{
label: 'ethereum-mainnet',
key: 'Ethereum Mainnet',
label: 'Ethereum Mainnet',
key: 'ethereum-mainnet',
chain: 'Ethereum',
},
],
Expand Down

0 comments on commit 354190d

Please sign in to comment.