Skip to content

Commit

Permalink
Merge pull request #96 from ainize-team/fix/woojae/triggerFilter
Browse files Browse the repository at this point in the history
fix: path
  • Loading branch information
akastercomcom authored Jan 30, 2024
2 parents 99abbf1 + dc4d34a commit 34de664
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/middlewares/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@ export default class Middleware {
blockchainTriggerFilter = async (req: Request, res: Response, next: NextFunction) => {
//check if request is from blockchain trigger
const { triggerPath, triggerValue, txHash } = extractTriggerDataFromRequest(req);
if(!triggerPath || !triggerValue || !txHash) {
res.send("Not from blockchain");
return;
}
const result = await this.ain.getValue(triggerPath);
// if request is first reque st, set cache
if (this.cache.get(txHash) && this.cache.get(txHash) !== "error") {
res.send("duplicated");
res.send("Duplicated");
return;
}
this.cache.set(txHash, "in_progress", 500);
_.isEqual(result, triggerValue) ? next(): res.send("not from blockChain");
_.isEqual(result, triggerValue) ? next(): res.send("Not from blockchain");
}
/**
* DEPRECATED
Expand Down
2 changes: 1 addition & 1 deletion src/utils/extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const extractTriggerDataFromRequest = (req:Request) => {
const triggerData = {
triggerPath: path,
triggerValue: req.body.value,
txHash: req.body.txhash,
txHash: req.body.transaction.hash,
}
return triggerData
}
Expand Down

0 comments on commit 34de664

Please sign in to comment.