Skip to content

Commit

Permalink
Hector.vote snapshot proposal (#1226)
Browse files Browse the repository at this point in the history
* update snapshot proposal page

* create snpashot proposal workflow

* update UI

* utilize snapshot js

* add snapshot create proposal

* add sushi token for testing purpose

* correct wrong code

* complete creating snapshot proposal

* Handle proposals missing Passed and Executed events

* Add debug trace when Substrate proposals fail to load

* Show missing PROP/MOTs

* Reduce data passed in bulkEntities

* Include chain entities on getThread

* Remove extra sanitize pass

* Ensure treasury proposals are always created

* Add missing data tag for tres proposals

* Adjust mobile header

* Enforce DISTINCT when query for collaborators and chain entities with ARRAY_AGG

* Minor copy

* Integrate github actions. (#1219)

* Migrate CI to github actions.

* Add NO_CLIENT env for test suite.

* Map postgres port to localhost.

* Offchain Community Creation (site-admin only) (#1204)

* create an offchain community(site admin only)

* Remove commented code

* Route to the newly created community

Co-authored-by: zakhap <zhs2104@columbia.edu>

* update manage community form

* Fixed README.md to properly display instructions (#1215)

* fixed README.md to properly display instructions

* fixed connect address instructions using substrate cmd line

* Remove token balance requirement for creating threads (#1220)

* remove token balance requirement

* allow commenting as well

* Fix createReaction and remove dead code.

Co-authored-by: Maxwell Foley <maxwell.foley@certik.org>
Co-authored-by: Jake Naviasky <jake@commonwealth.im>

* Skip token holder test cases.

* add confirm vote modal

* Fix hydradx spec and disable bounties page.

* add snapshot util functions for voting

* Fix completion hack in referendum.

* Invite Flow Fixes, Stage 1 (#1212)

* Add invite count pip

* Reinit app on private community invite acceptance

* Remove logs, remove svg work

* Conditionally close modal if no remaining invites

* Refactor Community Options Popover (#1214)

* Small Invite Flow Bug Fixes (#1213)

* small bugs for invite flow

* Get Invite Link Section updated

* button label update

* add strategies from snapshot.js to fix ts errors

* remove warnings

* Add underline to Quill Editor links

* Fix Comma/Semicolon Bug (#1224)

* Serve Substrate specs from DB. (#1223)

* Store substrate specs in db.

* Add spec_settings page.

* Remove plasm switch in substrate controller.

* Attempt CSS.

* style update

* Permit community admin to edit spec and QA.

Co-authored-by: James Truong <jamestruong.consult@gmail.com>

* complete voting

* utilize snapshotjs npm package

* fix linting test

* test linting

* fix lint error and update code

* Tips UI (#1221)

* Remove puppeteer.

* Add tip controllers.

* Add tentative view.

* Comment out tx success callbacks.

* tips ui integration first pass

* tips ui done

* changed tip value from sum to median

* changed tip value display style to match design

* Bump CW version and fix migrations.

* fix responsive design issue, show contribute only for council members and tip reason in listing page

* minor styling change

* Fix tip view page error.

Co-authored-by: Jake Naviasky <jake@commonwealth.im>
Co-authored-by: zakhap <zhs2104@columbia.edu>

* Added Google Tag Manager Script (#1233)

* Offchain Polls v2 (#1240)

* motions wip

* sidebar wip

* sidebar modules

* hierarchical sidebar

* move poll, style revs

* Add offchain voting options json blob to backend

* offchain vote options

* Add form, update JSON field names, revs on poll creation flow

* Bug fixes and styling

* More bugs and style fixes

* Hide motions for now

* Minor fixes: Update copy for offchain communities, update styling

* Minor fixes: topic selector dropdown arrow

* Fix allowNull requirement for threads

* Update user address styling

* Adjust discussion row tag styling

* Fix responsive new thread form, mobile header glitch

* Fix notifications menu overflow text

* Use formatter on notification rows

* Reset app.chain when chain initialization was aborted, to prevent infinite spinner race condition

* Manage community modal styling

* Tips "Reason" fix (#1242)

* tips reason fix: commonwealth links open in the same tab

* changes based on Zak's review

* update getVotes from snapshot.js

* Optimization: Load bulkOffchain in parallel with proposal comments and chain entities (#1243)

* Bump typescript dependency version.

* fix ajv issue

* Remove global and cleanup lint and add redraw.

* Lint fixes.

* Add another demo community

* Add new snapshot space id to fei

* Add voting buffer style

* Fix voter addresses to be User objects and the snapshot author to be User object with link

* Fix header spacing issues

* Unlink the Created and Updated at metadata, date calculation still wrong

* Add spinner while proposals load from snapshot api

* Make the proposal form look nicer, oddly thin?, removed the weird date-pickers.

* Remove evidence of DatePicker from form

* Add spinner for when callout is loading on new proposal form

* Add margin to the bottom of voting actions so they don't touch the bottom

* Add comment on VotingAction buttons where they're hardcoded to always be clickable.

* Comment out SnapshotProposalStagesBar because it has no logic to do anything and the proposal rows do not have attributes for filtering yet.

* Add fei.eth back to migration

* Fix ending/ended ago bug

* Add 'in' to timestamp interpretation

* resetServer.ts demos community, broken

* Add generic snapshot adapter and use it for all snapshot communities

* Add demo community to migration and ChainNetwork, probably wrong contract address on chainnode"

* Add demo to down migration and add TEST token contract to node

* Make hub.snapshot default, add demo community.

* Default apollo to hub.snapshot as well

* Add demo to address model

* The changes to run the demo, not generalized

* Make snapshot pages mobile friendly

* add snapshot filtering

* Clean up proposal listing UI

* UI tweaks for snapshot proposal pages

* Catch voting errors

* Switch off oninit lifecycle; move submit proposal button to new proposal button

Co-authored-by: Raymond Zhong <raykyri@gmail.com>
Co-authored-by: Jake Naviasky <jake@commonwealth.im>
Co-authored-by: rakeshup <parthiban.rakesh95@gmail.com>
Co-authored-by: zakhap <zhs2104@columbia.edu>
Co-authored-by: Timothee Legros <62490329+timolegros@users.noreply.github.com>
Co-authored-by: maxwellfoley3 <maxwellsfoley@gmail.com>
Co-authored-by: Maxwell Foley <maxwell.foley@certik.org>
Co-authored-by: gdjohnson <graham@commonwealth.im>
Co-authored-by: true-eye <jamestruong.consult@gmail.com>
Co-authored-by: Raymond Zhong <raykyri@users.noreply.github.com>
  • Loading branch information
11 people authored Jul 13, 2021
1 parent c78d7b6 commit 3b792d9
Show file tree
Hide file tree
Showing 177 changed files with 6,868 additions and 2,590 deletions.
37 changes: 0 additions & 37 deletions .circleci/config.yml

This file was deleted.

59 changes: 59 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Build
on: [push]

jobs:
build:
name: Build
runs-on: ubuntu-latest

services:
postgres:
image: postgres
env:
POSTGRES_USER: commonwealth
POSTGRES_DB: commonwealth
POSTGRES_PASSWORD: edgeware
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432

steps:
- name: Checkout
uses: actions/checkout@v1

- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 14.x

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn

- name: Run tests
run: yarn test-suite
env:
NO_CLIENT: true

- name: Archive code coverage results
uses: actions/upload-artifact@v2
with:
name: code-coverage-report
path: coverage
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ yarn-error.log
coverage/
*.sw*
.env
.yalc
yalc.lock
*yalc*

# Database downloads
latest.dump
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ nvm install
```

- if for some reason, nvm still doesnt work, try using
````
```
source ~/.nvm/nvm.sh
```

Expand Down
5 changes: 5 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, shrink-to-fit=no">
<meta name="apple-mobile-web-app-capable" content="yes" />

<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-KRWH69V');</script>
<!-- End Google Tag Manager -->

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-136522342-5"></script>

<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
Expand Down
134 changes: 43 additions & 91 deletions client/scripts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import $ from 'jquery';
import { FocusManager } from 'construct-ui';
import moment from 'moment';
import mixpanel from 'mixpanel-browser';
import _ from 'underscore';

import app, { ApiStatus, LoginState } from 'state';
import {
Expand All @@ -20,6 +21,7 @@ import {
ChainNetwork,
NotificationCategory,
Notification,
ChainBase,
} from 'models';
import { WebsocketMessageType, IWebsocketsPayload } from 'types';

Expand All @@ -33,6 +35,7 @@ import ConfirmInviteModal from 'views/modals/confirm_invite_modal';
import LoginModal from 'views/modals/login_modal';
import { alertModalWithText } from 'views/modals/alert_modal';
import Login from './views/components/login';
import { formatSpace } from './helpers/snapshot_utils/snapshot_utils';

// Prefetch commonly used pages
import(/* webpackPrefetch: true */ 'views/pages/landing');
Expand Down Expand Up @@ -114,7 +117,15 @@ export async function initAppState(updateSelectedNode = true): Promise<void> {
app.config.chains.getAll().find((c) => c.customDomain === host) !== undefined
|| app.config.communities.getAll().find((c) => c.customDomain === host) !== undefined
);

app.snapshot.client.getSpaces().then((response) => {
console.log(response);
app.snapshot.spaces = _.object(
Object.entries(response).map((space) => [
space[0],
formatSpace(space[0], space[1])
])
);
});
resolve();
}).catch((err: any) => {
app.loadingError = err.responseJSON?.error || 'Error loading application state';
Expand All @@ -129,10 +140,12 @@ export async function deinitChainOrCommunity() {
app.chain.networkStatus = ApiStatus.Disconnected;
app.chain.deinitServer();
await app.chain.deinit();
console.log('Finished deinitializing chain');
app.chain = null;
}
if (app.community) {
await app.community.deinit();
console.log('Finished deinitializing community');
app.community = null;
}
app.user.setSelectedNode(null);
Expand Down Expand Up @@ -237,76 +250,13 @@ export async function selectNode(n?: NodeInfo, deferred = false): Promise<boolea
// Import top-level chain adapter lazily, to facilitate code split.
let newChain;
let initApi; // required for NEAR
if (n.chain.network === ChainNetwork.Edgeware) {
const Edgeware = (await import(
/* webpackMode: "lazy" */
/* webpackChunkName: "edgeware-main" */
'./controllers/chain/edgeware/main'
)).default;
newChain = new Edgeware(n, app);
} else if (n.chain.network === ChainNetwork.Kusama) {
const Kusama = (await import(
/* webpackMode: "lazy" */
/* webpackChunkName: "kusama-main" */
'./controllers/chain/kusama/main'
)).default;
newChain = new Kusama(n, app);
} else if (n.chain.network === ChainNetwork.Polkadot) {
const Polkadot = (await import(
/* webpackMode: "lazy" */
/* webpackChunkName: "kusama-main" */
'./controllers/chain/polkadot/main'
)).default;
newChain = new Polkadot(n, app);
} else if (n.chain.network === ChainNetwork.Kulupu) {
const Kulupu = (await import(
/* webpackMode: "lazy" */
/* webpackChunkName: "kulupu-main" */
'./controllers/chain/kulupu/main'
)).default;
newChain = new Kulupu(n, app);
} else if (n.chain.network === ChainNetwork.Plasm) {
const Plasm = (await import(
/* webpackMode: "lazy" */
/* webpackChunkName: "plasm-main" */
'./controllers/chain/plasm/main'
)).default;
newChain = new Plasm(n, app);
} else if (n.chain.network === ChainNetwork.Stafi) {
const Stafi = (await import(
/* webpackMode: "lazy" */
/* webpackChunkName: "stafi-main" */
'./controllers/chain/stafi/main'
)).default;
newChain = new Stafi(n, app);
} else if (n.chain.network === ChainNetwork.Crust) {
const Crust = (await import(
if (n.chain.base === ChainBase.Substrate) {
const Substrate = (await import(
/* webpackMode: "lazy" */
/* webpackChunkName: "crust-main" */
'./controllers/chain/crust/main'
/* webpackChunkName: "substrate-main" */
'./controllers/chain/substrate/main'
)).default;
newChain = new Crust(n, app);
} else if (n.chain.network === ChainNetwork.Darwinia) {
const Darwinia = (await import(
/* webpackMode: "lazy" */
/* webpackChunkName: "darwinia-main" */
'./controllers/chain/darwinia/main'
)).default;
newChain = new Darwinia(n, app);
} else if (n.chain.network === ChainNetwork.Phala) {
const Phala = (await import(
/* webpackMode: "lazy" */
/* webpackChunkName: "phala-main" */
'./controllers/chain/phala/main'
)).default;
newChain = new Phala(n, app);
} else if (n.chain.network === ChainNetwork.Centrifuge) {
const Centrifuge = (await import(
/* webpackMode: "lazy" */
/* webpackChunkName: "centrifuge-main" */
'./controllers/chain/centrifuge/main'
)).default;
newChain = new Centrifuge(n, app);
newChain = new Substrate(n, app);
} else if (n.chain.network === ChainNetwork.Cosmos) {
const Cosmos = (await import(
/* webpackMode: "lazy" */
Expand Down Expand Up @@ -336,20 +286,6 @@ export async function selectNode(n?: NodeInfo, deferred = false): Promise<boolea
)).default;
newChain = new Near(n, app);
initApi = true;
} else if (n.chain.network === ChainNetwork.Clover) {
const Clover = (await import(
/* webpackMode: "lazy" */
/* webpackChunkName: "clover-main" */
'./controllers/chain/clover/main'
)).default;
newChain = new Clover(n, app);
} else if (n.chain.network === ChainNetwork.HydraDX) {
const HydraDX = (await import(
/* webpackMode: "lazy" */
/* webpackChunkName: "hydradx-main" */
'./controllers/chain/hydradx/main'
)).default;
newChain = new HydraDX(n, app);
} else if (n.chain.network === ChainNetwork.Moloch || n.chain.network === ChainNetwork.Metacartel) {
const Moloch = (await import(
/* webpackMode: "lazy" */
Expand Down Expand Up @@ -382,23 +318,30 @@ export async function selectNode(n?: NodeInfo, deferred = false): Promise<boolea
const Yearn = (await import(
/* webpackMode: "lazy" */
/* webpackChunkName: "commonwealth-main" */
'./controllers/chain/ethereum/yearn/adapter'
'./controllers/chain/ethereum/snapshot/adapter'
)).default;
newChain = new Yearn(n, app);
} else if (n.chain.network === ChainNetwork.Fei) {
const Fei = (await import(
/* webpackMode: "lazy" */
/* webpackChunkName: "commonwealth-main" */
'./controllers/chain/ethereum/fei/adapter'
'./controllers/chain/ethereum/snapshot/adapter'
)).default;
newChain = new Fei(n, app);
} else if (n.chain.network === ChainNetwork.Sushi) {
const Sushi = (await import(
const Snapshot = (await import(
/* webpackMode: "lazy" */
/* webpackChunkName: "commonwealth-main" */
'./controllers/chain/ethereum/snapshot/adapter'
)).default;
newChain = new Snapshot(n, app);
} else if (n.chain.network === ChainNetwork.Demo) {
const Snapshot = (await import(
/* webpackMode: "lazy" */
/* webpackChunkName: "commonwealth-main" */
'./controllers/chain/ethereum/sushi/adapter'
'./controllers/chain/ethereum/snapshot/adapter'
)).default;
newChain = new Sushi(n, app);
newChain = new Snapshot(n, app);
} else {
throw new Error('Invalid chain');
}
Expand All @@ -407,14 +350,17 @@ export async function selectNode(n?: NodeInfo, deferred = false): Promise<boolea
const finalizeInitialization = await newChain.initServer();

// If the user is still on the initializing node, finalize the
// initialization; otherwise, abort and return false
// initialization; otherwise, abort, deinit, and return false.
//
// Also make sure the state is sufficiently reset so that the
// next redraw cycle will reinitialize any needed chain.
if (!finalizeInitialization) {
console.log('Chain loading aborted');
app.chainPreloading = false;
app.chain = null;
return false;
} else {
app.chain = newChain;
const snapshotId = app.chain?.meta.chain.snapshot;
app.snapshot.fetchSnapshotProposals(snapshotId);
}
if (initApi) {
app.chain.initApi(); // required for loading NearAccounts
Expand Down Expand Up @@ -707,6 +653,7 @@ $(() => {
'/:scope/proposals': importRoute('views/pages/proposals', { scoped: true }),
'/:scope/treasury': importRoute('views/pages/treasury', { scoped: true }),
'/:scope/bounties': importRoute('views/pages/bounties', { scoped: true }),
'/:scope/tips': importRoute('views/pages/tips', { scoped: true }),
'/:scope/proposal/:type/:identifier': importRoute('views/pages/view_proposal/index', { scoped: true }),
'/:scope/council': importRoute('views/pages/council', { scoped: true }),
'/:scope/delegate': importRoute('views/pages/delegate', { scoped: true, }),
Expand All @@ -715,6 +662,7 @@ $(() => {
'/:scope/new/snapshot-proposal/:snapshotId': importRoute('views/pages/new_snapshot_proposal', { scoped: true, deferChain: true }),
'/:scope/new/proposal/:type': importRoute('views/pages/new_proposal/index', { scoped: true }),
'/:scope/admin': importRoute('views/pages/admin', { scoped: true }),
'/:scope/spec_settings': importRoute('views/pages/spec_settings', { scoped: true, deferChain: true }),
'/:scope/settings': importRoute('views/pages/settings', { scoped: true }),
'/:scope/analytics': importRoute('views/pages/stats', { scoped: true, deferChain: true }),
'/:scope/web3login': importRoute('views/pages/web3login', { scoped: true }),
Expand All @@ -732,6 +680,10 @@ $(() => {
'/:scope/finishNearLogin': importRoute('views/pages/finish_near_login', { scoped: true }),
});

const script = document.createElement('noscript');
m.render(script, m.trust('<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KRWH69V" height="0" width="0" style="display:none;visibility:hidden"></iframe>'));
document.body.insertBefore(script, document.body.firstChild);

// initialize construct-ui focus manager
FocusManager.showFocusOnlyOnTab();

Expand Down
1 change: 0 additions & 1 deletion client/scripts/controllers/app/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export function linkExistingAddressToChainOrCommunity(
}

export async function setActiveAccount(account: Account<any>): Promise<void> {
console.log('set active account');
const chain = app.activeChainId();
const community = app.activeCommunityId();
const role = app.user.getRoleInCommunity({ account, chain, community });
Expand Down
2 changes: 1 addition & 1 deletion client/scripts/controllers/app/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { notifyError } from 'controllers/app/notifications';
class SettingsController {
public static async disableRichText(value: boolean) {
if (!app.isLoggedIn()) return;
return new Promise((resolve, reject) => {
return new Promise<void>((resolve, reject) => {
$.post(`${app.serverUrl()}/writeUserSetting`, {
jwt: app.user.jwt,
key: 'disableRichText',
Expand Down
Loading

0 comments on commit 3b792d9

Please sign in to comment.