Skip to content

Commit

Permalink
fix: add refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
yongenaelf committed Nov 16, 2024
1 parent 8232f98 commit c4fd37e
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions components/contract-viewer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"use client";

import React from "react";
import React, { useState } from "react";
import { useSearchParams } from "next/navigation";
import { useWallet } from "@/data/wallet";
import { ContractView } from "aelf-smartcontract-viewer";
import { useTheme } from "next-themes";
import { Button } from "../ui/button";

const sideChainTestnetRpc = "https://tdvw-test-node.aelf.io";

Expand All @@ -13,20 +14,27 @@ const ContractViewer = ({ name }: { name: string }) => {
const wallet = useWallet();
const { resolvedTheme } = useTheme();
const contractViewerAddress = searchParams.get("contract-viewer-address");
const [key, setKey] = useState("0");

if (!contractViewerAddress || !wallet?.wallet) {
return;
}

return (
<ContractView
wallet={wallet.wallet}
address={contractViewerAddress}
headerTitle={"Contract View"}
rpcUrl={sideChainTestnetRpc}
contractName={name}
theme={resolvedTheme as "dark" | "light"}
/>
<>
<div className="flex">
<Button className="mx-auto mt-2" onClick={() => setKey(prev => parseInt(prev) + 1 + "")}>Refresh</Button>
</div>
<ContractView
key={key}
wallet={wallet.wallet}
address={contractViewerAddress}
headerTitle={"Contract View"}
rpcUrl={sideChainTestnetRpc}
contractName={name}
theme={resolvedTheme as "dark" | "light"}
/>
</>
);
};

Expand Down

0 comments on commit c4fd37e

Please sign in to comment.