Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix breadcrumbs url #160

Merged
merged 8 commits into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 86 additions & 12 deletions packages/api/src/dataFeedsRouter.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,6 @@
"deviationPercentage": 1.0,
"maxSecsBetweenUpdates": 86400,
"minSecsBetweenUpdates": 3600
},
"Price-BTC/USD-6": {
"label": "$",
"deviationPercentage": 1.0,
"maxSecsBetweenUpdates": 86400,
"minSecsBetweenUpdates": 3600
},
"Price-ETH/USD-6": {
"label": "$",
"deviationPercentage": 1.0,
"maxSecsBetweenUpdates": 86400,
"minSecsBetweenUpdates": 3600
}
}
},
Expand Down Expand Up @@ -345,6 +333,44 @@
}
}
},
"cronos": {
"name": "Cronos",
"networks": {
"cronos.testnet": {
"address": "0xeD074DA2A76FD2Ca90C1508930b4FB4420e413B0",
"blockExplorer": "https://cronos.org/explorer/testnet3/address/{address}/read-contract",
"color": "#6600ff",
"name": "Cronos Testnet",
"pollingPeriod": 300000,
"feeds": {
"Price-BTC/USD-6": {
"label": "$",
"deviationPercentage": 1.0,
"maxSecsBetweenUpdates": 3600,
"minSecsBetweenUpdates": 900
},
"Price-CRO/USDT-6": {
"label": "₮",
"deviationPercentage": 1.0,
"maxSecsBetweenUpdates": 3600,
"minSecsBetweenUpdates": 900
},
"Price-ETH/USD-6": {
"label": "$",
"deviationPercentage": 1.0,
"maxSecsBetweenUpdates": 3600,
"minSecsBetweenUpdates": 900
},
"Price-USDT/USD-6": {
"label": "$",
"deviationPercentage": 0.1,
"maxSecsBetweenUpdates": 86400,
"minSecsBetweenUpdates": 900
}
}
}
}
},
"ethereum": {
"name": "Ethereum",
"networks": {
Expand Down Expand Up @@ -449,6 +475,24 @@
"name": "KCC Testnet",
"pollingPeriod": 15000,
"feeds": {
"Price-DAI/USD-6": {
"label": "$",
"deviationPercentage": 0.1,
"maxSecsBetweenUpdates": 86400,
"minSecsBetweenUpdates": 900
},
"Price-USDC/USD-6": {
"label": "$",
"deviationPercentage": 0.1,
"maxSecsBetweenUpdates": 86400,
"minSecsBetweenUpdates": 900
},
"Price-USDT/USD-6": {
"label": "$",
"deviationPercentage": 0.1,
"maxSecsBetweenUpdates": 86400,
"minSecsBetweenUpdates": 900
},
"Price-KCS/USDT-6": {
"label": "₮",
"deviationPercentage": 0.5,
Expand Down Expand Up @@ -476,6 +520,24 @@
"name": "KCC Mainnet",
"pollingPeriod": 15000,
"feeds": {
"Price-DAI/USD-6": {
"label": "$",
"deviationPercentage": 0.1,
"maxSecsBetweenUpdates": 86400,
"minSecsBetweenUpdates": 900
},
"Price-USDC/USD-6": {
"label": "$",
"deviationPercentage": 0.1,
"maxSecsBetweenUpdates": 86400,
"minSecsBetweenUpdates": 900
},
"Price-USDT/USD-6": {
"label": "$",
"deviationPercentage": 0.1,
"maxSecsBetweenUpdates": 86400,
"minSecsBetweenUpdates": 900
},
"Price-KCS/USDT-6": {
"label": "₮",
"deviationPercentage": 0.5,
Expand Down Expand Up @@ -593,6 +655,12 @@
"name": "Polygon Mumbai",
"pollingPeriod": 15000,
"feeds": {
"Price-DAI/USD-6": {
"label": "$",
"deviationPercentage": 0.1,
"maxSecsBetweenUpdates": 86400,
"minSecsBetweenUpdates": 900
},
"Price-BTC/USD-6": {
"label": "$",
"deviationPercentage": 3.5,
Expand All @@ -614,6 +682,12 @@
"name": "Polygon Mainnet",
"pollingPeriod": 15000,
"feeds": {
"Price-DAI/USD-6": {
"label": "$",
"deviationPercentage": 0.1,
"maxSecsBetweenUpdates": 86400,
"minSecsBetweenUpdates": 900
},
"Price-BTC/USD-6": {
"label": "$",
"deviationPercentage": 1.0,
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/typeDefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const typeDefs = gql`
name: String!
network: String!
networkName: String
chain: String
lastResult: String
lastResultTimestamp: String
deviation: String!
Expand Down
5 changes: 4 additions & 1 deletion packages/api/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,18 @@ export type ExtendedFeedConfig = {
color: string
name: string
chain: string
network: string
pollingPeriod: number
feeds: FeedInfoRouterConfigMap
}

export type Chain = { name: string; networks: Record<string, FeedConfig> }

export type NetworkConfigMap = Record<string, FeedConfig>

export type RouterDataFeedsConfig = {
abi: string
chains: Record<string, { name: string; networks: Record<string, FeedConfig> }>
chains: Record<string, Chain>
}

export type FeedInfosWithoutAbis = Array<
Expand Down
37 changes: 17 additions & 20 deletions packages/api/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import {
ExtendedFeedConfig,
FeedConfig,
FeedInfosWithoutAbis,
FeedParamsConfig,
FeedParsedParams,
NetworkConfigMap,
RouterDataFeedsConfig,
NetworksConfig
NetworksConfig,
Chain,
FeedConfig
} from '../types'
// parse network name to fit schema
export function parseNetworkName (value) {
Expand Down Expand Up @@ -85,24 +86,20 @@ export function normalizeConfig (
const chains: Array<{ networks: NetworkConfigMap }> = Object.values(
config.chains
)

// Extracts networks with its key label from chains object
const networksConfigMap: Array<NetworkConfigMap> = chains.reduce(
(acc: Array<NetworkConfigMap>, network) => {
return [...acc, network.networks]
},
[]
)
// Network Config list deleting key label
const configs: Array<FeedConfig> = networksConfigMap.flatMap(
networkConfigMap =>
Object.values(networkConfigMap).map((feed, index) => ({
...feed,
chain: Object.keys(networkConfigMap)[index]
}))
)
const networksConfigMap = chains.flatMap((network: Chain) => {
const networks = Object.values(network.networks).map(
(feedConfig: FeedConfig, index) => ({
...feedConfig,
chain: network.name,
network: Object.keys(network.networks)[index]
})
)
return [...networks]
gabaldon marked this conversation as resolved.
Show resolved Hide resolved
})

// Parse Feed adding common config
const feeds: FeedInfosWithoutAbis = configs.reduce(
const feeds: FeedInfosWithoutAbis = networksConfigMap.reduce(
(acc: FeedInfosWithoutAbis, config: ExtendedFeedConfig) => {
const feedsArrayConfig: Array<FeedParamsConfig> = Object.values(
config.feeds
Expand All @@ -118,8 +115,8 @@ export function normalizeConfig (
)

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

Expand Down
Loading