Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gas Fee Updation #336

Merged
merged 2 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions app/controllers/api/v1/gasFees.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
module.exports = function (router: any) {

router.get('/:chainId', async (req: any, res: any) => {

router.get("/:chainId", async (req: any, res: any) => {
var filter: any = {};

if(req.params.chainId){
if (req.params.chainId) {
filter.chainId = req.params.chainId;
}

if (req.params.type) {
filter.type = req.params.type;
}

let gasFees = await db.GasFees.findOne(filter);

return res.http200({
gasFees: gasFees
gasFees: gasFees,
});

});

};
71 changes: 71 additions & 0 deletions app/controllers/api/v1/super-admin/gasFees.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
module.exports = function (router: any) {
router.post("/create", async (req: any, res: any) => {
if (
!req.body.maxFeePerGas ||
!req.body.maxPriorityFeePerGas ||
!req.body.gasLimit
) {
return res.http400(
"maxFeePerGas & maxPriorityFeePerGas & gasLimit are required."
);
}

req.body.createdAt = new Date();
req.body.updatedAt = new Date();

let gasFees = await db.GasFees.create(req.body);

return res.http200({
gasFees: gasFees,
});
});

router.put("/update/:id", async (req: any, res: any) => {
let filter = {};
filter = { _id: req.params.id };

req.body.updatedAt = new Date();

let gasFees = await db.GasFees.findOneAndUpdate(filter, req.body, {
new: true,
});

return res.http200({
gasFees: gasFees,
});
});

router.get("/list", async (req: any, res: any) => {
var filter = {};

let data = await db.GasFees.find(filter)
.sort({ createdAt: -1 })
.skip(req.query.offset ? parseInt(req.query.offset) : 0)
.limit(req.query.limit ? parseInt(req.query.limit) : 10);

return res.http200({
data: data,
});
});

router.get("/:id", async (req: any, res: any) => {
let filter = {};
filter = { _id: req.params.id };

let gasFees = await db.GasFees.findOne(filter);

return res.http200({
gasFees: gasFees,
});
});

router.delete("/:id", async (req: any, res: any) => {
let filter = {};

await db.GasFees.remove({ _id: req.params.id });

return res.http200({
message: stringHelper.strSuccess,
});
});
};
9 changes: 5 additions & 4 deletions app/models/gasFees.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
"use strict";

var mongoose = require("mongoose");
var collectionName = 'gasFees';
var collectionName = "gasFees";

var schema = mongoose.Schema(
{
maxFeePerGas: { type: String, default: '' },
maxPriorityFeePerGas: { type: String, default: '' },
gasLimit: { type: String, default: '' },
maxFeePerGas: { type: String, default: "" },
maxPriorityFeePerGas: { type: String, default: "" },
gasLimit: { type: String, default: "" },
type: { type: String, default: "" },
chainId: { type: String, default: "" },
isActive: { type: Boolean, default: true },

Expand Down
Loading