Skip to content

Commit

Permalink
Merge pull request #317 from rossneilson/fix/tokens-locked-snapshot
Browse files Browse the repository at this point in the history
Hotfix: Fixing total locked in snapshot guild
  • Loading branch information
rossneilson committed Sep 19, 2022
2 parents 1fcb1ed + 33d8828 commit a91f62e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Modules/Guilds/Hooks/useProposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const useProposal = (guildId: string, proposalId: string) => {
addressOrName: guildId,
contractInterface: ERC20GuildContract.abi,
functionName: 'getProposal',
args: [proposalId],
args: proposalId,
watch: true,
});
const proposalData = data as unknown as InitialProposal;
Expand Down
24 changes: 12 additions & 12 deletions src/Modules/Guilds/Hooks/useTotalLocked.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import useCurrentSnapshotId from './useCurrentSnapshotId';
import useGuildToken from 'Modules/Guilds/Hooks/useGuildToken';
import useTotalSupplyAt from 'Modules/Guilds/Hooks/useTotalSupplyAt';
import { useTypedParams } from 'Modules/Guilds/Hooks/useTypedParams';
Expand All @@ -11,18 +10,13 @@ import { BigNumber } from 'ethers';

const useTotalLocked = (guildAddress: string, snapshotId?: string) => {
// Hooks call
const { data: currentSnapshotId } = useCurrentSnapshotId({
contractAddress: guildAddress,
});

const { proposalId } = useTypedParams();
const { data: _snapshotId } = useSnapshotId({
contractAddress: guildAddress,
proposalId,
});

const SNAPSHOT_ID =
snapshotId ?? _snapshotId?.toString() ?? currentSnapshotId?.toString();
const SNAPSHOT_ID = snapshotId ?? _snapshotId?.toString() ?? null;

const { isSnapshotGuild, isRepGuild } =
useGuildImplementationType(guildAddress);
Expand Down Expand Up @@ -63,11 +57,17 @@ const useTotalLocked = (guildAddress: string, snapshotId?: string) => {
}

if (isSnapshotGuild) {
return {
data: totalLockedAtProposalSnapshotResponse
? BigNumber.from(totalLockedAtProposalSnapshotResponse)
: undefined,
};
return SNAPSHOT_ID
? {
data: totalLockedAtProposalSnapshotResponse
? BigNumber.from(totalLockedAtProposalSnapshotResponse)
: undefined,
}
: {
data: totalLockedResponse
? BigNumber.from(totalLockedResponse)
: undefined,
};
}
return {
data: totalLockedResponse ? BigNumber.from(totalLockedResponse) : undefined,
Expand Down
2 changes: 1 addition & 1 deletion src/Modules/Guilds/Hooks/useVotingPowerOf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const useVotingPowerOf = ({
fallbackSnapshotId,
});

if (isSnapshotGuild) return votingPowerAtSnapshotResponse;
if (isSnapshotGuild && snapshotId) return votingPowerAtSnapshotResponse;
return {
data: votingPowerOfResponse
? BigNumber.from(votingPowerOfResponse)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const InfoValue = styled.span`
`;

export const InfoOldValue = styled(InfoValue)`
color: ${({ theme }) => theme.colors.border1};
color: ${({ theme }) => theme.colors.grey};
display: inline-flex;
align-items: center;
`;
Expand Down

0 comments on commit a91f62e

Please sign in to comment.