Skip to content

Commit

Permalink
GA-fix: fixes bug when trying to open the transaction details, a blan…
Browse files Browse the repository at this point in the history
…k page appears with a "Return to Home" button
  • Loading branch information
ArtemBurakov committed May 30, 2024
1 parent c3d2917 commit 7ad885a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
4 changes: 4 additions & 0 deletions background/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,8 @@ export default class Main extends BaseService<never> {
addressNetwork.network,
txHash
)
if (!transaction) return

const enrichedTransaction = await this.enrichmentService.enrichTransaction(
transaction,
2
Expand Down Expand Up @@ -1608,6 +1610,8 @@ export default class Main extends BaseService<never> {
addressNetwork.network,
txHash
)
if (!transaction) return []

const enrichedTransaction = await this.enrichmentService.enrichTransaction(
transaction,
2
Expand Down
31 changes: 18 additions & 13 deletions background/services/chain/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1060,23 +1060,28 @@ export default class ChainService extends BaseService<Events> {
async getTransaction(
network: EVMNetwork,
txHash: HexString
): Promise<AnyEVMTransaction> {
const cachedTx = await this.db.getTransaction(network, txHash)
// If tx is cached and already included in a block, don't need to query provider
if (cachedTx && cachedTx.blockHash != undefined) return cachedTx
): Promise<AnyEVMTransaction | null> {
const provider = this.providerForNetworkOrThrow(network)
const gethResult = await provider.getTransaction(txHash)

const gethResult = await this.providerForNetworkOrThrow(
network
).getTransaction(txHash)
const newTransaction = transactionFromEthersTransaction(gethResult, network)
if (gethResult) {
const newTransaction = transactionFromEthersTransaction(
gethResult,
network
)

if (!newTransaction.blockHash && !newTransaction.blockHeight) {
this.subscribeToTransactionConfirmation(network, newTransaction)
if (!newTransaction.blockHash && !newTransaction.blockHeight) {
this.subscribeToTransactionConfirmation(network, newTransaction)
}

this.saveTransaction(newTransaction, "local")
return newTransaction
}

// TODO proper provider string
this.saveTransaction(newTransaction, "local")
return newTransaction
const cachedTx = await this.db.getTransaction(network, txHash)
if (cachedTx) return cachedTx

return null
}

/**
Expand Down
4 changes: 2 additions & 2 deletions ui/components/Wallet/WalletActivityDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export default function WalletActivityDetails(
/>
</div>
<ul>
{details.length ? (
{details?.length ? (
<></>
) : (
Array.from({ length: 7 }).map(() => (
Expand All @@ -203,7 +203,7 @@ export default function WalletActivityDetails(
/>
))
)}
{details.map(({ assetIconUrl, label, value }) => {
{details?.map(({ assetIconUrl, label, value }) => {
return (
<DetailRowItem
key={label}
Expand Down
4 changes: 3 additions & 1 deletion ui/pages/SingleAsset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ const MAX_SYMBOL_LENGTH = 10
export default function SingleAsset(): ReactElement {
const { t } = useTranslation()
const location = useLocation<AnyAsset>()
const locationAsset = location.state
const currentAccount = useBackgroundSelector(selectCurrentAccount)
const locationAsset = location.state ?? currentAccount.network.baseAsset

const { symbol } = locationAsset
const contractAddress =
"contractAddress" in locationAsset
Expand Down

0 comments on commit 7ad885a

Please sign in to comment.