limit wallet networks (#745)

This commit is contained in:
Felicio
2025-07-10 23:35:06 +09:00
committed by GitHub
parent e466a1aeb2
commit dbe7dae012
27 changed files with 41 additions and 426 deletions
+7
View File
@@ -0,0 +1,7 @@
---
"@status-im/wallet": patch
"portfolio": patch
"wallet": patch
---
limit wallet networks
@@ -39,14 +39,7 @@ export default async function AssetDetailPage(props: Props) {
const { address, ticker: slug } = await params
const searchParams = await props.searchParams
const networks = searchParams['networks']?.split(',') ?? [
'ethereum',
'optimism',
'arbitrum',
'base',
'polygon',
'bsc',
]
const networks = searchParams['networks']?.split(',') ?? ['ethereum']
const keyHash = JSON.stringify({
route: 'ticker',
networks,
@@ -339,7 +332,7 @@ async function AssetChart({
balanceChart = await apiClient.assets.tokenBalanceChart({
address,
networks: ['ethereum', 'optimism', 'arbitrum', 'base', 'polygon', 'bsc'],
networks: ['ethereum'],
contract: slug,
days: '30',
})
@@ -351,7 +344,7 @@ async function AssetChart({
balanceChart = await apiClient.assets.nativeTokenBalanceChart({
address,
networks: ['ethereum', 'optimism', 'arbitrum', 'base', 'polygon', 'bsc'],
networks: ['ethereum'],
days: '30',
})
} else {
@@ -15,14 +15,7 @@ type Props = {
export default async function TotalBalance({ params, searchParams }: Props) {
const address = (await params).address
const networks = (await searchParams)['networks']?.split(',') ?? [
'ethereum',
'optimism',
'arbitrum',
'base',
'polygon',
'bsc',
]
const networks = (await searchParams)['networks']?.split(',') ?? ['ethereum']
const apiClient = await getAPIClient()
@@ -15,14 +15,7 @@ type Props = {
export default async function Summary({ params, searchParams }: Props) {
const address = (await params).address
const networks = (await searchParams)['networks']?.split(',') ?? [
'ethereum',
'optimism',
'arbitrum',
'base',
'polygon',
'bsc',
]
const networks = (await searchParams)['networks']?.split(',') ?? ['ethereum']
const apiClient = await getAPIClient()
@@ -16,14 +16,7 @@ export default async function AssetsList(props: Props) {
const address = (await props.params).address
const searchParams = await props.searchParams
const networks = searchParams['networks']?.split(',') ?? [
'ethereum',
'optimism',
'arbitrum',
'base',
'polygon',
'bsc',
]
const networks = searchParams['networks']?.split(',') ?? ['ethereum']
const apiClient = await getAPIClient()
@@ -26,7 +26,7 @@ type Props = {
const CollectiblesGrid = ({
initialCollectibles,
address,
networks = ['ethereum', 'optimism', 'arbitrum', 'base', 'polygon', 'bsc'],
networks = ['ethereum'],
getCollectibles,
hasMore: initialHasMore,
}: Props) => {
@@ -22,14 +22,7 @@ export default async function CollectiblesPage(props: Props) {
const address = (await props.params).address
const searchParams = await props.searchParams
const networks = searchParams['networks']?.split(',') ?? [
'ethereum',
'optimism',
'arbitrum',
'base',
'polygon',
'bsc',
]
const networks = searchParams['networks']?.split(',') ?? ['ethereum']
const search = searchParams['search'] ?? undefined
const sortParam = searchParams['sort']?.split(',') ?? [
-5
View File
@@ -20,11 +20,6 @@ type ApiInput = {
function getChainIdFromCode(chainCode: string): number | undefined {
return match(chainCode)
.with('ETHEREUM', () => 1)
.with('ARBITRUM', () => 42161)
.with('OPTIMISM', () => 10)
.with('BASE', () => 8453)
.with('POLYGON', () => 137)
.with('BSC', () => 56)
.otherwise(() => undefined)
}
@@ -4,7 +4,7 @@ import { match } from 'ts-pattern'
import { Image } from '../_components/assets'
type Props = {
name: 'etherscan' | 'arbiscan' | 'basescan' | 'polygonscan' | 'bscscan'
name: 'etherscan'
}
// TODO: move to svg
@@ -20,38 +20,6 @@ export const NetworkExplorerLogo = ({ name }: Props) => {
alt=""
/>
))
.with('arbiscan', () => (
<Image
id="Portfolio/Logos/Arbiscan:32:32"
width={16}
height={16}
alt=""
/>
))
.with('basescan', () => (
<Image
id="Portfolio/Logos/Etherscan:32:32"
width={16}
height={16}
alt=""
/>
))
.with('polygonscan', () => (
<Image
id="Portfolio/Logos/Etherscan:32:32"
width={16}
height={16}
alt=""
/>
))
.with('bscscan', () => (
<Image
id="Portfolio/Logos/Etherscan:32:32"
width={16}
height={16}
alt=""
/>
))
.exhaustive()}
</div>
)
@@ -15,31 +15,6 @@ const NETWORKS = [
name: 'Ethereum',
icon: <Image id="Wallet/Icons/Logos/01:120:120" alt="mainnet" />,
},
{
id: 'optimism',
name: 'Optimism',
icon: <Image id="Wallet/Icons/Logos/02:120:120" alt="optimism" />,
},
{
id: 'arbitrum',
name: 'Arbitrum',
icon: <Image id="Wallet/Icons/Logos/03:120:120" alt="arbitrum" />,
},
{
id: 'base',
name: 'Base',
icon: <Image id="Wallet/Icons/Logos/01:120:120" alt="mainnet" />,
},
{
id: 'polygon',
name: 'Polygon',
icon: <Image id="Wallet/Icons/Logos/01:120:120" alt="mainnet" />,
},
{
id: 'bsc',
name: 'BSC',
icon: <Image id="Wallet/Icons/Logos/01:120:120" alt="mainnet" />,
},
] as const
// const CURRENCY = 'EUR'
@@ -57,26 +32,6 @@ const BALANCE_NETWORKS: Array<{ network: NetworkType; balance: number }> = [
network: 'ethereum',
balance: 412342.23,
},
{
network: 'optimism',
balance: 40827.83,
},
{
network: 'arbitrum',
balance: 1654.42,
},
{
network: 'base',
balance: 1654.42,
},
{
network: 'polygon',
balance: 1654.42,
},
{
network: 'bsc',
balance: 1654.42,
},
]
export const NetworksFilter = () => {
@@ -28,48 +28,6 @@ export const NetworkLogo = ({ name, size }: Props) => {
alt="mainnet"
/>
))
.with('optimism', () => (
<Image
id="Wallet/Icons/Logos/02:120:120"
width={size}
height={size}
alt="optimism"
/>
))
.with('arbitrum', () => (
<Image
id="Wallet/Icons/Logos/03:120:120"
width={size}
height={size}
alt="arbitrum"
/>
))
.with('base', () => (
<Image
// fixme: export correct image
id="Wallet/Icons/Logos/01:120:120"
width={size}
height={size}
// fixme:
alt="mainnet"
/>
))
.with('polygon', () => (
<Image
id="Wallet/Icons/Logos/01:120:120"
width={size}
height={size}
alt="mainnet"
/>
))
.with('bsc', () => (
<Image
id="Wallet/Icons/Logos/01:120:120"
width={size}
height={size}
alt="mainnet"
/>
))
.exhaustive()}
</div>
)
+2 -4
View File
@@ -1,14 +1,12 @@
import { createConfig, http } from 'wagmi'
import { arbitrum, mainnet, optimism } from 'wagmi/chains'
import { mainnet } from 'wagmi/chains'
export const config = createConfig({
chains: [mainnet, optimism, arbitrum],
chains: [mainnet],
ssr: false,
transports: {
// todo: replace public clients
[mainnet.id]: http(),
[optimism.id]: http(),
[arbitrum.id]: http(),
},
})
@@ -39,11 +39,6 @@ export const AccountsProvider = ({ children }: { children: ReactNode }) => {
const searchParams = useSearchParams()
const networks = (searchParams.get('networks')?.split(',') ?? [
'ethereum',
'optimism',
'arbitrum',
'base',
'polygon',
'bsc',
]) as NetworkType[]
const activeAccounts = accounts.filter(
+1 -8
View File
@@ -57,14 +57,7 @@ const getTransfers = async (
export const useActivities = ({ address }: Props) => {
const searchParams = new URLSearchParams(window.location.search)
const networks = searchParams.get('networks')?.split(',') ?? [
'ethereum',
// 'optimism',
// 'arbitrum',
// 'base',
// 'polygon',
// 'bsc',
]
const networks = searchParams.get('networks')?.split(',') ?? ['ethereum']
return useInfiniteQuery({
queryKey: ['activities', address, networks],
+1 -8
View File
@@ -30,14 +30,7 @@ const useAssets = (
JSON.stringify({
json: {
address,
networks: [
'ethereum',
'optimism',
'arbitrum',
'base',
'polygon',
'bsc',
],
networks: ['ethereum'],
},
}),
)
+1 -8
View File
@@ -87,14 +87,7 @@ const useCollectibles = (props: Props) => {
DEFAULT_SORT.collectibles.direction,
}
const networks = searchParams.get('networks')?.split(',') ?? [
'ethereum',
'optimism',
'arbitrum',
'base',
'polygon',
'bsc',
]
const networks = searchParams.get('networks')?.split(',') ?? ['ethereum']
return useInfiniteQuery({
queryKey: ['collectibles', address, networks, search, sort],
+1 -8
View File
@@ -2,14 +2,7 @@ import { useQuery } from '@tanstack/react-query'
import type { ApiOutput } from '@status-im/wallet/data'
const NETWORKS = [
'ethereum',
'optimism',
'arbitrum',
'base',
'polygon',
'bsc',
] as const
const NETWORKS = ['ethereum'] as const
export const useEthBalance = (address: string, enabled: boolean = true) => {
return useQuery<ApiOutput['assets']['nativeToken']>({
@@ -32,14 +32,7 @@ const getTimeFrameDays = (timeFrame: string): string => {
}
}
const NETWORKS = [
'ethereum',
'optimism',
'arbitrum',
'base',
'polygon',
'bsc',
] as const
const NETWORKS = ['ethereum'] as const
function AssetChart({
address,
@@ -16,7 +16,6 @@ import {
CurrencyAmount,
DEFAULT_DATA_TYPE,
DEFAULT_TIME_FRAME,
NetworkBreakdown,
ReceiveCryptoDrawer,
type SendAssetsFormData,
SendAssetsModal,
@@ -44,14 +43,7 @@ type Props = {
ticker: string
}
const NETWORKS = [
'ethereum',
'optimism',
'arbitrum',
'base',
'polygon',
'bsc',
] as const
const NETWORKS = ['ethereum'] as const
const Token = (props: Props) => {
const { ticker, address } = props
@@ -352,10 +344,6 @@ const Token = (props: Props) => {
</div>
</div>
{typedToken.summary.total_balance > 0 && (
<NetworkBreakdown token={typedToken} />
)}
<div className="relative">
<div className="flex items-center justify-between">
<div className="inline-flex">
@@ -18,7 +18,6 @@ import {
import { DeleteAddressAlert } from '../delete-address-alert'
import { NetworkExplorerLogo } from '../network-explorer-logo'
import { NetworkLogo } from '../network-logo'
// import { AddressDrawer } from './address-drawer'
import { ReceiveCryptoDrawer } from '../receive-crypto-drawer'
import { shortenAddress } from '../shorten-address'
@@ -136,53 +135,6 @@ const AccountMenu = (props: Props) => {
}
href={'https://etherscan.io/address/' + account.address}
/>
<DropdownMenuLink
label={
<>
<NetworkLogo name="optimism" size={16} />
Optimism Explorer
</>
}
href={
'https://optimistic.etherscan.io/address/' + account.address
}
/>
<DropdownMenuLink
label={
<>
<NetworkExplorerLogo name="arbiscan" />
Arbiscan
</>
}
href={'https://arbiscan.io/address/' + account.address}
/>
<DropdownMenuLink
label={
<>
<NetworkExplorerLogo name="basescan" />
Base Explorer
</>
}
href={'https://basescan.org/tx/' + account.address}
/>
<DropdownMenuLink
label={
<>
<NetworkExplorerLogo name="polygonscan" />
Polygon Explorer
</>
}
href={'https://polygonscan.com/tx/' + account.address}
/>
<DropdownMenuLink
label={
<>
<NetworkExplorerLogo name="bscscan" />
BSC Explorer
</>
}
href={'https://bscscan.com/tx/' + account.address}
/>
</DropdownMenu.SubContent>
</DropdownMenu.Sub>
@@ -27,43 +27,6 @@ export const NetworkLogo = ({ name, size }: Props) => {
alt="mainnet"
/>
))
.with('optimism', () => (
<Image
id="Wallet/Icons/Logos/02:120:120"
className="size-fit"
alt="optimism"
/>
))
.with('arbitrum', () => (
<Image
id="Wallet/Icons/Logos/03:120:120"
className="size-fit"
alt="arbitrum"
/>
))
.with('base', () => (
<Image
// fixme: export correct image
id="Wallet/Icons/Logos/01:120:120"
// fixme:
className="size-fit"
alt="mainnet"
/>
))
.with('polygon', () => (
<Image
id="Wallet/Icons/Logos/01:120:120"
className="size-fit"
alt="mainnet"
/>
))
.with('bsc', () => (
<Image
id="Wallet/Icons/Logos/01:120:120"
className="size-fit"
alt="mainnet"
/>
))
.exhaustive()}
</div>
)
@@ -97,16 +97,7 @@ export const activitiesRouter = router({
.input(
z.object({
address: z.string(),
networks: z.array(
z.enum([
'ethereum',
'optimism',
'arbitrum',
'base',
'polygon',
'bsc',
]),
),
networks: z.array(z.enum(['ethereum'])),
limit: z.number().optional(),
pageKeys: z.record(z.string()).optional(),
}),
@@ -120,14 +111,7 @@ export const activitiesRouter = router({
.input(
z.object({
address: z.string(),
network: z.enum([
'ethereum',
'optimism',
'arbitrum',
'base',
'polygon',
'bsc',
]),
network: z.enum(['ethereum']),
}),
)
.query(async ({ input }) => {
+5 -55
View File
@@ -57,11 +57,6 @@ type Asset = {
const STATUS_NETWORKS: Record<number, NetworkType> = {
1: 'ethereum',
10: 'optimism',
42161: 'arbitrum',
8453: 'base',
137: 'polygon',
56: 'bsc',
}
const DEFAULT_TOKEN_SYMBOLS = [
@@ -79,16 +74,7 @@ export const assetsRouter = router({
.input(
z.object({
address: z.string(),
networks: z.array(
z.enum([
'ethereum',
'optimism',
'arbitrum',
'base',
'polygon',
'bsc',
]),
),
networks: z.array(z.enum(['ethereum'])),
}),
)
.query(async ({ input }) => {
@@ -109,16 +95,7 @@ export const assetsRouter = router({
.input(
z.object({
address: z.string(),
networks: z.array(
z.enum([
'ethereum',
'optimism',
'arbitrum',
'base',
'polygon',
'bsc',
]),
),
networks: z.array(z.enum(['ethereum'])),
symbol: z.string(),
}),
)
@@ -131,16 +108,7 @@ export const assetsRouter = router({
.input(
z.object({
address: z.string(),
networks: z.array(
z.enum([
'ethereum',
'optimism',
'arbitrum',
'base',
'polygon',
'bsc',
]),
),
networks: z.array(z.enum(['ethereum'])),
contract: z.string(),
}),
)
@@ -177,16 +145,7 @@ export const assetsRouter = router({
.input(
z.object({
address: z.string(),
networks: z.array(
z.enum([
'ethereum',
'optimism',
'arbitrum',
'base',
'polygon',
'bsc',
]),
),
networks: z.array(z.enum(['ethereum'])),
days: z.enum(['1', '7', '30', '90', '365', 'all']).optional(),
}),
)
@@ -199,16 +158,7 @@ export const assetsRouter = router({
.input(
z.object({
address: z.string(),
networks: z.array(
z.enum([
'ethereum',
'optimism',
'arbitrum',
'base',
'polygon',
'bsc',
]),
),
networks: z.array(z.enum(['ethereum'])),
days: z.enum(['1', '7', '30', '90', '365', 'all']).optional(),
contract: z.string(),
}),
@@ -45,16 +45,7 @@ export const collectiblesRouter = router({
.input(
z.object({
address: z.string(),
networks: z.array(
z.enum([
'ethereum',
'optimism',
'arbitrum',
'base',
'polygon',
'bsc',
]),
),
networks: z.array(z.enum(['ethereum'])),
pages: z.record(z.string(), z.string()).optional(),
limit: z.number().optional(),
offset: z.number().optional(),
@@ -76,14 +67,7 @@ export const collectiblesRouter = router({
z.object({
contract: z.string(),
tokenId: z.string(),
network: z.enum([
'ethereum',
'optimism',
'arbitrum',
'base',
'polygon',
'bsc',
]),
network: z.enum(['ethereum']),
}),
)
.query(async ({ input }) => {
@@ -13,9 +13,7 @@ export const nodesRouter = router({
getFeeRate: publicProcedure
.input(
z.object({
network: z
.enum(['ethereum', 'optimism', 'arbitrum', 'base', 'polygon', 'bsc'])
.optional(),
network: z.enum(['ethereum']).optional(),
params: z.object({
from: z.string(),
to: z.string(),
@@ -32,9 +30,7 @@ export const nodesRouter = router({
.input(
z.object({
txHex: z.string(),
network: z
.enum(['ethereum', 'optimism', 'arbitrum', 'base', 'polygon', 'bsc'])
.optional(),
network: z.enum(['ethereum']).optional(),
}),
)
.mutation(async ({ input }) => {
@@ -48,9 +44,7 @@ export const nodesRouter = router({
.input(
z.object({
address: z.string(),
network: z
.enum(['ethereum', 'optimism', 'arbitrum', 'base', 'polygon', 'bsc'])
.optional(),
network: z.enum(['ethereum']).optional(),
}),
)
.query(async ({ input }) => {
+1 -7
View File
@@ -8,12 +8,6 @@ type ApiOutput = inferRouterOutputs<ApiRouter>
export type { ApiInput, ApiOutput, ApiRouter }
export type NetworkType =
| 'ethereum'
| 'optimism'
| 'arbitrum'
| 'base'
| 'polygon'
| 'bsc'
export type NetworkType = 'ethereum'
export type { Activity, Collectible }
@@ -43,10 +43,10 @@ const alchemyNetworks = {
}
const unsupportedCategoriesByNetwork: Partial<Record<NetworkType, string[]>> = {
bsc: ['internal'],
arbitrum: ['internal'],
base: ['internal'],
optimism: ['internal'],
// bsc: ['internal'],
// arbitrum: ['internal'],
// base: ['internal'],
// optimism: ['internal'],
}
const allCategories = [