From 7ee690a7427d7bf2734a40f46d735486f8bbcd03 Mon Sep 17 00:00:00 2001 From: gabaldon Date: Fri, 23 Feb 2024 12:44:52 +0100 Subject: [PATCH] fix(style): lint changes --- packages/api/readme.md | 2 +- packages/api/src/dataFeedsRouter.json | 7 +- packages/api/src/index.ts | 23 +- packages/api/src/repository/ResultRequest.ts | 23 +- packages/api/src/types.ts | 4 +- .../api/src/web3Middleware/Configuration.ts | 80 +++-- .../api/src/web3Middleware/NetworkRouter.ts | 131 +++++--- packages/api/src/web3Middleware/PriceFeed.ts | 25 +- packages/api/src/web3Middleware/index.ts | 38 ++- .../test/web3Middleware/configuration.spec.ts | 314 ++++++++++-------- .../test/web3Middleware/dataFeedsRouter.json | 12 - .../test/web3Middleware/networkRouter.spec.ts | 19 +- packages/ui/components/Main.vue | 243 -------------- 13 files changed, 363 insertions(+), 558 deletions(-) delete mode 100644 packages/ui/components/Main.vue diff --git a/packages/api/readme.md b/packages/api/readme.md index 8ac16473..2046f79c 100644 --- a/packages/api/readme.md +++ b/packages/api/readme.md @@ -1 +1 @@ -# Data Feeds Explorer Api +# Data Feeds Explorer Api diff --git a/packages/api/src/dataFeedsRouter.json b/packages/api/src/dataFeedsRouter.json index e393f96f..265e70fe 100644 --- a/packages/api/src/dataFeedsRouter.json +++ b/packages/api/src/dataFeedsRouter.json @@ -1438,9 +1438,7 @@ "color": "#66ff00", "name": "Optimism Goerli (testnet)", "pollingPeriod": 120000, - "feeds": { - - } + "feeds": {} }, "optimism.mainnet": { "legacy": true, @@ -1774,8 +1772,7 @@ "color": "#66ff00", "name": "Syscoin Rollux Testnet", "pollingPeriod": 90000, - "feeds": { - } + "feeds": {} } } }, diff --git a/packages/api/src/index.ts b/packages/api/src/index.ts index b223fc68..dda05eaa 100644 --- a/packages/api/src/index.ts +++ b/packages/api/src/index.ts @@ -5,7 +5,12 @@ import { MongoManager } from './database' import { FeedRepository } from './repository/Feed' import { ResultRequestRepository } from './repository/ResultRequest' import { createServer } from './server' -import { RouterDataFeedsConfig, Repositories, FeedInfo, NetworksConfig } from './types' +import { + RouterDataFeedsConfig, + Repositories, + FeedInfo, + NetworksConfig +} from './types' import { Web3Middleware } from './web3Middleware/index' import { normalizeNetworkConfig } from './utils/index' import { @@ -23,7 +28,9 @@ async function main () { const configurationFile: RouterDataFeedsConfig = await fetchDataFeedsRouterConfig() const configuration = new Configuration(configurationFile) - const legacyFeeds: Array = normalizeAndValidateDataFeedConfig(configurationFile) + const legacyFeeds: Array = normalizeAndValidateDataFeedConfig( + configurationFile + ) const networksConfigPartial: Array { if (!config.provider) { - console.warn("No provider found for ", config.key) + console.warn('No provider found for ', config.key) } return config.provider }) - .map(networkInfo => new NetworkRouter(configuration, repositories, networkInfo)) - + .map( + networkInfo => new NetworkRouter(configuration, repositories, networkInfo) + ) const newFeeds: Array = [] @@ -71,7 +80,7 @@ async function main () { const web3Middleware = new Web3Middleware( configuration, { repositories, Web3: Web3 }, - legacyFeeds, + legacyFeeds ) web3Middleware.listen() diff --git a/packages/api/src/repository/ResultRequest.ts b/packages/api/src/repository/ResultRequest.ts index e0815bdb..1e1c4d0e 100644 --- a/packages/api/src/repository/ResultRequest.ts +++ b/packages/api/src/repository/ResultRequest.ts @@ -66,13 +66,10 @@ export class ResultRequestRepository { async getLastResult ( feedFullName: string ): Promise { - const lastResultRequest = await this.collection.findOne( - { - feedFullName - }, - { - sort: { - timestamp: -1 + const lastResultRequest = await this.collection + .findOne( + { + feedFullName }, { sort: { @@ -83,11 +80,11 @@ export class ResultRequestRepository { numericOrdering: true } } - } - ).catch(e => { - console.log(`Error in getLastResult: ${feedFullName}`, e) - return null - }) + ) + .catch(e => { + console.log(`Error in getLastResult: ${feedFullName}`, e) + return null + }) return this.normalizeId(lastResultRequest) } @@ -113,7 +110,6 @@ export class ResultRequestRepository { async insertIfLatest ( resultRequest: WithoutId ): Promise { - let storedResult = this.latestResults[resultRequest.feedFullName] if (!storedResult) { storedResult = await this.getLastResult(resultRequest.feedFullName) @@ -132,7 +128,6 @@ export class ResultRequestRepository { } } - private normalizeId ( resultRequest: ResultRequestDbObject ): ResultRequestDbObjectNormalized | null { diff --git a/packages/api/src/types.ts b/packages/api/src/types.ts index 0337f94c..f15c6d95 100644 --- a/packages/api/src/types.ts +++ b/packages/api/src/types.ts @@ -42,7 +42,7 @@ export type ConfigByFullName = { } export enum Network { - ArbitrumOne = 'arbitrum-one' , + ArbitrumOne = 'arbitrum-one', ArbitrumGoerli = 'arbitrum-goerli', AvalancheMainnet = 'avalanche-mainnet', AvalancheFuji = 'avalanche-fuji', @@ -195,7 +195,7 @@ export type FeedParsedParams = { } export type FeedConfig = { - legacy?: boolean, + legacy?: boolean address: string blockExplorer: string hide?: boolean diff --git a/packages/api/src/web3Middleware/Configuration.ts b/packages/api/src/web3Middleware/Configuration.ts index 903074ff..74df972b 100644 --- a/packages/api/src/web3Middleware/Configuration.ts +++ b/packages/api/src/web3Middleware/Configuration.ts @@ -1,12 +1,17 @@ -import { FeedParamsConfig, Network, NetworksConfig, RouterDataFeedsConfig } from "../types"; -import { getNetworksListByChain, sortAlphabeticallyByLabel } from "../utils"; -import { NetworkInfo } from "./NetworkRouter"; -import { getProvider } from "./provider"; +import { + FeedParamsConfig, + Network, + NetworksConfig, + RouterDataFeedsConfig +} from '../types' +import { getNetworksListByChain, sortAlphabeticallyByLabel } from '../utils' +import { NetworkInfo } from './NetworkRouter' +import { getProvider } from './provider' export class Configuration { private configurationFile: RouterDataFeedsConfig - constructor(json: RouterDataFeedsConfig) { + constructor (json: RouterDataFeedsConfig) { this.configurationFile = json } @@ -35,65 +40,80 @@ export class Configuration { } // return networks using the new price feeds router contract - public listNetworksUsingPriceFeedsContract(): Array { + public listNetworksUsingPriceFeedsContract (): Array { return Object.values(this.configurationFile.chains) .flatMap(chain => Object.entries(chain.networks)) - .filter(([_, network])=> network.legacy === false) + .filter(([_, network]) => network.legacy === false) .map(([networkKey, network]) => { return { provider: getProvider(networkKey.replaceAll('.', '-') as Network), address: network.address, pollingPeriod: network.pollingPeriod, key: this.fromNetworkKeyToNetwork(networkKey), - networkName: network.name, + networkName: network.name } }) } - public getLegacyConfigurationFile(): RouterDataFeedsConfig { - const chains = Object.entries(this.configurationFile.chains).reduce((acc, [chainKey, chain]) => { - - if (chain.hide) { - return acc - } - - const networks = Object.entries(chain.networks).reduce((accNetworks, [networkKey, network]) => { - // add the network entry if it's legacy - return network.legacy ? { ...accNetworks, [networkKey]: network } : accNetworks; - }, {}) + public getLegacyConfigurationFile (): RouterDataFeedsConfig { + const chains = Object.entries(this.configurationFile.chains).reduce( + (acc, [chainKey, chain]) => { + if (chain.hide) { + return acc + } - return Object.keys(networks).length > 0 ? { ...acc, [chainKey]: { ...chain, networks } } : acc - }, {}) + const networks = Object.entries(chain.networks).reduce( + (accNetworks, [networkKey, network]) => { + // add the network entry if it's legacy + return network.legacy + ? { ...accNetworks, [networkKey]: network } + : accNetworks + }, + {} + ) + + return Object.keys(networks).length > 0 + ? { ...acc, [chainKey]: { ...chain, networks } } + : acc + }, + {} + ) return { ...this.configurationFile, - chains, + chains } } - public getFeedConfiguration(priceFeedName: string, network: Network): FeedParamsConfig { + public getFeedConfiguration ( + priceFeedName: string, + network: Network + ): FeedParamsConfig { const defaultFeed = this.configurationFile.feeds[priceFeedName] - const specificFeedConfiguration = this.getNetworkConfiguration(network).feeds[priceFeedName] + const specificFeedConfiguration = this.getNetworkConfiguration(network) + .feeds[priceFeedName] return { ...defaultFeed, ...specificFeedConfiguration } } - public isFeedActive(caption: string): boolean { + public isFeedActive (caption: string): boolean { return Object.keys(this.configurationFile.feeds).includes(caption) } - public getNetworkConfiguration(network: Network) { - return this.configurationFile.chains[getChain(network)].networks[networkToKey(network)] + public getNetworkConfiguration (network: Network) { + return this.configurationFile.chains[getChain(network)].networks[ + networkToKey(network) + ] } - private fromNetworkKeyToNetwork(networkKey: string): Network { + private fromNetworkKeyToNetwork (networkKey: string): Network { return networkKey.replace('.', '-') as Network } } -export function getChain(network: Network) { +export function getChain (network: Network) { return network.split('-')[0] } -export function networkToKey(network: Network) { +export function networkToKey (network: Network) { return network.replaceAll('-', '.') } diff --git a/packages/api/src/web3Middleware/NetworkRouter.ts b/packages/api/src/web3Middleware/NetworkRouter.ts index c51cc497..166718d9 100644 --- a/packages/api/src/web3Middleware/NetworkRouter.ts +++ b/packages/api/src/web3Middleware/NetworkRouter.ts @@ -1,11 +1,10 @@ -import Web3 from "web3" +import Web3 from 'web3' import WitnetPriceFeedsABI from './../abi/WitnetPriceFeeds.json' -import { FeedInfo, Network, Repositories } from "./../types" -import { toHex } from "web3-utils" -import { createFeedFullName } from "../utils" -import { PriceFeed } from "./PriceFeed" -import { Configuration } from "./Configuration" - +import { FeedInfo, Network, Repositories } from './../types' +import { toHex } from 'web3-utils' +import { createFeedFullName } from '../utils' +import { PriceFeed } from './PriceFeed' +import { Configuration } from './Configuration' enum ResultStatus { Void = 0, @@ -17,27 +16,27 @@ enum ResultStatus { } export type SupportedFeed = { - id: string, + id: string caption: string solver: string } type LatestPrice = { - value: string, - timestamp: string, - tallyHash: string, - status: ResultStatus + value: string + timestamp: string + tallyHash: string + status: ResultStatus } export type NetworkInfo = { - provider: string, - address: string, - pollingPeriod: number, - key: Network, + provider: string + address: string + pollingPeriod: number + key: Network networkName: string } export type NetworkSnapshot = { - network: string, + network: string feeds: Array } @@ -46,24 +45,28 @@ export class NetworkRouter { public network: Network public networkName: string public pollingPeriod: number - public feeds?: Array<{ name: string; }> + public feeds?: Array<{ name: string }> public repositories: Repositories private address: string private configuration: Configuration private provider: string - - constructor(configuration: Configuration, repositories: Repositories, networkInfo: NetworkInfo) { + constructor ( + configuration: Configuration, + repositories: Repositories, + networkInfo: NetworkInfo + ) { const { provider, address, pollingPeriod, key } = networkInfo if (!provider) { throw new Error(`Missing provider for ${name}`) } - const web3 = new Web3(new Web3.providers.HttpProvider(provider, { timeout: 30000 })) + const web3 = new Web3( + new Web3.providers.HttpProvider(provider, { timeout: 30000 }) + ) // TODO: why this type isn't working? - this.contract = new web3.eth.Contract( WitnetPriceFeedsABI as any, address) - this.pollingPeriod = pollingPeriod, - this.repositories = repositories + this.contract = new web3.eth.Contract(WitnetPriceFeedsABI as any, address) + ;(this.pollingPeriod = pollingPeriod), (this.repositories = repositories) this.network = key this.configuration = configuration this.provider = provider @@ -71,25 +74,33 @@ export class NetworkRouter { } // Periodically fetch the price feed router contract and store it in mongodb - public listen() { + public listen () { setInterval(async () => { const snapshot = await this.getSnapshot() - const insertPromises = snapshot.feeds.filter(feed => feed.status !== ResultStatus.Ready).map((feed) => ({ - feedFullName: createFeedFullName(this.network, feed.caption, feed.caption.split("-").reverse()[0]), - drTxHash: toHex(feed.tallyHash).slice(2), - requestId: feed.id, - result: feed.value, - timestamp: feed.timestamp - })) - .map(resultRequest =>{ - return this.repositories.resultRequestRepository.insertIfLatest(resultRequest) - }) + const insertPromises = snapshot.feeds + .filter(feed => feed.status !== ResultStatus.Ready) + .map(feed => ({ + feedFullName: createFeedFullName( + this.network, + feed.caption, + feed.caption.split('-').reverse()[0] + ), + drTxHash: toHex(feed.tallyHash).slice(2), + requestId: feed.id, + result: feed.value, + timestamp: feed.timestamp + })) + .map(resultRequest => { + return this.repositories.resultRequestRepository.insertIfLatest( + resultRequest + ) + }) Promise.all(insertPromises) }, this.pollingPeriod) } - async getSnapshot(): Promise { + async getSnapshot (): Promise { const supportedFeeds = await this.getSupportedFeeds() const feedIds = supportedFeeds.map(feed => feed.id) const latestPrices = await this.latestPrices(feedIds) @@ -103,23 +114,27 @@ export class NetworkRouter { } } - async getFeedInfos(): Promise> { + async getFeedInfos (): Promise> { const suppoortedFeeds = await this.getSupportedFeeds() - return suppoortedFeeds.map((supportedFeed)=> { - if (!this.configuration.isFeedActive(supportedFeed.caption)) { - console.log(`${supportedFeed.caption} in ${this.network} is deprecated`) - return null - } - const res = PriceFeed.fromWitnetPriceFeedsContract( - this.configuration, - supportedFeed, - this.address, - this.network, - this.networkName, - ).toJson() - return res - }).filter(x => !!x) + return suppoortedFeeds + .map(supportedFeed => { + if (!this.configuration.isFeedActive(supportedFeed.caption)) { + console.log( + `${supportedFeed.caption} in ${this.network} is deprecated` + ) + return null + } + const res = PriceFeed.fromWitnetPriceFeedsContract( + this.configuration, + supportedFeed, + this.address, + this.network, + this.networkName + ).toJson() + return res + }) + .filter(x => !!x) } // Wrap supportedFeeds contract method @@ -129,10 +144,13 @@ export class NetworkRouter { return supportedFeeds._ids.map((_, index) => ({ id: supportedFeeds._ids[index], caption: supportedFeeds._captions[index], - solver: supportedFeeds._solvers[index], + solver: supportedFeeds._solvers[index] })) } catch (e) { - console.log(`Error in getSupportedFeeds \n\tnetwork: ${this.network}\n\tprovider: ${this.provider}\n\taddress: ${this.address}\n\tError:`, e) + console.log( + `Error in getSupportedFeeds \n\tnetwork: ${this.network}\n\tprovider: ${this.provider}\n\taddress: ${this.address}\n\tError:`, + e + ) return [] } } @@ -148,8 +166,11 @@ export class NetworkRouter { status: Number(latestPrice.status) })) } catch (e) { - console.log(`Error in latestPrices\n\tnetwork: ${this.network}\n\tprovider: ${this.provider}\n\taddress: ${this.address}\n\tError:`, e) + console.log( + `Error in latestPrices\n\tnetwork: ${this.network}\n\tprovider: ${this.provider}\n\taddress: ${this.address}\n\tError:`, + e + ) return [] } } - } +} diff --git a/packages/api/src/web3Middleware/PriceFeed.ts b/packages/api/src/web3Middleware/PriceFeed.ts index 16a98f03..350ba372 100644 --- a/packages/api/src/web3Middleware/PriceFeed.ts +++ b/packages/api/src/web3Middleware/PriceFeed.ts @@ -1,8 +1,8 @@ -import { AbiItem, FeedInfo, Network } from "../types"; -import { SupportedFeed } from "./NetworkRouter"; +import { AbiItem, FeedInfo, Network } from '../types' +import { SupportedFeed } from './NetworkRouter' import WitnetPriceFeedsABI from './../abi/WitnetPriceFeeds.json' -import { createFeedFullName } from "../utils"; -import { Configuration, getChain } from "./Configuration"; +import { createFeedFullName } from '../utils' +import { Configuration, getChain } from './Configuration' export class PriceFeed { feedFullName: string @@ -25,11 +25,7 @@ export class PriceFeed { configuration: Configuration networkName: string -<<<<<<< HEAD - constructor(configuration: Configuration, args: FeedInfo) { -======= constructor (configuration: Configuration, args: FeedInfo) { ->>>>>>> 6c74911 (feat: migrate ui package to nuxt3) this.configuration = configuration this.feedFullName = args.feedFullName this.id = args.id @@ -51,7 +47,7 @@ export class PriceFeed { this.networkName = args.networkName } - toJson(): FeedInfo { + toJson (): FeedInfo { return { feedFullName: this.feedFullName, id: this.id, @@ -71,18 +67,21 @@ export class PriceFeed { blockExplorer: this.blockExplorer, deviation: this.deviation, heartbeat: this.heartbeat, - finality: this.finality, + finality: this.finality } } - static fromWitnetPriceFeedsContract( + static fromWitnetPriceFeedsContract ( configuration: Configuration, feed: SupportedFeed, address: string, network: Network, networkName: string ): PriceFeed { - const feedConfiguration = configuration.getFeedConfiguration(feed.caption, network) + const feedConfiguration = configuration.getFeedConfiguration( + feed.caption, + network + ) const networkConfiguration = configuration.getNetworkConfiguration(network) if (!feedConfiguration || Object.keys(feedConfiguration).length === 0) { @@ -94,7 +93,7 @@ export class PriceFeed { feedConfiguration.deviationPercentage = 0 } - const decimals = feed.caption.split("-").reverse()[0] + const decimals = feed.caption.split('-').reverse()[0] return new PriceFeed(configuration, { feedFullName: createFeedFullName(network, feed.caption, decimals), id: feed.id, diff --git a/packages/api/src/web3Middleware/index.ts b/packages/api/src/web3Middleware/index.ts index 5607d312..b90101e8 100644 --- a/packages/api/src/web3Middleware/index.ts +++ b/packages/api/src/web3Middleware/index.ts @@ -7,7 +7,7 @@ import { FeedInfo, Repositories, ContractInfo, - Contract, + Contract } from '../types' import { isZeroAddress } from '../utils/index' import { getProvider } from './provider' @@ -30,25 +30,35 @@ export class Web3Middleware { constructor ( configuration: Configuration, dependencies: { Web3: typeof Web3; repositories: Repositories }, - legacyDataFeeds: Array, + legacyDataFeeds: Array ) { this.repositories = dependencies.repositories - this.legacyDataFeeds =legacyDataFeeds + this.legacyDataFeeds = legacyDataFeeds this.Web3 = dependencies.Web3 this.configuration = configuration } - public listen() { + public listen () { this.listenLegacyPriceRouter() this.listenWitnetPriceFeeds() } public async listenWitnetPriceFeeds () { - this.configuration.listNetworksUsingPriceFeedsContract().forEach(networkInfo => new NetworkRouter(this.configuration, this.repositories, networkInfo).listen()) + this.configuration + .listNetworksUsingPriceFeedsContract() + .forEach(networkInfo => + new NetworkRouter( + this.configuration, + this.repositories, + networkInfo + ).listen() + ) } private async initializeAddresses (): Promise> { - const promises = this.legacyDataFeeds.map(feed => this.recheckFeedAddress(feed)) + const promises = this.legacyDataFeeds.map(feed => + this.recheckFeedAddress(feed) + ) const feeds = await Promise.all(promises) @@ -266,15 +276,13 @@ export class Web3Middleware { contracts, feedFullName ) - await this.repositories.resultRequestRepository.insertIfLatest( - { - result: lastPrice, - timestamp: lastTimestamp, - requestId: requestId, - drTxHash: toHex(lastDrTxHash).slice(2), - feedFullName - } - ) + await this.repositories.resultRequestRepository.insertIfLatest({ + result: lastPrice, + timestamp: lastTimestamp, + requestId: requestId, + drTxHash: toHex(lastDrTxHash).slice(2), + feedFullName + }) resolve(true) } catch (error) { console.error( diff --git a/packages/api/test/web3Middleware/configuration.spec.ts b/packages/api/test/web3Middleware/configuration.spec.ts index d6e15d88..ffd1bbb4 100644 --- a/packages/api/test/web3Middleware/configuration.spec.ts +++ b/packages/api/test/web3Middleware/configuration.spec.ts @@ -1,109 +1,107 @@ import { Network, RouterDataFeedsConfig } from '../../src/types' import { Configuration } from '../../src/web3Middleware/Configuration' - const configurationFile: RouterDataFeedsConfig = { - abi: "" as any, + abi: '' as any, chains: { - "arbitrum": { - "name": "Arbitrum", - "networks": { - "arbitrum.one": { - "legacy": false, - "address": "0x9999999d139bdBFbF25923ba39F63bBFc7593400", - "blockExplorer": "https://arbiscan.io/address/{address}", - "color": "#E84142", - "mainnet": true, - "name": "Arbitrum ONE", - "pollingPeriod": 120000, - "feeds": { - "Price-ETH/USD-6": { - "label": "$", - "deviationPercentage": 3.5, - "maxSecsBetweenUpdates": 86400, - "minSecsBetweenUpdates": 900 + arbitrum: { + name: 'Arbitrum', + networks: { + 'arbitrum.one': { + legacy: false, + address: '0x9999999d139bdBFbF25923ba39F63bBFc7593400', + blockExplorer: 'https://arbiscan.io/address/{address}', + color: '#E84142', + mainnet: true, + name: 'Arbitrum ONE', + pollingPeriod: 120000, + feeds: { + 'Price-ETH/USD-6': { + label: '$', + deviationPercentage: 3.5, + maxSecsBetweenUpdates: 86400, + minSecsBetweenUpdates: 900 } } }, - "arbitrum.goerli": { - "legacy": false, - "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 + 'arbitrum.goerli': { + legacy: false, + 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": { - "legacy": true, - "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: { + name: 'Avalanche', + networks: { + 'avalanche.mainnet': { + legacy: true, + 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": { - "legacy": false, - "address": "0x9999999d139bdBFbF25923ba39F63bBFc7593400", - "blockExplorer": "https://testnet.snowtrace.io/address/{address}", - "color": "#E84142", - "name": "Avalanche Fuji", - "pollingPeriod": 120000, - "feeds": { - "Price-ETH/USD-6": { - "label": "$", - "deviationPercentage": 3.5, - "maxSecsBetweenUpdates": 86400, - "minSecsBetweenUpdates": 900 + 'avalanche.fuji': { + legacy: false, + address: '0x9999999d139bdBFbF25923ba39F63bBFc7593400', + blockExplorer: 'https://testnet.snowtrace.io/address/{address}', + color: '#E84142', + name: 'Avalanche Fuji', + pollingPeriod: 120000, + feeds: { + 'Price-ETH/USD-6': { + label: '$', + deviationPercentage: 3.5, + maxSecsBetweenUpdates: 86400, + minSecsBetweenUpdates: 900 } } } } }, - "boba": { - "name": "Boba", - "networks": { - "boba.ethereum.mainnet": { - "legacy": true, - "mainnet": true, - "address": "0x93f61D0D5F623144e7C390415B70102A9Cc90bA5", - "blockExplorer": "https://blockexplorer.boba.network/address/{address}", - "color": "#007dff", - "name": "Boba ETH/L2 Mainnet", - "pollingPeriod": 120000, - "feeds": { - } - }, + boba: { + name: 'Boba', + networks: { + 'boba.ethereum.mainnet': { + legacy: true, + mainnet: true, + address: '0x93f61D0D5F623144e7C390415B70102A9Cc90bA5', + blockExplorer: 'https://blockexplorer.boba.network/address/{address}', + color: '#007dff', + name: 'Boba ETH/L2 Mainnet', + pollingPeriod: 120000, + feeds: {} + } } - }, + } }, feeds: { - "Price-ETH/USD-6": { - "label": "$", - "deviationPercentage": 10, - "maxSecsBetweenUpdates": 86400, - "minSecsBetweenUpdates": 900 + 'Price-ETH/USD-6': { + label: '$', + deviationPercentage: 10, + maxSecsBetweenUpdates: 86400, + minSecsBetweenUpdates: 900 } } } @@ -113,7 +111,29 @@ describe('Configuration', () => { const configuration = new Configuration(configurationFile) const result = configuration.listNetworksUsingPriceFeedsContract() - const expected = [{"address": "0x9999999d139bdBFbF25923ba39F63bBFc7593400", "key": "arbitrum-one", "networkName": "Arbitrum ONE", "pollingPeriod": 120000, "provider": "https://arb1.arbitrum.io/rpc/"}, {"address": "0x9999999d139bdBFbF25923ba39F63bBFc7593400", "key": "arbitrum-goerli", "networkName": "Arbitrum Nitro Goerli", "pollingPeriod": 120000, "provider": "https://goerli-rollup.arbitrum.io/rpc"}, {"address": "0x9999999d139bdBFbF25923ba39F63bBFc7593400", "key": "avalanche-fuji", "networkName": "Avalanche Fuji", "pollingPeriod": 120000, "provider": "https://api.avax-test.network/ext/bc/C/rpc"}] + const expected = [ + { + address: '0x9999999d139bdBFbF25923ba39F63bBFc7593400', + key: 'arbitrum-one', + networkName: 'Arbitrum ONE', + pollingPeriod: 120000, + provider: 'https://arb1.arbitrum.io/rpc/' + }, + { + address: '0x9999999d139bdBFbF25923ba39F63bBFc7593400', + key: 'arbitrum-goerli', + networkName: 'Arbitrum Nitro Goerli', + pollingPeriod: 120000, + provider: 'https://goerli-rollup.arbitrum.io/rpc' + }, + { + address: '0x9999999d139bdBFbF25923ba39F63bBFc7593400', + key: 'avalanche-fuji', + networkName: 'Avalanche Fuji', + pollingPeriod: 120000, + provider: 'https://api.avax-test.network/ext/bc/C/rpc' + } + ] expect(result).toStrictEqual(expected) }) @@ -123,55 +143,55 @@ describe('Configuration', () => { const result = configuration.getLegacyConfigurationFile() const expected = { - "abi": "", - "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, - }, + abi: '', + 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 + } }, - "legacy": true, - "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": { - }, - "legacy": true, - "mainnet": true, - "name": "Boba ETH/L2 Mainnet", - "pollingPeriod": 120000, - }, - }, + legacy: true, + 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: {}, + legacy: true, + mainnet: true, + name: 'Boba ETH/L2 Mainnet', + pollingPeriod: 120000 + } + } + } }, - "feeds": { - "Price-ETH/USD-6": { - "deviationPercentage": 10, - "label": "$", - "maxSecsBetweenUpdates": 86400, - "minSecsBetweenUpdates": 900, - }, - }, + feeds: { + 'Price-ETH/USD-6': { + deviationPercentage: 10, + label: '$', + maxSecsBetweenUpdates: 86400, + minSecsBetweenUpdates: 900 + } + } } expect(result).toStrictEqual(expected) @@ -180,7 +200,10 @@ describe('Configuration', () => { it('getFeedConfiguration', () => { const configuration = new Configuration(configurationFile) - const result = configuration.getFeedConfiguration('Price-ETH/USD-6', Network.BobaEthereumMainnet) + const result = configuration.getFeedConfiguration( + 'Price-ETH/USD-6', + Network.BobaEthereumMainnet + ) expect(result).toStrictEqual({ label: '$', @@ -193,14 +216,17 @@ describe('Configuration', () => { it('getFeedConfiguration overwrite', () => { const configuration = new Configuration(configurationFile) - const result = configuration.getFeedConfiguration('Price-ETH/USD-6', Network.AvalancheMainnet) + const result = configuration.getFeedConfiguration( + 'Price-ETH/USD-6', + Network.AvalancheMainnet + ) expect(result).toStrictEqual({ deviationPercentage: 3.5, - label: "$", + label: '$', maxSecsBetweenUpdates: 86400, - minSecsBetweenUpdates: 900, - }) + minSecsBetweenUpdates: 900 + }) }) it('isFeedActive', () => { @@ -213,17 +239,19 @@ describe('Configuration', () => { it('getNetworkConfiguration', () => { const configuration = new Configuration(configurationFile) - const result = configuration.getNetworkConfiguration(Network.BobaEthereumMainnet) + const result = configuration.getNetworkConfiguration( + Network.BobaEthereumMainnet + ) expect(result).toStrictEqual({ - "address": "0x93f61D0D5F623144e7C390415B70102A9Cc90bA5", - "blockExplorer": "https://blockexplorer.boba.network/address/{address}", - "color": "#007dff", - "feeds": {}, - "legacy": true, - "mainnet": true, - "name": "Boba ETH/L2 Mainnet", - "pollingPeriod": 120000, + address: '0x93f61D0D5F623144e7C390415B70102A9Cc90bA5', + blockExplorer: 'https://blockexplorer.boba.network/address/{address}', + color: '#007dff', + feeds: {}, + legacy: true, + mainnet: true, + name: 'Boba ETH/L2 Mainnet', + pollingPeriod: 120000 }) }) }) diff --git a/packages/api/test/web3Middleware/dataFeedsRouter.json b/packages/api/test/web3Middleware/dataFeedsRouter.json index 3214fcc1..ed49e023 100644 --- a/packages/api/test/web3Middleware/dataFeedsRouter.json +++ b/packages/api/test/web3Middleware/dataFeedsRouter.json @@ -537,17 +537,9 @@ } } } -<<<<<<< HEAD - }, - "feeds": { - "Price-ADA/USD-6": { -======= -<<<<<<< HEAD -======= }, "feeds": { "Price-ADA/USD-6": { ->>>>>>> 6c74911 (feat: migrate ui package to nuxt3) "label": "$", "deviationPercentage": 3.5, "maxSecsBetweenUpdates": 86400, @@ -1029,9 +1021,5 @@ "maxSecsBetweenUpdates": 86400, "minSecsBetweenUpdates": 900 } -<<<<<<< HEAD -======= ->>>>>>> 3ed77b4 (feat: migrate ui package to nuxt3) ->>>>>>> 6c74911 (feat: migrate ui package to nuxt3) } } diff --git a/packages/api/test/web3Middleware/networkRouter.spec.ts b/packages/api/test/web3Middleware/networkRouter.spec.ts index ec6caae8..a187fdff 100644 --- a/packages/api/test/web3Middleware/networkRouter.spec.ts +++ b/packages/api/test/web3Middleware/networkRouter.spec.ts @@ -1,32 +1,15 @@ -<<<<<<< HEAD:packages/api/test/web3Middleware/NetworkRouter.spec.ts import { Repositories } from '../../src/types.js' import { NetworkRouter } from '../../src/web3Middleware/NetworkRouter' -======= -import { Network, Repositories } from '../../src/types' -import { Configuration } from '../../src/web3Middleware/Configuration' -import { - NetworkInfo, - NetworkRouter -} from '../../src/web3Middleware/NetworkRouter' ->>>>>>> 3ed77b4 (feat: migrate ui package to nuxt3):packages/api/test/web3Middleware/networkRouter.spec.ts - describe('NetworkRouter', () => { it('should fetch network contract', async () => { // FIXME: create a proper mock -<<<<<<< HEAD:packages/api/test/web3Middleware/NetworkRouter.spec.ts - const repositories = { feedRepository: { }, resultRequestRepository: { } } as unknown as Repositories - const networkInfo = { - address:'0x9999999d139bdBFbF25923ba39F63bBFc7593400', -======= - const configuration = ({} as unknown) as Configuration const repositories = ({ feedRepository: {}, resultRequestRepository: {} } as unknown) as Repositories - const networkInfo: NetworkInfo = { + const networkInfo = { address: '0x9999999d139bdBFbF25923ba39F63bBFc7593400', ->>>>>>> 3ed77b4 (feat: migrate ui package to nuxt3):packages/api/test/web3Middleware/networkRouter.spec.ts provider: 'https://rpc2.sepolia.org', name: 'ethereum.sepholia', pollingPeriod: 1, diff --git a/packages/ui/components/Main.vue b/packages/ui/components/Main.vue deleted file mode 100644 index 0819caae..00000000 --- a/packages/ui/components/Main.vue +++ /dev/null @@ -1,243 +0,0 @@ - - - - -