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

fix: bust getReceiveAddress cache for wallets other than Ledger #5469

Merged
merged 2 commits into from
Oct 17, 2023
Merged
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
7 changes: 6 additions & 1 deletion src/components/MultiHopTrade/hooks/useReceiveAddress.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { fromAccountId, fromAssetId } from '@shapeshiftoss/caip'
import { isLedger } from '@shapeshiftoss/hdwallet-ledger'
import stableStringify from 'fast-json-stable-stringify'
import pMemoize from 'p-memoize'
import { useCallback, useEffect, useState } from 'react'
import { v4 as uuid } from 'uuid'
import type { GetReceiveAddressArgs } from 'components/MultiHopTrade/types'
import { getChainAdapterManager } from 'context/PluginProvider/chainAdapterSingleton'
import { useWallet } from 'hooks/useWallet/useWallet'
Expand Down Expand Up @@ -31,7 +33,10 @@ export const getReceiveAddress = pMemoize(
return address
},
{
cacheKey: ([{ asset, accountMetadata, deviceId }]) => {
cacheKey: ([{ asset, accountMetadata, deviceId, wallet }]) => {
// Bust cache for all wallets other than Ledger.
// This will mean a few more runs of this for other wallets, which is fine.
if (!isLedger(wallet)) return uuid()
woodenfurniture marked this conversation as resolved.
Show resolved Hide resolved
return stableStringify({
assetId: asset.assetId,
accountMetadata,
Expand Down