mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2025-06-18 18:41:21 +00:00
fix: JS-client bugs and tech debt [fixes DXJ-520] (#374)
Fix various bugs and a pair of TODO's
This commit is contained in:
@ -16,7 +16,7 @@
|
||||
|
||||
import { promises as fs } from "fs";
|
||||
|
||||
import * as api from "@fluencelabs/aqua-api/aqua-api.js";
|
||||
import { Path, Aqua } from "@fluencelabs/aqua-api/aqua-api.js";
|
||||
import {
|
||||
FunctionCallDef,
|
||||
JSONArray,
|
||||
@ -68,11 +68,16 @@ export type CompiledFile = {
|
||||
services: { [key: string]: ServiceDef };
|
||||
};
|
||||
|
||||
interface FunctionInfo {
|
||||
script: string;
|
||||
funcDef: FunctionCallDef;
|
||||
}
|
||||
|
||||
export const compileAqua = async (aquaFile: string): Promise<CompiledFile> => {
|
||||
await fs.access(aquaFile);
|
||||
|
||||
const compilationResult = await api.Aqua.compile(
|
||||
new api.Path(aquaFile),
|
||||
const compilationResult = await Aqua.compile(
|
||||
new Path(aquaFile),
|
||||
[],
|
||||
undefined,
|
||||
);
|
||||
@ -84,12 +89,10 @@ export const compileAqua = async (aquaFile: string): Promise<CompiledFile> => {
|
||||
}
|
||||
|
||||
const functions = Object.entries(compilationResult.functions)
|
||||
.map(([name, fnInfo]) => {
|
||||
.map(([name, fnInfo]: [string, FunctionInfo]) => {
|
||||
const callFn = (peer: FluencePeer, args: PassedArgs) => {
|
||||
return callAquaFunction({
|
||||
// TODO: Set our compiler here and fix this
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
||||
def: fnInfo.funcDef as FunctionCallDef,
|
||||
def: fnInfo.funcDef,
|
||||
script: fnInfo.script,
|
||||
config: {},
|
||||
peer: peer,
|
||||
@ -105,9 +108,7 @@ export const compileAqua = async (aquaFile: string): Promise<CompiledFile> => {
|
||||
|
||||
return {
|
||||
functions,
|
||||
// TODO: set our compiler here and fix this
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
||||
services: compilationResult.services as Record<string, ServiceDef>,
|
||||
services: compilationResult.services,
|
||||
};
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user