Skip to content

Commit

Permalink
Remove galachain
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpolman committed Jul 19, 2024
1 parent fc28f95 commit c18f948
Show file tree
Hide file tree
Showing 49 changed files with 54 additions and 954 deletions.
1 change: 0 additions & 1 deletion apps/api/scripts/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import db from '@thxnetwork/api/util/database';
// import main from './src/veTransfer';
// import main from './src/veRewards';
// import main from './src/time';
// import main from './src/galachain';
// import main from './src/sdk';
// import main from './src/vethx';
// import main from './src/ipfs';
Expand Down
83 changes: 0 additions & 83 deletions apps/api/scripts/src/galachain.ts

This file was deleted.

37 changes: 0 additions & 37 deletions apps/api/src/app/connection-profiles/cpp-curator.json

This file was deleted.

41 changes: 0 additions & 41 deletions apps/api/src/app/connection-profiles/cpp-partner.json

This file was deleted.

59 changes: 0 additions & 59 deletions apps/api/src/app/connection-profiles/cpp-users.json

This file was deleted.

9 changes: 3 additions & 6 deletions apps/api/src/app/controllers/erc1155/token/list.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Request, Response } from 'express';
import { ERC1155Token, ERC1155TokenDocument } from '@thxnetwork/api/models/ERC1155Token';
import { query } from 'express-validator';
import { BadRequestError } from '@thxnetwork/api/util/errors';
import { PromiseParser } from '@thxnetwork/api/util';
import SafeService from '@thxnetwork/api/services/SafeService';
import ERC1155Service from '@thxnetwork/api/services/ERC1155Service';

Expand All @@ -13,7 +14,7 @@ const controller = async (req: Request, res: Response) => {
if (!wallet) throw new BadRequestError('Wallet not found');

const tokens = await ERC1155Token.find({ walletId: wallet._id, chainId });
const results = await Promise.allSettled(
const results = await PromiseParser.parse(
tokens.map(async (token: ERC1155TokenDocument) => {
const erc1155 = await ERC1155Service.findById(token.erc1155Id);
if (!erc1155) throw new BadRequestError('ERC1155 not found');
Expand All @@ -24,12 +25,8 @@ const controller = async (req: Request, res: Response) => {
return Object.assign(token.toJSON() as TERC1155Token, { metadata, nft: erc1155 });
}),
);
const response = results
.reverse()
.filter((result) => result.status === 'fulfilled')
.map((result: any) => result.value);

res.json(response);
res.json(results.reverse());
};

export { controller, validation };
10 changes: 3 additions & 7 deletions apps/api/src/app/controllers/erc721/token/list.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ERC721Token, ERC721TokenDocument, ERC721Metadata } from '@thxnetwork/ap
import { BadRequestError } from '@thxnetwork/api/util/errors';
import ERC721Service from '@thxnetwork/api/services/ERC721Service';
import SafeService from '@thxnetwork/api/services/SafeService';
import { PromiseParser } from '@thxnetwork/api/util';

const validation = [query('walletId').isMongoId(), query('chainId').isInt()];

Expand All @@ -13,7 +14,7 @@ const controller = async (req: Request, res: Response) => {
if (!wallet) throw new BadRequestError('Wallet not found');

const tokens = await ERC721Token.find({ walletId: wallet.id, chainId });
const results = await Promise.allSettled(
const results = await PromiseParser.parse(
tokens.map(async (token: ERC721TokenDocument) => {
const erc721 = await ERC721Service.findById(token.erc721Id);
if (!erc721) return;
Expand All @@ -25,12 +26,7 @@ const controller = async (req: Request, res: Response) => {
}),
);

const response = results
.reverse()
.filter((result) => result.status === 'fulfilled')
.map((result: any) => result.value);

res.json(response);
res.json(results.reverse());
};

export { controller, validation };
7 changes: 0 additions & 7 deletions apps/api/src/app/controllers/pools/get.controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Request, Response } from 'express';
import { param } from 'express-validator';
import { Participant, Widget, Wallet, Event, Identity } from '@thxnetwork/api/models';
import { ethers } from 'ethers';
import PoolService from '@thxnetwork/api/services/PoolService';
import BrandService from '@thxnetwork/api/services/BrandService';

Expand All @@ -10,12 +9,6 @@ const validation = [param('id').isMongoId()];
const controller = async (req: Request, res: Response) => {
const pool = await PoolService.getById(req.params.id);

// Create a galachain private key if none exists
if (!pool.settings.galachainPrivateKey) {
const privateKey = ethers.Wallet.createRandom().privateKey;
await pool.updateOne({ 'settings.galachainPrivateKey': privateKey });
}

// Fetch all other campaign entities
const [widget, brand, wallets, collaborators, owner, events, identities, subscriberCount] = await Promise.all([
Widget.findOne({ poolId: req.params.id }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ import {
RewardCoin,
RewardDiscordRole,
RewardCustom,
RewardGalachain,
ERC20,
ERC721,
ERC1155,
} from '@thxnetwork/api/models';
import { ChainId, RewardVariant } from '@thxnetwork/common/enums';
import { RewardVariant } from '@thxnetwork/common/enums';
import PoolService from '@thxnetwork/api/services/PoolService';
import ERC20Service from '@thxnetwork/api/services/ERC20Service';
import SafeService from '@thxnetwork/api/services/SafeService';

const validation = [
Expand All @@ -39,7 +37,6 @@ const controller = async (req: Request, res: Response) => {
{ $unionWith: { coll: RewardCoupon.collection.name } },
{ $unionWith: { coll: RewardCustom.collection.name } },
{ $unionWith: { coll: RewardDiscordRole.collection.name } },
{ $unionWith: { coll: RewardGalachain.collection.name } },
{ $match },
];
const arr = await Promise.all(
Expand Down
9 changes: 0 additions & 9 deletions apps/api/src/app/controllers/pools/rewards/post.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,6 @@ const validationBaseQuest = [
body('metadata').optional().isString(),
// DiscordRole
body('discordRoleId').optional().isString(),
// Galachain
body('contractChannelName').optional().isString(),
body('contractChaincodeName').optional().isString(),
body('contractContractName').optional().isString(),
body('tokenCollection').optional().isString(),
body('tokenCategory').optional().isString(),
body('tokenType').optional().isString(),
body('tokenAdditionalKey').optional().isString(),
body('amount').optional().isInt({ gt: 0 }),
];

const validation = [param('id').isMongoId(), ...validationBaseQuest];
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/app/controllers/rewards/list.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ const controller = async (req: Request, res: Response) => {
const pool = await PoolService.getById(req.header('X-PoolId'));
const account = sub && (await AccountProxy.findById(sub));

const [coin, nft, custom, coupon, discordRole, galachain] = await RewardService.list({
const [coin, nft, custom, coupon, discordRole] = await RewardService.list({
pool,
account,
});

res.json({ coin, nft, custom, coupon, discordRole, galachain });
res.json({ coin, nft, custom, coupon, discordRole });
};

export { controller };
3 changes: 1 addition & 2 deletions apps/api/src/app/jobs/updateCampaignRanks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
RewardCustom,
RewardCoupon,
RewardDiscordRole,
RewardGalachain,
QuestDaily,
QuestInvite,
QuestSocial,
Expand All @@ -19,7 +18,7 @@ import { logger } from '../util/logger';
export async function updateCampaignRanks() {
try {
const questModels = [QuestDaily, QuestInvite, QuestSocial, QuestCustom, QuestWeb3, QuestGitcoin];
const rewardModels = [RewardCoin, RewardNFT, RewardCustom, RewardCoupon, RewardDiscordRole, RewardGalachain];
const rewardModels = [RewardCoin, RewardNFT, RewardCustom, RewardCoupon, RewardDiscordRole];
const questLookupStages = questModels.map((model) => {
return {
$lookup: {
Expand Down
Loading

0 comments on commit c18f948

Please sign in to comment.