MCPcopy Create free account
hub / github.com/chainjet/platform / getTemplate

Method getTemplate

apps/api/src/compiler/compiler.service.ts:105–134  ·  view source on GitHub ↗
(workflowAction: WorkflowAction, allActions: WorkflowAction[], usedVars: VarEvm[])

Source from the content-addressed store, hash-verified

103 }
104
105 private async getTemplate(workflowAction: WorkflowAction, allActions: WorkflowAction[], usedVars: VarEvm[]) {
106 const integrationAction = await this.integrationActionService.findById(
107 workflowAction.integrationAction._id.toString(),
108 )
109 if (!integrationAction) {
110 throw new InternalServerErrorException(`Integration action ${workflowAction.integrationAction.id} not found`)
111 }
112 const integration = await this.integrationService.findById(integrationAction.integration._id.toString())
113 if (!integration) {
114 throw new InternalServerErrorException(`Integration ${integrationAction.integration.id} not found`)
115 }
116 const definition = this.integrationDefinitionFactory.getDefinition(integration.parentKey ?? integration.key)
117 const operationAction = definition.actions.find((action) => action.key === integrationAction.key) as OperationEvm
118
119 // interpolate solidity variables
120 const inputs = { ...workflowAction.inputs }
121 for (const [key, value] of Object.entries(inputs)) {
122 const interpolated = getInterpolatedValue(value)
123 if (interpolated && interpolated.split('.').length === 2) {
124 const id = interpolated.split('.')[0]
125 const action = allActions.find((action) => action._id.toString() === id)
126 if (action) {
127 const varKey = interpolated.split('.')[1]
128 inputs[key] = `{{solidity:${varKey}}}`
129 }
130 }
131 }
132
133 return operationAction.template(inputs, usedVars)
134 }
135
136 private async compileSourceCode(workflowId: string, sourcecode: string) {
137 const fileName = `workflow-${workflowId}.sol`

Callers 1

compileMethod · 0.95

Calls 4

getInterpolatedValueFunction · 0.90
findByIdMethod · 0.80
getDefinitionMethod · 0.45
templateMethod · 0.45

Tested by

no test coverage detected