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

Redesign data feeds explorer #122

Merged
merged 25 commits into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b7f5c0b
feat(ui): implement new navbar
gabaldon Jan 10, 2022
ff102c2
feat(ui): implement footer
gabaldon Jan 17, 2022
3e260b3
feat(ui): redesign feed card
gabaldon Jan 17, 2022
b82ad62
feat(api): delete pagination for feeds
gabaldon Jan 25, 2022
e822edc
fix(ui): add breadcrumbs and delete unnecessary networks
gabaldon Feb 7, 2022
be405a0
feat(ui): add tooltip and fix layout
gabaldon Feb 10, 2022
b05390a
feat(ui): fix responsive
gabaldon Feb 10, 2022
2845afa
feat(ui): redesign data feed details
gabaldon Feb 25, 2022
b5100a4
feat(ui): add contract id and update chart tooltip
gabaldon Feb 25, 2022
03c5cee
feat(ui): implement responsive
gabaldon Feb 25, 2022
0b9ec73
feat(ui): add avalanche data feed config
gabaldon Mar 1, 2022
6cea900
feat(ui): add favicon and fix tooltip in transaction value
gabaldon Mar 1, 2022
9ef3e60
feat(ui): add integration details external links
gabaldon Mar 1, 2022
d0fd48b
fix(ui): fix responsive nav padding
gabaldon Mar 1, 2022
40190bc
feat(ui): add status to data feed details
gabaldon Mar 1, 2022
833f6c6
feat(ui): add status to data feed card
gabaldon Mar 1, 2022
8c8bd3a
feat(api): re-order networks
gabaldon Mar 1, 2022
67df93c
feat(ui): add text size variables and fonts
gabaldon Mar 1, 2022
1f7f9bf
feat(ui): adjust responsive sizes
gabaldon Mar 1, 2022
f2c0bf0
fix(ui): fix tests and responsive
gabaldon Mar 2, 2022
1ad943b
refactor(ui): clean code
gabaldon Mar 3, 2022
4f52801
fix(ui): add polygon mainnet and metis mainnet types
gabaldon Mar 3, 2022
8a93e05
fix(ui): add remaining locale strings
gabaldon Mar 4, 2022
d16d798
feat(ui): add olo/usdc data feed
gabaldon Mar 4, 2022
e85048a
fix(api): add dataFeedsRouter config file for tests
gabaldon Mar 4, 2022
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
4 changes: 2 additions & 2 deletions packages/api/src/dataFeedsRouter.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
"minSecsBetweenUpdates": 900
},
"Price-OMG/BTC-9": {
"label": "BTC",
"label": "",
"deviationPercentage": 1.0,
"maxSecsBetweenUpdates": 86400,
"minSecsBetweenUpdates": 900
},
"Price-OMG/ETH-9": {
"label": "ETH",
"label": "Ξ",
"deviationPercentage": 1.0,
"maxSecsBetweenUpdates": 86400,
"minSecsBetweenUpdates": 900
Expand Down
17 changes: 10 additions & 7 deletions packages/api/src/repository/Feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,24 @@ export class FeedRepository {

async getPaginatedFeeds (
// starts in 1
page: number,
size: number,
network: string
): Promise<PaginatedFeedsObject> {
const filteredFeeds =
network === 'all'
? this.sortedDataFeeds
: this.dataFeedsByNetwork[network]

const paginatedFeeds = filteredFeeds.slice((page - 1) * size, page * size)

return {
feeds: paginatedFeeds,
feeds: filteredFeeds,
total: filteredFeeds.length
}
}

updateFeedAddress (feedFullName: string, address: string): FeedInfo {
updateFeedAddress (
feedFullName: string,
address: string,
contractId: string
): FeedInfo {
gabaldon marked this conversation as resolved.
Show resolved Hide resolved
const hasSameFeedFullName = (feed: FeedInfo) =>
feed.feedFullName === feedFullName

Expand All @@ -61,14 +61,17 @@ export class FeedRepository {
)
const feed = this.sortedDataFeeds[sortedDataFeedIndex]
feed.address = address

feed.contractId = contractId
// Update address in dataFeedsByNetwork
gabaldon marked this conversation as resolved.
Show resolved Hide resolved
const dataFeedsByNetworkIndex = this.dataFeedsByNetwork[
feed.network
].findIndex(hasSameFeedFullName)
this.dataFeedsByNetwork[feed.network][
dataFeedsByNetworkIndex
].address = address
this.dataFeedsByNetwork[feed.network][
dataFeedsByNetworkIndex
].contractId = contractId
gabaldon marked this conversation as resolved.
Show resolved Hide resolved

return feed
}
Expand Down
1 change: 0 additions & 1 deletion packages/api/src/repository/ResultRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export class ResultRequestRepository {
}
}
)

return this.normalizeId(lastResultRequest)
}

Expand Down
17 changes: 12 additions & 5 deletions packages/api/src/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import { Context, Network } from './types'
const resolvers = {
Query: {
feeds: async (_parent, args, { feedRepository }: Context) => {
return await feedRepository.getPaginatedFeeds(
args.page,
args.pageSize,
args.network
)
return await feedRepository.getPaginatedFeeds(args.network)
},

networks: async (_parent, _args) => {
Expand Down Expand Up @@ -36,12 +32,23 @@ const resolvers = {
return (await resultRequestRepository.getLastResult(parent.feedFullName))
?.result
},
lastResultTimestamp: async (
parent,
_args,
{ resultRequestRepository }: Context
) => {
return (await resultRequestRepository.getLastResult(parent.feedFullName))
gabaldon marked this conversation as resolved.
Show resolved Hide resolved
?.timestamp
},
color: async (parent, _args, { config }: Context) => {
return config[parent.feedFullName]?.color || ''
},
blockExplorer: async (parent, _args, { config }: Context) => {
return config[parent.feedFullName]?.blockExplorer || ''
},
proxyAddress: async (parent, _args, { config }: Context) => {
return config[parent.feedFullName]?.routerAddress || ''
},
deviation: async (parent, _args, { config }: Context) => {
return config[parent.feedFullName]?.deviation || ''
},
Expand Down
5 changes: 4 additions & 1 deletion packages/api/src/typeDefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ const typeDefs = gql`
type Feed {
id: String!
address: String!
contractId: String!
blockExplorer: String!
color: String!
feedFullName: String!
label: String!
name: String!
network: String!
lastResult: String
lastResultTimestamp: String
deviation: String!
proxyAddress: String
heartbeat: String!
finality: String!
requests(timestamp: Int!): [ResultRequest]!
Expand Down Expand Up @@ -49,7 +52,7 @@ const typeDefs = gql`

type Query {
feed(feedFullName: String!): Feed
feeds(page: Int!, pageSize: Int!, network: String): FeedsPage!
feeds(network: String): FeedsPage!
requests(feedFullName: String!, page: Int!, size: Int!): [ResultRequest]!
networks: [Network]!
}
Expand Down
6 changes: 6 additions & 0 deletions packages/api/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export type FeedInfoGeneric<ABI> = {
name: string
pollingPeriod: number
label: string
contractId: string
color: string
blockExplorer: string
deviation: string
Expand All @@ -64,6 +65,11 @@ export type PaginatedFeedsObject = {
total: number
}

export type ContractInfo = {
contractAddress: string
contractId: string
}

export type ResultRequestDbObjectNormalized = ResultRequestDbObject & {
id: string
}
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export function normalizeConfig (
feedFullName: createFeedFullName(network, name, decimals),
id: feed.key,
address: '0x0000000000000000000000000000000000000000',
contractId: '0x0000000000000000000000000000000000000000',
routerAddress: config.address,
network,
name,
Expand Down
39 changes: 27 additions & 12 deletions packages/api/src/web3Middleware/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
FeedInfo,
Repositories,
ResultRequestDbObject,
ObjectId
ObjectId,
ContractInfo
} from '../types'
import { getProvider } from './provider'

Expand Down Expand Up @@ -34,17 +35,24 @@ export class Web3Middleware {
}

async updateAddress (feedInfo: FeedInfo) {
gabaldon marked this conversation as resolved.
Show resolved Hide resolved
const contractAddress = await this.getContractAddress(feedInfo)
const contractInfo = await this.getContractAddress(feedInfo)
console.log('contractInfo in updateAddress', contractInfo)
gabaldon marked this conversation as resolved.
Show resolved Hide resolved
const feed = this.repositories.feedRepository.get(feedInfo.feedFullName)

if (feed && contractAddress && contractAddress !== feed.address) {
if (
feed &&
contractInfo &&
contractInfo.contractAddress &&
contractInfo.contractAddress !== feed.address
gabaldon marked this conversation as resolved.
Show resolved Hide resolved
) {
return this.repositories.feedRepository.updateFeedAddress(
feedInfo.feedFullName,
contractAddress
contractInfo.contractAddress,
contractInfo.contractId
Tommytrg marked this conversation as resolved.
Show resolved Hide resolved
)
}

return feedInfo
return feedInfo
}

async listen () {
Expand Down Expand Up @@ -89,7 +97,7 @@ export class Web3Middleware {
this.intervals = []
}

async getContractAddress (feedInfo: FeedInfo): Promise<string | null> {
async getContractAddress (feedInfo: FeedInfo): Promise<ContractInfo | null> {
gabaldon marked this conversation as resolved.
Show resolved Hide resolved
try {
return await new Promise(async (resolve, reject) => {
try {
Expand All @@ -109,11 +117,15 @@ export class Web3Middleware {
const contractIdentifier = await feedContract.methods
.currencyPairId(feedInfo.id)
.call()
console.log('contract Identifier!!!', feedInfo.id, contractIdentifier)
gabaldon marked this conversation as resolved.
Show resolved Hide resolved
const address = await feedContract.methods
.getPriceFeed(contractIdentifier)
.call()

resolve(address)
resolve({
contractAddress: address,
contractId: contractIdentifier
})
} catch (err) {
reject(err)
}
Expand All @@ -127,22 +139,25 @@ export class Web3Middleware {
}

async listenToDataFeed (feedInfo: FeedInfo) {
const contractAddress = await this.getContractAddress(feedInfo)
const contractInfo = await this.getContractAddress(feedInfo)
gabaldon marked this conversation as resolved.
Show resolved Hide resolved
const provider = getProvider(feedInfo.network)
if (provider) {
console.log('contractInfo in listenToDataFeed', contractInfo)
gabaldon marked this conversation as resolved.
Show resolved Hide resolved
if (
contractAddress &&
contractAddress !== '0x0000000000000000000000000000000000000000'
contractInfo &&
contractInfo.contractAddress &&
contractInfo.contractAddress !==
'0x0000000000000000000000000000000000000000'
gabaldon marked this conversation as resolved.
Show resolved Hide resolved
) {
try {
const web3 = new this.Web3(provider)
const feedContract = new web3.eth.Contract(
feedInfo.abi,
contractAddress
contractInfo.contractAddress
)
const interval = setInterval(async () => {
console.log(
`Reading ${feedInfo.feedFullName} contract state at address: ${contractAddress}`
`Reading ${feedInfo.feedFullName} contract state at address: ${contractInfo.contractAddress}`
)
await this.fetchAndSaveContractSnapshot(
{ feedContract },
Expand Down
2 changes: 1 addition & 1 deletion packages/api/test/web3Middleware/dataFeedsRouter.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
"label": "$",
"deviationPercentage": 1.0,
"maxSecsBetweenUpdates": 28800,
"minSecsBetweenUpdates": 900
"minSecsBetweenUpdates": 900
},
"Price-ETH/USD-6": {
"label": "$",
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/apollo/queries/feed.gql
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ query feed($feedFullName: String!, $timestamp: Int!) {
feedFullName
name
address
contractId
lastResult
network
label
deviation
proxyAddress
heartbeat
finality
requests(timestamp: $timestamp) {
Expand Down
5 changes: 3 additions & 2 deletions packages/ui/apollo/queries/feeds.gql
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
query feeds ($page: Int!, $pageSize: Int!, $network: String!) {
feeds (page: $page, pageSize: $pageSize, network: $network) {
query feeds ($network: String!) {
feeds (network: $network) {
feeds {
feedFullName
name
address
lastResult
lastResultTimestamp
network
label
blockExplorer
Expand Down
Binary file added packages/ui/assets/.DS_Store
Binary file not shown.
5 changes: 4 additions & 1 deletion packages/ui/assets/styles/colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ $black: black;
// GREENS
$green-1: #5fbfae;
$green-2: #468d80;
$green-3: #26474B;
$green-4: #4AB6A1;
$green-4-opacity: #4ab6a02c;
//BLUES
$blue-1: #758ea9;
$blue-2: #526488;
Expand All @@ -14,5 +17,5 @@ $red: #E54343;
//GREYS
$grey-1: #e4e4e4;
$grey-2: #999;
$grey-3: #5f5f5f;
$grey-3: #767575;
gabaldon marked this conversation as resolved.
Show resolved Hide resolved
$grey-4: #4d4d4d;
Loading