mirror of
https://github.com/Instadapp/assembly.git
synced 2024-07-29 22:37:06 +00:00
hide network selector in gnosis safe
This commit is contained in:
parent
7bc988ed9e
commit
83b93dcf13
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="relative w-1/2 md:w-[178px]" v-click-outside="hide">
|
<div v-if="!isGnosisSafe" class="relative w-1/2 md:w-[178px]" v-click-outside="hide">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="bg-primary-blue-dark hover:bg-primary-blue-hover relative w-full border border-primary-blue-border rounded pl-2.5 pr-10 py-1.5 text-left focus:outline-none focus:ring-1 focus:ring-[#0846E4] focus:border-[#0846E4] sm:text-sm"
|
class="bg-primary-blue-dark hover:bg-primary-blue-hover relative w-full border border-primary-blue-border rounded pl-2.5 pr-10 py-1.5 text-left focus:outline-none focus:ring-1 focus:ring-[#0846E4] focus:border-[#0846E4] sm:text-sm"
|
||||||
|
@ -102,14 +102,19 @@
|
||||||
import { defineComponent, nextTick, ref } from '@nuxtjs/composition-api'
|
import { defineComponent, nextTick, ref } from '@nuxtjs/composition-api'
|
||||||
import { useNetwork } from '~/composables/useNetwork'
|
import { useNetwork } from '~/composables/useNetwork'
|
||||||
import { useTenderly } from '~/composables/useTenderly'
|
import { useTenderly } from '~/composables/useTenderly'
|
||||||
|
import { useWeb3 } from '@instadapp/vue-web3'
|
||||||
|
import { gnosisSafe } from '~/connectors'
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
setup() {
|
setup() {
|
||||||
const show = ref(false)
|
const show = ref(false)
|
||||||
|
|
||||||
|
const { connector } = useWeb3()
|
||||||
const { networks, activeNetworkId, activeNetwork, checkForNetworkMismatch } = useNetwork()
|
const { networks, activeNetworkId, activeNetwork, checkForNetworkMismatch } = useNetwork()
|
||||||
const { stopSimulation } = useTenderly()
|
const { stopSimulation } = useTenderly()
|
||||||
|
|
||||||
|
const isGnosisSafe = computed(() => connector.value === gnosisSafe)
|
||||||
|
|
||||||
const setActiveNetwork = async networkId => {
|
const setActiveNetwork = async networkId => {
|
||||||
await stopSimulation()
|
await stopSimulation()
|
||||||
activeNetworkId.value = networkId;
|
activeNetworkId.value = networkId;
|
||||||
|
@ -129,6 +134,7 @@ export default defineComponent({
|
||||||
activeNetwork,
|
activeNetwork,
|
||||||
setActiveNetwork,
|
setActiveNetwork,
|
||||||
activeNetworkId,
|
activeNetworkId,
|
||||||
|
isGnosisSafe,
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,18 +2,23 @@ import { useWeb3 } from "@instadapp/vue-web3";
|
||||||
import { injected } from "../connectors";
|
import { injected } from "../connectors";
|
||||||
import { onMounted, ref, watch } from "@nuxtjs/composition-api";
|
import { onMounted, ref, watch } from "@nuxtjs/composition-api";
|
||||||
import { SafeAppConnector } from "@gnosis.pm/safe-apps-web3-react";
|
import { SafeAppConnector } from "@gnosis.pm/safe-apps-web3-react";
|
||||||
|
import { useNetwork } from "./useNetwork";
|
||||||
|
|
||||||
export function useSafeAppConnection(connector?: SafeAppConnector) {
|
export function useSafeAppConnection(connector?: SafeAppConnector) {
|
||||||
const { activate, active } = useWeb3();
|
const { activate, active } = useWeb3();
|
||||||
|
const { activeNetworkId} = useNetwork();
|
||||||
|
|
||||||
const tried = ref(false);
|
const tried = ref(false);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
connector?.isSafeApp().then((loadedInSafe: boolean) => {
|
connector?.isSafeApp().then(async (loadedInSafe: boolean) => {
|
||||||
if (loadedInSafe) {
|
if (loadedInSafe) {
|
||||||
activate(connector, undefined, true).catch(() => {
|
await activate(connector, undefined, true).catch(() => {
|
||||||
tried.value = true;
|
tried.value = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//@ts-ignore
|
||||||
|
activeNetworkId.value = await connector.getChainId()
|
||||||
} else {
|
} else {
|
||||||
tried.value = true;
|
tried.value = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user