Skip to content

Commit

Permalink
remove isSupportedChain
Browse files Browse the repository at this point in the history
  • Loading branch information
gjeanmart committed Oct 29, 2024
1 parent 03e3619 commit 6e3aeac
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
3 changes: 1 addition & 2 deletions src/components/safe-apps/AppFrame/useAppCommunicator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { selectRpc } from '@/store/settingsSlice'
import { createSafeAppsWeb3Provider } from '@/hooks/wallets/web3'
import { useGetSafenetConfigQuery } from '@/store/safenet'
import { QueryStatus } from '@reduxjs/toolkit/query'
import { isSupportedChain } from '@/utils/safenet'
import { SAFENET_API_URL } from '@/config/constants'
import { useDarkMode } from '@/hooks/useDarkMode'

Expand Down Expand Up @@ -83,7 +82,7 @@ const useAppCommunicator = (
safenetConfigStatus === QueryStatus.fulfilled &&
chain &&
safenetConfig &&
isSupportedChain(Number(chain.chainId), safenetConfig)
safenetConfig.chains.includes(Number(chain.chainId))
const isDarkMode = useDarkMode()

const safeAppWeb3Provider = useMemo(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/loadables/useLoadBalances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { POLLING_INTERVAL } from '@/config/constants'
import useIntervalCounter from '../useIntervalCounter'
import useSafeInfo from '../useSafeInfo'
import { useGetSafenetConfigQuery } from '@/store/safenet'
import { convertSafenetBalanceToSafeClientGatewayBalance, isSupportedChain } from '@/utils/safenet'
import { convertSafenetBalanceToSafeClientGatewayBalance } from '@/utils/safenet'
import { getSafenetBalances } from '@/store/safenet'

export const useTokenListSetting = (): boolean | undefined => {
Expand Down Expand Up @@ -55,7 +55,7 @@ export const useLoadBalances = (): AsyncResult<SafeBalanceResponse> => {
const web3 = useWeb3()
const chain = useCurrentChain()
const chainId = safe.chainId
const chainSupportedBySafenet = isSafenetConfigSuccess && isSupportedChain(Number(chainId), safenetConfig)
const chainSupportedBySafenet = isSafenetConfigSuccess && safenetConfig.chains.includes(Number(chainId))

// Re-fetch assets when the entire SafeInfo updates
const [data, error, loading] = useAsync<SafeBalanceResponse | undefined>(
Expand Down
3 changes: 1 addition & 2 deletions src/pages/settings/safenet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
import type { ExtendedSafeInfo } from '@/store/safeInfoSlice'
import { SAFE_FEATURES } from '@safe-global/protocol-kit/dist/src/utils'
import { hasSafeFeature } from '@/utils/safe-versions'
import { isSupportedChain } from '@/utils/safenet'
import { getRTKErrorMessage } from '@/utils/redux-toolkit-query'

const getSafenetTokensByChain = (chainId: number, safenetConfig: SafenetConfigEntity): string[] => {
Expand All @@ -41,7 +40,7 @@ const SafenetContent = ({ safenetConfig, safe }: { safenetConfig: SafenetConfigE
const safenetGuardAddress = safenetConfig.guards[safe.chainId]
const safenetProcessorAddress = safenetConfig.processors[safe.chainId]
const isSafenetGuardEnabled = isVersionWithGuards && sameAddress(safe.guard?.value, safenetGuardAddress)
const chainSupported = isSupportedChain(Number(safe.chainId), safenetConfig)
const chainSupported = safenetConfig.chains.includes(Number(safe.chainId))
const { setTxFlow } = useContext(TxModalContext)

// Lazy query because running it on unsupported chain throws an error
Expand Down
6 changes: 1 addition & 5 deletions src/utils/safenet.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import type { SafenetBalanceEntity, SafenetConfigEntity } from '@/store/safenet'
import { TokenType, type SafeBalanceResponse } from '@safe-global/safe-gateway-typescript-sdk'

const isSupportedChain = (chainId: number, safenetConfig: SafenetConfigEntity) => {
return safenetConfig.chains.includes(chainId)
}

const convertSafenetBalanceToSafeClientGatewayBalance = (
safenetBalance: SafenetBalanceEntity,
safenetConfig: SafenetConfigEntity,
Expand Down Expand Up @@ -39,4 +35,4 @@ const convertSafenetBalanceToSafeClientGatewayBalance = (
return balances
}

export { isSupportedChain, convertSafenetBalanceToSafeClientGatewayBalance }
export { convertSafenetBalanceToSafeClientGatewayBalance }

0 comments on commit 6e3aeac

Please sign in to comment.