Skip to content
This repository has been archived by the owner on Dec 31, 2024. It is now read-only.

Commit

Permalink
Add transaction entity and feathers service
Browse files Browse the repository at this point in the history
related to #51
  • Loading branch information
mohammadranjbarz committed Aug 31, 2021
1 parent e69d316 commit d3b0f30
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
24 changes: 24 additions & 0 deletions feathers-src/models/transactions.model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function Transaction(app) {
const mongooseClient = app.get('mongooseClient');
const { Schema } = mongooseClient;
const transaction = new Schema(
{
hash: { type: String, required: true, index: true },
from: { type: String },
gasPrice: { type: Number },
gasUsed: { type: Number },
blockNumber: { type: Number },
isHome: { type: Boolean, default: false },
timestamp: { type: Date },
},
{
timestamps: false,
},
);

return mongooseClient.model('transactions', transaction);
}

module.exports = {
createModel: Transaction,
};
2 changes: 2 additions & 0 deletions feathers-src/services/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const spenders = require('./spenders/spenders.service');
const depositors = require('./depositors/depositors.service');
const information = require('./information/information.service');
const events = require('./events/events.service');
const transactions = require('./transactions/transactions.service');

// eslint-disable-next-line no-unused-vars
module.exports = app => {
Expand All @@ -17,4 +18,5 @@ module.exports = app => {
app.configure(depositors);
app.configure(information);
app.configure(events);
app.configure(transactions);
};
10 changes: 10 additions & 0 deletions feathers-src/services/transactions/transactions.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Initializes the `transactions` model and save it in app
const { createModel } = require('../../models/transactions.model');

module.exports = function serviceFactory() {
const app = this;
const Model = createModel(app);

// Save transaction model
app.set('transactionsModel', Model);
};

0 comments on commit d3b0f30

Please sign in to comment.