Skip to content

Commit

Permalink
Remove token thresholds from server (#6105)
Browse files Browse the repository at this point in the history
* remove client side gating flag + topic threshold logic

* remove token balance property + methods from client Account model

* remove more token threshold logic from client

* remove env var from webpack

* remove ITokenAdapter

* removed banner

* removed NftAdapter

* remove token adapters

* remove .only in API tests

* eslint fixes

* `Topics.token_threshold` removal migration

* remove `/bulkBalances`

* remove `/tokenBalance`

* remove `/tokenBalance` - external API

* remove test + types

* remove token_balance requirement in created_topics to fix topic creation

* remove unused error

* remove validateTopicThreshold

* fix unit tests

* remove token_threshold from sequelize model + delete `/setTopicThreshold`

* remove setTopicThreshold mutation

* reorder migration

* add gating flag to unit tests

* integration test fix

* fix unit test

* fix sublayout banner

* invert flag check

* fix unit tests
  • Loading branch information
timolegros authored Jan 4, 2024
1 parent 451890f commit 4f8f902
Show file tree
Hide file tree
Showing 22 changed files with 162 additions and 621 deletions.
2 changes: 1 addition & 1 deletion packages/commonwealth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"test-integration-util": "NODE_ENV=test nyc ts-mocha --project tsconfig.json ./test/integration/*.spec.ts",
"test-select": "NODE_ENV=test nyc ts-mocha --project tsconfig.json",
"test-suite": "NODE_ENV=test nyc ts-mocha --project tsconfig.json './test/**/*.spec.ts'",
"unit-test": "NODE_ENV=test ts-mocha --project tsconfig.json './test/unit/**/*.spec.ts'",
"unit-test": "NODE_ENV=test FEATURE_FLAG_GROUP_CHECK_ENABLED=true ts-mocha --project tsconfig.json './test/unit/**/*.spec.ts'",
"unit-test:watch": "NODE_ENV=test ts-mocha --project tsconfig.json --opts test/mocha-dev.opts './test/unit/**/*.spec.ts' -w --watch-files '**/*.ts'",
"wait-server": "chmod +x ./scripts/wait-server.sh && ./scripts/wait-server.sh",
"refresh-all-memberships": "npx ts-node -T ./scripts/refresh-all-memberships.ts",
Expand Down
25 changes: 0 additions & 25 deletions packages/commonwealth/server/api/extApiTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import type { CommentAttributes } from '../models/comment';
import type { CommunityAttributes } from '../models/community';
import type { ProfileAttributes } from '../models/profile';
import type { ReactionAttributes } from '../models/reaction';
import type { RoleAttributes } from '../models/role';
import type { ThreadAttributes } from '../models/thread';
import type { TopicAttributes } from '../models/topic';

Expand Down Expand Up @@ -95,10 +94,6 @@ export type GetProfilesReq = {
count_only?: boolean;
} & IPagination;

export type PostProfilesReq = {
profiles: (ProfileAttributes[] & { community_id: string })[];
};

export type GetProfilesResp = { profiles?: ProfileAttributes[]; count: number };

export type GetChainNodesReq = {
Expand All @@ -117,13 +112,6 @@ export type GetBalanceProvidersResp = {
count: number;
};

export type GetTokenBalanceReq = {
chain_node_id: number;
addresses: string[];
balance_provider: string;
opts: Record<string, string | undefined>;
};

export type GetTopicsReq = {
community_id: string;
count_only?: boolean;
Expand All @@ -135,19 +123,6 @@ export type PostTopicsReq = {

export type GetTopicsResp = { topics?: TopicAttributes[]; count: number };

export type GetRolesReq = {
community_id: string;
addresses?: string[];
count_only?: boolean;
permissions?: string[];
} & IPagination;

export type GetRolesResp = { roles?: RoleAttributes[]; count: number };

export type PostRolesReq = {
roles: (RoleAttributes & { community_id: string })[];
};

export type OnlyErrorResp = { error?: string | object };

export const needParamErrMsg = 'Please provide a parameter to query by';
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export async function __createCommentReaction(
try {
const { isValid } = await validateTopicGroupsMembership(
this.models,
this.tokenBalanceCacheV1,
this.tokenBalanceCacheV2,
thread.topic_id,
community,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export async function __updatePollVote(
// check token balance threshold if needed
const { isValid } = await validateTopicGroupsMembership(
this.models,
this.tokenBalanceCacheV1,
this.tokenBalanceCacheV2,
thread.topic_id,
community,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ export async function __createThread(
if (!isAdmin) {
const { isValid, message } = await validateTopicGroupsMembership(
this.models,
this.tokenBalanceCacheV1,
this.tokenBalanceCacheV2,
topicId,
community,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ export async function __createThreadComment(
if (!isAdmin) {
const { isValid, message } = await validateTopicGroupsMembership(
this.models,
this.tokenBalanceCacheV1,
this.tokenBalanceCacheV2,
thread.topic_id,
community,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export async function __createThreadReaction(
if (!isAdmin) {
const { isValid, message } = await validateTopicGroupsMembership(
this.models,
this.tokenBalanceCacheV1,
this.tokenBalanceCacheV2,
thread.topic_id,
community,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.removeColumn('Topics', 'token_threshold');
},

down: async (queryInterface, Sequelize) => {
// data loss occurs
await queryInterface.addColumn(
'Topics',
'token_threshold',
{
type: Sequelize.STRING,
allowNull: true,
defaultValue: '0',
},
{ transaction: t },
);
},
};
2 changes: 0 additions & 2 deletions packages/commonwealth/server/models/topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export type TopicAttributes = {
created_at?: Date;
updated_at?: Date;
deleted_at?: Date;
token_threshold: string;
default_offchain_template?: string;
group_ids: number[];

Expand Down Expand Up @@ -47,7 +46,6 @@ export default (
created_at: { type: dataTypes.DATE, allowNull: false },
updated_at: { type: dataTypes.DATE, allowNull: false },
deleted_at: { type: dataTypes.DATE, allowNull: true },
token_threshold: { type: dataTypes.STRING, allowNull: true },
featured_in_sidebar: {
type: dataTypes.BOOLEAN,
allowNull: true,
Expand Down
170 changes: 0 additions & 170 deletions packages/commonwealth/server/routes/bulkBalances.ts

This file was deleted.

38 changes: 0 additions & 38 deletions packages/commonwealth/server/routes/getTokenBalance.ts

This file was deleted.

48 changes: 0 additions & 48 deletions packages/commonwealth/server/routes/setTopicThreshold.ts

This file was deleted.

Loading

0 comments on commit 4f8f902

Please sign in to comment.