mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2025-04-25 09:52:12 +00:00
module config, blueprint id (#993)
This commit is contained in:
parent
14a8463d3a
commit
957c0f90c1
8
package-lock.json
generated
8
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "fluence",
|
"name": "fluence",
|
||||||
"version": "0.7.82",
|
"version": "0.7.93",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -25,9 +25,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@fluencelabs/aquamarine-stepper": {
|
"@fluencelabs/aquamarine-stepper": {
|
||||||
"version": "0.0.13",
|
"version": "0.0.15",
|
||||||
"resolved": "https://registry.npmjs.org/@fluencelabs/aquamarine-stepper/-/aquamarine-stepper-0.0.13.tgz",
|
"resolved": "https://registry.npmjs.org/@fluencelabs/aquamarine-stepper/-/aquamarine-stepper-0.0.15.tgz",
|
||||||
"integrity": "sha512-DymSTILKXUeZsyOB9b7zKv4ZfGsbGUCMjCsafUHQIaAsMxD+p4DJsQ4FdHRI6rh9MqWmv5OVFXEpHhqai7fqug=="
|
"integrity": "sha512-dCzBlqiR0/EiYzCseIlpE8wbi/jRMLvMsFkTIm0tmhvSfWtBskXLniM9CE4JqyUATAVuBdKJ5HKsufACugGf4A=="
|
||||||
},
|
},
|
||||||
"@sinonjs/commons": {
|
"@sinonjs/commons": {
|
||||||
"version": "1.7.2",
|
"version": "1.7.2",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "fluence",
|
"name": "fluence",
|
||||||
"version": "0.7.83",
|
"version": "0.7.95",
|
||||||
"description": "the browser js-libp2p client for the Fluence network",
|
"description": "the browser js-libp2p client for the Fluence network",
|
||||||
"main": "./dist/fluence.js",
|
"main": "./dist/fluence.js",
|
||||||
"typings": "./dist/fluence.d.ts",
|
"typings": "./dist/fluence.d.ts",
|
||||||
@ -15,7 +15,7 @@
|
|||||||
"author": "Fluence Labs",
|
"author": "Fluence Labs",
|
||||||
"license": "Apache 2.0",
|
"license": "Apache 2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fluencelabs/aquamarine-stepper": "0.0.13",
|
"@fluencelabs/aquamarine-stepper": "0.0.15",
|
||||||
"async": "3.2.0",
|
"async": "3.2.0",
|
||||||
"base64-js": "1.3.1",
|
"base64-js": "1.3.1",
|
||||||
"bs58": "4.0.1",
|
"bs58": "4.0.1",
|
||||||
|
@ -64,4 +64,6 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.Fluence = Fluence;
|
if (typeof window !== "undefined") {
|
||||||
|
window.Fluence = Fluence;
|
||||||
|
}
|
||||||
|
@ -30,6 +30,7 @@ import {
|
|||||||
import {instantiateStepper, Stepper} from "./stepper";
|
import {instantiateStepper, Stepper} from "./stepper";
|
||||||
import log from "loglevel";
|
import log from "loglevel";
|
||||||
import {waitService} from "./helpers/waitService";
|
import {waitService} from "./helpers/waitService";
|
||||||
|
import {ModuleConfig} from "./moduleConfig";
|
||||||
|
|
||||||
const bs58 = require('bs58')
|
const bs58 = require('bs58')
|
||||||
|
|
||||||
@ -213,15 +214,17 @@ export class FluenceClient {
|
|||||||
/**
|
/**
|
||||||
* Send a script to add module to a relay. Waiting for a response from a relay.
|
* Send a script to add module to a relay. Waiting for a response from a relay.
|
||||||
*/
|
*/
|
||||||
async addModule(name: string, moduleBase64: string, nodeId?: string, ttl?: number): Promise<void> {
|
async addModule(name: string, moduleBase64: string, config?: ModuleConfig, nodeId?: string, ttl?: number): Promise<void> {
|
||||||
let config = {
|
if (!config) {
|
||||||
name: name,
|
config = {
|
||||||
mem_pages_count: 100,
|
name: name,
|
||||||
logger_enabled: true,
|
mem_pages_count: 100,
|
||||||
wasi: {
|
logger_enabled: true,
|
||||||
envs: {},
|
wasi: {
|
||||||
preopened_files: ["/tmp"],
|
envs: {},
|
||||||
mapped_dirs: {},
|
preopened_files: ["/tmp"],
|
||||||
|
mapped_dirs: {},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,12 +240,12 @@ export class FluenceClient {
|
|||||||
/**
|
/**
|
||||||
* Send a script to add module to a relay. Waiting for a response from a relay.
|
* Send a script to add module to a relay. Waiting for a response from a relay.
|
||||||
*/
|
*/
|
||||||
async addBlueprint(name: string, dependencies: string[], nodeId?: string, ttl?: number): Promise<string> {
|
async addBlueprint(name: string, dependencies: string[], blueprintId?: string, nodeId?: string, ttl?: number): Promise<string> {
|
||||||
let returnValue = "blueprint_id";
|
let returnValue = "blueprint_id";
|
||||||
let call = (nodeId: string) => `(call "${nodeId}" ("dist" "add_blueprint") [blueprint] ${returnValue})`
|
let call = (nodeId: string) => `(call "${nodeId}" ("dist" "add_blueprint") [blueprint] ${returnValue})`
|
||||||
|
|
||||||
let data = new Map()
|
let data = new Map()
|
||||||
data.set("blueprint", { name: name, dependencies: dependencies })
|
data.set("blueprint", { name: name, dependencies: dependencies, id: blueprintId })
|
||||||
|
|
||||||
return this.requestResponse("addBlueprint", call, returnValue, data, (args: any[]) => args[0] as string, nodeId, ttl)
|
return this.requestResponse("addBlueprint", call, returnValue, data, (args: any[]) => args[0] as string, nodeId, ttl)
|
||||||
}
|
}
|
||||||
|
29
src/moduleConfig.ts
Normal file
29
src/moduleConfig.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 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 interface ModuleConfig {
|
||||||
|
name: string,
|
||||||
|
mem_pages_count?: number,
|
||||||
|
logger_enabled?: boolean,
|
||||||
|
wasi?: Wasi,
|
||||||
|
mounted_binaries?: object
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Wasi {
|
||||||
|
envs?: object,
|
||||||
|
preopened_files?: string[],
|
||||||
|
mapped_dirs?: object,
|
||||||
|
}
|
@ -36,7 +36,7 @@ function wrapScript(selfPeerId: string, script: string, fields: string[]): strin
|
|||||||
fields.forEach((v) => {
|
fields.forEach((v) => {
|
||||||
script = `
|
script = `
|
||||||
(seq
|
(seq
|
||||||
(call "${selfPeerId}" ("" "load") ["${v}"] ${v})
|
(call %init_peer_id% ("" "load") ["${v}"] ${v})
|
||||||
${script}
|
${script}
|
||||||
)
|
)
|
||||||
`
|
`
|
||||||
|
@ -77,7 +77,8 @@ export async function instantiateStepper(pid: PeerId): Promise<Stepper> {
|
|||||||
log.debug(str)
|
log.debug(str)
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
log.trace(str)
|
// we don't want a trace in trace logs
|
||||||
|
log.debug(str)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user