From 0e6e57f1a8972891c9ac63ec2c70777d75cf9290 Mon Sep 17 00:00:00 2001 From: zzggo Date: Wed, 20 Nov 2024 15:06:15 +1100 Subject: [PATCH 1/3] fixed: display linked account nft in settings frontend --- .../views/Setting/Linked/LinkedCollection.tsx | 5 ++-- src/ui/views/Setting/Linked/LinkedDetail.tsx | 30 +++++++------------ 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/ui/views/Setting/Linked/LinkedCollection.tsx b/src/ui/views/Setting/Linked/LinkedCollection.tsx index 2c2da93a..211b3278 100644 --- a/src/ui/views/Setting/Linked/LinkedCollection.tsx +++ b/src/ui/views/Setting/Linked/LinkedCollection.tsx @@ -202,7 +202,7 @@ const LinkedCollection = (props) => { try { const res = await getCollection(address, collection_name); console.log('res ', res); - setInfo(res.info); + setInfo(res.collection); setTotal(res.nftCount); setLists(res.nfts); } catch (err) { @@ -245,7 +245,6 @@ const LinkedCollection = (props) => { }; const getCollection = async (ownerAddress, collection, offset = 0) => { - console.log('collection_info ', collection_info); return await usewallet.getSingleCollection(ownerAddress, collection, offset); }; @@ -314,7 +313,7 @@ const LinkedCollection = (props) => { - {truncate(info?.collectionDisplay?.name || info.name, 16)} + {truncate(info?.name || info.contract_name, 16)} diff --git a/src/ui/views/Setting/Linked/LinkedDetail.tsx b/src/ui/views/Setting/Linked/LinkedDetail.tsx index 868d32f5..3b7ead5a 100644 --- a/src/ui/views/Setting/Linked/LinkedDetail.tsx +++ b/src/ui/views/Setting/Linked/LinkedDetail.tsx @@ -107,7 +107,6 @@ const LinkedDetail = () => { setChildAccount(childresp[key]); setKey(key); const catalog = await usewallet.getNftCatalog(); - console.log('catalog ,', catalog); const parentaddress = await usewallet.getMainWallet(); @@ -118,25 +117,18 @@ const LinkedDetail = () => { const nftResult = await usewallet.checkAccessibleNft(parentaddress); activec.forEach((active) => { - console.log('nft result ', active); const collection = findObjectByContractName(active, catalog); if (collection) { collectionMap[collection.contract_name] = { ...collection, total: 0, nfts: [] }; } }); - console.log('nft result ', nftResult, key); - - nftResult.forEach((nft) => { - const someResult = checkContractAddressInCollections(nft, Object.values(collectionMap)); - console.log('someResult , ', someResult, Object.values(collectionMap)); + Object.entries(nftResult[key]).forEach((nft) => { + const someResult = checkContractAddressInCollections(nft[0], Object.values(collectionMap)); if (someResult) { collectionMap[someResult.contract_name].total! += 1; collectionMap[someResult.contract_name].nfts!.push(nft); } }); - console.log('collectionMap result ', collectionMap); - - console.log('active check nftResult ', nftResult); if (nftResult) { setNft(nftResult); const collectionsArray = Object.values(collectionMap); @@ -148,7 +140,6 @@ const LinkedDetail = () => { } setLoading(false); - console.log('availableNft ', availableNft, availableFt); } catch (error) { // Handle any errors that occur during data fetching console.error('Error fetching data:', error); @@ -156,21 +147,22 @@ const LinkedDetail = () => { } }; - const extractContractAddress = (collection) => { + const extractContractName = (collection) => { return collection.split('.')[2]; }; const findObjectByContractName = (contractName, collections) => { - const extractedAddress = extractContractAddress(contractName); - const foundObject = collections.find((item) => item.contract_name === extractedAddress); + const extractedContract = extractContractName(contractName); + const foundObject = collections.find((item) => item.contract_name === extractedContract); return foundObject || null; }; const checkContractAddressInCollections = (nft, activec) => { - const contractAddressWithout0x = nft.collectionName; const matchedResult = activec.find((collection) => { - const extractedAddress = collection.name; - return extractedAddress === contractAddressWithout0x; + const parts = nft.split('.'); + const address = `0x${parts[1]}`; + const contractName = parts[2]; + return collection.address === address && collection.contract_name == contractName; }); return matchedResult; }; @@ -192,7 +184,6 @@ const LinkedDetail = () => { const toggleHide = (event) => { event.stopPropagation(); - console.log('hideEmpty ', hideEmpty); const prevEmpty = hideEmpty; setHide(!prevEmpty); }; @@ -200,9 +191,10 @@ const LinkedDetail = () => { const navigateWithState = (data, key) => { const state = { nft: data }; localStorage.setItem('nftLinkedState', JSON.stringify(state)); + const storagePath = data.path.storage_path.split('/')[2]; if (data.total) { history.push({ - pathname: `/dashboard/nested/linked/collectiondetail/${key + '.' + data.contract_name + '.' + data.total + '.linked'}`, + pathname: `/dashboard/nested/linked/collectiondetail/${key + '.' + storagePath + '.' + data.total + '.linked'}`, state: { collection: data, ownerAddress: key, From 517288d35f67d2a5a11da7ec43e9eecf9fc212be Mon Sep 17 00:00:00 2001 From: zzggo Date: Wed, 20 Nov 2024 16:29:42 +1100 Subject: [PATCH 2/3] fixed: switch to child account --- src/ui/views/Dashboard/Header.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ui/views/Dashboard/Header.tsx b/src/ui/views/Dashboard/Header.tsx index 1ee323c4..bde662a9 100644 --- a/src/ui/views/Dashboard/Header.tsx +++ b/src/ui/views/Dashboard/Header.tsx @@ -191,6 +191,10 @@ const Header = ({ loading }) => { evmWallet.address = evmAddress; await setCurrent(evmWallet); setMainLoading(false); + } else if (isChild) { + const currentWallet = await usewallet.getCurrentWallet(); + await setCurrent(currentWallet); + setMainLoading(false); } else { const mainwallet = await usewallet.returnMainWallet(); await setCurrent(mainwallet); @@ -264,7 +268,7 @@ const Header = ({ loading }) => { await usewallet.lockWallet(); await usewallet.clearWallet(); - await usewallet.refreshAll(); + // await usewallet.refreshAll(); await usewallet.switchNetwork(switchingTo); history.push('/switchunlock'); From 4ca2aad3e926d54c68029955f22431cf4c50a2f5 Mon Sep 17 00:00:00 2001 From: zzggo Date: Wed, 20 Nov 2024 21:51:07 +1100 Subject: [PATCH 3/3] fixed: remove commented code --- src/ui/views/Dashboard/Header.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ui/views/Dashboard/Header.tsx b/src/ui/views/Dashboard/Header.tsx index bde662a9..7af96a0c 100644 --- a/src/ui/views/Dashboard/Header.tsx +++ b/src/ui/views/Dashboard/Header.tsx @@ -268,7 +268,6 @@ const Header = ({ loading }) => { await usewallet.lockWallet(); await usewallet.clearWallet(); - // await usewallet.refreshAll(); await usewallet.switchNetwork(switchingTo); history.push('/switchunlock');