mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2025-06-27 14:51:32 +00:00
Introduce fluence-network-environment package
This commit is contained in:
3
.github/release-please/config.json
vendored
3
.github/release-please/config.json
vendored
@ -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": {}
|
||||
}
|
||||
}
|
||||
|
3
.github/release-please/manifest.json
vendored
3
.github/release-please/manifest.json
vendored
@ -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"
|
||||
}
|
||||
|
16
packages/core/fluence-network-environment/.gitignore
vendored
Normal file
16
packages/core/fluence-network-environment/.gitignore
vendored
Normal file
@ -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/
|
28
packages/core/fluence-network-environment/CHANGELOG.md
Normal file
28
packages/core/fluence-network-environment/CHANGELOG.md
Normal file
@ -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))
|
65
packages/core/fluence-network-environment/README.md
Normal file
65
packages/core/fluence-network-environment/README.md
Normal file
@ -0,0 +1,65 @@
|
||||
# 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? |
|
||||
|
||||
<br/>
|
||||
|
||||
<p width="100%">
|
||||
<img alt="aquamarine scheme" align="center" src="doc/image.png"/>
|
||||
</p>
|
||||
|
||||
## License
|
||||
|
||||
[Apache 2.0](https://github.com/fluencelabs/fluence/blob/trustless_computing/LICENSE.md)
|
BIN
packages/core/fluence-network-environment/doc/image.png
Normal file
BIN
packages/core/fluence-network-environment/doc/image.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 MiB |
37
packages/core/fluence-network-environment/package-lock.json
generated
Normal file
37
packages/core/fluence-network-environment/package-lock.json
generated
Normal file
@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "@fluencelabs/fluence-network-environment",
|
||||
"version": "1.1.2",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@fluencelabs/fluence-network-environment",
|
||||
"version": "1.1.2",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"typescript": "3.9.5"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "3.9.5",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.5.tgz",
|
||||
"integrity": "sha512-hSAifV3k+i6lEoCJ2k6R2Z/rp/H3+8sdmcn5NrS3/3kE7+RyZXm9aqvxWqjEXHAd8b0pShatpcdMTvEdvAJltQ==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.2.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"typescript": {
|
||||
"version": "3.9.5",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.5.tgz",
|
||||
"integrity": "sha512-hSAifV3k+i6lEoCJ2k6R2Z/rp/H3+8sdmcn5NrS3/3kE7+RyZXm9aqvxWqjEXHAd8b0pShatpcdMTvEdvAJltQ==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
16
packages/core/fluence-network-environment/package.json
Normal file
16
packages/core/fluence-network-environment/package.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"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"
|
||||
}
|
@ -164,26 +164,3 @@ export const kras: Relay[] = [
|
||||
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;
|
||||
}
|
8
packages/core/fluence-network-environment/tsconfig.json
Normal file
8
packages/core/fluence-network-environment/tsconfig.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "../../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
@ -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 {
|
||||
|
@ -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>;
|
5
pnpm-lock.yaml
generated
5
pnpm-lock.yaml
generated
@ -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
|
||||
|
Reference in New Issue
Block a user