From 14b61528b28c41f5a62a2d5536bd2a37d58cc0d0 Mon Sep 17 00:00:00 2001 From: KillariDev Date: Fri, 29 Nov 2024 12:48:03 +0200 Subject: [PATCH] rename current to active --- app/inpage/ts/inpage.ts | 8 +++--- app/ts/AddressBook.tsx | 28 +++++++++---------- app/ts/background/accessManagement.ts | 4 +-- app/ts/background/background-startup.ts | 2 +- app/ts/background/background.ts | 11 +++----- app/ts/background/iconHandler.ts | 4 +-- app/ts/background/popupMessageHandlers.ts | 10 +++---- app/ts/background/providerMessageHandlers.ts | 2 +- app/ts/background/settings.ts | 8 +++--- app/ts/components/App.tsx | 2 +- .../subcomponents/ConfigureRpcConnection.tsx | 10 +++---- app/ts/types/interceptor-messages.ts | 4 +-- app/ts/utils/storageUtils.ts | 4 +-- 13 files changed, 47 insertions(+), 50 deletions(-) diff --git a/app/inpage/ts/inpage.ts b/app/inpage/ts/inpage.ts index 6c5ac751..641042d6 100644 --- a/app/inpage/ts/inpage.ts +++ b/app/inpage/ts/inpage.ts @@ -177,7 +177,7 @@ class InterceptorMessageListener { private readonly onChainChangedCallBacks: Set<((chainId: string) => void)> = new Set() private currentAddress = '' - private currentChainId = '' + private activeChainId = '' private currentSigner: Signer = 'NoSigner' private waitForAccountsFromWallet: InterceptorFuture | undefined = undefined @@ -451,8 +451,8 @@ class InterceptorMessageListener { } case 'chainChanged': { const reply = replyRequest.result as string - if (this.currentChainId === reply) return - this.currentChainId = reply + if (this.activeChainId === reply) return + this.activeChainId = reply if (this.metamaskCompatibilityMode && this.signerWindowEthereumRequest === undefined && window.ethereum !== undefined) { try { window.ethereum.chainId = reply } catch(error) {} try { window.ethereum.networkVersion = Number(reply).toString(10) } catch(error) {} @@ -546,7 +546,7 @@ class InterceptorMessageListener { const chainId = forwardRequest.result as string try { window.ethereum.chainId = chainId } catch(e) {} try { window.ethereum.networkVersion = Number(chainId).toString(10) } catch(e) {} - this.currentChainId = chainId + this.activeChainId = chainId break } } diff --git a/app/ts/AddressBook.tsx b/app/ts/AddressBook.tsx index 149b2faf..55cee38f 100644 --- a/app/ts/AddressBook.tsx +++ b/app/ts/AddressBook.tsx @@ -178,8 +178,8 @@ type AddressBookEntriesWithFilter = { export function AddressBook() { const addressBookEntriesWithFilter = useSignal({ addressBookEntries: [], activeFilter: 'My Active Addresses' }) const addressBookEntries = useComputed(() => addressBookEntriesWithFilter.value.addressBookEntries || []) - const currentChain = useSignal(undefined) - const currentChainId = useComputed(() => currentChain.value?.chainId || 1n) + const activeChain = useSignal(undefined) + const activeChainId = useComputed(() => activeChain.value?.chainId || 1n) const rpcEntries = useSignal([]) const viewFilter = useSignal({ activeFilter: 'My Active Addresses', searchString: '', chain: undefined }) const modalState = useSignal({ page: 'noModal' }) @@ -201,24 +201,24 @@ export function AddressBook() { if (!maybeParsed.success) return // not a message we are interested in const parsed = maybeParsed.value if (parsed.method === 'popup_addressBookEntriesChanged') { - const chainId = currentChain.peek()?.chainId + const chainId = activeChain.peek()?.chainId if (chainId !== undefined) sendQuery() return } if (parsed.method === 'popup_settingsUpdated') return sendPopupMessageToBackgroundPage({ method: 'popup_requestSettings' }) if (parsed.method === 'popup_requestSettingsReply') { rpcEntries.value = parsed.data.rpcEntries - const prevCurrentNetwork = currentChain.peek() - if (prevCurrentNetwork === undefined || prevCurrentNetwork.chainId === parsed.data.currentRpcNetwork.chainId) { - currentChain.value = parsed.data.currentRpcNetwork - if (prevCurrentNetwork === undefined || viewFilter.value.chain === undefined) { - viewFilter.value = { ...viewFilter.value, chain: currentChain.value === undefined ? undefined : { name: currentChain.value.name, chainId: currentChain.value.chainId } } + const prevActiveNetwork = activeChain.peek() + if (prevActiveNetwork === undefined || prevActiveNetwork.chainId === parsed.data.activeRpcNetwork.chainId) { + activeChain.value = parsed.data.activeRpcNetwork + if (prevActiveNetwork === undefined || viewFilter.value.chain === undefined) { + viewFilter.value = { ...viewFilter.value, chain: activeChain.value === undefined ? undefined : { name: activeChain.value.name, chainId: activeChain.value.chainId } } } } } if (parsed.method !== 'popup_getAddressBookDataReply') return const reply = GetAddressBookDataReply.parse(msg) - if (currentChain.peek()?.chainId === reply.data.data.chainId) { + if (activeChain.peek()?.chainId === reply.data.data.chainId) { addressBookEntriesWithFilter.value = { addressBookEntries: reply.data.entries, activeFilter: reply.data.data.filter, @@ -239,9 +239,9 @@ export function AddressBook() { viewFilter.value = { ...viewFilter.peek(), searchString } } - function changeCurrentChain(entry: ChainEntry) { - if (entry.chainId === currentChain.peek()?.chainId) return - currentChain.value = entry + function changeActiveChain(entry: ChainEntry) { + if (entry.chainId === activeChain.peek()?.chainId) return + activeChain.value = entry viewFilter.value = { ...viewFilter.peek(), chain: { name: entry.name, chainId: entry.chainId } } } @@ -281,7 +281,7 @@ export function AddressBook() { abi: undefined, useAsActiveAddress: filter === 'My Active Addresses', declarativeNetRequestBlockMode: undefined, - chainId: currentChain.peek()?.chainId || 1n, + chainId: activeChain.peek()?.chainId || 1n, } } } return @@ -324,7 +324,7 @@ export function AddressBook() {
- +