diff --git a/.fluence/schemas/env.json b/.fluence/schemas/env.json index 53bb4492..9c03303a 100644 --- a/.fluence/schemas/env.json +++ b/.fluence/schemas/env.json @@ -11,14 +11,13 @@ "enum": [ "dar", "stage", - "kras", "local", "custom" ], "nullable": true }, "version": { - "type": "number", + "type": "integer", "const": 0 } }, diff --git a/.github/release-please/config.json b/.github/release-please/config.json index 4091172e..93787a8a 100644 --- a/.github/release-please/config.json +++ b/.github/release-please/config.json @@ -13,6 +13,7 @@ "packages/core/marine-worker": {}, "packages/core/aqua-to-js": {}, "packages/core/interfaces": {}, - "packages/core/npm-aqua-compiler": {} + "packages/core/npm-aqua-compiler": {}, + "packages/core/fluence-network-environment": {} } } diff --git a/.github/release-please/manifest.json b/.github/release-please/manifest.json index 9d20d83e..d42b427e 100644 --- a/.github/release-please/manifest.json +++ b/.github/release-please/manifest.json @@ -4,5 +4,6 @@ "packages/core/aqua-to-js": "0.3.13", "packages/core/js-client-isomorphic": "0.6.0", "packages/core/interfaces": "0.12.0", - "packages/core/npm-aqua-compiler": "0.0.3" + "packages/core/npm-aqua-compiler": "0.0.3", + "packages/core/fluence-network-environment": "1.1.2" } diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index a93f8e23..7033124d 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -43,6 +43,7 @@ jobs: uses: fluencelabs/aqua/.github/workflows/tests.yml@main with: js-client-snapshots: "${{ needs.js-client.outputs.js-client-snapshots }}" + nox-image: "docker.fluence.dev/nox:feat-vm-425-aquavm-mem-limits-from-config-2_5056_1" flox: needs: - js-client @@ -50,3 +51,4 @@ jobs: uses: fluencelabs/flox/.github/workflows/tests.yml@main with: js-client-snapshots: "${{ needs.js-client.outputs.js-client-snapshots }}" + nox-image: "docker.fluence.dev/nox:feat-vm-425-aquavm-mem-limits-from-config-2_5056_1" diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 69395c41..9b42314e 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -28,4 +28,4 @@ jobs: uses: ./.github/workflows/tests.yml with: ref: ${{ github.ref }} - nox-image: "docker.fluence.dev/nox:renovate-avm_4905_1" + nox-image: "docker.fluence.dev/nox:feat-vm-425-aquavm-mem-limits-from-config-2_5056_1" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3b2db7f9..b79a0d4a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -81,6 +81,8 @@ jobs: - name: Run nox network run: fluence local up + env: + FCLI_V_NOX: docker.fluence.dev/nox:feat-vm-425-aquavm-mem-limits-from-config-2_5056_1 - name: Setup pnpm uses: pnpm/action-setup@v2.2.4 diff --git a/packages/core/aqua-to-js/src/generate/service.ts b/packages/core/aqua-to-js/src/generate/service.ts index 13cb89ab..7ff57f50 100644 --- a/packages/core/aqua-to-js/src/generate/service.ts +++ b/packages/core/aqua-to-js/src/generate/service.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { JSONValue, ServiceDef } from "@fluencelabs/interfaces"; +import { ServiceDef } from "@fluencelabs/interfaces"; import { recursiveRenameLaquaProps } from "../utils.js"; @@ -63,6 +63,6 @@ function generateRegisterServiceOverload( } function serviceToJson(service: ServiceDef): string { - const record: Record = service; + const record: Record = service; return JSON.stringify(recursiveRenameLaquaProps(record), null, 4); } diff --git a/packages/core/aqua-to-js/src/utils.ts b/packages/core/aqua-to-js/src/utils.ts index d56cb477..847908dc 100644 --- a/packages/core/aqua-to-js/src/utils.ts +++ b/packages/core/aqua-to-js/src/utils.ts @@ -20,7 +20,6 @@ import { join } from "path"; import { ArrowType, ArrowWithoutCallbacks, - JSONValue, LabeledProductType, NilType, SimpleTypes, @@ -67,7 +66,7 @@ export function getFuncArgs( } } -export function recursiveRenameLaquaProps(obj: JSONValue): unknown { +export function recursiveRenameLaquaProps(obj: unknown): unknown { if (typeof obj !== "object" || obj === null) { return obj; } @@ -78,7 +77,9 @@ export function recursiveRenameLaquaProps(obj: JSONValue): unknown { }); } - return Object.getOwnPropertyNames(obj).reduce((acc, prop) => { + const objType: Record = obj; + + return Object.getOwnPropertyNames(objType).reduce((acc, prop) => { let accessProp = prop; if (prop.includes("Laqua_js")) { @@ -89,12 +90,14 @@ export function recursiveRenameLaquaProps(obj: JSONValue): unknown { throw new Error(`Bad property name: ${prop}.`); } - if (refinedProperty in obj) { + if (refinedProperty in objType) { accessProp = refinedProperty; } } - const laquaProp = obj[accessProp]; + const accessObj: Record = objType; + + const laquaProp = accessObj[accessProp]; if (laquaProp === undefined) { return acc; diff --git a/packages/core/fluence-network-environment/.gitignore b/packages/core/fluence-network-environment/.gitignore new file mode 100644 index 00000000..99246bb7 --- /dev/null +++ b/packages/core/fluence-network-environment/.gitignore @@ -0,0 +1,16 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release +bundle/ +dist/ + +# Dependency directories +node_modules/ +jspm_packages/ \ No newline at end of file diff --git a/packages/core/fluence-network-environment/CHANGELOG.md b/packages/core/fluence-network-environment/CHANGELOG.md new file mode 100644 index 00000000..7377325e --- /dev/null +++ b/packages/core/fluence-network-environment/CHANGELOG.md @@ -0,0 +1,28 @@ +# Changelog + +## [1.1.2](https://github.com/fluencelabs/fluence-network-environment/compare/fluence-network-environment-v1.1.1...fluence-network-environment-v1.1.2) (2023-07-05) + + +### Bug Fixes + +* Update DNS records after kras migration to Nomad ([#11](https://github.com/fluencelabs/fluence-network-environment/issues/11)) ([446df4f](https://github.com/fluencelabs/fluence-network-environment/commit/446df4f5eaa64d8d5b803e23f73b8cf8e4331d2e)) + +## [1.1.1](https://github.com/fluencelabs/fluence-network-environment/compare/fluence-network-environment-v1.1.0...fluence-network-environment-v1.1.1) (2023-07-03) + + +### Bug Fixes + +* Actually build package ([#9](https://github.com/fluencelabs/fluence-network-environment/issues/9)) ([25ef57e](https://github.com/fluencelabs/fluence-network-environment/commit/25ef57e061d75abaa08d58a4fef89e71d9cfb4da)) + +## [1.1.0](https://github.com/fluencelabs/fluence-network-environment/compare/fluence-network-environment-v1.0.14...fluence-network-environment-v1.1.0) (2023-06-19) + + +### Features + +* Rename krasnodar to kras. Add functions to pick random nodes ([#4](https://github.com/fluencelabs/fluence-network-environment/issues/4)) ([a65217f](https://github.com/fluencelabs/fluence-network-environment/commit/a65217fd2e0d3c65f4ae54105b54018af778e92d)) +* Update stage multiaddr ([#7](https://github.com/fluencelabs/fluence-network-environment/issues/7)) ([3c0f1f8](https://github.com/fluencelabs/fluence-network-environment/commit/3c0f1f89a5f713e94ee0104bcf0fa9b66f8a5cca)) + + +### Bug Fixes + +* Update testnet DNS records ([#8](https://github.com/fluencelabs/fluence-network-environment/issues/8)) ([2ed6209](https://github.com/fluencelabs/fluence-network-environment/commit/2ed6209c9c122fe2cd2b7811379c97163c64db88)) diff --git a/packages/core/fluence-network-environment/README.md b/packages/core/fluence-network-environment/README.md new file mode 100644 index 00000000..b00f9f64 --- /dev/null +++ b/packages/core/fluence-network-environment/README.md @@ -0,0 +1,65 @@ +# Fluence network environment + +[![npm](https://img.shields.io/npm/v/@fluencelabs/fluence-network-environment)](https://www.npmjs.com/package/@fluencelabs/fluence-network-environment) + +Maintained list of well-known Fluence network nodes. The package is meant to be used in combination with [Fluence JS SDK](https://github.com/fluencelabs/fluence-js). + +## Installation + +With npm + +```bash +npm install @fluencelabs/fluence-network-environment +``` + +With yarn + +```bash +yarn add @fluencelabs/fluence-network-environment +``` + +## Usage + +Pick a node to connect to the Fluence network. + +```typescript +import { testNet } from "@fluencelabs/fluence-network-environment"; + +export const relayNode = testNet[0]; +``` + +Which can be used to initialize the Fluence client (see [Fluence JS SDK](https://github.com/fluencelabs/fluence-js).) + +```typescript +import { FluencePeer } from "@fluencelabs/fluence"; + +const peer = new FluencePeer(); +await peer.start({ connectTo: relayNode }); +``` + +## Known networks + +- stage - unstable network for development tests; low capacity +- TestNet - more stable network, used for QA of new releases; higher capacity +- Kras - stable network, has the highest load capacity + +All 3 networks are connected, i.e. any node can be discovered from every other. They're open and permissionless, meaning that anyone can use any node for bootstrapping. + +## Fluence Stack + +| Layer | Tech | Scale | State | Based on | +| :-------------------: | :-------------------------------------------------------------------------------------------------------------------------------: | :------------------------------: | :-------------------------------: | :-----------------------------------------------------------------------------------------------------------: | +| Execution | [Marine](https://github.com/fluencelabs/marine) | Single peer | Disk, network, external processes | Wasm, [IT](https://github.com/fluencelabs/interface-types), [Wasmer\*](https://github.com/fluencelabs/wasmer) | +| Composition | [Aqua](https://github.com/fluencelabs/aqua) | Involved peers | Results and signatures | ⇅, π-calculus | +| Topology | [TrustGraph](https://github.com/fluencelabs/fluence/tree/master/trust-graph), [DHT\*](https://github.com/fluencelabs/rust-libp2p) | Distributed with Kademlia\* algo | Actual state of the network | [libp2p](https://github.com/libp2p/rust-libp2p) | +| Security & Accounting | Blockchain | Whole network | Licenses & payments | substrate? | + +
+ +

+aquamarine scheme +

+ +## License + +[Apache 2.0](https://github.com/fluencelabs/fluence/blob/trustless_computing/LICENSE.md) diff --git a/packages/core/fluence-network-environment/doc/image.png b/packages/core/fluence-network-environment/doc/image.png new file mode 100644 index 00000000..ecaa8431 Binary files /dev/null and b/packages/core/fluence-network-environment/doc/image.png differ diff --git a/packages/core/fluence-network-environment/package.json b/packages/core/fluence-network-environment/package.json new file mode 100644 index 00000000..7bb67e2b --- /dev/null +++ b/packages/core/fluence-network-environment/package.json @@ -0,0 +1,17 @@ +{ + "type": "module", + "name": "@fluencelabs/fluence-network-environment", + "version": "1.1.2", + "description": "Fluence network environments addresses", + "files": [ + "dist" + ], + "main": "./dist/index.js", + "typings": "./dist/index.d.ts", + "scripts": { + "build": "tsc" + }, + "repository": "https://github.com/fluencelabs/fluence-network-environment", + "author": "Fluence Labs", + "license": "Apache-2.0" +} diff --git a/packages/core/js-client/src/network.ts b/packages/core/fluence-network-environment/src/index.ts similarity index 95% rename from packages/core/js-client/src/network.ts rename to packages/core/fluence-network-environment/src/index.ts index fe232fb4..f184c7cb 100644 --- a/packages/core/js-client/src/network.ts +++ b/packages/core/fluence-network-environment/src/index.ts @@ -165,23 +165,24 @@ export const kras: Relay[] = [ }, ]; -export const randomKras = (): Relay => { +// for backward compatibility +export const krasnodar = kras; + +export const randomKras = () => { return randomItem(kras); }; -export const randomTestNet = (): Relay => { +export const randomTestNet = () => { return randomItem(testNet); }; -export const randomStage = (): Relay => { +export const randomStage = () => { return randomItem(stage); }; -function randomItem(arr: Relay[]): Relay { +function randomItem(arr: Relay[]) { const index = randomInt(0, arr.length); - // This array access always defined - // eslint-disable-next-line @typescript-eslint/consistent-type-assertions - return arr[index] as Relay; + return arr[index]; } function randomInt(min: number, max: number) { diff --git a/packages/core/fluence-network-environment/tsconfig.json b/packages/core/fluence-network-environment/tsconfig.json new file mode 100644 index 00000000..a04ef1f8 --- /dev/null +++ b/packages/core/fluence-network-environment/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../../tsconfig.json", + "compilerOptions": { + "outDir": "./dist" + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "dist"] +} diff --git a/packages/core/interfaces/src/index.ts b/packages/core/interfaces/src/index.ts index 54d8726d..f6ec28e1 100644 --- a/packages/core/interfaces/src/index.ts +++ b/packages/core/interfaces/src/index.ts @@ -15,5 +15,4 @@ */ export * from "./compilerSupport/aquaTypeDefinitions.js"; -export * from "./commonTypes.js"; export * from "./future.js"; diff --git a/packages/core/js-client/package.json b/packages/core/js-client/package.json index ca344c49..926cf650 100644 --- a/packages/core/js-client/package.json +++ b/packages/core/js-client/package.json @@ -35,6 +35,7 @@ "@fluencelabs/avm": "0.62.0", "@fluencelabs/interfaces": "workspace:*", "@fluencelabs/js-client-isomorphic": "workspace:*", + "@fluencelabs/fluence-network-environment": "workspace:*", "@fluencelabs/marine-worker": "0.6.0", "@fluencelabs/threads": "^2.0.0", "@libp2p/crypto": "4.0.1", diff --git a/packages/core/js-client/src/api.ts b/packages/core/js-client/src/api.ts index 2dbd95e5..cae0931b 100644 --- a/packages/core/js-client/src/api.ts +++ b/packages/core/js-client/src/api.ts @@ -17,7 +17,6 @@ import type { ArrowWithoutCallbacks, FunctionCallDef, - JSONValue, ServiceDef, SimpleTypes, } from "@fluencelabs/interfaces"; @@ -32,6 +31,7 @@ import { } from "./compilerSupport/conversions.js"; import { ServiceImpl, UserServiceImpl } from "./compilerSupport/types.js"; import { FluencePeer } from "./jsPeer/FluencePeer.js"; +import type { JSONValue } from "./util/types.js"; import { zip } from "./util/utils.js"; import { callAquaFunction, Fluence, registerService } from "./index.js"; diff --git a/packages/core/js-client/src/clientPeer/__test__/client.spec.ts b/packages/core/js-client/src/clientPeer/__test__/client.spec.ts index 98af037f..e321faa5 100644 --- a/packages/core/js-client/src/clientPeer/__test__/client.spec.ts +++ b/packages/core/js-client/src/clientPeer/__test__/client.spec.ts @@ -14,13 +14,13 @@ * limitations under the License. */ -import { JSONValue } from "@fluencelabs/interfaces"; import { it, describe, expect, assert } from "vitest"; import { ExpirationError } from "../../jsPeer/errors.js"; import { CallServiceData } from "../../jsServiceHost/interfaces.js"; import { handleTimeout } from "../../particle/Particle.js"; import { registerHandlersHelper, withClient } from "../../util/testUtils.js"; +import type { JSONValue } from "../../util/types.js"; import { checkConnection } from "../checkConnection.js"; import { nodes, RELAY } from "./connection.js"; diff --git a/packages/core/js-client/src/clientPeer/checkConnection.ts b/packages/core/js-client/src/clientPeer/checkConnection.ts index e7d8a3df..39735c7c 100644 --- a/packages/core/js-client/src/clientPeer/checkConnection.ts +++ b/packages/core/js-client/src/clientPeer/checkConnection.ts @@ -14,11 +14,10 @@ * limitations under the License. */ -import { JSONValue } from "@fluencelabs/interfaces"; - import { WrapFnIntoServiceCall } from "../jsServiceHost/serviceUtils.js"; import { handleTimeout } from "../particle/Particle.js"; import { logger } from "../util/logger.js"; +import type { JSONValue } from "../util/types.js"; import { ClientPeer } from "./ClientPeer.js"; diff --git a/packages/core/js-client/src/clientPeer/types.ts b/packages/core/js-client/src/clientPeer/types.ts index 3a9cff7a..6314f55f 100644 --- a/packages/core/js-client/src/clientPeer/types.ts +++ b/packages/core/js-client/src/clientPeer/types.ts @@ -16,11 +16,6 @@ import { z } from "zod"; -/** - * Peer ID's id as a base58 string (multihash/CIDv0). - */ -export type PeerIdB58 = string; - const relaySchema = z.object({ peerId: z.string(), multiaddr: z.string(), diff --git a/packages/core/js-client/src/compilerSupport/__test__/conversion.spec.ts b/packages/core/js-client/src/compilerSupport/__test__/conversion.spec.ts index 946432b7..d08a44ee 100644 --- a/packages/core/js-client/src/compilerSupport/__test__/conversion.spec.ts +++ b/packages/core/js-client/src/compilerSupport/__test__/conversion.spec.ts @@ -14,9 +14,10 @@ * limitations under the License. */ -import { JSONValue, NonArrowSimpleType } from "@fluencelabs/interfaces"; +import { NonArrowSimpleType } from "@fluencelabs/interfaces"; import { it, describe, expect, test } from "vitest"; +import type { JSONValue } from "../../util/types.js"; import { aqua2js, js2aqua } from "../conversions.js"; const i32 = { tag: "scalar", name: "i32" } as const; diff --git a/packages/core/js-client/src/compilerSupport/callFunction.ts b/packages/core/js-client/src/compilerSupport/callFunction.ts index 1e2971e9..530a33f2 100644 --- a/packages/core/js-client/src/compilerSupport/callFunction.ts +++ b/packages/core/js-client/src/compilerSupport/callFunction.ts @@ -14,11 +14,10 @@ * limitations under the License. */ -import { JSONValue } from "@fluencelabs/interfaces"; - import { FluencePeer } from "../jsPeer/FluencePeer.js"; import { logger } from "../util/logger.js"; import { ArgCallbackFunction } from "../util/testUtils.js"; +import type { JSONValue } from "../util/types.js"; import { errorHandlingService, diff --git a/packages/core/js-client/src/compilerSupport/conversions.ts b/packages/core/js-client/src/compilerSupport/conversions.ts index 68ce8865..0d59b9b7 100644 --- a/packages/core/js-client/src/compilerSupport/conversions.ts +++ b/packages/core/js-client/src/compilerSupport/conversions.ts @@ -17,7 +17,6 @@ import { ArrowType, ArrowWithoutCallbacks, - JSONValue, LabeledProductType, NonArrowSimpleType, ScalarType, @@ -25,6 +24,7 @@ import { UnlabeledProductType, } from "@fluencelabs/interfaces"; +import { JSONValue } from "../util/types.js"; import { zip } from "../util/utils.js"; import { ServiceImpl, UserServiceImpl } from "./types.js"; diff --git a/packages/core/js-client/src/compilerSupport/services.ts b/packages/core/js-client/src/compilerSupport/services.ts index 1a619e83..c74bc87a 100644 --- a/packages/core/js-client/src/compilerSupport/services.ts +++ b/packages/core/js-client/src/compilerSupport/services.ts @@ -14,8 +14,6 @@ * limitations under the License. */ -import { JSONValue } from "@fluencelabs/interfaces"; - import { FluencePeer } from "../jsPeer/FluencePeer.js"; import { CallServiceData, @@ -23,6 +21,7 @@ import { ResultCodes, } from "../jsServiceHost/interfaces.js"; import { Particle } from "../particle/Particle.js"; +import type { JSONValue } from "../util/types.js"; import { ServiceImpl } from "./types.js"; diff --git a/packages/core/js-client/src/compilerSupport/types.ts b/packages/core/js-client/src/compilerSupport/types.ts index 6ad2a283..4b46a8ed 100644 --- a/packages/core/js-client/src/compilerSupport/types.ts +++ b/packages/core/js-client/src/compilerSupport/types.ts @@ -14,9 +14,8 @@ * limitations under the License. */ -import { JSONArray, JSONValue } from "@fluencelabs/interfaces"; - import { ParticleContext } from "../jsServiceHost/interfaces.js"; +import type { JSONArray, JSONValue } from "../util/types.js"; export type MaybePromise = T | Promise; diff --git a/packages/core/js-client/src/connection/RelayConnection.ts b/packages/core/js-client/src/connection/RelayConnection.ts index 75a6d33f..659f6d8e 100644 --- a/packages/core/js-client/src/connection/RelayConnection.ts +++ b/packages/core/js-client/src/connection/RelayConnection.ts @@ -16,7 +16,6 @@ import { noise } from "@chainsafe/libp2p-noise"; import { yamux } from "@chainsafe/libp2p-yamux"; -import { PeerIdB58 } from "@fluencelabs/interfaces"; import { identify } from "@libp2p/identify"; import type { PeerId } from "@libp2p/interface"; import { peerIdFromString } from "@libp2p/peer-id"; @@ -39,6 +38,7 @@ import { } from "../particle/Particle.js"; import { throwHasNoPeerId } from "../util/libp2pUtils.js"; import { logger } from "../util/logger.js"; +import type { PeerIdB58 } from "../util/types.js"; import { IConnection } from "./interfaces.js"; diff --git a/packages/core/js-client/src/connection/interfaces.ts b/packages/core/js-client/src/connection/interfaces.ts index bb0345c4..0ea3bdb3 100644 --- a/packages/core/js-client/src/connection/interfaces.ts +++ b/packages/core/js-client/src/connection/interfaces.ts @@ -14,11 +14,11 @@ * limitations under the License. */ -import type { PeerIdB58 } from "@fluencelabs/interfaces"; import type { Subscribable } from "rxjs"; import { IParticle } from "../particle/interfaces.js"; import { IStartable } from "../util/commonTypes.js"; +import { PeerIdB58 } from "../util/types.js"; /** * Interface for connection used in Fluence Peer. diff --git a/packages/core/js-client/src/ephemeral/client.ts b/packages/core/js-client/src/ephemeral/client.ts index fe41d193..19ddc418 100644 --- a/packages/core/js-client/src/ephemeral/client.ts +++ b/packages/core/js-client/src/ephemeral/client.ts @@ -14,12 +14,11 @@ * limitations under the License. */ -import { PeerIdB58 } from "@fluencelabs/interfaces"; - import { FluencePeer, PeerConfig } from "../jsPeer/FluencePeer.js"; import { JsServiceHost } from "../jsServiceHost/JsServiceHost.js"; import { KeyPair } from "../keypair/index.js"; import { IMarineHost } from "../marine/interfaces.js"; +import { PeerIdB58 } from "../util/types.js"; import { EphemeralNetwork } from "./network.js"; diff --git a/packages/core/js-client/src/ephemeral/network.ts b/packages/core/js-client/src/ephemeral/network.ts index 3a90aecc..5b437e98 100644 --- a/packages/core/js-client/src/ephemeral/network.ts +++ b/packages/core/js-client/src/ephemeral/network.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import { PeerIdB58 } from "@fluencelabs/interfaces"; import { Subject } from "rxjs"; import { IConnection } from "../connection/interfaces.js"; @@ -26,6 +25,7 @@ import { loadMarineDeps } from "../marine/loader.js"; import { MarineBackgroundRunner } from "../marine/worker/index.js"; import { Particle } from "../particle/Particle.js"; import { logger } from "../util/logger.js"; +import { PeerIdB58 } from "../util/types.js"; const log = logger("ephemeral"); diff --git a/packages/core/js-client/src/index.ts b/packages/core/js-client/src/index.ts index 44d12bd3..9878ff01 100644 --- a/packages/core/js-client/src/index.ts +++ b/packages/core/js-client/src/index.ts @@ -146,7 +146,7 @@ export { fromOpts, } from "./keypair/index.js"; -export * from "./network.js"; +export * from "@fluencelabs/fluence-network-environment"; // TODO: Remove this export after DXJ-535 is done! export { js2aqua, aqua2js } from "./compilerSupport/conversions.js"; diff --git a/packages/core/js-client/src/jsPeer/FluencePeer.ts b/packages/core/js-client/src/jsPeer/FluencePeer.ts index 0444b5d8..5d9c7dd8 100644 --- a/packages/core/js-client/src/jsPeer/FluencePeer.ts +++ b/packages/core/js-client/src/jsPeer/FluencePeer.ts @@ -20,7 +20,6 @@ import { KeyPairFormat, serializeAvmArgs, } from "@fluencelabs/avm"; -import { JSONValue } from "@fluencelabs/interfaces"; import { fromUint8Array } from "js-base64"; import { concatMap, @@ -64,6 +63,7 @@ import { defaultSigGuard, Sig } from "../services/Sig.js"; import { Srv } from "../services/SingleModuleSrv.js"; import { Tracing } from "../services/Tracing.js"; import { logger } from "../util/logger.js"; +import type { JSONValue } from "../util/types.js"; import { getErrorMessage, isString, jsonify } from "../util/utils.js"; import { ExpirationError, InterpreterError, SendError } from "./errors.js"; diff --git a/packages/core/js-client/src/jsPeer/__test__/avm.spec.ts b/packages/core/js-client/src/jsPeer/__test__/avm.spec.ts index b7b5dde1..9162970c 100644 --- a/packages/core/js-client/src/jsPeer/__test__/avm.spec.ts +++ b/packages/core/js-client/src/jsPeer/__test__/avm.spec.ts @@ -14,11 +14,11 @@ * limitations under the License. */ -import { JSONValue } from "@fluencelabs/interfaces"; import { it, describe, expect, assert } from "vitest"; import { handleTimeout } from "../../particle/Particle.js"; import { registerHandlersHelper, withPeer } from "../../util/testUtils.js"; +import type { JSONValue } from "../../util/types.js"; describe("Basic AVM functionality in Fluence Peer tests", () => { it("Simple call", async () => { diff --git a/packages/core/js-client/src/jsPeer/__test__/par.spec.ts b/packages/core/js-client/src/jsPeer/__test__/par.spec.ts index 7a85654c..4299aa78 100644 --- a/packages/core/js-client/src/jsPeer/__test__/par.spec.ts +++ b/packages/core/js-client/src/jsPeer/__test__/par.spec.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import { JSONValue } from "@fluencelabs/interfaces"; import { describe, expect, it, assert } from "vitest"; import { @@ -23,6 +22,7 @@ import { } from "../../jsServiceHost/interfaces.js"; import { handleTimeout } from "../../particle/Particle.js"; import { registerHandlersHelper, withPeer } from "../../util/testUtils.js"; +import type { JSONValue } from "../../util/types.js"; describe("FluencePeer flow tests", () => { it("should execute par instruction in parallel", async function () { diff --git a/packages/core/js-client/src/jsServiceHost/interfaces.ts b/packages/core/js-client/src/jsServiceHost/interfaces.ts index 02f08898..74172ca7 100644 --- a/packages/core/js-client/src/jsServiceHost/interfaces.ts +++ b/packages/core/js-client/src/jsServiceHost/interfaces.ts @@ -15,8 +15,8 @@ */ import type { SecurityTetraplet } from "@fluencelabs/avm"; -import type { PeerIdB58 } from "@fluencelabs/interfaces"; -import { JSONArray, JSONValue } from "@fluencelabs/interfaces"; + +import type { JSONArray, JSONValue, PeerIdB58 } from "../util/types.js"; /** * JS Service host a low level interface for managing pure javascript services. diff --git a/packages/core/js-client/src/jsServiceHost/serviceUtils.ts b/packages/core/js-client/src/jsServiceHost/serviceUtils.ts index 2e6fcfe7..fea0a4dd 100644 --- a/packages/core/js-client/src/jsServiceHost/serviceUtils.ts +++ b/packages/core/js-client/src/jsServiceHost/serviceUtils.ts @@ -15,11 +15,11 @@ */ import { SecurityTetraplet } from "@fluencelabs/avm"; -import { JSONArray } from "@fluencelabs/interfaces"; import { FluencePeer } from "../jsPeer/FluencePeer.js"; import { IParticle } from "../particle/interfaces.js"; import { builtInServices } from "../services/builtins.js"; +import type { JSONArray } from "../util/types.js"; import { CallServiceData, diff --git a/packages/core/js-client/src/marine/interfaces.ts b/packages/core/js-client/src/marine/interfaces.ts index 996479d4..3afc44d0 100644 --- a/packages/core/js-client/src/marine/interfaces.ts +++ b/packages/core/js-client/src/marine/interfaces.ts @@ -14,10 +14,10 @@ * limitations under the License. */ -import { JSONObject, JSONValue, JSONArray } from "@fluencelabs/interfaces"; import { CallParameters } from "@fluencelabs/marine-worker"; import { IStartable } from "../util/commonTypes.js"; +import type { JSONObject, JSONValue, JSONArray } from "../util/types.js"; /** * Contract for marine host implementations. Marine host is responsible for creating calling and removing marine services diff --git a/packages/core/js-client/src/marine/worker/index.ts b/packages/core/js-client/src/marine/worker/index.ts index 66c665cc..83aaa37f 100644 --- a/packages/core/js-client/src/marine/worker/index.ts +++ b/packages/core/js-client/src/marine/worker/index.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import { JSONValue } from "@fluencelabs/interfaces"; import type { MarineBackgroundInterface, LogFunction, @@ -24,6 +23,7 @@ import type { import { ModuleThread, Thread } from "@fluencelabs/threads/master"; import { MarineLogger, marineLogger } from "../../util/logger.js"; +import type { JSONValue } from "../../util/types.js"; import { IMarineHost } from "../interfaces.js"; export class MarineBackgroundRunner implements IMarineHost { diff --git a/packages/core/js-client/src/particle/Particle.ts b/packages/core/js-client/src/particle/Particle.ts index 9d8c7025..33df49eb 100644 --- a/packages/core/js-client/src/particle/Particle.ts +++ b/packages/core/js-client/src/particle/Particle.ts @@ -19,7 +19,6 @@ import { MulticodecRepr, MsgPackRepr, } from "@fluencelabs/avm"; -import { JSONValue } from "@fluencelabs/interfaces"; import int64Buffer from "int64-buffer"; import { concat } from "uint8arrays/concat"; import { v4 as uuidv4 } from "uuid"; @@ -28,6 +27,7 @@ import { z } from "zod"; import { ExpirationError } from "../jsPeer/errors.js"; import { KeyPair } from "../keypair/index.js"; import { numberToLittleEndianBytes } from "../util/bytes.js"; +import type { JSONValue } from "../util/types.js"; import { IParticle } from "./interfaces.js"; diff --git a/packages/core/js-client/src/particle/interfaces.ts b/packages/core/js-client/src/particle/interfaces.ts index cbe5c8cb..0bba001d 100644 --- a/packages/core/js-client/src/particle/interfaces.ts +++ b/packages/core/js-client/src/particle/interfaces.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { PeerIdB58 } from "@fluencelabs/interfaces"; +import type { PeerIdB58 } from "../util/types.js"; /** * Immutable part of the particle. diff --git a/packages/core/js-client/src/services/Sig.ts b/packages/core/js-client/src/services/Sig.ts index 3aa85f5e..d2cceac5 100644 --- a/packages/core/js-client/src/services/Sig.ts +++ b/packages/core/js-client/src/services/Sig.ts @@ -14,10 +14,9 @@ * limitations under the License. */ -import { PeerIdB58 } from "@fluencelabs/interfaces"; - import { ServiceFnArgs } from "../compilerSupport/types.js"; import { KeyPair } from "../keypair/index.js"; +import type { PeerIdB58 } from "../util/types.js"; import { allowOnlyParticleOriginatedAt, diff --git a/packages/core/js-client/src/services/__test__/builtInHandler.spec.ts b/packages/core/js-client/src/services/__test__/builtInHandler.spec.ts index 5ac125c7..36b9553e 100644 --- a/packages/core/js-client/src/services/__test__/builtInHandler.spec.ts +++ b/packages/core/js-client/src/services/__test__/builtInHandler.spec.ts @@ -14,13 +14,13 @@ * limitations under the License. */ -import { JSONArray } from "@fluencelabs/interfaces"; import { toUint8Array } from "js-base64"; import { describe, expect, it, test, assert } from "vitest"; import { CallServiceData } from "../../jsServiceHost/interfaces.js"; import { KeyPair } from "../../keypair/index.js"; import { makeTestTetraplet } from "../../util/testUtils.js"; +import type { JSONArray } from "../../util/types.js"; import { builtInServices } from "../builtins.js"; import { allowServiceFn } from "../securityGuard.js"; import { defaultSigGuard, Sig } from "../Sig.js"; diff --git a/packages/core/js-client/src/services/builtins.ts b/packages/core/js-client/src/services/builtins.ts index ed331712..23d790cd 100644 --- a/packages/core/js-client/src/services/builtins.ts +++ b/packages/core/js-client/src/services/builtins.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import { JSONValue } from "@fluencelabs/interfaces"; import bs58 from "bs58"; import { sha256 } from "multiformats/hashes/sha2"; import { z } from "zod"; @@ -26,6 +25,7 @@ import { GenericCallServiceHandler, ResultCodes, } from "../jsServiceHost/interfaces.js"; +import type { JSONValue } from "../util/types.js"; import { getErrorMessage, jsonify } from "../util/utils.js"; const success = (result: CallServiceResultType): CallServiceResult => { diff --git a/packages/core/js-client/src/services/securityGuard.ts b/packages/core/js-client/src/services/securityGuard.ts index da32486e..8fe94158 100644 --- a/packages/core/js-client/src/services/securityGuard.ts +++ b/packages/core/js-client/src/services/securityGuard.ts @@ -15,9 +15,9 @@ */ import { SecurityTetraplet } from "@fluencelabs/avm"; -import { PeerIdB58 } from "@fluencelabs/interfaces"; import { ParticleContext } from "../jsServiceHost/interfaces.js"; +import type { PeerIdB58 } from "../util/types.js"; // Helpers for validating service function diff --git a/packages/core/js-client/src/util/testUtils.ts b/packages/core/js-client/src/util/testUtils.ts index 11be2584..5e33c8a2 100644 --- a/packages/core/js-client/src/util/testUtils.ts +++ b/packages/core/js-client/src/util/testUtils.ts @@ -17,12 +17,7 @@ import { promises as fs } from "fs"; import { compileFromPath } from "@fluencelabs/aqua-api"; -import { - FunctionCallDef, - JSONArray, - JSONValue, - ServiceDef, -} from "@fluencelabs/interfaces"; +import { FunctionCallDef, ServiceDef } from "@fluencelabs/interfaces"; import { Subject, Subscribable } from "rxjs"; import { ClientPeer, makeClientPeerConfig } from "../clientPeer/ClientPeer.js"; @@ -43,6 +38,8 @@ import { loadMarineDeps } from "../marine/loader.js"; import { MarineBackgroundRunner } from "../marine/worker/index.js"; import { Particle } from "../particle/Particle.js"; +import type { JSONArray, JSONValue } from "./types.js"; + export const registerHandlersHelper = ( peer: FluencePeer, particle: Particle, diff --git a/packages/core/interfaces/src/commonTypes.ts b/packages/core/js-client/src/util/types.ts similarity index 100% rename from packages/core/interfaces/src/commonTypes.ts rename to packages/core/js-client/src/util/types.ts diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 522c7dc0..7440ec19 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -194,6 +194,8 @@ importers: specifier: 3.22.4 version: 3.22.4 + packages/core/fluence-network-environment: {} + packages/core/interfaces: devDependencies: hotscript: @@ -211,6 +213,9 @@ importers: '@fluencelabs/avm': specifier: 0.62.0 version: 0.62.0 + '@fluencelabs/fluence-network-environment': + specifier: workspace:* + version: link:../fluence-network-environment '@fluencelabs/interfaces': specifier: workspace:* version: link:../interfaces