Skip to content

Commit

Permalink
refactor(app, iam, platforms): adds ff for twitter stamps
Browse files Browse the repository at this point in the history
  • Loading branch information
aminah-io committed Jul 14, 2023
1 parent 5ef9e1b commit 349d30b
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 59 deletions.
1 change: 1 addition & 0 deletions app/.env-example.env
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ NEXT_PUBLIC_FF_HOLONYM_STAMP=on
NEXT_PUBLIC_FF_NEW_GITHUB_STAMPS=on
NEXT_PUBLIC_FF_ONE_CLICK_VERIFICATION=on
NEXT_PUBLIC_FF_LIVE_ALLO_SCORE=on
NEXT_PUBLIC_FF_NEW_TWITTER_STAMPS=on

NEXT_PUBLIC_CERAMIC_CACHE_ENDPOINT=http://localhost:8002/

Expand Down
3 changes: 2 additions & 1 deletion iam/.env-example.env
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ PASSPORT_STAMP_METADATA_PATH=http://localhost:3000/stampMetadata.json

# Use this environment variable to enable/disable testnets on on-chain-based stamp evaluation.
INCLUDE_TESTNETS=false
ZKSYNC_ERA_MAINNET_ENDPOINT=zksync_mainnet_endpoint
ZKSYNC_ERA_MAINNET_ENDPOINT=zksync_mainnet_endpoint
FF_NEW_TWITTER_STAMPS=on
156 changes: 100 additions & 56 deletions platforms/src/Twitter/Providers-config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { PlatformSpec, PlatformGroupSpec, Provider } from "../types";
import { TwitterAccountAgeProvider } from "./Providers/twitterAccountAge";
import { TwitterTweetDaysProvider } from "./Providers/twitterTweetDays";
import * as legacyProviders from "./Providers/legacy";

export const PlatformDetails: PlatformSpec = {
icon: "./assets/twitterStampIcon.svg",
Expand All @@ -10,60 +11,103 @@ export const PlatformDetails: PlatformSpec = {
connectMessage: "Connect Account",
};

export const ProviderConfig: PlatformGroupSpec[] = [
{
platformGroup: "Account Creation",
providers: [
{
title: "Created at least 180 days ago",
name: "twitterAccountAgeGte#180",
},
{
title: "Created at least 1 year ago",
name: "twitterAccountAgeGte#365",
},
{
title: "Created at least 2 years ago",
name: "twitterAccountAgeGte#730",
},
],
},
{
platformGroup: "Consistent Engagement",
providers: [
{
title: "Tweet on at least 30 distinct days",
name: "twitterTweetDaysGte#30",
},
{
title: "Tweets on at least 60 distinct days",
name: "twitterTweetDaysGte#60",
},
{
title: "Tweets on at least 120 distinct days",
name: "twitterTweetDaysGte#120",
},
],
},
];
let providers: Provider[] = [];
let ProviderConfig: PlatformGroupSpec[] = [];

export const providers: Provider[] = [
new TwitterAccountAgeProvider({
threshold: "180",
}),
new TwitterAccountAgeProvider({
threshold: "365",
}),
new TwitterAccountAgeProvider({
threshold: "730",
}),
new TwitterTweetDaysProvider({
threshold: "30",
}),
new TwitterTweetDaysProvider({
threshold: "60",
}),
new TwitterTweetDaysProvider({
threshold: "120",
}),
];
if (process.env.FF_NEW_TWITTER_STAMPS === "on" || process.env.NEXT_PUBLIC_FF_NEW_TWITTER_STAMPS === "on") {
ProviderConfig = [
{
platformGroup: "Account Creation",
providers: [
{
title: "Created at least 180 days ago",
name: "twitterAccountAgeGte#180",
},
{
title: "Created at least 1 year ago",
name: "twitterAccountAgeGte#365",
},
{
title: "Created at least 2 years ago",
name: "twitterAccountAgeGte#730",
},
],
},
{
platformGroup: "Consistent Engagement",
providers: [
{
title: "Tweet on at least 30 distinct days",
name: "twitterTweetDaysGte#30",
},
{
title: "Tweets on at least 60 distinct days",
name: "twitterTweetDaysGte#60",
},
{
title: "Tweets on at least 120 distinct days",
name: "twitterTweetDaysGte#120",
},
],
},
];
providers = [
new TwitterAccountAgeProvider({
threshold: "180",
}),
new TwitterAccountAgeProvider({
threshold: "365",
}),
new TwitterAccountAgeProvider({
threshold: "730",
}),
new TwitterTweetDaysProvider({
threshold: "30",
}),
new TwitterTweetDaysProvider({
threshold: "60",
}),
new TwitterTweetDaysProvider({
threshold: "120",
}),
];
} else {
ProviderConfig = [
{
platformGroup: "Account Name",
providers: [{ title: "Encrypted", name: "Twitter" }],
},
{
platformGroup: "Tweet/Posts",
providers: [{ title: "More than 10", name: "TwitterTweetGT10" }],
},
{
platformGroup: "Followers",
providers: [
{ title: "More than 100", name: "TwitterFollowerGT100" },
{
title: "More than 500",
name: "TwitterFollowerGT500",
},
{
title: "More than 1000",
name: "TwitterFollowerGTE1000",
},
{
title: "More than 5000",
name: "TwitterFollowerGT5000",
},
],
},
];
providers = [
new legacyProviders.TwitterProvider(),
new legacyProviders.TwitterTweetGT10Provider(),
new legacyProviders.TwitterFollowerGT100Provider(),
new legacyProviders.TwitterFollowerGT500Provider(),
new legacyProviders.TwitterFollowerGTE1000Provider(),
new legacyProviders.TwitterFollowerGT5000Provider(),
];
}

export { providers, ProviderConfig };
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getAuthClient, requestFindMyUser, TwitterContext, TwitterFindMyUserResp
import type { Provider, ProviderOptions } from "../../../types";

// Export a Twitter Provider to carry out OAuth and return a record object
export default class TwitterProvider implements Provider {
export class TwitterProvider implements Provider {
// Give the provider a type so that we can select it with a payload
type = "Twitter";
// Options can be set here and/or via the constructor
Expand Down
3 changes: 3 additions & 0 deletions platforms/src/Twitter/Providers/legacy/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./TwitterAuthProvider";
export * from "./TwitterFollowerProvider";
export * from "./TwitterTweetsProvider";
2 changes: 1 addition & 1 deletion platforms/src/Twitter/Providers/legacy/twitter.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ---- Test subject
import TwitterProvider from "./TwitterAuthProvider";
import { TwitterProvider } from "./TwitterAuthProvider";

import { RequestPayload } from "@gitcoin/passport-types";
import { auth, Client } from "twitter-api-sdk";
Expand Down

0 comments on commit 349d30b

Please sign in to comment.