Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix trigger function #54

Merged
merged 3 commits into from
Sep 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 24 additions & 13 deletions src/controllers/appController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,30 @@ 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: setTriggerFunctionParm = {
ref: depositPath,
function_id: "deposit-trigger",
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: setTriggerFunctionParm = {
ref: serviceFuncPath,
function_id: "service-trigger",
function_type: "REST",
function_url: serviceFuncUrl
}
const serviceFuncValue = this.buildSetFunctionValue(serviceFuncParam);
const serviceFuncOp = buildSetOperation("SET_FUNCTION", serviceFuncParam.ref, serviceFuncValue);
setFunctionOps.push(serviceFuncOp);

const configOp = this.buildSetAppBillingConfigOp(appName, billingConfig);
setBillingConfigOps.push(configOp);

Expand Down Expand Up @@ -213,13 +233,4 @@ export default class AppController {
const value = !isRemoveOp ? null : true;
return buildSetOperation("SET_VALUE", path, value);
}

private depositTriggerFunctionConfig = (appName: string, serviceUrl: string): setTriggerFunctionParm => {
return {
ref: `${Path.app(appName).depositOfUser("$userAddress")}/$transferKey`,
function_type: "REST",
function_id: "deposit-trigger",
function_url: `${serviceUrl}/deposit`,
}
}
}