|
@@ -7,8 +7,9 @@ import {
|
|
|
CommandService_v1Client as CommandService,
|
|
CommandService_v1Client as CommandService,
|
|
|
QueryService_v1Client as QueryService
|
|
QueryService_v1Client as QueryService
|
|
|
} from 'iroha-helpers/lib/proto/endpoint_grpc_pb'
|
|
} from 'iroha-helpers/lib/proto/endpoint_grpc_pb'
|
|
|
-
|
|
|
|
|
import { queries } from 'iroha-helpers'
|
|
import { queries } from 'iroha-helpers'
|
|
|
|
|
+import util from 'util'
|
|
|
|
|
+import { exec } from 'child_process'
|
|
|
|
|
|
|
|
const app = express();
|
|
const app = express();
|
|
|
app.use(bodyParser.json());
|
|
app.use(bodyParser.json());
|
|
@@ -17,6 +18,8 @@ app.use(basicAuth({
|
|
|
challenge: true
|
|
challenge: true
|
|
|
}));
|
|
}));
|
|
|
|
|
|
|
|
|
|
+const asyncExec = util.promisify(exec);
|
|
|
|
|
+
|
|
|
const IROHA_ADMIN_PRIV = "f101537e319568c765b2cc89698325604991dca57b9716b58016b253506cab70";
|
|
const IROHA_ADMIN_PRIV = "f101537e319568c765b2cc89698325604991dca57b9716b58016b253506cab70";
|
|
|
const IROHA_ADMIN = "admin@test";
|
|
const IROHA_ADMIN = "admin@test";
|
|
|
const IROHA_ADDRESS = "localhost:50051";
|
|
const IROHA_ADDRESS = "localhost:50051";
|
|
@@ -24,7 +27,7 @@ const commandService = new CommandService(IROHA_ADDRESS, grpc.credentials.create
|
|
|
const queryService = new QueryService(IROHA_ADDRESS, grpc.credentials.createInsecure());
|
|
const queryService = new QueryService(IROHA_ADDRESS, grpc.credentials.createInsecure());
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+const CHAIN4ALL_RASTER_CLIP_SCRIPT_PATH = process.env.CHAIN4ALL_RASTER_CLIP_SCRIPT_PATH || '/home/kunickyd/Documents/chain4all/chain4all_raster_clip.sh';
|
|
|
const CHAIN4ALL_SERVICE_PORT = process.env.CHAIN4ALL_SERVICE_PORT || 3000;
|
|
const CHAIN4ALL_SERVICE_PORT = process.env.CHAIN4ALL_SERVICE_PORT || 3000;
|
|
|
const IROHA_API_HOST = process.env.IROHA_API_HOST || "http://localhost";
|
|
const IROHA_API_HOST = process.env.IROHA_API_HOST || "http://localhost";
|
|
|
const IROHA_API_PORT = process.env.IROHA_API_PORT || 5000;
|
|
const IROHA_API_PORT = process.env.IROHA_API_PORT || 5000;
|
|
@@ -67,11 +70,16 @@ app.post("/buy", async (req, res, next) => {
|
|
|
throw Error(JSON.stringify({ error: { name: "Error, request body has no \"user\" property!" } }));
|
|
throw Error(JSON.stringify({ error: { name: "Error, request body has no \"user\" property!" } }));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //TODO validate this properly
|
|
|
let txDetail = await getTransactionDetail(req.body.txHash, req.body.user);
|
|
let txDetail = await getTransactionDetail(req.body.txHash, req.body.user);
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
+ const { stdout, stderr } = await asyncExec(CHAIN4ALL_RASTER_CLIP_SCRIPT_PATH);
|
|
|
|
|
+
|
|
|
|
|
+ if(stderr){
|
|
|
|
|
+ throw(stderr);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- res.send(txDetail);
|
|
|
|
|
|
|
+ res.send(stdout);
|
|
|
}
|
|
}
|
|
|
catch (err) {
|
|
catch (err) {
|
|
|
next(err);
|
|
next(err);
|
|
@@ -81,7 +89,7 @@ app.post("/buy", async (req, res, next) => {
|
|
|
async function getTransactionDetail(txHash: string, user: string) {
|
|
async function getTransactionDetail(txHash: string, user: string) {
|
|
|
let quer: any = await queries.getAccountTransactions({
|
|
let quer: any = await queries.getAccountTransactions({
|
|
|
privateKey: IROHA_ADMIN_PRIV,
|
|
privateKey: IROHA_ADMIN_PRIV,
|
|
|
- creatorAccountId: 'admin@test',
|
|
|
|
|
|
|
+ creatorAccountId: IROHA_ADMIN,
|
|
|
queryService,
|
|
queryService,
|
|
|
timeoutLimit: 5000
|
|
timeoutLimit: 5000
|
|
|
}, {
|
|
}, {
|