Skip to content

Commit

Permalink
Merge pull request #143 from palladians/fix/tx-details-providers
Browse files Browse the repository at this point in the history
fix(tx): fix tx details fetching
  • Loading branch information
mrcnk authored Jan 28, 2024
2 parents 23f6e0d + c6a7e02 commit c7450f6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/features/src/common/hooks/use-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import useSWR from 'swr'
import { useAppStore } from '../store/app'

export const useTransaction = ({ hash }: { hash: string }) => {
const providerConfig = useVault((state) => state.getCurrentNetworkInfo())
const currentWallet = useVault((state) => state.getCurrentWallet())
const _syncTransactions = useVault((state) => state._syncTransactions)
const getTransaction = useVault((state) => state.getTransaction)
const publicKey = currentWallet.credential.credential?.address as string
const network = useAppStore((state) => state.network)
const syncAndGetTransaction = async () => {
await _syncTransactions(network, currentWallet?.credential.credential)
await _syncTransactions(providerConfig, publicKey)
return getTransaction(network, publicKey, hash, 'MINA') // TODO: remove hardcoded 'MINA'
}
return useSWR(
Expand Down
2 changes: 1 addition & 1 deletion packages/features/src/common/hooks/use-transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ export const useTransactions = () => {
const network = useAppStore((state) => state.network)
return useSWR(
publicKey ? [publicKey, 'transactions', network] : null,
async () => await getTransactions(network, publicKey, 'MINA') // TODO: remove hardcoded 'MINA'
() => getTransactions(network, publicKey, 'MINA') // TODO: remove hardcoded 'MINA'
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ export const TransactionDetailsView = () => {
const { hash } = useParams()
if (!hash) return null
if (!publicKey) return null
const { data: transactionData, isLoading: transactionLoading } =
useTransaction({ hash })
const {
data: transactionData,
isLoading: transactionLoading,
error
} = useTransaction({ hash })
const transaction =
transactionData &&
structurizeTransaction({
tx: transactionData as any,

Check warning on line 28 in packages/features/src/transactions/views/transaction-details.tsx

View workflow job for this annotation

GitHub Actions / Build and test

Unexpected any. Specify a different type
walletPublicKey: publicKey
})
console.log('>>>TXD', transactionData, error)
const transactionMetaFields = transaction && [
{
label: 'Hash',
Expand Down
6 changes: 3 additions & 3 deletions packages/vault/src/network-info/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { ProviderConfig } from '@palladxyz/providers'

import { NetworkName } from './network-info-state'

export const DEFAULT_NETWORK = 'Mina - Berkeley'
export const DEFAULT_NETWORK = 'Berkeley'

export const DEFAULT_NETWORK_INFO: Record<NetworkName, ProviderConfig> = {
'Mina - Berkeley': {
Berkeley: {
nodeEndpoint: {
providerName: 'mina-explorer',
url: 'https://proxy.berkeley.minaexplorer.com/'
Expand All @@ -14,7 +14,7 @@ export const DEFAULT_NETWORK_INFO: Record<NetworkName, ProviderConfig> = {
providerName: 'mina-explorer',
url: 'https://berkeley.graphql.minaexplorer.com'
},
networkName: 'Mina - Berkeley',
networkName: 'Berkeley',
chainId: '...' // todo: fetch chainId from a provider
}
}
3 changes: 2 additions & 1 deletion packages/vault/test/network-info/network-info-store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ describe('CredentialStore', () => {

beforeEach(async () => {
networkNameMainnet = 'Mainnet'
networkNameBerkeley = 'Berkeley'
// don't use the same network name
networkNameBerkeley = 'Berkeley Other'
providerConfigMainnet = {
nodeEndpoint: {
providerName: 'mina-explorer',
Expand Down

0 comments on commit c7450f6

Please sign in to comment.