Skip to content

Commit

Permalink
fix: only check installed wallets for multicall
Browse files Browse the repository at this point in the history
  • Loading branch information
fracek committed Aug 28, 2022
1 parent 0ca8dc9 commit faad89b
Show file tree
Hide file tree
Showing 3 changed files with 2,412 additions and 6,809 deletions.
5 changes: 5 additions & 0 deletions .changeset/strong-pets-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@starknet-react/core': patch
---

Fix multicall execute when connectors missing
9 changes: 5 additions & 4 deletions packages/core/src/hooks/execute.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useCallback, useReducer } from 'react'
import type { AccountInterface } from 'starknet'
import { AddTransactionResponse } from 'starknet'
import { useStarknet, useStarknetTransactionManager } from '..'
import { useConnectors, useStarknet, useStarknetTransactionManager } from '..'

interface State {
data?: string
Expand Down Expand Up @@ -85,7 +85,8 @@ export function useStarknetExecute({ calls, metadata }: UseStarknetExecuteArgs)
loading: false,
})

const { account: accountAddress, connectors } = useStarknet()
const { account: accountAddress } = useStarknet()
const { available: availableConnectors } = useConnectors()

const reset = useCallback(() => {
dispatch({ type: 'reset' })
Expand All @@ -95,7 +96,7 @@ export function useStarknetExecute({ calls, metadata }: UseStarknetExecuteArgs)
if (calls) {
try {
let accountInterface: AccountInterface | null = null
for (const connector of connectors) {
for (const connector of availableConnectors) {
const account = await connector.account()
if (account.address === accountAddress) {
accountInterface = account
Expand All @@ -120,7 +121,7 @@ export function useStarknetExecute({ calls, metadata }: UseStarknetExecuteArgs)
}
}
return undefined
}, [accountAddress, connectors, addTransaction, calls, metadata])
}, [accountAddress, availableConnectors, addTransaction, calls, metadata])

return { data: state.data, loading: state.loading, error: state.error, reset, execute }
}
Loading

0 comments on commit faad89b

Please sign in to comment.