Skip to content

Commit

Permalink
chore: Review fixes at #378 (#383)
Browse files Browse the repository at this point in the history
* Review fixes

* remove logs

* Fixes

* Todo to remove prefix later

* Refactor service signatures

* Fixes

* Update lock file

* Fix lockfile

* Update deps

* More fixes and renames

* Fix compiler

* Peer refactoring and cutting onConnectionChange API

* Revert deleted API
  • Loading branch information
Akim authored Nov 22, 2023
1 parent f4a550d commit 98462bf
Show file tree
Hide file tree
Showing 34 changed files with 2,403 additions and 575 deletions.
4 changes: 2 additions & 2 deletions packages/@tests/aqua/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
"base64-js": "1.5.1"
},
"devDependencies": {
"@fluencelabs/aqua-api": "0.12.4-main-cee4448-2196-1",
"@fluencelabs/aqua-api": "0.13.0",
"@fluencelabs/aqua-lib": "0.6.0",
"@fluencelabs/aqua-to-js": "workspace:*",
"@fluencelabs/js-client": "workspace:*",
"@fluencelabs/registry": "0.8.8-1",
"@fluencelabs/registry": "0.9.0",
"@fluencelabs/trust-graph": "3.1.2",
"ts-node": "10.9.1"
}
Expand Down
6 changes: 0 additions & 6 deletions packages/@tests/aqua/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

import { Fluence, type ClientConfig } from "@fluencelabs/js-client";
import { fromByteArray } from "base64-js";

import { test as particleTest } from "./_aqua/finalize_particle.js";
import {
Expand Down Expand Up @@ -56,10 +55,6 @@ export type TestResult =

export const runTest = async (): Promise<TestResult> => {
try {
Fluence.onConnectionStateChange((state) => {
console.info("connection state changed: ", state);
});

console.log("connecting to Fluence Network...");
console.log("multiaddr: ", relay.multiaddr);

Expand All @@ -82,7 +77,6 @@ export const runTest = async (): Promise<TestResult> => {
const client = Fluence.getClient();

console.log("my peer id: ", client.getPeerId());
console.log("my sk id: ", fromByteArray(client.getPeerSecretKey()));

console.log("running hello test...");
const hello = await helloTest();
Expand Down
4 changes: 2 additions & 2 deletions packages/core/aqua-to-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
"ts-pattern": "5.0.5"
},
"devDependencies": {
"@fluencelabs/aqua-api": "0.12.4-main-cee4448-2196-1",
"@fluencelabs/aqua-api": "0.13.0",
"@fluencelabs/aqua-lib": "0.7.3",
"@fluencelabs/interfaces": "workspace:*",
"@fluencelabs/js-client": "workspace:^",
"@fluencelabs/registry": "0.8.7",
"@fluencelabs/registry": "0.9.0",
"@fluencelabs/spell": "0.5.20",
"@fluencelabs/trust-graph": "0.4.7",
"vitest": "0.34.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,51 @@ import {
v5_registerService as registerService$$
} from '@fluencelabs/js-client';

// Services
export interface SrvDef {
create: (wasm_b64_content: string, callParams: ParticleContext$$) => { error: string | null; service_id: string | null; success: boolean; } | Promise<{ error: string | null; service_id: string | null; success: boolean; }>;
list: (callParams: ParticleContext$$) => string[] | Promise<string[]>;
remove: (service_id: string, callParams: ParticleContext$$) => { error: string | null; success: boolean; } | Promise<{ error: string | null; success: boolean; }>;
}
export function registerSrv(service: SrvDef): void;
export function registerSrv(serviceId: string, service: SrvDef): void;
export function registerSrv(peer: IFluenceClient$$, service: SrvDef): void;
export function registerSrv(peer: IFluenceClient$$, serviceId: string, service: SrvDef): void;
export interface CalcServiceDef {
divide: (num: number, callParams: ParticleContext$$) => number | Promise<number>;
clear_state: (callParams: ParticleContext$$) => void | Promise<void>;
test_logs: (callParams: ParticleContext$$) => void | Promise<void>;
multiply: (num: number, callParams: ParticleContext$$) => number | Promise<number>;
add: (num: number, callParams: ParticleContext$$) => number | Promise<number>;
state: (callParams: ParticleContext$$) => number | Promise<number>;
subtract: (num: number, callParams: ParticleContext$$) => number | Promise<number>;
}
export function registerCalcService(serviceId: string, service: CalcServiceDef): void;
export function registerCalcService(peer: IFluenceClient$$, serviceId: string, service: CalcServiceDef): void;
export interface HelloWorldDef {
hello: (str: string, callParams: ParticleContext$$) => string | Promise<string>;
}
export function registerHelloWorld(service: HelloWorldDef): void;
export function registerHelloWorld(serviceId: string, service: HelloWorldDef): void;
export function registerHelloWorld(peer: IFluenceClient$$, service: HelloWorldDef): void;
export function registerHelloWorld(peer: IFluenceClient$$, serviceId: string, service: HelloWorldDef): void;

// Functions
export type ResourceTestResultType = [string | null, string[]]

export type ResourceTestParams = [label: string, config?: {ttl?: number}] | [peer: IFluenceClient$$, label: string, config?: {ttl?: number}];

export type ResourceTestResult = Promise<ResourceTestResultType>;

export type HelloTestParams = [config?: {ttl?: number}] | [peer: IFluenceClient$$, config?: {ttl?: number}];

export type HelloTestResult = Promise<string>;

export type Demo_calculationParams = [service_id: string, config?: {ttl?: number}] | [peer: IFluenceClient$$, service_id: string, config?: {ttl?: number}];

export type Demo_calculationResult = Promise<number>;

export type MarineTestParams = [wasm64: string, config?: {ttl?: number}] | [peer: IFluenceClient$$, wasm64: string, config?: {ttl?: number}];

export type MarineTestResult = Promise<number>;

Loading

0 comments on commit 98462bf

Please sign in to comment.