Skip to content

Commit

Permalink
feat: use isTestnet flag
Browse files Browse the repository at this point in the history
  • Loading branch information
schmanu committed Feb 8, 2024
1 parent e881ab1 commit b3692fb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@safe-global/safe-core-sdk-utils": "^1.7.4",
"@safe-global/safe-deployments": "1.32.0",
"@safe-global/safe-ethers-lib": "^1.9.4",
"@safe-global/safe-gateway-typescript-sdk": "^3.14.0",
"@safe-global/safe-gateway-typescript-sdk": "^3.15.0",
"@safe-global/safe-modules-deployments": "^1.2.0",
"@sentry/react": "^7.91.0",
"@spindl-xyz/attribution-lite": "^1.4.0",
Expand Down
7 changes: 1 addition & 6 deletions src/components/common/NetworkSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ const MenuWithTooltip = forwardRef<HTMLUListElement>(function MenuWithTooltip(pr
)
})

const testNets = ['gor', 'base-gor', 'sep']
const isTestnet = (shortName: string) => {
return testNets.includes(shortName)
}

const NetworkSelector = (props: { onChainSelect?: () => void }): ReactElement => {
const wallet = useWallet()
const isDarkMode = useDarkMode()
Expand All @@ -44,7 +39,7 @@ const NetworkSelector = (props: { onChainSelect?: () => void }): ReactElement =>
const chainId = useChainId()
const router = useRouter()

const [testNets, prodNets] = useMemo(() => partition(configs, (config) => isTestnet(config.shortName)), [configs])
const [testNets, prodNets] = useMemo(() => partition(configs, (config) => config.isTestnet), [configs])

const getNetworkLink = useCallback(
(shortName: string) => {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/loadables/useLoadTxQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const useLoadTxQueue = (): AsyncResult<TransactionListPage> => {
const { chainId, txQueuedTag, txHistoryTag } = safe
const [proposedId, setProposedId] = useState<string>('')
// N.B. we reload when txQueuedTag/txHistoryTag/proposedId changes as txQueuedTag alone is not enough
const reloadTag = txQueuedTag + txHistoryTag + proposedId
const reloadTag = (txQueuedTag ?? '') + (txHistoryTag ?? '') + proposedId

// Re-fetch when chainId/address, or txQueueTag change
const [data, error, loading] = useAsync<TransactionListPage>(
Expand Down
12 changes: 12 additions & 0 deletions src/tests/mocks/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const CONFIG_SERVICE_CHAINS: ChainInfo[] = [
chainName: 'Ethereum',
shortName: 'eth',
l2: false,
isTestnet: false,
description: 'The main Ethereum network',
rpcUri: { authentication: RPC_AUTHENTICATION.API_KEY_PATH, value: 'https://mainnet.infura.io/v3/' },
safeAppsRpcUri: { authentication: RPC_AUTHENTICATION.API_KEY_PATH, value: 'https://mainnet.infura.io/v3/' },
Expand Down Expand Up @@ -57,6 +58,7 @@ const CONFIG_SERVICE_CHAINS: ChainInfo[] = [
chainName: 'Gnosis Chain',
shortName: 'gno',
l2: true,
isTestnet: false,
description: '',
rpcUri: { authentication: RPC_AUTHENTICATION.NO_AUTHENTICATION, value: 'https://rpc.gnosischain.com/' },
safeAppsRpcUri: { authentication: RPC_AUTHENTICATION.NO_AUTHENTICATION, value: 'https://rpc.gnosischain.com/' },
Expand Down Expand Up @@ -105,6 +107,7 @@ const CONFIG_SERVICE_CHAINS: ChainInfo[] = [
chainName: 'Polygon',
shortName: 'matic',
l2: true,
isTestnet: false,
description: 'L2 chain (MATIC)',
rpcUri: { authentication: RPC_AUTHENTICATION.API_KEY_PATH, value: 'https://polygon-mainnet.infura.io/v3/' },
safeAppsRpcUri: { authentication: RPC_AUTHENTICATION.API_KEY_PATH, value: 'https://polygon-mainnet.infura.io/v3/' },
Expand Down Expand Up @@ -159,6 +162,7 @@ const CONFIG_SERVICE_CHAINS: ChainInfo[] = [
chainName: 'BNB Smart Chain',
shortName: 'bnb',
l2: true,
isTestnet: false,
description: '',
rpcUri: { authentication: RPC_AUTHENTICATION.NO_AUTHENTICATION, value: 'https://bsc-dataseed.binance.org/' },
safeAppsRpcUri: {
Expand Down Expand Up @@ -209,6 +213,7 @@ const CONFIG_SERVICE_CHAINS: ChainInfo[] = [
chainName: 'Energy Web Chain',
shortName: 'ewt',
l2: true,
isTestnet: false,
description: '',
rpcUri: { authentication: RPC_AUTHENTICATION.NO_AUTHENTICATION, value: 'https://rpc.energyweb.org' },
safeAppsRpcUri: { authentication: RPC_AUTHENTICATION.NO_AUTHENTICATION, value: 'https://rpc.energyweb.org' },
Expand Down Expand Up @@ -257,6 +262,7 @@ const CONFIG_SERVICE_CHAINS: ChainInfo[] = [
chainName: 'Arbitrum',
shortName: 'arb1',
l2: true,
isTestnet: false,
description: '',
rpcUri: { authentication: RPC_AUTHENTICATION.NO_AUTHENTICATION, value: 'https://arb1.arbitrum.io/rpc' },
safeAppsRpcUri: { authentication: RPC_AUTHENTICATION.NO_AUTHENTICATION, value: 'https://arb1.arbitrum.io/rpc' },
Expand Down Expand Up @@ -303,6 +309,7 @@ const CONFIG_SERVICE_CHAINS: ChainInfo[] = [
chainName: 'Aurora',
shortName: 'aurora',
l2: true,
isTestnet: false,
description: '',
rpcUri: { authentication: RPC_AUTHENTICATION.NO_AUTHENTICATION, value: 'https://mainnet.aurora.dev' },
safeAppsRpcUri: { authentication: RPC_AUTHENTICATION.NO_AUTHENTICATION, value: 'https://mainnet.aurora.dev' },
Expand Down Expand Up @@ -344,6 +351,7 @@ const CONFIG_SERVICE_CHAINS: ChainInfo[] = [
chainName: 'Avalanche',
shortName: 'avax',
l2: true,
isTestnet: false,
description: '',
rpcUri: { authentication: RPC_AUTHENTICATION.NO_AUTHENTICATION, value: 'https://api.avax.network/ext/bc/C/rpc' },
safeAppsRpcUri: {
Expand Down Expand Up @@ -397,6 +405,7 @@ const CONFIG_SERVICE_CHAINS: ChainInfo[] = [
chainName: 'Optimism',
shortName: 'oeth',
l2: true,
isTestnet: false,
description: '',
rpcUri: { authentication: RPC_AUTHENTICATION.NO_AUTHENTICATION, value: 'https://mainnet.optimism.io/' },
safeAppsRpcUri: { authentication: RPC_AUTHENTICATION.NO_AUTHENTICATION, value: 'https://mainnet.optimism.io/' },
Expand Down Expand Up @@ -443,6 +452,7 @@ const CONFIG_SERVICE_CHAINS: ChainInfo[] = [
chainName: 'Goerli',
shortName: 'gor',
l2: true,
isTestnet: true,
description: 'Ethereum Testnet Görli',
rpcUri: { authentication: RPC_AUTHENTICATION.API_KEY_PATH, value: 'https://goerli.infura.io/v3/' },
safeAppsRpcUri: { authentication: RPC_AUTHENTICATION.API_KEY_PATH, value: 'https://goerli.infura.io/v3/' },
Expand Down Expand Up @@ -492,6 +502,7 @@ const CONFIG_SERVICE_CHAINS: ChainInfo[] = [
chainName: 'Rinkeby',
shortName: 'rin',
l2: false,
isTestnet: true,
description: 'Ethereum testnet',
rpcUri: { authentication: RPC_AUTHENTICATION.API_KEY_PATH, value: 'https://rinkeby.infura.io/v3/' },
safeAppsRpcUri: { authentication: RPC_AUTHENTICATION.API_KEY_PATH, value: 'https://rinkeby.infura.io/v3/' },
Expand Down Expand Up @@ -531,6 +542,7 @@ const CONFIG_SERVICE_CHAINS: ChainInfo[] = [
chainName: 'Volta',
shortName: 'vt',
l2: true,
isTestnet: false,
description: '',
rpcUri: { authentication: RPC_AUTHENTICATION.NO_AUTHENTICATION, value: 'https://volta-rpc.energyweb.org' },
safeAppsRpcUri: { authentication: RPC_AUTHENTICATION.NO_AUTHENTICATION, value: 'https://volta-rpc.energyweb.org' },
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4003,10 +4003,10 @@
"@safe-global/safe-core-sdk-utils" "^1.7.4"
ethers "5.7.2"

"@safe-global/safe-gateway-typescript-sdk@^3.14.0":
version "3.14.0"
resolved "https://registry.yarnpkg.com/@safe-global/safe-gateway-typescript-sdk/-/safe-gateway-typescript-sdk-3.14.0.tgz#9581c524c1ea4956555f40761eb6b4007392aa82"
integrity sha512-/dqU66RvHw50n+7x3nwnJedq8V6iLQyoWitNdjx5cFTBmae+rpP+LvHq+LqZfXJVkB1qNytMdjFjdyES0t79gQ==
"@safe-global/safe-gateway-typescript-sdk@^3.15.0":
version "3.15.0"
resolved "https://registry.yarnpkg.com/@safe-global/safe-gateway-typescript-sdk/-/safe-gateway-typescript-sdk-3.15.0.tgz#2a99e7eca7aecfad1f5e00744ffdd949cefa4f6a"
integrity sha512-zAzhPgUwzdp89ZrZwCAOImUyAQMQE0LQKcK4vLO5eMbfAcNOxz5g4eVdBRBRa+kVXxjyW5wii58ZlGaYUVBa7g==

"@safe-global/safe-gateway-typescript-sdk@^3.5.3":
version "3.12.0"
Expand Down

0 comments on commit b3692fb

Please sign in to comment.