Skip to content

Commit

Permalink
Fix the bucket name being used
Browse files Browse the repository at this point in the history
  • Loading branch information
ECWireless committed Oct 22, 2024
1 parent 58dc536 commit b9794b0
Show file tree
Hide file tree
Showing 5 changed files with 16,439 additions and 21 deletions.
24 changes: 12 additions & 12 deletions app/api/channel/route.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
import { GetObjectCommand } from '@aws-sdk/client-s3';
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
import { JsonRpcProvider, Interface, Contract, verifyMessage } from 'ethers';
import { NextResponse } from 'next/server';
import { GetObjectCommand } from "@aws-sdk/client-s3";
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
import { JsonRpcProvider, Interface, Contract, verifyMessage } from "ethers";
import { NextResponse } from "next/server";

import { s3Client } from '../../config';
import { s3Client } from "../../config";

export async function POST(req, res) {
let request = await req.json();

const address = verifyMessage(
'gm raidguild member',
"gm raidguild member",
request.signature.toString()
);

const abi = new Interface([
'function members(address account) view returns (address, uint256, uint256, bool, uint256, uint256)'
"function members(address account) view returns (address, uint256, uint256, bool, uint256, uint256)",
]);
const contract = new Contract(
'0xfe1084bc16427e5eb7f13fc19bcd4e641f7d571f',
"0xfe1084bc16427e5eb7f13fc19bcd4e641f7d571f",
abi,
new JsonRpcProvider('https://rpc.ankr.com/gnosis')
new JsonRpcProvider("https://rpc.ankr.com/gnosis")
);

const member = await contract.members(address);

if (member[3]) {
const bucketParams = {
Bucket: 'raidguild',
Key: request.key
Bucket: "raid-guild-valhalla",
Key: request.key,
};

const url = await getSignedUrl(
s3Client,
new GetObjectCommand(bucketParams),
{
expiresIn: 15 * 60
expiresIn: 15 * 60,
}
);

Expand Down
8 changes: 4 additions & 4 deletions app/api/files/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { NextResponse } from "next/server";
import { s3Client } from "../../config";
import axios from "axios";

const bucketParams = { Bucket: "raidguild" };
const bucketParams = { Bucket: "raid-guild-valhalla" };

export async function POST(req) {
const request = await req.json();

// Verify the message using the provided signature
const address = verifyMessage(
"gm raidguild member",
request.signature.toString(),
request.signature.toString()
);

try {
Expand All @@ -33,11 +33,11 @@ export async function POST(req) {
headers: {
Origin: "https://admin.daohaus.club",
},
},
}
);

const members = response.data.data.members.map((member) =>
member.memberAddress.toLowerCase(),
member.memberAddress.toLowerCase()
);

if (members.includes(address.toLowerCase())) {
Expand Down
9 changes: 5 additions & 4 deletions app/config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { S3 } from '@aws-sdk/client-s3';
import { S3 } from "@aws-sdk/client-s3";

export const CONFIG = {
JWT_SECRET: process.env.JWT_SECRET
JWT_SECRET: process.env.JWT_SECRET,
};

export const s3Client = new S3({
forcePathStyle: false,
endpoint: process.env.S3_ENDPOINT,
region: process.env.S3_REGION,
credentials: {
accessKeyId: process.env.S3_KEY,
secretAccessKey: process.env.S3_SECRET
}
secretAccessKey: process.env.S3_SECRET,
},
});
4 changes: 3 additions & 1 deletion app/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ export default function Home() {
loadingText="Querying.."
onClick={() => getFile(file.Key)}
>
{file.Key.slice(9, -5)}
{file.Key.length > 30
? `${file.Key.slice(0, 25)}...`
: file.Key.slice(0, -5)}
</Button>
))}
</SimpleGrid>
Expand Down
Loading

0 comments on commit b9794b0

Please sign in to comment.