diff --git a/packages/api/src/repository/Feed.ts b/packages/api/src/repository/Feed.ts index 767801b5..4a413763 100644 --- a/packages/api/src/repository/Feed.ts +++ b/packages/api/src/repository/Feed.ts @@ -49,8 +49,7 @@ export class FeedRepository { updateFeedAddress ( feedFullName: string, - address: string, - contractId: string + { address, contractId }: { address: string; contractId: string } ): FeedInfo { const hasSameFeedFullName = (feed: FeedInfo) => feed.feedFullName === feedFullName @@ -62,13 +61,14 @@ export class FeedRepository { const feed = this.sortedDataFeeds[sortedDataFeedIndex] feed.address = address feed.contractId = contractId - // Update address in dataFeedsByNetwork + // Update address in dataFeedsByNetwork cache const dataFeedsByNetworkIndex = this.dataFeedsByNetwork[ feed.network ].findIndex(hasSameFeedFullName) this.dataFeedsByNetwork[feed.network][ dataFeedsByNetworkIndex ].address = address + // Update contractId in dataFeedsByNetwork cache this.dataFeedsByNetwork[feed.network][ dataFeedsByNetworkIndex ].contractId = contractId diff --git a/packages/api/src/resolvers.ts b/packages/api/src/resolvers.ts index 1a266c07..e73adf9f 100644 --- a/packages/api/src/resolvers.ts +++ b/packages/api/src/resolvers.ts @@ -29,6 +29,7 @@ const resolvers = { ) }, lastResult: async (parent, _args, { resultRequestRepository }: Context) => { + // FIXME: add dataloader library to avoid overfetching return (await resultRequestRepository.getLastResult(parent.feedFullName)) ?.result }, @@ -37,6 +38,7 @@ const resolvers = { _args, { resultRequestRepository }: Context ) => { + // FIXME: add dataloader library to avoid overfetching return (await resultRequestRepository.getLastResult(parent.feedFullName)) ?.timestamp }, diff --git a/packages/api/src/utils/index.ts b/packages/api/src/utils/index.ts index 2413df51..a621da80 100644 --- a/packages/api/src/utils/index.ts +++ b/packages/api/src/utils/index.ts @@ -100,6 +100,10 @@ export function normalizeConfig ( return feeds } +export function isZeroAddress (address: string) { + return address === '0x0000000000000000000000000000000000000000' +} + export function sleep (ms) { return new Promise(resolve => setTimeout(resolve, ms)) } diff --git a/packages/api/src/web3Middleware/index.ts b/packages/api/src/web3Middleware/index.ts index 9a978620..96dff7bc 100644 --- a/packages/api/src/web3Middleware/index.ts +++ b/packages/api/src/web3Middleware/index.ts @@ -9,6 +9,7 @@ import { ObjectId, ContractInfo } from '../types' +import { isZeroAddress } from '../utils/index' import { getProvider } from './provider' export class Web3Middleware { @@ -29,26 +30,25 @@ export class Web3Middleware { } public async initializeAddresses (): Promise> { - const promises = this.dataFeeds.map(feed => this.updateAddress(feed)) + const promises = this.dataFeeds.map(feed => this.updateFeed(feed)) return await Promise.all(promises) } - async updateAddress (feedInfo: FeedInfo) { - const contractInfo = await this.getContractAddress(feedInfo) - console.log('contractInfo in updateAddress', contractInfo) + async updateFeed (feedInfo: FeedInfo) { + const contractInfo = await this.getContractInfo(feedInfo) const feed = this.repositories.feedRepository.get(feedInfo.feedFullName) if ( - feed && - contractInfo && - contractInfo.contractAddress && - contractInfo.contractAddress !== feed.address + contractInfo?.contractAddress && + contractInfo?.contractAddress !== feed?.address ) { return this.repositories.feedRepository.updateFeedAddress( feedInfo.feedFullName, - contractInfo.contractAddress, - contractInfo.contractId + { + address: contractInfo.contractAddress, + contractId: contractInfo.contractId + } ) } @@ -76,7 +76,7 @@ export class Web3Middleware { feeds.forEach(feed => { const feedInfo = feedDictionary[feed?.feedFullName]?.feedInfo if (feedInfo) { - this.updateAddress(feedInfo) + this.updateFeed(feedInfo) } }) @@ -97,7 +97,7 @@ export class Web3Middleware { this.intervals = [] } - async getContractAddress (feedInfo: FeedInfo): Promise { + async getContractInfo (feedInfo: FeedInfo): Promise { try { return await new Promise(async (resolve, reject) => { try { @@ -117,7 +117,6 @@ export class Web3Middleware { const contractIdentifier = await feedContract.methods .currencyPairId(feedInfo.id) .call() - console.log('contract Identifier!!!', feedInfo.id, contractIdentifier) const address = await feedContract.methods .getPriceFeed(contractIdentifier) .call() @@ -139,15 +138,13 @@ export class Web3Middleware { } async listenToDataFeed (feedInfo: FeedInfo) { - const contractInfo = await this.getContractAddress(feedInfo) + const contractInfo = await this.getContractInfo(feedInfo) const provider = getProvider(feedInfo.network) if (provider) { - console.log('contractInfo in listenToDataFeed', contractInfo) if ( contractInfo && contractInfo.contractAddress && - contractInfo.contractAddress !== - '0x0000000000000000000000000000000000000000' + !isZeroAddress(contractInfo.contractAddress) ) { try { const web3 = new this.Web3(provider) diff --git a/packages/api/test/validateFeedsConfig.spec.ts b/packages/api/test/validateFeedsConfig.spec.ts index 151126d4..577059d3 100644 --- a/packages/api/test/validateFeedsConfig.spec.ts +++ b/packages/api/test/validateFeedsConfig.spec.ts @@ -12,13 +12,62 @@ describe('validateDataFeedsConfig', () => { const expected = [ { address: '0x0000000000000000000000000000000000000000', + blockExplorer: 'https://testnet.snowtrace.io/address/{address}', + color: '#E84142', + contractId: '0x0000000000000000000000000000000000000000', + deviation: '1', + feedFullName: 'avalanche-fuji_avax-usd_6', + finality: '900000', + heartbeat: '3600000', + id: 'Price-AVAX/USD-6', + label: '$', + name: 'avax/usd', + network: 'avalanche-fuji', + pollingPeriod: 15000, + routerAddress: '0x99Af0CF37d1C6b9Bdfe33cc0A89C00D97D3c42F4' + }, + { + address: '0x0000000000000000000000000000000000000000', + blockExplorer: 'https://testnet.snowtrace.io/address/{address}', + color: '#E84142', + contractId: '0x0000000000000000000000000000000000000000', + deviation: '1', + feedFullName: 'avalanche-fuji_btc-usd_6', + finality: '900000', + heartbeat: '3600000', + id: 'Price-BTC/USD-6', + label: '$', + name: 'btc/usd', + network: 'avalanche-fuji', + pollingPeriod: 15000, + routerAddress: '0x99Af0CF37d1C6b9Bdfe33cc0A89C00D97D3c42F4' + }, + { + address: '0x0000000000000000000000000000000000000000', + blockExplorer: 'https://testnet.snowtrace.io/address/{address}', + color: '#E84142', + contractId: '0x0000000000000000000000000000000000000000', + deviation: '1', + feedFullName: 'avalanche-fuji_eth-usd_6', + finality: '900000', + heartbeat: '3600000', + id: 'Price-ETH/USD-6', + label: '$', + name: 'eth/usd', + network: 'avalanche-fuji', + pollingPeriod: 15000, + routerAddress: '0x99Af0CF37d1C6b9Bdfe33cc0A89C00D97D3c42F4' + }, + { + address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://blockexplorer.rinkeby.boba.network/address/{address}', color: '#1cd83d', deviation: '1', feedFullName: 'boba-rinkeby_boba-usdt_6', finality: '900000', - heartbeat: '3600000', + heartbeat: '86400000', id: 'Price-BOBA/USDT-6', label: '₮', name: 'boba/usdt', @@ -28,13 +77,14 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://blockexplorer.rinkeby.boba.network/address/{address}', color: '#1cd83d', deviation: '1', feedFullName: 'boba-rinkeby_btc-usd_6', finality: '900000', - heartbeat: '3600000', + heartbeat: '86400000', id: 'Price-BTC/USD-6', label: '$', name: 'btc/usd', @@ -44,13 +94,14 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://blockexplorer.rinkeby.boba.network/address/{address}', color: '#1cd83d', deviation: '1', feedFullName: 'boba-rinkeby_eth-usd_6', finality: '900000', - heartbeat: '3600000', + heartbeat: '86400000', id: 'Price-ETH/USD-6', label: '$', name: 'eth/usd', @@ -63,10 +114,28 @@ describe('validateDataFeedsConfig', () => { blockExplorer: 'https://blockexplorer.rinkeby.boba.network/address/{address}', color: '#1cd83d', + contractId: '0x0000000000000000000000000000000000000000', + deviation: '0.1', + feedFullName: 'boba-rinkeby_frax-usdt_6', + finality: '900000', + heartbeat: '86400000', + id: 'Price-FRAX/USDT-6', + label: '₮', + name: 'frax/usdt', + network: 'boba-rinkeby', + pollingPeriod: 15000, + routerAddress: '0x36928Aeedaaf7D85bcA39aDfB2A39ec529ce221a' + }, + { + address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', + blockExplorer: + 'https://blockexplorer.rinkeby.boba.network/address/{address}', + color: '#1cd83d', deviation: '1', feedFullName: 'boba-rinkeby_fxs-usdt_6', finality: '900000', - heartbeat: '3600000', + heartbeat: '86400000', id: 'Price-FXS/USDT-6', label: '₮', name: 'fxs/usdt', @@ -76,15 +145,16 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://blockexplorer.rinkeby.boba.network/address/{address}', color: '#1cd83d', deviation: '1', feedFullName: 'boba-rinkeby_omg-btc_9', finality: '900000', - heartbeat: '3600000', + heartbeat: '86400000', id: 'Price-OMG/BTC-9', - label: 'BTC', + label: '₿', name: 'omg/btc', network: 'boba-rinkeby', pollingPeriod: 15000, @@ -92,15 +162,16 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://blockexplorer.rinkeby.boba.network/address/{address}', color: '#1cd83d', deviation: '1', feedFullName: 'boba-rinkeby_omg-eth_9', finality: '900000', - heartbeat: '3600000', + heartbeat: '86400000', id: 'Price-OMG/ETH-9', - label: 'ETH', + label: 'Ξ', name: 'omg/eth', network: 'boba-rinkeby', pollingPeriod: 15000, @@ -108,13 +179,14 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://blockexplorer.rinkeby.boba.network/address/{address}', color: '#1cd83d', deviation: '1', feedFullName: 'boba-rinkeby_omg-usdt_6', finality: '900000', - heartbeat: '3600000', + heartbeat: '86400000', id: 'Price-OMG/USDT-6', label: '₮', name: 'omg/usdt', @@ -122,10 +194,45 @@ describe('validateDataFeedsConfig', () => { pollingPeriod: 15000, routerAddress: '0x36928Aeedaaf7D85bcA39aDfB2A39ec529ce221a' }, + { + address: '0x0000000000000000000000000000000000000000', + blockExplorer: + 'https://blockexplorer.rinkeby.boba.network/address/{address}', + color: '#1cd83d', + contractId: '0x0000000000000000000000000000000000000000', + deviation: '0.1', + feedFullName: 'boba-rinkeby_usdc-usd_6', + finality: '900000', + heartbeat: '86400000', + id: 'Price-USDC/USD-6', + label: '$', + name: 'usdc/usd', + network: 'boba-rinkeby', + pollingPeriod: 15000, + routerAddress: '0x36928Aeedaaf7D85bcA39aDfB2A39ec529ce221a' + }, + { + address: '0x0000000000000000000000000000000000000000', + blockExplorer: + 'https://blockexplorer.rinkeby.boba.network/address/{address}', + color: '#1cd83d', + contractId: '0x0000000000000000000000000000000000000000', + deviation: '0.1', + feedFullName: 'boba-rinkeby_usdt-usd_6', + finality: '900000', + heartbeat: '86400000', + id: 'Price-USDT/USD-6', + label: '$', + name: 'usdt/usd', + network: 'boba-rinkeby', + pollingPeriod: 15000, + routerAddress: '0x36928Aeedaaf7D85bcA39aDfB2A39ec529ce221a' + }, { address: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://blockexplorer.boba.network/address/{address}', color: '#007dff', + contractId: '0x0000000000000000000000000000000000000000', deviation: '1', feedFullName: 'boba-mainnet_boba-usdt_6', finality: '900000', @@ -141,6 +248,7 @@ describe('validateDataFeedsConfig', () => { address: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://blockexplorer.boba.network/address/{address}', color: '#007dff', + contractId: '0x0000000000000000000000000000000000000000', deviation: '1', feedFullName: 'boba-mainnet_btc-usd_6', finality: '900000', @@ -156,6 +264,7 @@ describe('validateDataFeedsConfig', () => { address: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://blockexplorer.boba.network/address/{address}', color: '#007dff', + contractId: '0x0000000000000000000000000000000000000000', deviation: '1', feedFullName: 'boba-mainnet_eth-usd_6', finality: '900000', @@ -169,6 +278,55 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + blockExplorer: 'https://blockexplorer.boba.network/address/{address}', + color: '#007dff', + contractId: '0x0000000000000000000000000000000000000000', + deviation: '0.25', + feedFullName: 'boba-mainnet_frax-usdt_6', + finality: '900000', + heartbeat: '86400000', + id: 'Price-FRAX/USDT-6', + label: '₮', + name: 'frax/usdt', + network: 'boba-mainnet', + pollingPeriod: 15000, + routerAddress: '0x93f61D0D5F623144e7C390415B70102A9Cc90bA5' + }, + { + address: '0x0000000000000000000000000000000000000000', + blockExplorer: 'https://blockexplorer.boba.network/address/{address}', + color: '#007dff', + contractId: '0x0000000000000000000000000000000000000000', + deviation: '0.25', + feedFullName: 'boba-mainnet_usdc-usd_6', + finality: '900000', + heartbeat: '86400000', + id: 'Price-USDC/USD-6', + label: '$', + name: 'usdc/usd', + network: 'boba-mainnet', + pollingPeriod: 15000, + routerAddress: '0x93f61D0D5F623144e7C390415B70102A9Cc90bA5' + }, + { + address: '0x0000000000000000000000000000000000000000', + blockExplorer: 'https://blockexplorer.boba.network/address/{address}', + color: '#007dff', + contractId: '0x0000000000000000000000000000000000000000', + deviation: '0.25', + feedFullName: 'boba-mainnet_usdt-usd_6', + finality: '900000', + heartbeat: '86400000', + id: 'Price-USDT/USD-6', + label: '$', + name: 'usdt/usd', + network: 'boba-mainnet', + pollingPeriod: 15000, + routerAddress: '0x93f61D0D5F623144e7C390415B70102A9Cc90bA5' + }, + { + address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://alfajores-blockscout.celo-testnet.org/address/{address}', color: '#1cd8d2', @@ -185,6 +343,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://alfajores-blockscout.celo-testnet.org/address/{address}', color: '#1cd8d2', @@ -201,6 +360,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://alfajores-blockscout.celo-testnet.org/address/{address}', color: '#1cd8d2', @@ -217,6 +377,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://alfajores-blockscout.celo-testnet.org/address/{address}', color: '#1cd8d2', @@ -233,6 +394,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://explorer.celo.org/address/{address}', color: '#ff8100', deviation: '1', @@ -248,6 +410,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://explorer.celo.org/address/{address}', color: '#ff8100', deviation: '1', @@ -263,6 +426,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://explorer.celo.org/address/{address}', color: '#ff8100', deviation: '3.5', @@ -278,6 +442,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://explorer.celo.org/address/{address}', color: '#ff8100', deviation: '3.5', @@ -293,6 +458,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://testnet.confluxscan.io/address/{address}', color: '#6600ff', deviation: '1', @@ -308,6 +474,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://testnet.confluxscan.io/address/{address}', color: '#6600ff', deviation: '1', @@ -323,6 +490,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://testnet.confluxscan.io/address/{address}', color: '#6600ff', deviation: '1', @@ -338,6 +506,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://confluxscan.io/address/{address}', color: '#ff0000', deviation: '1', @@ -353,6 +522,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://confluxscan.io/address/{address}', color: '#ff0000', deviation: '3.5', @@ -368,6 +538,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://confluxscan.io/address/{address}', color: '#ff0000', deviation: '3.5', @@ -383,6 +554,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://goerli.etherscan.io/address/{address}', color: '#ff5599', deviation: '1', @@ -398,6 +570,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://goerli.etherscan.io/address/{address}', color: '#ff5599', deviation: '1', @@ -413,6 +586,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://rinkeby.etherscan.io/address/{address}', color: '#ff5599', deviation: '1', @@ -428,6 +602,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://rinkeby.etherscan.io/address/{address}', color: '#ff5599', deviation: '1', @@ -443,6 +618,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://etherscan.io/address/{address}', color: '#ff5599', deviation: '3.5', @@ -458,6 +634,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://etherscan.io/address/{address}', color: '#ff5599', deviation: '3.5', @@ -473,6 +650,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://explorer.pops.one/address/{address}', color: '#f6006f', deviation: '1', @@ -488,6 +666,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://explorer.pops.one/address/{address}', color: '#f6006f', deviation: '1', @@ -503,6 +682,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://scan-testnet.kcc.network/address/{address}', color: '#ff0066', deviation: '0.5', @@ -518,6 +698,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://scan-testnet.kcc.network/address/{address}', color: '#ff0066', deviation: '0.5', @@ -533,6 +714,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://scan-testnet.kcc.network/address/{address}', color: '#ff0066', deviation: '0.5', @@ -548,6 +730,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://scan.kcc.io/address/{address}', color: '#ff0066', deviation: '0.5', @@ -563,6 +746,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://scan.kcc.io/address/{address}', color: '#ff0066', deviation: '0.5', @@ -578,6 +762,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://scan.kcc.io/address/{address}', color: '#ff0066', deviation: '0.5', @@ -593,6 +778,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://stardust-explorer.metis.io/address/{address}', color: '#ff6600', deviation: '1', @@ -608,6 +794,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://stardust-explorer.metis.io/address/{address}', color: '#ff6600', deviation: '1', @@ -623,6 +810,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://stardust-explorer.metis.io/address/{address}', color: '#ff6600', deviation: '1', @@ -638,6 +826,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://andromeda-explorer.metis.io/address/{address}', color: '#ff6600', deviation: '2', @@ -653,6 +842,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://mumbai.polygonscan.com/address/{address}', color: '#66ff00', deviation: '3.5', @@ -668,6 +858,7 @@ describe('validateDataFeedsConfig', () => { }, { address: '0x0000000000000000000000000000000000000000', + contractId: '0x0000000000000000000000000000000000000000', blockExplorer: 'https://mumbai.polygonscan.com/address/{address}', color: '#66ff00', deviation: '3.5', @@ -680,6 +871,38 @@ describe('validateDataFeedsConfig', () => { network: 'polygon-goerli', pollingPeriod: 15000, routerAddress: '0x6d5544ca5b35bf2e7a78ace4E7B8d191fe5C9FAb' + }, + { + address: '0x0000000000000000000000000000000000000000', + blockExplorer: 'https://polygonscan.com/address/{address}', + color: '#66ff00', + contractId: '0x0000000000000000000000000000000000000000', + deviation: '1', + feedFullName: 'polygon-mainnet_btc-usd_6', + finality: '900000', + heartbeat: '86400000', + id: 'Price-BTC/USD-6', + label: '$', + name: 'btc/usd', + network: 'polygon-mainnet', + pollingPeriod: 15000, + routerAddress: '0x3806311c7138ddF2bAF2C2093ff3633E5A73AbD4' + }, + { + address: '0x0000000000000000000000000000000000000000', + blockExplorer: 'https://polygonscan.com/address/{address}', + color: '#66ff00', + contractId: '0x0000000000000000000000000000000000000000', + deviation: '1', + feedFullName: 'polygon-mainnet_eth-usd_6', + finality: '900000', + heartbeat: '86400000', + id: 'Price-ETH/USD-6', + label: '$', + name: 'eth/usd', + network: 'polygon-mainnet', + pollingPeriod: 15000, + routerAddress: '0x3806311c7138ddF2bAF2C2093ff3633E5A73AbD4' } ] diff --git a/packages/ui/apollo/queries/feeds.gql b/packages/ui/apollo/queries/feeds.gql index 188aa9ce..a7eb0974 100644 --- a/packages/ui/apollo/queries/feeds.gql +++ b/packages/ui/apollo/queries/feeds.gql @@ -11,6 +11,7 @@ query feeds ($network: String!) { blockExplorer color heartbeat + finality } total } diff --git a/packages/ui/assets/styles/main.scss b/packages/ui/assets/styles/main.scss index 5a74a3ea..bfa555aa 100644 --- a/packages/ui/assets/styles/main.scss +++ b/packages/ui/assets/styles/main.scss @@ -184,7 +184,7 @@ --btn-secondary-border-color: #4AB6A1; //footer - --footer-bg: #26474B; + --footer-bg: #4ab6a02c; //sidebar --tab-gradient: linear-gradient(90deg, #2d2c39d3 95%, #4ab6a02c); diff --git a/packages/ui/assets/svg/avalanche.svg b/packages/ui/assets/svg/avalanche.svg index 3cd24ac6..a8f9fa48 100644 --- a/packages/ui/assets/svg/avalanche.svg +++ b/packages/ui/assets/svg/avalanche.svg @@ -1,4 +1,4 @@ - + diff --git a/packages/ui/assets/svg/avax.svg b/packages/ui/assets/svg/avax.svg index 3cd24ac6..a8f9fa48 100644 --- a/packages/ui/assets/svg/avax.svg +++ b/packages/ui/assets/svg/avax.svg @@ -1,4 +1,4 @@ - + diff --git a/packages/ui/assets/svg/boba.svg b/packages/ui/assets/svg/boba.svg index 6817a2c5..9582b917 100644 --- a/packages/ui/assets/svg/boba.svg +++ b/packages/ui/assets/svg/boba.svg @@ -1,4 +1,4 @@ - + diff --git a/packages/ui/assets/svg/btc.svg b/packages/ui/assets/svg/btc.svg index c7639fc9..de6c1166 100644 --- a/packages/ui/assets/svg/btc.svg +++ b/packages/ui/assets/svg/btc.svg @@ -1,3 +1,3 @@ - + diff --git a/packages/ui/assets/svg/celo.svg b/packages/ui/assets/svg/celo.svg index b475b7ee..c37a53ce 100644 --- a/packages/ui/assets/svg/celo.svg +++ b/packages/ui/assets/svg/celo.svg @@ -1,4 +1,4 @@ - + diff --git a/packages/ui/assets/svg/cfx.svg b/packages/ui/assets/svg/cfx.svg index 02d7011c..dea02f18 100644 --- a/packages/ui/assets/svg/cfx.svg +++ b/packages/ui/assets/svg/cfx.svg @@ -1,4 +1,4 @@ - + diff --git a/packages/ui/assets/svg/conflux.svg b/packages/ui/assets/svg/conflux.svg index 31716b2e..b1ac1120 100644 --- a/packages/ui/assets/svg/conflux.svg +++ b/packages/ui/assets/svg/conflux.svg @@ -1,4 +1,4 @@ - + diff --git a/packages/ui/assets/svg/eth.svg b/packages/ui/assets/svg/eth.svg index 4d48b18a..fa915ae9 100644 --- a/packages/ui/assets/svg/eth.svg +++ b/packages/ui/assets/svg/eth.svg @@ -1,4 +1,4 @@ - + diff --git a/packages/ui/assets/svg/ethereum.svg b/packages/ui/assets/svg/ethereum.svg index 20bbe82f..0f75a807 100644 --- a/packages/ui/assets/svg/ethereum.svg +++ b/packages/ui/assets/svg/ethereum.svg @@ -1,4 +1,4 @@ - + diff --git a/packages/ui/assets/svg/frax.svg b/packages/ui/assets/svg/frax.svg index 702c69b5..bc977e77 100644 --- a/packages/ui/assets/svg/frax.svg +++ b/packages/ui/assets/svg/frax.svg @@ -1,4 +1,4 @@ - + diff --git a/packages/ui/assets/svg/fxs.svg b/packages/ui/assets/svg/fxs.svg index 2b3e034e..edfecd31 100644 --- a/packages/ui/assets/svg/fxs.svg +++ b/packages/ui/assets/svg/fxs.svg @@ -1,4 +1,4 @@ - + diff --git a/packages/ui/assets/svg/github.svg b/packages/ui/assets/svg/github.svg index 0ffe697a..3910a188 100644 --- a/packages/ui/assets/svg/github.svg +++ b/packages/ui/assets/svg/github.svg @@ -1,3 +1,3 @@ - + diff --git a/packages/ui/assets/svg/harmony.svg b/packages/ui/assets/svg/harmony.svg index 42aaac05..d67330e9 100644 --- a/packages/ui/assets/svg/harmony.svg +++ b/packages/ui/assets/svg/harmony.svg @@ -1,4 +1,4 @@ - + diff --git a/packages/ui/assets/svg/kcc.svg b/packages/ui/assets/svg/kcc.svg index fdc70c6a..c6e686ce 100644 --- a/packages/ui/assets/svg/kcc.svg +++ b/packages/ui/assets/svg/kcc.svg @@ -1,4 +1,4 @@ - + diff --git a/packages/ui/assets/svg/kcs.svg b/packages/ui/assets/svg/kcs.svg index a1567dc2..7d6ec624 100644 --- a/packages/ui/assets/svg/kcs.svg +++ b/packages/ui/assets/svg/kcs.svg @@ -1,4 +1,4 @@ - + diff --git a/packages/ui/assets/svg/metis.svg b/packages/ui/assets/svg/metis.svg index 80022844..9103d2db 100644 --- a/packages/ui/assets/svg/metis.svg +++ b/packages/ui/assets/svg/metis.svg @@ -1,3 +1,3 @@ - + diff --git a/packages/ui/assets/svg/omg.svg b/packages/ui/assets/svg/omg.svg index 6e34efdc..77aaba7f 100644 --- a/packages/ui/assets/svg/omg.svg +++ b/packages/ui/assets/svg/omg.svg @@ -1,4 +1,4 @@ - + diff --git a/packages/ui/assets/svg/one.svg b/packages/ui/assets/svg/one.svg index 42aaac05..d67330e9 100644 --- a/packages/ui/assets/svg/one.svg +++ b/packages/ui/assets/svg/one.svg @@ -1,4 +1,4 @@ - + diff --git a/packages/ui/assets/svg/polygon.svg b/packages/ui/assets/svg/polygon.svg index 4ac8b3b1..80e506ad 100644 --- a/packages/ui/assets/svg/polygon.svg +++ b/packages/ui/assets/svg/polygon.svg @@ -1,3 +1,3 @@ - + diff --git a/packages/ui/assets/svg/usdc.svg b/packages/ui/assets/svg/usdc.svg index 0e2039e1..8c1a0773 100644 --- a/packages/ui/assets/svg/usdc.svg +++ b/packages/ui/assets/svg/usdc.svg @@ -1,4 +1,4 @@ - + diff --git a/packages/ui/assets/svg/usdt.svg b/packages/ui/assets/svg/usdt.svg index 705923cb..0b372bdd 100644 --- a/packages/ui/assets/svg/usdt.svg +++ b/packages/ui/assets/svg/usdt.svg @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/packages/ui/assets/svg/xau.svg b/packages/ui/assets/svg/xau.svg index 98024f19..95a79ed1 100644 --- a/packages/ui/assets/svg/xau.svg +++ b/packages/ui/assets/svg/xau.svg @@ -1,4 +1,4 @@ - + diff --git a/packages/ui/components/BreadCrumbs.vue b/packages/ui/components/BreadCrumbs.vue index 018bf85f..d571804e 100644 --- a/packages/ui/components/BreadCrumbs.vue +++ b/packages/ui/components/BreadCrumbs.vue @@ -46,11 +46,18 @@ export default { @media screen and (max-width: 1100px) { .breadcrumbs { &.container { - padding: 0 16px; + padding: 0 24px; } } } @media (max-width: 850px) { + .breadcrumbs { + &.container { + padding: 0 24px; + } + } +} +@media screen and (max-width: 300px) { .breadcrumbs { &.container { padding: 0 16px; diff --git a/packages/ui/components/DataFeedDetails.vue b/packages/ui/components/DataFeedDetails.vue index 3e873e43..a8896aff 100644 --- a/packages/ui/components/DataFeedDetails.vue +++ b/packages/ui/components/DataFeedDetails.vue @@ -8,7 +8,7 @@ :last-result-value="lastResultvalue" :data-label="feed.label" :name="feedName" - :heartbeat="heartbeat" + :time-to-update="maxTimeToResolve" :decimals="feedDecimals" @change-range="updateQuery" /> @@ -175,16 +175,21 @@ export default { }, heartbeat() { if (this.feed) { - return Number(this.feed.heartbeat) + Number(this.feed.finality) + return Number(this.feed.heartbeat) } else { - return '' + return 0 + } + }, + finality() { + if (this.feed) { + return Number(this.feed.finality) + } else { + return 0 } }, feedTimeToUpdate() { if (this.feed) { - return formatMilliseconds( - Number(this.feed.heartbeat) + Number(this.feed.finality) - ) + return formatMilliseconds(this.heartbeat + this.finality) } else { return '' } @@ -200,9 +205,7 @@ export default { } }, maxTimeToResolve() { - return this.feed - ? (Number(this.feed.heartbeat) + Number(this.feed.finality)).toString() - : '' + return this.heartbeat + this.finality }, numberOfPages() { return this.feed diff --git a/packages/ui/components/DataFeedStatus.vue b/packages/ui/components/DataFeedStatus.vue index b0f4077d..e4acc861 100644 --- a/packages/ui/components/DataFeedStatus.vue +++ b/packages/ui/components/DataFeedStatus.vue @@ -9,7 +9,7 @@ import { getDataFeedStatus } from '@/utils/getDataFeedStatus' export default { props: { - heartbeat: { + timeToUpdate: { type: Number, required: true, }, @@ -20,10 +20,12 @@ export default { }, computed: { statusColor() { - return getDataFeedStatus(this.heartbeat, this.lastResultTimestamp).color + return getDataFeedStatus(this.timeToUpdate, this.lastResultTimestamp) + .color }, statusLabel() { - return getDataFeedStatus(this.heartbeat, this.lastResultTimestamp).label + return getDataFeedStatus(this.timeToUpdate, this.lastResultTimestamp) + .label }, }, } diff --git a/packages/ui/components/DataFeeds.vue b/packages/ui/components/DataFeeds.vue index 30515adc..bfe5003e 100644 --- a/packages/ui/components/DataFeeds.vue +++ b/packages/ui/components/DataFeeds.vue @@ -6,7 +6,7 @@ :details-path="feed.detailsPath" :name="feed.name" :decimals="feed.decimals" - :heartbeat="feed.heartbeat" + :time-to-update="feed.timeToUpdate" :img="feed.img" :value="feed.value" :last-result-timestamp="feed.lastResultTimestamp" @@ -61,7 +61,6 @@ export default { return !!feed.lastResult }) .map((feed) => { - console.log(feed) return { detailsPath: { name: 'feeds-id', @@ -72,7 +71,7 @@ export default { value: feed.lastResult, lastResultTimestamp: feed.lastResultTimestamp || '0', label: feed.label, - heartbeat: feed.heartbeat, + timeToUpdate: Number(feed.heartbeat) + Number(feed.finality), img: { name: formatSvgName(feed.name), alt: feed.name, @@ -103,28 +102,36 @@ export default { display: grid; grid-gap: 16px; width: 100%; - grid-template: repeat(auto-fit, 80px) / repeat(auto-fit, 300px); + grid-template-rows: repeat(auto-fill, 80px); + grid-template-columns: repeat(3, minmax(300px, 1fr)); justify-content: flex-start; align-items: center; } -@media screen and (max-width: 600px) { +@media screen and (max-width: 1100px) { + .feeds-container { + grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); + } +} +@media screen and (max-width: 900px) { .feeds-container { + grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); padding: 0; - justify-content: center; } } -@media screen and (max-width: 300px) { +@media screen and (max-width: 600px) { .feeds-container { + grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); padding: 0; justify-content: center; - grid-template: none; - grid-template-columns: 1fr; } } -@media screen and (max-width: 900px) { +@media screen and (max-width: 300px) { .feeds-container { padding: 0; + justify-content: center; + grid-template-rows: repeat(auto-fill, 120px); + grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); } } diff --git a/packages/ui/components/FeedCard.vue b/packages/ui/components/FeedCard.vue index 0624a679..df3b4c2f 100644 --- a/packages/ui/components/FeedCard.vue +++ b/packages/ui/components/FeedCard.vue @@ -1,5 +1,5 @@
@@ -55,8 +55,8 @@ export default { type: String, required: true, }, - heartbeat: { - type: String, + timeToUpdate: { + type: Number, required: true, }, network: { @@ -73,13 +73,15 @@ export default { return formatNumber(parseFloat(this.value) / 10 ** this.decimals) }, statusColor() { - return getDataFeedStatus(this.heartbeat, this.lastResultTimestamp).color + return getDataFeedStatus(this.timeToUpdate, this.lastResultTimestamp) + .color }, dataFeedStatusKey() { - return getDataFeedStatus(this.heartbeat, this.lastResultTimestamp).key + return getDataFeedStatus(this.timeToUpdate, this.lastResultTimestamp).key }, dataFeedStatusLabel() { - return getDataFeedStatus(this.heartbeat, this.lastResultTimestamp).label + return getDataFeedStatus(this.timeToUpdate, this.lastResultTimestamp) + .label }, }, methods: { @@ -101,7 +103,7 @@ a { color: var(--value-color); } .card-container { - width: 300px; + width: 100%; height: max-content; background: var(--card-background); box-shadow: var(--card-box-shadow); diff --git a/packages/ui/components/Main.vue b/packages/ui/components/Main.vue index 11ec18c5..c6351492 100644 --- a/packages/ui/components/Main.vue +++ b/packages/ui/components/Main.vue @@ -75,7 +75,6 @@ export default { return result.join(', ').replace(/, ([^,]*)$/, ' and $1') }, }, - mounted() {}, methods: { updateOptions(index) { this.$store.commit('deleteEmptyNetwork', { index }) @@ -140,11 +139,19 @@ export default { justify-self: center; } } +@media screen and (max-width: 1100px) { + .list-container { + margin-right: 16px; + } +} @media (max-width: 850px) { + .list-container { + margin-right: 0; + } .main { grid-template-columns: 1fr; - padding: 0 16px; + padding: 0 24px; } .section-header { padding: 0 32px 32px 32px; @@ -158,9 +165,15 @@ export default { padding: 0 16px 16px 16px; } .list-container { + margin-right: 0; .pagination { margin-bottom: 48px; } } } +@media screen and (max-width: 300px) { + .main { + padding: 0 16px; + } +} diff --git a/packages/ui/components/NavBar.vue b/packages/ui/components/NavBar.vue index 57790099..3bad551b 100644 --- a/packages/ui/components/NavBar.vue +++ b/packages/ui/components/NavBar.vue @@ -1,21 +1,23 @@