From 453ff5fc5988168cf33a17e1c29e18ac521fd2c7 Mon Sep 17 00:00:00 2001 From: Yoojin Ko Date: Thu, 21 Sep 2023 10:57:25 +0900 Subject: [PATCH 1/3] feat: add service function --- src/controllers/appController.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/controllers/appController.ts b/src/controllers/appController.ts index 8a65579..2a1f1f9 100644 --- a/src/controllers/appController.ts +++ b/src/controllers/appController.ts @@ -35,10 +35,20 @@ export default class AppController { setRuleOps.push(ruleOp); } - const depositParam = this.depositTriggerFunctionConfig(appName, serviceUrl); - const value = this.buildSetFunctionValue(depositParam); - const funcOp = buildSetOperation("SET_FUNCTION", depositParam.ref, value); - setFunctionOps.push(funcOp); + const depositPath = `${Path.app(appName).depositOfUser("$userAddress")}/$transferKey` + const depositUrl = `${serviceUrl}/deposit`; + const depositParam = this.buildTriggerFunctionConfig(appName, depositPath, depositUrl); + const depositValue = this.buildSetFunctionValue(depositParam); + const depositFuncOp = buildSetOperation("SET_FUNCTION", depositParam.ref, depositValue); + setFunctionOps.push(depositFuncOp); + + const serviceFuncPath = Path.app(appName).request("$userAddress", "$requestKey") + const serviceFuncUrl = `${serviceUrl}/service`; + const serviceFuncParam = this.buildTriggerFunctionConfig(appName, serviceFuncPath, serviceFuncUrl); + const serviceFuncValue = this.buildSetFunctionValue(serviceFuncParam); + const serviceFuncOp = buildSetOperation("SET_FUNCTION", depositParam.ref, serviceFuncValue); + setFunctionOps.push(serviceFuncOp); + const configOp = this.buildSetAppBillingConfigOp(appName, billingConfig); setBillingConfigOps.push(configOp); @@ -214,7 +224,7 @@ export default class AppController { return buildSetOperation("SET_VALUE", path, value); } - private depositTriggerFunctionConfig = (appName: string, serviceUrl: string): setTriggerFunctionParm => { + private buildTriggerFunctionConfig = (appName: string, path: string, serviceUrl: string): setTriggerFunctionParm => { return { ref: `${Path.app(appName).depositOfUser("$userAddress")}/$transferKey`, function_type: "REST", From a640406e9eecefffe88627780d1d92e2a9d4bb3d Mon Sep 17 00:00:00 2001 From: Yoojin Ko Date: Thu, 21 Sep 2023 12:13:12 +0900 Subject: [PATCH 2/3] fix: trigger function --- src/controllers/appController.ts | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/controllers/appController.ts b/src/controllers/appController.ts index 2a1f1f9..f3d0e64 100644 --- a/src/controllers/appController.ts +++ b/src/controllers/appController.ts @@ -37,16 +37,26 @@ export default class AppController { const depositPath = `${Path.app(appName).depositOfUser("$userAddress")}/$transferKey` const depositUrl = `${serviceUrl}/deposit`; - const depositParam = this.buildTriggerFunctionConfig(appName, depositPath, depositUrl); + const depositParam: setTriggerFunctionParm = { + ref: depositPath, + function_id: "deposit-tregger", + function_type: "REST", + function_url: depositUrl + } const depositValue = this.buildSetFunctionValue(depositParam); const depositFuncOp = buildSetOperation("SET_FUNCTION", depositParam.ref, depositValue); setFunctionOps.push(depositFuncOp); const serviceFuncPath = Path.app(appName).request("$userAddress", "$requestKey") const serviceFuncUrl = `${serviceUrl}/service`; - const serviceFuncParam = this.buildTriggerFunctionConfig(appName, serviceFuncPath, serviceFuncUrl); + const serviceFuncParam: setTriggerFunctionParm = { + ref: serviceFuncPath, + function_id: "service-tregger", + function_type: "REST", + function_url: serviceFuncUrl + } const serviceFuncValue = this.buildSetFunctionValue(serviceFuncParam); - const serviceFuncOp = buildSetOperation("SET_FUNCTION", depositParam.ref, serviceFuncValue); + const serviceFuncOp = buildSetOperation("SET_FUNCTION", serviceFuncParam.ref, serviceFuncValue); setFunctionOps.push(serviceFuncOp); const configOp = this.buildSetAppBillingConfigOp(appName, billingConfig); @@ -223,13 +233,4 @@ export default class AppController { const value = !isRemoveOp ? null : true; return buildSetOperation("SET_VALUE", path, value); } - - private buildTriggerFunctionConfig = (appName: string, path: string, serviceUrl: string): setTriggerFunctionParm => { - return { - ref: `${Path.app(appName).depositOfUser("$userAddress")}/$transferKey`, - function_type: "REST", - function_id: "deposit-trigger", - function_url: `${serviceUrl}/deposit`, - } - } } From 15441310c11346536a138a8a1b1189d2a2abf330 Mon Sep 17 00:00:00 2001 From: Yoojin Ko Date: Thu, 21 Sep 2023 13:41:48 +0900 Subject: [PATCH 3/3] fix: typo --- src/controllers/appController.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/appController.ts b/src/controllers/appController.ts index f3d0e64..2007a0e 100644 --- a/src/controllers/appController.ts +++ b/src/controllers/appController.ts @@ -39,7 +39,7 @@ export default class AppController { const depositUrl = `${serviceUrl}/deposit`; const depositParam: setTriggerFunctionParm = { ref: depositPath, - function_id: "deposit-tregger", + function_id: "deposit-trigger", function_type: "REST", function_url: depositUrl } @@ -51,7 +51,7 @@ export default class AppController { const serviceFuncUrl = `${serviceUrl}/service`; const serviceFuncParam: setTriggerFunctionParm = { ref: serviceFuncPath, - function_id: "service-tregger", + function_id: "service-trigger", function_type: "REST", function_url: serviceFuncUrl }