Browse Source

fake buy - no payment

kunickyd 3 years ago
parent
commit
d7f691fe67
1 changed files with 24 additions and 26 deletions
  1. 24 26
      app.js

+ 24 - 26
app.js

@@ -52,7 +52,7 @@ app.get("/users/:userId/assets/:assetId", async (req, res, next) => {
         let irohaResponse = await fetchUsersAssets(req.params.userId);
         let irohaResponseJson = await irohaResponse.json();        
         let assets = irohaResponseJson.assets;
-        
+
         let parsedAssetName = "";
         let i = 0;
         for (i; i < assets.length; i++) {
@@ -96,37 +96,35 @@ app.post("/buy", async (req, res, next) => {
 
         let price = getPrice(req.body.extent);
 
-        let irohaResponse = await forwardBuyRequest(
-            {
-                privateKey: req.body.privateKey,
-                transfers: [
-                    {
-                        asset: IROHA_ASSET + "#" + IROHA_DOMAIN,
-                        source: req.body.user + "@" + IROHA_DOMAIN,
-                        destination: DATA_OWNER + "@" + IROHA_DOMAIN,
-                        description: "test", //TODO: compose uniform description
-                        amount: price
-                    }
-                ]
-            }
-        );
-
-        let data = "test - to be implemented"; //TODO implement data extraction 
+        // let irohaResponse = await forwardBuyRequest(
+        //     {
+        //         privateKey: req.body.privateKey,
+        //         transfers: [
+        //             {
+        //                 asset: IROHA_ASSET + "#" + IROHA_DOMAIN,
+        //                 source: req.body.user + "@" + IROHA_DOMAIN,
+        //                 destination: DATA_OWNER + "@" + IROHA_DOMAIN,
+        //                 description: "test", //TODO: compose uniform description
+        //                 amount: price
+        //             }
+        //         ]
+        //     }
+        // );
 
-        res.status(irohaResponse.status);
+        let data = "https://gis.lesprojekt.cz/chain4all/raster_112233.tif"; //TODO implement data extraction 
 
-        if (!irohaResponse.ok) {
-            res.send(await irohaResponse.json());
-            return;
-        }
+        // res.status(irohaResponse.status);
 
-        let irohaResponseJson = await irohaResponse.json();
+        // if (!irohaResponse.ok) {
+        //     res.send(await irohaResponse.json());
+        //     return;
+        // }
 
-        console.log("tx hash: " + irohaResponseJson.transactionHash);
+        // let irohaResponseJson = await irohaResponse.json();
 
         res.send({
-            data: data,
-            transactionHash: irohaResponseJson.transactionHash
+            dataUrl: data,
+            transactionHash: "91edf4700823a82ee8f57889cb620094cd1f5bb68d1273b093b17d128e62a590"//irohaResponseJson.transactionHash 
         });
     }
     catch (err) {