-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update examples and deps updates
- Loading branch information
1 parent
94f8792
commit 19d35a2
Showing
17 changed files
with
2,963 additions
and
2,835 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 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,88 @@ | ||
import { clsx } from 'clsx' | ||
import { useFilsnap } from 'filsnap-adapter-react' | ||
import { Token } from 'iso-filecoin/token' | ||
import { useAccount, useBalance } from 'wagmi' | ||
import ExplorerLink from './explorer-link.jsx' | ||
|
||
/** | ||
* @typedef {import('filsnap-adapter-react').} FilsnapContext | ||
*/ | ||
|
||
/** | ||
* Connect to the network. | ||
*/ | ||
export default function ConnectAll() { | ||
const { | ||
isConnected: isConnectedSnap, | ||
account, | ||
connect, | ||
disconnect, | ||
config, | ||
} = useFilsnap() | ||
const { isConnected: isConnectedWagmi, address } = useAccount() | ||
const { data } = useBalance({ | ||
address, | ||
}) | ||
|
||
const isConnected = isConnectedWagmi && isConnectedSnap | ||
|
||
let out = null | ||
|
||
if (!isConnected) { | ||
out = ( | ||
<button | ||
type="button" | ||
data-testid="connect-snap" | ||
onClick={() => { | ||
connect() | ||
}} | ||
> | ||
Connect | ||
</button> | ||
) | ||
} | ||
|
||
if (isConnected) { | ||
out = ( | ||
<> | ||
<h3>Native Account</h3> | ||
<div> | ||
<b> | ||
{account | ||
? Token.fromAttoFIL(account.balance).toFIL().toFormat() | ||
: 'unknown'}{' '} | ||
{config.unit.symbol} | ||
</b> | ||
</div> | ||
<span data-testid="account-info"> | ||
<ExplorerLink address={account.address} chain="filecoin" /> | ||
</span> | ||
<br /> | ||
<h3>FEVM Account</h3> | ||
<div> | ||
<b> | ||
{data?.formatted} {data?.symbol} | ||
</b> | ||
</div> | ||
<ExplorerLink address={address} chain="ethereum" /> | ||
<ExplorerLink address={address} chain="filecoin" /> | ||
<br /> | ||
<button | ||
type="button" | ||
data-testid="connect-snap" | ||
onClick={() => { | ||
disconnect() | ||
}} | ||
> | ||
Disconnect | ||
</button> | ||
</> | ||
) | ||
} | ||
|
||
return ( | ||
<div class={clsx('Cell100', 'Box', !isConnected && 'u-AlignCenter')}> | ||
{out} | ||
</div> | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.