Skip to content

Commit

Permalink
Fix: Putting contract into MOL (replace MOL if already exists).
Browse files Browse the repository at this point in the history
  • Loading branch information
zoernert committed Jan 25, 2024
1 parent 5be6fef commit c60a444
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions framework/services/contract.service.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
"use strict";

const axios = require("axios");


/**
* @typedef {import('moleculer').ServiceSchema} ServiceSchema Moleculer's Service Schema
* @typedef {import('moleculer').Context} Context Moleculer's Context
Expand All @@ -23,7 +20,7 @@ module.exports = {
actions: {
add: {
rest: {
method: "GET",
method: "POST",
path: "/add"
},
params: {
Expand All @@ -47,8 +44,13 @@ module.exports = {
* @return {Array} the result of the function
*/
async handler(ctx) {
ctx.params.contractId = await ctx.call("access.randomString",{});
ctx.params.contractId = await ctx.call("access.randomString",{length:10});
const contract = await ctx.call("contract_model.insert",{entity:ctx.params});
// for the moment we only allow one entry in the MOL
await ctx.call("meritorder.set",{
assetId:ctx.params.assetId,
mol:[ctx.params]
});
return ctx.params;
},
}
Expand Down

0 comments on commit c60a444

Please sign in to comment.