-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: migrate authentication system from Lock to in-house to support …
…EIP-6963
- Loading branch information
Showing
38 changed files
with
1,038 additions
and
1,790 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,39 @@ | ||
<script lang="ts" setup> | ||
import { Connector, ConnectorType } from '@/networks/types'; | ||
const props = defineProps<{ | ||
supportedConnectors?: ConnectorType[]; | ||
}>(); | ||
const emit = defineEmits<{ | ||
(e: 'click', connector: Connector): void; | ||
}>(); | ||
const { connectors } = useConnectors(); | ||
const availableConnectors = computed(() => { | ||
if (!props.supportedConnectors?.length) return connectors.value; | ||
return connectors.value.filter(connector => | ||
props.supportedConnectors!.includes(connector.type) | ||
); | ||
}); | ||
</script> | ||
|
||
<template> | ||
<UiButton | ||
v-for="connector in availableConnectors" | ||
:key="connector.id" | ||
class="w-full flex justify-center items-center gap-2" | ||
@click="emit('click', connector)" | ||
> | ||
<img | ||
:src="connector.info.icon" | ||
height="28" | ||
width="28" | ||
class="rounded-sm" | ||
:alt="connector.info.name" | ||
/> | ||
{{ connector.info.name }} | ||
</UiButton> | ||
</template> |
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 |
---|---|---|
@@ -1,73 +1,28 @@ | ||
<script setup lang="ts"> | ||
import { getInjected } from '@snapshot-labs/lock/src/utils'; | ||
import connectors, { | ||
getConnectorIconUrl, | ||
mapConnectorId | ||
} from '@/helpers/connectors'; | ||
const win = window; | ||
const injected = getInjected(); | ||
if (injected) | ||
connectors['injected'] = { | ||
...connectors['injected'], | ||
...injected, | ||
id: 'injected', | ||
icon: connectors[mapConnectorId(injected.id)]?.icon ?? injected.icon | ||
}; | ||
import { Connector, ConnectorType } from '@/networks/types'; | ||
const props = defineProps<{ | ||
open: boolean; | ||
supportedConnectors: string[]; | ||
supportedConnectors: ConnectorType[]; | ||
}>(); | ||
const emit = defineEmits<{ | ||
(e: 'pick', connector: string): void; | ||
(e: 'pick', connector: Connector): void; | ||
(e: 'close'): void; | ||
}>(); | ||
const { open } = toRefs(props); | ||
const availableConnectors = computed(() => { | ||
return Object.values(connectors).filter(connector => { | ||
if (!props.supportedConnectors.includes(connector.id)) return false; | ||
const hasNoType = !('type' in connector) || !connector.type; | ||
const isActive = | ||
'type' in connector && | ||
'root' in connector && | ||
connector.type === 'injected' && | ||
win[connector.root]; | ||
return hasNoType || isActive; | ||
}); | ||
}); | ||
</script> | ||
|
||
<template> | ||
<UiModal :open="open" @close="emit('close')"> | ||
<template #header> | ||
<h3 v-text="'Log in'" /> | ||
</template> | ||
<div> | ||
<div class="m-4 space-y-2 flex flex-col"> | ||
<button | ||
v-for="connector in availableConnectors" | ||
:key="connector.id" | ||
type="button" | ||
@click="emit('pick', connector.id)" | ||
> | ||
<UiButton class="w-full flex justify-center items-center"> | ||
<img | ||
:src="getConnectorIconUrl(connector.icon)" | ||
height="28" | ||
width="28" | ||
class="mr-2 -mt-1" | ||
:alt="connector.name" | ||
/> | ||
{{ connector.name }} | ||
</UiButton> | ||
</button> | ||
</div> | ||
<div class="m-4 space-y-2 flex flex-col"> | ||
<Connectors | ||
:connectors-type="supportedConnectors" | ||
@click="(connector: Connector) => emit('pick', connector)" | ||
/> | ||
</div> | ||
</UiModal> | ||
</template> |
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.