-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ability to fetch chain tip by forwarding lightwalletd calls
- Loading branch information
1 parent
aff28fc
commit f406298
Showing
6 changed files
with
146 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,52 @@ | ||
import React, { useContext, useEffect, useState } from "react"; | ||
|
||
import Form from "react-bootstrap/Form"; | ||
import Card from "react-bootstrap/Card"; | ||
import Stack from "react-bootstrap/Stack"; | ||
|
||
import { WalletContext } from "../App"; | ||
import { WalletSummary, AccountBalance } from "@webzjs/webz-core"; | ||
import { WalletSummary } from "@webzjs/webz-core"; | ||
import { Button } from "react-bootstrap"; | ||
|
||
export function Header() { | ||
let webWallet = useContext(WalletContext); | ||
let [summary, setSummary] = useState<WalletSummary | null>(); | ||
|
||
let resyncSummary = async () => { | ||
if (!webWallet) { | ||
return; | ||
} | ||
console.log("fetching balance"); | ||
let summary = await webWallet?.get_wallet_summary(); | ||
console.log("summary", summary); | ||
console.log("balances"); | ||
|
||
setSummary(summary); | ||
}; | ||
|
||
export function Header({ | ||
walletSummary, | ||
refreshSummary, | ||
activeAccount, | ||
setActiveAccount, | ||
triggerRescan, | ||
chainHeight, | ||
}: { | ||
walletSummary: WalletSummary | null; | ||
refreshSummary: () => Promise<void>; | ||
activeAccount: number; | ||
setActiveAccount: (account: number) => void; | ||
triggerRescan: () => void; | ||
chainHeight: bigint | null; | ||
}) { | ||
return ( | ||
<div className="p-2"> | ||
<span className="me-2">Balance: </span> | ||
</div> | ||
<Stack direction="horizontal" gap={3}> | ||
<Form.Select | ||
value={activeAccount} | ||
onChange={(e) => setActiveAccount(parseInt(e.target.value))} | ||
> | ||
{walletSummary?.account_balances.map(([id]) => ( | ||
<option key={id} value={id}> | ||
Account {id} | ||
</option> | ||
))} | ||
</Form.Select> | ||
<Card style={{ width: "30rem" }}> | ||
<Card.Title>Balance: {0} ZEC</Card.Title> | ||
<Card.Text>Available Balance: {0} ZEC</Card.Text> | ||
</Card> | ||
<Card style={{ width: "30rem" }}> | ||
<Card.Text>Chain Height: {chainHeight ? ""+chainHeight : '?'}</Card.Text> | ||
<Card.Text>Synced Height: {walletSummary?.fully_scanned_height ? walletSummary?.fully_scanned_height : '?'}</Card.Text> | ||
</Card> | ||
<Stack> | ||
<Button onClick={async () => await refreshSummary()}>Refresh</Button> | ||
<Button onClick={() => triggerRescan()}>Sync</Button> | ||
</Stack> | ||
</Stack> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React, { useContext, useEffect, useState } from "react"; | ||
|
||
import Form from "react-bootstrap/Form"; | ||
|
||
import { WalletContext } from "../App"; | ||
import { WalletSummary, AccountBalance } from "@webzjs/webz-core"; | ||
import { Button } from "react-bootstrap"; | ||
|
||
export function Summary({ | ||
walletSummary, | ||
}: { | ||
walletSummary: WalletSummary | null; | ||
}) { | ||
return ( | ||
<div> | ||
<pre> | ||
{JSON.stringify( | ||
walletSummary?.toJSON(), | ||
(key, value) => | ||
typeof value === "bigint" ? value.toString() : value, | ||
2 | ||
)} | ||
</pre> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters