Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vouched projects and superfluid Base improvements #1897

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6ba562f
throw error on un-vouching the givbackseligible projects
MohammadPCh Oct 27, 2024
5565767
update message
MohammadPCh Oct 27, 2024
a744af6
optimize the approveMultipleProjects
MohammadPCh Oct 27, 2024
8d017d1
make projects verified if they become givbacksEligible
MohammadPCh Oct 27, 2024
7db802f
prevent approve or reject draft projects
MohammadPCh Oct 28, 2024
a680fa2
Merge branch 'staging' into update-verify-approve-conditions
MohammadPCh Oct 29, 2024
f33cb33
fix records
MohammadPCh Oct 29, 2024
7c23f75
fix conditions
MohammadPCh Oct 29, 2024
102ce11
use redirectUrl
MohammadPCh Oct 29, 2024
d23a58a
fix tests
MohammadPCh Oct 29, 2024
4d8b591
add unverifyProjectsTestCases
MohammadPCh Oct 29, 2024
9d99aff
add test:projectVerificationTab
MohammadPCh Oct 29, 2024
4d82302
temporary comment
MohammadPCh Oct 29, 2024
52cfb82
fix typo
MohammadPCh Nov 4, 2024
b3dfb59
send email when project verification status changed
MohammadPCh Nov 4, 2024
baa24d1
Feat/Generating public user data
kkatusic Dec 3, 2024
e5605eb
Merge branch 'staging' into feat/user_sitemap_list
kkatusic Dec 5, 2024
fd8ea0e
added tests for querying user basic data
kkatusic Dec 5, 2024
e89c1ea
add includeUnlisted to FilterProjectQueryInputParams
MohammadPCh Dec 9, 2024
92f15c9
return proper projects
MohammadPCh Dec 9, 2024
2051be0
add recipient address to streams when nonexistent (#1890)
CarlosQ96 Dec 9, 2024
d6e3888
Merge branch 'master' into staging
CarlosQ96 Dec 10, 2024
d12453d
Merge pull request #1889 from Giveth/fetch-unlisted-projects
MohammadPCh Dec 10, 2024
f0c3fc8
Superfluid Base Support (#1893)
CarlosQ96 Dec 17, 2024
445fe68
Merge pull request #1866 from Giveth/update-verify-approve-conditions
divine-comedian Dec 18, 2024
82dfc17
remove project validation from anchor contract
CarlosQ96 Dec 21, 2024
b41c543
Merge pull request #1887 from Giveth/feat/user_sitemap_list
kkatusic Dec 26, 2024
ff91c4d
Add networkId logic to superfluid subgraphs (#1896)
CarlosQ96 Dec 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions migration/data/seedTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1695,6 +1695,16 @@ const seedTokens: ITokenData[] = [
coingeckoId: 'degen-base',
isGivbackEligible: false,
},
// cbBTC - https://basescan.org/token/0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf
{
name: 'Coinbase Wrapped BTC',
symbol: 'cbBTC',
address: '0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf',
decimals: 8,
networkId: NETWORK_IDS.BASE_MAINNET,
coingeckoId: 'coinbase-wrapped-btc',
isGivbackEligible: false,
},
// Osaka Protocol - https://basescan.org/token/0xbFd5206962267c7b4b4A8B3D76AC2E1b2A5c4d5e
{
name: 'Osaka Protocol',
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
"test:qfRoundService": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/services/qfRoundService.test.ts",
"test:project": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/entities/project.test.ts",
"test:projectsTab": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/server/adminJs/tabs/projectsTab.test.ts",
"test:projectVerificationTab": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/server/adminJs/tabs/projectVerificationTab.test.ts",
"test:syncUsersModelScore": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/services/cronJobs/syncUsersModelScore.test.ts",
"test:notifyDonationsWithSegment": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/services/cronJobs/notifyDonationsWithSegment.test.ts",
"test:checkProjectVerificationStatus": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/services/cronJobs/checkProjectVerificationStatus.test.ts",
Expand Down
52 changes: 43 additions & 9 deletions src/adapters/superFluid/superFluidAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
import axios from 'axios';
import { logger } from '../../utils/logger';
import { isProduction } from '../../utils/utils';
import {
FlowUpdatedEvent,
SuperFluidAdapterInterface,
} from './superFluidAdapterInterface';
import { NETWORK_IDS } from '../../provider';

const superFluidGraphqlUrl =
const superFluidGraphqlPolygonUrl =
'https://subgraph-endpoints.superfluid.dev/optimism-mainnet/protocol-v1';
const superFluidGraphqlStagingUrl =
const superFluidGraphqlPolygonStagingUrl =
'https://optimism-sepolia.subgraph.x.superfluid.dev';
const superFluidGraphBaseUrl =
'https://subgraph-endpoints.superfluid.dev/base-mainnet/protocol-v1';

const subgraphUrl = isProduction
? superFluidGraphqlUrl
: superFluidGraphqlStagingUrl;
const subgraphUrlMap = {
[NETWORK_IDS.OPTIMISTIC]: superFluidGraphqlPolygonUrl,
[NETWORK_IDS.OPTIMISM_SEPOLIA]: superFluidGraphqlPolygonStagingUrl,
[NETWORK_IDS.BASE_MAINNET]: superFluidGraphBaseUrl,
[NETWORK_IDS.BASE_SEPOLIA]: superFluidGraphBaseUrl,
};

// Function to retrieve the subgraph URL for a given network ID
const getSubgraphUrl = (networkId: number) => {
const url = subgraphUrlMap[networkId];
if (!url) {
throw new Error(`No subgraph URL found for network ID: ${networkId}`);
}
return url;
};

// Define your GraphQL query as a string and prepare your variables
const accountQuery = `
Expand Down Expand Up @@ -169,8 +183,9 @@ export class SuperFluidAdapter implements SuperFluidAdapterInterface {
*/

// Optimism works
async accountBalance(accountId: string) {
async accountBalance(accountId: string, networkId: number) {
try {
const subgraphUrl = getSubgraphUrl(networkId);
const response = await axios.post(subgraphUrl, {
query: accountQuery,
variables: {
Expand All @@ -189,12 +204,21 @@ export class SuperFluidAdapter implements SuperFluidAdapterInterface {
sender: string;
flowRate: string;
transactionHash: string;
networkId: number;
}): Promise<FlowUpdatedEvent | undefined> {
try {
const subgraphUrl = getSubgraphUrl(params.networkId);
const whereParams = {
receiver: params.receiver,
sender: params.sender,
flowRate: params.flowRate,
transactionHash: params.transactionHash,
};

const response = await axios.post(subgraphUrl, {
query: getFlowsQuery,
variables: {
where: params,
where: whereParams,
orderBy: 'timestamp',
orderDirection: 'asc',
},
Expand All @@ -213,14 +237,24 @@ export class SuperFluidAdapter implements SuperFluidAdapterInterface {
sender: string;
flowRate: string;
timestamp_gt: number;
networkId: number;
}): Promise<FlowUpdatedEvent | undefined> {
try {
const subgraphUrl = getSubgraphUrl(params.networkId);

logger.debug('getFlowByReceiverSenderFlowRate has been called', params);

const whereParams = {
receiver: params.receiver,
sender: params.sender,
flowRate: params.flowRate,
timestamp_gt: params.timestamp_gt,
};

const response = await axios.post(subgraphUrl, {
query: getFlowsQuery,
variables: {
where: params,
where: whereParams,
orderBy: 'timestamp',
orderDirection: 'asc',
},
Expand Down
4 changes: 3 additions & 1 deletion src/adapters/superFluid/superFluidAdapterInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@ export interface SuperFluidAdapterInterface {
currency: string;
recurringDonationTxHash: string;
}): Promise<any>;
accountBalance(accountId: string): Promise<any>;
accountBalance(accountId: string, networkId: number): Promise<any>;
getFlowByTxHash(params: {
receiver: string;
sender: string;
flowRate: string;
transactionHash: string;
networkId: number;
}): Promise<FlowUpdatedEvent | undefined>;
getFlowByReceiverSenderFlowRate(params: {
receiver: string;
sender: string;
flowRate: string;
timestamp_gt: number;
networkId: number;
}): Promise<FlowUpdatedEvent | undefined>;
}
2 changes: 2 additions & 0 deletions src/adapters/superFluid/superFluidMockAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export class SuperFluidMockAdapter implements SuperFluidAdapterInterface {
sender: string;
flowRate: string;
timestamp_gt: number;
networkId: number;
}): Promise<FlowUpdatedEvent | undefined> {
return Promise.resolve(undefined);
}
Expand All @@ -94,6 +95,7 @@ export class SuperFluidMockAdapter implements SuperFluidAdapterInterface {
sender: string;
flowRate: string;
transactionHash: string;
networkId: number;
}): Promise<FlowUpdatedEvent | undefined> {
const { receiver, sender, flowRate, transactionHash } = params;
return Promise.resolve({
Expand Down
15 changes: 15 additions & 0 deletions src/entities/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,18 @@ export class User extends BaseEntity {
return `givethId-${this.id}`;
}
}

@ObjectType()
export class UserPublicData extends BaseEntity {
@Field(_type => String, { nullable: true })
firstName?: string;

@Field(_type => String, { nullable: true })
lastName?: string;

@Field(_type => String, { nullable: true })
name?: string;

@Field(_type => String, { nullable: true })
walletAddress?: string;
}
68 changes: 68 additions & 0 deletions src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,76 @@ export const superTokensToToken = {
DAIx: 'DAI',
OPx: 'OP',
GIVx: 'GIV',
DEGENx: 'DEGEN',
cbBTCx: 'cbBTC',
};

export const superTokensBase = [
{
underlyingToken: {
decimals: 6,
id: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
name: 'USD Coin',
symbol: 'USDC',
coingeckoId: 'usd-coin',
},
decimals: 18,
id: '0xD04383398dD2426297da660F9CCA3d439AF9ce1b',
name: 'Super USD Coin',
symbol: 'USDCx',
isSuperToken: true,
coingeckoId: 'usd-coin',
},
{
underlyingToken: {
name: 'Ethereum',
symbol: 'ETH',
decimals: 18,
id: '0x0000000000000000000000000000000000000000',
},
decimals: 18,
id: '0x46fd5cfB4c12D87acD3a13e92BAa53240C661D93',
name: 'Super ETH',
symbol: 'ETHx',
},
{
underlyingToken: {
decimals: 8,
id: '0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf',
name: 'Coinbase Wrapped BTC',
symbol: 'cbBTC',
},
decimals: 18,
id: '0xDFd428908909CB5E24F5e79E6aD6BDE10bdf2327',
name: 'Super Coinbase Wrapped BTC',
symbol: 'cbBTCx',
},
{
underlyingToken: {
decimals: 18,
id: '0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb',
name: 'DAI Stablecoin',
symbol: 'DAI',
},
decimals: 18,
id: '0x708169c8C87563Ce904E0a7F3BFC1F3b0b767f41',
name: 'Super DAI Stablecoin',
symbol: 'DAIx',
},
{
underlyingToken: {
decimals: 18,
id: '0x4ed4E862860beD51a9570b96d89aF5E1B0Efefed',
name: 'Degen',
symbol: 'DEGEN',
},
decimals: 18,
id: '0x1efF3Dd78F4A14aBfa9Fa66579bD3Ce9E1B30529',
name: 'Super Degen',
symbol: 'DEGENx',
},
];

export const superTokens = [
{
underlyingToken: {
Expand Down
12 changes: 9 additions & 3 deletions src/repositories/projectRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export type FilterProjectQueryInputParams = {
qfRoundId?: number;
activeQfRoundId?: number;
qfRoundSlug?: string;
includeUnlisted?: boolean;
};
export const filterProjectsQuery = (params: FilterProjectQueryInputParams) => {
const {
Expand All @@ -97,6 +98,7 @@ export const filterProjectsQuery = (params: FilterProjectQueryInputParams) => {
qfRoundId,
qfRoundSlug,
activeQfRoundId,
includeUnlisted,
} = params;

let query = Project.createQueryBuilder('project')
Expand All @@ -122,11 +124,16 @@ export const filterProjectsQuery = (params: FilterProjectQueryInputParams) => {
'projectPower.totalPower',
'projectPower.powerRank',
'projectPower.round',
])
.where(
]);

if (includeUnlisted) {
query = query.where(`project.statusId = ${ProjStatus.active}`);
} else {
query = query.where(
`project.statusId = ${ProjStatus.active} AND project.reviewStatus = :reviewStatus`,
{ reviewStatus: ReviewStatus.Listed },
);
}

const isFilterByQF =
!!filters?.find(f => f === FilterField.ActiveQfRound) && activeQfRoundId;
Expand Down Expand Up @@ -255,7 +262,6 @@ export const filterProjectsQuery = (params: FilterProjectQueryInputParams) => {
break;
case SortingField.BestMatch:
break;

default:
query
.addOrderBy('projectInstantPower.totalPower', OrderDirection.DESC)
Expand Down
22 changes: 9 additions & 13 deletions src/repositories/projectVerificationRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,24 +417,20 @@ export const approveProject = async (params: {
return project.save();
};

export const approveMultipleProjects = async (params: {
export const approveMultipleProjects = async ({
approved,
projectsIds,
}: {
approved: boolean;
projectsIds: string[] | number[];
}): Promise<UpdateResult> => {
if (params.approved) {
await Project.query(`
UPDATE project
SET "verificationStatus" = NULL
WHERE id IN (${params.projectsIds?.join(',')})
`);
}

return Project.createQueryBuilder('project')
.update<Project>(Project, {
isGivbackEligible: params.approved,
.update<Project>(Project)
.set({
isGivbackEligible: approved,
...(approved && { verificationStatus: null, verified: true }),
})
.where('project.id IN (:...ids)')
.setParameter('ids', params.projectsIds)
.where('project.id IN (:...ids)', { ids: projectsIds })
.returning('*')
.updateEntity(true)
.execute();
Expand Down
Loading
Loading