Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(TransactionFeedV2): Add initial implementation of Transaction Feed V2 #6135

Merged
merged 16 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion knip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const config: KnipConfig = {
'src/utils/inputValidation.ts',
'src/utils/country.json',
'src/redux/reducersForSchemaGeneration.ts',
'src/transactions/apiTestHelpers.ts',
],
}

Expand Down
6 changes: 4 additions & 2 deletions src/transactions/NoActivity.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { type SerializedError } from '@reduxjs/toolkit'
import { type FetchBaseQueryError } from '@reduxjs/toolkit/query'
import * as React from 'react'
import { WithTranslation } from 'react-i18next'
import { type WithTranslation } from 'react-i18next'
import { ActivityIndicator, StyleSheet, Text, View } from 'react-native'
import { withTranslation } from 'src/i18n'
import colors from 'src/styles/colors'
import { typeScale } from 'src/styles/fonts'
interface OwnProps {
loading: boolean
error: Error | undefined
error: Error | FetchBaseQueryError | SerializedError | undefined
}

type Props = OwnProps & WithTranslation
Expand Down
10 changes: 8 additions & 2 deletions src/transactions/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createApi } from '@reduxjs/toolkit/query/react'
import { baseQuery } from 'src/redux/api'
import type { TokenTransaction } from 'src/transactions/types'

type TransactionFeedV2Response = {
export type TransactionFeedV2Response = {
transactions: TokenTransaction[]
pageInfo: {
hasNextPage: boolean
Expand All @@ -17,7 +17,13 @@ export const transactionFeedV2Api = createApi({
TransactionFeedV2Response,
{ address: string; endCursor: number }
>({
query: ({ address, endCursor }) => `/wallet/${address}/transactions?endCursor=${endCursor}`,
query: ({ address, endCursor }) => {
const cursor = endCursor ? `?endCursor=${endCursor}` : ''
return `/wallet/${address}/transactions${cursor}`
},
keepUnusedDataFor: 60, // 1 min
}),
}),
})

export const { useTransactionFeedV2Query } = transactionFeedV2Api
12 changes: 4 additions & 8 deletions src/transactions/apiTestHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { RootState } from 'src/redux/reducers'
import { getMockStoreData, RecursivePartial } from 'test/utils'

/**
* This function is taken from the Redux team. It creates a testable store that is compatible with RTK-Query.
* It is slightly modified to also include the preloaded state.
* This function is taken from the Redux team. It creates a testable store that is compatible
* with RTK-Query. It is slightly modified to also include the preloaded state.
* https://github.com/reduxjs/redux-toolkit/blob/e7540a5594b0d880037f2ff41a83a32c629d3117/packages/toolkit/src/tests/utils/helpers.tsx#L186
*
* For more info on why this is needed and how it works - here's an article that answers some of the questions:
Expand All @@ -17,7 +17,6 @@ export function setupApiStore<
reducer: Reducer<any, any>
reducerPath: string
middleware: Middleware
util: { resetApiState(): any }
},
Preloaded extends RecursivePartial<Omit<RootState, ApiReducersKeys>>,
R extends Record<string, Reducer<any, any>> = Record<never, never>,
Expand All @@ -37,12 +36,9 @@ export function setupApiStore<
},
})

type Store = { api: ReturnType<A['reducer']> } & { [K in keyof R]: ReturnType<R[K]> }
type StoreType = EnhancedStore<
{
api: ReturnType<A['reducer']>
} & {
[K in keyof R]: ReturnType<R[K]>
},
Store,
UnknownAction,
ReturnType<typeof getStore> extends EnhancedStore<any, any, infer M> ? M : never
>
Expand Down
Loading