diff --git a/packages/api/src/dataFeedsRouter.json b/packages/api/src/dataFeedsRouter.json index e658d8c2..49e3bf34 100644 --- a/packages/api/src/dataFeedsRouter.json +++ b/packages/api/src/dataFeedsRouter.json @@ -1,9 +1,5 @@ { "contracts": { - "legacy": { - "abi": "./src/abi/PriceFeedRouter.json", - "pollingPeriod": 120000 - }, "2.0": { "abi": "./src/abi/WitnetPriceFeeds.json", "address": "0x1111AbA2164AcdC6D291b08DfB374280035E1111", diff --git a/packages/api/src/index.ts b/packages/api/src/index.ts index 146d4875..585fad88 100644 --- a/packages/api/src/index.ts +++ b/packages/api/src/index.ts @@ -13,7 +13,7 @@ import { } from '../types' import { Web3Middleware } from './web3Middleware/index' import { normalizeNetworkConfig } from './utils/index' -import { fetchFeedsLegacy, fetchDataFeedsRouterConfig } from './readDataFeeds' +import { fetchDataFeedsRouterConfig } from './readDataFeeds' import { SvgCache } from './svgCache' import { NetworkRouter } from './web3Middleware/NetworkRouter' import { Configuration } from './web3Middleware/Configuration' @@ -71,23 +71,18 @@ class DataFeedsExplorer { await this.initializeConfiguration(this.svgCache) this.routers = await this.initializeNetworkRouters() - const legacyFeeds: Array = fetchFeedsLegacy( - this.configurationFile, - ) const v2Feeds: Array = await fetchFeedsV2(this.routers) this.repositories = { feedRepository: new FeedRepository(this.feedsState), resultRequestRepository: new ResultRequestRepository(db), } - this.repositories.feedRepository.setLegacyFeeds(legacyFeeds) this.repositories.feedRepository.setV2Feeds(v2Feeds) - const web3Middleware = new Web3Middleware( - this.configuration, - { repositories: this.repositories, Web3: Web3 }, - legacyFeeds, - ) + const web3Middleware = new Web3Middleware(this.configuration, { + repositories: this.repositories, + Web3: Web3, + }) web3Middleware.listen() diff --git a/packages/api/src/readDataFeeds.ts b/packages/api/src/readDataFeeds.ts index f883230e..74853d14 100644 --- a/packages/api/src/readDataFeeds.ts +++ b/packages/api/src/readDataFeeds.ts @@ -1,8 +1,5 @@ import axios from 'axios' -import path from 'path' -import fs from 'fs' -import { RouterDataFeedsConfig, FeedInfo, FeedInfoConfig } from '../types' -import { normalizeConfig } from './utils' +import { RouterDataFeedsConfig } from '../types' const CONFIG_URL = process.env.TEST_BRANCH ? `https://raw.github.com/witnet/data-feeds-explorer/${process.env.TEST_BRANCH}/packages/api/src/dataFeedsRouter.json` @@ -32,91 +29,3 @@ export async function fetchDataFeedsRouterConfig(): Promise { - const dataFeeds: Array> = - normalizeConfig(config) - - // Throw and error if config file is not valid - // validateDataFeeds(dataFeeds) - return dataFeeds.map((dataFeed) => ({ - ...dataFeed, - routerAbi: JSON.parse( - fs.readFileSync( - path.resolve( - process.env.DATA_FEED_ROUTER_ABI_PATH || config.contracts.legacy.abi, - ), - 'utf-8', - ), - ), - abi: JSON.parse( - fs.readFileSync( - path.resolve( - // TODO: should this abi be in the config file? - process.env.DATA_FEED_ABI_PATH || './src/abi/PriceFeed.json', - ), - 'utf-8', - ), - ), - })) -} - -// // Throw an error if a field is missing in the data feed config file -// function validateDataFeeds ( -// dataFeeds: Array> -// ) { -// const expectedFields = [ -// 'feedFullName', -// 'id', -// 'address', -// 'contractId', -// 'network', -// 'networkName', -// 'chain', -// 'name', -// 'label', -// 'pollingPeriod', -// 'color', -// 'blockExplorer', -// 'deviation', -// 'heartbeat', -// 'finality', -// 'isRouted' -// ] - -// const optionalFields = ['deviation', 'heartbeat', 'isRouted'] - -// dataFeeds.forEach((feedInfoConfig, index) => { -// expectedFields.forEach(field => { -// // Validate nested keys in a field -// field.split('.').reduce((acc, val) => { -// // Throw error if the key is not found or has a falsy value -// if (!(val in acc) || !acc[val]) { -// if (optionalFields.includes(val)) { -// return acc[val] -// } else { -// throw new Error( -// `Missing field ${field} in index ${index} in data feed config file` -// ) -// } -// } else { -// // Throw error if not validated new fields are added in the config file -// if (Object.keys(feedInfoConfig).length !== expectedFields.length) { -// throw new Error( -// `There are more fields in the feed config than expected` -// ) -// } -// return acc[val] -// } -// }, feedInfoConfig) -// }) -// }) -// } diff --git a/packages/api/src/repository/Feed.ts b/packages/api/src/repository/Feed.ts index d0d284f0..12f37988 100644 --- a/packages/api/src/repository/Feed.ts +++ b/packages/api/src/repository/Feed.ts @@ -59,24 +59,6 @@ export class FeedRepository { } } - updateFeedAddress( - feedFullName: string, - { address, contractId }: { address: string; contractId: string }, - ): FeedInfo { - const hasSameFeedFullName = (feed: FeedInfo) => - feed.feedFullName === feedFullName - - const legacyFeeds = this.feedsState.getLegacyFeeds() - const index = legacyFeeds.findIndex(hasSameFeedFullName) - const updatedFeed = { ...legacyFeeds[index], address, contractId } - legacyFeeds[index] = updatedFeed - this.feedsState.setLegacyFeeds(legacyFeeds) - - this.initialize() - - return updatedFeed - } - refreshV2NetworkFeeds(network: string, feedInfos: Array) { const v2Feeds = this.feedsState.getV2Feeds() @@ -89,11 +71,6 @@ export class FeedRepository { this.initialize() } - setLegacyFeeds(legacyFeeds: Array) { - this.feedsState.setLegacyFeeds(legacyFeeds) - this.initialize() - } - setV2Feeds(v2Feeds: Array) { this.feedsState.setV2Feeds(v2Feeds) this.initialize() diff --git a/packages/api/src/repository/feedState.ts b/packages/api/src/repository/feedState.ts index af3ec8eb..faad4ce1 100644 --- a/packages/api/src/repository/feedState.ts +++ b/packages/api/src/repository/feedState.ts @@ -1,11 +1,9 @@ import { FeedInfo } from '../../types' export class FeedsState { - private legacyFeeds: Array private v2Feeds: Array constructor() { - this.legacyFeeds = [] this.v2Feeds = [] } @@ -13,19 +11,11 @@ export class FeedsState { this.v2Feeds = v2Feeds } - setLegacyFeeds(legacyFeeds: Array) { - this.legacyFeeds = legacyFeeds - } - getV2Feeds(): Array { return this.v2Feeds } - getLegacyFeeds(): Array { - return this.legacyFeeds - } - listFeeds(): Array { - return [...this.legacyFeeds, ...this.v2Feeds] + return [...this.v2Feeds] } } diff --git a/packages/api/src/utils/index.ts b/packages/api/src/utils/index.ts index b7ca52c7..c3fe62a9 100644 --- a/packages/api/src/utils/index.ts +++ b/packages/api/src/utils/index.ts @@ -1,28 +1,5 @@ -import { - ExtendedFeedConfig, - FeedInfosWithoutAbis, - FeedParamsConfig, - FeedParsedParams, - NetworkConfigMap, - RouterDataFeedsConfig, - NetworksConfig, - Chain, - FeedConfig, -} from '../../types' -// parse network name to fit schema -export function parseNetworkName(value) { - return value.toLowerCase().split('.').join('-') -} -export function parseChainName(value) { - return value.toLowerCase().split('.')[0] -} -// parse data feed name to fit schema -export function parseDataName(value) { - return value.split('-')[1].toLowerCase() -} -export function parseDataDecimals(value) { - return value.split('-')[2] -} +import { RouterDataFeedsConfig, NetworksConfig } from '../../types' + // parse data feed full name to fit schema export function createFeedFullName(network, name, decimals) { return `${network}_${name.split('/').join('-')}_${decimals}`.toLowerCase() @@ -73,97 +50,6 @@ export function normalizeNetworkConfig( ] } -// normalize config to fit schema - -export function normalizeConfig( - config: RouterDataFeedsConfig, -): FeedInfosWithoutAbis { - // Chain list - const chains: Array<{ networks: NetworkConfigMap }> = Object.values( - config.chains, - ) - // Network Config list deleting key label - const networksConfigMap = chains.flatMap((network: Chain) => { - return Object.values(network.networks) - .map((chainConfig: FeedConfig, index) => ({ - ...chainConfig, - chain: network.name, - hide: !!network.hide || chainConfig.hide, - network: Object.keys(network.networks)[index], - })) - .filter((network) => !network.version || network.version === 'legacy') - }) - - // Parse Feed adding common config - const feeds: FeedInfosWithoutAbis = networksConfigMap.reduce( - (acc: FeedInfosWithoutAbis, config: ExtendedFeedConfig) => { - const feedsArrayConfig: Array = config.feeds - ? Object.values(config.feeds) - : [] - // Extracts feeds deleting key label - const feedsArray: Array = feedsArrayConfig.map( - (feed, index) => { - return { - ...feed, - key: Object.keys(config.feeds)[index], - } as FeedParsedParams - }, - ) - - feedsArray.forEach((feed) => { - const chain = config.chain - const network = parseNetworkName(config.network) - const name = parseDataName(feed.key) - const decimals = parseDataDecimals(feed.key) - if (!config.hide) { - acc.push({ - feedFullName: createFeedFullName(network, name, decimals), - isRouted: !!feed.isRouted, - id: feed.key, - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: config.address, - network, - networkName: config.name, - chain, - name, - label: feed.label, - pollingPeriod: config.pollingPeriod, - color: config.color, - blockExplorer: config.blockExplorer, - deviation: feed.deviationPercentage?.toString() || null, - heartbeat: feed.maxSecsBetweenUpdates - ? `${feed.maxSecsBetweenUpdates}000` - : null, - finality: '900000', - }) - } - }) - - return acc - }, - [], - ) - - return feeds -} - -export function isZeroAddress(address: string) { - return address === '0x0000000000000000000000000000000000000000' || !address -} - -export function isZeroHash(hash: string) { - return ( - hash === - '0x0000000000000000000000000000000000000000000000000000000000000000' || - !hash - ) -} - -export function sleep(ms) { - return new Promise((resolve) => setTimeout(resolve, ms)) -} - export function removeRepeatedElements(items: Array): Array { return [...new Set(items)] } diff --git a/packages/api/src/web3Middleware/Configuration.ts b/packages/api/src/web3Middleware/Configuration.ts index 6692968e..431fccf5 100644 --- a/packages/api/src/web3Middleware/Configuration.ts +++ b/packages/api/src/web3Middleware/Configuration.ts @@ -1,6 +1,5 @@ import { FeedParamsConfig, - LegacyRouterDataFeedsConfig, Network, NetworksConfig, RouterDataFeedsConfig, @@ -66,32 +65,6 @@ export class Configuration { ) } - public getLegacyConfigurationFile(): LegacyRouterDataFeedsConfig { - const abi = this.configurationFile.contracts.legacy.abi - const chains = Object.entries(this.configurationFile.chains).reduce( - (acc, [chainKey, chain]) => { - const networks = Object.entries(chain.networks).reduce( - (accNetworks, [networkKey, network]) => { - // add the network entry if it's legacy - return !network.version || network.version === 'legacy' - ? { ...accNetworks, [networkKey]: network } - : accNetworks - }, - {}, - ) - return Object.keys(networks).length > 0 - ? { ...acc, [chainKey]: { ...chain, networks } } - : acc - }, - {}, - ) - - return { - chains, - abi, - } - } - public getFeedConfiguration( priceFeedName: string, network: Network, diff --git a/packages/api/src/web3Middleware/NetworkRouter.ts b/packages/api/src/web3Middleware/NetworkRouter.ts index faaad7af..bb313163 100644 --- a/packages/api/src/web3Middleware/NetworkRouter.ts +++ b/packages/api/src/web3Middleware/NetworkRouter.ts @@ -60,6 +60,7 @@ export class NetworkRouter { private configuration: Configuration private provider: string private lastSupportedFeedsID = '' + private interval constructor( configuration: Configuration, @@ -88,7 +89,7 @@ export class NetworkRouter { // Periodically fetch the price feed router contract and store it in mongodb public listen() { - setInterval(async () => { + this.interval = setInterval(async () => { const snapshot = await this.getSnapshot() const insertPromises = snapshot.feeds .filter((feed) => isFeedWithPrice(feed) && feed.timestamp !== '0') @@ -114,6 +115,10 @@ export class NetworkRouter { }, this.pollingPeriod) } + public stop() { + clearInterval(this.interval) + } + async getSnapshot(): Promise { const supportedFeeds = await this.getSupportedFeeds() diff --git a/packages/api/src/web3Middleware/index.ts b/packages/api/src/web3Middleware/index.ts index ff1f6b6d..4e7f766a 100644 --- a/packages/api/src/web3Middleware/index.ts +++ b/packages/api/src/web3Middleware/index.ts @@ -1,295 +1,40 @@ -import { ObjectId } from 'mongodb' import Web3 from 'web3' -import { toHex } from 'web3-utils' -import { - Contracts, - ContractsState, - FeedInfo, - Repositories, - ContractInfo, -} from '../../types' -import { isZeroAddress } from '../utils/index' -import { getProvider } from './provider' +import { Repositories } from '../../types' import { NetworkRouter } from './NetworkRouter' import { Configuration } from './Configuration' export class Web3Middleware { public repositories: Repositories private Web3: typeof Web3 - public legacyDataFeeds: Array - public routerContractByNetwork: Record = {} - public contractIdByFeedId: Record = {} - // feedFullname -> address - public currentFeedAddresses: Record = {} - public networkRouters: Array + public networkRouters: Array = [] public configuration: Configuration - private intervals: Array> = [] - constructor( configuration: Configuration, dependencies: { Web3: typeof Web3; repositories: Repositories }, - legacyDataFeeds: Array, ) { this.repositories = dependencies.repositories - this.legacyDataFeeds = legacyDataFeeds this.Web3 = dependencies.Web3 this.configuration = configuration - } - - public listen() { - this.listenLegacyPriceRouter() - this.listenWitnetPriceFeeds() - } - public async listenWitnetPriceFeeds() { - this.configuration + this.networkRouters = this.configuration .listNetworksUsingPriceFeedsContract() - .forEach((networkInfo) => - new NetworkRouter( - this.configuration, - this.Web3, - this.repositories, - networkInfo, - ).listen(), - ) - } - - private async initializeAddresses(): Promise> { - const promises = this.legacyDataFeeds.map((feed) => - this.recheckFeedAddress(feed), - ) - - const feeds = await Promise.all(promises) - - // Store latest price feed addresses in memory - this.currentFeedAddresses = feeds.reduce( - (addresses, feed) => ({ - ...addresses, - [feed.feedFullName]: feed.address, - }), - {}, - ) - - return feeds - } - - async recheckFeedAddress(feedInfo: FeedInfo) { - const contractInfo = await this.getContractInfo(feedInfo) - const feed = this.repositories.feedRepository.get(feedInfo.feedFullName) - - if ( - contractInfo?.contractAddress && - contractInfo?.contractAddress !== feed?.address - ) { - console.log( - `Address of ${feedInfo.feedFullName}: ${feed.address} -> ${contractInfo.contractAddress}`, - ) - - this.currentFeedAddresses[feed.feedFullName] = - contractInfo.contractAddress - - return this.repositories.feedRepository.updateFeedAddress( - feedInfo.feedFullName, - { - address: contractInfo.contractAddress, - contractId: contractInfo.contractId, - }, - ) - } - - return feedInfo - } - - async listenLegacyPriceRouter() { - const feeds = await this.initializeAddresses() - - const feedDictionary = this.legacyDataFeeds.reduce( - ( - acc: Record, - feedInfo: FeedInfo, - ) => { - return { - ...acc, - [feedInfo.feedFullName]: { - feedInfo, - }, - } as Record - }, - {}, - ) - - feeds.forEach((feed) => { - const feedInfo = feedDictionary[feed?.feedFullName]?.feedInfo - if (feedInfo) { - const interval = setInterval( - () => this.recheckFeedAddress(feedInfo), - feed.pollingPeriod, - ) - this.intervals.push(interval) - } - }) - - const promises = Object.values(feedDictionary).map( - async (entry) => await this.listenToDataFeed(entry?.feedInfo), - ) - - Promise.all(promises).catch((err) => { - console.error('[ERROR]', err.message) - }) - } - - stop() { - this.intervals.forEach((interval) => { - clearInterval(interval) - }) - - this.intervals = [] - } - - async getContractInfo(feedInfo: FeedInfo): Promise { - try { - return await new Promise(async (resolve, reject) => { - try { - const provider = getProvider(feedInfo.network) - const timeout = 30000 - let web3: Web3 | undefined - //FIXME: make timeout work - if (provider) { - web3 = new this.Web3(new Web3.providers.HttpProvider(provider)) - } - //FIXME: use web3 timeout instead of custom - setTimeout(() => { - reject('Timeout') - }, timeout) - - if (web3 && !this.routerContractByNetwork[feedInfo.network]) { - this.routerContractByNetwork[feedInfo.network] = - new web3.eth.Contract( - feedInfo.routerAbi as any, - feedInfo.routerAddress, - ) - } - const routerContract = this.routerContractByNetwork[feedInfo.network] - - if (!this.contractIdByFeedId[feedInfo.id]) { - this.contractIdByFeedId[feedInfo.id] = await routerContract.methods - .currencyPairId(feedInfo.id) - .call() - } - const contractIdentifier = this.contractIdByFeedId[feedInfo.id] - const address = await routerContract.methods - .getPriceFeed(contractIdentifier) - .call() - resolve({ - contractAddress: address, - contractId: contractIdentifier, - }) - } catch (err) { - reject(err) - } - }) - } catch (err) { - console.log( - `Error reading pricefeed contract address for ${feedInfo.feedFullName}: ${err}`, + .map( + (networkInfo) => + new NetworkRouter( + this.configuration, + this.Web3, + this.repositories, + networkInfo, + ), ) - return null - } } - async readDataFeedContract(feedInfo: FeedInfo, provider) { - const web3 = new this.Web3(provider) - const contractAddress = this.currentFeedAddresses[feedInfo.feedFullName] - if (contractAddress && !isZeroAddress(contractAddress)) { - const feedContract = new web3.eth.Contract( - feedInfo.abi as any, - contractAddress, - ) - console.log( - `Reading ${feedInfo.feedFullName} contract state at address: ${contractAddress}`, - ) - await this.fetchAndSaveContractSnapshot( - { feedContract }, - feedInfo.feedFullName, - ) - } else { - console.error(`Pricefeed address not set for ${feedInfo.feedFullName}`) - } - } - - async listenToDataFeed(feedInfo: FeedInfo) { - const provider = getProvider(feedInfo.network) - if (provider) { - try { - this.readDataFeedContract(feedInfo, provider) - const interval = setInterval(async () => { - this.readDataFeedContract(feedInfo, provider) - }, feedInfo.pollingPeriod) - - this.intervals.push(interval) - } catch (err) { - console.error(`Provider not valid for ${feedInfo.network}`, err) - } - } else { - console.error(`Provider not set for network ${feedInfo.network}`) - } - - return + public async listen() { + this.networkRouters.map((networkRouter) => networkRouter.listen()) } - async readContractsState({ feedContract }: Contracts, feedFullName: string) { - try { - const { _lastPrice, _lastTimestamp, _lastDrTxHash, _latestUpdateStatus } = - await feedContract.methods.lastValue().call() - console.log( - `Latest contract update status for ${feedFullName}`, - _latestUpdateStatus, - ) - const requestId = await feedContract.methods.latestQueryId().call() - return { - lastPrice: _lastPrice.toString(), - lastTimestamp: _lastTimestamp.toString(), - lastDrTxHash: _lastDrTxHash.toString(), - requestId: requestId.toString(), - } - } catch (err) { - throw new Error(`Error reading contract state for ${feedFullName} ${err}`) - } - } - - async fetchAndSaveContractSnapshot( - contracts: Contracts, - feedFullName: string, - ) { - return new Promise(async (resolve) => { - try { - setTimeout(() => { - console.log(`Timeout while reading from ${feedFullName}`) - resolve(true) - }, 30000) - const { - lastPrice, - lastTimestamp, - lastDrTxHash, - requestId, - }: ContractsState = await this.readContractsState( - contracts, - feedFullName, - ) - await this.repositories.resultRequestRepository.insertIfLatest({ - result: lastPrice, - timestamp: lastTimestamp, - requestId: requestId, - drTxHash: toHex(lastDrTxHash).slice(2), - feedFullName, - }) - resolve(true) - } catch (error) { - console.error( - `Error reading contracts state for ${feedFullName}:`, - error, - ) - } - }) + public stop() { + this.networkRouters.forEach((networkRouter) => networkRouter.stop()) } } diff --git a/packages/api/test/.test.env b/packages/api/test/.test.env index c02ed10e..c9407889 100644 --- a/packages/api/test/.test.env +++ b/packages/api/test/.test.env @@ -1,3 +1,5 @@ ARBITRUM_ONE_PROVIDER=provider-arbitrum-one ARBITRUM_GOERLI_PROVIDER=provider-arbitrum-goerli -AVALANCHE_FUJI_PROVIDER=provider-avalanche-fuji \ No newline at end of file +AVALANCHE_FUJI_PROVIDER=provider-avalanche-fuji +AVALANCHE_MAINNET_PROVIDER=provider-avalanche-mainnet +BOBA_ETHEREUM_MAINNET_PROVIDER=provider-boba-ethereum-mainnet \ No newline at end of file diff --git a/packages/api/test/repository/feed.spec.ts b/packages/api/test/repository/feed.spec.ts index b0e8c22c..89d42045 100644 --- a/packages/api/test/repository/feed.spec.ts +++ b/packages/api/test/repository/feed.spec.ts @@ -3,176 +3,6 @@ import { FeedsState } from '../../src/repository/feedState' import { FeedInfo, Network } from '../../types' describe('FeedRepository', () => { - const legacyFeeds: Array = [ - { - feedFullName: 'arbitrum-one_eth-usd_6', - isRouted: false, - id: 'Price-ETH/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0xf56E739C436EA6e65A17DBfaC9D7E57062D19422', - network: 'arbitrum-one' as Network, - networkName: 'Arbitrum ONE', - chain: 'Arbitrum', - name: 'eth/usd', - label: '$', - pollingPeriod: 120000, - color: '#E84142', - blockExplorer: 'https://arbiscan.io/address/{address}', - deviation: '3.5', - heartbeat: '86400000', - finality: '900000', - routerAbi: [], - abi: [], - }, - { - feedFullName: 'elastos-mainnet_bnb-usd_6', - isRouted: true, - id: 'Price-BNB/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x0Aa147F25CE8BfaA4E6B4B2CCa91f595bD732CD4', - network: 'elastos-mainnet' as Network, - networkName: 'Elastos Mainnet', - chain: 'Elastos', - name: 'bnb/usd', - label: '$', - pollingPeriod: 120000, - color: '#66ff00', - blockExplorer: 'https://esc.elastos.io/address/{address}', - deviation: null, - heartbeat: null, - finality: '900000', - routerAbi: [], - abi: [], - }, - { - feedFullName: 'kcc-mainnet_usdt-usd_6', - isRouted: false, - id: 'Price-USDT/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0xD39D4d972C7E166856c4eb29E54D3548B4597F53', - network: 'kcc-mainnet' as Network, - networkName: 'KCC Mainnet', - chain: 'KCC', - name: 'usdt/usd', - label: '$', - pollingPeriod: 120000, - color: '#ff0066', - blockExplorer: 'https://scan.kcc.io/address/{address}', - deviation: '0.1', - heartbeat: '86400000', - finality: '900000', - routerAbi: [], - abi: [], - }, - { - feedFullName: 'polygon-mainnet_btc-usd_6', - isRouted: false, - id: 'Price-BTC/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x3806311c7138ddF2bAF2C2093ff3633E5A73AbD4', - network: 'polygon-mainnet' as Network, - networkName: 'Polygon Mainnet', - chain: 'Polygon', - name: 'btc/usd', - label: '$', - pollingPeriod: 120000, - color: '#66ff00', - blockExplorer: 'https://polygonscan.com/address/{address}', - deviation: '3.5', - heartbeat: '86400000', - finality: '900000', - routerAbi: [], - abi: [], - }, - { - feedFullName: 'polygon-mainnet_dai-usd_6', - isRouted: false, - id: 'Price-DAI/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x3806311c7138ddF2bAF2C2093ff3633E5A73AbD4', - network: 'polygon-mainnet' as Network, - networkName: 'Polygon Mainnet', - chain: 'Polygon', - name: 'dai/usd', - label: '$', - pollingPeriod: 120000, - color: '#66ff00', - blockExplorer: 'https://polygonscan.com/address/{address}', - deviation: '0.1', - heartbeat: '86400000', - finality: '900000', - routerAbi: [], - abi: [], - }, - { - feedFullName: 'polygon-zkevm-mainnet_usdc-usd_6', - isRouted: false, - id: 'Price-USDC/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0xb99FA0430C73E7B82604Aa99d351d6aFdCe46A16', - network: 'polygon-zkevm-mainnet' as Network, - networkName: 'Polygon zkEVM Mainnet', - chain: 'Polygon', - name: 'usdc/usd', - label: '$', - pollingPeriod: 120000, - color: '#66ff00', - blockExplorer: 'https://zkevm.polygonscan.com/address/{address}', - deviation: '0.1', - heartbeat: '86400000', - finality: '900000', - routerAbi: [], - abi: [], - }, - { - feedFullName: 'reef-mainnet_reef-usdt_6', - isRouted: false, - id: 'Price-REEF/USDT-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x828D7517D9Cf0d99f952d709371117ef8825e81B', - network: 'reef-mainnet' as Network, - networkName: 'Reef Mainnet', - chain: 'Reef', - name: 'reef/usdt', - label: '₮', - pollingPeriod: 180000, - color: '#66ff00', - blockExplorer: 'https://reefscan.com/contract/{address}', - deviation: '3.5', - heartbeat: '86400000', - finality: '900000', - routerAbi: [], - abi: [], - }, - ] - const legacyFeed = { - feedFullName: 'scroll-mainnet_usdc-usd_6', - isRouted: false, - id: 'Price-USDC/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x0d13c6058DDE86da77565ED6038C065Af71e9208', - network: 'scroll-mainnet' as Network, - networkName: 'Scroll Mainnet', - chain: 'Scroll', - name: 'usdc/usd', - label: '$', - pollingPeriod: 120000, - color: '#66ff00', - blockExplorer: 'https://scrollscan.com/address/{address}', - deviation: '0.2', - heartbeat: '86400000', - finality: '900000', - routerAbi: [], - abi: [], - } const v2Feeds: Array = [ { feedFullName: 'arbitrum-sepolia_eth-usd_6', @@ -281,153 +111,6 @@ describe('FeedRepository', () => { color: '#66ff00', } const baseConfigFullName = { - 'arbitrum-one_eth-usd_6': { - feedFullName: 'arbitrum-one_eth-usd_6', - isRouted: false, - id: 'Price-ETH/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0xf56E739C436EA6e65A17DBfaC9D7E57062D19422', - network: 'arbitrum-one', - networkName: 'Arbitrum ONE', - chain: 'Arbitrum', - name: 'eth/usd', - label: '$', - pollingPeriod: 120000, - color: '#E84142', - blockExplorer: 'https://arbiscan.io/address/{address}', - deviation: '3.5', - heartbeat: '86400000', - finality: '900000', - routerAbi: [], - abi: [], - }, - 'elastos-mainnet_bnb-usd_6': { - feedFullName: 'elastos-mainnet_bnb-usd_6', - isRouted: true, - id: 'Price-BNB/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x0Aa147F25CE8BfaA4E6B4B2CCa91f595bD732CD4', - network: 'elastos-mainnet', - networkName: 'Elastos Mainnet', - chain: 'Elastos', - name: 'bnb/usd', - label: '$', - pollingPeriod: 120000, - color: '#66ff00', - blockExplorer: 'https://esc.elastos.io/address/{address}', - deviation: null, - heartbeat: null, - finality: '900000', - routerAbi: [], - abi: [], - }, - 'kcc-mainnet_usdt-usd_6': { - feedFullName: 'kcc-mainnet_usdt-usd_6', - isRouted: false, - id: 'Price-USDT/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0xD39D4d972C7E166856c4eb29E54D3548B4597F53', - network: 'kcc-mainnet', - networkName: 'KCC Mainnet', - chain: 'KCC', - name: 'usdt/usd', - label: '$', - pollingPeriod: 120000, - color: '#ff0066', - blockExplorer: 'https://scan.kcc.io/address/{address}', - deviation: '0.1', - heartbeat: '86400000', - finality: '900000', - routerAbi: [], - abi: [], - }, - 'polygon-mainnet_btc-usd_6': { - feedFullName: 'polygon-mainnet_btc-usd_6', - isRouted: false, - id: 'Price-BTC/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x3806311c7138ddF2bAF2C2093ff3633E5A73AbD4', - network: 'polygon-mainnet', - networkName: 'Polygon Mainnet', - chain: 'Polygon', - name: 'btc/usd', - label: '$', - pollingPeriod: 120000, - color: '#66ff00', - blockExplorer: 'https://polygonscan.com/address/{address}', - deviation: '3.5', - heartbeat: '86400000', - finality: '900000', - routerAbi: [], - abi: [], - }, - 'polygon-mainnet_dai-usd_6': { - feedFullName: 'polygon-mainnet_dai-usd_6', - isRouted: false, - id: 'Price-DAI/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x3806311c7138ddF2bAF2C2093ff3633E5A73AbD4', - network: 'polygon-mainnet', - networkName: 'Polygon Mainnet', - chain: 'Polygon', - name: 'dai/usd', - label: '$', - pollingPeriod: 120000, - color: '#66ff00', - blockExplorer: 'https://polygonscan.com/address/{address}', - deviation: '0.1', - heartbeat: '86400000', - finality: '900000', - routerAbi: [], - abi: [], - }, - 'polygon-zkevm-mainnet_usdc-usd_6': { - feedFullName: 'polygon-zkevm-mainnet_usdc-usd_6', - isRouted: false, - id: 'Price-USDC/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0xb99FA0430C73E7B82604Aa99d351d6aFdCe46A16', - network: 'polygon-zkevm-mainnet', - networkName: 'Polygon zkEVM Mainnet', - chain: 'Polygon', - name: 'usdc/usd', - label: '$', - pollingPeriod: 120000, - color: '#66ff00', - blockExplorer: 'https://zkevm.polygonscan.com/address/{address}', - deviation: '0.1', - heartbeat: '86400000', - finality: '900000', - routerAbi: [], - abi: [], - }, - 'reef-mainnet_reef-usdt_6': { - feedFullName: 'reef-mainnet_reef-usdt_6', - isRouted: false, - id: 'Price-REEF/USDT-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x828D7517D9Cf0d99f952d709371117ef8825e81B', - network: 'reef-mainnet', - networkName: 'Reef Mainnet', - chain: 'Reef', - name: 'reef/usdt', - label: '₮', - pollingPeriod: 180000, - color: '#66ff00', - blockExplorer: 'https://reefscan.com/contract/{address}', - deviation: '3.5', - heartbeat: '86400000', - finality: '900000', - routerAbi: [], - abi: [], - }, 'arbitrum-sepolia_eth-usd_6': { feedFullName: 'arbitrum-sepolia_eth-usd_6', id: '0x3d15f701', @@ -514,174 +197,6 @@ describe('FeedRepository', () => { }, } const updatedConfig = { - 'arbitrum-one_eth-usd_6': { - feedFullName: 'arbitrum-one_eth-usd_6', - isRouted: false, - id: 'Price-ETH/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0xf56E739C436EA6e65A17DBfaC9D7E57062D19422', - network: 'arbitrum-one', - networkName: 'Arbitrum ONE', - chain: 'Arbitrum', - name: 'eth/usd', - label: '$', - pollingPeriod: 120000, - color: '#E84142', - blockExplorer: 'https://arbiscan.io/address/{address}', - deviation: '3.5', - heartbeat: '86400000', - finality: '900000', - routerAbi: [], - abi: [], - }, - 'elastos-mainnet_bnb-usd_6': { - feedFullName: 'elastos-mainnet_bnb-usd_6', - isRouted: true, - id: 'Price-BNB/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x0Aa147F25CE8BfaA4E6B4B2CCa91f595bD732CD4', - network: 'elastos-mainnet', - networkName: 'Elastos Mainnet', - chain: 'Elastos', - name: 'bnb/usd', - label: '$', - pollingPeriod: 120000, - color: '#66ff00', - blockExplorer: 'https://esc.elastos.io/address/{address}', - deviation: null, - heartbeat: null, - finality: '900000', - routerAbi: [], - abi: [], - }, - 'kcc-mainnet_usdt-usd_6': { - feedFullName: 'kcc-mainnet_usdt-usd_6', - isRouted: false, - id: 'Price-USDT/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0xD39D4d972C7E166856c4eb29E54D3548B4597F53', - network: 'kcc-mainnet', - networkName: 'KCC Mainnet', - chain: 'KCC', - name: 'usdt/usd', - label: '$', - pollingPeriod: 120000, - color: '#ff0066', - blockExplorer: 'https://scan.kcc.io/address/{address}', - deviation: '0.1', - heartbeat: '86400000', - finality: '900000', - routerAbi: [], - abi: [], - }, - 'polygon-mainnet_btc-usd_6': { - feedFullName: 'polygon-mainnet_btc-usd_6', - isRouted: false, - id: 'Price-BTC/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x3806311c7138ddF2bAF2C2093ff3633E5A73AbD4', - network: 'polygon-mainnet', - networkName: 'Polygon Mainnet', - chain: 'Polygon', - name: 'btc/usd', - label: '$', - pollingPeriod: 120000, - color: '#66ff00', - blockExplorer: 'https://polygonscan.com/address/{address}', - deviation: '3.5', - heartbeat: '86400000', - finality: '900000', - routerAbi: [], - abi: [], - }, - 'polygon-mainnet_dai-usd_6': { - feedFullName: 'polygon-mainnet_dai-usd_6', - isRouted: false, - id: 'Price-DAI/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x3806311c7138ddF2bAF2C2093ff3633E5A73AbD4', - network: 'polygon-mainnet', - networkName: 'Polygon Mainnet', - chain: 'Polygon', - name: 'dai/usd', - label: '$', - pollingPeriod: 120000, - color: '#66ff00', - blockExplorer: 'https://polygonscan.com/address/{address}', - deviation: '0.1', - heartbeat: '86400000', - finality: '900000', - routerAbi: [], - abi: [], - }, - 'polygon-zkevm-mainnet_usdc-usd_6': { - feedFullName: 'polygon-zkevm-mainnet_usdc-usd_6', - isRouted: false, - id: 'Price-USDC/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0xb99FA0430C73E7B82604Aa99d351d6aFdCe46A16', - network: 'polygon-zkevm-mainnet', - networkName: 'Polygon zkEVM Mainnet', - chain: 'Polygon', - name: 'usdc/usd', - label: '$', - pollingPeriod: 120000, - color: '#66ff00', - blockExplorer: 'https://zkevm.polygonscan.com/address/{address}', - deviation: '0.1', - heartbeat: '86400000', - finality: '900000', - routerAbi: [], - abi: [], - }, - 'reef-mainnet_reef-usdt_6': { - feedFullName: 'reef-mainnet_reef-usdt_6', - isRouted: false, - id: 'Price-REEF/USDT-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x828D7517D9Cf0d99f952d709371117ef8825e81B', - network: 'reef-mainnet', - networkName: 'Reef Mainnet', - chain: 'Reef', - name: 'reef/usdt', - label: '₮', - pollingPeriod: 180000, - color: '#66ff00', - blockExplorer: 'https://reefscan.com/contract/{address}', - deviation: '3.5', - heartbeat: '86400000', - finality: '900000', - routerAbi: [], - abi: [], - }, - 'scroll-mainnet_usdc-usd_6': { - feedFullName: 'scroll-mainnet_usdc-usd_6', - isRouted: false, - id: 'Price-USDC/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x0d13c6058DDE86da77565ED6038C065Af71e9208', - network: 'scroll-mainnet', - networkName: 'Scroll Mainnet', - chain: 'Scroll', - name: 'usdc/usd', - label: '$', - pollingPeriod: 120000, - color: '#66ff00', - blockExplorer: 'https://scrollscan.com/address/{address}', - deviation: '0.2', - heartbeat: '86400000', - finality: '900000', - routerAbi: [], - abi: [], - }, 'arbitrum-sepolia_eth-usd_6': { feedFullName: 'arbitrum-sepolia_eth-usd_6', id: '0x3d15f701', @@ -789,10 +304,9 @@ describe('FeedRepository', () => { }, } - it('Updates config by fullname map after updating the legacy and v2 feeds from the repository', async () => { + it('Updates config by fullname map after updating v2 feeds from the repository', async () => { const feedState = new FeedsState() - feedState.setLegacyFeeds(legacyFeeds) feedState.setV2Feeds(v2Feeds) const feedRepository = new FeedRepository(feedState) @@ -801,17 +315,15 @@ describe('FeedRepository', () => { feedRepository.getConfigByFullName(), ) - feedRepository.setLegacyFeeds([...legacyFeeds, legacyFeed]) feedRepository.setV2Feeds([...v2Feeds, v2Feed]) expect(updatedConfig).toStrictEqual(feedRepository.getConfigByFullName()) expect(updatedConfig).not.toStrictEqual(baseConfigFullName) }) - it('Updates config by fullname map after updating the legacy and v2 feeds from the feed state and then calling initialize', async () => { + it('Updates config by fullname map after updating v2 feeds from the feed state and then calling initialize', async () => { const feedState = new FeedsState() - feedState.setLegacyFeeds(legacyFeeds) feedState.setV2Feeds(v2Feeds) const feedRepository = new FeedRepository(feedState) @@ -820,7 +332,6 @@ describe('FeedRepository', () => { feedRepository.getConfigByFullName(), ) - feedState.setLegacyFeeds([...legacyFeeds, legacyFeed]) feedState.setV2Feeds([...v2Feeds, v2Feed]) feedRepository.initialize() @@ -831,7 +342,6 @@ describe('FeedRepository', () => { it('refreshV2NetworkFeeds concats new values in the state instead of overwrite them', () => { const feedState = new FeedsState() - feedState.setLegacyFeeds(legacyFeeds) feedState.setV2Feeds(v2Feeds) const feedRepository = new FeedRepository(feedState) diff --git a/packages/api/test/sanity.spec.ts b/packages/api/test/sanity.spec.ts deleted file mode 100644 index 30a58dc0..00000000 --- a/packages/api/test/sanity.spec.ts +++ /dev/null @@ -1,5 +0,0 @@ -describe('sanity', () => { - it('works', () => { - expect(1 + 1).toBe(2) - }) -}) diff --git a/packages/api/test/validateFeedsConfig.spec.ts b/packages/api/test/validateFeedsConfig.spec.ts deleted file mode 100644 index 6a08b382..00000000 --- a/packages/api/test/validateFeedsConfig.spec.ts +++ /dev/null @@ -1,836 +0,0 @@ -import { normalizeConfig } from '../src/utils/index' -import dataFeedsRouterConfig from '../test/web3Middleware/dataFeedsRouter.json' -import { RouterDataFeedsConfig } from '../types' - -describe.skip('validateDataFeedsConfig', () => { - it('check if the structure is correct', async () => { - const feeds = normalizeConfig( - dataFeedsRouterConfig as RouterDataFeedsConfig, - ) - const expected = [ - { - address: '0x0000000000000000000000000000000000000000', - blockExplorer: 'https://arbiscan.io/address/{address}', - chain: 'Arbitrum', - color: '#E84142', - contractId: '0x0000000000000000000000000000000000000000', - deviation: '3.5', - feedFullName: 'arbitrum-one_eth-usd_6', - finality: '900000', - heartbeat: '86400000', - id: 'Price-ETH/USD-6', - isRouted: false, - label: '$', - name: 'eth/usd', - network: 'arbitrum-one', - networkName: 'Arbitrum ONE', - pollingPeriod: 120000, - routerAddress: '0x9999999d139bdBFbF25923ba39F63bBFc7593400', - }, - { - feedFullName: 'boba-mainnet_boba-usdt_6', - isRouted: false, - id: 'Price-BOBA/USDT-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x93f61D0D5F623144e7C390415B70102A9Cc90bA5', - network: 'boba-mainnet', - networkName: 'Boba Mainnet', - chain: 'Boba', - name: 'boba/usdt', - label: '₮', - pollingPeriod: 15000, - color: '#007dff', - blockExplorer: 'https://blockexplorer.boba.network/address/{address}', - deviation: '1', - heartbeat: '86400000', - finality: '900000', - }, - { - feedFullName: 'boba-mainnet_btc-usd_6', - isRouted: false, - id: 'Price-BTC/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x93f61D0D5F623144e7C390415B70102A9Cc90bA5', - network: 'boba-mainnet', - networkName: 'Boba Mainnet', - chain: 'Boba', - name: 'btc/usd', - label: '$', - pollingPeriod: 15000, - color: '#007dff', - blockExplorer: 'https://blockexplorer.boba.network/address/{address}', - deviation: '1', - heartbeat: '86400000', - finality: '900000', - }, - { - feedFullName: 'boba-mainnet_eth-usd_6', - isRouted: false, - id: 'Price-ETH/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x93f61D0D5F623144e7C390415B70102A9Cc90bA5', - network: 'boba-mainnet', - networkName: 'Boba Mainnet', - chain: 'Boba', - name: 'eth/usd', - label: '$', - pollingPeriod: 15000, - color: '#007dff', - blockExplorer: 'https://blockexplorer.boba.network/address/{address}', - deviation: '1', - heartbeat: '86400000', - finality: '900000', - }, - { - feedFullName: 'boba-mainnet_frax-usdt_6', - isRouted: false, - id: 'Price-FRAX/USDT-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x93f61D0D5F623144e7C390415B70102A9Cc90bA5', - network: 'boba-mainnet', - networkName: 'Boba Mainnet', - chain: 'Boba', - name: 'frax/usdt', - label: '₮', - pollingPeriod: 15000, - color: '#007dff', - blockExplorer: 'https://blockexplorer.boba.network/address/{address}', - deviation: '0.25', - heartbeat: '86400000', - finality: '900000', - }, - { - feedFullName: 'boba-mainnet_usdc-usd_6', - isRouted: false, - id: 'Price-USDC/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x93f61D0D5F623144e7C390415B70102A9Cc90bA5', - network: 'boba-mainnet', - networkName: 'Boba Mainnet', - chain: 'Boba', - name: 'usdc/usd', - label: '$', - pollingPeriod: 15000, - color: '#007dff', - blockExplorer: 'https://blockexplorer.boba.network/address/{address}', - deviation: '0.25', - heartbeat: '86400000', - finality: '900000', - }, - { - feedFullName: 'boba-mainnet_usdt-usd_6', - isRouted: false, - id: 'Price-USDT/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x93f61D0D5F623144e7C390415B70102A9Cc90bA5', - network: 'boba-mainnet', - networkName: 'Boba Mainnet', - chain: 'Boba', - name: 'usdt/usd', - label: '$', - pollingPeriod: 15000, - color: '#007dff', - blockExplorer: 'https://blockexplorer.boba.network/address/{address}', - deviation: '0.25', - heartbeat: '86400000', - finality: '900000', - }, - { - feedFullName: 'celo-alfajores_btc-usd_6', - isRouted: false, - id: 'Price-BTC/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x6f8A7E2bBc1eDb8782145cD1089251f6e2C738AE', - network: 'celo-alfajores', - networkName: 'Celo Alfajores', - chain: 'Celo', - name: 'btc/usd', - label: '$', - pollingPeriod: 15000, - color: '#1cd8d2', - blockExplorer: - 'https://alfajores-blockscout.celo-testnet.org/address/{address}', - deviation: '1', - heartbeat: '3600000', - finality: '900000', - }, - { - feedFullName: 'celo-alfajores_celo-eur_6', - isRouted: false, - id: 'Price-CELO/EUR-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x6f8A7E2bBc1eDb8782145cD1089251f6e2C738AE', - network: 'celo-alfajores', - networkName: 'Celo Alfajores', - chain: 'Celo', - name: 'celo/eur', - label: '€', - pollingPeriod: 15000, - color: '#1cd8d2', - blockExplorer: - 'https://alfajores-blockscout.celo-testnet.org/address/{address}', - deviation: '1', - heartbeat: '3600000', - finality: '900000', - }, - { - feedFullName: 'celo-alfajores_celo-usd_6', - isRouted: false, - id: 'Price-CELO/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x6f8A7E2bBc1eDb8782145cD1089251f6e2C738AE', - network: 'celo-alfajores', - networkName: 'Celo Alfajores', - chain: 'Celo', - name: 'celo/usd', - label: '$', - pollingPeriod: 15000, - color: '#1cd8d2', - blockExplorer: - 'https://alfajores-blockscout.celo-testnet.org/address/{address}', - deviation: '1', - heartbeat: '3600000', - finality: '900000', - }, - { - feedFullName: 'celo-alfajores_eth-usd_6', - isRouted: false, - id: 'Price-ETH/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x6f8A7E2bBc1eDb8782145cD1089251f6e2C738AE', - network: 'celo-alfajores', - networkName: 'Celo Alfajores', - chain: 'Celo', - name: 'eth/usd', - label: '$', - pollingPeriod: 15000, - color: '#1cd8d2', - blockExplorer: - 'https://alfajores-blockscout.celo-testnet.org/address/{address}', - deviation: '1', - heartbeat: '3600000', - finality: '900000', - }, - { - feedFullName: 'celo-mainnet_celo-eur_6', - isRouted: false, - id: 'Price-CELO/EUR-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x931673904eB6E69D775e35F522c0EA35575297Cb', - network: 'celo-mainnet', - networkName: 'Celo Mainnet', - chain: 'Celo', - name: 'celo/eur', - label: '€', - pollingPeriod: 15000, - color: '#ff8100', - blockExplorer: 'https://explorer.celo.org/address/{address}', - deviation: '1', - heartbeat: '86400000', - finality: '900000', - }, - { - feedFullName: 'celo-mainnet_celo-usd_6', - isRouted: false, - id: 'Price-CELO/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x931673904eB6E69D775e35F522c0EA35575297Cb', - network: 'celo-mainnet', - networkName: 'Celo Mainnet', - chain: 'Celo', - name: 'celo/usd', - label: '$', - pollingPeriod: 15000, - color: '#ff8100', - blockExplorer: 'https://explorer.celo.org/address/{address}', - deviation: '1', - heartbeat: '86400000', - finality: '900000', - }, - { - feedFullName: 'celo-mainnet_btc-usd_6', - isRouted: false, - id: 'Price-BTC/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x931673904eB6E69D775e35F522c0EA35575297Cb', - network: 'celo-mainnet', - networkName: 'Celo Mainnet', - chain: 'Celo', - name: 'btc/usd', - label: '$', - pollingPeriod: 15000, - color: '#ff8100', - blockExplorer: 'https://explorer.celo.org/address/{address}', - deviation: '3.5', - heartbeat: '86400000', - finality: '900000', - }, - { - feedFullName: 'celo-mainnet_eth-usd_6', - isRouted: false, - id: 'Price-ETH/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x931673904eB6E69D775e35F522c0EA35575297Cb', - network: 'celo-mainnet', - networkName: 'Celo Mainnet', - chain: 'Celo', - name: 'eth/usd', - label: '$', - pollingPeriod: 15000, - color: '#ff8100', - blockExplorer: 'https://explorer.celo.org/address/{address}', - deviation: '3.5', - heartbeat: '86400000', - finality: '900000', - }, - { - feedFullName: 'conflux-testnet_cfx-usdt_6', - isRouted: false, - id: 'Price-CFX/USDT-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x8F61C7b18F69bB87D6151B8a5D733E1945ea6c25', - network: 'conflux-testnet', - networkName: 'Conflux Core (Testnet)', - chain: 'Conflux', - name: 'cfx/usdt', - label: '₮', - pollingPeriod: 15000, - color: '#6600ff', - blockExplorer: 'https://testnet.confluxscan.io/address/{address}', - deviation: '1', - heartbeat: '3600000', - finality: '900000', - }, - { - feedFullName: 'conflux-testnet_btc-usd_6', - isRouted: false, - id: 'Price-BTC/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x8F61C7b18F69bB87D6151B8a5D733E1945ea6c25', - network: 'conflux-testnet', - networkName: 'Conflux Core (Testnet)', - chain: 'Conflux', - name: 'btc/usd', - label: '$', - pollingPeriod: 15000, - color: '#6600ff', - blockExplorer: 'https://testnet.confluxscan.io/address/{address}', - deviation: '1', - heartbeat: '3600000', - finality: '900000', - }, - { - feedFullName: 'conflux-testnet_eth-usd_6', - isRouted: false, - id: 'Price-ETH/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x8F61C7b18F69bB87D6151B8a5D733E1945ea6c25', - network: 'conflux-testnet', - networkName: 'Conflux Core (Testnet)', - chain: 'Conflux', - name: 'eth/usd', - label: '$', - pollingPeriod: 15000, - color: '#6600ff', - blockExplorer: 'https://testnet.confluxscan.io/address/{address}', - deviation: '1', - heartbeat: '3600000', - finality: '900000', - }, - { - feedFullName: 'conflux-tethys_cfx-usdt_6', - isRouted: false, - id: 'Price-CFX/USDT-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x806c8dFd322EE2d52b188CC472e0814F64304C32', - network: 'conflux-tethys', - networkName: 'Conflux Core (Hydra)', - chain: 'Conflux', - name: 'cfx/usdt', - label: '₮', - pollingPeriod: 15000, - color: '#ff0000', - blockExplorer: 'https://confluxscan.io/address/{address}', - deviation: '1', - heartbeat: '3600000', - finality: '900000', - }, - { - feedFullName: 'conflux-tethys_btc-usd_6', - isRouted: false, - id: 'Price-BTC/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x806c8dFd322EE2d52b188CC472e0814F64304C32', - network: 'conflux-tethys', - networkName: 'Conflux Core (Hydra)', - chain: 'Conflux', - name: 'btc/usd', - label: '$', - pollingPeriod: 15000, - color: '#ff0000', - blockExplorer: 'https://confluxscan.io/address/{address}', - deviation: '3.5', - heartbeat: '86400000', - finality: '900000', - }, - { - feedFullName: 'conflux-tethys_eth-usd_6', - isRouted: false, - id: 'Price-ETH/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x806c8dFd322EE2d52b188CC472e0814F64304C32', - network: 'conflux-tethys', - networkName: 'Conflux Core (Hydra)', - chain: 'Conflux', - name: 'eth/usd', - label: '$', - pollingPeriod: 15000, - color: '#ff0000', - blockExplorer: 'https://confluxscan.io/address/{address}', - deviation: '3.5', - heartbeat: '86400000', - finality: '900000', - }, - { - feedFullName: 'ethereum-goerli_btc-usd_6', - isRouted: false, - id: 'Price-BTC/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x1cF3Aa9DBF4880d797945726B94B9d29164211BE', - network: 'ethereum-goerli', - networkName: 'Ethereum Goerli', - chain: 'Ethereum', - name: 'btc/usd', - label: '$', - pollingPeriod: 15000, - color: '#ff5599', - blockExplorer: 'https://goerli.etherscan.io/address/{address}', - deviation: '1', - heartbeat: '28800000', - finality: '900000', - }, - { - feedFullName: 'ethereum-goerli_eth-usd_6', - isRouted: false, - id: 'Price-ETH/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x1cF3Aa9DBF4880d797945726B94B9d29164211BE', - network: 'ethereum-goerli', - networkName: 'Ethereum Goerli', - chain: 'Ethereum', - name: 'eth/usd', - label: '$', - pollingPeriod: 15000, - color: '#ff5599', - blockExplorer: 'https://goerli.etherscan.io/address/{address}', - deviation: '1', - heartbeat: '28800000', - finality: '900000', - }, - { - feedFullName: 'ethereum-rinkeby_btc-usd_6', - isRouted: false, - id: 'Price-BTC/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0xa50b17C2fc373c247C3b603f83df6A7800cB0DC9', - network: 'ethereum-rinkeby', - networkName: 'Ethereum Rinkeby', - chain: 'Ethereum', - name: 'btc/usd', - label: '$', - pollingPeriod: 15000, - color: '#ff5599', - blockExplorer: 'https://rinkeby.etherscan.io/address/{address}', - deviation: '1', - heartbeat: '86400000', - finality: '900000', - }, - { - feedFullName: 'ethereum-rinkeby_eth-usd_6', - isRouted: false, - id: 'Price-ETH/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0xa50b17C2fc373c247C3b603f83df6A7800cB0DC9', - network: 'ethereum-rinkeby', - networkName: 'Ethereum Rinkeby', - chain: 'Ethereum', - name: 'eth/usd', - label: '$', - pollingPeriod: 15000, - color: '#ff5599', - blockExplorer: 'https://rinkeby.etherscan.io/address/{address}', - deviation: '1', - heartbeat: '86400000', - finality: '900000', - }, - { - feedFullName: 'ethereum-mainnet_btc-usd_6', - isRouted: false, - id: 'Price-BTC/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x83A757eAe821Ad7B520D9A74952337138A80b2AF', - network: 'ethereum-mainnet', - networkName: 'Ethereum Mainnet', - chain: 'Ethereum', - name: 'btc/usd', - label: '$', - pollingPeriod: 15000, - color: '#ff5599', - blockExplorer: 'https://etherscan.io/address/{address}', - deviation: '3.5', - heartbeat: '86400000', - finality: '900000', - }, - { - feedFullName: 'ethereum-mainnet_eth-usd_6', - isRouted: false, - id: 'Price-ETH/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x83A757eAe821Ad7B520D9A74952337138A80b2AF', - network: 'ethereum-mainnet', - networkName: 'Ethereum Mainnet', - chain: 'Ethereum', - name: 'eth/usd', - label: '$', - pollingPeriod: 15000, - color: '#ff5599', - blockExplorer: 'https://etherscan.io/address/{address}', - deviation: '3.5', - heartbeat: '86400000', - finality: '900000', - }, - { - feedFullName: 'harmony-testnet_btc-usd_6', - isRouted: false, - id: 'Price-BTC/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x08d479a544b05B297454e5CAc133abA3a584AB8E', - network: 'harmony-testnet', - networkName: 'Harmony Testnet', - chain: 'Harmony', - name: 'btc/usd', - label: '$', - pollingPeriod: 15000, - color: '#f6006f', - blockExplorer: 'https://explorer.pops.one/address/{address}', - deviation: '1', - heartbeat: '3600000', - finality: '900000', - }, - { - feedFullName: 'harmony-testnet_eth-usd_6', - isRouted: false, - id: 'Price-ETH/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x08d479a544b05B297454e5CAc133abA3a584AB8E', - network: 'harmony-testnet', - networkName: 'Harmony Testnet', - chain: 'Harmony', - name: 'eth/usd', - label: '$', - pollingPeriod: 15000, - color: '#f6006f', - blockExplorer: 'https://explorer.pops.one/address/{address}', - deviation: '1', - heartbeat: '3600000', - finality: '900000', - }, - { - feedFullName: 'kcc-testnet_kcs-usdt_6', - isRouted: false, - id: 'Price-KCS/USDT-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0xba7CF62498340fa3734EC51Ca8A69928F0d9E03a', - network: 'kcc-testnet', - networkName: 'KCC Testnet', - chain: 'KCC', - name: 'kcs/usdt', - label: '₮', - pollingPeriod: 15000, - color: '#ff0066', - blockExplorer: 'https://scan-testnet.kcc.network/address/{address}', - deviation: '0.5', - heartbeat: '600000', - finality: '900000', - }, - { - feedFullName: 'kcc-testnet_btc-usd_6', - isRouted: false, - id: 'Price-BTC/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0xba7CF62498340fa3734EC51Ca8A69928F0d9E03a', - network: 'kcc-testnet', - networkName: 'KCC Testnet', - chain: 'KCC', - name: 'btc/usd', - label: '$', - pollingPeriod: 15000, - color: '#ff0066', - blockExplorer: 'https://scan-testnet.kcc.network/address/{address}', - deviation: '0.5', - heartbeat: '600000', - finality: '900000', - }, - { - feedFullName: 'kcc-testnet_eth-usd_6', - isRouted: false, - id: 'Price-ETH/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0xba7CF62498340fa3734EC51Ca8A69928F0d9E03a', - network: 'kcc-testnet', - networkName: 'KCC Testnet', - chain: 'KCC', - name: 'eth/usd', - label: '$', - pollingPeriod: 15000, - color: '#ff0066', - blockExplorer: 'https://scan-testnet.kcc.network/address/{address}', - deviation: '0.5', - heartbeat: '600000', - finality: '900000', - }, - { - feedFullName: 'kcc-mainnet_kcs-usdt_6', - isRouted: false, - id: 'Price-KCS/USDT-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0xD39D4d972C7E166856c4eb29E54D3548B4597F53', - network: 'kcc-mainnet', - networkName: 'KCC Mainnet', - chain: 'KCC', - name: 'kcs/usdt', - label: '₮', - pollingPeriod: 15000, - color: '#ff0066', - blockExplorer: 'https://scan.kcc.io/address/{address}', - deviation: '0.5', - heartbeat: '600000', - finality: '900000', - }, - { - feedFullName: 'kcc-mainnet_btc-usd_6', - isRouted: false, - id: 'Price-BTC/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0xD39D4d972C7E166856c4eb29E54D3548B4597F53', - network: 'kcc-mainnet', - networkName: 'KCC Mainnet', - chain: 'KCC', - name: 'btc/usd', - label: '$', - pollingPeriod: 15000, - color: '#ff0066', - blockExplorer: 'https://scan.kcc.io/address/{address}', - deviation: '0.5', - heartbeat: '600000', - finality: '900000', - }, - { - feedFullName: 'kcc-mainnet_eth-usd_6', - isRouted: false, - id: 'Price-ETH/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0xD39D4d972C7E166856c4eb29E54D3548B4597F53', - network: 'kcc-mainnet', - networkName: 'KCC Mainnet', - chain: 'KCC', - name: 'eth/usd', - label: '$', - pollingPeriod: 15000, - color: '#ff0066', - blockExplorer: 'https://scan.kcc.io/address/{address}', - deviation: '0.5', - heartbeat: '600000', - finality: '900000', - }, - { - feedFullName: 'metis-rinkeby_metis-usdt_6', - isRouted: false, - id: 'Price-METIS/USDT-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x5134EAF08bcf8cE1922991150AAad1774e93751f', - network: 'metis-rinkeby', - networkName: 'Metis Rinkeby', - chain: 'Metis', - name: 'metis/usdt', - label: '₮', - pollingPeriod: 15000, - color: '#ff6600', - blockExplorer: 'https://stardust-explorer.metis.io/address/{address}', - deviation: '1', - heartbeat: '86400000', - finality: '900000', - }, - { - feedFullName: 'metis-rinkeby_btc-usd_6', - isRouted: false, - id: 'Price-BTC/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x5134EAF08bcf8cE1922991150AAad1774e93751f', - network: 'metis-rinkeby', - networkName: 'Metis Rinkeby', - chain: 'Metis', - name: 'btc/usd', - label: '$', - pollingPeriod: 15000, - color: '#ff6600', - blockExplorer: 'https://stardust-explorer.metis.io/address/{address}', - deviation: '1', - heartbeat: '86400000', - finality: '900000', - }, - { - feedFullName: 'metis-rinkeby_eth-usd_6', - isRouted: false, - id: 'Price-ETH/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x5134EAF08bcf8cE1922991150AAad1774e93751f', - network: 'metis-rinkeby', - networkName: 'Metis Rinkeby', - chain: 'Metis', - name: 'eth/usd', - label: '$', - pollingPeriod: 15000, - color: '#ff6600', - blockExplorer: 'https://stardust-explorer.metis.io/address/{address}', - deviation: '1', - heartbeat: '86400000', - finality: '900000', - }, - { - feedFullName: 'metis-mainnet_metis-usdt_6', - isRouted: false, - id: 'Price-METIS/USDT-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0xD39D4d972C7E166856c4eb29E54D3548B4597F53', - network: 'metis-mainnet', - networkName: 'Metis Mainnet', - chain: 'Metis', - name: 'metis/usdt', - label: '₮', - pollingPeriod: 15000, - color: '#ff6600', - blockExplorer: 'https://andromeda-explorer.metis.io/address/{address}', - deviation: '2', - heartbeat: '86400000', - finality: '900000', - }, - { - feedFullName: 'polygon-goerli_btc-usd_6', - isRouted: false, - id: 'Price-BTC/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x6d5544ca5b35bf2e7a78ace4E7B8d191fe5C9FAb', - network: 'polygon-goerli', - networkName: 'Polygon Mumbai', - chain: 'Polygon', - name: 'btc/usd', - label: '$', - pollingPeriod: 15000, - color: '#66ff00', - blockExplorer: 'https://mumbai.polygonscan.com/address/{address}', - deviation: '3.5', - heartbeat: '86400000', - finality: '900000', - }, - { - feedFullName: 'polygon-goerli_eth-usd_6', - isRouted: false, - id: 'Price-ETH/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x6d5544ca5b35bf2e7a78ace4E7B8d191fe5C9FAb', - network: 'polygon-goerli', - networkName: 'Polygon Mumbai', - chain: 'Polygon', - name: 'eth/usd', - label: '$', - pollingPeriod: 15000, - color: '#66ff00', - blockExplorer: 'https://mumbai.polygonscan.com/address/{address}', - deviation: '3.5', - heartbeat: '86400000', - finality: '900000', - }, - { - feedFullName: 'polygon-mainnet_btc-usd_6', - isRouted: false, - id: 'Price-BTC/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x3806311c7138ddF2bAF2C2093ff3633E5A73AbD4', - network: 'polygon-mainnet', - networkName: 'Polygon Mainnet', - chain: 'Polygon', - name: 'btc/usd', - label: '$', - pollingPeriod: 15000, - color: '#66ff00', - blockExplorer: 'https://polygonscan.com/address/{address}', - deviation: '1', - heartbeat: '86400000', - finality: '900000', - }, - { - feedFullName: 'polygon-mainnet_eth-usd_6', - isRouted: false, - id: 'Price-ETH/USD-6', - address: '0x0000000000000000000000000000000000000000', - contractId: '0x0000000000000000000000000000000000000000', - routerAddress: '0x3806311c7138ddF2bAF2C2093ff3633E5A73AbD4', - network: 'polygon-mainnet', - networkName: 'Polygon Mainnet', - chain: 'Polygon', - name: 'eth/usd', - label: '$', - pollingPeriod: 15000, - color: '#66ff00', - blockExplorer: 'https://polygonscan.com/address/{address}', - deviation: '1', - heartbeat: '86400000', - finality: '900000', - }, - ] - - expect(feeds).toStrictEqual(expected) - }) -}) diff --git a/packages/api/test/web3Middleware/configuration/baseConfigurationFile.ts b/packages/api/test/web3Middleware/configuration/baseConfigurationFile.ts index e45a3d0d..2ee903c0 100644 --- a/packages/api/test/web3Middleware/configuration/baseConfigurationFile.ts +++ b/packages/api/test/web3Middleware/configuration/baseConfigurationFile.ts @@ -1,9 +1,5 @@ export const baseConfigurationFile = { contracts: { - legacy: { - abi: './src/abi/WitnetPriceRouter.json', - pollingPeriod: 120000, - }, '2.0': { abi: './src/abi/WitnetPriceFeeds.json', address: '0x0000000000000000000000000000000000000000', diff --git a/packages/api/test/web3Middleware/configuration/getFeedConfiguration.spec.ts b/packages/api/test/web3Middleware/configuration/getFeedConfiguration.spec.ts index 4ba4d5b5..bfd55f18 100644 --- a/packages/api/test/web3Middleware/configuration/getFeedConfiguration.spec.ts +++ b/packages/api/test/web3Middleware/configuration/getFeedConfiguration.spec.ts @@ -3,10 +3,6 @@ import { Configuration } from '../../../src/web3Middleware/Configuration' const configurationFile: RouterDataFeedsConfig = { contracts: { - legacy: { - abi: './src/abi/WitnetPriceRouter.json', - pollingPeriod: 120000, - }, '2.0': { abi: './src/abi/WitnetPriceFeeds.json', address: '0x1111AbA2164AcdC6D291b08DfB374280035E1111', @@ -61,7 +57,7 @@ const configurationFile: RouterDataFeedsConfig = { name: 'Avalanche', networks: { 'avalanche.mainnet': { - version: 'legacy', + version: '2.0', mainnet: true, address: '0xBaaF31F4AAc5ab5334b6E239a83bf4E855C55ea7', blockExplorer: 'https://snowtrace.io/address/{address}', @@ -98,7 +94,7 @@ const configurationFile: RouterDataFeedsConfig = { name: 'Boba', networks: { 'boba.ethereum.mainnet': { - version: 'legacy', + version: '2.0', mainnet: true, address: '0x93f61D0D5F623144e7C390415B70102A9Cc90bA5', blockExplorer: 'https://blockexplorer.boba.network/address/{address}', diff --git a/packages/api/test/web3Middleware/configuration/getFeedCurrencySymbol.spec.ts b/packages/api/test/web3Middleware/configuration/getFeedCurrencySymbol.spec.ts index bad49ca0..297fb6d4 100644 --- a/packages/api/test/web3Middleware/configuration/getFeedCurrencySymbol.spec.ts +++ b/packages/api/test/web3Middleware/configuration/getFeedCurrencySymbol.spec.ts @@ -3,10 +3,6 @@ import { Configuration } from '../../../src/web3Middleware/Configuration' const configurationFile: RouterDataFeedsConfig = { contracts: { - legacy: { - abi: './src/abi/WitnetPriceRouter.json', - pollingPeriod: 120000, - }, '2.0': { abi: './src/abi/WitnetPriceFeeds.json', address: '0x1111AbA2164AcdC6D291b08DfB374280035E1111', @@ -63,7 +59,7 @@ const configurationFile: RouterDataFeedsConfig = { name: 'Avalanche', networks: { 'avalanche.mainnet': { - version: 'legacy', + version: '2.0', mainnet: true, address: '0xBaaF31F4AAc5ab5334b6E239a83bf4E855C55ea7', blockExplorer: 'https://snowtrace.io/address/{address}', @@ -101,7 +97,7 @@ const configurationFile: RouterDataFeedsConfig = { name: 'Boba', networks: { 'boba.ethereum.mainnet': { - version: 'legacy', + version: '2.0', mainnet: true, address: '0x93f61D0D5F623144e7C390415B70102A9Cc90bA5', blockExplorer: 'https://blockexplorer.boba.network/address/{address}', diff --git a/packages/api/test/web3Middleware/configuration/getLegacyConfigurationFile.spec.ts b/packages/api/test/web3Middleware/configuration/getLegacyConfigurationFile.spec.ts deleted file mode 100644 index 0ce8bfa3..00000000 --- a/packages/api/test/web3Middleware/configuration/getLegacyConfigurationFile.spec.ts +++ /dev/null @@ -1,191 +0,0 @@ -import { Configuration } from '../../../src/web3Middleware/Configuration' -import { RouterDataFeedsConfig } from '../../../types' - -const configurationFile: RouterDataFeedsConfig = { - contracts: { - legacy: { - abi: './src/abi/WitnetPriceRouter.json', - pollingPeriod: 120000, - }, - '2.0': { - abi: './src/abi/WitnetPriceFeeds.json', - address: '0x0000000000000000000000000000000000000000', - pollingPeriod: 120000, - }, - }, - currencies: { - EUR: '€', - KRW: '₩', - USD: '$', - USDC: '$', - USDT: '₮', - }, - chains: { - arbitrum: { - name: 'Arbitrum', - networks: { - 'arbitrum.one': { - version: '2.0', - blockExplorer: 'https://arbiscan.io/address/{address}', - color: '#E84142', - mainnet: true, - name: 'Arbitrum ONE', - feeds: { - 'Price-ETH/USD-6': { - label: '$', - deviationPercentage: 3.5, - maxSecsBetweenUpdates: 86400, - minSecsBetweenUpdates: 900, - }, - }, - }, - 'arbitrum.goerli': { - version: '2.0', - address: '0x9999999d139bdBFbF25923ba39F63bBFc7593400', - blockExplorer: 'https://goerli.arbiscan.io/address/{address}', - color: '#E84142', - name: 'Arbitrum Nitro Goerli', - pollingPeriod: 120000, - feeds: { - 'Price-ETH/USD-6': { - label: '$', - deviationPercentage: 3.5, - maxSecsBetweenUpdates: 86400, - minSecsBetweenUpdates: 900, - }, - }, - }, - }, - }, - avalanche: { - name: 'Avalanche', - networks: { - 'avalanche.mainnet': { - version: 'legacy', - mainnet: true, - address: '0xBaaF31F4AAc5ab5334b6E239a83bf4E855C55ea7', - blockExplorer: 'https://snowtrace.io/address/{address}', - color: '#070fdf', - name: 'Avalanche Mainnet', - pollingPeriod: 120000, - feeds: { - 'Price-ETH/USD-6': { - label: '$', - deviationPercentage: 3.5, - maxSecsBetweenUpdates: 86400, - minSecsBetweenUpdates: 900, - }, - }, - }, - 'avalanche.fuji': { - version: '2.0', - address: '0x9999999d139bdBFbF25923ba39F63bBFc7593400', - blockExplorer: 'https://testnet.snowtrace.io/address/{address}', - color: '#E84142', - name: 'Avalanche Fuji', - feeds: { - 'Price-ETH/USD-6': { - deviationPercentage: 3.5, - maxSecsBetweenUpdates: 86400, - minSecsBetweenUpdates: 900, - }, - }, - }, - }, - }, - boba: { - name: 'Boba', - networks: { - 'boba.ethereum.mainnet': { - version: 'legacy', - mainnet: true, - address: '0x93f61D0D5F623144e7C390415B70102A9Cc90bA5', - blockExplorer: 'https://blockexplorer.boba.network/address/{address}', - color: '#007dff', - name: 'Boba ETH/L2 Mainnet', - pollingPeriod: 120000, - feeds: { - 'Price-ETH/USD-6': { - label: '$', - deviationPercentage: 3.5, - maxSecsBetweenUpdates: 86400, - minSecsBetweenUpdates: 900, - }, - }, - }, - }, - }, - }, - conditions: { - default: { - deviationPercentage: 3.5, - maxSecsBetweenUpdates: 86400, - minSecsBetweenUpdates: 3600, - }, - 'Price-ETH/USD-6': { - deviationPercentage: 10, - maxSecsBetweenUpdates: 86400, - minSecsBetweenUpdates: 900, - }, - }, -} - -describe('getLegacyConfigurationFile', () => { - it('should return only networks using the legacy contract', () => { - const configuration = new Configuration(configurationFile) - const result = configuration.getLegacyConfigurationFile() - - const expected = { - abi: './src/abi/WitnetPriceRouter.json', - chains: { - avalanche: { - name: 'Avalanche', - networks: { - 'avalanche.mainnet': { - address: '0xBaaF31F4AAc5ab5334b6E239a83bf4E855C55ea7', - blockExplorer: 'https://snowtrace.io/address/{address}', - color: '#070fdf', - feeds: { - 'Price-ETH/USD-6': { - deviationPercentage: 3.5, - label: '$', - maxSecsBetweenUpdates: 86400, - minSecsBetweenUpdates: 900, - }, - }, - version: 'legacy', - mainnet: true, - name: 'Avalanche Mainnet', - pollingPeriod: 120000, - }, - }, - }, - boba: { - name: 'Boba', - networks: { - 'boba.ethereum.mainnet': { - address: '0x93f61D0D5F623144e7C390415B70102A9Cc90bA5', - blockExplorer: - 'https://blockexplorer.boba.network/address/{address}', - color: '#007dff', - feeds: { - 'Price-ETH/USD-6': { - deviationPercentage: 3.5, - label: '$', - maxSecsBetweenUpdates: 86400, - minSecsBetweenUpdates: 900, - }, - }, - version: 'legacy', - mainnet: true, - name: 'Boba ETH/L2 Mainnet', - pollingPeriod: 120000, - }, - }, - }, - }, - } - - expect(result).toStrictEqual(expected) - }) -}) diff --git a/packages/api/test/web3Middleware/configuration/getNetworkConfiguration.spec.ts b/packages/api/test/web3Middleware/configuration/getNetworkConfiguration.spec.ts index 93c0c2b7..3b9d788e 100644 --- a/packages/api/test/web3Middleware/configuration/getNetworkConfiguration.spec.ts +++ b/packages/api/test/web3Middleware/configuration/getNetworkConfiguration.spec.ts @@ -6,10 +6,6 @@ describe('getNetworkConfiguration', () => { it('complete', () => { const configurationFile: RouterDataFeedsConfig = { contracts: { - legacy: { - abi: './src/abi/WitnetPriceRouter.json', - pollingPeriod: 120000, - }, '2.0': { abi: './src/abi/WitnetPriceFeeds.json', address: '0x1111AbA2164AcdC6D291b08DfB374280035E1111', @@ -66,7 +62,7 @@ describe('getNetworkConfiguration', () => { name: 'Avalanche', networks: { 'avalanche.mainnet': { - version: 'legacy', + version: '2.0', mainnet: true, address: '0xBaaF31F4AAc5ab5334b6E239a83bf4E855C55ea7', blockExplorer: 'https://snowtrace.io/address/{address}', @@ -103,7 +99,7 @@ describe('getNetworkConfiguration', () => { name: 'Boba', networks: { 'boba.ethereum.mainnet': { - version: 'legacy', + version: '2.0', mainnet: true, address: '0x93f61D0D5F623144e7C390415B70102A9Cc90bA5', blockExplorer: diff --git a/packages/api/test/web3Middleware/configuration/listNetworksUsingPriceFeedsContract.spec.ts b/packages/api/test/web3Middleware/configuration/listNetworksUsingPriceFeedsContract.spec.ts index becc5031..73148d25 100644 --- a/packages/api/test/web3Middleware/configuration/listNetworksUsingPriceFeedsContract.spec.ts +++ b/packages/api/test/web3Middleware/configuration/listNetworksUsingPriceFeedsContract.spec.ts @@ -6,10 +6,6 @@ describe('listNetworksUsingPriceFeedsContract', () => { it('Full file', () => { const configurationFile = { contracts: { - legacy: { - abi: './src/abi/WitnetPriceRouter.json', - pollingPeriod: 120000, - }, '2.0': { abi: './src/abi/WitnetPriceFeeds.json', address: '0x0000000000000000000000000000000000000000', @@ -64,7 +60,7 @@ describe('listNetworksUsingPriceFeedsContract', () => { name: 'Avalanche', networks: { 'avalanche.mainnet': { - version: 'legacy', + version: '2.0', mainnet: true, address: '0xBaaF31F4AAc5ab5334b6E239a83bf4E855C55ea7', blockExplorer: 'https://snowtrace.io/address/{address}', @@ -100,7 +96,7 @@ describe('listNetworksUsingPriceFeedsContract', () => { name: 'Boba', networks: { 'boba.ethereum.mainnet': { - version: 'legacy', + version: '2.0', mainnet: true, address: '0x93f61D0D5F623144e7C390415B70102A9Cc90bA5', blockExplorer: @@ -147,6 +143,14 @@ describe('listNetworksUsingPriceFeedsContract', () => { pollingPeriod: 120000, provider: 'provider-arbitrum-goerli', }, + { + address: '0xBaaF31F4AAc5ab5334b6E239a83bf4E855C55ea7', + chain: 'Avalanche', + key: 'avalanche-mainnet', + networkName: 'Avalanche Mainnet', + pollingPeriod: 120000, + provider: 'provider-avalanche-mainnet', + }, { address: '0x9999999d139bdBFbF25923ba39F63bBFc7593400', chain: 'Avalanche', @@ -155,6 +159,14 @@ describe('listNetworksUsingPriceFeedsContract', () => { pollingPeriod: 120000, provider: 'provider-avalanche-fuji', }, + { + address: '0x93f61D0D5F623144e7C390415B70102A9Cc90bA5', + chain: 'Boba', + key: 'boba-ethereum-mainnet', + networkName: 'Boba ETH/L2 Mainnet', + pollingPeriod: 120000, + provider: 'provider-boba-ethereum-mainnet', + }, ] expect(result).toStrictEqual(expected) diff --git a/packages/api/test/web3Middleware/dataFeedsRouter.json b/packages/api/test/web3Middleware/dataFeedsRouter.json index 208f04a1..3264c741 100644 --- a/packages/api/test/web3Middleware/dataFeedsRouter.json +++ b/packages/api/test/web3Middleware/dataFeedsRouter.json @@ -1,9 +1,5 @@ { "contracts": { - "legacy": { - "abi": "./src/abi/WitnetPriceRouter.json", - "pollingPeriod": 120000 - }, "2.0": { "abi": "./src/abi/WitnetPriceFeeds.json", "address": "0x1111AbA2164AcdC6D291b08DfB374280035E1111", diff --git a/packages/api/test/web3Middleware/index.spec.ts b/packages/api/test/web3Middleware/index.spec.ts index 601deab8..d8370808 100644 --- a/packages/api/test/web3Middleware/index.spec.ts +++ b/packages/api/test/web3Middleware/index.spec.ts @@ -1,17 +1,14 @@ // FIXME: create a proper mock for web3 import Web3 from 'web3' -import { FeedInfo, Db, RouterDataFeedsConfig } from '../../types' +import { Db, RouterDataFeedsConfig } from '../../types' import { FeedRepository } from '../../src/repository/Feed' import { ResultRequestRepository } from '../../src/repository/ResultRequest' import { Web3Middleware } from '../../src/web3Middleware/index' -import { normalizeConfig } from '../../src/utils' import dataFeedsRouter from './dataFeedsRouter.json' import { ObjectId } from 'mongodb' import { Configuration } from '../../src/web3Middleware/Configuration' import { FeedsState } from '../../src/repository/feedState' -const dataFeeds = normalizeConfig(dataFeedsRouter as RouterDataFeedsConfig) - jest.mock('../../src/repository/Feed') jest.mock('../../src/repository/ResultRequest') @@ -71,7 +68,6 @@ beforeEach(() => { describe.skip('web3Middleware', () => { it('should read the state of each datafeed provided', async () => { const feedState = new FeedsState() - const feedInfos: Array = [dataFeeds[0] as FeedInfo] const resultRequestRepository = new ResultRequestRepository( '' as unknown as Db, ) @@ -92,14 +88,10 @@ describe.skip('web3Middleware', () => { const configuration = new Configuration( dataFeedsRouter as RouterDataFeedsConfig, ) - const middleware = new Web3Middleware( - configuration, - { - repositories: { feedRepository, resultRequestRepository }, - Web3: Web3Mock, - }, - feedInfos, - ) + const middleware = new Web3Middleware(configuration, { + repositories: { feedRepository, resultRequestRepository }, + Web3: Web3Mock, + }) await middleware.listen() await new Promise((resolve) => setTimeout(() => resolve(''), 1000)) middleware.stop() diff --git a/packages/api/types.ts b/packages/api/types.ts index 317e63f2..58ac32a5 100644 --- a/packages/api/types.ts +++ b/packages/api/types.ts @@ -134,18 +134,11 @@ export type NetworksConfig = { export type FeedInfo = FeedInfoGeneric> -export type FeedInfoConfig = FeedInfoGeneric - export type PaginatedFeedsObject = { feeds: Array total: number } -export type ContractInfo = { - contractAddress: string - contractId: string -} - export type ResultRequestDbObjectNormalized = ResultRequestDbObject & { id: string } @@ -155,22 +148,6 @@ export type Repositories = { resultRequestRepository: ResultRequestRepository } -export type ContractsState = { - lastPrice: string - lastTimestamp: string - lastDrTxHash: string - requestId: string -} - -export type LastResponse = { - timestamp: string - drTxHash: string -} - -export type Contracts = { - feedContract: any -} - export type FeedInfoRouterConfigMap = { [key: string]: FeedParamsConfig } @@ -183,18 +160,8 @@ export type FeedParamsConfig = { minSecsBetweenUpdates?: number } -export type FeedParsedParams = { - label: string - isRouted?: boolean - deviationPercentage?: number - maxSecsBetweenUpdates?: number - minSecsBetweenUpdates?: number - key: string - chain: string -} - export type FeedConfig = { - version?: 'legacy' | '2.0' + version?: '2.0' address?: string blockExplorer: string blockProvider?: string @@ -206,32 +173,14 @@ export type FeedConfig = { feeds?: FeedInfoRouterConfigMap } -export type ExtendedFeedConfig = { - address: string - blockExplorer: string - color: string - name: string - chain: string - hide: boolean - network: string - pollingPeriod: number - feeds: FeedInfoRouterConfigMap -} - export type Chain = { name: string hide?: boolean networks: Record } -export type NetworkConfigMap = Record - export type RouterDataFeedsConfig = { contracts: { - legacy: { - abi: string - pollingPeriod: number - } '2.0': { abi: string address: string @@ -248,12 +197,3 @@ export type RouterDataFeedsConfig = { } currencies: Record } - -export type LegacyRouterDataFeedsConfig = { - abi: string - chains: Record -} - -export type FeedInfosWithoutAbis = Array< - Omit ->