Skip to content

Commit d1f6b88

Browse files
authored
Merge pull request #2845 from IntersectMBO/staging
GovTool - v2.0.10-patch1
2 parents 2ceb696 + d9c783f commit d1f6b88

File tree

25 files changed

+215
-110
lines changed

25 files changed

+215
-110
lines changed

.github/workflows/test_backend.yml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: Backend Test
22

33
on:
4-
push:
5-
branches:
6-
- test
74
workflow_dispatch:
85
inputs:
96
deployment:
@@ -14,10 +11,26 @@ on:
1411
- "sanchogov.tools/api"
1512
- "staging.govtool.byron.network/api"
1613
- "govtool.cardanoapi.io/api"
14+
- "z6b8d2f7a-zca4a4c45-gtw.z937eb260.rustrocks.fr"
15+
- "dev-sanchonet.govtool.byron.network/api"
16+
- "be.gov.tools"
17+
network:
18+
required: true
19+
type: choice
20+
default: "preview"
21+
options:
22+
- "sanchonet"
23+
- "preview"
24+
- "mainnet"
25+
- "preprod"
26+
workflow_run:
27+
workflows: ["Build and deploy GovTool test stack"]
28+
types: [completed]
1729

1830
jobs:
1931
backend-tests:
2032
runs-on: ubuntu-latest
33+
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
2134
steps:
2235
- name: Checkout code
2336
uses: actions/checkout@v4
@@ -42,16 +55,9 @@ jobs:
4255
fi
4356
python ./setup.py
4457
python -m pytest --alluredir allure-results
45-
if [[ "${{ env.NETWORK }}" == "preprod" ]]; then
46-
echo "FAUCET_API_KEY=${{ secrets.FAUCET_API_KEY_PREPROD }}" >> $GITHUB_ENV
47-
elif [[ "${{ env.NETWORK }}" == "sanchonet" ]]; then
48-
echo "FAUCET_API_KEY=${{ secrets.FAUCET_API_KEY_SANCHONET }}" >> $GITHUB_ENV
49-
else
50-
echo "FAUCET_API_KEY=${{ secrets.FAUCET_API_KEY_PREVIEW }}" >> $GITHUB_ENV
51-
fi
5258
env:
5359
BASE_URL: https://${{inputs.deployment || 'govtool.cardanoapi.io/api' }}
54-
NETWORK: ${{ vars.NETWORK }}
60+
NETWORK: ${{ inputs.network || vars.NETWORK }}
5561
KUBER_API_KEY: ${{ secrets.KUBER_API_KEY }}
5662

5763
- name: Upload report
@@ -63,7 +69,7 @@ jobs:
6369

6470
publish-report:
6571
runs-on: ubuntu-latest
66-
if: always()
72+
if: always() && needs.backend-tests.result != 'skipped'
6773
needs: backend-tests
6874
steps:
6975
- uses: actions/checkout@v4

.github/workflows/test_integration_playwright.yml

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: Integration Test [Playwright]
22

33
on:
4-
push:
5-
branches:
6-
- test
74
workflow_dispatch:
85
inputs:
96
deployment:
@@ -16,14 +13,24 @@ on:
1613
- "govtool.cardanoapi.io"
1714
- "preview.gov.tools"
1815
- "gov.tools"
16+
network:
17+
required: true
18+
type: choice
19+
default: "preview"
20+
options:
21+
- "sanchonet"
22+
- "preview"
23+
- "mainnet"
24+
- "preprod"
1925

2026
workflow_run:
21-
workflows: ["Build and deploy GovTool to TEST server"]
27+
workflows: ["Build and deploy GovTool test stack"]
2228
types: [completed]
2329

2430
jobs:
2531
integration-tests:
2632
runs-on: ubuntu-latest
33+
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
2734
defaults:
2835
run:
2936
working-directory: tests/govtool-frontend/playwright
@@ -56,23 +63,19 @@ jobs:
5663
chmod +w ./lib/_mock
5764
npm run generate-wallets
5865
59-
# Set network variables based on deployment input and environment
60-
if [[ "${{inputs.deployment}}" == "gov.tools" ]]; then
61-
export NETWORK='mainnet'
62-
else
63-
export NETWORK="${{ vars.NETWORK }}"
64-
fi
65-
6666
# Set API keys based on the network
67-
if [[ "${{ vars.NETWORK }}" == "preprod" ]]; then
67+
if [[ "${{ env.NETWORK }}" == "preprod" ]]; then
6868
export FAUCET_API_KEY="${{ secrets.FAUCET_API_KEY_PREPROD }}"
6969
export BLOCKFROST_API_KEY="${{ secrets.BLOCKFROST_API_KEY_PREPROD }}"
70-
elif [[ "${{ vars.NETWORK }}" == "sanchonet" ]]; then
70+
elif [[ "${{ env.NETWORK }}" == "sanchonet" ]]; then
7171
export FAUCET_API_KEY="${{ secrets.FAUCET_API_KEY_SANCHONET }}"
7272
export BLOCKFROST_API_KEY="${{ secrets.BLOCKFROST_API_KEY_SANCHONET }}"
73-
else
73+
elif [[ "${{ env.NETWORK }}" == "preview" ]]; then
7474
export FAUCET_API_KEY="${{ secrets.FAUCET_API_KEY_PREVIEW }}"
7575
export BLOCKFROST_API_KEY="${{ secrets.BLOCKFROST_API_KEY_PREVIEW }}"
76+
else
77+
export FAUCET_API_KEY="${{ secrets.FAUCET_API_KEY_PREVIEW }}"
78+
export BLOCKFROST_API_KEY="${{ secrets.BLOCKFROST_API_KEY_MAINNET }}"
7679
fi
7780
7881
npm test
@@ -96,6 +99,7 @@ jobs:
9699
API_URL: https://${{inputs.deployment || 'govtool.cardanoapi.io' }}/api
97100
DOCS_URL: ${{ vars.DOCS_URL }}
98101
KUBER_API_KEY: ${{secrets.KUBER_API_KEY}}
102+
NETWORK: ${{ inputs.network || vars.NETWORK }}
99103
TEST_WORKERS: ${{vars.TEST_WORKERS}}
100104
CI: ${{vars.CI}}
101105
FAUCET_ADDRESS: ${{vars.FAUCET_ADDRESS}}
@@ -105,7 +109,7 @@ jobs:
105109

106110
publish-report:
107111
runs-on: ubuntu-latest
108-
if: always()
112+
if: always() && needs.integration-tests.result != 'skipped'
109113
needs: integration-tests
110114
steps:
111115
- uses: actions/checkout@v4

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ changes.
1616

1717
### Fixed
1818

19-
-
19+
- Fix displaying DRep with doNotList property as string
20+
- Handle exception when no index is provided to /proposal/get endpoint [Issue 1841](https://github.com/IntersectMBO/govtool/issues/1841)
2021

2122
### Changed
2223

govtool/backend/src/VVA/API/Types.hs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,14 @@ instance ToJSON GovActionId where
139139
instance FromHttpApiData GovActionId where
140140
parseUrlPiece t = case Text.splitOn "#" t of
141141
[hash, rest] -> do
142-
index <- case readMaybe $ Text.unpack rest of
143-
Just x -> pure x
144-
_ -> Left (Text.tail rest <> " is not a number")
145-
hexHash <- parseUrlPiece hash
146-
Right $ GovActionId hexHash index
142+
if Text.null rest
143+
then Left "Missing index in hash#index format"
144+
else do
145+
index <- case readMaybe $ Text.unpack rest of
146+
Just x -> pure x
147+
_ -> Left (rest <> " is not a number")
148+
hexHash <- parseUrlPiece hash
149+
Right $ GovActionId hexHash index
147150
_ -> Left "Not a valid hash#index value"
148151

149152
exampleGovActionId :: Text

govtool/frontend/src/pages/DRepDirectoryContent.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
} from "@hooks";
1515
import { DataActionsBar, EmptyStateDrepDirectory } from "@molecules";
1616
import { AutomatedVotingOptions, DRepCard } from "@organisms";
17-
import { correctAdaFormat, isSameDRep, uniqBy } from "@utils";
17+
import { correctAdaFormat, isSameDRep, uniqBy, parseBoolean } from "@utils";
1818
import { DRepData, DRepListSort, DRepStatus } from "@models";
1919
import {
2020
AutomatedVotingOptionCurrentDelegation,
@@ -107,9 +107,15 @@ export const DRepDirectoryContent: FC<DRepDirectoryContentProps> = ({
107107
const ada = correctAdaFormat(votingPower);
108108

109109
const listedDRepsWithoutYourself = uniqBy(
110-
dRepList?.filter((dRep) => !dRep.doNotList && !isSameDRep(dRep, myDRepId)),
110+
dRepList?.filter(
111+
(dRep) =>
112+
(typeof dRep.doNotList === "string"
113+
? !parseBoolean(dRep.doNotList)
114+
: !dRep.doNotList) && !isSameDRep(dRep, myDRepId),
115+
),
111116
"view",
112117
);
118+
113119
const dRepListToDisplay =
114120
yourselfDRep && showYourselfDRep
115121
? [yourselfDRep, ...listedDRepsWithoutYourself]

govtool/frontend/src/utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ export * from "./testIdFromLabel";
3737
export * from "./uniqBy";
3838
export * from "./wait";
3939
export * from "./getBase64ImageDetails";
40+
export * from "./parseBoolean";
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Parses a string value and returns its boolean equivalent.
3+
*
4+
* @param value - The string value to be parsed.
5+
* @returns `true` if the value is "true" (case insensitive),
6+
* `false` if the value is "false" (case insensitive),
7+
* or `null` if the value is neither.
8+
*/
9+
export const parseBoolean = (value: string): boolean | null =>
10+
({
11+
true: true,
12+
false: false,
13+
}[String(value).toLowerCase()] ?? null);
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
2+
import { parseBoolean } from "../parseBoolean";
3+
4+
describe("parseBoolean", () => {
5+
it("should return true for 'true' (case insensitive)", () => {
6+
expect(parseBoolean("true")).toBe(true);
7+
expect(parseBoolean("TRUE")).toBe(true);
8+
expect(parseBoolean("TrUe")).toBe(true);
9+
});
10+
11+
it("should return false for 'false' (case insensitive)", () => {
12+
expect(parseBoolean("false")).toBe(false);
13+
expect(parseBoolean("FALSE")).toBe(false);
14+
expect(parseBoolean("FaLsE")).toBe(false);
15+
});
16+
17+
it("should return null for any other string", () => {
18+
expect(parseBoolean("yes")).toBeNull();
19+
expect(parseBoolean("no")).toBeNull();
20+
expect(parseBoolean("1")).toBeNull();
21+
expect(parseBoolean("0")).toBeNull();
22+
expect(parseBoolean("")).toBeNull();
23+
});
24+
25+
it("should return null for non-string values", () => {
26+
expect(parseBoolean(null as any)).toBeNull();
27+
expect(parseBoolean(undefined as any)).toBeNull();
28+
expect(parseBoolean(123 as any)).toBeNull();
29+
expect(parseBoolean({} as any)).toBeNull();
30+
});
31+
});

govtool/frontend/yarn.lock

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,15 +1367,15 @@
13671367
resolved "https://registry.npmjs.org/@emurgo/cardano-serialization-lib-asmjs/-/cardano-serialization-lib-asmjs-12.1.1.tgz"
13681368
integrity sha512-K3f28QUfLDJ7seO6MtKfMYtRm5ccf36TQ5yxyTmZqX1TA85MkriEdxqpgV9KLiLEA95emwnlvU2/WmlHMRPg1A==
13691369

1370-
"@esbuild/linux-x64@0.21.5":
1370+
"@esbuild/darwin-arm64@0.21.5":
13711371
version "0.21.5"
1372-
resolved "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz"
1373-
integrity sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==
1372+
resolved "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz"
1373+
integrity sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==
13741374

1375-
"@esbuild/linux-x64@0.24.2":
1375+
"@esbuild/darwin-arm64@0.24.2":
13761376
version "0.24.2"
1377-
resolved "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.24.2.tgz"
1378-
integrity sha512-8Qi4nQcCTbLnK9WoMjdC9NiTG6/E38RNICU6sUNqK0QFxCYgoARqVqxdFmWkdonVsvGqWhmm7MO0jyTqLqwj0Q==
1377+
resolved "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.24.2.tgz"
1378+
integrity sha512-kj3AnYWc+CekmZnS5IPu9D+HWtUI49hbnyqk0FLEJDbzCIQt7hg7ucF1SQAilhtYpIujfaHr6O0UHlzzSPdOeA==
13791379

13801380
"@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0":
13811381
version "4.4.1"
@@ -2162,15 +2162,10 @@
21622162
resolved "https://registry.npmjs.org/@open-draft/until/-/until-2.1.0.tgz"
21632163
integrity sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg==
21642164

2165-
"@parcel/watcher-linux-x64-glibc@2.5.0":
2165+
"@parcel/watcher-darwin-arm64@2.5.0":
21662166
version "2.5.0"
2167-
resolved "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.5.0.tgz"
2168-
integrity sha512-d9AOkusyXARkFD66S6zlGXyzx5RvY+chTP9Jp0ypSTC9d4lzyRs9ovGf/80VCxjKddcUvnsGwCHWuF2EoPgWjw==
2169-
2170-
2171-
version "2.5.0"
2172-
resolved "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.5.0.tgz"
2173-
integrity sha512-iqOC+GoTDoFyk/VYSFHwjHhYrk8bljW6zOhPuhi5t9ulqiYq1togGJB5e3PwYVFFfeVgc6pbz3JdQyDoBszVaA==
2167+
resolved "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.5.0.tgz"
2168+
integrity sha512-hyZ3TANnzGfLpRA2s/4U1kbw2ZI4qGxaRJbBH2DCSREFfubMswheh8TeiC1sGZ3z2jUf3s37P0BBlrD3sjVTUw==
21742169

21752170
"@parcel/watcher@^2.4.1":
21762171
version "2.5.0"
@@ -2283,15 +2278,10 @@
22832278
estree-walker "^2.0.2"
22842279
picomatch "^4.0.2"
22852280

2286-
"@rollup/rollup-linux-x64-gnu@4.27.4":
2281+
"@rollup/rollup-darwin-arm64@4.27.4":
22872282
version "4.27.4"
2288-
resolved "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.27.4.tgz"
2289-
integrity sha512-Ni8mMtfo+o/G7DVtweXXV/Ol2TFf63KYjTtoZ5f078AUgJTmaIJnj4JFU7TK/9SVWTaSJGxPi5zMDgK4w+Ez7Q==
2290-
2291-
2292-
version "4.27.4"
2293-
resolved "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.27.4.tgz"
2294-
integrity sha512-5AeeAF1PB9TUzD+3cROzFTnAJAcVUGLuR8ng0E0WXGkYhp6RD6L+6szYVX+64Rs0r72019KHZS1ka1q+zU/wUw==
2283+
resolved "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.27.4.tgz"
2284+
integrity sha512-PlNiRQapift4LNS8DPUHuDX/IdXiLjf8mc5vdEmUR0fF/pyy2qWwzdLjB+iZquGr8LuN4LnUoSEvKRwjSVYz3Q==
22952285

22962286
"@rtsao/scc@^1.1.0":
22972287
version "1.1.0"
@@ -2870,15 +2860,10 @@
28702860
"@svgr/plugin-svgo" "^5.5.0"
28712861
loader-utils "^2.0.0"
28722862

2873-
"@swc/core-linux-x64-gnu@1.9.3":
2863+
"@swc/core-darwin-arm64@1.9.3":
28742864
version "1.9.3"
2875-
resolved "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.9.3.tgz"
2876-
integrity sha512-ivXXBRDXDc9k4cdv10R21ccBmGebVOwKXT/UdH1PhxUn9m/h8erAWjz5pcELwjiMf27WokqPgaWVfaclDbgE+w==
2877-
2878-
2879-
version "1.9.3"
2880-
resolved "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.9.3.tgz"
2881-
integrity sha512-ILsGMgfnOz1HwdDz+ZgEuomIwkP1PHT6maigZxaCIuC6OPEhKE8uYna22uU63XvYcLQvZYDzpR3ms47WQPuNEg==
2865+
resolved "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.9.3.tgz"
2866+
integrity sha512-hGfl/KTic/QY4tB9DkTbNuxy5cV4IeejpPD4zo+Lzt4iLlDWIeANL4Fkg67FiVceNJboqg48CUX+APhDHO5G1w==
28822867

28832868
"@swc/core@*", "@swc/core@^1.5.22", "@swc/core@^1.7.26":
28842869
version "1.9.3"
@@ -7184,6 +7169,16 @@ fs@^0.0.1-security:
71847169
resolved "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz"
71857170
integrity sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w==
71867171

7172+
fsevents@^2.3.2, fsevents@~2.3.2, fsevents@~2.3.3:
7173+
version "2.3.3"
7174+
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz"
7175+
integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==
7176+
7177+
7178+
version "2.3.2"
7179+
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz"
7180+
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
7181+
71877182
function-bind@^1.1.2:
71887183
version "1.1.2"
71897184
resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz"

tests/govtool-backend/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
METRICS_API_SECRET = os.getenv("METRICS_API_SECRET")
1414
KUBER_API_URL = f'https://{os.getenv("NETWORK","preview")}.kuber.cardanoapi.io'
1515
KUBER_API_KEY = os.getenv("KUBER_API_KEY")
16-
FAUCET_API_URL = f'https://faucet.${os.getenv("NETWORK","preview")}.world.dev.cardano.org'
16+
FAUCET_API_URL = f'https://faucet.{os.getenv("NETWORK","preview")}.world.dev.cardano.org'
1717
FACUET_API_KEY = os.getenv("FAUCET_API_KEY")

0 commit comments

Comments
 (0)