Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ export const AddCollectibleDialog = memo<AddCollectibleDialogProps>(({ open, onC
if (!isOwner) {
throw new Error(FormErrorType.NotExist)
} else {
tokenDetailed.owner = { address: account }
tokenDetailed.ownerId = account
await Token?.addToken?.(tokenDetailed)
onClose()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ interface CollectibleListProps {
export const CollectibleList = memo<CollectibleListProps>(({ selectedChain }) => {
const navigate = useNavigate()
const account = useAccount()
const trustedNonFungibleTokens = useTrustedNonFungibleTokens()
const trustedNonFungibleTokens = useTrustedNonFungibleTokens(
NetworkPluginID.PLUGIN_EVM,
undefined,
selectedChain?.chainId as ChainId,
)

const {
value = EMPTY_LIST,
Expand All @@ -57,9 +61,7 @@ export const CollectibleList = memo<CollectibleListProps>(({ selectedChain }) =>
})

const renderCollectibles = useMemo(() => {
const trustedOwnNonFungibleTokens = trustedNonFungibleTokens.filter((x) =>
isSameAddress(x.contract?.owner, account),
)
const trustedOwnNonFungibleTokens = trustedNonFungibleTokens.filter((x) => isSameAddress(x.ownerId, account))
return uniqBy(
[...trustedOwnNonFungibleTokens, ...value],
(x) => x?.contract?.address.toLowerCase() + x?.tokenId,
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-infra/src/web3/useTrustedFungibleTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ export function useTrustedFungibleTokens<S extends 'all' | void = void, T extend
return fungibleTokens
.filter((x) => (schemaType ? x.schema === schemaType : true))
.filter((x) => (chainId ? x.chainId === chainId : true))
}, [schemaType, fungibleTokens])
}, [schemaType, fungibleTokens, chainId])
}
9 changes: 5 additions & 4 deletions packages/plugin-infra/src/web3/useTrustedNonFungibleTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import { EMPTY_ARRAY } from '../utils/subscription'
export function useTrustedNonFungibleTokens<S extends 'all' | void = void, T extends NetworkPluginID = NetworkPluginID>(
pluginID?: T,
schemaType?: Web3Helper.SchemaTypeScope<S, T>,
chainId?: Web3Helper.ChainIdScope<S, T>,
) {
const { Token } = useWeb3State(pluginID)
const nonFungibleTokens = useSubscription(Token?.trustedNonFungibleTokens ?? EMPTY_ARRAY)
return useMemo<Array<Web3Helper.NonFungibleTokenScope<S, T>>>(() => {
return nonFungibleTokens.length && schemaType
? nonFungibleTokens.filter((x) => x.schema === schemaType)
: nonFungibleTokens
}, [schemaType, nonFungibleTokens])
return nonFungibleTokens
.filter((x) => (schemaType ? x.schema === schemaType : true))
.filter((x) => (chainId ? x.chainId === chainId : true))
}, [schemaType, nonFungibleTokens, chainId])
}