Skip to content

Commit

Permalink
chore: sentry / fetch fix
Browse files Browse the repository at this point in the history
  • Loading branch information
stackchain committed Dec 3, 2024
1 parent 7ff286f commit 9796cb1
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 21 deletions.
12 changes: 6 additions & 6 deletions apps/wallet/src/components/ConfirmTx/ConfirmTx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ import {
import {LocalizableError} from '../../kernel/i18n/LocalizableError'
import {isEmptyString} from '../../kernel/utils'
import {useSubmitTx} from '../../yoroi-wallets/hooks'
import {withBLE, withUSB} from '../../yoroi-wallets/hw/hwWallet'
import {YoroiSignedTx, YoroiUnsignedTx} from '../../yoroi-wallets/types/yoroi'
import {delay} from '../../yoroi-wallets/utils/timeUtils'
import {Button, ButtonProps} from '../Button/Button'
import {ValidatedTextInput} from '../ValidatedTextInput'
import {Dialog, Step as DialogStep} from './Dialog'
import {
AdaAppClosedError,
BluetoothDisabledError,
GeneralConnectionError,
LedgerUserError,
RejectedByUserError,
} from '../../yoroi-wallets/hw/hw'
import {withBLE, withUSB} from '../../yoroi-wallets/hw/hwWallet'
import {YoroiSignedTx, YoroiUnsignedTx} from '../../yoroi-wallets/types/yoroi'
import {delay} from '../../yoroi-wallets/utils/timeUtils'
import {Button, ButtonProps} from '../Button/Button'
import {ValidatedTextInput} from '../ValidatedTextInput'
import {Dialog, Step as DialogStep} from './Dialog'

type ErrorData = {
errorMessage: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as React from 'react'
import {Subject} from 'rxjs'

import {time} from '../../../../kernel/constants'
import {fetchPtPriceActivity} from '../../../../yoroi-wallets/cardano/usePrimaryTokenActivity'
import {fetchPtPriceActivity} from '../../../../yoroi-wallets/cardano/api/api'
import {getCurrencySymbol} from '../../../Settings/useCases/changeAppSettings/Currency/CurrencyContext'
import {useWalletManager} from '../../../WalletManager/context/WalletManagerProvider'
import {notificationManager} from './notification-manager'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {Chain, Portfolio} from '@yoroi/types'
import {supportedCurrencies, time} from '../../../../kernel/constants'
import {useLanguage} from '../../../../kernel/i18n'
import {logger} from '../../../../kernel/logger/logger'
import {fetchPtPriceActivity} from '../../../../yoroi-wallets/cardano/usePrimaryTokenActivity'
import {fetchPtPriceActivity} from '../../../../yoroi-wallets/cardano/api/api'
import {delay} from '../../../../yoroi-wallets/utils/timeUtils'
import {useCurrencyPairing} from '../../../Settings/useCases/changeAppSettings/Currency/CurrencyContext'
import {useSelectedNetwork} from '../../../WalletManager/common/hooks/useSelectedNetwork'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
configCurrencies,
supportedCurrencies,
} from '../../../../../kernel/constants'
import {usePrimaryTokenActivity} from '../../../../../yoroi-wallets/cardano/usePrimaryTokenActivity'
import {usePrimaryTokenActivity} from '../../../../../yoroi-wallets/cardano/use-primary-token-activity'
import {
ConfigCurrencies,
CurrencySymbol,
Expand Down
5 changes: 3 additions & 2 deletions apps/wallet/src/kernel/logger/adapters/sentry-transporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {App} from '@yoroi/types'
import {freeze} from 'immer'

import {toLoggerMetadata} from '../helpers/to-logger-metadata'
// TODO: REVISIT
import {Sentry} from './sentry.native'

export const sentryAdapter = (sentryRuntime = Sentry) => {
Expand All @@ -23,13 +24,13 @@ export const sentryAdapter = (sentryRuntime = Sentry) => {
message: formattedMessage,
data: formattedMetadata,
type: type ?? 'default',
level: level as Sentry.Breadcrumb['level'],
level: level as any,
timestamp: timestamp / 1000,
})

if (level === 'error' || level === 'warn' || level === 'log') {
sentryRuntime.captureMessage(formattedMessage, {
level: level as Sentry.Breadcrumb['level'],
level: level as any,
extra: meta,
})
}
Expand Down
2 changes: 1 addition & 1 deletion apps/wallet/src/kernel/logger/adapters/sentry.native.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import sentry from '@sentry/react-native'
import * as sentry from '@sentry/react-native'

export const Sentry = sentry
15 changes: 15 additions & 0 deletions apps/wallet/src/yoroi-wallets/cardano/api/api.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import {fetchData} from '@yoroi/common'
import {Chain} from '@yoroi/types'
import _ from 'lodash'

import {networkConfigs} from '../../../features/WalletManager/network-manager/network-manager'
import type {
AccountStateRequest,
AccountStateResponse,
FundInfoResponse,
PoolInfoRequest,
PriceMultipleResponse,
RawTransaction,
TipStatusResponse,
TxHistoryRequest,
Expand Down Expand Up @@ -106,3 +110,14 @@ export const fetchTxStatus = (
): Promise<TxStatusResponse> => {
return fetchDefault('tx/status', request, baseApiUrl)
}

// NOTE: this API should be moved inside portfolio token activity (support PT in the request)
// NOTE: price API is unique for all networks
const apiBaseUrl = networkConfigs[Chain.Network.Mainnet].legacyApiBaseUrl
const ptTicker = networkConfigs[Chain.Network.Mainnet].primaryTokenInfo.ticker

export const fetchPtPriceActivity = (timestamps: Array<number>) =>
fetchData<PriceMultipleResponse>({
url: `${apiBaseUrl}/price/${ptTicker}/${timestamps.join()}`,
method: 'get',
})
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {useQuery, UseQueryOptions} from '@tanstack/react-query'
import {fetchData, isRight} from '@yoroi/common'
import {isRight} from '@yoroi/common'
import {Chain} from '@yoroi/types'

import {networkConfigs} from '../../features/WalletManager/network-manager/network-manager'
import {time} from '../../kernel/constants'
import {queryInfo} from '../../kernel/query-client'
import {CurrencySymbol, PriceMultipleResponse} from '../types/other'
import {CurrencySymbol} from '../types/other'
import {fetchPtPriceActivity} from './api/api'

// NOTE: this API should be moved inside portfolio token activity (support PT in the request)
// NOTE: price API is unique for all networks
const apiBaseUrl = networkConfigs[Chain.Network.Mainnet].legacyApiBaseUrl
const ptTicker = networkConfigs[Chain.Network.Mainnet].primaryTokenInfo.ticker

type PrimaryTokenActivity = {
Expand Down Expand Up @@ -65,9 +65,3 @@ export const usePrimaryTokenActivity = ({

return {ptActivity: defaultPrimaryTokenActivity, isLoading: query.isLoading}
}

export const fetchPtPriceActivity = (timestamps: Array<number>) =>
fetchData<PriceMultipleResponse>({
url: `${apiBaseUrl}/price/${ptTicker}/${timestamps.join()}`,
method: 'get',
})

0 comments on commit 9796cb1

Please sign in to comment.