From a4b491a67d9864f7adbd6c9eac241e7d427d5510 Mon Sep 17 00:00:00 2001 From: jinoosss <112360739+jinoosss@users.noreply.github.com> Date: Tue, 5 Sep 2023 10:48:18 +0900 Subject: [PATCH] fix: Add network change injection method (#265) --- .../adena-extension/src/inject/message/methods/network.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/adena-extension/src/inject/message/methods/network.ts b/packages/adena-extension/src/inject/message/methods/network.ts index 414910b4..43994238 100644 --- a/packages/adena-extension/src/inject/message/methods/network.ts +++ b/packages/adena-extension/src/inject/message/methods/network.ts @@ -4,11 +4,11 @@ import { InjectionMessage, InjectionMessageInstance } from '../message'; import { InjectCore } from './core'; import { NetworkMetainfo } from '@states/network'; -function existsChainId(network: NetworkMetainfo, chainId: string) { +function matchChainId(network: NetworkMetainfo, chainId: string) { return network.chainId === chainId; } -function existsRPCUrl(network: NetworkMetainfo, rpcUrl: string) { - return network.rpcUrl === rpcUrl; +function matchRPCUrl(network: NetworkMetainfo, rpcUrl: string) { + return network.rpcUrl === rpcUrl.replace(/\/$/, ''); } export const addNetwork = async ( @@ -30,7 +30,7 @@ export const addNetwork = async ( const existNetwork = networks.findIndex( (current) => - (existsChainId(current, chainId) || existsRPCUrl(current, chainId)) && + (matchChainId(current, chainId) || matchRPCUrl(current, rpcUrl)) && current.deleted !== true, ) > -1; if (existNetwork) {