mirror of
https://github.com/Instadapp/assembly.git
synced 2024-07-29 22:37:06 +00:00
Update useWeb3.ts
This commit is contained in:
parent
c19e09c363
commit
ddbd31f241
|
|
@ -1,6 +1,6 @@
|
||||||
import { computed, onMounted, ref, watch } from "@nuxtjs/composition-api";
|
import { computed, onMounted, ref, watch } from "@nuxtjs/composition-api";
|
||||||
import Web3 from "web3";
|
import Web3 from "web3";
|
||||||
import { SafeAppWeb3Modal } from '@gnosis.pm/safe-apps-web3modal'
|
import { SafeAppWeb3Modal } from "@gnosis.pm/safe-apps-web3modal";
|
||||||
import { Network } from "./useNetwork";
|
import { Network } from "./useNetwork";
|
||||||
|
|
||||||
let web3Modal: SafeAppWeb3Modal;
|
let web3Modal: SafeAppWeb3Modal;
|
||||||
|
|
@ -49,6 +49,10 @@ export function useWeb3() {
|
||||||
if (web3Modal.cachedProvider) {
|
if (web3Modal.cachedProvider) {
|
||||||
await activate();
|
await activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (await web3Modal.isSafeApp()) {
|
||||||
|
await activate();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const activate = async () => {
|
const activate = async () => {
|
||||||
|
|
@ -126,11 +130,11 @@ export function useWeb3() {
|
||||||
|
|
||||||
const setWeb3 = (newWeb3: Web3) => {
|
const setWeb3 = (newWeb3: Web3) => {
|
||||||
web3.value = newWeb3;
|
web3.value = newWeb3;
|
||||||
}
|
};
|
||||||
|
|
||||||
watch(web3, () => {
|
watch(web3, () => {
|
||||||
window.web3 = web3.value;
|
window.web3 = web3.value;
|
||||||
})
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
account,
|
account,
|
||||||
|
|
@ -141,6 +145,6 @@ export function useWeb3() {
|
||||||
deactivate,
|
deactivate,
|
||||||
networkName,
|
networkName,
|
||||||
refreshWeb3,
|
refreshWeb3,
|
||||||
setWeb3,
|
setWeb3
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user