mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2025-06-23 12:51:32 +00:00
feat(fluence-network-environment): Introduce fluence-network-environment package (#442)
* Introduce fluence-network-environment package * Refactor types * Fix type * Remove BC * Update CLI * Remove fluence local up from CI * Add configs * Add type module * Update e2e file * Remove lock file * Revert "Add configs" This reverts commitade44760d1
. * Revert "Remove fluence local up from CI" This reverts commit477a12d889
.
This commit is contained in:
@ -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",
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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(),
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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> = T | Promise<T>;
|
||||
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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");
|
||||
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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 () => {
|
||||
|
@ -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 () {
|
||||
|
@ -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.
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -1,189 +0,0 @@
|
||||
/**
|
||||
* Copyright 2023 Fluence Labs Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export type Relay = { peerId: string; multiaddr: string };
|
||||
|
||||
export const stage: Relay[] = [
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/0-stage.fluence.dev/tcp/9000/wss/p2p/12D3KooWDcpWuyrMTDinqNgmXAuRdfd2mTdY9VoXZSAet2pDzh6r",
|
||||
peerId: "12D3KooWDcpWuyrMTDinqNgmXAuRdfd2mTdY9VoXZSAet2pDzh6r",
|
||||
},
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/1-stage.fluence.dev/tcp/9000/wss/p2p/12D3KooWHCJbJKGDfCgHSoCuK9q4STyRnVveqLoXAPBbXHTZx9Cv",
|
||||
peerId: "12D3KooWHCJbJKGDfCgHSoCuK9q4STyRnVveqLoXAPBbXHTZx9Cv",
|
||||
},
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/2-stage.fluence.dev/tcp/9000/wss/p2p/12D3KooWMigkP4jkVyufq5JnDJL6nXvyjeaDNpRfEZqQhsG3sYCU",
|
||||
peerId: "12D3KooWMigkP4jkVyufq5JnDJL6nXvyjeaDNpRfEZqQhsG3sYCU",
|
||||
},
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/3-stage.fluence.dev/tcp/9000/wss/p2p/12D3KooWMMGdfVEJ1rWe1nH1nehYDzNEHhg5ogdfiGk88AupCMnf",
|
||||
peerId: "12D3KooWMMGdfVEJ1rWe1nH1nehYDzNEHhg5ogdfiGk88AupCMnf",
|
||||
},
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/4-stage.fluence.dev/tcp/9000/wss/p2p/12D3KooWJ4bTHirdTFNZpCS72TAzwtdmavTBkkEXtzo6wHL25CtE",
|
||||
peerId: "12D3KooWJ4bTHirdTFNZpCS72TAzwtdmavTBkkEXtzo6wHL25CtE",
|
||||
},
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/5-stage.fluence.dev/tcp/9000/wss/p2p/12D3KooWAKNos2KogexTXhrkMZzFYpLHuWJ4PgoAhurSAv7o5CWA",
|
||||
peerId: "12D3KooWAKNos2KogexTXhrkMZzFYpLHuWJ4PgoAhurSAv7o5CWA",
|
||||
},
|
||||
];
|
||||
|
||||
export const testNet: Relay[] = [
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/0-dar.fluence.dev/tcp/9000/wss/p2p/12D3KooWMhVpgfQxBLkQkJed8VFNvgN4iE6MD7xCybb1ZYWW2Gtz",
|
||||
peerId: "12D3KooWMhVpgfQxBLkQkJed8VFNvgN4iE6MD7xCybb1ZYWW2Gtz",
|
||||
},
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/1-dar.fluence.dev/tcp/9000/wss/p2p/12D3KooWEXNUbCXooUwHrHBbrmjsrpHXoEphPwbjQXEGyzbqKnE9",
|
||||
peerId: "12D3KooWEXNUbCXooUwHrHBbrmjsrpHXoEphPwbjQXEGyzbqKnE9",
|
||||
},
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/2-dar.fluence.dev/tcp/9000/wss/p2p/12D3KooWHk9BjDQBUqnavciRPhAYFvqKBe4ZiPPvde7vDaqgn5er",
|
||||
peerId: "12D3KooWHk9BjDQBUqnavciRPhAYFvqKBe4ZiPPvde7vDaqgn5er",
|
||||
},
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/3-dar.fluence.dev/tcp/9000/wss/p2p/12D3KooWBUJifCTgaxAUrcM9JysqCcS4CS8tiYH5hExbdWCAoNwb",
|
||||
peerId: "12D3KooWBUJifCTgaxAUrcM9JysqCcS4CS8tiYH5hExbdWCAoNwb",
|
||||
},
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/4-dar.fluence.dev/tcp/9000/wss/p2p/12D3KooWJbJFaZ3k5sNd8DjQgg3aERoKtBAnirEvPV8yp76kEXHB",
|
||||
peerId: "12D3KooWJbJFaZ3k5sNd8DjQgg3aERoKtBAnirEvPV8yp76kEXHB",
|
||||
},
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/5-dar.fluence.dev/tcp/9000/wss/p2p/12D3KooWCKCeqLPSgMnDjyFsJuWqREDtKNHx1JEBiwaMXhCLNTRb",
|
||||
peerId: "12D3KooWCKCeqLPSgMnDjyFsJuWqREDtKNHx1JEBiwaMXhCLNTRb",
|
||||
},
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/6-dar.fluence.dev/tcp/9000/wss/p2p/12D3KooWKnRcsTpYx9axkJ6d69LPfpPXrkVLe96skuPTAo76LLVH",
|
||||
peerId: "12D3KooWKnRcsTpYx9axkJ6d69LPfpPXrkVLe96skuPTAo76LLVH",
|
||||
},
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/7-dar.fluence.dev/tcp/9000/wss/p2p/12D3KooWBSdm6TkqnEFrgBuSkpVE3dR1kr6952DsWQRNwJZjFZBv",
|
||||
peerId: "12D3KooWBSdm6TkqnEFrgBuSkpVE3dR1kr6952DsWQRNwJZjFZBv",
|
||||
},
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/8-dar.fluence.dev/tcp/9000/wss/p2p/12D3KooWGzNvhSDsgFoHwpWHAyPf1kcTYCGeRBPfznL8J6qdyu2H",
|
||||
peerId: "12D3KooWGzNvhSDsgFoHwpWHAyPf1kcTYCGeRBPfznL8J6qdyu2H",
|
||||
},
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/9-dar.fluence.dev/tcp/9000/wss/p2p/12D3KooWF7gjXhQ4LaKj6j7ntxsPpGk34psdQicN2KNfBi9bFKXg",
|
||||
peerId: "12D3KooWF7gjXhQ4LaKj6j7ntxsPpGk34psdQicN2KNfBi9bFKXg",
|
||||
},
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/10-dar.fluence.dev/tcp/9000/wss/p2p/12D3KooWB9P1xmV3c7ZPpBemovbwCiRRTKd3Kq2jsVPQN4ZukDfy",
|
||||
peerId: "12D3KooWB9P1xmV3c7ZPpBemovbwCiRRTKd3Kq2jsVPQN4ZukDfy",
|
||||
},
|
||||
];
|
||||
|
||||
export const kras: Relay[] = [
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/0-kras.fluence.dev/tcp/9000/wss/p2p/12D3KooWSD5PToNiLQwKDXsu8JSysCwUt8BVUJEqCHcDe7P5h45e",
|
||||
peerId: "12D3KooWSD5PToNiLQwKDXsu8JSysCwUt8BVUJEqCHcDe7P5h45e",
|
||||
},
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/1-kras.fluence.dev/tcp/9000/wss/p2p/12D3KooWR4cv1a8tv7pps4HH6wePNaK6gf1Hww5wcCMzeWxyNw51",
|
||||
peerId: "12D3KooWR4cv1a8tv7pps4HH6wePNaK6gf1Hww5wcCMzeWxyNw51",
|
||||
},
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/2-kras.fluence.dev/tcp/9000/wss/p2p/12D3KooWKnEqMfYo9zvfHmqTLpLdiHXPe4SVqUWcWHDJdFGrSmcA",
|
||||
peerId: "12D3KooWKnEqMfYo9zvfHmqTLpLdiHXPe4SVqUWcWHDJdFGrSmcA",
|
||||
},
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/3-kras.fluence.dev/tcp/9000/wss/p2p/12D3KooWHLxVhUQyAuZe6AHMB29P7wkvTNMn7eDMcsqimJYLKREf",
|
||||
peerId: "12D3KooWHLxVhUQyAuZe6AHMB29P7wkvTNMn7eDMcsqimJYLKREf",
|
||||
},
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/4-kras.fluence.dev/tcp/9000/wss/p2p/12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE",
|
||||
peerId: "12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE",
|
||||
},
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/5-kras.fluence.dev/tcp/9000/wss/p2p/12D3KooWFEwNWcHqi9rtsmDhsYcDbRUCDXH84RC4FW6UfsFWaoHi",
|
||||
peerId: "12D3KooWFEwNWcHqi9rtsmDhsYcDbRUCDXH84RC4FW6UfsFWaoHi",
|
||||
},
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/6-kras.fluence.dev/tcp/9000/wss/p2p/12D3KooWCMr9mU894i8JXAFqpgoFtx6qnV1LFPSfVc3Y34N4h4LS",
|
||||
peerId: "12D3KooWCMr9mU894i8JXAFqpgoFtx6qnV1LFPSfVc3Y34N4h4LS",
|
||||
},
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/7-kras.fluence.dev/tcp/9000/wss/p2p/12D3KooWDUszU2NeWyUVjCXhGEt1MoZrhvdmaQQwtZUriuGN1jTr",
|
||||
peerId: "12D3KooWDUszU2NeWyUVjCXhGEt1MoZrhvdmaQQwtZUriuGN1jTr",
|
||||
},
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/8-kras.fluence.dev/tcp/9000/wss/p2p/12D3KooWEFFCZnar1cUJQ3rMWjvPQg6yMV2aXWs2DkJNSRbduBWn",
|
||||
peerId: "12D3KooWEFFCZnar1cUJQ3rMWjvPQg6yMV2aXWs2DkJNSRbduBWn",
|
||||
},
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/9-kras.fluence.dev/tcp/9000/wss/p2p/12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt",
|
||||
peerId: "12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt",
|
||||
},
|
||||
{
|
||||
multiaddr:
|
||||
"/dns4/10-kras.fluence.dev/tcp/9000/wss/p2p/12D3KooWD7CvsYcpF9HE9CCV9aY3SJ317tkXVykjtZnht2EbzDPm",
|
||||
peerId: "12D3KooWD7CvsYcpF9HE9CCV9aY3SJ317tkXVykjtZnht2EbzDPm",
|
||||
},
|
||||
];
|
||||
|
||||
export const randomKras = (): Relay => {
|
||||
return randomItem(kras);
|
||||
};
|
||||
|
||||
export const randomTestNet = (): Relay => {
|
||||
return randomItem(testNet);
|
||||
};
|
||||
|
||||
export const randomStage = (): Relay => {
|
||||
return randomItem(stage);
|
||||
};
|
||||
|
||||
function randomItem(arr: Relay[]): 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;
|
||||
}
|
||||
|
||||
function randomInt(min: number, max: number) {
|
||||
return Math.floor(Math.random() * (max - min)) + min;
|
||||
}
|
@ -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";
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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,
|
||||
|
@ -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";
|
||||
|
@ -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 => {
|
||||
|
@ -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
|
||||
|
||||
|
@ -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,
|
||||
|
30
packages/core/js-client/src/util/types.ts
Normal file
30
packages/core/js-client/src/util/types.ts
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Copyright 2023 Fluence Labs Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Peer ID's id as a base58 string (multihash/CIDv0).
|
||||
*/
|
||||
export type PeerIdB58 = string;
|
||||
|
||||
export type JSONValue =
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| null
|
||||
| { [x: string]: JSONValue }
|
||||
| Array<JSONValue>;
|
||||
export type JSONObject = { [x: string]: JSONValue };
|
||||
export type JSONArray = Array<JSONValue>;
|
Reference in New Issue
Block a user