Skip to content

Commit aa6382e

Browse files
authored
Merge pull request #2248 from oasisprotocol/mz/revertBalancesFetching
Revert fetching balances from gRPC
2 parents 2f9ce36 + 8496c8f commit aa6382e

File tree

3 files changed

+5
-98
lines changed

3 files changed

+5
-98
lines changed

.changelog/2248.trivial.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Revert fetching balances from gRPC

src/app/utils/getRPCAccountBalances.ts

Lines changed: 0 additions & 48 deletions
This file was deleted.

src/oasis-nexus/api.ts

Lines changed: 4 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,8 @@
33
import axios, { AxiosResponse } from 'axios'
44
import { consensusDecimals, getTokensForScope, paraTimesConfig } from '../config'
55
import * 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'
188
import {
199
base64ToHex,
2010
getAccountSize,
@@ -27,7 +17,6 @@ import { getCancelTitle, getParameterChangeTitle, getProposalTitle } from '../ap
2717
import { Network } from '../types/network'
2818
import { SearchScope } from '../types/searchScope'
2919
import { Ticker } from '../types/ticker'
30-
import { getRPCAccountBalances } from '../app/utils/getRPCAccountBalances'
3120
import { toChecksumAddress } from '@ethereumjs/util'
3221
import { fromBaseUnits } from '../app/utils/number-utils'
3322
import { 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

556510
const MAX_LOADED_ADDRESSES = 100

0 commit comments

Comments
 (0)