-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #422 from MeshJS/fix-cip45
fix cip45 react UI component and bump version
- Loading branch information
Showing
17 changed files
with
311 additions
and
268 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
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
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
56 changes: 56 additions & 0 deletions
56
packages/mesh-react/src/cardano-wallet/connected-button.tsx
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,56 @@ | ||
import { useEffect, useState } from "react"; | ||
|
||
import { Button } from "../common/button"; | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuLabel, | ||
DropdownMenuSeparator, | ||
DropdownMenuTrigger, | ||
} from "../common/dropdown-menu"; | ||
import { useWallet } from "../hooks"; | ||
|
||
export default function ConnectedButton() { | ||
const { wallet, connected, disconnect } = useWallet(); | ||
const [address, setAddress] = useState(""); | ||
|
||
useEffect(() => { | ||
if (connected && wallet) { | ||
async function afterConnectedWallet() { | ||
let address = (await wallet.getUnusedAddresses())[0]; | ||
if (!address) address = await wallet.getChangeAddress(); | ||
setAddress(address); | ||
} | ||
afterConnectedWallet(); | ||
} | ||
}, [connected, wallet]); | ||
|
||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger> | ||
<Button variant="outline" className="mesh-text-white"> | ||
{address.slice(0, 6)}...{address.slice(-6)} | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent> | ||
<DropdownMenuLabel>Wallet</DropdownMenuLabel> | ||
<DropdownMenuSeparator /> | ||
<DropdownMenuItem | ||
onClick={() => { | ||
navigator.clipboard.writeText(address); | ||
}} | ||
> | ||
Copy Address | ||
</DropdownMenuItem> | ||
<DropdownMenuItem | ||
onClick={() => { | ||
disconnect(); | ||
}} | ||
> | ||
Disconnect | ||
</DropdownMenuItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); | ||
} |
Oops, something went wrong.