Skip to content

Commit

Permalink
Merge pull request #31 from Chia-Network/feat-replace-detok-file-with…
Browse files Browse the repository at this point in the history
…-detok-string

feat: replace detok file with detok string
  • Loading branch information
MichaelTaylor3D authored Nov 11, 2022
2 parents 764d680 + 5701455 commit 2d873a5
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const validator = joiExpress.createValidator({ passError: true });
const { updateConfig, getConfig } = require("./utils/config-loader");
const { connectToOrgSchema, tokenizeUnitSchema } = require("./validations.js");
const { getStoreIds } = require("./datalayer.js");
const { unzipAndUnlockZipFile } = require("./utils/decompress");

const app = express();
const port = 31311;
Expand Down Expand Up @@ -440,10 +439,7 @@ const getTokenizedUnitByAssetId = async (assetId) => {

app.post("/parse-detok-file", async (req, res) => {
try {
const password = req.body.password;
const filePath = req.files.file.path;

let detokString = await unzipAndUnlockZipFile(filePath, password);
let detokString = req.body.detokString;
detokString = detokString.replace(/(\r\n|\n|\r)/gm, "");
const detokStringkIsValid =
typeof detokString === "string" && detokString.startsWith("detok");
Expand All @@ -469,7 +465,7 @@ app.post("/parse-detok-file", async (req, res) => {
if (parseDetokResponse?.payment?.amount) {
unitToBeDetokenized.unitCount = parseDetokResponse?.payment?.amount;
}

const project = await getProjectByWarehouseProjectId(
unitToBeDetokenized?.issuance?.warehouseProjectId
);
Expand All @@ -489,7 +485,7 @@ app.post("/parse-detok-file", async (req, res) => {
index: parsedAssetIdOrgMetaData?.index,
public_key: parsedAssetIdOrgMetaData?.public_key,
asset_id: assetId,
warehouse_project_id: project.warehouseProjectId
warehouse_project_id: project.warehouseProjectId,
},
content: detokString,
unit: unitToBeDetokenized,
Expand Down

0 comments on commit 2d873a5

Please sign in to comment.