Skip to content

Commit

Permalink
Fix network switch with inmemory signer
Browse files Browse the repository at this point in the history
Signed-off-by: Manank Patni <[email protected]>
  • Loading branch information
Man-Jain committed Aug 7, 2023
1 parent b9c8c62 commit 8d3d35f
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/services/beacon/hooks/useTezos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,27 @@ export const useTezos = (): WalletConnectReturn => {
}
})
} else {
const { wallet } = await connectWithBeacon(newNetwork)
newTezos.setProvider({ wallet })
const newAccount = await newTezos.wallet.pkh()
let wallet, account

if (getEnv(EnvKey.REACT_APP_IS_NOT_TESTING) === "true") {
const { wallet: beaconWallet } = await connectWithBeacon(network)
wallet = beaconWallet
newTezos.setProvider({ wallet })
account = await newTezos.wallet.pkh()
} else {
const signer = await InMemorySigner.fromSecretKey(ALICE_PRIV_KEY)
wallet = signer
account = await signer.publicKeyHash()
newTezos.setProvider({ signer })
}

dispatch({
type: TezosActionType.UPDATE_TEZOS,
payload: {
network: newNetwork,
tezos: newTezos,
account: newAccount,
wallet
account,
wallet: wallet as BeaconWallet
}
})
}
Expand Down

0 comments on commit 8d3d35f

Please sign in to comment.