From 4ab62e25af56615ffb05d63e2f8ce29721604f71 Mon Sep 17 00:00:00 2001 From: William Wills Date: Mon, 13 Jan 2025 16:26:25 -0500 Subject: [PATCH 1/4] fix: refresh required to see new tokens --- climate-token-driver | 2 +- src/hooks/useGetAllCWAssets.tsx | 6 +-- src/hooks/wallet/useWalletsList.ts | 6 ++- src/pages/TokenWallet/TokenSidebar.tsx | 54 +++++++++++++------------ src/services/climateWarehouseService.ts | 6 +++ 5 files changed, 43 insertions(+), 31 deletions(-) diff --git a/climate-token-driver b/climate-token-driver index 39ff3245..6f1669e2 160000 --- a/climate-token-driver +++ b/climate-token-driver @@ -1 +1 @@ -Subproject commit 39ff3245846e9d253eac6e10cc6ae53f38b31742 +Subproject commit 6f1669e24ef78b134b5ca162143292cae9c4a0df diff --git a/src/hooks/useGetAllCWAssets.tsx b/src/hooks/useGetAllCWAssets.tsx index 3f852a09..6685360f 100644 --- a/src/hooks/useGetAllCWAssets.tsx +++ b/src/hooks/useGetAllCWAssets.tsx @@ -12,19 +12,19 @@ export function useGetAllCWAssets() { data: assets, isLoading: isLoadingAssets, error: errorAssets, - } = useGetAllCWAssetQuery('') + } = useGetAllCWAssetQuery(undefined, { pollingInterval: 60_000}) const { data: organizations, isLoading: isLoadingOrganizations, error: errorOrganizations, - } = useGetAllOrganizationsQuery('') + } = useGetAllOrganizationsQuery(undefined, { pollingInterval: 60_000}) const { data: projects, isLoading: isLoadingProjects, error: errorProjects, - } = useGetAllCWProjectQuery('') + } = useGetAllCWProjectQuery(undefined, { pollingInterval: 60_000}) const isLoading = isLoadingAssets || isLoadingOrganizations || isLoadingProjects diff --git a/src/hooks/wallet/useWalletsList.ts b/src/hooks/wallet/useWalletsList.ts index 4ef9220c..5fbbe9f9 100644 --- a/src/hooks/wallet/useWalletsList.ts +++ b/src/hooks/wallet/useWalletsList.ts @@ -43,7 +43,10 @@ export default function useWalletsList( hide: (walletId: number) => void show: (id: number | string) => Promise } { - const { data: wallets, isLoading: isLoadingGetWallets } = useGetWalletsQuery() + const { data: wallets, isLoading: isLoadingGetWallets } = + useGetWalletsQuery(undefined, { + pollingInterval: 10000, + }) const { data: catList, isLoading: isLoadingGetCatList } = useGetCatListQuery() const { data: strayCats, isLoading: isLoadingGetStrayCats } = useGetStrayCatsQuery(undefined, { @@ -125,6 +128,7 @@ export default function useWalletsList( (wallet: Wallet) => ![WalletType.CAT, WalletType.POOLING_WALLET].includes(wallet.type) ) ?? [] + const catBaseWallets = wallets?.filter((wallet: Wallet) => wallet.type === WalletType.CAT) ?? [] diff --git a/src/pages/TokenWallet/TokenSidebar.tsx b/src/pages/TokenWallet/TokenSidebar.tsx index 3d965c7f..317ff9e7 100644 --- a/src/pages/TokenWallet/TokenSidebar.tsx +++ b/src/pages/TokenWallet/TokenSidebar.tsx @@ -27,11 +27,11 @@ import { import { useEffect, useMemo, useState } from 'react' import { WalletListItem } from '../../types/WalletType' -enum TokeSortEnum { - QuentyHL = 0, // Quantity - high to low - QuentyLH = 1, // Quantity - low to high - NameAZ = 2, // Name - A to Z - NameZA = 3, // Name - Z to A +enum TokenSortEnum { + QuantityHightToLow = 0, // Quantity - high to low + QuantityLowToHigh = 1, // Quantity - low to high + NameAToZ = 2, // Name - A to Z + NameZToA = 3, // Name - Z to A } const StyledRoot = styled(Stack)(({ theme }) => ({ @@ -54,8 +54,8 @@ export default function TokenSidebar() { ) const { walletId, setWalletId } = useSelectedWallet() - const [tokenSort, setTokenSort] = useState( - TokeSortEnum.QuentyHL + const [tokenSort, setTokenSort] = useState( + TokenSortEnum.QuantityHightToLow ) const { isDetokenWallet } = useDetokenzationBlockingList() @@ -65,6 +65,9 @@ export default function TokenSidebar() { error: errorAllCWAssets, } = useGetAllCWAssets() + /** + * this filters down to just CATS with unit records in CADT (climate warehouse) + */ const filteredWallets = useMemo(() => { if (!wallets || !allCWAssets) { return [] @@ -83,7 +86,7 @@ export default function TokenSidebar() { useWalletsBalance(filteredWallets) // TODO : can refactor - const sortedWallets = useMemo(() => { + const sortedTokens = useMemo(() => { if (filteredWallets.length !== walletsBalance.length) { return [...filteredWallets] } @@ -91,21 +94,21 @@ export default function TokenSidebar() { switch (tokenSort) { default: return [...filteredWallets] - case TokeSortEnum.QuentyHL: + case TokenSortEnum.QuantityHightToLow: return [...filteredWallets].sort((a, b) => { return ( walletsBalance[filteredWallets.indexOf(b)] - walletsBalance[filteredWallets.indexOf(a)] ) }) - case TokeSortEnum.QuentyLH: + case TokenSortEnum.QuantityLowToHigh: return [...filteredWallets].sort((a, b) => { return ( walletsBalance[filteredWallets.indexOf(a)] - walletsBalance[filteredWallets.indexOf(b)] ) }) - case TokeSortEnum.NameAZ: + case TokenSortEnum.NameAToZ: return [...filteredWallets].sort((a, b) => { var aName = allCWAssets.find( @@ -121,7 +124,7 @@ export default function TokenSidebar() { )?.projectName ?? '' return aName.localeCompare(bName) }) - case TokeSortEnum.NameZA: + case TokenSortEnum.NameZToA: return [...filteredWallets].sort((a, b) => { var aName = allCWAssets.find( @@ -178,12 +181,12 @@ export default function TokenSidebar() { useEffect(() => { if ( !walletId && - sortedWallets.length > 0 && + sortedTokens.length > 0 && filteredWallets.length === walletsBalance.length ) { - setWalletId(sortedWallets[0].walletId) + setWalletId(sortedTokens[0].walletId) } - }, [sortedWallets, filteredWallets, walletsBalance]) + }, [sortedTokens, filteredWallets, walletsBalance]) if ( !isLoading && @@ -200,7 +203,7 @@ export default function TokenSidebar() { My Wallet - {!isLoading && sortedWallets.length > 0 && ( + {!isLoading && sortedTokens.length > 0 && ( )} @@ -213,7 +216,7 @@ export default function TokenSidebar() {
Your Chia Wallet is still syncing...
)} - ) : sortedWallets.length > 0 ? ( + ) : sortedTokens.length > 0 ? ( { - setTokenSort(event.target.value as TokeSortEnum) + setTokenSort(event.target.value as TokenSortEnum) }} sx={{ height: '40px', color: theme.palette.text.secondary, }} > - + Quantity - high to low - + Quantity - low to high - - Name - A to Z + + Project Name - A to Z - - Name - Z to A + + Project Name - Z to A - {sortedWallets.map((wallet) => { + {sortedTokens.map((wallet) => { const { walletId, assetId } = wallet - return ( Date: Wed, 15 Jan 2025 16:09:37 -0500 Subject: [PATCH 2/4] fix: transaction memo not displaying properly --- src/components/token/TokenHistoryRow.tsx | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/components/token/TokenHistoryRow.tsx b/src/components/token/TokenHistoryRow.tsx index b7cfd651..ce2b2707 100644 --- a/src/components/token/TokenHistoryRow.tsx +++ b/src/components/token/TokenHistoryRow.tsx @@ -111,23 +111,20 @@ const TokenHistoryRow = ({ transactionHistory }: TokenHistoryRowProps) => { ] const memosNode = useMemo(() => { - const memos = getMemosDescription(memoHexs) + const decodedMemoResult = getMemosDescription(memoHexs) + console.log(decodedMemoResult) return { key: 'Memos', title: {'Memos'}, value: Object.values(memoHexs).length === 0 ? ( {''} - ) : memos.state ? ( - - {memos.value.map((memo, index) => ( - - {memo ?? ''} - - ))} - ) : ( - {memos.value[0]} + decodedMemoResult.state && ( + + {decodedMemoResult.value[0] ?? ''} + + ) ), } }, [memoHexs]) From 19a019e3b8c10d29728fbc022e7d31211566aeed Mon Sep 17 00:00:00 2001 From: William Wills Date: Wed, 15 Jan 2025 16:09:37 -0500 Subject: [PATCH 3/4] fix: transaction memo not displaying properly --- src/components/token/TokenHistoryRow.tsx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/components/token/TokenHistoryRow.tsx b/src/components/token/TokenHistoryRow.tsx index b7cfd651..ff9ae39e 100644 --- a/src/components/token/TokenHistoryRow.tsx +++ b/src/components/token/TokenHistoryRow.tsx @@ -111,23 +111,19 @@ const TokenHistoryRow = ({ transactionHistory }: TokenHistoryRowProps) => { ] const memosNode = useMemo(() => { - const memos = getMemosDescription(memoHexs) + const decodedMemoResult = getMemosDescription(memoHexs) return { key: 'Memos', title: {'Memos'}, value: Object.values(memoHexs).length === 0 ? ( {''} - ) : memos.state ? ( - - {memos.value.map((memo, index) => ( - - {memo ?? ''} - - ))} - ) : ( - {memos.value[0]} + decodedMemoResult.state && ( + + {decodedMemoResult.value[0] ?? ''} + + ) ), } }, [memoHexs]) From 79fb36424e6531a8c7225a2de4aa852c183d0a81 Mon Sep 17 00:00:00 2001 From: William Wills Date: Thu, 23 Jan 2025 14:22:32 -0500 Subject: [PATCH 4/4] fix: default token diver to localhost --- src/services/climateService.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/services/climateService.ts b/src/services/climateService.ts index 258fcfdd..5370bccf 100644 --- a/src/services/climateService.ts +++ b/src/services/climateService.ts @@ -7,9 +7,9 @@ import { } from '@/types/ClimateServiceType' import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react' -export const serviceURL = `${process.env.CLIMATE_TOKEN_DRIVER_HOST}:${ - process.env.CLIMATE_TOKEN_DRIVER_PORT || '31314' -}` +export const serviceURL = `${ + process.env.CLIMATE_TOKEN_DRIVER_HOST || 'http://localhost' +}:${process.env.CLIMATE_TOKEN_DRIVER_PORT || '31314'}` export const climateServiceApi = createApi({ reducerPath: 'climateServiceApi',