Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #272 from BanklessDAO/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
SlinkyPotato authored Dec 8, 2021
2 parents f67c5b4 + 843f964 commit f4554db
Show file tree
Hide file tree
Showing 35 changed files with 805 additions and 846 deletions.
7 changes: 1 addition & 6 deletions .env.prod
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,4 @@ TWITTER_BEARER_TOKEN=
TWITTER_ACCESS_TOKEN=
TWITTER_ACCESS_TOKEN_SECRET=
TWITTER_VERIFICATION_URL=https://degen.bankless.community/verification/twitter
TWITTER_CLAIM_PAGE=https://degen.bankless.community/claim

# Datadog
DD_ENV=prod
DD_DYNO_HOST=true
DD_LOGS_INJECTION=true
TWITTER_CLAIM_PAGE=https://degen.bankless.community/claim
7 changes: 1 addition & 6 deletions .env.qa
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,4 @@ TWITTER_BEARER_TOKEN=
TWITTER_ACCESS_TOKEN=
TWITTER_ACCESS_TOKEN_SECRET=
TWITTER_VERIFICATION_URL=https://develop-degen.bankless.community/verification/twitter
TWITTER_CLAIM_PAGE=https://develop-degen.bankless.community/claim

# Datadog
DD_ENV=qa
DD_DYNO_HOST=true
DD_LOGS_INJECTION=true
TWITTER_CLAIM_PAGE=https://develop-degen.bankless.community/claim
6 changes: 6 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ TWITTER_BEARER_TOKEN=
TWITTER_ACCESS_TOKEN=
TWITTER_ACCESS_TOKEN_SECRET=
TWITTER_CALL_BACK_URL=

# POAP
POAP_DOMAIN=
POAP_AUDIENCE=
POAP_CLIENT_ID=
POAP_CLIENT_SECRET=
5 changes: 4 additions & 1 deletion .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,7 @@ jobs:
HD_TWITTER_API_SECRET: ${{secrets.PROD_TWITTER_API_SECRET}}
HD_TWITTER_BEARER_TOKEN: ${{secrets.PROD_TWITTER_API_BEARER_TOKEN}}
HD_TWITTER_ACCESS_TOKEN_SECRET: ${{secrets.PROD_TWITTER_API_ACCESS_TOKEN_SECRET}}
HD_DD_API_KEY: ${{secrets.PROD_DATADOG_API_KEY}}
HD_POAP_DOMAIN: ${{secrets.PROD_POAP_DOMAIN}}
HD_POAP_AUDIENCE: ${{secrets.PROD_POAP_AUDIENCE}}
HD_POAP_CLIENT_ID: ${{secrets.PROD_POAP_CLIENT_ID}}
HD_POAP_CLIENT_SECRET: ${{secrets.PROD_POAP_CLIENT_SECRET}}
3 changes: 1 addition & 2 deletions .github/workflows/deploy-qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,4 @@ jobs:
HD_TWITTER_API_TOKEN: ${{secrets.QA_TWITTER_API_TOKEN}}
HD_TWITTER_API_SECRET: ${{secrets.QA_TWITTER_API_SECRET}}
HD_TWITTER_BEARER_TOKEN: ${{secrets.QA_TWITTER_API_BEARER_TOKEN}}
HD_TWITTER_ACCESS_TOKEN_SECRET: ${{secrets.QA_TWITTER_API_ACCESS_TOKEN_SECRET}}
HD_DD_API_KEY: ${{secrets.QA_DATADOG_API_KEY}}
HD_TWITTER_ACCESS_TOKEN_SECRET: ${{secrets.QA_TWITTER_API_ACCESS_TOKEN_SECRET}}
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changelog

## 2.3.0-RELEASE (2021-12-07)

1. Enable poap scheduling (POAP API integration)
2. Remove Datadog
3. Enable poap config via channel flow
4. Add poap config status command to display list of authorized users and roles
5. Rename `/poap schedule` -> `/poap mint`
6. Enable POAP distribution
- reduce poap claim deleted to 5 minutes
- display poap claimed message
- fix poap duration for auto end events
7. Clear expired POAPs on startup
- surround error log in try/catch block
8. Add a security check for the poap urls that are passed
- default platform to discord


## 2.2.0-RELEASE (2021-11-30)

1. Send hidden claim messages for POAPs
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Licensor: BanklessDAO | DEGEN Workgroup
Licensed Work: DEGEN
The Licensed Work is (c) 2021 BanklessDAO | DEGEN Workgroup

Change Date: The earlier of 2023-10-31
Change Date: The earliest of 2023-12-07

Change License: GNU General Public License v3.0 or later

Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "degen",
"version": "2.2.0",
"version": "2.3.0",
"description": "Administrative and Utilitarian bot for the Bankless Discord Server.",
"main": "app.js",
"private": true,
Expand Down Expand Up @@ -40,7 +40,6 @@
"csv-parse": "^5.0.3",
"csv-stringify": "^6.0.3",
"dayjs": "^1.10.7",
"dd-trace": "^1.5.1",
"discord.js": "^13.3.1",
"discord.js-captcha": "^2.2.2",
"dotenv": "^10.0.0",
Expand Down
8 changes: 0 additions & 8 deletions src/app/api/PoapAPI.ts

This file was deleted.

26 changes: 15 additions & 11 deletions src/app/api/EventsAPI.ts → src/app/api/poap/EventsAPI.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { EventsRequestType } from './types/poap-events/EventsRequestType';
import { EventsResponseType } from './types/poap-events/EventsResponseType';
import { EventsRequestType } from '../types/poap-events/EventsRequestType';
import { EventsResponseType } from '../types/poap-events/EventsResponseType';
import FormData from 'form-data';
import axios, { AxiosRequestConfig } from 'axios';
import Log, { LogUtils } from '../utils/Log';
import { GuildMember } from 'discord.js';
import Log, { LogUtils } from '../../utils/Log';
import ValidationError from '../../errors/ValidationError';
import PoapAPI, { AuthToken } from './PoapAPI';

const EventsAPI = {
scheduleEvent: async (request: EventsRequestType, guildMember?: GuildMember): Promise<EventsResponseType> => {
URL: 'https://api.poap.xyz/events',

scheduleEvent: async (request: EventsRequestType): Promise<EventsResponseType> => {
const authToken: AuthToken = await PoapAPI.generateToken();

const formData: FormData = new FormData();
formData.append('name', request.name);
formData.append('description', request.description);
Expand All @@ -30,9 +35,10 @@ const EventsAPI = {
});
const config: AxiosRequestConfig = {
method: 'post',
url: 'https://api.poap.xyz/events',
url: EventsAPI.URL,
headers: {
...formData.getHeaders(),
'Authorization': `Bearer ${authToken.accessToken}`,
},
data : formData,
};
Expand All @@ -58,7 +64,7 @@ const EventsAPI = {
imagePath: `${request.image.config.url}`,
},
});
const response = await axios.post('https://api.poap.xyz/events', formData, config);
const response = await axios.post(EventsAPI.URL, formData, config);
Log.info('poap schedule response', {
indexMeta: true,
meta: {
Expand All @@ -78,11 +84,9 @@ const EventsAPI = {
},
});
if (e.response.status == '400') {
await guildMember.send({
content: `Hmmm 🤔, this is what I found: ${e.response.data.message}`,
});
throw new ValidationError(`${e.response.data.message}`);
}
throw new Error();
throw new Error('poap event request failed');
}
},
};
Expand Down
63 changes: 63 additions & 0 deletions src/app/api/poap/PoapAPI.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import axios, { AxiosRequestConfig } from 'axios';
import Log, { LogUtils } from '../../utils/Log';
import ValidationError from '../../errors/ValidationError';

export type AuthToken = {
accessToken: string,
scope: string,
expiresIn: number,
tokenType: string,
}

const PoapAPI = {
URL: `https://${process.env.POAP_DOMAIN}/oauth/token`,

generateToken: async (): Promise<AuthToken> => {
Log.debug('generating POAP auth token');

const postData = {
audience: process.env.POAP_AUDIENCE,
grant_type: 'client_credentials',
client_id: process.env.POAP_CLIENT_ID,
client_secret: process.env.POAP_CLIENT_SECRET,
};

const config: AxiosRequestConfig = {
method: 'post',
url: PoapAPI.URL,
headers: {
'Content-Type': 'application/json',
},
};
try {
Log.debug('attempting to request poap auth token');
const response = await axios.post(PoapAPI.URL, postData, config);
Log.debug('poap auth token response', {
indexMeta: true,
meta: {
data: response.data,
},
});
return {
accessToken: response.data.access_token,
scope: response.data.scope,
expiresIn: response.data.expires_in,
tokenType: response.data.token_type,
};
} catch (e) {
LogUtils.logError('failed to request poap auth token', e);
Log.warn('poap response', {
indexMeta: true,
meta: {
error: e.toJSON,
},
});
if (e.response.status == '400') {
throw new ValidationError(`${e.response.data.message}`);
}
throw new Error('poap auth request failed');
}
},
};

export default PoapAPI;
1 change: 0 additions & 1 deletion src/app/app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Libs
import './utils/tracer';
import { SlashCreator, GatewayServer, SlashCommand, CommandContext } from 'slash-create';
import Discord, { Client, ClientOptions, Intents, WSEventType } from 'discord.js';
import path from 'path';
Expand Down
Loading

0 comments on commit f4554db

Please sign in to comment.