Skip to content

Commit c34ea96

Browse files
feat(docs): improve guide for contract addresses
1 parent 6203801 commit c34ea96

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

docs/frontend/wagmi/02-get-official-contract-address.mdx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ import { GetAddressApp } from "@site/src/components/Frontend/GetAddressCard";
1414
import { AllOfficialContractsTableApp } from "@site/src/components/Frontend/AllOfficialContractsTable";
1515
import GetAddressCardCode from "!!raw-loader!/src/components/Frontend/GetAddressCard";
1616
import FlareContractRegistryAbi from "!!raw-loader!/src/abis/FlareContractRegistry.ts";
17+
import ContractsListCode from "!!raw-loader!/src/components/Frontend/AllOfficialContractsTable";
1718
import CodeBlock from "@theme/CodeBlock";
19+
import BrowserOnly from "@docusaurus/BrowserOnly";
1820

1921
In this guide we will use the `useReadContract` hook from the Wagmi framework to get addresses of official Flare contracts.
2022
The addresses could be hardcoded into the frontend, but that approach is error prone and requires manual updates.
@@ -59,9 +61,7 @@ Then, it invokes the `useReadContract` Wagmi hook, and returns the result.
5961
We can demonstrate how the `useFlareContractRegistry` hook can be used on a simple input card.
6062
The full code for this example as well as a list of all registered contract are available bellow.
6163

62-
{/* WARN:(Nik) This code is functional, but the development server throws a long and scary error. */}
63-
64-
<GetAddressApp />
64+
<BrowserOnly>{() => <GetAddressApp />}</BrowserOnly>
6565

6666
The card accepts a contract name as input.
6767
When the `Get contract address` button is pressed, the input data is saved to the state, which triggers a rerender of the `result` component.
@@ -76,10 +76,16 @@ To enable the `useReadContract` hook, the card is wrapped in a `QueryClientProvi
7676
In a real project, those would be placed at the root level of the app.
7777
To learn more about these, look at the [Tanstack Query](https://tanstack.com/query/latest/docs/framework/react/reference/QueryClientProvider) and [Wagmi](https://wagmi.sh/react/api/WagmiProvider) documentation for the corresponding components.
7878

79-
{/* WARN:(Nik) This code is functional, but the development server throws a long and scary error. */}
80-
8179
<details >
8280

8381
<summary>List of available official contracts</summary>
84-
<AllOfficialContractsTableApp />
82+
83+
<BrowserOnly>{() => <AllOfficialContractsTableApp />}</BrowserOnly>
84+
85+
This list is also prepared dynamically.
86+
The contract names are fetched from the `FlareContractRegistry`, by calling its `getAllContracts` function.
87+
88+
<CodeBlock language="tsx">
89+
{ContractsListCode}
90+
</CodeBlock>
8591
</details>

0 commit comments

Comments
 (0)