Skip to content

Commit

Permalink
Merge branch 'master' into tim/threads-semantics
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/commonwealth/test/integration/api/createChain.spec.ts
  • Loading branch information
timolegros committed Jan 5, 2024
2 parents 5d7972e + ab05726 commit a85e555
Show file tree
Hide file tree
Showing 70 changed files with 265 additions and 2,747 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,6 @@ jobs:
echo "Network name: $network_name"
/usr/bin/docker run -d --name chain --network $network_name --network-alias chain -p 8545:8545 -e GITHUB_ACTIONS=true -e CI=true trufflesuite/ganache --fork --miner.blockTime 12 --wallet.unlockedAccounts 0xF977814e90dA44bFA03b6295A0616a897441aceC --wallet.unlockedAccounts 0xfA9b5f7fDc8AB34AAf3099889475d47febF830D7 --wallet.unlockedAccounts 0xBE0eB53F46cd790Cd13851d5EFf43D12404d33E8;
- name: Run Token Balance Cache Unit Tests
run: yarn --cwd packages/token-balance-cache test --forbid-only

- name: Run EVM Devnet tests
run: yarn --cwd packages/commonwealth test-devnet evm --forbid-only

Expand Down
2 changes: 1 addition & 1 deletion knowledge_base/Link-Previews.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ To get link previews, you will need to do the following:
3. Run against the built site in the packages/commonwealth folder with:

```bash
NO_TOKEN_BALANCE_CACHE=true NO_PRERENDER=true NO_CLIENT_SERVER=true MIXPANEL_DEV_TOKEN=foo MIXPANEL_PROD_TOKEN=bar NODE_ENV=production npx ts-node -P tsconfig.server.json -T server.ts
NO_PRERENDER=true NO_CLIENT_SERVER=true MIXPANEL_DEV_TOKEN=foo MIXPANEL_PROD_TOKEN=bar NODE_ENV=production npx ts-node -P tsconfig.server.json -T server.ts
```

4. With the site running, query the link preview with `curl -G http://localhost:8080/<url>`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
@import '../../../../styles/shared.scss';

.Popover.UpvotePopover {
padding: 8px 0;
width: 256px;

.popover-title {
padding: 8px 16px;
margin-bottom: 0;
}

.upvoters-list {
display: flex;
flex-direction: column;

.upvoter-row {
display: flex;
height: 40px;
justify-content: space-between;
align-items: center;
padding: 0 20px;
align-self: stretch;

.User {
.user-display-name {
font-size: 12px;
font-weight: 500;
line-height: 16px;
letter-spacing: 0.24px;
}
}
}
}

.upvoter-count {
height: 40px;
padding: 0 20px;
display: flex;
align-items: center;
color: $neutral-400;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import React from 'react';
import { isMobile } from 'react-device-detect';
import app from 'state';
import { CWText } from '../component_kit/cw_text';
import CWIconButton from '../component_kit/new_designs/CWIconButton';
import CWPopover, {
UsePopoverProps,
} from '../component_kit/new_designs/CWPopover/CWPopover';
import { User } from '../user/user';
import './UpvotePopover.scss';

type UpvotePopoverProps = {
upvoters: string[];
} & UsePopoverProps;

export const UpvotePopover = ({
upvoters = [],
...popoverProps
}: UpvotePopoverProps) => {
const maxVisibleUpvotingAccounts = 3;

const createUpvoterList = (upvoterAddresses: string[]) => {
const slicedUpvoters = upvoterAddresses
.slice(0, maxVisibleUpvotingAccounts)
.map((upvoterAddress) => {
return (
<div key={upvoterAddress} className="upvoter-row">
<User
userAddress={upvoterAddress}
// set to 1inch for use on components page
userCommunityId={app.chain?.id || '1inch'}
avatarSize={24}
shouldLinkProfile
/>
<CWText className="vote-weight" type="b2">
5x
</CWText>
</div>
);
});

if (upvoterAddresses.length > maxVisibleUpvotingAccounts) {
slicedUpvoters.push(
<CWText
type="caption"
className="upvoter-count"
key="final"
>{`${upvoterAddresses.length} votes total`}</CWText>,
);
}

return <div className="upvoters-list">{slicedUpvoters}</div>;
};

return (
<>
{upvoters.length > 0 && (
<CWPopover
className="UpvotePopover"
title={
<>
Recent Upvotes
{isMobile && (
<div className="close">
<CWIconButton
iconName="close"
buttonSize="sm"
onClick={popoverProps.handleInteraction}
/>
</div>
)}
</>
}
body={createUpvoterList(upvoters)}
{...popoverProps}
/>
)}
</>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { UpvotePopover } from './UpvotePopover';

export default UpvotePopover;
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import CWFormSteps from 'views/components/component_kit/new_designs/CWFormSteps'
import CWPopover, {
usePopover,
} from 'views/components/component_kit/new_designs/CWPopover';

import {
createDeltaFromText,
ReactQuillEditor,
Expand All @@ -31,6 +32,7 @@ import { openConfirmation } from 'views/modals/confirmation_modal';
import { z } from 'zod';
import { AvatarUpload } from '../Avatar';
import CommunityStakeBanner from '../CommunityStakeBanner';
import UpvotePopover from '../UpvotePopover';
import { CWCard } from './cw_card';
import { CWCheckbox } from './cw_checkbox';
import { CWCollapsible } from './cw_collapsible';
Expand Down Expand Up @@ -238,6 +240,7 @@ export const ComponentShowcase = () => {

const unstyledPopoverProps = usePopover();
const styledPopoverProps = usePopover();
const upvotePopoverProps = usePopover();

const renderModal = (size?: ModalSize) => {
return (
Expand Down Expand Up @@ -380,6 +383,30 @@ export const ComponentShowcase = () => {
/>
</div>
</div>
<div className="basic-gallery">
<CWText type="h3">Upvote Popover</CWText>
<div
className="upvote-popover-wrapper"
onMouseEnter={upvotePopoverProps.handleInteraction}
onMouseLeave={upvotePopoverProps.handleInteraction}
>
<CWIconButton buttonSize="med" iconName="infoEmpty" />
<UpvotePopover
upvoters={[
'0x4d9E3fEEe018eD9bD86f0F9D61C682E2e97e777F',
'0x7C06900b29462995EB25525B87Ff5267016E49E2',
'0x6d3735749DfD7dA2A5f6528fC39938aF1760e6a4',
'0xe5B4c6C331Bbc6E2a2017a29E8e1D0754354b6cF',
'0x7A7C614EDFA324d61F5E897f085c18E007aE3dFf',
'0x04eE16f6FFD615eB448e8d939Dbcf28a2e064f0b',
'0x8Ae9b627637eaFeF5eC2E39b8A88b40bAA66af81',
'0xcB565Ee70934c5887F9459fb0Dcec6ADD7F43CF2',
'0xFcC142B9f39A9379B2D3f2621b67e10A907FeFF8',
]}
{...upvotePopoverProps}
/>
</div>
</div>
<div className="basic-gallery">
<CWText type="h3">Popover Menu</CWText>
<PopoverMenu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import { uuidv4 } from 'lib/util';
import { ComponentType } from 'views/components/component_kit/types';

import { CWText } from 'views/components/component_kit/cw_text';
import { getClasses } from '../../helpers';
import './CWPopover.scss';

export type AnchorType = HTMLElement | SVGSVGElement;

type UsePopoverProps = {
export type UsePopoverProps = {
anchorEl: AnchorType;
id: string;
open: boolean;
Expand Down Expand Up @@ -40,6 +41,7 @@ type CWPopoverProps = {
placement?: PopperPlacementType;
disablePortal?: boolean;
modifiers?: PopperOwnProps['modifiers'];
className?: string;
} & UsePopoverProps &
ComponentInteriorProps;

Expand Down Expand Up @@ -74,14 +76,20 @@ const CWPopover = ({
content,
id,
open,
className,
placement,
disablePortal,
modifiers = [],
title,
body,
}: CWPopoverProps) => {
const popoverContent = content || (
<div className={ComponentType.Popover}>
<div
className={getClasses<{ className?: string }>(
{ className },
ComponentType.Popover,
)}
>
{title && (
<CWText type="caption" fontWeight="medium" className="popover-title">
{title}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ $width: 360px;
color: $neutral-400;
}
}

.upvote-popover-wrapper {
width: fit-content;
}
}

.progress-gallery {
Expand Down
2 changes: 1 addition & 1 deletion packages/commonwealth/madge.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
# Generates a visualization of module dependencies
madge -i out.png --exclude '^state\.ts$|^identifiers\.ts$|app\/notifications|(node_modules\/@types)|rxjs|construct-ui|models\/|stores\/|shared\/adapters\/|helpers' client/scripts/app.tsx
madge -i out.png --exclude '^state\.ts$|^identifiers\.ts$|app\/notifications|(node_modules\/@types)|construct-ui|models\/|stores\/|shared\/adapters\/|helpers' client/scripts/app.tsx
22 changes: 2 additions & 20 deletions packages/commonwealth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
"@todesktop/client-core": "^1.1.3",
"@types/bn.js": "^4.11.6",
"@types/bs58": "^4.0.1",
"@types/chai-as-promised": "^7.1.8",
"@types/express": "^4.17.1",
"@types/filesystem": "^0.0.29",
"@types/jquery": "^3.5.4",
Expand All @@ -137,28 +138,21 @@
"amqplib": "^0.8.0",
"assert": "^2.0.0",
"aws-sdk": "^2.814.0",
"bcrypt-nodejs": "^0.0.3",
"bech32": "^2.0.0",
"bip39": "^3.0.2",
"bn.js": "^4.12.0",
"browser-image-compression": "^2.0.2",
"browserify-zlib": "^0.2.0",
"bs58": "^4.0.1",
"buffer": "^6.0.3",
"chart.js": "^2.8.0",
"cheerio": "1.0.0-rc.3",
"clipboard-polyfill": "^2.8.6",
"clsx": "^1.2.1",
"compression": "^1.7.4",
"connect-session-sequelize": "^7.1.1",
"cookie-parser": "^1.4.4",
"core-js": "3",
"create-hash": "^1.2.0",
"core-js": "^3.34.0",
"crypto-browserify": "^3.12.0",
"crypto-js": "^4.1.1",
"dompurify": "^2.2.6",
"dotenv": "^8.2.0",
"ethereum-block-by-date": "^1.2.2",
"ethereumjs-util": "7.1.0",
"ethereumjs-wallet": "^1.0.2",
"express": "^4.17.3",
Expand Down Expand Up @@ -189,17 +183,12 @@
"node-fetch": "2",
"node-jose": "^2.2.0",
"node-object-hash": "^3.0.0",
"node-statsd": "^0.1.1",
"numeral": "^2.0.6",
"object-hash": "^3.0.0",
"openai": "^3.1.0",
"os-browserify": "^0.3.0",
"parchment": "^1.1.4",
"passport": "^0.4.0",
"passport-discord": "^0.1.4",
"passport-github2": "^0.1.12",
"passport-jwt": "^4.0.0",
"passport-local": "^1.0.0",
"passport-magic": "^1.0.0",
"path-browserify": "^1.0.1",
"prerender": "^5.6.0",
Expand Down Expand Up @@ -231,31 +220,24 @@
"redis": "4.2.0",
"remove-markdown": "^0.5.0",
"rollbar": "^2.6.1",
"rxjs": "^7.3.0",
"safe-stable-stringify": "^2.4.2",
"sass": "^1.55.0",
"secp256k1": "^4.0.2",
"sequelize-cli": "^6.2.0",
"serve-favicon": "^2.5.0",
"sharp": "^0.31.2",
"siwe": "^2.1.4",
"sleep-promise": "^8.0.1",
"smart-truncate": "^1.0.1",
"source-map": "^0.7.3",
"stream-browserify": "^3.0.0",
"stream-http": "^3.2.0",
"superagent": "^5.2.2",
"swagger-ui-express": "^4.6.0",
"throttled-queue": "^1.0.7",
"ts-node": "^8.6.2",
"tsc-alias": "^1.7.0",
"tsconfig-paths": "^4.2.0",
"tweetnacl": "^1.0.3",
"underscore": "^1.13.1",
"usehooks-ts": "^2.9.1",
"velocity": "^0.7.2",
"vm-browserify": "^1.1.2",
"ws": "^7.4.6",
"yargs": "^17.7.2",
"zod": "^3.22.4",
"zustand": "^4.3.8"
Expand Down
13 changes: 3 additions & 10 deletions packages/commonwealth/scripts/refresh-all-memberships.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import * as dotenv from 'dotenv';
import { RedisCache } from '../../common-common/src/redisCache';
import { TokenBalanceCache as TokenBalanceCacheV1 } from '../../token-balance-cache/src';
import { REDIS_URL } from '../server/config';
import { ServerCommunitiesController } from '../server/controllers/server_communities_controller';
import { ServerGroupsController } from '../server/controllers/server_groups_controller';
import db from '../server/database';
import BanCache from '../server/util/banCheckCache';
import { TokenBalanceCache as TokenBalanceCacheV2 } from '../server/util/tokenBalanceCache/tokenBalanceCache';
import { TokenBalanceCache } from '../server/util/tokenBalanceCache/tokenBalanceCache';

dotenv.config();

Expand All @@ -16,22 +15,16 @@ async function main() {
await redisCache.init(REDIS_URL);
const banCache = new BanCache(models);

const tokenBalanceCacheV1 = new TokenBalanceCacheV1();
await tokenBalanceCacheV1.initBalanceProviders();
await tokenBalanceCacheV1.start();

const tokenBalanceCacheV2 = new TokenBalanceCacheV2(models, redisCache);
const tokenBalanceCache = new TokenBalanceCache(models, redisCache);

const communitiesController = new ServerCommunitiesController(
models,
tokenBalanceCacheV1,
banCache,
);

const groupsController = new ServerGroupsController(
models,
tokenBalanceCacheV1,
tokenBalanceCacheV2,
tokenBalanceCache,
banCache,
);

Expand Down
Loading

0 comments on commit a85e555

Please sign in to comment.