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

[Chore] Tidy up the codebase #56

Merged
merged 10 commits into from
Jul 18, 2022
Merged

[Chore] Tidy up the codebase #56

merged 10 commits into from
Jul 18, 2022

Conversation

ken-futureverse
Copy link
Collaborator

@ken-futureverse ken-futureverse commented Jul 17, 2022

Summary

Address issue #26

Changes

  • Rename progress dialogue steps
  • Add check to allow testing the form without having DISCORD_BOT
  • Swap over to use signAndSend everywhere
  • Remove node/models in favor of serivce/mongodb
  • Migrate node/types and web/types to node/utils and web/tils respectively
  • Consolidate all env vars into one service package service/env-vars

Notes

I'm still not very happy with how the env-vars are organised but this will do for now. Would be good to have the identity/connect test again to make sure I'm not mucking anything up @aidan-starke

@vercel
Copy link

vercel bot commented Jul 17, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
app-gov ✅ Ready (Inspect) Visit Preview Jul 18, 2022 at 1:57AM (UTC)

@ken-futureverse ken-futureverse marked this pull request as ready for review July 18, 2022 00:11
@ken-futureverse ken-futureverse enabled auto-merge (squash) July 18, 2022 00:50
Copy link
Collaborator

@aidan-starke aidan-starke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Couple things,

  • Will need to update ENV vars on Vercel, NX_CENNZ_NETWORK -> CENNZ_NETWORK, or update env-vars/index to default to process.env.NX_CENNZ_NETWORK
  • Padding has gone off-center on dialog

Screen Shot 2022-07-18 at 12 29 17 PM

@ken-futureverse
Copy link
Collaborator Author

hmm to make sure everything is centre perfectly regardless of the length of the labels might require a re-think of how we layout the elements, which we don't have time for now I think. Switch back to Confirm to mitigate it

@ken-futureverse ken-futureverse merged commit 4faade1 into develop Jul 18, 2022
@ken-futureverse ken-futureverse deleted the chore/clean-up branch July 18, 2022 02:14
@ken-futureverse ken-futureverse restored the chore/clean-up branch July 19, 2022 01:23
@ken-futureverse ken-futureverse deleted the chore/clean-up branch July 19, 2022 01:24
ken-futureverse added a commit that referenced this pull request Jul 27, 2022
* [Spike] Setup `gov-relayer` app (#53)

* Add base setup for `gov-relayer` as CLI App

* Rename to `proposal-sub`

* Start putting things together for `proposal-pub`

* Add `proposal-sub` that with new proposal handler

* Add requeuing mechanic to the proposal-sub

* Fix `lastKnownId` is not updated on the next iteration

* Fix compiling error when running `gov-website` and `gov-relayer` on dev

* Add basic README details for development

* Fix build error

* Slim down the `proposal/[pid].tsx` page temporarily to get the build working

* Rename `getAMQClient` / `getMDBClient` to `getRabbitClient` and `getMongoClient`

* [Spike] Update Discord DM & error messages (#52)

* Slight improvement to error messaging

* Update discord message

* Prefer `response.text()`, fallback to `response.statusText`

* [Chore] Tidy up the codebase (#56)

* Rename the progress dialog steps

* Add check to allow testing the form without having `DISCORD_BOT` defined

* Rename to `signAndSend`

* Use the new `signAndSend` impl across

* Remove `node/models` in favor of `service/mongodb`

* Migrate `node/types` to `node/utils`

* Migrate `web/types` to `web/utils`

* Consolidate all env vars into one service `service/env-vars`

* [Hotfix] Wrap error message (#55)

* Use `prose` so error text wraps nicely

* Apply `prose` to `ProposalNewFormDialog` error message

* [Spike] Add proposal activities monitor (#57)

* Add `status` as part of the `fetchProposalInfo`

* Rename to `gov-relayer:webpack`

* Update `waitForBlock` to avoid ignoring the `no-async-promise-executor` rule

* Remove the AbortController to make the code looks cleaner with async / await

* Add `monitorProposalActivity` to publish `proposal-activity` message

* Add `handleProposalActivityMessage` to update Deliberation votes

* Add handler for `ReferendumDeliberation` status

* [Spike] Add a placeholder for resolving justification content (#58)

* Add function to resolve justification content from the Uri

* Add comment block

* Add `safeFetch` method

* Remove the `npm-run-all` as dependency for runtime (#64)

Remove the `npm-run-all` as dependency for for runtime

* [Spike] Re-style Proposal Single page (#62)

* Add `ProposalBody` component and add it to single page view

* Add `ProposalSidebar`

* Simplify the submit button label

* Add `ProposalVoteForm`

* Chang FormState.step to `Sign`

* Add `useProposalVoteForm`

* Add `ProposalVoteFormDialog`

* Fix `AccountSelect` doesn't select the initial value

* Ensure form is validated before submit the action

* Remove `ProposalDetailsDisplay`

* Add `votePercentage` and have it synced in the DB

* Add `VotesInfo` to `ProposalSidebar`

* Add `VetoInfo`

* Round up the percentage number

* Use `BLOCK_POLLING_INTERVAL` to control the refreshing rate

* Make adjustment for smaller viewport

* [Fix] Make `resolveProposalJustification` safer with white-listing domains (#66)

* [Fix] Remove the `rejectVotes` out of `votePercentage` calculation (#67)

* [Spike] Send proposals & referendums to Discord (#60)

* Update `env.skel`, tidy up

* Port over `getDiscordWebhook` from `gov-services`

* Pass `discordWebhook` to `handleProposalActivityMessage`

* Port over `getDiscordMessage` from `gov-services`

* Update `getDiscordMessage` to work for both Proposals & Referendums

* Fetch discord webhook for each channel

* Fix logic to pick which `voteFields` are used

* Update `DISCORD_RELAYER_BOT` const

* Update `ProposalModel`

* Fetch discord webhooks and pass to `handleProposalActivityMessage`

* Update Discord with votes & status

* Prettier format

* Refactor

* Use `resolveProposalJustification`, resolve circular dependencies

* Fix build error

* Avoid build fail from bad `justificationUri`

* Improve typing for `getDiscordWebhooks`

* Refactor sidebar colours, only display `proposalDetails` if they can be fetched successfully

* Rename `service/relayer/utils` -> `service/relayer/src`

* Update imports

* Refactor `getProposalFields`

* Prettier format

* Temporary fix for `ipfs//` causing `HTTP/400` error and failing build

* Fix pinata gateway

* Ensure all necessary data is being passed to `getDiscordMessage`

* Fetch veto threshold

* Pass vote info in case of no change to avoid sending `undefined` to Discord

* Display votes as a percentage

* Avoid updating Discord message ids with empty string

* Get `discordWebhooks` once

* Revert to `while` loop

* Fix typo

* Get different discord message per channel

* Prettier format

* Refactor / tidy up

* Refactor `getProposalEmbed`, `getVoteButton`

* Regenerate `service-discord` package using `@nrwl/js`

* Only log if update found

* Regenerate `service-relayer` library with `@nrwl/js`

* Move `DISCORD_` vars to `//DISCORD` partition

* Move `assignDiscordRole` to `service-discord`

* Check for & reject on `getDiscordBot` error

* Update `getDiscordWebhooks` to accept arrays of channel & webhook ids

* [Hotfix] Add `discord.js` to `gov-relayer#dependencies` (#69)

Add `discord.js` to `gov-relayer#dependencies`

* [Spike] Proposal updates (#70)

* Extract `getHourInBlocks` to `node-utils`

* Add `48 hours` option for `enactmentDelay`

* Display `enactmentDelayInHours` on Discord

* Add `github.com` into the `justificationUri` white list

* Allow certain extrinsics, allow extrinsics that don't require args

* Refactor `getProposalFields`

* Update `service-relayer` tsconfig

* Remove vote button if proposal is not in voting stage

* Add `Pending` colour for `ApprovedWaitingEnactment` stage

* Refactor `transformFormData`

* Display `enactmentDelayInHours` for Proposal single view

* [Spike] Omit `system.setCode` args (#75)

* Catch error when decoding `setCode` proposal call and define `args` as omitted

* Use `toFixed` to round `enactmentDelayInHours` for cases where proposal is submitted through portal

* Refactor `call` catch block

* Omit args if none, or if `omitted` i.e. for `system.setCode`

* Display `omitted` args

* Update libs/service/cennznet/src/fetchProposalInfo.ts

Co-authored-by: Ken Vu <[email protected]>

* Round `enactmentDelayInHours` with `toFixed`

Co-authored-by: Ken Vu <[email protected]>

* [Hotfix] Avoid property `justificationUri` is undefined error (#77)

* Avoid property `justificationUri` is undefined error

* Return early if no `justificationUri`

* [Fix] Relayer performance issue (#78)

* Avoid requeue messages for `proposal-activity` type

Since we have to loop through all proposals and check for updates in every 2 blocks anyway

* Always create a record first to avoid the same proposal is being processed again

* Fix spacing for `update Discord` message

* [Fix] Add extra guard to ignore proposals that doesn't have `status` (#80)

Add extra guard to ignore building any proposals that doesn't have `status`

* [Fix] Add `health check` log (#81)

Add `health check` log

* [Fix] Styling updates (#84)

* Soften the shadow colors on Button and Dialog

* Add `favicon`

* Add the default meta description

* [Fix] API `autoConnect` (#83)

Add a regular check to make sure api is connected, if not throw error

* [Spike] Proposal changes (#85)

* Reduce revalidation time to 5 minutes

* Update default function call

* Hide `Arguments` section if function call has no arguments

* [Spike] Throw `create type` error if not handled (#86)

Throw `create type` error if not handled

* [Fix] Inactive proposal causes app to crash (#88)

* Prevent page crash on inactive proposal

* Redirect user to `proposal/new` if their vote causes proposal to end

* Fix build error

* Add console warning on failure to format `call`

* Inform user they will be redirected and why

* Return early if `call` is empty

* Revert "Redirect user to `proposal/new` if their vote causes proposal to end"

This reverts commit 45a84fa.

* Don't refetch proposal info if proposal is finalized

* Revert "Inform user they will be redirected and why"

* [Spike] Use `safeFetch` across code base (#79)

Use `safeFetch` across the repo

* Add a `proposal-patch <start> <end>` command to patch up DB (#91)

* [Spike] Proposal copy & link updates (#92)

* Update proposal submission copy

* Link directly to appropriate channel after voting

* Update env vars

* Revert change to `DISCORD_RELAYER_CHANNEL_IDS`

* Prettier format

* [Spike] Refactor discord messaging (#93)

Extract discord messaging to own function

* [Chore] Setup GitHub actions (#94)

* Add workflow when submit a PR

* Fix lint issues

* Reset version in `develop` branch

* Add `nrwl/nx-set-shas` to make `yarn nx affected` work

* Bump to version `v1.1.0`

Co-authored-by: Aidan Starke <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants