Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions packages/use-wallet-react/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ export const useWallet = () => {
if (networkId === activeNetwork) {
return
}
// Disconnect any connected wallets
await manager.disconnect()

console.info(`[React] Creating Algodv2 client for ${networkId}...`)

Expand Down
2 changes: 0 additions & 2 deletions packages/use-wallet-solid/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ export function useWallet() {
if (activeNetwork() === networkId) {
return
}
// Disconnect any connected wallets
await manager().disconnect()

console.info(`[Solid] Creating Algodv2 client for ${networkId}...`)

Expand Down
4 changes: 3 additions & 1 deletion packages/use-wallet-vue/src/__tests__/useWallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,9 @@ describe('useWallet', () => {
const { setActiveNetwork, algodClient } = useWallet()

const newNetwork = NetworkId.MAINNET
const newAlgodClient = new algosdk.Algodv2('mock-token', 'https://mock-server', '')

// Default mainnet algod config
const newAlgodClient = new algosdk.Algodv2('', 'https://mainnet-api.algonode.cloud/', '')

mockWalletManager.setActiveNetwork = async (networkId: NetworkId) => {
mockSetAlgodClient(newAlgodClient)
Expand Down
2 changes: 0 additions & 2 deletions packages/use-wallet-vue/src/useWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ export function useWallet() {
if (networkId === activeNetwork.value) {
return
}
// Disconnect any connected wallets
await manager.disconnect()

console.info(`[Vue] Creating Algodv2 client for ${networkId}...`)

Expand Down
26 changes: 0 additions & 26 deletions packages/use-wallet/src/__tests__/manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,36 +207,10 @@ describe('WalletManager', () => {
[WalletId.KIBISIS, mockKibisisWallet]
])

// Mock isConnected to return true
vi.spyOn(mockDeflyWallet, 'isConnected', 'get').mockReturnValue(true)
vi.spyOn(mockKibisisWallet, 'isConnected', 'get').mockReturnValue(true)

const disconnectMock = vi.spyOn(manager, 'disconnect')

await manager.setActiveNetwork(NetworkId.MAINNET)

expect(disconnectMock).toHaveBeenCalled()
expect(manager.activeNetwork).toBe(NetworkId.MAINNET)
})

it('does not call disconnect if the network is already active', async () => {
const manager = new WalletManager({
wallets: [WalletId.DEFLY, WalletId.KIBISIS]
})
manager._clients = new Map<WalletId, BaseWallet>([
[WalletId.DEFLY, mockDeflyWallet],
[WalletId.KIBISIS, mockKibisisWallet]
])

const disconnectMock = vi.spyOn(manager, 'disconnect')

// Set initial active network
manager.store.setState((state) => ({ ...state, activeNetwork: NetworkId.MAINNET }))

await manager.setActiveNetwork(NetworkId.MAINNET)

expect(disconnectMock).not.toHaveBeenCalled()
})
})

describe('subscribe', () => {
Expand Down
2 changes: 0 additions & 2 deletions packages/use-wallet/src/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,6 @@ export class WalletManager {
if (this.activeNetwork === networkId) {
return
}
// Disconnect any connected wallets
await this.disconnect()

setActiveNetwork(this.store, { networkId })
this.algodClient = this.createAlgodClient(this.networkConfig[networkId])
Expand Down