Skip to content

Commit

Permalink
Merge pull request #1441 from IntersectMBO/test
Browse files Browse the repository at this point in the history
chore: bump @intersect.mbo/[email protected]
  • Loading branch information
MSzalowski authored Jun 26, 2024
2 parents ea489a1 + a6d4125 commit 1e8b49e
Show file tree
Hide file tree
Showing 73 changed files with 2,572 additions and 5,518 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_storybook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Install Playwright
run: npx playwright install --with-deps
- name: Build Storybook
run: NODE_OPTIONS="--max-old-space-size=8046" npm run build-storybook --quiet
run: NODE_OPTIONS="--max-old-space-size=8046" npm run build:storybook --quiet
- name: Serve Storybook and run tests
run: |
npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ changes.

## [Unreleased]

- 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)
Expand Down Expand Up @@ -65,9 +66,14 @@ changes.
- Add PDF pillar [Issue 1090](https://github.com/IntersectMBO/govtool/issues/1090)
- 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)

### Fixed

- silenced `Thread killed by timeout manager` sentry log [Issue 1417](https://github.com/IntersectMBO/govtool/issues/1417)
- silenced `Warp: Client closed connection prematurely` error [Issue 1422](https://github.com/IntersectMBO/govtool/issues/1422)
- backend is now compiled with -threaded [Issue 1148](https://github.com/IntersectMBO/govtool/issues/1148)
- drep/get-voting-power no longer throws 500 for non-existing dreps. Instead it returns 0 [Issue 1093](https://github.com/IntersectMBO/govtool/issues/1093)
- proposal/list no longer throws 500 error when proposal's url is incorrect [Issue 1073](https://github.com/IntersectMBO/govtool/issues/1073)
- drep/list sql fix (now the drep type is correct) [Issue 957](https://github.com/IntersectMBO/govtool/issues/957)
- drep/list sql fix (now the latest tx date is correct) [Issue 826](https://github.com/IntersectMBO/govtool/issues/826)
Expand Down Expand Up @@ -99,6 +105,7 @@ changes.
- Fix validation of the GAs with missing references [Issue 1282](https://github.com/IntersectMBO/govtool/issues/1282)
- Fix displaying the GA Markdowns [Issue 1244](https://github.com/IntersectMBO/govtool/issues/1244)
- 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)

### Changed

Expand Down Expand Up @@ -131,6 +138,7 @@ changes.
- Changed documents to prepare for open source [Issue 737](https://github.com/IntersectMBO/govtool/issues/737)
- 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)

### Removed

Expand Down
43 changes: 43 additions & 0 deletions docs/GOVERNANCE_ACTION_SUBMISSION.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,46 @@ await buildSignSubmitConwayCertTx({
### Step 6: Verify the Governance Action

`buildSignSubmitConwayCertTx` logs the transaction CBOR making it able to be tracked on the transactions tools such as cexplorer.

## Additional steps for using the GovTool metadata validation on the imported Pillar component

```tsx
enum MetadataValidationStatus {
URL_NOT_FOUND = "URL_NOT_FOUND",
INVALID_JSONLD = "INVALID_JSONLD",
INVALID_HASH = "INVALID_HASH",
INCORRECT_FORMAT = "INCORRECT_FORMAT",
}
// Using the props passed to the component
type Props = {
validateMetadata: ({
url,
hash,
standard,
}: {
url: string;
hash: string;
standard: "CIP108";
}) => Promise<{
metadata?: any;
status?: MetadataValidationStatus;
valid: boolean;
}>;
};

import React, { Suspense } from "react";

const SomeImportedPillar: React.FC<Props> = React.lazy(
() => import("path/to/SomeImportedPillar")
);

const SomeWrapperComponent = () => {
const { validateMetadata } = useValidateMutation();

return (
<Suspense fallback={<div>I am lazy loading...</div>}>
<SomeImportedPillar validateMetadata={validateMetadata} />
</Suspense>
);
};
```
14 changes: 9 additions & 5 deletions govtool/backend/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ exceptionHandler :: VVAConfig -> Maybe Request -> SomeException -> IO ()
exceptionHandler vvaConfig mRequest exception = do
print mRequest
print exception
guard (show exception /= "Thread killed by timeout manager")
guard (show exception /= "Warp: Client closed connection prematurely")
let env = sentryEnv vvaConfig
sentryService <-
initRaven
(sentryDSN vvaConfig)
Expand All @@ -154,20 +157,21 @@ exceptionHandler vvaConfig mRequest exception = do
"vva.be"
Error
(formatMessage mRequest exception)
(recordUpdate mRequest exception)
(recordUpdate env mRequest exception)



formatMessage :: Maybe Request -> SomeException -> String
formatMessage Nothing exception = "Exception before request could be parsed: " ++ show exception
formatMessage (Just request) exception = "Exception " ++ show exception ++ " while handling request " ++ show request

recordUpdate :: Maybe Request -> SomeException -> SentryRecord -> SentryRecord
recordUpdate Nothing exception record = record
recordUpdate (Just request) exception record =
recordUpdate :: String -> Maybe Request -> SomeException -> SentryRecord -> SentryRecord
recordUpdate env Nothing exception record = record { srEnvironment = Just env }
recordUpdate env (Just request) exception record =
record
{ srCulprit = Just $ unpack $ rawPathInfo request,
srServerName = unpack <$> requestHeaderHost request
srServerName = unpack <$> requestHeaderHost request,
srEnvironment = Just env
}

shouldDisplayException :: SomeException -> Bool
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 @@ -10,6 +10,7 @@
"host" : "localhost",
"cachedurationseconds": 20,
"sentrydsn": "https://username:[email protected]/id",
"sentryenv": "dev",
"metadatavalidationhost": "localhost",
"metadatavalidationport": 3001,
"metadatavalidationmaxconcurrentrequests": 10
Expand Down
6 changes: 6 additions & 0 deletions govtool/backend/src/VVA/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ data VVAConfigInternal
, vVaConfigInternalCacheDurationSeconds :: Int
-- | Sentry DSN
, vVAConfigInternalSentrydsn :: String
-- | Sentry environment
, vVAConfigInternalSentryEnv :: String
-- | Metadata validation service host
, vVAConfigInternalMetadataValidationHost :: Text
-- | Metadata validation service port
Expand All @@ -97,6 +99,7 @@ instance DefaultConfig VVAConfigInternal where
vVAConfigInternalHost = "localhost",
vVaConfigInternalCacheDurationSeconds = 20,
vVAConfigInternalSentrydsn = "https://username:[email protected]/id",
vVAConfigInternalSentryEnv = "development",
vVAConfigInternalMetadataValidationHost = "localhost",
vVAConfigInternalMetadataValidationPort = 3001,
vVAConfigInternalMetadataValidationMaxConcurrentRequests = 10
Expand All @@ -115,6 +118,8 @@ data VVAConfig
, cacheDurationSeconds :: Int
-- | Sentry DSN
, sentryDSN :: String
-- | Sentry environment
, sentryEnv :: String
-- | Metadata validation service host
, metadataValidationHost :: Text
-- | Metadata validation service port
Expand Down Expand Up @@ -161,6 +166,7 @@ convertConfig VVAConfigInternal {..} =
serverHost = vVAConfigInternalHost,
cacheDurationSeconds = vVaConfigInternalCacheDurationSeconds,
sentryDSN = vVAConfigInternalSentrydsn,
sentryEnv = vVAConfigInternalSentryEnv,
metadataValidationHost = vVAConfigInternalMetadataValidationHost,
metadataValidationPort = vVAConfigInternalMetadataValidationPort,
metadataValidationMaxConcurrentRequests = vVAConfigInternalMetadataValidationMaxConcurrentRequests
Expand Down
6 changes: 4 additions & 2 deletions govtool/backend/src/VVA/DRep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ getVotingPower ::
Text ->
m Integer
getVotingPower drepId = withPool $ \conn -> do
[SQL.Only votingPower] <-
result <-
liftIO
(SQL.query @_ @(SQL.Only Scientific) conn getVotingPowerSql $ SQL.Only drepId)
return $ floor votingPower
case result of
[SQL.Only votingPower] -> return $ floor votingPower
[] -> return 0

listDRepsSql :: SQL.Query
listDRepsSql = sqlFrom $(embedFile "sql/list-dreps.sql")
Expand Down
2 changes: 2 additions & 0 deletions govtool/backend/vva-be.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ executable vva-be

hs-source-dirs: app
default-language: Haskell2010
ghc-options: -threaded

library
hs-source-dirs: src
Expand Down Expand Up @@ -118,3 +119,4 @@ library
, VVA.Types
, VVA.Network
, VVA.Metadata
ghc-options: -threaded
Loading

0 comments on commit 1e8b49e

Please sign in to comment.