Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Move chain data #1426

Merged
merged 14 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ module.exports = {
transform: {
"^.+\\.ts?$": "ts-jest",
},
moduleNameMapper: {
"\\.(css)$": "<rootDir>/src/__mocks__/styleMock.ts",
},
transformIgnorePatterns: ["<rootDir>/node_modules/"],
}
1 change: 1 addition & 0 deletions src/__mocks__/styleMock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {}
3 changes: 2 additions & 1 deletion src/content/data-feeds/examples.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ metadata:
description: "How to use Chainlink Data Feeds in your smart contracts."
---

import { LatestPrice, priceFeedAddresses } from "@features/feeds"
import { LatestPrice } from "@features/feeds"
import { priceFeedAddresses } from "@features/data"
import { Aside, CodeSample } from "@components"
import { Tabs } from "@components/Tabs"
import button from "@chainlink/design-system/button.module.css"
Expand Down
4 changes: 3 additions & 1 deletion src/content/data-feeds/feed-registry/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ whatsnext:
}
---

import { RegistryPrice, registryAddresses } from "@features/feeds"
import { RegistryPrice } from "@features/feeds"
import { registryAddresses } from "@features/data"

import { Aside, ClickToZoom, CodeSample } from "@components"

The Chainlink Feed Registry is an on-chain mapping of assets to feeds. It enables you to query Chainlink data feeds from asset addresses directly, without needing to know the feed contract addresses. They enable smart contracts to get the latest price of an asset in a single call, from a single contract.
Expand Down
3 changes: 2 additions & 1 deletion src/content/data-feeds/historical-data.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ metadata:
description: "How to use Chainlink Data Feeds to retrieve historical data in your smart contracts."
---

import { HistoricalPrice, priceFeedAddresses } from "@features/feeds"
import { priceFeedAddresses } from "@features/data"
import { HistoricalPrice } from "@features/feeds"
import { Aside, ClickToZoom, CodeSample } from "@components"
import button from "@chainlink/design-system/button.module.css"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import EleventyFetch from "@11ty/eleventy-fetch"
import { ChainMetadata } from "."
import { Chain } from "../data/chains"
import { Chain } from "../chains"

export const getServerSideChainMetadata = async (chains: Chain[]): Promise<ChainMetadata> => {
const cache = {} as ChainMetadata
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Chain } from "../data/chains"
import { Chain } from "../chains"

interface Docs {
nftFloorUnits: any
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChainMetadata } from "../api"
import { ChainMetadata } from "./api"

type ChainTags = ("default" | "proofOfReserve" | "nftFloorPrice" | "rates")[]
export interface ChainNetwork {
Expand All @@ -17,6 +17,7 @@ export interface Chain {
networks: ChainNetwork[]
label?: string
tags?: ChainTags
supportedFeatures: ("vrfSubscription" | "vrfDirectFunding" | "feeds")[]
}

export const CHAINS: Chain[] = [
Expand All @@ -26,6 +27,7 @@ export const CHAINS: Chain[] = [
img: "/assets/chains/ethereum.svg",
networkStatusUrl: "https://ethstats.dev/",
tags: ["default", "proofOfReserve", "nftFloorPrice", "rates"],
supportedFeatures: ["vrfSubscription", "vrfDirectFunding", "feeds"],
networks: [
{
name: "Ethereum Mainnet",
Expand Down Expand Up @@ -57,6 +59,7 @@ export const CHAINS: Chain[] = [
img: "/assets/chains/bnb-chain.svg",
networkStatusUrl: "https://bscscan.freshstatus.io/",
tags: ["default"],
supportedFeatures: ["vrfSubscription", "vrfDirectFunding", "feeds"],
networks: [
{
name: "BNB Chain Mainnet",
Expand All @@ -80,6 +83,7 @@ export const CHAINS: Chain[] = [
img: "/assets/chains/polygon.svg",
networkStatusUrl: "https://polygon.io/system",
tags: ["default", "proofOfReserve", "nftFloorPrice", "rates"],
supportedFeatures: ["vrfSubscription", "vrfDirectFunding", "feeds"],
networks: [
{
name: "Polygon Mainnet",
Expand All @@ -103,6 +107,7 @@ export const CHAINS: Chain[] = [
img: "/assets/chains/gnosis-chain.svg",
networkStatusUrl: "https://gnosisscan.io/",
tags: ["default"],
supportedFeatures: ["feeds"],
networks: [
{
name: "Gnosis Chain Mainnet",
Expand All @@ -119,6 +124,7 @@ export const CHAINS: Chain[] = [
img: "/assets/chains/avalanche.svg",
networkStatusUrl: "https://status.avax.network/",
tags: ["default", "proofOfReserve", "rates"],
supportedFeatures: ["vrfSubscription", "vrfDirectFunding", "feeds"],
networks: [
{
name: "Avalanche Mainnet",
Expand All @@ -144,6 +150,7 @@ export const CHAINS: Chain[] = [
img: "/assets/chains/fantom.svg",
networkStatusUrl: "https://ftmscan.com/",
tags: ["default"],
supportedFeatures: ["vrfSubscription", "vrfDirectFunding", "feeds"],
networks: [
{
name: "Fantom Mainnet",
Expand All @@ -166,6 +173,7 @@ export const CHAINS: Chain[] = [
img: "/assets/chains/arbitrum.svg",
networkStatusUrl: "https://arbiscan.freshstatus.io/",
tags: ["default", "rates"],
supportedFeatures: ["vrfSubscription", "vrfDirectFunding", "feeds"],
networks: [
{
name: "Arbitrum Mainnet",
Expand All @@ -189,6 +197,7 @@ export const CHAINS: Chain[] = [
img: "/assets/chains/harmony.svg",
networkStatusUrl: "https://status.harmony.one/",
tags: ["default"],
supportedFeatures: ["feeds"],
networks: [
{
name: "Harmony Mainnet",
Expand All @@ -205,6 +214,7 @@ export const CHAINS: Chain[] = [
img: "/assets/chains/optimism.svg",
networkStatusUrl: "https://status.optimism.io/",
tags: ["default"],
supportedFeatures: ["feeds"],
networks: [
{
name: "Optimism Mainnet",
Expand All @@ -227,6 +237,7 @@ export const CHAINS: Chain[] = [
img: "/assets/chains/moonriver.svg",
networkStatusUrl: "https://moonscan.freshstatus.io/",
tags: ["default"],
supportedFeatures: ["feeds"],
networks: [
{
name: "Moonriver Mainnet",
Expand All @@ -243,6 +254,7 @@ export const CHAINS: Chain[] = [
img: "/assets/chains/moonbeam.svg",
networkStatusUrl: "https://moonscan.freshstatus.io/",
tags: ["default"],
supportedFeatures: ["feeds"],
networks: [
{
name: "Moonbeam Mainnet",
Expand All @@ -259,6 +271,7 @@ export const CHAINS: Chain[] = [
img: "/assets/chains/metis.svg",
networkStatusUrl: "https://andromeda-explorer.metis.io/",
tags: ["default"],
supportedFeatures: ["feeds"],
networks: [
{
name: "Metis Mainnet",
Expand All @@ -275,6 +288,7 @@ export const CHAINS: Chain[] = [
img: "/assets/chains/base.svg",
networkStatusUrl: "https://goerli.basescan.org",
tags: ["default"],
supportedFeatures: ["feeds"],
networks: [
{
name: "BASE Goerli testnet",
Expand All @@ -291,6 +305,7 @@ export const CHAINS: Chain[] = [
img: "/assets/chains/celo.svg",
networkStatusUrl: "https://stats.celo.org/",
tags: ["default"],
supportedFeatures: ["feeds"],
networks: [
{
name: "Celo mainnet",
Expand All @@ -313,6 +328,7 @@ export const CHAINS: Chain[] = [
img: "/assets/chains/starknet.svg",
networkStatusUrl: "https://testnet.starkscan.co/stats",
tags: ["default"],
supportedFeatures: ["feeds"],
networks: [
{
name: "StarkNet testnet",
Expand All @@ -329,6 +345,7 @@ export const CHAINS: Chain[] = [
img: "/assets/chains/solana.svg",
networkStatusUrl: "https://status.solana.com/",
tags: ["default"],
supportedFeatures: ["feeds"],
networks: [
{
name: "Solana Mainnet",
Expand All @@ -354,6 +371,7 @@ export const ALL_CHAINS: Chain[] = [
img: "/assets/chains/ethereum.svg",
networkStatusUrl: "https://ethstats.dev/",
tags: ["default", "proofOfReserve", "nftFloorPrice"],
supportedFeatures: ["feeds"],
networks: [
{
name: "Ethereum Mainnet",
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/features/feeds/components/FeedList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { MainnetTable, TestnetTable } from "./Tables"
import feedList from "./FeedList.module.css"
import { clsx } from "~/lib"
import { updateTableOfContents } from "~/components/RightSidebar/TableOfContents/tocStore"
import { Chain, CHAINS, ALL_CHAINS } from "../data/chains"
import { Chain, CHAINS, ALL_CHAINS } from "~/features/data/chains"
import { useGetChainMetadata } from "./useGetChainMetadata"
import { ChainMetadata } from "../api"
import { ChainMetadata } from "../../data/api"
import useQueryString from "~/hooks/useQueryString"

export type DataFeedType = "default" | "por" | "nftFloor" | "rates"
Expand Down
6 changes: 3 additions & 3 deletions src/features/feeds/components/FeedPage.astro
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ export type Props = {
ecosystem: string
dataFeedType?: DataFeedType
}
import { getServerSideChainMetadata } from "../api/backend"
import { CHAINS, ALL_CHAINS } from "../data/chains"
import { getServerSideChainMetadata } from "~/features/data//api/backend"
import { CHAINS, ALL_CHAINS } from "~/features/data/chains"
import { CheckHeartbeat } from "./pause-notice/CheckHeartbeat"
import { FeedDataItem, monitoredFeeds } from "../data"
import { FeedDataItem, monitoredFeeds } from "~/features/data"

const { initialNetwork, ecosystem, dataFeedType } = Astro.props

Expand Down
4 changes: 2 additions & 2 deletions src/features/feeds/components/Tables.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/** @jsxImportSource preact */
import feedList from "./FeedList.module.css"
import { clsx } from "../../../lib"
import { ChainNetwork } from "../data/chains"
import { ChainNetwork } from "~/features/data/chains"
import tableStyles from "./Tables.module.css"
import { CheckHeartbeat } from "./pause-notice/CheckHeartbeat"
import { monitoredFeeds, FeedDataItem } from "../data"
import { monitoredFeeds, FeedDataItem } from "~/features/data"

const feedItems = monitoredFeeds.mainnet
const feedCategories = {
Expand Down
4 changes: 2 additions & 2 deletions src/features/feeds/components/useGetChainMetadata.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from "preact/hooks"
import { getChainMetadata } from "../api"
import { Chain } from "../data/chains"
import { getChainMetadata } from "../../data/api"
import { Chain } from "~/features/data/chains"

export function useGetChainMetadata(chain: Chain, { initialCache }) {
const [cache, setCache] = useState(initialCache ?? { [chain.page]: chain })
Expand Down
1 change: 0 additions & 1 deletion src/features/feeds/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from "./components"
export * from "./data"
export * from "./types"
39 changes: 39 additions & 0 deletions src/features/vrf/v2/components/CostTable.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { getGasCalculatorUrl } from "./CostTable"
import { expect, test } from "@jest/globals"
import { ChainNetwork } from "~/features/data/chains"

describe("getGasCalculatorUrl", () => {
test("works with testnet", () => {
const mainChainName = "ethereum"
const networkName = "goerli"
const chain: ChainNetwork = {
name: "Goerli Testnet",
explorerUrl: "https://goerli.etherscan.io/address/%s",
networkType: "testnet",
rddUrl: "https://reference-data-directory.vercel.app/feeds-goerli.json",
tags: ["proofOfReserve", "nftFloorPrice"],
}
const method = "vrfSubscription"

expect(getGasCalculatorUrl({ mainChainName, networkName, chain, method })).toEqual(
"https://vrf.chain.link/api/calculator?networkName=ethereum&networkType=goerli&method=subscription"
)
})

test("works with mainnet", () => {
const mainChainName = "polygon"
const networkName = "mainnet"
const chain: ChainNetwork = {
name: "Polygon Mainnet",
explorerUrl: "https://polygonscan.com/address/%s",
networkType: "mainnet",
rddUrl: "https://reference-data-directory.vercel.app/feeds-matic-mainnet.json",
tags: ["proofOfReserve"],
}
const method = "vrfDirectFunding"

expect(getGasCalculatorUrl({ mainChainName, networkName, chain, method })).toEqual(
"https://vrf.chain.link/api/calculator?networkName=polygon&networkType=mainnet&method=directFunding"
)
})
})
Loading