Skip to content

Commit

Permalink
feat(Ops): Finishing cleaning stagging env + fixing some bugs happeni…
Browse files Browse the repository at this point in the history
…ng only their
  • Loading branch information
izimio committed May 1, 2024
1 parent 66e9242 commit 5a68b70
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 8 deletions.
1 change: 1 addition & 0 deletions backend/.env.schema
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ALLOWED_ORIGINS=localhost:3000
IS_TEST_MODE=false
BOOST_DURATION=2
BASE_MINING_DREAMAKER=5
UPLOAD_PATH="src/uploads"

# ======================== Ethereum ========================

Expand Down
6 changes: 6 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ RUN npm run build
FROM node:18 as runner

WORKDIR /app

COPY package*.json ./

RUN npm ci --only=production

RUN mkdir -p uploads

COPY --from=builder /app/build build/

CMD [ "node", "build/server.js" ]
7 changes: 7 additions & 0 deletions backend/src/Watchers/Watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const logErr = logError.extend("ws");
class EventWatcher {
proxyEvents: IEvent[];
isReady: boolean = false;
eventsTxs: string[] = [];

constructor() {
this.proxyEvents = Object.values(events).filter(
Expand Down Expand Up @@ -53,6 +54,12 @@ class EventWatcher {
}

provider.on(filter, async (event) => {
if (this.eventsTxs.includes(event.transactionHash)) {
log("🟡", "[BLOCKING] Duplicate event");
return;
}
this.eventsTxs.push(event.transactionHash);

const decoded = this.parseLogs(signature, event.data);
const origin = event.address;

Expand Down
3 changes: 2 additions & 1 deletion backend/src/middlewares/files.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import koaBody from "koa-body";
import { ValidationError } from "yup";
import { ALLOWED_EXTENSIONS } from "../utils/constants";
import { UPLOAD_PATH } from "../utils/config";

export const filesMiddleware = koaBody({
formidable: {
maxFieldsSize: 10 * 1024 * 1024,
maxFiles: 5,
uploadDir: "src/uploads",
uploadDir: UPLOAD_PATH,
filename(name, ext) {
const timestamp =
new Date().getTime() + Math.floor(Math.random() * 1000);
Expand Down
5 changes: 5 additions & 0 deletions backend/src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ if (!BASE_MINING_DREAMAKER_PERCENTAGE) {
throw new Error("Missing BASE_MINING_DREAMAKER_PERCENTAGE");
}

export const UPLOAD_PATH = process.env.UPLOAD_PATH as string;
if (!UPLOAD_PATH) {
throw new Error("Missing UPLOAD_PATH");
}

export const IS_TEST_MODE =
process.env.IS_TEST_MODE && process.env.IS_TEST_MODE === "true"
? true
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ services:
environment:
- MONGO_HOST=database
- BLOCKCHAIN_RPC=http://hardhat:8545
- UPLOAD_PATH=uploads
ports:
- "8080:8080"
networks:
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/ActionHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ const ActionHistory: FC<ActionHistoryProps> = ({ actions }) => {
<Th>
{action.amount !== "None"
? ethers.formatEther(action.amount) +
" ETH"
" " +
(action.action === "BOOST"
? "DMK"
: "ETH")
: "None"}
</Th>
</Tooltip>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/AddressCadrant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
import EmojiEventsIcon from "@mui/icons-material/EmojiEvents";
import AccountCircleIcon from "@mui/icons-material/AccountCircle";
import CottageIcon from "@mui/icons-material/Cottage";
import AdminPanelSettingsIcon from '@mui/icons-material/AdminPanelSettings';
import AdminPanelSettingsIcon from "@mui/icons-material/AdminPanelSettings";

import { useEthereum } from "../providers/ethereum";
import { useGlobal } from "../providers/global";
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/DreamList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ const DreamList: FC<DreamListProps> = ({ dreams }) => {
my={2}
textDecoration="underline"
>
{filteredDreams.length} dreams found
{filteredDreams.length} dream{" "}
<span> {filteredDreams.length > 1 ? "s" : ""}</span> found
</Text>
<Box
maxH="1000px"
Expand Down
1 change: 0 additions & 1 deletion frontend/src/pages/Admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const AdminPanel: FC = () => {
}
}, [user, navigate]);


if (!user) {
return (
<Box
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference types="vite/client" />

interface Window {
ethereum?: any
}
ethereum?: any;
}
2 changes: 1 addition & 1 deletion frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export default defineConfig({
preview: {
port: 3000,
strictPort: true,
}
},
});

0 comments on commit 5a68b70

Please sign in to comment.