Skip to content

Commit

Permalink
TW-1614: Temple Tap Airdrop confirmation (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-tsx authored Dec 24, 2024
1 parent 999f45a commit bf54124
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
1 change: 1 addition & 0 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ REDIS_URL=
ADMIN_USERNAME=
ADMIN_PASSWORD=
COVALENT_API_KEY=
TEMPLE_TAP_API_URL=
3 changes: 2 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export const EnvVars = {
ADMIN_USERNAME: getEnv('ADMIN_USERNAME'),
ADMIN_PASSWORD: getEnv('ADMIN_PASSWORD'),
COVALENT_API_KEY: getEnv('COVALENT_API_KEY'),
ALCHEMY_API_KEY: getEnv('ALCHEMY_API_KEY')
ALCHEMY_API_KEY: getEnv('ALCHEMY_API_KEY'),
TEMPLE_TAP_API_URL: getEnv('TEMPLE_TAP_API_URL')
};

for (const name in EnvVars) {
Expand Down
29 changes: 28 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import swaggerJSDoc from 'swagger-jsdoc';
import swaggerUi from 'swagger-ui-express';

import { getAdvertisingInfo } from './advertising/advertising';
import { MIN_ANDROID_APP_VERSION, MIN_IOS_APP_VERSION } from './config';
import { EnvVars, MIN_ANDROID_APP_VERSION, MIN_IOS_APP_VERSION } from './config';
import getDAppsStats from './getDAppsStats';
import { getMagicSquareQuestParticipants, startMagicSquareQuest } from './magic-square';
import { basicAuth } from './middlewares/basic-auth.middleware';
Expand Down Expand Up @@ -398,6 +398,33 @@ app.get('/api/signing-nonce', (req, res) => {
}
});

app.post('/api/temple-tap/confirm-airdrop-username', async (req, res) => {
try {
const response = await fetch(new URL('/v1/confirm-airdrop-address', EnvVars.TEMPLE_TAP_API_URL), {
method: 'POST',
body: JSON.stringify(req.body),
headers: {
'Content-Type': 'application/json'
}
});

const statusCode = String(response.status);
const responseBody = await response.text();

if (statusCode.startsWith('2') || statusCode.startsWith('4')) {
res.status(response.status).send(responseBody);

return;
}

throw new Error(responseBody);
} catch (error) {
console.error('Temple Tap API proxy endpoint exception:', error);

res.status(500).send({ message: 'Unknown error' });
}
});

const swaggerOptions = {
swaggerDefinition: {
openapi: '3.0.0',
Expand Down
3 changes: 2 additions & 1 deletion templewallet-backend.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"ALICE_BOB_PUBLIC_KEY": "SECRET_VALUE",
"ALICE_BOB_PRIVATE_KEY": "SECRET_VALUE",
"THREE_ROUTE_API_URL": "SECRET_VALUE",
"THREE_ROUTE_API_AUTH_TOKEN": "SECRET_VALUE"
"THREE_ROUTE_API_AUTH_TOKEN": "SECRET_VALUE",
"TEMPLE_TAP_API_URL": "SECRET_VALUE"
}
}
]
Expand Down

0 comments on commit bf54124

Please sign in to comment.