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
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
};
};

10 changes: 7 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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'
@@ -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

GitHub Actions / Checks if ts and lint works

Unexpected any. Specify a different type

Check warning on line 158 in src/index.ts

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();
@@ -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

GitHub Actions / Checks if ts and lint works

Unexpected any. Specify a different type

Check warning on line 342 in src/index.ts

GitHub Actions / Checks if ts and lint works

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

if (error instanceof CodedError) {
@@ -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

GitHub Actions / Checks if ts and lint works

Unexpected any. Specify a different type

Check warning on line 356 in src/index.ts

GitHub Actions / Checks if ts and lint works

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

if (error instanceof CodedError) {
@@ -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

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

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

GitHub Actions / Checks if ts and lint works

Unexpected any. Specify a different type

Check warning on line 373 in src/index.ts

GitHub Actions / Checks if ts and lint works

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

if (error instanceof CodedError) {
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;
@@ -16,7 +16,7 @@ enum DappType {
Other = 'Other'
}

export const dappList: DappList[] = [
export const DAPPS_LIST: DappListItem[] = [
{
name: 'QuipuSwap',
dappUrl: 'https://quipuswap.com',
@@ -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: []
}
];

Unchanged files with check annotations Beta

buildResponse() {
const res: CodedErrorForResponse = { message: this.message };
if (this.errorCode) res.code = this.errorCode;

Check warning on line 17 in src/utils/errors.ts

GitHub Actions / Checks if ts and lint works

Unexpected nullable string value in conditional. Please handle the nullish/empty cases explicitly

Check warning on line 17 in src/utils/errors.ts

GitHub Actions / Checks if ts and lint works

Unexpected nullable string value in conditional. Please handle the nullish/empty cases explicitly
return res;
}
}
const exchangeRatesWithHoles = await Promise.all(
tokens!

Check warning on line 43 in src/utils/tokens.ts

GitHub Actions / Checks if ts and lint works

Forbidden non-null assertion

Check warning on line 43 in src/utils/tokens.ts

GitHub Actions / Checks if ts and lint works

Forbidden non-null assertion
.filter(
(token): token is ThreeRouteFa12Token | ThreeRouteFa2Token => token.standard !== ThreeRouteStandardEnum.xtz
)
.map(async (token): Promise<TokenExchangeRateEntry | undefined> => {
const { contract, tokenId: rawTokenId, symbol } = token;
const tokenId = isDefined(rawTokenId) ? Number(rawTokenId) : undefined;
const { ask, bid } = exchangeRatesInputs![symbol] ?? { ask: 0, bid: 0 };

Check warning on line 50 in src/utils/tokens.ts

GitHub Actions / Checks if ts and lint works

Forbidden non-null assertion

Check warning on line 50 in src/utils/tokens.ts

GitHub Actions / Checks if ts and lint works

Forbidden non-null assertion
if (ask === 0 && bid === 0) {
logger.error(`Failed to get exchange rate for token ${token.symbol}`);
const { data: metadata } = await tokensMetadataProvider.get(contract, tokenId);
const tokensPerTez = ask === 0 ? bid : ask;
const exchangeRate = new BigNumber(1).div(tokensPerTez).times(tezExchangeRate!);

Check warning on line 60 in src/utils/tokens.ts

GitHub Actions / Checks if ts and lint works

Forbidden non-null assertion

Check warning on line 60 in src/utils/tokens.ts

GitHub Actions / Checks if ts and lint works

Forbidden non-null assertion
return {
tokenAddress: contract,