Skip to content

Commit

Permalink
New fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaituVR committed Jan 16, 2024
1 parent a3431aa commit aab6162
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ SERVICE_PUSHER_BEAMS_SECRET_KEY=
WALLETCONNECT_PROJECT_ID=
WALLETCONNECT_PROJECT_SECRET=
WALLETCONNECT_NOTIFY_SERVER_URL=https://notify.walletconnect.com
WALLETCONNECT_NOTIFICATION_TYPE=

# Sentry
SENTRY_DSN=
Expand Down
18 changes: 2 additions & 16 deletions src/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import express from 'express';
import { send } from './providers/walletconnectNotify';
import { sendEvent } from './providers/webhook';
import { capture } from '@snapshot-labs/snapshot-sentry';
import { getSubscribers } from './helpers/utils';

const router = express.Router();

Expand All @@ -15,22 +14,9 @@ router.get('/test', async (req, res) => {
expire: 1647343155
};

const proposal = {
id: '0x45121903be7c520701d8d5536d2de29577367f2c84f39602026dc09ef1da8346',
title: 'Proposal to Redirect Multichain Warchest to CAKE Burn',
start: 1695376800,
end: 1695463200,
state: 'closed',
space: {
id: 'cakevote.eth',
name: 'PancakeSwap',
avatar: 'ipfs://bafkreidd4kzjvr5hfbcazj5jqpvd5vz2lj467uhl2i3ejdllafnlx4itcy'
}
};

try {
new URL(url);
await send(event, proposal, ['caip 10 address']);
await sendEvent(event, url, method);

return res.json({ url, success: true });
} catch (e: any) {
Expand Down
7 changes: 4 additions & 3 deletions src/providers/walletconnectNotify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { capture } from '@snapshot-labs/snapshot-sentry';
const WALLETCONNECT_NOTIFY_SERVER_URL = process.env.WALLETCONNECT_NOTIFY_SERVER_URL;

Check failure on line 4 in src/providers/walletconnectNotify.ts

View workflow job for this annotation

GitHub Actions / lint (18) / Lint

Insert `⏎·`
const WALLETCONNECT_PROJECT_SECRET = process.env.WALLETCONNECT_PROJECT_SECRET;
const WALLETCONNECT_PROJECT_ID = process.env.WALLETCONNECT_PROJECT_ID;
const WALLETCONNECT_NOTIFICATION_TYPE = process.env.WALLETCONNECT_NOTIFICATION_TYPE;

Check failure on line 7 in src/providers/walletconnectNotify.ts

View workflow job for this annotation

GitHub Actions / lint (18) / Lint

Insert `⏎·`

const AUTH_HEADER = {
Authorization: WALLETCONNECT_PROJECT_SECRET ? `Bearer ${WALLETCONNECT_PROJECT_SECRET}` : ''

Check failure on line 10 in src/providers/walletconnectNotify.ts

View workflow job for this annotation

GitHub Actions / lint (18) / Lint

Replace `·?·`Bearer·${WALLETCONNECT_PROJECT_SECRET}`` with `⏎····?·`Bearer·${WALLETCONNECT_PROJECT_SECRET}`⏎···`
Expand All @@ -25,7 +26,7 @@ async function wait(seconds: number) {
// That should be defined in the wc-notify-config.json
function getNotificationType(event) {
if (event.includes('proposal/')) {
return 'ed2fd071-65e1-440d-95c5-7d58884eae43';
return WALLETCONNECT_NOTIFICATION_TYPE;
} else {
return null;
}
Expand All @@ -34,7 +35,7 @@ function getNotificationType(event) {
// Generate a notification body per the event
function getNotificationBody(event, space) {
switch (event) {
case 'proposal/create':
case 'proposal/created':
return `A new proposal has been created for ${space.name}`;
case 'proposal/end':
return `A proposal has closed for ${space.name}`;
Expand Down Expand Up @@ -124,7 +125,7 @@ export async function sendNotification(notification, accounts) {
}

// Transform proposal event into notification format.
async function formatMessage(event, proposal) {
function formatMessage(event, proposal) {
const space = proposal.space;
if (!space) return null;

Expand Down

0 comments on commit aab6162

Please sign in to comment.