Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
adimpdl committed Oct 7, 2024
1 parent 09a56af commit 48c54e7
Show file tree
Hide file tree
Showing 8 changed files with 177 additions and 107 deletions.
19 changes: 18 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
FROM node:18-alpine

# install postgres and run databse
# RUN apk add postgresql
# RUN mkdir /run/postgresql
# RUN chown postgres:postgres /run/postgresql
# USER postgres
# RUN mkdir /var/lib/postgresql/data
# RUN chmod 0700 /var/lib/postgresql/data
# RUN initdb -D /var/lib/postgresql/data
# RUN pg_ctl start -D /var/lib/postgresql/data
# su postgres -c 'pg_ctl start -D /var/lib/postgresql/data';


WORKDIR /validator_dapp
COPY package*.json ./
RUN npm install
COPY . .
RUN npx prisma generate
RUN npm run build
EXPOSE 3000
CMD ["sh", "-c", "npx prisma migrate deploy && npm run start"]
RUN chmod +x callApi.sh
RUN chmod 0644 crntab
COPY crntab /etc/crontabs/root
ENV DATABASE_URL="postgres://postgres:postgres@localhost:5432/postgres"
CMD ["sh", "-c", "npx prisma migrate deploy && npm run start && crond"]
178 changes: 89 additions & 89 deletions abis/ValidatorMetadataTest.abi.json
Original file line number Diff line number Diff line change
@@ -1,91 +1,91 @@
[
{
"constant": false,
"inputs": [
{
"name": "_firstName",
"type": "string"
},
{
"name": "_lastName",
"type": "string"
},
{
"name": "_contactEmail",
"type": "string"
},
{
"name": "_researchInstitute",
"type": "string"
},
{
"name": "_researchField",
"type": "string"
},
{
"name": "_instituteAddress",
"type": "string"
}
],
"name": "createMetadata",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "memberAddress",
"type": "address"
}
],
"name": "CreatedMetadata",
"type": "event"
},
{
"constant": true,
"inputs": [
{
"name": "memberAddress",
"type": "address"
}
],
"name": "validatorsMetadata",
"outputs": [
{
"name": "firstName",
"type": "string"
},
{
"name": "lastName",
"type": "string"
},
{
"name": "contactEmail",
"type": "string"
},
{
"name": "researchInstitute",
"type": "string"
},
{
"name": "researchField",
"type": "string"
},
{
"name": "instituteAddress",
"type": "string"
},
{
"name": "sender",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
{
"constant": false,
"inputs": [
{
"name": "_firstName",
"type": "string"
},
{
"name": "_lastName",
"type": "string"
},
{
"name": "_contactEmail",
"type": "string"
},
{
"name": "_researchInstitute",
"type": "string"
},
{
"name": "_researchField",
"type": "string"
},
{
"name": "_instituteAddress",
"type": "string"
}
],
"name": "createMetadata",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "memberAddress",
"type": "address"
}
],
"name": "CreatedMetadata",
"type": "event"
},
{
"constant": true,
"inputs": [
{
"name": "memberAddress",
"type": "address"
}
],
"name": "validatorsMetadata",
"outputs": [
{
"name": "firstName",
"type": "string"
},
{
"name": "lastName",
"type": "string"
},
{
"name": "contactEmail",
"type": "string"
},
{
"name": "researchInstitute",
"type": "string"
},
{
"name": "researchField",
"type": "string"
},
{
"name": "instituteAddress",
"type": "string"
},
{
"name": "sender",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
]
13 changes: 13 additions & 0 deletions callApi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; // Remove in production

const axios = require('axios');

const callApi = async () => {
try {
const response = await axios.post('https://bloxberg-qa-traefik.mpdl.mpg.de/api/update-validators-details');
} catch (error) {
console.log('Error calling API:', error);
}
};

callApi();
2 changes: 2 additions & 0 deletions callApi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
/usr/local/bin/node /validator_dapp/callApi.js
1 change: 1 addition & 0 deletions crntab
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*/5 * * * * /validator_dapp/callApi.sh 2>> /validator_dapp/logg.log
28 changes: 12 additions & 16 deletions pages/inactiveValidators.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {

const inactiveValidators = ({ validators }) => {
const [searchTerm, setSearchTerm] = useState("");
const [isValidKey, setiIsValidKey] = useState(false);
// const [isValidKey, setiIsValidKey] = useState(false);

useEffect(() => {
if (checkEthereumExists()) {
Expand All @@ -22,28 +22,24 @@ const inactiveValidators = ({ validators }) => {
window.ethereum.on("chainChanged", () => {
window.location.reload();
});
getConnectedAccounts()
.then((value) => {
checkAccessKey(value).then((finalvalue) => {
setiIsValidKey(finalvalue);
});
})
.catch((err) => {
console.log(err);
});
// getConnectedAccounts()
// .then((value) => {
// checkAccessKey(value).then((finalvalue) => {
// setiIsValidKey(finalvalue);
// });
// })
// .catch((err) => {
// console.log(err);
// });
}
}, []);

return isValidKey ? (
return (
<section className="px-8">
<SearchBar setSearchTerm={setSearchTerm} />
{AllValidators({ validators, searchTerm })}
</section>
) : (
<div className="text-light-blue text-3xl py-6">
<MainTitle title="Invalid Key" />
</div>
);
)
};

export async function getServerSideProps() {
Expand Down
20 changes: 19 additions & 1 deletion pages/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';

import { useState } from "react";
import { AllValidators } from "@/components/AllValidators";
import { SearchBar } from "@/components/SearchBar";
import { prisma } from "../server/db/client";
import axios from "axios";

export default function Home({ validators }) {
const [searchTerm, setSearchTerm] = useState("");
Expand All @@ -21,14 +24,29 @@ export default function Home({ validators }) {
export async function getServerSideProps() {
// will always run on the server
// newest first
const validators = await prisma.validators.findMany({
let validators = await prisma.validators.findMany({
where: {
active: true,
},
include: {
users: true,
},
});

if (validators.length == 0) {
await axios.post('https://bloxberg-qa-traefik.mpdl.mpg.de/api/save-validators-details');
validators = await prisma.validators.findMany({
where: {
active: true,
},
include: {
users: true,
},
});
await axios.post('https://bloxberg-qa-traefik.mpdl.mpg.de/api/update-validators-details');
}
// await axios.post('https://bloxberg-qa-traefik.mpdl.mpg.de/api/update-validators-details');

return {
props: {
validators: JSON.parse(JSON.stringify(validators)),
Expand Down
Loading

0 comments on commit 48c54e7

Please sign in to comment.