Skip to content

Commit

Permalink
Move payment stream asset logo fetch to useHatsTree
Browse files Browse the repository at this point in the history
  • Loading branch information
DarksightKellar committed Dec 10, 2024
1 parent ee3bfe5 commit 9b2699d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
8 changes: 7 additions & 1 deletion src/hooks/DAO/loaders/useHatsTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ const useHatsTree = () => {
? secondsTimestampToDate(lockupLinearStream.cliffTime)
: undefined;

const logo =
getValue({
cacheName: CacheKeys.TOKEN_INFO,
tokenAddress: lockupLinearStream.asset.address,
})?.logoUri || '';

return {
streamId: lockupLinearStream.id,
contractAddress: lockupLinearStream.contract.address,
Expand All @@ -213,7 +219,7 @@ const useHatsTree = () => {
name: lockupLinearStream.asset.name,
symbol: lockupLinearStream.asset.symbol,
decimals: lockupLinearStream.asset.decimals,
logo: '', // @todo - how do we get logo?
logo,
},
amount: {
bigintValue: BigInt(lockupLinearStream.depositAmount),
Expand Down
20 changes: 4 additions & 16 deletions src/store/roles/useRolesStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { getContract, Hex, PublicClient } from 'viem';
import { create } from 'zustand';
import { SablierV2LockupLinearAbi } from '../../assets/abi/SablierV2LockupLinear';
import { convertStreamIdToBigInt } from '../../hooks/streams/useCreateSablierStream';
import { CacheKeys } from '../../hooks/utils/cache/cacheDefaults';
import { getValue } from '../../hooks/utils/cache/useLocalStorage';
import { DecentRoleHat, RolesStore } from '../../types/roles';
import { initialHatsStore, sanitize } from './rolesStoreUtils';

Expand Down Expand Up @@ -119,22 +117,12 @@ const useRolesStore = create<RolesStore>()((set, get) => ({
const filteredStreamIds = streamIdsToHatIdsMap
.filter(ids => ids.hatId === BigInt(roleHat.id))
.map(ids => ids.streamId);

return {
...roleHat,
payments: (roleHat.isTermed
? roleHat.payments?.filter(payment => {
return filteredStreamIds.includes(payment.streamId);
})
: roleHat.payments
)?.map(p => ({
...p,
asset: {
...p.asset,
logo:
getValue({ cacheName: CacheKeys.TOKEN_INFO, tokenAddress: p.asset.address })
?.logoUri || '',
},
})),
payments: roleHat.isTermed
? roleHat.payments?.filter(payment => filteredStreamIds.includes(payment.streamId))
: roleHat.payments,
};
}),
};
Expand Down

0 comments on commit 9b2699d

Please sign in to comment.