From 39bbf4ee329a94d8e425353582727af6e8fb5084 Mon Sep 17 00:00:00 2001 From: Yoojin Ko Date: Mon, 11 Mar 2024 14:06:30 +0900 Subject: [PATCH 01/10] fix: temporarily remove validation --- src/middlewares/middleware.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/middlewares/middleware.ts b/src/middlewares/middleware.ts index 1b36249..2323521 100644 --- a/src/middlewares/middleware.ts +++ b/src/middlewares/middleware.ts @@ -26,14 +26,17 @@ export default class Middleware { res.send("Not from blockchain"); return; } - const result = await this.ain.getValue(triggerPath); - // if request is first reque st, set cache + // NOTE(yoojin): Validation will changed. Temp comment out. + // 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"); return; } this.cache.set(txHash, "in_progress", 500); - _.isEqual(result, triggerValue) ? next(): res.send("Not from blockchain"); + // NOTE(yoojin): Validation will changed. Temp comment out. + // _.isEqual(result, triggerValue) ? next(): res.send("Not from blockchain"); } /** * DEPRECATED From d054ab1ff7c822aa3caa1b7543158c45555869ca Mon Sep 17 00:00:00 2001 From: Yoojin Ko Date: Mon, 11 Mar 2024 14:07:02 +0900 Subject: [PATCH 02/10] package ver --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 24138c9..b971ae0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ainize-team/ainize-js", - "version": "1.1.1", + "version": "1.1.1-beta.1", "main": "dist/ainize.js", "types": "dist/ainize.d.ts", "scripts": { From 5d8454549bd9f6297fc2c3719727fc3ce2270704 Mon Sep 17 00:00:00 2001 From: Yoojin Ko Date: Fri, 22 Mar 2024 13:50:31 +0900 Subject: [PATCH 03/10] fix: filter --- src/middlewares/middleware.ts | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/middlewares/middleware.ts b/src/middlewares/middleware.ts index 2323521..d8eb930 100644 --- a/src/middlewares/middleware.ts +++ b/src/middlewares/middleware.ts @@ -21,22 +21,26 @@ 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; + try { + const { triggerPath, triggerValue, txHash } = extractTriggerDataFromRequest(req); + if(!triggerPath || !triggerValue || !txHash) { + throw new Error("Not from blockchain"); + } + // NOTE(yoojin): Validation will changed. Temp comment out. + // 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") { + throw new Error("Duplicated"); + } + this.cache.set(txHash, "in_progress", 500); + // NOTE(yoojin): Validation will changed. Temp comment out. + // _.isEqual(result, triggerValue) ? next(): res.send("Not from blockchain"); + next(); + } catch (e) { + console.log("Filtering Error ", e) + res.send(e); } - // NOTE(yoojin): Validation will changed. Temp comment out. - // 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"); - return; - } - this.cache.set(txHash, "in_progress", 500); - // NOTE(yoojin): Validation will changed. Temp comment out. - // _.isEqual(result, triggerValue) ? next(): res.send("Not from blockchain"); } /** * DEPRECATED From 01af5995d74e8cdabcc108a95e2e71be5d37c835 Mon Sep 17 00:00:00 2001 From: Yoojin Ko Date: Fri, 22 Mar 2024 13:52:25 +0900 Subject: [PATCH 04/10] fix: add return --- src/middlewares/middleware.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/middlewares/middleware.ts b/src/middlewares/middleware.ts index d8eb930..61b6cfa 100644 --- a/src/middlewares/middleware.ts +++ b/src/middlewares/middleware.ts @@ -40,6 +40,7 @@ export default class Middleware { } catch (e) { console.log("Filtering Error ", e) res.send(e); + return; } } /** From 1541e0ffc73865416f08b98e7de46a253b1fba17 Mon Sep 17 00:00:00 2001 From: akaster99 Date: Fri, 22 Mar 2024 14:04:43 +0900 Subject: [PATCH 05/10] version update --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b971ae0..c299103 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ainize-team/ainize-js", - "version": "1.1.1-beta.1", + "version": "1.1.1-beta.2", "main": "dist/ainize.js", "types": "dist/ainize.d.ts", "scripts": { From 94609dabffd65d9534ba2064c9fb7361010a500b Mon Sep 17 00:00:00 2001 From: akaster99 Date: Fri, 22 Mar 2024 14:08:20 +0900 Subject: [PATCH 06/10] fix:duplicated filter --- src/middlewares/middleware.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/middlewares/middleware.ts b/src/middlewares/middleware.ts index 61b6cfa..0aa45eb 100644 --- a/src/middlewares/middleware.ts +++ b/src/middlewares/middleware.ts @@ -31,7 +31,8 @@ export default class Middleware { // If request is first reque st, set cache if (this.cache.get(txHash) && this.cache.get(txHash) !== "error") { - throw new Error("Duplicated"); + res.send("Duplicated"); + return; } this.cache.set(txHash, "in_progress", 500); // NOTE(yoojin): Validation will changed. Temp comment out. From cbb17373ee0709f085ed6567a77520cb7814f178 Mon Sep 17 00:00:00 2001 From: Yoojin Ko Date: Tue, 9 Apr 2024 16:37:41 +0900 Subject: [PATCH 07/10] fix: add handler connection on signer login --- src/ainize.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ainize.ts b/src/ainize.ts index 1749b60..d99bff0 100644 --- a/src/ainize.ts +++ b/src/ainize.ts @@ -49,6 +49,7 @@ export default class Ainize { async loginWithSigner() { const signer = new AinWalletSigner; this.ain.setSigner(signer); + await this.handler.connect(); console.log('login success! address: ', await this.ain.getAddress()); } From c59ae72b12a494def156628388d8c07cb4b339ac Mon Sep 17 00:00:00 2001 From: akaster99 Date: Tue, 9 Apr 2024 16:39:03 +0900 Subject: [PATCH 08/10] version update --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c299103..a703c2a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ainize-team/ainize-js", - "version": "1.1.1-beta.2", + "version": "1.1.1-beta.3", "main": "dist/ainize.js", "types": "dist/ainize.d.ts", "scripts": { From 6f1cd712da964bdfcb060e4c83ca93c7396092d6 Mon Sep 17 00:00:00 2001 From: Yoojin Ko Date: Thu, 18 Apr 2024 13:32:29 +0900 Subject: [PATCH 09/10] package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a703c2a..24138c9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ainize-team/ainize-js", - "version": "1.1.1-beta.3", + "version": "1.1.1", "main": "dist/ainize.js", "types": "dist/ainize.d.ts", "scripts": { From c903dacc6425173fff3c5beb6d6d004233523437 Mon Sep 17 00:00:00 2001 From: Yoojin Ko Date: Thu, 18 Apr 2024 13:46:24 +0900 Subject: [PATCH 10/10] fix: return commented validation --- src/middlewares/middleware.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/middlewares/middleware.ts b/src/middlewares/middleware.ts index 0aa45eb..825c0df 100644 --- a/src/middlewares/middleware.ts +++ b/src/middlewares/middleware.ts @@ -26,18 +26,15 @@ export default class Middleware { if(!triggerPath || !triggerValue || !txHash) { throw new Error("Not from blockchain"); } - // NOTE(yoojin): Validation will changed. Temp comment out. - // const result = await this.ain.getValue(triggerPath); + const result = await this.ain.getValue(triggerPath); - // If request is first reque st, set cache + // If request is first request, set cache if (this.cache.get(txHash) && this.cache.get(txHash) !== "error") { res.send("Duplicated"); return; } this.cache.set(txHash, "in_progress", 500); - // NOTE(yoojin): Validation will changed. Temp comment out. - // _.isEqual(result, triggerValue) ? next(): res.send("Not from blockchain"); - next(); + _.isEqual(result, triggerValue) ? next(): res.send("Not from blockchain"); } catch (e) { console.log("Filtering Error ", e) res.send(e);