From e461c645fa438e13dcef9e7630810aaec48239fd Mon Sep 17 00:00:00 2001 From: Tomek Marciniak Date: Sun, 28 Jan 2024 13:38:46 +0100 Subject: [PATCH 1/2] fix(tx): fix tx details fetching --- packages/features/src/common/hooks/use-transaction.ts | 3 ++- packages/features/src/common/hooks/use-transactions.ts | 2 +- .../src/transactions/views/transaction-details.tsx | 8 ++++++-- packages/vault/src/network-info/default.ts | 6 +++--- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/features/src/common/hooks/use-transaction.ts b/packages/features/src/common/hooks/use-transaction.ts index 61b206ed..e47a59de 100644 --- a/packages/features/src/common/hooks/use-transaction.ts +++ b/packages/features/src/common/hooks/use-transaction.ts @@ -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( diff --git a/packages/features/src/common/hooks/use-transactions.ts b/packages/features/src/common/hooks/use-transactions.ts index 7f928946..c204ef7f 100644 --- a/packages/features/src/common/hooks/use-transactions.ts +++ b/packages/features/src/common/hooks/use-transactions.ts @@ -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' ) } diff --git a/packages/features/src/transactions/views/transaction-details.tsx b/packages/features/src/transactions/views/transaction-details.tsx index 8b6ecc95..3a915818 100644 --- a/packages/features/src/transactions/views/transaction-details.tsx +++ b/packages/features/src/transactions/views/transaction-details.tsx @@ -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, walletPublicKey: publicKey }) + console.log('>>>TXD', transactionData, error) const transactionMetaFields = transaction && [ { label: 'Hash', diff --git a/packages/vault/src/network-info/default.ts b/packages/vault/src/network-info/default.ts index a85c8c78..dc0fcf4e 100644 --- a/packages/vault/src/network-info/default.ts +++ b/packages/vault/src/network-info/default.ts @@ -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 = { - 'Mina - Berkeley': { + Berkeley: { nodeEndpoint: { providerName: 'mina-explorer', url: 'https://proxy.berkeley.minaexplorer.com/' @@ -14,7 +14,7 @@ export const DEFAULT_NETWORK_INFO: Record = { providerName: 'mina-explorer', url: 'https://berkeley.graphql.minaexplorer.com' }, - networkName: 'Mina - Berkeley', + networkName: 'Berkeley', chainId: '...' // todo: fetch chainId from a provider } } From c6a7e026e99fff52182bc80a3c368ed370c82cf5 Mon Sep 17 00:00:00 2001 From: teddyjfpender Date: Sun, 28 Jan 2024 12:53:04 +0000 Subject: [PATCH 2/2] fix: Tomek's same network name issue --- packages/vault/test/network-info/network-info-store.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/vault/test/network-info/network-info-store.test.ts b/packages/vault/test/network-info/network-info-store.test.ts index 8a9aa3bd..9a973030 100644 --- a/packages/vault/test/network-info/network-info-store.test.ts +++ b/packages/vault/test/network-info/network-info-store.test.ts @@ -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',