|
|
@@ -6,15 +6,15 @@ import basicAuth from "express-basic-auth"
|
|
|
import {
|
|
|
CommandService_v1Client as CommandService,
|
|
|
QueryService_v1Client as QueryService
|
|
|
-} from 'iroha-helpers/lib/proto/endpoint_grpc_pb.js'
|
|
|
+} from 'iroha-helpers/lib/proto/endpoint_grpc_pb'
|
|
|
|
|
|
-import iroha from 'iroha-helpers'
|
|
|
+import { queries } from 'iroha-helpers'
|
|
|
|
|
|
const app = express();
|
|
|
app.use(bodyParser.json());
|
|
|
app.use(basicAuth({
|
|
|
-users: { admin: 'superPasswd' },
|
|
|
-challenge: true
|
|
|
+ users: { admin: 'superPasswd' },
|
|
|
+ challenge: true
|
|
|
}));
|
|
|
|
|
|
const IROHA_ADMIN_PRIV = "f101537e319568c765b2cc89698325604991dca57b9716b58016b253506cab70";
|
|
|
@@ -62,27 +62,22 @@ app.post("/buy", async (req, res, next) => {
|
|
|
}
|
|
|
|
|
|
//TODO load from headers, or something like that??
|
|
|
- if (!req.body.user) {
|
|
|
+ if (!req.body.user) {
|
|
|
res.status(400);
|
|
|
throw Error(JSON.stringify({ error: { name: "Error, request body has no \"user\" property!" } }));
|
|
|
}
|
|
|
|
|
|
let txDetail = await getTransactionDetail(req.body.txHash, "kunicykd@test");
|
|
|
|
|
|
- if()
|
|
|
+ res.send(txDetail);
|
|
|
}
|
|
|
catch (err) {
|
|
|
next(err);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
-
|
|
|
-function isTransacationValid(){
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-async function getTransactionDetail(txHash, user) {
|
|
|
- let quer = await iroha.queries.getAccountTransactions({
|
|
|
+async function getTransactionDetail(txHash: string, user: string) {
|
|
|
+ let quer: any = await queries.getAccountTransactions({
|
|
|
privateKey: IROHA_ADMIN_PRIV,
|
|
|
creatorAccountId: 'admin@test',
|
|
|
queryService,
|
|
|
@@ -102,10 +97,10 @@ async function getTransactionDetail(txHash, user) {
|
|
|
});
|
|
|
|
|
|
//TODO find better way to look for transferAssets command in transaction
|
|
|
- return quer.transactionsList[0].payload.reducedPayload.commandsList[0].transferAsset;
|
|
|
+ return quer.transactionsList[0].payload.reducedPayload.commandsList[0].transferAsset;
|
|
|
}
|
|
|
|
|
|
-function getArea(extent: Array<Array<number>>) : number {
|
|
|
+function getArea(extent: Array<Array<number>>): number {
|
|
|
|
|
|
let y1 = extent[0][1];
|
|
|
let y4 = extent[3][1];
|
|
|
@@ -119,7 +114,7 @@ function getArea(extent: Array<Array<number>>) : number {
|
|
|
return height * width;
|
|
|
}
|
|
|
|
|
|
-function getPrice(extent: Array<Array<number>>) : number{
|
|
|
+function getPrice(extent: Array<Array<number>>): number {
|
|
|
return getArea(extent) * PRICE_MODIFIER;
|
|
|
}
|
|
|
|