Skip to content

Commit

Permalink
Merge pull request #205 from Chia-Network/fix-restart-to-see-new-tokens
Browse files Browse the repository at this point in the history
Overall Bug Fixes
  • Loading branch information
wwills2 authored Jan 28, 2025
2 parents 7d2707d + bc97e6a commit 552103c
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 44 deletions.
2 changes: 1 addition & 1 deletion climate-token-driver
Submodule climate-token-driver updated 79 files
+0 −1 .env.example
+0 −10 .flake8
+0 −7 .github/dependabot.yml
+0 −61 .github/workflows/auto-release.yml
+74 −261 .github/workflows/build-installers.yaml
+0 −46 .github/workflows/ensure-version-increment.yml
+0 −68 .github/workflows/pre-commit.yml
+0 −44 .github/workflows/release-notes.yml
+0 −77 .github/workflows/tests.yaml
+0 −1 .gitignore
+3 −0 .gitmodules
+0 −4 .isort.cfg
+0 −1 .nvmrc
+43 −40 .pre-commit-config.yaml
+0 −4 .repo-content-updater.yaml
+0 −162 CHANGELOG.md
+0 −201 LICENSE
+33 −171 README.md
+8 −17 app/api/dependencies.py
+0 −2 app/api/v1/__init__.py
+11 −124 app/api/v1/activities.py
+2 −11 app/api/v1/core.py
+55 −88 app/api/v1/cron.py
+19 −14 app/api/v1/keys.py
+0 −20 app/api/v1/organizations.py
+49 −59 app/api/v1/tokens.py
+28 −16 app/api/v1/transactions.py
+23 −40 app/config.py
+13 −16 app/core/chialisp/gateway.py
+0 −2 app/core/chialisp/load_clvm.py
+10 −7 app/core/chialisp/tail.py
+166 −144 app/core/climate_wallet/wallet.py
+41 −23 app/core/climate_wallet/wallet_utils.py
+6 −6 app/core/derive_keys.py
+27 −25 app/core/types.py
+39 −29 app/core/utils.py
+0 −2 app/crud/__init__.py
+73 −129 app/crud/chia.py
+27 −27 app/crud/db.py
+0 −2 app/db/base.py
+11 −6 app/db/session.py
+4 −6 app/errors.py
+2 −10 app/logger.py
+10 −34 app/main.py
+0 −4 app/models/__init__.py
+11 −4 app/models/activity.py
+1 −3 app/models/state.py
+7 −10 app/schemas/__init__.py
+3 −12 app/schemas/activity.py
+5 −7 app/schemas/core.py
+0 −2 app/schemas/key.py
+0 −2 app/schemas/metadata.py
+1 −5 app/schemas/payment.py
+0 −2 app/schemas/state.py
+17 −14 app/schemas/token.py
+0 −2 app/schemas/transaction.py
+0 −2 app/schemas/types.py
+12 −27 app/utils.py
+0 −39 build-scripts/deb/systemd-template@.service.j2
+1 −0 chia-blockchain
+3 −9 config.yaml
+27 −0 docker-compose.yaml
+65 −0 dockerfile/Dockerfile.chia-blockchain
+25 −0 dockerfile/Dockerfile.ivern
+98 −0 dockerfile/docker-entrypoint.sh
+119 −0 dockerfile/docker-healthcheck.sh
+15 −0 dockerfile/docker-start.sh
+0 −25 mypy.ini
+1,323 −2,337 poetry.lock
+4 −10 pyinstaller.spec
+13 −46 pyproject.toml
+0 −21 pytest.ini
+16 −12 tests/conftest.py
+105 −121 tests/test_activities_api.py
+48 −33 tests/test_cat_lifecycle.py
+314 −427 tests/test_cat_workflow.py
+110 −161 tests/test_crud_chia.py
+2 −4 tests/test_crud_core.py
+0 −23 tests/test_disallow.py
16 changes: 6 additions & 10 deletions src/components/token/TokenHistoryRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,23 +111,19 @@ const TokenHistoryRow = ({ transactionHistory }: TokenHistoryRowProps) => {
]

const memosNode = useMemo<RowType>(() => {
const memos = getMemosDescription(memoHexs)
const decodedMemoResult = getMemosDescription(memoHexs)
return {
key: 'Memos',
title: <Trans>{'Memos'}</Trans>,
value:
Object.values(memoHexs).length === 0 ? (
<Typography variant="inherit">{''}</Typography>
) : memos.state ? (
<Stack direction="row" spacing={1}>
{memos.value.map((memo, index) => (
<Typography variant="inherit" key={index}>
{memo ?? ''}
</Typography>
))}
</Stack>
) : (
<Typography variant="inherit">{memos.value[0]}</Typography>
decodedMemoResult.state && (
<Typography variant="inherit">
{decodedMemoResult.value[0] ?? ''}
</Typography>
)
),
}
}, [memoHexs])
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/useGetAllCWAssets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/hooks/wallet/useWalletsList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ export default function useWalletsList(
hide: (walletId: number) => void
show: (id: number | string) => Promise<void>
} {
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, {
Expand Down Expand Up @@ -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) ?? []

Expand Down
54 changes: 28 additions & 26 deletions src/pages/TokenWallet/TokenSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => ({
Expand All @@ -54,8 +54,8 @@ export default function TokenSidebar() {
)
const { walletId, setWalletId } = useSelectedWallet()

const [tokenSort, setTokenSort] = useState<TokeSortEnum>(
TokeSortEnum.QuentyHL
const [tokenSort, setTokenSort] = useState<TokenSortEnum>(
TokenSortEnum.QuantityHightToLow
)
const { isDetokenWallet } = useDetokenzationBlockingList()

Expand All @@ -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<WalletListItem[]>(() => {
if (!wallets || !allCWAssets) {
return []
Expand All @@ -83,29 +86,29 @@ export default function TokenSidebar() {
useWalletsBalance(filteredWallets)

// TODO : can refactor
const sortedWallets = useMemo<WalletListItem[]>(() => {
const sortedTokens = useMemo<WalletListItem[]>(() => {
if (filteredWallets.length !== walletsBalance.length) {
return [...filteredWallets]
}

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(
Expand All @@ -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(
Expand Down Expand Up @@ -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 &&
Expand All @@ -200,7 +203,7 @@ export default function TokenSidebar() {
<Typography variant="h5">
<Trans>My Wallet</Trans>
</Typography>
{!isLoading && sortedWallets.length > 0 && (
{!isLoading && sortedTokens.length > 0 && (
<ExportButton fileName="token.csv" data={allCWAssetsCSVData} />
)}
</Stack>
Expand All @@ -213,7 +216,7 @@ export default function TokenSidebar() {
<center>Your Chia Wallet is still syncing...</center>
)}
</div>
) : sortedWallets.length > 0 ? (
) : sortedTokens.length > 0 ? (
<Stack spacing={1} direction="column">
<Stack
direction="row"
Expand All @@ -234,31 +237,30 @@ export default function TokenSidebar() {
value={tokenSort}
displayEmpty
onChange={(event) => {
setTokenSort(event.target.value as TokeSortEnum)
setTokenSort(event.target.value as TokenSortEnum)
}}
sx={{
height: '40px',
color: theme.palette.text.secondary,
}}
>
<MenuItem value={TokeSortEnum.QuentyHL}>
<MenuItem value={TokenSortEnum.QuantityHightToLow}>
<Trans>Quantity - high to low</Trans>
</MenuItem>
<MenuItem value={TokeSortEnum.QuentyLH}>
<MenuItem value={TokenSortEnum.QuantityLowToHigh}>
<Trans>Quantity - low to high</Trans>
</MenuItem>
<MenuItem value={TokeSortEnum.NameAZ}>
<Trans>Name - A to Z</Trans>
<MenuItem value={TokenSortEnum.NameAToZ}>
<Trans>Project Name - A to Z</Trans>
</MenuItem>
<MenuItem value={TokeSortEnum.NameZA}>
<Trans>Name - Z to A</Trans>
<MenuItem value={TokenSortEnum.NameZToA}>
<Trans>Project Name - Z to A</Trans>
</MenuItem>
</Select>
</FormControl>
</Stack>
{sortedWallets.map((wallet) => {
{sortedTokens.map((wallet) => {
const { walletId, assetId } = wallet

return (
<TokenListItem
key={assetId ?? walletId}
Expand Down
6 changes: 3 additions & 3 deletions src/services/climateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 6 additions & 0 deletions src/services/climateWarehouseService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const climateWarehouseServiceApi = createApi({

return response
},
keepUnusedDataFor: 0,
}),

// get one unit by warehouseUnitId
Expand All @@ -36,6 +37,7 @@ export const climateWarehouseServiceApi = createApi({
params: { warehouseUnitId },
method: 'get',
}),
keepUnusedDataFor: 0,
}),

// get all organizations
Expand All @@ -44,6 +46,7 @@ export const climateWarehouseServiceApi = createApi({
url: '/v1/organizations',
method: 'get',
}),
keepUnusedDataFor: 0,
}),

// get all project
Expand All @@ -62,6 +65,7 @@ export const climateWarehouseServiceApi = createApi({

return response
},
keepUnusedDataFor: 0,
}),

// get one project by warehouseProjectId
Expand All @@ -71,6 +75,7 @@ export const climateWarehouseServiceApi = createApi({
params: { warehouseProjectId },
method: 'get',
}),
keepUnusedDataFor: 0,
}),

// get one project by orgUid
Expand All @@ -80,6 +85,7 @@ export const climateWarehouseServiceApi = createApi({
params: { orgUid },
method: 'get',
}),
keepUnusedDataFor: 0,
}),
}),
})
Expand Down

0 comments on commit 552103c

Please sign in to comment.