33import axios , { AxiosResponse } from 'axios'
44import { consensusDecimals , getTokensForScope , paraTimesConfig } from '../config'
55import * as generated from './generated/api'
6- import { QueryKey , UseQueryOptions , UseQueryResult , useQuery } from '@tanstack/react-query'
7- import {
8- Account ,
9- EvmToken ,
10- EvmTokenType ,
11- GetRuntimeAccountsAddress ,
12- HumanReadableErrorResponse ,
13- NotFoundErrorResponse ,
14- Runtime ,
15- RuntimeAccount ,
16- RuntimeEventType ,
17- } from './generated/api'
6+ import { UseQueryOptions } from '@tanstack/react-query'
7+ import { Account , EvmToken , Runtime , RuntimeAccount , RuntimeEventType } from './generated/api'
188import {
199 base64ToHex ,
2010 getAccountSize ,
@@ -27,7 +17,6 @@ import { getCancelTitle, getParameterChangeTitle, getProposalTitle } from '../ap
2717import { Network } from '../types/network'
2818import { SearchScope } from '../types/searchScope'
2919import { Ticker } from '../types/ticker'
30- import { getRPCAccountBalances } from '../app/utils/getRPCAccountBalances'
3120import { toChecksumAddress } from '@ethereumjs/util'
3221import { fromBaseUnits } from '../app/utils/number-utils'
3322import { getConsensusTransactionAmount , getConsensusTransactionToAddress } from '../app/utils/transaction'
@@ -460,7 +449,7 @@ export const useGetRuntimeAccountsAddress: typeof generated.useGetRuntimeAccount
460449 address ,
461450 options ,
462451) => {
463- const query = generated . useGetRuntimeAccountsAddress ( network , runtime , address , {
452+ return generated . useGetRuntimeAccountsAddress ( network , runtime , address , {
464453 ...options ,
465454 query : {
466455 ...( options ?. query ?? { } ) ,
@@ -515,42 +504,7 @@ export const useGetRuntimeAccountsAddress: typeof generated.useGetRuntimeAccount
515504 ...arrayify ( options ?. request ?. transformResponse ) ,
516505 ] ,
517506 } ,
518- } ) as UseQueryResult <
519- Awaited < ReturnType < typeof GetRuntimeAccountsAddress > > ,
520- HumanReadableErrorResponse | NotFoundErrorResponse
521- > & { queryKey : QueryKey }
522-
523- const runtimeAccount = query . data ?. data
524-
525- // TODO: Remove after account balances on Nexus are in sync with the node
526- const oasisAddress = getOasisAddressOrNull ( address )
527- const rpcAccountBalances = useQuery ( {
528- enabled : ! ! oasisAddress ,
529- queryKey : [ oasisAddress , network , runtime ] ,
530- queryFn : async ( ) => {
531- if ( ! oasisAddress ) throw new Error ( 'Needed to fix types - see `enabled`' )
532- return await getRPCAccountBalances ( oasisAddress , { network : network , layer : runtime } )
533- } ,
534- } ) . data
535-
536- const data =
537- rpcAccountBalances && runtimeAccount
538- ? {
539- ...runtimeAccount ,
540- balances : rpcAccountBalances ,
541- }
542- : runtimeAccount
543-
544- return {
545- ...query ,
546- data : query . data
547- ? {
548- ...query . data ,
549- data,
550- }
551- : query . data ,
552- // TypeScript complaining for no good reason
553- } as any
507+ } )
554508}
555509
556510const MAX_LOADED_ADDRESSES = 100
0 commit comments