Skip to content

Commit

Permalink
changes as per feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
vignesha22 committed Feb 27, 2024
1 parent 0e0072c commit 02c8e98
Show file tree
Hide file tree
Showing 25 changed files with 145 additions and 136 deletions.
50 changes: 25 additions & 25 deletions admin_frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 17 additions & 17 deletions admin_frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@emotion/react": "^11.11.3",
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.15.3",
"@mui/lab": "^5.0.0-alpha.159",
"@mui/material": "^5.15.3",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hot-toast": "^2.4.1",
"react-router-dom": "^6.21.1",
"@emotion/react": "11.11.3",
"@emotion/styled": "11.11.0",
"@mui/icons-material": "5.15.3",
"@mui/lab": "5.0.0-alpha.159",
"@mui/material": "5.15.3",
"@testing-library/jest-dom": "5.17.0",
"@testing-library/react": "13.4.0",
"@testing-library/user-event": "13.5.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hot-toast": "2.4.1",
"react-router-dom": "6.21.1",
"react-scripts": "5.0.1",
"styled-components": "^6.1.8",
"web-vitals": "^2.1.4"
"styled-components": "6.1.8",
"web-vitals": "2.1.4"
},
"scripts": {
"start": "PORT=3002 react-scripts start",
Expand All @@ -44,8 +44,8 @@
]
},
"devDependencies": {
"autoprefixer": "^10.4.16",
"postcss": "^8.4.33",
"tailwindcss": "^3.4.1"
"autoprefixer": "10.4.16",
"postcss": "8.4.33",
"tailwindcss": "3.4.1"
}
}
59 changes: 30 additions & 29 deletions admin_frontend/src/components/ApiKeys.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from "react";
import AddCircleIcon from "@mui/icons-material/AddCircle";
import RemoveCircleIcon from '@mui/icons-material/RemoveCircle';
import RemoveCircleIcon from "@mui/icons-material/RemoveCircle";
import toast from "react-hot-toast";
import { TextField } from "@mui/material";
import Table from "@mui/material/Table";
Expand All @@ -17,7 +17,7 @@ import IconButton from "@mui/material/IconButton";
import OutlinedInput from "@mui/material/OutlinedInput";
import FormControl from "@mui/material/FormControl";
import InputLabel from "@mui/material/InputLabel";
import Checkbox from '@mui/material/Checkbox';
import Checkbox from "@mui/material/Checkbox";
import Header from "./Header";

const ApiKeysPage = () => {
Expand All @@ -38,8 +38,8 @@ const ApiKeysPage = () => {
};

const handleChange = (event) => {
setTxnMode(event.target.checked ? 1 : 0)
};
setTxnMode(event.target.checked ? 1 : 0);
};

const fetchData = async () => {
try {
Expand All @@ -49,13 +49,10 @@ const ApiKeysPage = () => {
method: "GET",
})
).json();
console.log("data: ", data);
setKeys(data);
setLoading(false);
} catch (err) {
toast.error(
"Check Backend Service for more info"
);
toast.error("Check Backend Service for more info");
}
};

Expand All @@ -68,8 +65,14 @@ const ApiKeysPage = () => {
toast.error("Please input both API_KEY & PRIVATE_KEY field");
return;
}
if (!/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*-_&])[A-Za-z\d@$!%*-_&]{8,}$/.test(apiKey)) {
toast.error("Invalid Validation: API_KEY format. Please see the docs for more info");
if (
!/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*-_&])[A-Za-z\d@$!%*-_&]{8,}$/.test(
apiKey
)
) {
toast.error(
"Invalid Validation: API_KEY format. Please see the docs for more info"
);
return;
}
try {
Expand All @@ -80,16 +83,16 @@ const ApiKeysPage = () => {
SUPPORTED_NETWORKS: supportedNetworks ?? "",
ERC20_PAYMASTERS: customErc20Paymaster ?? "",
TRANSACTION_LIMIT: txnMode,
NO_OF_TRANSACTIONS_IN_A_MONTH: noOfTxn,
INDEXER_ENDPOINT: 'http://localhost:3003'
NO_OF_TRANSACTIONS_IN_A_MONTH: noOfTxn,
INDEXER_ENDPOINT:
process.env.REACT_APP_INDEXER_ENDPOINT ?? "http://localhost:3003",
};
const data = await (
await fetch("http://localhost:5050/saveKey", {
method: "POST",
body: JSON.stringify(requestData),
})
).json();
if (!data.error) {
const data = await fetch("http://localhost:5050/saveKey", {
method: "POST",
body: JSON.stringify(requestData),
});
const dataJson = await data.json();
if (!dataJson.error) {
toast.success("Saved Successfully");
setApiKey("");
setPrivateKey("");
Expand All @@ -99,9 +102,7 @@ const ApiKeysPage = () => {
toast.error("Could not save");
}
} catch (err) {
toast.error(
"Check Backend Service for more info"
);
toast.error("Check Backend Service for more info");
setLoading(false);
}
};
Expand All @@ -124,9 +125,7 @@ const ApiKeysPage = () => {
}
} catch (err) {
console.log("err: ", err);
toast.error(
"Check Backend Service for more info"
);
toast.error("Check Backend Service for more info");
setLoading(false);
}
};
Expand Down Expand Up @@ -229,13 +228,13 @@ const ApiKeysPage = () => {
</TableCell>
<TableCell>
<Checkbox
checked={txnMode === 0? false : true}
checked={txnMode === 0 ? false : true}
onChange={handleChange}
inputProps={{ 'aria-label': 'controlled' }}
inputProps={{ "aria-label": "controlled" }}
/>
</TableCell>
<TableCell>
<TextField
<TextField
type="number"
variant="outlined"
color="secondary"
Expand Down Expand Up @@ -284,7 +283,9 @@ const ApiKeysPage = () => {
</TableCell>
<TableCell>{row.SUPPORTED_NETWORKS}</TableCell>
<TableCell>{row.ERC20_PAYMASTERS}</TableCell>
<TableCell>{row.TRANSACTION_LIMIT === 0 ? 'OFF': 'ON'}</TableCell>
<TableCell>
{row.TRANSACTION_LIMIT === 0 ? "OFF" : "ON"}
</TableCell>
<TableCell>{row.NO_OF_TRANSACTIONS_IN_A_MONTH}</TableCell>
<TableCell>
<LoadingButton
Expand Down
2 changes: 1 addition & 1 deletion backend/indexer/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "ponder"
}
}
3 changes: 2 additions & 1 deletion backend/indexer/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
/generated/
/.ponder/

package-lock.json
package-lock.json

2 changes: 1 addition & 1 deletion backend/indexer/EtherspotAbi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -597,4 +597,4 @@ export const EtherspotPaymasterAbi = [
"stateMutability": "nonpayable",
"type": "function"
}
] as const;
] as const;
50 changes: 25 additions & 25 deletions backend/indexer/package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"name": "indexer",
"version": "0.0.1",
"private": true,
"type": "module",
"scripts": {
"dev": "ponder dev --port 3003",
"start": "ponder start --port 3003",
"codegen": "ponder codegen",
"lint": "eslint .",
"typecheck": "tsc"
},
"dependencies": {
"@ponder/core": "0.2.2",
"viem": "1.19.3"
},
"devDependencies": {
"@types/node": "20.9.0",
"eslint": "8.53.0",
"eslint-config-ponder": "0.2.2",
"typescript": "5.2.2"
},
"engines": {
"node": ">=18.14"
}
}
"name": "indexer",
"version": "0.0.1",
"private": true,
"type": "module",
"scripts": {
"dev": "ponder dev --port 3003",
"start": "ponder start --port 3003",
"codegen": "ponder codegen",
"lint": "eslint .",
"typecheck": "tsc"
},
"dependencies": {
"@ponder/core": "0.2.2",
"viem": "1.19.3"
},
"devDependencies": {
"@types/node": "20.9.0",
"eslint": "8.53.0",
"eslint-config-ponder": "0.2.2",
"typescript": "5.2.2"
},
"engines": {
"node": ">=18.14"
}
}
2 changes: 1 addition & 1 deletion backend/indexer/ponder.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ export default createSchema((p) => ({
year: p.int(),
chainId: p.int(),
}),
}));
}));
31 changes: 17 additions & 14 deletions backend/indexer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ ponder.on("EtherspotPaymaster:SponsorSuccessful", async ({ event, context }) =>
const { args, block, transaction, log } = event;
const time = Number(BigNumber.from(block.timestamp).toString());
const timestamp = new Date(time * 1000);

await db.PaymasterEvent.create({
id: transaction.hash + log.logIndex,
data: {
chainId: network.chainId,
sender: args.sender,
paymaster: args.paymaster,
transactionHash: transaction.hash,
timestamp: block.timestamp,
month: timestamp.getMonth(),
year: timestamp.getFullYear()
}
})
});
try {
await db.PaymasterEvent.create({
id: transaction.hash + log.logIndex,
data: {
chainId: network.chainId,
sender: args.sender,
paymaster: args.paymaster,
transactionHash: transaction.hash,
timestamp: block.timestamp,
month: timestamp.getMonth(),
year: timestamp.getFullYear()
}
})
} catch (err) {
// caught err
}
});
2 changes: 1 addition & 1 deletion backend/indexer/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
},
"include": ["./**/*.ts"],
"exclude": ["node_modules"]
}
}
Loading

0 comments on commit 02c8e98

Please sign in to comment.