Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
… into salman/Issue#10009/permission-ui-revamp
  • Loading branch information
salman-neslit committed Dec 30, 2024
2 parents baa5319 + c966bc8 commit 393a6fe
Show file tree
Hide file tree
Showing 710 changed files with 20,751 additions and 7,560 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ env:
USES_DOCKER_PGSQL: true
PORT: 8080
REDIS_URL: redis://localhost:6379
ENTITIES_URL: ${{ secrets.ENTITIES_URL }}
GITHUB_BASE_REF: ${{ github.base_ref }}
FEDERATION_POSTGRES_DB_URL: postgresql://commonwealth:edgeware@localhost/common_test
ALCHEMY_PRIVATE_APP_KEY: ${{ secrets.ALCHEMY_PRIVATE_APP_KEY }}
ALCHEMY_PUBLIC_APP_KEY: ${{ secrets.ALCHEMY_PUBLIC_APP_KEY }}

on:
workflow_dispatch:
inputs:
pr_number:
description: "PR number to test (optional)"
required: false
type: number
pull_request:
merge_group:
push:
branches:
- master
Expand Down Expand Up @@ -58,6 +62,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.pr_number && format('refs/pull/{0}/head', github.event.inputs.pr_number) || github.ref }}
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}
Expand Down Expand Up @@ -118,6 +124,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.pr_number && format('refs/pull/{0}/head', github.event.inputs.pr_number) || github.ref }}
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}
Expand Down Expand Up @@ -175,6 +182,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.pr_number && format('refs/pull/{0}/head', github.event.inputs.pr_number) || github.ref }}
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}
Expand Down Expand Up @@ -209,6 +218,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.pr_number && format('refs/pull/{0}/head', github.event.inputs.pr_number) || github.ref }}
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}
Expand All @@ -229,6 +239,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.pr_number && format('refs/pull/{0}/head', github.event.inputs.pr_number) || github.ref }}
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}
Expand Down Expand Up @@ -272,6 +283,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.pr_number && format('refs/pull/{0}/head', github.event.inputs.pr_number) || github.ref }}
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}
Expand Down Expand Up @@ -327,6 +339,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.pr_number && format('refs/pull/{0}/head', github.event.inputs.pr_number) || github.ref }}
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}
Expand Down Expand Up @@ -375,6 +389,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.pr_number && format('refs/pull/{0}/head', github.event.inputs.pr_number) || github.ref }}
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}
Expand Down Expand Up @@ -427,6 +443,8 @@ jobs:
- 6379:6379
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.pr_number && format('refs/pull/{0}/head', github.event.inputs.pr_number) || github.ref }}
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/Versioning.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ jobs:
with:
node-version: 20

- name: Bump external API version if necessary
run: pnpm -F commonwealth validate-external-api-version
#. Openapi diff hanging. Blocks release. Commenting out for now
# - name: Bump external API version if necessary
# run: pnpm -F commonwealth validate-external-api-version

- name: Check if version was updated
run: |
Expand Down
19 changes: 19 additions & 0 deletions common_knowledge/Chain-Events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# EVM Chain Events

There are 2 methods of adding chain events sources. Parent contracts are contracts that we (Common) deploy and child
contracts are contracts deployed by users (e.g. Single Contests). Parent contract addresses are stable (almost never
change) and are therefore hardcoded in `chainConfig.ts`. On the other hand, we cannot know the address of a child
contract ahead of time since it is deployed at runtime. For this reason, child contract sources are stored in the
EvmEventSources table with a reference to the parent contract in the EventRegistry.

These instructions only describe how to ensure events are picked it up by EVM CE _not_ how these events are processed.

## Adding Parent Contract Events
1. Add the contract address in the `factoryContracts` object in `chainConfig.ts`.
2. Add the relevant event signatures in `eventSignatures.ts`.
3. Update the `EventRegistry` object in `eventRegistry.ts` to reference the new contract/event.

## Adding Child Contract Events
1. Add the relevant event signatures in `eventSignatures.ts`.
2. Update the `EventRegistry` object in `eventRegistry.ts` to reference the new events.
3. Ensure that the parent events pertaining to child contract launches create sources in the `EvmEventSources` table.
5 changes: 0 additions & 5 deletions common_knowledge/Environment-Variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ If you add a new environment variable, you must add documentation here. Please d
- [NEXT_PUBLIC_RSA_PRIVATE_KEY](#next_public_rsa_private_key)
- [NEXT_PUBLIC_RSA_PUBLIC_KEY](#next_public_rsa_public_key)
- [NO_GLOBAL_ACTIVITY_CACHE](#no_global_activity_cache)
- [NO_PRERENDER](#no_prerender)
- [NO_SSL](#no_ssl)
- [NODE_ENV](#node_env)
- [PGPASSWORD](#pgpassword)
Expand Down Expand Up @@ -266,10 +265,6 @@ Mixpanel analytics tracking token for our live production site.

If `true`, disables the initialization of `globalActivityCache.ts` from server.

## NO_PRERENDER

In a production environment, prerender is only run from `commonwealth/server.ts` if this flag is false or blank.

## NO_SSL

Used and defined on-the-fly for the `start-external-webpack` package.json script.
Expand Down
2 changes: 1 addition & 1 deletion common_knowledge/Twitter.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,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_PRERENDER=true NO_CLIENT_SERVER=true MIXPANEL_DEV_TOKEN=foo MIXPANEL_PROD_TOKEN=bar NODE_ENV=production npx tsx server.ts
NO_CLIENT_SERVER=true MIXPANEL_DEV_TOKEN=foo MIXPANEL_PROD_TOKEN=bar NODE_ENV=production npx tsx server.ts
```

4. With the site running, query the link preview with `curl -G http://localhost:8080/<url>`
Expand Down
3 changes: 1 addition & 2 deletions libs/adapters/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@aws-sdk/s3-request-presigner": "^3.577.0",
"@hicommonwealth/core": "workspace:*",
"@hicommonwealth/shared": "workspace:*",
"@hicommonwealth/schemas": "workspace:*",
"@knocklabs/node": "^0.6.13",
"@trpc/server": "^10.45.1",
"amqplib": "^0.10.3",
Expand All @@ -53,10 +54,8 @@
"@types/express": "^4.17.21",
"@types/express-serve-static-core": "^4.19.0",
"@types/qs": "^6.9.14",
"@types/sinon": "^17.0.3",
"@types/superagent": "4.1.13",
"@types/swagger-ui-express": "^4.1.6",
"sinon": "^17.0.2",
"superagent": "^5.2.2",
"tsx": "^4.7.2"
}
Expand Down
4 changes: 2 additions & 2 deletions libs/adapters/src/blobStorage/s3.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CompleteMultipartUploadCommandOutput, S3 } from '@aws-sdk/client-s3';
import { BlobBucket, type BlobStorage } from '@hicommonwealth/core';
import { S3_ASSET_BUCKET_CDN } from '@hicommonwealth/shared';
import { PRODUCTION_DOMAIN, S3_ASSET_BUCKET_CDN } from '@hicommonwealth/shared';
import { config } from '../config';
import { exists_S3sdk, getSignedUrl_S3sdk, upload_S3sdk } from './util';

Expand All @@ -14,7 +14,7 @@ const s3Buckets: Partial<Record<BlobBucket, string>> =
: {
assets: S3_ASSET_BUCKET_CDN,
archives: 'outbox-event-stream-archive',
sitemap: 'sitemap.commonwealth.im',
sitemap: `sitemap.${PRODUCTION_DOMAIN}`,
};

function formatS3Url(
Expand Down
10 changes: 5 additions & 5 deletions libs/adapters/src/mixpanel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ export const MixpanelAnalytics = (): Analytics => {
mixpanelNode = MixpanelLib.init(config.ANALYTICS.MIXPANEL_DEV_TOKEN!);
}
} catch (e) {
log.error(
'Unable to initialized the backend mixpanel client: ',
e as Error,
);
log.error('Unable to initialize the backend mixpanel: ', e as Error);
}

return {
Expand All @@ -29,7 +26,10 @@ export const MixpanelAnalytics = (): Analytics => {
try {
mixpanelNode?.track(event, payload);
} catch (e) {
log.error(`Failed to track event, ${event.toString()}:`, e as Error);
log.error(
`Failed to track backend mixpanel event, ${event.toString()}:`,
e as Error,
);
}
},
};
Expand Down
3 changes: 1 addition & 2 deletions libs/adapters/src/rabbitmq/RabbitMQAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import {
BrokerSubscriptions,
CustomRetryStrategyError,
EventContext,
EventNames,
EventSchemas,
Events,
EventsHandlerMetadata,
ILogger,
InvalidInput,
Expand All @@ -16,6 +14,7 @@ import {
handleEvent,
logger,
} from '@hicommonwealth/core';
import { EventNames, Events } from '@hicommonwealth/schemas';
import { Message } from 'amqplib';
import { AckOrNack, default as Rascal } from 'rascal';

Expand Down
25 changes: 25 additions & 0 deletions libs/adapters/src/rabbitmq/configuration/rascalConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ export function getAllRascalConfigs(
arguments: queueOptions,
},
},
[RascalQueues.XpProjection]: {
...queueConfig,
options: {
arguments: queueOptions,
},
},
[RascalQueues.FarcasterWorkerPolicy]: {
...queueConfig,
options: {
Expand Down Expand Up @@ -203,6 +209,21 @@ export function getAllRascalConfigs(
RascalRoutingKeys.ContestProjectionContestContentUpvoted,
],
},
[RascalBindings.XpProjection]: {
source: RascalExchanges.MessageRelayer,
destination: RascalQueues.XpProjection,
destinationType: 'queue',
bindingKeys: [
RascalRoutingKeys.XpProjectionSignUpFlowCompleted,
RascalRoutingKeys.XpProjectionCommunityCreated,
RascalRoutingKeys.XpProjectionCommunityJoined,
RascalRoutingKeys.XpProjectionThreadCreated,
RascalRoutingKeys.XpProjectionThreadUpvoted,
RascalRoutingKeys.XpProjectionCommentCreated,
RascalRoutingKeys.XpProjectionCommentUpvoted,
RascalRoutingKeys.XpProjectionUserMentioned,
],
},
[RascalBindings.FarcasterWorkerPolicy]: {
source: RascalExchanges.MessageRelayer,
destination: RascalQueues.FarcasterWorkerPolicy,
Expand Down Expand Up @@ -239,6 +260,10 @@ export function getAllRascalConfigs(
queue: RascalQueues.ContestProjection,
...subscriptionConfig,
},
[RascalSubscriptions.XpProjection]: {
queue: RascalQueues.XpProjection,
...subscriptionConfig,
},
[RascalSubscriptions.FarcasterWorkerPolicy]: {
queue: RascalQueues.FarcasterWorkerPolicy,
...subscriptionConfig,
Expand Down
3 changes: 3 additions & 0 deletions libs/adapters/src/rabbitmq/rabbitMQConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export function getRabbitMQConfig(
RascalQueues.NotificationsSettings,
RascalQueues.ContestWorkerPolicy,
RascalQueues.ContestProjection,
RascalQueues.XpProjection,
RascalQueues.FarcasterWorkerPolicy,
RascalQueues.DiscordBotPolicy,
]);
Expand All @@ -83,6 +84,7 @@ export function getRabbitMQConfig(
RascalBindings.NotificationsSettings,
RascalBindings.ContestWorkerPolicy,
RascalBindings.ContestProjection,
RascalBindings.XpProjection,
RascalBindings.FarcasterWorkerPolicy,
RascalBindings.DiscordBotPolicy,
]);
Expand All @@ -95,6 +97,7 @@ export function getRabbitMQConfig(
RascalSubscriptions.NotificationsSettings,
RascalSubscriptions.ContestWorkerPolicy,
RascalSubscriptions.ContestProjection,
RascalSubscriptions.XpProjection,
RascalSubscriptions.FarcasterWorkerPolicy,
RascalSubscriptions.DiscordBotPolicy,
]);
Expand Down
14 changes: 13 additions & 1 deletion libs/adapters/src/rabbitmq/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
BrokerPublications,
BrokerSubscriptions,
EventNames,
RoutingKeyTags,
} from '@hicommonwealth/core';
import { EventNames } from '@hicommonwealth/schemas';

export enum RascalPublications {
MessageRelayer = BrokerPublications.MessageRelayer,
Expand All @@ -17,6 +17,7 @@ export enum RascalSubscriptions {
NotificationsSettings = BrokerSubscriptions.NotificationsSettings,
ContestWorkerPolicy = BrokerSubscriptions.ContestWorkerPolicy,
ContestProjection = BrokerSubscriptions.ContestProjection,
XpProjection = BrokerSubscriptions.XpProjection,
FarcasterWorkerPolicy = BrokerSubscriptions.FarcasterWorkerPolicy,
}

Expand All @@ -33,6 +34,7 @@ export enum RascalQueues {
NotificationsSettings = 'NotificationsSettingsQueue',
ContestWorkerPolicy = 'ContestWorkerPolicyQueue',
ContestProjection = 'ContestProjection',
XpProjection = 'XpProjection',
FarcasterWorkerPolicy = 'FarcasterWorkerPolicyQueue',
}

Expand All @@ -44,6 +46,7 @@ export enum RascalBindings {
ChainEvent = 'ChainEventBinding',
ContestWorkerPolicy = 'ContestWorkerPolicy',
ContestProjection = 'ContestProjection',
XpProjection = 'XpProjection',
FarcasterWorkerPolicy = 'FarcasterWorkerPolicy',
}

Expand Down Expand Up @@ -77,6 +80,15 @@ export enum RascalRoutingKeys {
ContestProjectionContestContentAdded = EventNames.ContestContentAdded,
ContestProjectionContestContentUpvoted = EventNames.ContestContentUpvoted,

XpProjectionSignUpFlowCompleted = EventNames.SignUpFlowCompleted,
XpProjectionCommunityCreated = EventNames.CommunityCreated,
XpProjectionCommunityJoined = EventNames.CommunityJoined,
XpProjectionThreadCreated = `${EventNames.ThreadCreated}.#`,
XpProjectionThreadUpvoted = `${EventNames.ThreadUpvoted}.#`,
XpProjectionCommentCreated = EventNames.CommentCreated,
XpProjectionCommentUpvoted = EventNames.CommentUpvoted,
XpProjectionUserMentioned = EventNames.UserMentioned,

FarcasterWorkerPolicyCastCreated = EventNames.FarcasterCastCreated,
FarcasterWorkerPolicyReplyCastCreated = EventNames.FarcasterReplyCastCreated,
FarcasterWorkerPolicyVoteCreated = EventNames.FarcasterVoteCreated,
Expand Down
2 changes: 1 addition & 1 deletion libs/adapters/src/trpc/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
CacheNamespaces,
Events,
INVALID_ACTOR_ERROR,
INVALID_INPUT_ERROR,
INVALID_STATE_ERROR,
Expand All @@ -13,6 +12,7 @@ import {
type EventsHandlerMetadata,
type Metadata,
} from '@hicommonwealth/core';
import { Events } from '@hicommonwealth/schemas';
import { TRPCError } from '@trpc/server';
import { ZodSchema, ZodUndefined, z } from 'zod';
import { Commit, Tag, Track, buildproc, procedure } from './middleware';
Expand Down
Loading

0 comments on commit 393a6fe

Please sign in to comment.