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

TW-1456: Limit DApps list for iOS #158

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions src/getDAppsStats.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { dappList } from './utils/dapp-list-constants';
import { DAPPS_LIST, IOS_DAPPS_LIST } from './utils/dapp-list-constants';
import logger from './utils/logger';

const getDAppsStats = async () => {
const getDAppsStats = (forIOs: boolean) => {
logger.info('Getting dApps list...');

return {
dApps: dappList
dApps: forIOs ? IOS_DAPPS_LIST : DAPPS_LIST
};
};

Expand Down
10 changes: 7 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@
app.use(cors());
app.use(bodyParser.json());

const dAppsProvider = new SingleQueryDataProvider(15 * 60 * 1000, getDAppsStats);

const androidApp = firebaseAdmin.initializeApp(
{
projectId: 'templewallet-fa3b3'
Expand Down Expand Up @@ -157,12 +155,18 @@
await redisClient.lpush('notifications', JSON.stringify(newNotification));

res.status(200).send({ message: 'Notification added successfully', notification: newNotification });
} catch (error: any) {

Check warning on line 158 in src/index.ts

View workflow job for this annotation

GitHub Actions / Checks if ts and lint works

Unexpected any. Specify a different type

Check warning on line 158 in src/index.ts

View workflow job for this annotation

GitHub Actions / Checks if ts and lint works

Unexpected any. Specify a different type
res.status(500).send({ error: error.message });
}
});

app.get('/api/dapps', makeProviderDataRequestHandler(dAppsProvider));
app.get('/api/dapps', (req, res) => {
const platform = req.query.platform;

const data = getDAppsStats(platform === 'ios');

res.status(200).header('Cache-Control', 'public, max-age=300').send(data);
});

app.get('/api/abtest', (_, res) => {
const data = getABData();
Expand Down Expand Up @@ -335,7 +339,7 @@
await startMagicSquareQuest(req.body);

res.status(200).send({ message: 'Quest successfully started' });
} catch (error: any) {

Check warning on line 342 in src/index.ts

View workflow job for this annotation

GitHub Actions / Checks if ts and lint works

Unexpected any. Specify a different type

Check warning on line 342 in src/index.ts

View workflow job for this annotation

GitHub Actions / Checks if ts and lint works

Unexpected any. Specify a different type
console.error(error);

if (error instanceof CodedError) {
Expand All @@ -349,7 +353,7 @@
app.get('/api/magic-square-quest/participants', basicAuth, async (req, res) => {
try {
res.status(200).send(await getMagicSquareQuestParticipants());
} catch (error: any) {

Check warning on line 356 in src/index.ts

View workflow job for this annotation

GitHub Actions / Checks if ts and lint works

Unexpected any. Specify a different type

Check warning on line 356 in src/index.ts

View workflow job for this annotation

GitHub Actions / Checks if ts and lint works

Unexpected any. Specify a different type
console.error(error);

if (error instanceof CodedError) {
Expand All @@ -363,10 +367,10 @@
app.get('/api/signing-nonce', (req, res) => {
try {
const pkh = req.query.pkh;
if (!pkh || typeof pkh !== 'string') throw new Error('PKH is not a string');

Check warning on line 370 in src/index.ts

View workflow job for this annotation

GitHub Actions / Checks if ts and lint works

Unexpected value in conditional. A boolean expression is required

Check warning on line 370 in src/index.ts

View workflow job for this annotation

GitHub Actions / Checks if ts and lint works

Unexpected value in conditional. A boolean expression is required

res.status(200).send(getSigningNonce(pkh));
} catch (error: any) {

Check warning on line 373 in src/index.ts

View workflow job for this annotation

GitHub Actions / Checks if ts and lint works

Unexpected any. Specify a different type

Check warning on line 373 in src/index.ts

View workflow job for this annotation

GitHub Actions / Checks if ts and lint works

Unexpected any. Specify a different type
console.error(error);

if (error instanceof CodedError) {
Expand Down
39 changes: 37 additions & 2 deletions src/utils/dapp-list-constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
interface DappList {
interface DappListItem {
name: string;
dappUrl: string;
type: DappType;
Expand All @@ -16,7 +16,7 @@ enum DappType {
Other = 'Other'
}

export const dappList: DappList[] = [
export const DAPPS_LIST: DappListItem[] = [
{
name: 'QuipuSwap',
dappUrl: 'https://quipuswap.com',
Expand Down Expand Up @@ -154,3 +154,38 @@ export const dappList: DappList[] = [
categories: [DappType.DeFi]
}
];

export const IOS_DAPPS_LIST: DappListItem[] = [
{
name: 'Tezos Projects',
dappUrl: 'https://ecosystem.tezos.com',
logo: 'https://temple-wallet-stage-bucket.nyc3.cdn.digitaloceanspaces.com/dapps/tezos.png',
slug: 'ecosystem.tezos.com',
type: DappType.Other,
categories: []
},
{
name: 'Mad.Fish',
dappUrl: 'https://mad.fish/products',
logo: 'https://temple-wallet-stage-bucket.nyc3.cdn.digitaloceanspaces.com/dapps/madfish.png',
slug: 'mad.fish/products',
type: DappType.Other,
categories: []
},
{
name: 'Temple Wallet',
dappUrl: 'https://templewallet.com/download?platform=extension',
logo: 'https://temple-wallet-stage-bucket.nyc3.cdn.digitaloceanspaces.com/dapps/temple.png',
slug: 'download-tw-extension',
type: DappType.Other,
categories: []
},
{
name: 'TZKT',
dappUrl: 'https://tzkt.io/dapps',
logo: 'https://temple-wallet-stage-bucket.nyc3.cdn.digitaloceanspaces.com/dapps/tzkt.png',
slug: 'tzkt.io/dapps',
type: DappType.Other,
categories: []
}
];
Loading