module config, blueprint id (#993)

This commit is contained in:
Dima
2020-12-04 17:08:35 +03:00
committed by GitHub
parent 14a8463d3a
commit 957c0f90c1
7 changed files with 55 additions and 20 deletions

View File

@ -30,6 +30,7 @@ import {
import {instantiateStepper, Stepper} from "./stepper";
import log from "loglevel";
import {waitService} from "./helpers/waitService";
import {ModuleConfig} from "./moduleConfig";
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.
*/
async addModule(name: string, moduleBase64: string, nodeId?: string, ttl?: number): Promise<void> {
let config = {
name: name,
mem_pages_count: 100,
logger_enabled: true,
wasi: {
envs: {},
preopened_files: ["/tmp"],
mapped_dirs: {},
async addModule(name: string, moduleBase64: string, config?: ModuleConfig, nodeId?: string, ttl?: number): Promise<void> {
if (!config) {
config = {
name: name,
mem_pages_count: 100,
logger_enabled: true,
wasi: {
envs: {},
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.
*/
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 call = (nodeId: string) => `(call "${nodeId}" ("dist" "add_blueprint") [blueprint] ${returnValue})`
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)
}