From c60a444b8db7797f5980cb10d6880b71e0e30d99 Mon Sep 17 00:00:00 2001 From: Thorsten Zoerner Date: Thu, 25 Jan 2024 01:31:57 +0100 Subject: [PATCH] Fix: Putting contract into MOL (replace MOL if already exists). --- framework/services/contract.service.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/framework/services/contract.service.js b/framework/services/contract.service.js index 2930a86..07b08a0 100644 --- a/framework/services/contract.service.js +++ b/framework/services/contract.service.js @@ -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 @@ -23,7 +20,7 @@ module.exports = { actions: { add: { rest: { - method: "GET", + method: "POST", path: "/add" }, params: { @@ -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; }, }