Skip to content

Commit

Permalink
fix: impersonated
Browse files Browse the repository at this point in the history
  • Loading branch information
Argeare5 committed Jan 11, 2024
1 parent 9233aee commit fd8b414
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/web3/connectors/ImpersonatedConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ export function impersonated(parameters: ImpersonatedParameters) {
connected = false;
},
async getProvider({ chainId }: { chainId?: number } = {}) {
accountAddress = parameters.getAccountAddress() || zeroAddress;
accountAddress =
(!!parameters.getAccountAddress()
? parameters.getAccountAddress()
: zeroAddress) || zeroAddress;
const chain =
config.chains.find((x) => x.id === chainId) ?? config.chains[0];
const url = chain.rpcUrls.default.http[0]!;
Expand Down
17 changes: 11 additions & 6 deletions src/web3/store/walletSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,15 @@ export function createWalletSlice({
},
disconnectActiveWallet: async () => {
const config = get().wagmiConfig;
if (config && !!config.connectors.length) {
await disconnect(config);
set({ activeWallet: undefined });
deleteLocalStorageWallet();
clearWalletLinkLocalStorage();
clearWalletConnectV2LocalStorage();
if (config) {
const account = getAccount(config);
if (account.isConnected) {
await disconnect(config);
set({ activeWallet: undefined });
deleteLocalStorageWallet();
clearWalletLinkLocalStorage();
clearWalletConnectV2LocalStorage();
}
}
},
resetWalletConnectionError: () => {
Expand Down Expand Up @@ -319,6 +322,8 @@ export function createWalletSlice({
getImpersonatedAddress: () => {
const impersonated = get().impersonated;

console.log('getImpersonatedAddress', impersonated);

if (impersonated) {
if (impersonated.isViewOnly) {
return impersonated.address;
Expand Down

0 comments on commit fd8b414

Please sign in to comment.