Skip to content

Commit

Permalink
Merge pull request #2607 from IntersectMBO/develop
Browse files Browse the repository at this point in the history
GovTool 2.0.4
  • Loading branch information
MSzalowski authored Jan 7, 2025
2 parents c3e8886 + db747ed commit 25b39ca
Show file tree
Hide file tree
Showing 33 changed files with 192 additions and 105 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@ changes.

-

## [v2.0.4](https://github.com/IntersectMBO/govtool/releases/tag/v2.0.4) 2025-01-07

### Added

-

### Fixed

- Fix CIP-129 DRep view identifier for script based DReps [Issue 2583](https://github.com/IntersectMBO/govtool/issues/2583)
- Fix fetching metadata from IPFS gateway
- Fix bad request on passing the random sorting to GA list request [Issue 2535](https://github.com/IntersectMBO/govtool/issues/2535)
- Fix wrong drep activity conditions

### Changed

- Reduce CSL version to 12.1.1 [Issue 2600](https://github.com/IntersectMBO/govtool/issues/2600)

### Removed

-

## [v2.0.3](https://github.com/IntersectMBO/govtool/releases/tag/v2.0.3) 2024-12-30

### Added
Expand Down
2 changes: 1 addition & 1 deletion govtool/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ FROM $BASE_IMAGE_REPO:$BASE_IMAGE_TAG
WORKDIR /src
COPY . .
RUN cabal build
RUN cp dist-newstyle/build/x86_64-linux/ghc-9.2.7/vva-be-2.0.3/x/vva-be/build/vva-be/vva-be /usr/local/bin
RUN cp dist-newstyle/build/x86_64-linux/ghc-9.2.7/vva-be-2.0.4/x/vva-be/build/vva-be/vva-be /usr/local/bin
2 changes: 1 addition & 1 deletion govtool/backend/Dockerfile.qovery
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM $BASE_IMAGE_REPO:$BASE_IMAGE_TAG
WORKDIR /src
COPY . .
RUN cabal build
RUN cp dist-newstyle/build/x86_64-linux/ghc-9.2.7/vva-be-2.0.3/x/vva-be/build/vva-be/vva-be /usr/local/bin
RUN cp dist-newstyle/build/x86_64-linux/ghc-9.2.7/vva-be-2.0.4/x/vva-be/build/vva-be/vva-be /usr/local/bin

# Expose the necessary port
EXPOSE 9876
Expand Down
22 changes: 21 additions & 1 deletion govtool/backend/sql/list-dreps.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ DRepActivity AS (
ORDER BY
epoch_no DESC
LIMIT 1
),
LatestVotingProcedure AS (
SELECT
vp.*,
ROW_NUMBER() OVER (PARTITION BY drep_voter ORDER BY tx_id DESC) AS rn
FROM
voting_procedure vp
),
LatestVoteEpoch AS (
SELECT
block.epoch_no,
lvp.drep_voter as drep_id
FROM
LatestVotingProcedure lvp
JOIN tx ON tx.id = lvp.tx_id
JOIN block ON block.id = tx.block_id
WHERE
lvp.rn = 1
)
SELECT DISTINCT ON (dh.raw)
encode(dh.raw, 'hex'),
Expand All @@ -26,7 +44,7 @@ SELECT DISTINCT ON (dh.raw)
encode(va.data_hash, 'hex'),
dr_deposit.deposit,
DRepDistr.amount,
(DRepActivity.epoch_no - newestRegister.epoch_no) <= DRepActivity.drep_activity AS active,
(DRepActivity.epoch_no - GREATEST(MAX(COALESCE(block.epoch_no, block_first_register.epoch_no)), lve.epoch_no)) <= DRepActivity.drep_activity AS active,
encode(dr_voting_anchor.tx_hash, 'hex') AS tx_hash,
newestRegister.time AS last_register_time,
COALESCE(latestDeposit.deposit, 0),
Expand Down Expand Up @@ -143,6 +161,7 @@ FROM
) AS dr_first_register ON dr_first_register.drep_hash_id = dh.id AND dr_first_register.rn = 1
LEFT JOIN tx AS tx_first_register ON tx_first_register.id = dr_first_register.tx_id
LEFT JOIN block AS block_first_register ON block_first_register.id = tx_first_register.block_id
LEFT JOIN LatestVoteEpoch lve ON lve.drep_id = dh.id
WHERE
(
COALESCE(?, '') = '' OR
Expand All @@ -163,6 +182,7 @@ GROUP BY
DRepDistr.amount,
DRepActivity.epoch_no,
DRepActivity.drep_activity,
lve.epoch_no,
dr_voting_anchor.tx_hash,
newestRegister.time,
newestRegister.epoch_no,
Expand Down
2 changes: 1 addition & 1 deletion govtool/backend/vva-be.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.6
name: vva-be
version: 2.0.3
version: 2.0.4

-- A short (one-line) description of the package.
-- synopsis:
Expand Down
18 changes: 6 additions & 12 deletions govtool/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions govtool/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@govtool/frontend",
"private": true,
"version": "2.0.3",
"version": "2.0.4",
"type": "module",
"scripts": {
"build": "vite build",
Expand All @@ -25,7 +25,7 @@
"dependencies": {
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@emurgo/cardano-serialization-lib-asmjs": "^13.1.0",
"@emurgo/cardano-serialization-lib-asmjs": "^12.1.1",
"@hookform/resolvers": "^3.3.1",
"@intersect.mbo/intersectmbo.org-icons-set": "^1.0.8",
"@intersect.mbo/pdf-ui": "^0.5.5",
Expand Down Expand Up @@ -112,6 +112,5 @@
"typescript": "^5.0.2",
"nth-check": "^2.0.1",
"postcss": "^8.4.31"
},
"_id": "[email protected]"
}
}
5 changes: 3 additions & 2 deletions govtool/frontend/src/components/organisms/DRepCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const DRepCard = ({
metadataStatus,
image,
drepId,
isScriptBased,
},
isConnected,
isDelegationLoading,
Expand All @@ -59,8 +60,8 @@ export const DRepCard = ({
});

const cip129Identifier = encodeCIP129Identifier({
txID: `22${drepId}`,
bech32Prefix: "drep",
txID: `${isScriptBased ? "23" : "22"}${drepId}`,
bech32Prefix: isScriptBased ? "drep_script" : "drep",
});

return (
Expand Down
5 changes: 3 additions & 2 deletions govtool/frontend/src/components/organisms/DRepDetailsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const DRepDetailsCard = ({
view,
drepId,
votingPower,
isScriptBased,
} = dRepData;

const groupedReferences = references?.reduce<Record<string, Reference[]>>(
Expand Down Expand Up @@ -120,8 +121,8 @@ export const DRepDetailsCard = ({
>
<CopyableText
value={encodeCIP129Identifier({
txID: `22${drepId}`,
bech32Prefix: "drep",
txID: `${isScriptBased ? "23" : "22"}${drepId}`,
bech32Prefix: isScriptBased ? "drep_script" : "drep",
})}
dataTestId="copy-cip-129-drep-id-button"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ const StyledTab = styled((props: StyledTabProps) => (
}));

export const DashboardGovernanceActions = () => {
const { debouncedSearchText, ...dataActionsBarProps } = useDataActionsBar();
const { debouncedSearchText, isAdjusting, ...dataActionsBarProps } =
useDataActionsBar();
const { chosenFilters, chosenSorting } = dataActionsBarProps;
const { voter } = useGetVoterInfo();
const { isMobile } = useScreenDimension();
Expand All @@ -81,6 +82,7 @@ export const DashboardGovernanceActions = () => {
filters: queryFilters,
sorting: chosenSorting,
searchPhrase: debouncedSearchText,
enabled: !isAdjusting,
});

const { state } = useLocation();
Expand Down
2 changes: 1 addition & 1 deletion govtool/frontend/src/components/organisms/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const Footer = () => {
}}
>
<Typography fontWeight={500} variant="caption">
{t("footer.copyright")}
{t("footer.copyright", { year: new Date().getFullYear() })}
</Typography>
<Box
sx={{
Expand Down
6 changes: 6 additions & 0 deletions govtool/frontend/src/context/dataActionsBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { useLocation } from "react-router-dom";
import { useDebounce } from "@hooks";

interface DataActionsBarContextType {
isAdjusting: boolean;
chosenFilters: string[];
chosenFiltersLength: number;
chosenSorting: string;
Expand All @@ -40,6 +41,7 @@ interface ProviderProps {
}

const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
const [isAdjusting, setIsAdjusting] = useState<boolean>(true);
const [searchText, setSearchText] = useState<string>("");
const debouncedSearchText = useDebounce(searchText, 300);
const [filtersOpen, setFiltersOpen] = useState<boolean>(false);
Expand All @@ -62,6 +64,7 @@ const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
setSearchText("");
setChosenFilters([]);
setChosenSorting("");
setIsAdjusting(false);
}, []);

const userMovedToDifferentAppArea =
Expand All @@ -74,6 +77,7 @@ const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
pathname.includes("governance_actions/category");

useEffect(() => {
setIsAdjusting(true);
if (
(!pathname.includes("drep_directory") &&
userMovedToDifferentAppArea &&
Expand All @@ -90,6 +94,7 @@ const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {

const contextValue = useMemo(
() => ({
isAdjusting,
chosenFilters,
chosenFiltersLength: chosenFilters.length,
chosenSorting,
Expand All @@ -106,6 +111,7 @@ const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
sortOpen,
}),
[
isAdjusting,
chosenFilters,
chosenSorting,
debouncedSearchText,
Expand Down
4 changes: 4 additions & 0 deletions govtool/frontend/src/hooks/queries/useGetProposalsQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const useGetProposalsQuery = ({
filters = [],
searchPhrase,
sorting,
enabled,
}: GetProposalsArguments) => {
const { dRepID, pendingTransaction } = useCardano();
const { voter } = useGetVoterInfo();
Expand Down Expand Up @@ -42,6 +43,9 @@ export const useGetProposalsQuery = ({
pendingTransaction.vote?.transactionHash,
],
fetchProposals,
{
enabled,
},
);

const proposals = Object.values(groupByType(data) ?? []);
Expand Down
2 changes: 1 addition & 1 deletion govtool/frontend/src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
}
},
"footer": {
"copyright": "© 2024 Intersect MBO",
"copyright": "© {{year}} Intersect MBO",
"privacyPolicy": "Privacy policy",
"termOfService": "Terms of Use"
},
Expand Down
39 changes: 2 additions & 37 deletions govtool/frontend/src/services/requests/getDRepList.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { bech32 } from "bech32";
import {
type Infinite,
type DRepStatus,
Expand All @@ -7,11 +6,7 @@ import {
DrepDataDTO,
} from "@models";
import { API } from "../API";
import {
decodeCIP129Identifier,
encodeCIP129Identifier,
mapDtoToDrep,
} from "@/utils";
import { dRepSearchPhraseProcessor, mapDtoToDrep } from "@/utils";

export type GetDRepListArguments = {
filters?: string[];
Expand All @@ -30,37 +25,7 @@ export const getDRepList = async ({
searchPhrase: rawSearchPhrase = "",
status = [],
}: GetDRepListArguments): Promise<Infinite<DRepData>> => {
// DBSync contains wrong representation of DRep view for script based DReps,
// but it's still used by BE
const searchPhraseProcessor = async () => {
try {
if (rawSearchPhrase.startsWith("drep_script")) {
const { words } = bech32.decode(rawSearchPhrase);
return bech32.encode("drep", words);
}
if (rawSearchPhrase.startsWith("drep")) {
const decodedIdentifier = decodeCIP129Identifier(rawSearchPhrase);
if (decodedIdentifier) {
const isCIP129Identifier = decodedIdentifier.txID.startsWith("22");
if (isCIP129Identifier) {
return encodeCIP129Identifier({
txID: decodedIdentifier.txID.slice(2),
bech32Prefix: "drep",
});
}
return encodeCIP129Identifier({
txID: decodedIdentifier.txID,
bech32Prefix: "drep",
});
}
}
return rawSearchPhrase;
} catch (e) {
return rawSearchPhrase;
}
};

const searchPhrase = await searchPhraseProcessor();
const searchPhrase = await dRepSearchPhraseProcessor(rawSearchPhrase);

const response = await API.get<Infinite<DrepDataDTO>>("/drep/list", {
params: {
Expand Down
1 change: 1 addition & 0 deletions govtool/frontend/src/services/requests/getProposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type GetProposalsArguments = {
pageSize?: number;
sorting?: string;
searchPhrase?: string;
enabled?: boolean;
};

export const getProposals = async ({
Expand Down
Loading

0 comments on commit 25b39ca

Please sign in to comment.