Skip to content

Commit f30f36f

Browse files
authored
Merge pull request #3991 from IntersectMBO/develop
v2.0.33
2 parents b65e343 + 90ddbe5 commit f30f36f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1424
-588
lines changed

.github/workflows/code_check_backend.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ jobs:
1313
- name: Use Haskell
1414
uses: haskell-actions/setup@v2
1515
with:
16-
ghc-version: '9.2.7'
17-
cabal-version: '3.6.0.0'
16+
ghc-version: '9.2.8'
17+
cabal-version: '3.8.1.0'
18+
cabal-update: false
1819

1920
- name: Use Python
2021
uses: actions/setup-python@v2
@@ -26,6 +27,13 @@ jobs:
2627

2728
- name: Install HLint
2829
run: |
30+
rm -rf ~/.cabal ~/.ghcup
31+
mkdir -p ~/.cabal
32+
cat <<EOF > ~/.cabal/config
33+
repository hackage.haskell.org
34+
url: http://hackage.haskell.org/
35+
secure: False
36+
EOF
2937
cabal update
3038
cabal install hlint
3139
@@ -41,8 +49,9 @@ jobs:
4149
- name: Use Haskell
4250
uses: haskell-actions/setup@v2
4351
with:
44-
ghc-version: '9.2.7'
45-
cabal-version: '3.6.0.0'
52+
ghc-version: '9.2.8'
53+
cabal-version: '3.8.1.0'
54+
cabal-update: false
4655

4756
- name: Use Python
4857
uses: actions/setup-python@v2
@@ -54,6 +63,13 @@ jobs:
5463

5564
- name: Install HLint
5665
run: |
66+
rm -rf ~/.cabal ~/.ghcup
67+
mkdir -p ~/.cabal
68+
cat <<EOF > ~/.cabal/config
69+
repository hackage.haskell.org
70+
url: http://hackage.haskell.org/
71+
secure: False
72+
EOF
5773
cabal update
5874
cabal install stylish-haskell
5975

.github/workflows/merge.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ permissions:
1212
packages: write
1313

1414
env:
15-
ENVIRONMENT: ${{ (github.ref_name == 'main' && 'prod-govtool') || (github.ref_name == 'staging' && 'pre-prod-govtool') || (github.ref_name == 'test' && 'qa-govtool') || (github.ref_name == 'develop' && 'dev-govtool') }}
15+
ENVIRONMENT: ${{ (github.ref_name == 'develop' && 'dev-govtool') }}
1616

1717
jobs:
1818
check-build-deploy:
19-
environment: ${{ (github.ref_name == 'main' && 'prod-govtool') || (github.ref_name == 'staging' && 'pre-prod-govtool') || (github.ref_name == 'test' && 'qa-govtool') || (github.ref_name == 'develop' && 'dev-govtool') }}
19+
environment: ${{ (github.ref_name == 'develop' && 'dev-govtool') }}
2020
strategy:
2121
fail-fast: false
2222
matrix:

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ changes.
1515
### Fixed
1616

1717
- Fix disappearing proposals in the governance actions list for the same tx hashes [Issue 3918](https://github.com/IntersectMBO/govtool/issues/3918)
18+
- Fix incorrect display of new committee parameters in Governance Action details [Issue 3954](https://github.com/IntersectMBO/govtool/issues/3954)
1819

1920
### Changed
2021

govtool/backend/app/Main.hs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Control.Monad.Trans.Except
1616
import Control.Monad.Trans.Reader
1717

1818
import Data.Aeson hiding (Error)
19+
import Data.Aeson (encode)
1920
import qualified Data.ByteString as BS
2021
import Data.ByteString.Char8 (unpack)
2122
import qualified Data.Cache as Cache
@@ -35,7 +36,7 @@ import Data.Text.Encoding (encodeUtf8)
3536
import qualified Data.Text.IO as Text
3637
import qualified Data.Text.Lazy as LazyText
3738
import qualified Data.Text.Lazy.Encoding as LazyText
38-
39+
import qualified Data.ByteString.Lazy.Char8 as BS8
3940
import Database.PostgreSQL.Simple (close, connectPostgreSQL, Connection)
4041

4142
import Network.Wai
@@ -62,8 +63,10 @@ import VVA.API.Types
6263
import VVA.CommandLine
6364
import VVA.Config
6465
import VVA.Types (AppEnv (..),
65-
AppError (CriticalError, InternalError, NotFoundError, ValidationError),
66+
AppError (..),
6667
CacheEnv (..))
68+
import VVA.Ipfs (IpfsError(..))
69+
6770

6871
-- Function to create a connection pool with optimized settings
6972
createOptimizedConnectionPool :: BS.ByteString -> IO (Pool Connection)
@@ -288,10 +291,15 @@ liftServer appEnv =
288291
where
289292
handleErrors :: Either AppError a -> Handler a
290293
handleErrors (Right x) = pure x
291-
handleErrors (Left (ValidationError msg)) = throwError $ err400 { errBody = BS.fromStrict $ encodeUtf8 msg }
292-
handleErrors (Left (NotFoundError msg)) = throwError $ err404 { errBody = BS.fromStrict $ encodeUtf8 msg }
293-
handleErrors (Left (CriticalError msg)) = throwError $ err500 { errBody = BS.fromStrict $ encodeUtf8 msg }
294-
handleErrors (Left (InternalError msg)) = throwError $ err500 { errBody = BS.fromStrict $ encodeUtf8 msg }
294+
handleErrors (Left appError) = do
295+
let status = case appError of
296+
ValidationError _ -> err400
297+
NotFoundError _ -> err404
298+
CriticalError _ -> err500
299+
InternalError _ -> err500
300+
AppIpfsError (OtherIpfsError _) -> err400
301+
AppIpfsError _ -> err503
302+
throwError $ status { errBody = encode appError, errHeaders = [("Content-Type", "application/json")] }
295303
-- * Swagger
296304

297305
type SwaggerAPI = SwaggerSchemaUI "swagger-ui" "swagger.json"

govtool/backend/example-config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"password" : "postgres",
77
"port" : 5432
88
},
9+
"pinataapijwt": "",
910
"port" : 9999,
1011
"host" : "localhost",
1112
"cachedurationseconds": 20,

govtool/backend/sql/list-proposals.sql

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,21 @@ CommitteeData AS (
4242
FROM
4343
committee_member cm
4444
JOIN committee_hash ch ON cm.committee_hash_id = ch.id
45+
WHERE EXISTS (
46+
SELECT 1
47+
FROM committee_registration cr
48+
WHERE cr.cold_key_id = ch.id
49+
)
50+
AND NOT EXISTS (
51+
SELECT 1
52+
FROM committee_de_registration cdr
53+
WHERE cdr.cold_key_id = ch.id
54+
AND cdr.tx_id > (
55+
SELECT MAX(cr2.tx_id)
56+
FROM committee_registration cr2
57+
WHERE cr2.cold_key_id = ch.id
58+
)
59+
)
4560
ORDER BY
4661
ch.raw, cm.expiration_epoch DESC
4762
),
@@ -61,10 +76,31 @@ ParsedDescription AS (
6176
MembersToBeRemoved AS (
6277
SELECT
6378
id,
64-
json_agg(VALUE->>'keyHash') AS members_to_be_removed
79+
json_agg(
80+
json_build_object(
81+
'hash', COALESCE(
82+
VALUE->>'keyHash',
83+
VALUE->>'scriptHash'
84+
),
85+
'type', CASE
86+
WHEN VALUE->>'keyHash' IS NOT NULL THEN 'keyHash'
87+
WHEN VALUE->>'scriptHash' IS NOT NULL THEN 'scriptHash'
88+
ELSE 'unknown'
89+
END,
90+
'hasScript', CASE
91+
WHEN VALUE->>'scriptHash' IS NOT NULL THEN true
92+
ELSE false
93+
END
94+
)
95+
) AS members_to_be_removed
6596
FROM
6697
ParsedDescription pd,
67-
json_array_elements(members_to_be_removed::json) AS value
98+
json_array_elements(
99+
CASE
100+
WHEN pd.members_to_be_removed IS NULL THEN '[]'::json
101+
ELSE pd.members_to_be_removed::json
102+
END
103+
) AS value
68104
GROUP BY
69105
id
70106
),
@@ -73,7 +109,15 @@ ProcessedCurrentMembers AS (
73109
pd.id,
74110
json_agg(
75111
json_build_object(
76-
'hash', regexp_replace(kv.key, '^keyHash-', ''),
112+
'hash', COALESCE(
113+
regexp_replace(kv.key, '^keyHash-', ''),
114+
regexp_replace(kv.key, '^scriptHash-', '')
115+
),
116+
'type', CASE
117+
WHEN kv.key LIKE 'keyHash-%' THEN 'keyHash'
118+
WHEN kv.key LIKE 'scriptHash-%' THEN 'scriptHash'
119+
ELSE 'unknown'
120+
END,
77121
'newExpirationEpoch', kv.value::int
78122
)
79123
) AS current_members
@@ -88,9 +132,17 @@ EnrichedCurrentMembers AS (
88132
pcm.id,
89133
json_agg(
90134
json_build_object(
91-
'hash', cm.hash,
135+
'hash', CASE
136+
WHEN (member->>'hash') LIKE 'scriptHash-%' THEN
137+
regexp_replace(member->>'hash', '^scriptHash-', '')
138+
WHEN (member->>'hash') LIKE 'keyHash-%' THEN
139+
regexp_replace(member->>'hash', '^keyHash-', '')
140+
ELSE
141+
member->>'hash'
142+
END,
143+
'type', member->>'type',
92144
'expirationEpoch', cm.expiration_epoch,
93-
'hasScript', cm.has_script,
145+
'hasScript', COALESCE(cm.has_script, member->>'type' = 'scriptHash'),
94146
'newExpirationEpoch', (member->>'newExpirationEpoch')::int
95147
)
96148
) AS enriched_members
@@ -247,9 +299,9 @@ SELECT
247299
)
248300
FROM
249301
ParsedDescription pd
250-
JOIN
302+
LEFT JOIN
251303
MembersToBeRemoved mtr ON pd.id = mtr.id
252-
JOIN
304+
LEFT JOIN
253305
EnrichedCurrentMembers em ON pd.id = em.id
254306
WHERE
255307
pd.id = gov_action_proposal.id

0 commit comments

Comments
 (0)