Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
add symbols to UI
Browse files Browse the repository at this point in the history
  • Loading branch information
geoknee committed Oct 19, 2023
1 parent f565caf commit 03cfe52
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
27 changes: 22 additions & 5 deletions src/Intermediary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
import { blo } from "blo";
import { formatEther } from "ethers";
import { useBalances } from "./useBalances";
import { ChainData, chains } from "./chains";

Check failure on line 19 in src/Intermediary.tsx

View workflow job for this annotation

GitHub Actions / build-and-lint

Import "ChainData" is only used as types

const startingIntermediaryBalance = BigInt(
// @ts-expect-error
Expand All @@ -32,6 +33,16 @@ export const Coordinator: React.FunctionComponent = () => {
const aliceScwAddress = import.meta.env.VITE_ALICE_SCW_ADDRESS;
// @ts-expect-error
const bobScwAddress = import.meta.env.VITE_BOB_SCW_ADDRESS;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const aliceChain = chains.find(
// @ts-expect-error
(c) => c.url === import.meta.env.VITE_ALICE_CHAIN_URL,
)!;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const bobChain = chains.find(
// @ts-expect-error
(c) => c.url === import.meta.env.VITE_BOB_CHAIN_URL,
)!;

const [withAlice] = useState(
() =>
Expand Down Expand Up @@ -100,20 +111,22 @@ export const Coordinator: React.FunctionComponent = () => {
spacing={2}
>
<Divider />
<Intermediary client={withAlice} />
<Intermediary client={withAlice} chain={aliceChain} />
<Divider />
<Intermediary client={withBob} />
<Intermediary client={withBob} chain={bobChain} />
</Stack>
</Card>
);
};

export const Intermediary: React.FunctionComponent<{
client: IntermediaryClient;
}> = (props: { client: IntermediaryClient }) => {
chain: ChainData;
}> = (props: { client: IntermediaryClient; chain: ChainData }) => {
const [ownerBalance, intermediaryBalance] = useBalances(props.client);
return (
<>
{props.chain.name}
<Stack
direction="row"
justifyContent="left"
Expand All @@ -126,7 +139,10 @@ export const Intermediary: React.FunctionComponent<{
sx={{ width: 24, height: 24 }}
/>
</Tooltip>
<Typography>Owner balance: {formatEther(ownerBalance)}</Typography>
<Typography>
Owner balance:{" "}
{formatEther(BigInt(ownerBalance)) + " " + props.chain.symbol}
</Typography>
</Stack>
<Stack
direction="row"
Expand All @@ -141,7 +157,8 @@ export const Intermediary: React.FunctionComponent<{
/>
</Tooltip>
<Typography>
IntermediaryBalance: {formatEther(intermediaryBalance)}
IntermediaryBalance:{" "}
{formatEther(BigInt(intermediaryBalance)) + " " + props.chain.symbol}
</Typography>
</Stack>
</>
Expand Down
7 changes: 4 additions & 3 deletions src/Wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ const Wallet: React.FunctionComponent<{ role: Role }> = (props: {
BigInt(parseInt(import.meta.env.VITE_SCW_DEPOSIT, 10) / 100);

const [recipient, setRecipient] = useState(myPeer);
const [hostNetwork, setHostNetwork] = useState("Scroll");
const [isModalL1PayOpen, setModalL1PayOpen] = useState<boolean>(false);
const [isModalEjectOpen, setModalEjectOpen] = useState<boolean>(false);
const [userOpHash, setUserOpHash] = useState<string | null>(null);
Expand Down Expand Up @@ -200,11 +199,13 @@ const Wallet: React.FunctionComponent<{ role: Role }> = (props: {
</Typography>
<Typography>
{" "}
<b> Balance:</b> {formatEther(ownerBalance)}{" "}
<b> Balance:</b>{" "}
{formatEther(BigInt(ownerBalance)) + " " + myChain.symbol}{" "}
</Typography>
<Typography>
{" "}
<b> Inbound Capacity:</b> {formatEther(intermediaryBalance)}{" "}
<b> Inbound Capacity:</b>{" "}
{formatEther(BigInt(intermediaryBalance)) + " " + myChain.symbol}{" "}
</Typography>
</Stack>
<br />
Expand Down

0 comments on commit 03cfe52

Please sign in to comment.