use shallowRef for connector, provider and library

This commit is contained in:
Georges KABBOUCHI 2022-06-15 17:37:37 +03:00
parent 00ad34076c
commit 37fad40f13
2 changed files with 12 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@instadapp/vue-web3", "name": "@instadapp/vue-web3",
"version": "0.8.3", "version": "0.9.0",
"description": "Vue web3 composition api", "description": "Vue web3 composition api",
"license": "MIT", "license": "MIT",
"main": "index.js", "main": "index.js",

View File

@ -1,7 +1,14 @@
import { AbstractConnector } from '@web3-react/abstract-connector' import { AbstractConnector } from '@web3-react/abstract-connector'
import { normalizeAccount, normalizeChainId } from './normalizers' import { normalizeAccount, normalizeChainId } from './normalizers'
import { ConnectorEvent, ConnectorUpdate } from '@web3-react/types' import { ConnectorEvent, ConnectorUpdate } from '@web3-react/types'
import { computed, onBeforeUnmount, Ref, ref, watch } from 'vue-demi' import {
computed,
onBeforeUnmount,
Ref,
ref,
shallowRef,
watch,
} from 'vue-demi'
export class UnsupportedChainIdError extends Error { export class UnsupportedChainIdError extends Error {
public constructor( public constructor(
@ -16,10 +23,10 @@ export class UnsupportedChainIdError extends Error {
} }
} }
const connector = ref<AbstractConnector>() const connector = shallowRef<AbstractConnector>()
const chainId = ref() const chainId = ref()
const account = ref<null | string>() const account = ref<null | string>()
const provider = ref<any>() const provider = shallowRef<any>()
const error = ref<Error>() const error = ref<Error>()
const active = computed( const active = computed(
() => () =>
@ -28,7 +35,7 @@ const active = computed(
account.value !== undefined && account.value !== undefined &&
!!!error.value, !!!error.value,
) )
const library = ref() const library = shallowRef()
let getLibrary: any = (provider?: any, connector?: any) => (): any => null let getLibrary: any = (provider?: any, connector?: any) => (): any => null