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

Enhancements and Fixes: Documentation Updates, Pending Transaction Logic, and Governance Action Details #563

Merged
merged 26 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
90df4b8
[#543] Update frontend package readme
MSzalowski Mar 25, 2024
bb26945
[#522] fix bugs in usePendingTransaction
j-dyczka Mar 25, 2024
55a0f24
Merge pull request #544 from IntersectMBO/docs/543-update-readme-of-a…
MSzalowski Mar 26, 2024
a189d87
[#512] fix ts and eslint errors in wallet
j-dyczka Mar 25, 2024
28d782c
[#522] fix pending transaction expiration logic
j-dyczka Mar 26, 2024
bc5665d
Merge pull request #553 from IntersectMBO/transaction-state
jdyczka Mar 26, 2024
6d59394
[#522] fix reading pending transaction from localStorage
j-dyczka Mar 26, 2024
221318e
introduce stack
jankun4 Mar 25, 2024
7c54758
[#372] provide governance action details for TreasuryWithdrawals
jankun4 Mar 25, 2024
2dd1bee
[#372] update changelog
jankun4 Mar 25, 2024
e4d4b81
New Gov Actions
JanJaroszczak Mar 4, 2024
4719277
Lint fixes
JanJaroszczak Mar 23, 2024
2aa8b89
Further changes
JanJaroszczak Mar 24, 2024
de9dffb
Fixes after CR
JanJaroszczak Mar 25, 2024
2f64bf1
Filter and sort dropdowns fixes
JanJaroszczak Mar 25, 2024
2512248
Merge pull request #525 from IntersectMBO/gov-actions-new
JanJaroszczak Mar 26, 2024
d7c3494
add logic to handle drep metadata
Sworzen1 Mar 22, 2024
902d4a5
metadata creation for DRep registration
Sworzen1 Mar 25, 2024
c62334f
lint fixes
Sworzen1 Mar 25, 2024
0798723
add to changelog
Sworzen1 Mar 26, 2024
fa6c777
eslint fix
Sworzen1 Mar 26, 2024
354b539
add errors into render linds dependencies
Sworzen1 Mar 26, 2024
d398f1c
Merge pull request #551 from IntersectMBO/feat/new-drep-registration-…
Sworzen1 Mar 26, 2024
16aae05
[#550] new retire as drep flow
Sworzen1 Mar 25, 2024
a508b5c
Merge pull request #552 from IntersectMBO/feat/new-drep-retirement
Sworzen1 Mar 26, 2024
aa63ed7
update backend config
jankun4 Mar 26, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ local/

# used by haskell
govtool/backend/dist-newstyle/
govtool/backend/.stack-work/

# target environment config dir
scripts/govtool/config/target
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ changes.

## [Unreleased]

- DRep metadata builder [Issue 497](https://github.com/IntersectMBO/govtool/issues/497)
- Update Cardano Serialization Lib to 12.0.0-alpha.19 [Issue 521](https://github.com/IntersectMBO/govtool/issues/521)
- Add generate jsonld function [Issue 451](https://github.com/IntersectMBO/govtool/issues/451)
- Create GA review subbmision page [Issue 362](https://github.com/IntersectMBO/govtool/issues/362)
Expand All @@ -26,6 +27,7 @@ changes.
- Fix all the existing eslint errors [Issue 514](https://github.com/IntersectMBO/govtool/issues/514)
- Fix all the existing typescript errors [Issue 514](https://github.com/IntersectMBO/govtool/issues/514)
- Fix endless spinner on a dashboard [Issue 539](https://github.com/IntersectMBO/govtool/issues/539)
- Update frontend package readme to reflect recent changes [Issue 543](https://github.com/IntersectMBO/govtool/issues/543)

### Added

Expand Down Expand Up @@ -59,6 +61,8 @@ changes.

### Changed

- `proposal/list` returns additional data such ass `expiryEpochNo`, `createdEpochNo`, `title`, `about`, `motivation`,
`rationale`. `TreasuryWithdrawals` GAs also got nicely formated details. [Issue 372](https://github.com/IntersectMBO/govtool/issues/372)
- `drep/list` now return also `status` and `type` fields. Also it now returns the retired dreps, and you can search for given drep by name using optional query parameter. If the drep name is passed exactly, then you can even find a drep that's sole voter. [Issue 446](https://github.com/IntersectMBO/govtool/issues/446)
- `drep/list` and `drep/info` endpoints now return additional data such as metadata url and hash, and voting power [Issue 223](https://github.com/IntersectMBO/govtool/issues/223)
- `drep/info` now does not return sole voters (dreps without metadata) [Issue 317](https://github.com/IntersectMBO/govtool/issues/317)
Expand Down
2 changes: 1 addition & 1 deletion govtool/backend/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# is a common practice in Haskell projects, as it can significantly reduce the
# time it takes to build the project.

FROM haskell:9.2-buster
FROM haskell:9.2.7-buster
WORKDIR /src
COPY . .
RUN cabal update && cabal configure && cabal install --only-dependencies && rm -rf /src/*
6 changes: 4 additions & 2 deletions govtool/backend/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ import Data.Monoid (mempty)
import qualified Data.Cache as Cache
import VVA.API.Types
import System.Clock (TimeSpec(TimeSpec))
import Data.Pool (newPool, defaultPoolConfig)
import Data.Pool (createPool)
import Database.PostgreSQL.Simple (connectPostgreSQL, close)
import Data.Text.Encoding (encodeUtf8)
import Data.Has (getter)
Expand Down Expand Up @@ -138,7 +138,7 @@ startApp vvaConfig = do
, dRepListCache
, networkMetricsCache
}
connectionPool <- newPool $ defaultPoolConfig (connectPostgreSQL (encodeUtf8 (dbSyncConnectionString $ getter vvaConfig))) close 1 60
connectionPool <- createPool (connectPostgreSQL (encodeUtf8 (dbSyncConnectionString $ getter vvaConfig))) close 1 1 60

let appEnv = AppEnv {vvaConfig=vvaConfig, vvaCache=cacheEnv, vvaConnectionPool=connectionPool}
server' <- mkVVAServer appEnv
Expand All @@ -161,6 +161,8 @@ exceptionHandler vvaConfig mRequest exception = do
(formatMessage mRequest exception)
(recordUpdate 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
Expand Down
32 changes: 30 additions & 2 deletions govtool/backend/sql/list-proposals.sql
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,27 @@ SELECT
encode(creator_tx.hash, 'hex'),
gov_action_proposal.index,
gov_action_proposal.type::text,
gov_action_proposal.description::json,
(
case when gov_action_proposal.type = 'TreasuryWithdrawals' then
json_build_object('Reward Address', stake_address.view, 'Amount', treasury_withdrawal.amount)

when gov_action_proposal.type::text = 'InfoAction' then
json_build_object()
else
null
end
) as description,
epoch_utils.last_epoch_end_time + epoch_utils.epoch_duration *(gov_action_proposal.expiration - epoch_utils.last_epoch_no),
gov_action_proposal.expiration,
creator_block.time,
creator_block.epoch_no,
/* 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,
coalesce(Sum(ldd.amount) FILTER (WHERE voting_procedure.vote::text = 'Yes'), 0) +(
CASE WHEN gov_action_proposal.type = 'NoConfidence' THEN
always_no_confidence_voting_power.amount
Expand All @@ -59,12 +74,18 @@ SELECT
coalesce(Sum(ldd.amount) FILTER (WHERE voting_procedure.vote::text = 'Abstain'), 0) + always_abstain_voting_power.amount "abstain_votes"
FROM
gov_action_proposal
LEFT JOIN treasury_withdrawal
on gov_action_proposal.id = treasury_withdrawal.gov_action_proposal_id
LEFT JOIN stake_address
on stake_address.id = treasury_withdrawal.stake_address_id

CROSS JOIN EpochUtils AS epoch_utils
CROSS JOIN always_no_confidence_voting_power
CROSS JOIN always_abstain_voting_power
JOIN tx AS creator_tx ON creator_tx.id = gov_action_proposal.tx_id
JOIN block AS creator_block ON creator_block.id = creator_tx.block_id
JOIN voting_anchor ON voting_anchor.id = gov_action_proposal.voting_anchor_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 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 @@ -81,6 +102,13 @@ AND gov_action_proposal.expired_epoch IS NULL
AND gov_action_proposal.dropped_epoch IS NULL
GROUP BY
(gov_action_proposal.id,
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,
gov_action_proposal.index,
creator_tx.hash,
creator_block.time,
Expand Down
8 changes: 7 additions & 1 deletion govtool/backend/src/VVA/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,17 @@ proposalToResponse Types.Proposal {..} =
proposalResponseTxHash = HexText proposalTxHash,
proposalResponseIndex = proposalIndex,
proposalResponseType = fromMaybe InfoAction $ readMaybe $ unpack proposalType,
proposalResponseDetails = GovernanceActionDetails proposalDetails,
proposalResponseDetails = GovernanceActionDetails <$> proposalDetails,
proposalResponseExpiryDate = proposalExpiryDate,
proposalResponseExpiryEpochNo = proposalExpiryEpochNo,
proposalResponseCreatedDate = proposalCreatedDate,
proposalResponseCreatedEpochNo = proposalCreatedEpochNo,
proposalResponseUrl = proposalUrl,
proposalResponseMetadataHash = HexText proposalDocHash,
proposalResponseTitle = proposalTitle,
proposalResponseAbout = proposalAbout,
proposalResponseMotivation = proposalMotivaiton,
proposalResponseRationale = proposalRationale,
proposalResponseYesVotes = proposalYesVotes,
proposalResponseNoVotes = proposalNoVotes,
proposalResponseAbstainVotes = proposalAbstainVotes
Expand Down
14 changes: 13 additions & 1 deletion govtool/backend/src/VVA/API/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,17 @@ data ProposalResponse = ProposalResponse
proposalResponseTxHash :: HexText,
proposalResponseIndex :: Integer,
proposalResponseType :: GovernanceActionType,
proposalResponseDetails :: GovernanceActionDetails,
proposalResponseDetails :: Maybe GovernanceActionDetails,
proposalResponseExpiryDate :: Maybe UTCTime,
proposalResponseExpiryEpochNo :: Maybe Integer,
proposalResponseCreatedDate :: UTCTime,
proposalResponseCreatedEpochNo :: Integer,
proposalResponseUrl :: Text,
proposalResponseMetadataHash :: HexText,
proposalResponseTitle :: Maybe Text,
proposalResponseAbout :: Maybe Text,
proposalResponseMotivation :: Maybe Text,
proposalResponseRationale :: Maybe Text,
proposalResponseYesVotes :: Integer,
proposalResponseNoVotes :: Integer,
proposalResponseAbstainVotes :: Integer
Expand All @@ -258,9 +264,15 @@ exampleProposalResponse = "{ \"id\": \"proposalId123\","
<> "\"type\": \"InfoAction\","
<> "\"details\": \"some details\","
<> "\"expiryDate\": \"1970-01-01T00:00:00Z\","
<> "\"expiryEpochNo\": 0,"
<> "\"createdDate\": \"1970-01-01T00:00:00Z\","
<> "\"createdEpochNo\": 0,"
<> "\"url\": \"https://proposal.metadata.xyz\","
<> "\"metadataHash\": \"9af10e89979e51b8cdc827c963124a1ef4920d1253eef34a1d5cfe76438e3f11\","
<> "\"title\": \"Proposal Title\","
<> "\"about\": \"Proposal About\","
<> "\"motivation\": \"Proposal Motivation\","
<> "\"rationale\": \"Proposal Rationale\","
<> "\"yesVotes\": 0,"
<> "\"noVotes\": 0,"
<> "\"abstainVotes\": 0}"
Expand Down
45 changes: 42 additions & 3 deletions govtool/backend/src/VVA/Proposal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ import VVA.Pool (ConnectionPool, withPool)
import Control.Exception (throw)
import VVA.Types (Proposal(..), AppError(..))

import Data.Aeson
import Data.Aeson.Types (parseMaybe, Parser)
import Data.Text (Text)

sqlFrom :: ByteString -> SQL.Query
sqlFrom bs = fromString $ unpack $ Text.decodeUtf8 bs
Expand Down Expand Up @@ -67,10 +70,46 @@ getProposals mProposalIds = withPool $ \conn -> do

timeZone <- liftIO getCurrentTimeZone
return $ map
( \(id', txHash', index', type', details', expiryDate', createdDate', url', docHash', yesVotes', noVotes', abstainVotes') ->
( \( id'
, txHash'
, index'
, type'
, details'
, expiryDate'
, expiryEpochNo'
, createdDate'
, createdEpochNo'
, url'
, docHash'
, title'
, about'
, motivation'
, rationale'
, yesVotes'
, noVotes'
, abstainVotes'
) ->
let eDate = localTimeToUTC timeZone <$> expiryDate'
cDate = localTimeToUTC timeZone createdDate'
in
Proposal id' txHash' (floor @Scientific index') type' details' eDate cDate url' docHash' (floor @Scientific yesVotes') (floor @Scientific noVotes') (floor @Scientific abstainVotes')
Proposal
id'
txHash'
(floor @Scientific index')
type'
details'
eDate
expiryEpochNo'
cDate
createdEpochNo'
url'
docHash'
title'
about'
motivation'
rationale'
(floor @Scientific yesVotes')
(floor @Scientific noVotes')
(floor @Scientific abstainVotes')
)
proposalResults
proposalResults
8 changes: 7 additions & 1 deletion govtool/backend/src/VVA/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,17 @@ data Proposal = Proposal
proposalTxHash :: Text,
proposalIndex :: Integer,
proposalType :: Text,
proposalDetails :: Value,
proposalDetails :: Maybe Value,
proposalExpiryDate :: Maybe UTCTime,
proposalExpiryEpochNo :: Maybe Integer,
proposalCreatedDate :: UTCTime,
proposalCreatedEpochNo :: Integer,
proposalUrl :: Text,
proposalDocHash :: Text,
proposalTitle :: Maybe Text,
proposalAbout :: Maybe Text,
proposalMotivaiton :: Maybe Text,
proposalRationale :: Maybe Text,
proposalYesVotes :: Integer,
proposalNoVotes :: Integer,
proposalAbstainVotes :: Integer
Expand Down
6 changes: 6 additions & 0 deletions govtool/backend/stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resolver: lts-20.24
packages:
- .

extra-deps:
- raven-haskell-0.1.4.1@sha256:9187272adc064197528645b5ad9b89163b668f386f34016d97fa646d5c790784
19 changes: 19 additions & 0 deletions govtool/backend/stack.yaml.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This file was autogenerated by Stack.
# You should not edit this file by hand.
# For more information, please see the documentation at:
# https://docs.haskellstack.org/en/stable/lock_files

packages:
- completed:
hackage: raven-haskell-0.1.4.1@sha256:9187272adc064197528645b5ad9b89163b668f386f34016d97fa646d5c790784,1479
pantry-tree:
sha256: e8f14bfed6b055dc95933257441ba97d3d779cbe08a0e82c3c2dff5d69c8c48f
size: 632
original:
hackage: raven-haskell-0.1.4.1@sha256:9187272adc064197528645b5ad9b89163b668f386f34016d97fa646d5c790784
snapshots:
- completed:
sha256: e019cd29e3f7f9dbad500225829a3f7a50f73c674614f2f452e21bb8bf5d99ea
size: 650253
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/20/24.yaml
original: lts-20.24
7 changes: 5 additions & 2 deletions govtool/backend/vva-be.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ executable vva-be
, lens
, cache
, clock
, resource-pool >= 0.4.0.0
, resource-pool
, postgresql-simple
, data-has
, raven-haskell >= 0.1.4.1
, bytestring
, http-client
, http-client-tls
, raven-haskell >= 0.1.4.1

hs-source-dirs: app
default-language: Haskell2010
Expand Down Expand Up @@ -97,6 +99,7 @@ library
, resource-pool
, swagger2


exposed-modules: VVA.Config
, VVA.CommandLine
, VVA.API
Expand Down
1 change: 1 addition & 0 deletions govtool/frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ module.exports = {
"operator-linebreak": "off",
"implicit-arrow-linebreak": "off",
"consistent-return": "off",
"no-console": ["error", { allow: ["warn", "error"] }],
"no-shadow": "off",
"function-paren-newline": "off",
"object-curly-newline": "off",
Expand Down
Loading
Loading