Skip to content

Commit

Permalink
fix: optimize.
Browse files Browse the repository at this point in the history
  • Loading branch information
web3max committed Apr 12, 2024
1 parent 5e80f00 commit 79baaea
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
8 changes: 2 additions & 6 deletions src/lib/wallets/WalletConnectorHandler/UnisatConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,8 @@ export class UnisatConnector extends WalletConnector {
}

async switchNetwork(chainId: string): Promise<void> {
try {
const { provider } = this.context
await provider.switchNetwork(chainId)
} catch (err) {
console.error(err)
}
const { provider } = this.context
await provider.switchNetwork(chainId)
}

async signData(data: SignDataType): Promise<string | undefined> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class TronLinkEventListener extends WalletEventListener {
const isAuth = event.data?.message?.data?.data?.isAuth

if (!_chainId || !isAuth || eventTabReplyDebounce) {
// shim disconnect
if (_chainId && isAuth === false) {
this.removeEvents()
this.context.address = undefined
Expand All @@ -37,6 +38,7 @@ export class TronLinkEventListener extends WalletEventListener {
return
}

// switch network check
eventTabReplyDebounce = true
globalThis.setTimeout(() => {
eventTabReplyDebounce = false
Expand Down Expand Up @@ -129,6 +131,7 @@ export class TronLinkEventListener extends WalletEventListener {
}

if (event.data?.message?.action === 'disconnect') {
// shim disconnect
this.removeEvents()
this.context.address = undefined
this.context.chainId = undefined
Expand Down
2 changes: 1 addition & 1 deletion src/lib/wallets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class WalletSDK {

async sendTransaction(data: ISendTrxParams): Promise<string | undefined> {
const isInit = await this.initWallet()
if (!isInit) {
if (!isInit && !this.walletTransaction) {
// eslint-disable-next-line lingui/no-unlocalized-strings
throw new CustomError(errno.failedToInitializeWallet, 'sendTransaction: Please initialize wallet first')
}
Expand Down

0 comments on commit 79baaea

Please sign in to comment.