Skip to content

Commit

Permalink
chore: refetch interval for stale data
Browse files Browse the repository at this point in the history
  • Loading branch information
Jennievon committed Nov 13, 2023
1 parent a346f77 commit 173cbc1
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 11 deletions.
16 changes: 10 additions & 6 deletions tools/obscuroscan_v3/frontend/components/layouts/footer.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
import { SocialLinks } from '@/src/lib/constants'
import { GitHubLogoIcon, TwitterLogoIcon, DiscordLogoIcon } from '@radix-ui/react-icons'
import { socialLinks } from "@/src/lib/constants";
import {
GitHubLogoIcon,
TwitterLogoIcon,
DiscordLogoIcon,
} from "@radix-ui/react-icons";

export default function Footer() {
return (
<div className="border-t">
<div className="flex h-16 items-center px-4">
<div className="flex-1 flex items-center space-x-4">
<a
href={SocialLinks.github}
href={socialLinks.github}
className="text-muted-foreground hover:text-primary transition-colors"
>
<GitHubLogoIcon />
</a>
<a
href={SocialLinks.twitter}
href={socialLinks.twitter}
className="text-muted-foreground hover:text-primary transition-colors"
>
<TwitterLogoIcon />
</a>
<a
href={SocialLinks.discord}
href={socialLinks.discord}
className="text-muted-foreground hover:text-primary transition-colors"
>
<DiscordLogoIcon />
Expand All @@ -41,5 +45,5 @@ export default function Footer() {
</div>
</div>
</div>
)
);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,70 @@
// {
// "Header":
// {
// "parentHash":
// "0x558b1be28fe24a6766e40aa24317492fe5978b159f8fd543170d61ae2749a8bb",
// "stateRoot":
// "0xb6c8ea4a0cfc96e202b512a2096c313e36c15883227b83f146564cdea5484e82",
// "transactionsRoot":
// "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
// "receiptsRoot":
// "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
// "number":
// 9084,
// "sequencerOrderNo":
// 9085,
// "gasLimit":
// 1537228672809129200,
// "gasUsed":
// 0,
// "timestamp":
// 1699909432,
// "extraData":
// "",
// "baseFee":
// 1,
// "coinbase":
// "0xd6c9230053f45f873cb66d8a02439380a37a4fbf",
// "l1Proof":
// "0x712ca13aff6745094fc215ca9a6b9790e778f13f852d0439b6f998e0b49b64c2",
// "R":
// 1.0666142563506898e+77,
// "S":
// 1.9832304678215498e+76,
// "crossChainMessages":
// [
// ],
// "inboundCrossChainHash":
// "0x712ca13aff6745094fc215ca9a6b9790e778f13f852d0439b6f998e0b49b64c2",
// "inboundCrossChainHeight":
// 37008,
// "transfersTree":
// "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
// "hash":
// "0xa6cecb66607c02561dce716d6c077cfaea40119b2ad30427474801cea3740d4a",
// "sha3Uncles":
// null,
// "miner":
// "0xd6c9230053f45f873cb66d8a02439380a37a4fbf",
// "logsBloom":
// null,
// "difficulty":
// null,
// "nonce":
// null,
// "baseFeePerGas":
// 1
// },
// "TxHashes":
// [
// ],
// "EncryptedTxBlob":
// "Fse8O1ZX32W9p68bd8ExeNiPMvfHnNi90o8pgFCIjiQB"

import { Separator } from "@/components/ui/separator";
import TruncatedAddress from "../common/truncated-address";

// }
export function BatchDetails() {
return (
<div className="space-y-8">
Expand Down
3 changes: 3 additions & 0 deletions tools/obscuroscan_v3/frontend/src/hooks/useBatches.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { getBatches, getLatestBatch } from "@/api/batches";
import { useQuery } from "@tanstack/react-query";
import { pollingInterval } from "../lib/constants";

export const useBatches = () => {
const { data: batches, isLoading: isBatchesLoading } = useQuery({
queryKey: ["batches"],
queryFn: () => getBatches(),
refetchInterval: pollingInterval,
});

const { data: latestBatch, isLoading: isLatestBatchLoading } = useQuery({
queryKey: ["latestBatch"],
queryFn: () => getLatestBatch(),
refetchInterval: pollingInterval,
});

return { batches, isBatchesLoading, latestBatch, isLatestBatchLoading };
Expand Down
2 changes: 2 additions & 0 deletions tools/obscuroscan_v3/frontend/src/hooks/useBlocks.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { getBlocks } from "@/api/blocks";
import { useQuery } from "@tanstack/react-query";
import { pollingInterval } from "../lib/constants";

export const useBlocks = () => {
const { data: blocks, isLoading: isBlocksLoading } = useQuery({
queryKey: ["blocks"],
queryFn: () => getBlocks(),
refetchInterval: pollingInterval,
});

return { blocks, isBlocksLoading };
Expand Down
4 changes: 4 additions & 0 deletions tools/obscuroscan_v3/frontend/src/hooks/useTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useWalletConnection } from "@/components/providers/wallet-provider";
import { useQuery } from "@tanstack/react-query";
import { ethers } from "ethers";
import { useEffect, useState } from "react";
import { pollingInterval, pricePollingInterval } from "../lib/constants";

export const useTransactions = () => {
const { walletAddress, provider } = useWalletConnection();
Expand All @@ -20,12 +21,14 @@ export const useTransactions = () => {
const { data: transactions, isLoading: isTransactionsLoading } = useQuery({
queryKey: ["transactions"],
queryFn: () => getTransactions(),
refetchInterval: pollingInterval,
});

const { data: transactionCount, isLoading: isTransactionCountLoading } =
useQuery({
queryKey: ["transactionCount"],
queryFn: () => getTransactionCount(),
refetchInterval: pollingInterval,
});

const personalTransactions = async () => {
Expand All @@ -43,6 +46,7 @@ export const useTransactions = () => {
const { data: price, isLoading: isPriceLoading } = useQuery({
queryKey: ["price"],
queryFn: () => getPrice(),
refetchInterval: pricePollingInterval,
});

return {
Expand Down
14 changes: 9 additions & 5 deletions tools/obscuroscan_v3/frontend/src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
export const SocialLinks = {
github: 'https://github.com/obscuro-protocol',
discord: 'https://discord.gg/2JQ2Z3r',
twitter: 'https://twitter.com/obscuroprotocol'
}
export const socialLinks = {
github: "https://github.com/obscuronet",
discord: "https://discord.gg/2JQ2Z3r",
twitter: "https://twitter.com/obscuronet",
};

export const pollingInterval = 5000;
export const maxRetries = 3;
export const pricePollingInterval = 60 * 1000;

0 comments on commit 173cbc1

Please sign in to comment.