Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sancho-v1.0.10 #1589

Merged
merged 80 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
6a08db6
[#1404] improve query data type from any
j-dyczka Jul 5, 2024
4e67563
list-proposals: fix SQL
disassembler Jul 10, 2024
db6f11b
backend: allow using metadata directly from db-sync
disassembler Jul 10, 2024
b53d746
chore: bump @intersect.mbo/pdf-ui to v0.2.9
j-dyczka Jul 12, 2024
4aba061
Merge pull request #1572 from IntersectMBO/chore/bump-pdf-ui
jdyczka Jul 12, 2024
47573b7
Merge pull request #1553 from disassembler/sl/metadata-validation-opt…
bosko-m Jul 12, 2024
d29b93e
Merge pull request #1552 from disassembler/sl/fix-proposals-sql
bosko-m Jul 12, 2024
a812883
fix: fix frontend build
MSzalowski Jul 15, 2024
003bb2b
Merge pull request #1579 from IntersectMBO/fix/fix-vite-package-trans…
MSzalowski Jul 16, 2024
bd911e1
[#1538] Update Cardano Node and DB Sync versions in dev environment
placek Jul 15, 2024
a842bd2
[#1538] Update Cardano DB Sync and Node versions
placek Jul 15, 2024
e2e17d9
Update resync workflow to align with deployment workflow configuration
placek Jul 15, 2024
9dcf3a6
[#1413] remove balance check on redirect
j-dyczka Jul 16, 2024
83b4d55
Merge pull request #1577 from IntersectMBO/chore/1538-chore-bump-db-s…
placek Jul 16, 2024
af9616b
fix: add missing dependency @babel/preset-react
j-dyczka Jul 16, 2024
5e20d70
Merge pull request #1586 from IntersectMBO/fix/add-missing-dependecy
MSzalowski Jul 16, 2024
f57a140
[#1472] Bump CSL version to 12.0.0-beta.2
j-dyczka Jul 12, 2024
ad57a1a
Merge pull request #1570 from IntersectMBO/chore/1472-bump-csl
MSzalowski Jul 16, 2024
1d600f6
chore: bump version v1.0.9
MSzalowski Jul 16, 2024
f8855e0
Merge pull request #1587 from IntersectMBO/chore/bump-version
MSzalowski Jul 16, 2024
93b0542
Merge pull request #1584 from IntersectMBO/fix/1413-no-balance-check-…
jdyczka Jul 16, 2024
3761b68
Merge pull request #1532 from IntersectMBO/fix/1404-dRepHash-of-undef…
jdyczka Jul 16, 2024
a927c7d
Improve exception handling to better recognize and skip specific exce…
placek Jul 17, 2024
b56cffe
Address HLint complaints
placek Jul 17, 2024
638263c
Apply stylish-haskell code formatting
placek Jul 17, 2024
55d5739
Merge pull request #1592 from IntersectMBO/1417-sentry-exception-befo…
placek Jul 18, 2024
1083782
chore(#1575): Provide pdf api url from the env variables
MSzalowski Jul 18, 2024
4708192
Merge pull request #1593 from IntersectMBO/chore/provide-pdf-api-url-…
MSzalowski Jul 19, 2024
0f37c72
[#1501] Set proposal discussion forum enabled by default
j-dyczka Jul 9, 2024
95761c8
Auto stash before rebase of "chore/provide-pdf-api-url-from-the-env-v…
MSzalowski Jul 18, 2024
9011cba
Merge pull request #1533 from IntersectMBO/1501-default-enable-propos…
jdyczka Jul 19, 2024
941e436
fix: verify identity on navigation to proposal creation for treasury …
kneerose Jul 10, 2024
5275507
chore: add assertion instead of wait timeout on get and view draft
kneerose Jul 10, 2024
59277c7
fix: proposal created with poll enabled test issue due to user auth a…
kneerose Jul 18, 2024
d465e4b
chore: bump @intersect.mbo/pdf-ui@0.3.0
MSzalowski Jul 19, 2024
67dd138
chore: increase get draft assertion timeout due to slow rendering
kneerose Jul 22, 2024
eb66e5d
Merge pull request #1595 from IntersectMBO/chore/bump-pdf-ui-0.3.0
MSzalowski Jul 22, 2024
4f69121
Merge pull request #1596 from IntersectMBO/bugfix/test-proposal-draft
kneerose Jul 22, 2024
687dfd6
Make Haskell artifacts exclusion more generic in .gitignore
placek Jul 22, 2024
ba21289
EnableFutureGenesis option added to dbsync config
placek Jul 22, 2024
cc36c54
chore: bump @intersect.mbo/pdf-ui@0.3.1
MSzalowski Jul 23, 2024
7970bad
Apply DBSync configuration to the DBSync container
placek Jul 22, 2024
4b3c48e
Merge pull request #1604 from IntersectMBO/chore/bump-@intersect-mbo-…
MSzalowski Jul 23, 2024
8c87540
fix: flaky test 8c by modifying the assertion to check for `testid` i…
kneerose Jul 23, 2024
3f31675
chore: seperate proposal type and status filter
kneerose Jul 23, 2024
9cd9d62
chore: setup temporary proposal auth instead of using on beforeEach …
kneerose Jul 23, 2024
01d0ad4
fix: test 7B assertion
kneerose Jul 23, 2024
ade9d73
chore: add extra two proposal auth for proposal draft
kneerose Jul 23, 2024
735b3d9
chore: add missing test ids on proposal details page
kneerose Jul 24, 2024
bcc3cf2
chore: update proposalCreation navigation flow on submit a proposal
kneerose Jul 24, 2024
a182d20
Merge pull request #1606 from IntersectMBO/bugfix/proposal-discussion
kneerose Jul 24, 2024
ea89bb0
Enable future genesis in dbsync configuration
placek Jul 24, 2024
489b4f9
refactor: extract duplicate authentication setup into a helper function
kneerose Jul 24, 2024
1a86aa9
Merge pull request #1607 from IntersectMBO/refactor/auth-setup
kneerose Jul 24, 2024
dfa69cb
Add missing ENV variable for PDF API in workflow
placek Jul 24, 2024
7126599
Add ECR registry for custom Cardano DB Sync image
placek Jul 24, 2024
78a591c
Prepare Makefile to build Cardano DB Sync image with custom entrypoint
placek Jul 24, 2024
c51f482
Add entrypoint that customizes DBSync configuration
placek Jul 24, 2024
10aff0c
Merge pull request #1609 from IntersectMBO/fix/1464-add-enable-future…
placek Jul 24, 2024
d28b355
[#1117] redirect to private drep directory url if connected user ente…
j-dyczka Jul 24, 2024
22098bb
chore: provide more postgres connection options
MSzalowski Jul 26, 2024
f6a0c47
[#1117] change implementation of checkIsWalletConnected
j-dyczka Jul 26, 2024
2067137
Merge pull request #1617 from IntersectMBO/chore/provide-more-postgre…
MSzalowski Jul 29, 2024
20ba77a
fix(#1612): Fix connection to the metadata-validation service
MSzalowski Jul 26, 2024
6204f1d
chore(#1612): fix indentation
MSzalowski Jul 29, 2024
d648c52
Merge pull request #1618 from IntersectMBO/fix/1612-be-get-dreplist-t…
MSzalowski Jul 29, 2024
b2bb561
fix: fix indentation syntax error in Metadata.hs
MSzalowski Jul 29, 2024
fc3e5c3
Merge pull request #1619 from IntersectMBO/fix/fix-metadata-hs-syntax…
MSzalowski Jul 29, 2024
78ba78b
Merge pull request #1610 from IntersectMBO/1117-drep-directory-auth-r…
jdyczka Jul 29, 2024
cf2ed10
[#1442] Add redirect to dashboard cards after connect
j-dyczka Jul 24, 2024
6ff7c58
Merge pull request #1611 from IntersectMBO/1442-home-cards-redirect-a…
jdyczka Jul 29, 2024
f880076
fix(#1582): Add support for CIP-100 on vote metadata
MSzalowski Jul 23, 2024
6d0fac5
chore(#1582): get rid of canonization of CIP-100 metadata
MSzalowski Jul 29, 2024
8174a9f
Merge pull request #1603 from IntersectMBO/fix/1582-vote-metadata-fol…
MSzalowski Jul 29, 2024
0c40167
fix(wallet): fix inputs selection with the change config
MSzalowski Jul 23, 2024
9ac0345
removed unneeded code
Ryun1 Jul 25, 2024
96fc496
Update CHANGELOG.md
MSzalowski Jul 29, 2024
71412e0
Merge pull request #1605 from IntersectMBO/fix/add-change-config-for-…
MSzalowski Jul 29, 2024
86a4892
chore: bump GovTool version to v1.0.10
MSzalowski Jul 29, 2024
8522c3d
Merge pull request #1620 from IntersectMBO/chore/bump-govtool-to-v1.0.10
MSzalowski Jul 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 31 additions & 9 deletions .github/workflows/resync-cardano-node-and-db-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,27 @@ on:
- "test"
- "staging"
- "beta"
isProposalDiscussionForumEnabled:
description: "Enable proposal discussion forum"
required: true
type: choice
default: "disabled"
options:
- "enabled"
- "disabled"
forceRebuildDockerImages:
description: "Force rebuild the docker images"
required: false
type: choice
default: "false"
options:
- "true"
- "false"

env:
ENVIRONMENT: ${{ inputs.environment || 'dev' }}
CARDANO_NETWORK: "sanchonet"
FORCE_REBUILD: ${{inputs.forceRebuildDockerImages == 'true'}}

jobs:
deploy:
Expand All @@ -27,22 +44,27 @@ jobs:
working-directory: ./scripts/govtool
env:
DBSYNC_POSTGRES_DB: "cexplorer"
DBSYNC_POSTGRES_USER: "postgres"
DBSYNC_POSTGRES_PASSWORD: "pSa8JCpQOACMUdGb"
DBSYNC_POSTGRES_USER: "postgres"
GA_CLIENT_EMAIL: ${{ secrets.GA_CLIENT_EMAIL }}
GA_PRIVATE_KEY: ${{ secrets.GA_PRIVATE_KEY }}
GRAFANA_ADMIN_PASSWORD: ${{ secrets.GRAFANA_ADMIN_PASSWORD }}
GRAFANA_SLACK_RECIPIENT: ${{ secrets.GRAFANA_SLACK_RECIPIENT }}
GRAFANA_SLACK_OAUTH_TOKEN: ${{ secrets.GRAFANA_SLACK_OAUTH_TOKEN }}
DEV_NGINX_BASIC_AUTH: ${{ secrets.DEV_NGINX_BASIC_AUTH }}
TEST_NGINX_BASIC_AUTH: ${{ secrets.TEST_NGINX_BASIC_AUTH }}
STAGING_NGINX_BASIC_AUTH: ${{ secrets.STAGING_NGINX_BASIC_AUTH }}
SENTRY_DSN_BACKEND: ${{ secrets.SENTRY_DSN_BACKEND }}
TRAEFIK_LE_EMAIL: "admin+govtool@binarapps.com"
GRAFANA_SLACK_RECIPIENT: ${{ secrets.GRAFANA_SLACK_RECIPIENT }}
GTM_ID: ${{ secrets.GTM_ID }}
NPMRC_TOKEN: ${{ secrets.NPMRC_TOKEN }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN_FRONTEND }}
PIPELINE_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
IP_ADDRESS_BYPASSING_BASIC_AUTH1: ${{ secrets.IP_ADDRESS_BYPASSING_BASIC_AUTH1 }}
IP_ADDRESS_BYPASSING_BASIC_AUTH2: ${{ secrets.IP_ADDRESS_BYPASSING_BASIC_AUTH2 }}
NEXT_PUBLIC_API_URL: "https://participation.sanchogov.tools"
NEXT_PUBLIC_GA4_PROPERTY_ID: ${{ secrets.NEXT_PUBLIC_GA4_PROPERTY_ID }}
DEV_NGINX_BASIC_AUTH: ${{ secrets.DEV_NGINX_BASIC_AUTH }}
PIPELINE_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN_FRONTEND }}
SENTRY_DSN_BACKEND: ${{ secrets.SENTRY_DSN_BACKEND }}
SENTRY_IGNORE_API_RESOLUTION_ERROR: "1"
TRAEFIK_LE_EMAIL: "admin+govtool@binarapps.com"
USERSNAP_SPACE_API_KEY: ${{ secrets.USERSNAP_SPACE_API_KEY }}
IS_PROPOSAL_DISCUSSION_FORUM_ENABLED: ${{ inputs.isProposalDiscussionForumEnabled == 'enabled' }}
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down
34 changes: 24 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,28 @@ changes.

## [Unreleased]

### Added

-

### Fixed

-

### Changed

-

## [sancho-v1.0.9](https://github.com/IntersectMBO/govtool/releases/tag/sancho-v1.0.9) 2024-07-16

### Added

- Added 'sentryenv' field in backend config file [Issue 1401](https://github.com/IntersectMBO/govtool/issues/1401)
- Add wallet connector package [Issue 898](https://github.com/IntersectMBO/govtool/issues/898)
- Change DRep without metadata name from "Sole Voter" to "Direct Voter" [Issue 880](https://github.com/IntersectMBO/govtool/issues/880)
- Inicialize Usersnap into App [Issue 546](https://github.com/IntersectMBO/govtool/issues/546)
- Initialize Usersnap into App [Issue 546](https://github.com/IntersectMBO/govtool/issues/546)
- Integrate frontend with metadata validation service [Issue 617](https://github.com/IntersectMBO/govtool/issues/617)
- Implement a loading modal for the validation of the metadata [Issue 646](https://github.com/IntersectMBO/govtool/issues/646)
- Fix displaying modals to not block signing transactions [Issue 710](https://github.com/IntersectMBO/govtool/issues/710)
- Change style of url button to trim the file name [Issue 655](https://github.com/IntersectMBO/govtool/issues/655)
- Change regex for parsing urls to match urls without protocol [Issue 655](https://github.com/IntersectMBO/govtool/issues/655)
- Integrate ga displaying metadata validation with the validation service [Issue 712](https://github.com/IntersectMBO/govtool/issues/712)
- Correct text of the governance action type [Issue 651](https://github.com/IntersectMBO/govtool/issues/651)
- Enable coverage tests report

### Added

- added `bio` `dRepName` `email` `references` `metadataValid` and `metadataStatus` fields to `drep/list`
- added `metadatavalidationmaxconcurrentrequests` field to the backend config
- added `metadata/validate` endpoint [Issue 876](https://github.com/IntersectMBO/govtool/issues/876)
Expand Down Expand Up @@ -67,6 +74,7 @@ changes.
- Replace govtool-wrapper governance action creation in favor of pdf-pillar [Issue 1284](https://github.com/IntersectMBO/govtool/issues/1284)
- Add sentry environment config [Issue 1324](https://github.com/IntersectMBO/govtool/issues/1324)
- Add proposal discussion pillar to home page [Issue 1431](https://github.com/IntersectMBO/govtool/issues/1431)
- Enable coverage tests report

### Fixed

Expand Down Expand Up @@ -107,6 +115,9 @@ changes.
- Fix app crash on voting on the GA without the connected wallet before [Issue 1313](https://github.com/IntersectMBO/govtool/issues/1313)
- Fix the navigation to Home from Proposal pillar on disconnected wallet [Issue 1355](https://github.com/IntersectMBO/govtool/issues/1355)
- Fix navigation over Proposal discussion forum pillar [Issue 1436](https://github.com/IntersectMBO/govtool/issues/1436)
- Fix building the frontend image [Issue 1583](https://github.com/IntersectMBO/govtool/issues/1583)
- Correct text of the governance action type [Issue 651](https://github.com/IntersectMBO/govtool/issues/651)
- Fix displaying modals to not block signing transactions [Issue 710](https://github.com/IntersectMBO/govtool/issues/710)

### Changed

Expand Down Expand Up @@ -140,6 +151,9 @@ changes.
- Changed copy on maintenance page [Issue 753](https://github.com/IntersectMBO/govtool/issues/753)
- Update link to docs [Issue 1246](https://github.com/IntersectMBO/govtool/issues/1246)
- Change label of Proposal Discussion nav item [Issue 1349](https://github.com/IntersectMBO/govtool/issues/1349)
- Change DRep without metadata name from "Sole Voter" to "Direct Voter" [Issue 880](https://github.com/IntersectMBO/govtool/issues/880)
- Change style of url button to trim the file name [Issue 655](https://github.com/IntersectMBO/govtool/issues/655)
- Change regex for parsing urls to match urls without protocol [Issue 655](https://github.com/IntersectMBO/govtool/issues/655)

### Removed

Expand Down
1 change: 1 addition & 0 deletions govtool/backend/example-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"cachedurationseconds": 20,
"sentrydsn": "https://username:password@senty.host/id",
"sentryenv": "dev",
"metadatavalidationenabled": true,
"metadatavalidationhost": "localhost",
"metadatavalidationport": 3001,
"metadatavalidationmaxconcurrentrequests": 10
Expand Down
17 changes: 9 additions & 8 deletions govtool/backend/sql/list-proposals.sql
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ SELECT
/* created date */
voting_anchor.url,
encode(voting_anchor.data_hash, 'hex'),
off_chain_vote_data.title,
off_chain_vote_data.abstract,
off_chain_vote_data.motivation,
off_chain_vote_data.rationale,
off_chain_vote_gov_action_data.title,
off_chain_vote_gov_action_data.abstract,
off_chain_vote_gov_action_data.motivation,
off_chain_vote_gov_action_data.rationale,
off_chain_vote_data.json,
off_chain_vote_data.json#>'{body, references}' as references,
coalesce(Sum(ldd.amount) FILTER (WHERE voting_procedure.vote::text = 'Yes'), 0) +(
Expand Down Expand Up @@ -88,6 +88,7 @@ FROM
JOIN block AS creator_block ON creator_block.id = creator_tx.block_id
LEFT JOIN voting_anchor ON voting_anchor.id = gov_action_proposal.voting_anchor_id
LEFT JOIN off_chain_vote_data ON off_chain_vote_data.voting_anchor_id = voting_anchor.id
LEFT JOIN off_chain_vote_gov_action_data ON off_chain_vote_gov_action_data.off_chain_vote_data_id = off_chain_vote_data.id
LEFT JOIN voting_procedure ON voting_procedure.gov_action_proposal_id = gov_action_proposal.id
LEFT JOIN LatestDrepDistr ldd ON ldd.hash_id = voting_procedure.drep_voter
AND ldd.rn = 1
Expand All @@ -107,10 +108,10 @@ GROUP BY
stake_address.view,
treasury_withdrawal.amount,
creator_block.epoch_no,
off_chain_vote_data.title,
off_chain_vote_data.abstract,
off_chain_vote_data.motivation,
off_chain_vote_data.rationale,
off_chain_vote_gov_action_data.title,
off_chain_vote_gov_action_data.abstract,
off_chain_vote_gov_action_data.motivation,
off_chain_vote_gov_action_data.rationale,
off_chain_vote_data.json,
gov_action_proposal.index,
creator_tx.hash,
Expand Down
24 changes: 18 additions & 6 deletions govtool/backend/src/VVA/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -217,18 +217,30 @@ proposalToResponse Types.Proposal {..} Types.MetadataValidationResult{..} =
proposalResponseCreatedEpochNo = proposalCreatedEpochNo,
proposalResponseUrl = proposalUrl,
proposalResponseMetadataHash = HexText proposalDocHash,
proposalResponseTitle = Types.proposalMetadataTitle <$> metadata,
proposalResponseAbstract = Types.proposalMetadataAbstract <$> metadata,
proposalResponseMotivation = Types.proposalMetadataMotivation <$> metadata,
proposalResponseRationale = Types.proposalMetadataRationale <$> metadata,
proposalResponseTitle = getTitle proposalTitle metadata,
proposalResponseAbstract = getAbstract proposalAbstract metadata,
proposalResponseMotivation = getMotivation proposalMotivation metadata,
proposalResponseRationale = getRationale proposalRationale metadata,
proposalResponseMetadata = GovernanceActionMetadata <$> proposalMetadata,
proposalResponseReferences = maybe [] Types.proposalMetadataReferences metadata,
proposalResponseReferences = getReferences proposalReferences metadata,
proposalResponseYesVotes = proposalYesVotes,
proposalResponseNoVotes = proposalNoVotes,
proposalResponseAbstainVotes = proposalAbstainVotes,
proposalResponseMetadataStatus = metadataValidationResultStatus,
proposalResponseMetadataValid = metadataValidationResultValid
}
where
getTitle p Nothing = p
getTitle _ m = Types.proposalMetadataTitle <$> m
getAbstract p Nothing = p
getAbstract _ m = Types.proposalMetadataAbstract <$> m
getMotivation p Nothing = p
getMotivation _ m = Types.proposalMetadataMotivation <$> m
getRationale p Nothing = p
getRationale _ m = Types.proposalMetadataRationale <$> m
-- TODO: convert aeson references to [Text] from database
--getReferences p Nothing = p
getReferences _ m = maybe [] Types.proposalMetadataReferences m

voteToResponse :: Types.Vote -> VoteParams
voteToResponse Types.Vote {..} =
Expand Down Expand Up @@ -467,4 +479,4 @@ getDRepMetadataValidationResponse params = do
return $ MetadataValidationResponse
{ metadataValidationResponseValid = metadataValidationResultValid
, metadataValidationResponseStatus = metadataValidationResultStatus
}
}
13 changes: 13 additions & 0 deletions govtool/backend/src/VVA/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module VVA.Config
, getServerHost
, getServerPort
, vvaConfigToText
, getMetadataValidationEnabled
, getMetadataValidationHost
, getMetadataValidationPort
) where
Expand Down Expand Up @@ -82,6 +83,8 @@ data VVAConfigInternal
, vVAConfigInternalSentrydsn :: String
-- | Sentry environment
, vVAConfigInternalSentryEnv :: String
-- | Metadata validation service enabled
, vVAConfigInternalMetadataValidationEnabled :: Bool
-- | Metadata validation service host
, vVAConfigInternalMetadataValidationHost :: Text
-- | Metadata validation service port
Expand All @@ -100,6 +103,7 @@ instance DefaultConfig VVAConfigInternal where
vVaConfigInternalCacheDurationSeconds = 20,
vVAConfigInternalSentrydsn = "https://username:password@senty.host/id",
vVAConfigInternalSentryEnv = "development",
vVAConfigInternalMetadataValidationEnabled = True,
vVAConfigInternalMetadataValidationHost = "localhost",
vVAConfigInternalMetadataValidationPort = 3001,
vVAConfigInternalMetadataValidationMaxConcurrentRequests = 10
Expand All @@ -120,6 +124,8 @@ data VVAConfig
, sentryDSN :: String
-- | Sentry environment
, sentryEnv :: String
-- | Metadata validation service enabled
, metadataValidationEnabled :: Bool
-- | Metadata validation service host
, metadataValidationHost :: Text
-- | Metadata validation service port
Expand Down Expand Up @@ -167,6 +173,7 @@ convertConfig VVAConfigInternal {..} =
cacheDurationSeconds = vVaConfigInternalCacheDurationSeconds,
sentryDSN = vVAConfigInternalSentrydsn,
sentryEnv = vVAConfigInternalSentryEnv,
metadataValidationEnabled = vVAConfigInternalMetadataValidationEnabled,
metadataValidationHost = vVAConfigInternalMetadataValidationHost,
metadataValidationPort = vVAConfigInternalMetadataValidationPort,
metadataValidationMaxConcurrentRequests = vVAConfigInternalMetadataValidationMaxConcurrentRequests
Expand Down Expand Up @@ -208,6 +215,12 @@ getServerHost ::
m Text
getServerHost = asks (serverHost . getter)

-- | Access MetadataValidationService enabled
getMetadataValidationEnabled ::
(Has VVAConfig r, MonadReader r m) =>
m Bool
getMetadataValidationEnabled = asks (metadataValidationEnabled . getter)

-- | Access MetadataValidationService host
getMetadataValidationHost ::
(Has VVAConfig r, MonadReader r m) =>
Expand Down
34 changes: 20 additions & 14 deletions govtool/backend/src/VVA/Metadata.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,26 @@ validateMetadata
-> Maybe Text
-> m (Either Text Value)
validateMetadata url hash standard = do
metadataEnabled <- getMetadataValidationEnabled
metadataHost <- getMetadataValidationHost
metadataPort <- getMetadataValidationPort
manager <- asks getter
let requestBody = encode $ object (["url" .= unpack url, "hash" .= unpack hash] ++ maybe [] (\x -> ["standard" .= unpack x]) standard)
initialRequest <- liftIO $ parseRequest (unpack metadataHost <> ":" <> show metadataPort <> "/validate")
let request = initialRequest
{ method = "POST"
, requestBody = RequestBodyLBS requestBody
, requestHeaders = [("Content-Type", "application/json")]
}
response <- liftIO $ try $ httpLbs request manager
case response of
Left (e :: HttpException) -> return $ Left (pack $ show e)
Right r -> case decode $ responseBody r of
Nothing -> throwError $ InternalError "Failed to validate metadata"
Just x -> return $ Right x
case metadataEnabled of
True -> do
let requestBody = encode $ object (["url" .= unpack url, "hash" .= unpack hash] ++ maybe [] (\x -> ["standard" .= unpack x]) standard)
initialRequest <- liftIO $ parseRequest (unpack metadataHost <> ":" <> show metadataPort <> "/validate")
let request = initialRequest
{ method = "POST"
, requestBody = RequestBodyLBS requestBody
, requestHeaders = [("Content-Type", "application/json")]
}
response <- liftIO $ try $ httpLbs request manager
case response of
Left (e :: HttpException) -> return $ Left (pack $ show e)
Right r -> case decode $ responseBody r of
Nothing -> throwError $ InternalError "Failed to validate metadata"
Just x -> return $ Right x
False -> return $ Right ""

getProposalMetadataValidationResult ::
(Has ConnectionPool r, Has Manager r, Has VVAConfig r, MonadReader r m, MonadIO m, MonadFail m, MonadError AppError m) =>
Expand All @@ -67,6 +71,7 @@ getProposalMetadataValidationResult url hash = do
Right (Object r) -> case go r of
Nothing -> throwError $ InternalError "Failed to validate metadata"
Just x -> return x
Right "" -> return $ MetadataValidationResult True (Just "200") Nothing
where
go result = do
(Bool valid) <- lookup "valid" result
Expand Down Expand Up @@ -97,6 +102,7 @@ getDRepMetadataValidationResult url hash = do
Right (Object r) -> case go r of
Nothing -> throwError $ InternalError "Failed to validate metadata"
Just x -> return x
Right "" -> return $ MetadataValidationResult True (Just "200") Nothing
where
go result = do
(Bool valid) <- lookup "valid" result
Expand All @@ -110,4 +116,4 @@ getDRepMetadataValidationResult url hash = do
let email = (\(String s) -> s) <$> lookup "email" m
let references = (\(Array references') -> map (\(String x) -> x) $ toList references') <$> lookup "references" m
DRepMetadata <$> bio <*> dRepName <*> email <*> references
return $ MetadataValidationResult valid status proposalMetadata
return $ MetadataValidationResult valid status proposalMetadata
4 changes: 2 additions & 2 deletions govtool/backend/src/VVA/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ data Proposal
, proposalUrl :: Text
, proposalDocHash :: Text
, proposalTitle :: Maybe Text
, proposalAbout :: Maybe Text
, proposalMotivaiton :: Maybe Text
, proposalAbstract :: Maybe Text
, proposalMotivation :: Maybe Text
, proposalRationale :: Maybe Text
, proposalMetadata :: Maybe Value
, proposalReferences :: Maybe Value
Expand Down
2 changes: 1 addition & 1 deletion govtool/frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ARG NPMRC_TOKEN
ARG VITE_USERSNAP_SPACE_API_KEY
ARG VITE_IS_PROPOSAL_DISCUSSION_FORUM_ENABLED='false'

ENV NODE_OPTIONS=--max_old_space_size=4096
ENV NODE_OPTIONS=--max_old_space_size=8192
WORKDIR /src

# Set npm configuration settings using environment variables
Expand Down
Loading
Loading