Skip to content

Commit

Permalink
remove recurring donation codes
Browse files Browse the repository at this point in the history
  • Loading branch information
ae2079 committed Aug 8, 2024
1 parent e406ca0 commit 15af4e0
Show file tree
Hide file tree
Showing 49 changed files with 28 additions and 8,071 deletions.
14 changes: 0 additions & 14 deletions config/example.env
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,6 @@ DONATION_SAVE_BACKUP_DATABASE=
# Default value is saveBackup
DONATION_SAVE_BACKUP_ADAPTER=saveBackup

ENABLE_UPDATE_RECURRING_DONATION_STREAM=true

# Default value is 1
NUMBER_OF_UPDATE_RECURRING_DONATION_CONCURRENT_JOB=1

# Default value is 0 0 * * * that means one day at 00:00
UPDATE_RECURRING_DONATIONS_STREAM_CRONJOB=0 0 * * *

# Default value is 0.4
PROJECT_SEARCH_SIMILARITY_THRESHOLD=0.4

Expand All @@ -253,12 +245,6 @@ QfRound_PASSPORT_SCORE_CHECK_START_TIMESTAMP_IN_SECONDS=
ORTTO_API_KEY=FAKE_API_KEY
ORTTO_PERSON_API=https://api.ap3api.com/v1/person/merge


RECURRING_DONATION_VERIFICATION_EXPIRATION_HOURS=24
NUMBER_OF_VERIFY_RECURRING_DONATION_CONCURRENT_JOB=1
ENABLE_DRAFT_RECURRING_DONATION=true
DRAFT_RECURRING_DONATION_MATCH_EXPIRATION_HOURS=24

OPTIMISTIC_SEPOLIA_SCAN_API_KEY=

BASE_SCAN_API_URL=https://api.basescan.org/api
Expand Down
5 changes: 0 additions & 5 deletions config/test.env
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ CHAINVINE_ADAPTER=mock
CHAINVINE_API_ENABLE_TEST_MODE=true
# We should not try to verify donaitons after some hours, because checking old donations would make lots of requests to web3 providers
DONATION_VERIFICAITON_EXPIRATION_HOURS=24
RECURRING_DONATION_VERIFICAITON_EXPIRATION_HOURS=24

# We need it for monoswap
POLYGON_MAINNET_NODE_HTTP_URL=https://polygon-rpc.com
Expand Down Expand Up @@ -205,10 +204,6 @@ INSERT_USER_PASSPORT_SCORE_FOR_QF_ROUND_CRONJOB_TIME=0 0 * * *
# Optional
QfRound_PASSPORT_SCORE_CHECK_START_TIMESTAMP_IN_SECONDS=

ENABLE_DRAFT_RECURRING_DONATION=true
DRAFT_RECURRING_DONATION_MATCH_EXPIRATION_HOURS=24


OPTIMISTIC_SEPOLIA_SCAN_API_KEY=

SUPER_FLUID_ADAPTER=superfluid
Expand Down
3 changes: 1 addition & 2 deletions docs/adminPermissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ Below table has been generated by https://www.tablesgenerator.com/markdown_table
| Broadcast Notification | list, new, show | list, show | list, show | list, show | - |
| Project Update | list, show, addFeaturedProjectUpdate | list, show | list, show | list, show, addFeaturedProjectUpdate | - |
| Sybil | list, show, new, edit, delete, bulkDelete | list, show | list, show | list, show | list, show, new, edit, delete, bulkDelete |
| Project Fraud | list, show, new, edit, delete, bulkDelete | list, show | list, show | list, show | list, show, new, edit, delete, bulkDelete |
| Recurring donation | list, show, new, edit, delete, bulkDelete | list, show | list, show | list, show | - | |
| Project Fraud | list, show, new, edit, delete, bulkDelete | list, show | list, show | list, show | list, show, new, edit, delete, bulkDelete |
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,11 @@
"test:broadcastNotificationRepository": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/repositories/broadcastNotificationRepository.test.ts",
"test:projectAddressRepository": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/repositories/projectAddressRepository.test.ts",
"test:anchorContractAddressRepository": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/repositories/anchorContractAddressRepository.test.ts",
"test:recurringDonationRepository": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/repositories/recurringDonationRepository.test.ts",
"test:userPassportScoreRepository": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/repositories/userPassportScoreRepository.test.ts",
"test:recurringDonationService": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/services/recurringDonationService.test.ts",
"test:anchorContractAddressResolver": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/resolvers/anchorContractAddressResolver.test.ts",
"test:recurringDonationResolver": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/resolvers/recurringDonationResolver.test.ts",
"test:donationService": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/repositories/qfRoundHistoryRepository.test.ts ./src/services/donationService.test.ts",
"test:draftDonationService": "NODE_ENV=test mocha -t 99999 ./test/pre-test-scripts.ts src/services/chains/evm/draftDonationService.test.ts src/repositories/draftDonationRepository.test.ts src/workers/draftDonationMatchWorker.test.ts src/resolvers/draftDonationResolver.test.ts",
"test:draftDonationWorker": "NODE_ENV=test mocha -t 99999 ./test/pre-test-scripts.ts src/workers/draftDonationMatchWorker.test.ts",
"test:draftRecurringDonationService": "NODE_ENV=test mocha -t 99999 ./test/pre-test-scripts.ts src/services/chains/evm/draftRecurringDonationService.test.ts",
"test:userService": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/services/userService.test.ts",
"test:lostDonations": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/services/cronJobs/importLostDonationsJob.test.ts",
"test:reactionsService": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/services/reactionsService.test.ts",
Expand Down
11 changes: 1 addition & 10 deletions src/adapters/notifications/MockNotificationAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { Donation } from '../../entities/donation';
import { Project } from '../../entities/project';
import { User } from '../../entities/user';
import { logger } from '../../utils/logger';
import { RecurringDonation } from '../../entities/recurringDonation';

export class MockNotificationAdapter implements NotificationAdapterInterface {
async subscribeOnboarding(params: { email: string }): Promise<void> {
Expand Down Expand Up @@ -40,17 +39,9 @@ export class MockNotificationAdapter implements NotificationAdapterInterface {
}

donationReceived(params: {
donation: Donation | RecurringDonation;
donation: Donation;
project: Project;
}): Promise<void> {
if (params.donation instanceof RecurringDonation) {
logger.debug('MockNotificationAdapter donationReceived', {
projectSlug: params.project.slug,
donationTxHash: params.donation.txHash,
donationNetworkId: params.donation.networkId,
});
return Promise.resolve(undefined);
}
logger.debug('MockNotificationAdapter donationReceived', {
projectSlug: params.project.slug,
donationTxHash: params.donation.transactionId,
Expand Down
3 changes: 1 addition & 2 deletions src/adapters/notifications/NotificationAdapterInterface.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Donation } from '../../entities/donation';
import { Project } from '../../entities/project';
import { UserStreamBalanceWarning, User } from '../../entities/user';
import { RecurringDonation } from '../../entities/recurringDonation';

export interface BroadCastNotificationInputParams {
broadCastNotificationId: number;
Expand Down Expand Up @@ -41,7 +40,7 @@ export interface NotificationAdapterInterface {
updateOrttoPeople(params: OrttoPerson[]): Promise<void>;

donationReceived(params: {
donation: Donation | RecurringDonation;
donation: Donation;
project: Project;
user: User | null;
}): Promise<void>;
Expand Down
93 changes: 20 additions & 73 deletions src/adapters/notifications/NotificationCenterAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ import {
} from '../../repositories/userRepository';
import { buildProjectLink } from './NotificationCenterUtils';
import { buildTxLink } from '../../utils/networks';
import { RecurringDonation } from '../../entities/recurringDonation';
import { getTokenPrice } from '../../services/priceService';
import { Token } from '../../entities/token';
import { toFixNumber } from '../../services/donationService';
import { findOrganizationById } from '../../repositories/organizationRepository';

const notificationCenterUsername = process.env.NOTIFICATION_CENTER_USERNAME;
Expand Down Expand Up @@ -123,7 +119,6 @@ export class NotificationCenterAdapter implements NotificationAdapterInterface {
metadata: {
...payload,
networkName,
recurringDonationTab: `${process.env.WEBSITE_URL}/account?tab=recurring-donations`,
},
segment: {
payload,
Expand Down Expand Up @@ -213,44 +208,21 @@ export class NotificationCenterAdapter implements NotificationAdapterInterface {
}

async donationReceived(params: {
donation: Donation | RecurringDonation;
donation: Donation;
project: Project;
user: User | null;
}): Promise<void> {
const { project, donation, user } = params;
const isRecurringDonation = donation instanceof RecurringDonation;
let transactionId: string, transactionNetworkId: number;
if (isRecurringDonation) {
transactionId = donation.txHash;
transactionNetworkId = donation.networkId;
const token = await Token.findOneBy({
symbol: donation.currency,
networkId: transactionNetworkId,
});
const amount =
(Number(donation.flowRate) / 10 ** (token?.decimals || 18)) * 2628000; // convert flowRate in wei from per second to per month
const price = await getTokenPrice(transactionNetworkId, token!);
const donationValueUsd = toFixNumber(amount * price, 4);
logger.debug('donationReceived (recurring) has been called', {
params,
amount,
price,
donationValueUsd,
token,
});
if (donationValueUsd <= 5) return;
} else {
transactionId = donation.transactionId;
transactionNetworkId = donation.transactionNetworkId;
const donationValueUsd = donation.valueUsd;
logger.debug('donationReceived has been called', {
params,
transactionId,
transactionNetworkId,
donationValueUsd,
});
if (donationValueUsd <= 1) return;
}
const transactionId = donation.transactionId;
const transactionNetworkId = donation.transactionNetworkId;
const donationValueUsd = donation.valueUsd;
logger.debug('donationReceived has been called', {
params,
transactionId,
transactionNetworkId,
donationValueUsd,
});
if (donationValueUsd <= 1) return;

await sendProjectRelatedNotificationsQueue.add({
project,
Expand All @@ -268,12 +240,7 @@ export class NotificationCenterAdapter implements NotificationAdapterInterface {
}),
},
trackId:
'donation-received-' +
transactionNetworkId +
'-' +
transactionId +
'-' +
isRecurringDonation,
'donation-received-' + transactionNetworkId + '-' + transactionId,
});
}

Expand Down Expand Up @@ -957,35 +924,16 @@ export class NotificationCenterAdapter implements NotificationAdapterInterface {
const getEmailDataDonationAttributes = async (params: {
user: User;
project: Project;
donation: Donation | RecurringDonation;
donation: Donation;
}) => {
const { user, project, donation } = params;
const isRecurringDonation = donation instanceof RecurringDonation;
let amount: number,
transactionId: string,
transactionNetworkId: number,
toWalletAddress: string | undefined,
donationValueUsd: number | undefined,
donationValueEth: number | undefined,
transakStatus: string | undefined;
if (isRecurringDonation) {
transactionId = donation.txHash;
transactionNetworkId = donation.networkId;
const token = await Token.findOneBy({
symbol: donation.currency,
networkId: transactionNetworkId,
});
amount =
(Number(donation.flowRate) / 10 ** (token?.decimals || 18)) * 2628000; // convert flowRate in wei from per second to per month
} else {
amount = Number(donation.amount);
transactionId = donation.transactionId;
transactionNetworkId = donation.transactionNetworkId;
toWalletAddress = donation.toWalletAddress.toLowerCase();
donationValueUsd = donation.valueUsd;
donationValueEth = donation.valueEth;
transakStatus = donation.transakStatus;
}
const amount = Number(donation.amount);
const transactionId = donation.transactionId;
const transactionNetworkId = donation.transactionNetworkId;
const toWalletAddress = donation.toWalletAddress.toLowerCase();
const donationValueUsd = donation.valueUsd;
const donationValueEth = donation.valueEth;
const transakStatus = donation.transakStatus;
return {
email: user.email,
title: project.title,
Expand All @@ -994,7 +942,6 @@ const getEmailDataDonationAttributes = async (params: {
slug: project.slug,
projectLink: `${process.env.WEBSITE_URL}/project/${project.slug}`,
amount,
isRecurringDonation,
token: donation.currency,
transactionId: transactionId.toLowerCase(),
transactionNetworkId: Number(transactionNetworkId),
Expand Down
47 changes: 0 additions & 47 deletions src/adapters/superFluid/superFluidAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,53 +96,6 @@ const getFlowsQuery = `
},
*/
export class SuperFluidAdapter implements SuperFluidAdapterInterface {
async streamPeriods(params: {
address: string;
chain: number;
start: number;
end: number;
priceGranularity: string;
virtualization: string;
currency: string;
recurringDonationTxHash: string;
}) {
const {
address,
chain,
start,
end,
priceGranularity,
virtualization,
currency,
recurringDonationTxHash,
} = params;
try {
const response = await axios.get(
'https://accounting.superfluid.dev/v1/stream-periods',
{
params: {
addresses: address,
chains: chain,
start,
end,
priceGranularity,
virtualization,
currency,
},
},
);
// Fetch the stream table with the recurringDonation TxHash
const filteredData = response.data.filter(streamTable =>
streamTable.startedAtEvent
.toLowerCase()
.includes(recurringDonationTxHash.toLowerCase()),
);
return filteredData[0];
} catch (e) {
logger.error('superFluidAdaptor.streamPeriods error', e);
}
}

/* RESPONSE
{
"data": {
Expand Down
10 changes: 0 additions & 10 deletions src/adapters/superFluid/superFluidAdapterInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@ export interface FlowUpdatedEvent {
}

export interface SuperFluidAdapterInterface {
streamPeriods(params: {
address: string;
chain: number;
start: number;
end: number;
priceGranularity: string;
virtualization: string;
currency: string;
recurringDonationTxHash: string;
}): Promise<any>;
accountBalance(accountId: string): Promise<any>;
getFlowByTxHash(params: {
receiver: string;
Expand Down
51 changes: 0 additions & 51 deletions src/adapters/superFluid/superFluidMockAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,6 @@ import {
} from './superFluidAdapterInterface';

export class SuperFluidMockAdapter implements SuperFluidAdapterInterface {
async streamPeriods() {
return {
id: '0x8c3bf3eb2639b2326ff937d041292da2e79adbbf-0xd964ab7e202bab8fbaa28d5ca2b2269a5497cf68-0x1305f6b6df9dc47159d12eb7ac2804d4a33173c2-0.0-0.0',
flowRate: '462962962962962',
startedAtTimestamp: '1617118948',
startedAtBlockNumber: '12658248',
stoppedAtTimestamp: '1626702963',
stoppedAtBlockNumber: '17035432',
totalAmountStreamed: '4437043981481472252430',
chainId: 137,
token: {
id: '0x1305f6b6df9dc47159d12eb7ac2804d4a33173c2',
symbol: 'DAIx',
name: 'Super DAI (PoS)',
underlyingAddress: '0x8f3cf7ad23cd3cadbd9735aff958023239c6a063',
},
sender: '0x8c3bf3eb2639b2326ff937d041292da2e79adbbf',
receiver: '0xd964ab7e202bab8fbaa28d5ca2b2269a5497cf68',
startedAtEvent:
'0x241d2db890d58d2d9980ad214580c4f3ea22021e2b8dd89387a6257fceebef9d',
stoppedAtEvent:
'0x4d8e9edec495fdcdeece9061267f7eef1a96923378c8940ca5ab09439d08d2fd',
virtualPeriods: [
{
startTime: 1617249600,
endTime: 1619827199,
amount: '-1193332870370367888200',
amountFiat: '-1193.9934002402638654',
},
{
startTime: 1619827200,
endTime: 1622505599,
amount: '-1239999537037034457800',
amountFiat: '-1241.1103421307001618',
},
{
startTime: 1622505600,
endTime: 1625097599,
amount: '-1199999537037034541000',
amountFiat: '-1202.7360631768932664',
},
{
startTime: 1625097600,
endTime: 1626702963,
amount: '-743223611111109565210',
amountFiat: '-745.57117099624968902',
},
],
};
}

async accountBalance() {
return {
id: '0x0000000000000000000000000000000000000000',
Expand Down
Loading

0 comments on commit 15af4e0

Please sign in to comment.