Skip to content

Commit

Permalink
Add dpkiNetworkSeed option
Browse files Browse the repository at this point in the history
  • Loading branch information
maackle committed Sep 13, 2024
1 parent a56a691 commit 7fde415
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 37 deletions.
35 changes: 22 additions & 13 deletions ts/src/local/conductor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ export interface ConductorOptions {
*/
noDpki?: boolean;

/**
* Set the network seed for the DPKI network.
*/
dpkiNetworkSeed?: string;

/**
* Timeout for requests to Admin and App API.
*/
Expand All @@ -77,7 +82,7 @@ export interface ConductorOptions {
*/
export type CreateConductorOptions = Pick<
ConductorOptions,
"bootstrapServerUrl" | "networkType" | "noDpki" | "timeout"
"bootstrapServerUrl" | "networkType" | "noDpki" | "dpkiNetworkSeed" | "timeout"
>;

/**
Expand All @@ -96,6 +101,7 @@ export const createConductor = async (
"bootstrapServerUrl",
"networkType",
"noDpki",
"dpkiNetworkSeed",
"timeout",
]);
const conductor = await Conductor.create(
Expand Down Expand Up @@ -160,6 +166,9 @@ export class Conductor implements IConductor {
if (options?.noDpki) {
args.push("--no-dpki");
}
if (options?.dpkiNetworkSeed) {
args.push("--dpki-network-seed", options.dpkiNetworkSeed);
}
args.push(networkType);
if (networkType === NetworkType.WebRtc) {
args.push(signalingServerUrl.href);
Expand Down Expand Up @@ -383,19 +392,19 @@ export class Conductor implements IConductor {
const installAppRequest: InstallAppRequest =
"bundle" in appBundleSource
? {
bundle: appBundleSource.bundle,
agent_key,
membrane_proofs,
installed_app_id,
network_seed,
}
bundle: appBundleSource.bundle,
agent_key,
membrane_proofs,
installed_app_id,
network_seed,
}
: {
path: appBundleSource.path,
agent_key,
membrane_proofs,
installed_app_id,
network_seed,
};
path: appBundleSource.path,
agent_key,
membrane_proofs,
installed_app_id,
network_seed,
};
logger.debug(
`installing app with id ${installed_app_id} for agent ${encodeHashToBase64(
agent_key
Expand Down
53 changes: 29 additions & 24 deletions ts/src/trycp/conductor/conductor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ export interface TryCpConductorOptions {
*/
noDpki?: boolean;

/**
* Set the network seed for the DPKI network (optional).
*/
dpkiNetworkSeed?: string;

/**
* Start up conductor after creation.
*
Expand Down Expand Up @@ -1021,19 +1026,19 @@ export class TryCpConductor implements IConductor {
const installAppRequest: InstallAppRequest =
"bundle" in appBundleSource
? {
bundle: appBundleSource.bundle,
agent_key,
membrane_proofs,
installed_app_id,
network_seed,
}
bundle: appBundleSource.bundle,
agent_key,
membrane_proofs,
installed_app_id,
network_seed,
}
: {
path: appBundleSource.path,
agent_key,
membrane_proofs,
installed_app_id,
network_seed,
};
path: appBundleSource.path,
agent_key,
membrane_proofs,
installed_app_id,
network_seed,
};
return this.adminWs().installApp(installAppRequest);
}

Expand All @@ -1055,19 +1060,19 @@ export class TryCpConductor implements IConductor {
const installAppRequest: InstallAppRequest =
"bundle" in appForAgent.app
? {
bundle: appForAgent.app.bundle,
agent_key,
membrane_proofs,
installed_app_id,
network_seed,
}
bundle: appForAgent.app.bundle,
agent_key,
membrane_proofs,
installed_app_id,
network_seed,
}
: {
path: appForAgent.app.path,
agent_key,
membrane_proofs,
installed_app_id,
network_seed,
};
path: appForAgent.app.path,
agent_key,
membrane_proofs,
installed_app_id,
network_seed,
};

logger.debug(
`installing app with id ${installed_app_id} for agent ${encodeHashToBase64(
Expand Down

0 comments on commit 7fde415

Please sign in to comment.