generated from Tahul/vue-composable-starter
-
-
Notifications
You must be signed in to change notification settings - Fork 49
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 #170 from vu3th/issue/165
Issue/165
- Loading branch information
Showing
14 changed files
with
315 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<script setup lang="ts"> | ||
import { useVueDapp, shortenAddress, type ConnectorName, RDNS } from '@vue-dapp/core' | ||
import { useVueDappModal } from '@vue-dapp/modal' | ||
const { providerDetails, wallet, address, status, connectTo, disconnect, error, isConnected } = useVueDapp() | ||
const providerList = computed(() => { | ||
return providerDetails.value.slice().sort((a, b) => { | ||
if (a.info.rdns === RDNS.rabby) return -1 | ||
if (b.info.rdns === RDNS.rabby) return 1 | ||
if (a.info.rdns === RDNS.metamask) return -1 | ||
if (b.info.rdns === RDNS.metamask) return 1 | ||
return 0 | ||
}) | ||
}) | ||
async function onClickWallet(connName: ConnectorName, rdns?: RDNS | string) { | ||
useVueDappModal().close() | ||
await connectTo(connName, { rdns }) | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="flex flex-col gap-2"> | ||
<div class="flex flex-wrap gap-2"> | ||
<n-button | ||
v-for="detail in providerList" | ||
:key="detail.info.uuid" | ||
@click="onClickWallet('BrowserWallet', detail.info.rdns)" | ||
size="medium" | ||
:disabled="status === 'connecting' || wallet.providerInfo?.rdns === detail.info.rdns" | ||
> | ||
<div>{{ detail.info.name }}</div> | ||
</n-button> | ||
<p v-if="!providerList.length">No provider was found in this browser.</p> | ||
</div> | ||
<div | ||
:class="{ | ||
'h-[200px]': status !== 'idle', | ||
}" | ||
> | ||
<div class="flex flex-col gap-1"> | ||
<div v-if="status === 'connecting'">Connecting...</div> | ||
<div v-if="isConnected" class="flex flex-col gap-1"> | ||
<div>uuid: {{ wallet.providerInfo?.uuid }}</div> | ||
<div>name: {{ wallet.providerInfo?.name }}</div> | ||
<div class="flex items-center gap-2"> | ||
<span class="">icon:</span> | ||
<img | ||
class="w-5 h-5 m-0 p-0" | ||
:src="wallet.providerInfo?.icon" | ||
:alt="wallet.providerInfo?.name" | ||
/> | ||
</div> | ||
<div>rdns: {{ wallet.providerInfo?.rdns }}</div> | ||
<div class="mt-5 flex items-center gap-2"> | ||
<n-button @click="disconnect">Disconnect</n-button> | ||
<div>{{ shortenAddress(address || '') }}</div> | ||
</div> | ||
</div> | ||
</div> | ||
<p class="text-red-500">{{ error }}</p> | ||
</div> | ||
</div> | ||
</template> | ||
<style lang="scss"></style> |
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
Oops, something went wrong.