Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dump full state, importing lots of types from https://github.com/holochain-open-dev/core-types #94

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
holonixPath ? builtins.fetchTarball { url = "https://github.com/holochain/holonix/archive/726694e2889a57a28b553541d2fabd8f1fbb52b2.tar.gz"; }
}:

let
holonix = import (holonixPath) { };
holonixRev = "089a6f2f1627f0bd7e15c848b9f6886eb5d32c05";

holonixPath = builtins.fetchTarball "https://github.com/holochain/holonix/archive/${holonixRev}.tar.gz";
holonix = import (holonixPath) {};
nixpkgs = holonix.pkgs;
in nixpkgs.mkShell {
inputsFrom = [ holonix.main ];
buildInputs = with nixpkgs; [
binaryen
packages = with nixpkgs; [
# Additional packages go here
nodejs-16_x
];
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 12 additions & 9 deletions src/api/admin.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Requester } from "./common"
import { Requester } from "./common";
import {
HoloHash,
AgentPubKey,
MembraneProof,
DnaProperties,
InstalledAppId,
CellId,
InstalledAppInfo,
RoleId
} from "./types"
RoleId,
} from "../types/common";
import { InstalledAppInfo, MembraneProof } from "./types";
import { FullStateDump } from "./state-dump";

export type AttachAppInterfaceRequest = { port: number };
export type AttachAppInterfaceResponse = { port: number };
Expand Down Expand Up @@ -38,6 +38,12 @@ export type StartAppResponse = boolean;
export type DumpStateRequest = { cell_id: CellId };
export type DumpStateResponse = any;

export type DumpFullStateRequest = {
cell_id: CellId;
dht_ops_cursor: number | undefined;
};
export type DumpFullStateResponse = FullStateDump;

export type GenerateAgentPubKeyRequest = void;
export type GenerateAgentPubKeyResponse = AgentPubKey;

Expand Down Expand Up @@ -215,6 +221,7 @@ export interface AdminApi {
disableApp: Requester<DisableAppRequest, DisableAppResponse>;
startApp: Requester<StartAppRequest, StartAppResponse>;
dumpState: Requester<DumpStateRequest, DumpStateResponse>;
dumpFullState: Requester<DumpFullStateRequest, DumpFullStateResponse>;
generateAgentPubKey: Requester<
GenerateAgentPubKeyRequest,
GenerateAgentPubKeyResponse
Expand Down Expand Up @@ -303,10 +310,6 @@ export type DnaSource =
bundle: DnaBundle;
};

export interface HoloHashed<T> {
hash: HoloHash;
content: T;
}

export type Zomes = Array<[string, { wasm_hash: Array<HoloHash> }]>;
export type WasmCode = [HoloHash, { code: Array<number> }];
52 changes: 29 additions & 23 deletions src/api/app.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
import { Requester } from "./common"
import { CellId, CapSecret, AgentPubKey, InstalledAppId, InstalledAppInfo } from "./types"
import { Requester } from "./common";
import {
CellId,
AgentPubKey,
InstalledAppId,
} from "../types/common";
import { InstalledAppInfo } from "./types";
import { CapSecret } from "../types/capabilities";

export type CallZomeRequestGeneric<Payload> = {
cap: CapSecret | null,
cell_id: CellId,
zome_name: string,
fn_name: string,
payload: Payload,
provenance: AgentPubKey,
}
export type CallZomeResponseGeneric<Payload> = Payload
export type CallZomeRequest = CallZomeRequestGeneric<any>
export type CallZomeResponse = CallZomeResponseGeneric<any>
cap: CapSecret | null;
cell_id: CellId;
zome_name: string;
fn_name: string;
payload: Payload;
provenance: AgentPubKey;
};
export type CallZomeResponseGeneric<Payload> = Payload;
export type CallZomeRequest = CallZomeRequestGeneric<any>;
export type CallZomeResponse = CallZomeResponseGeneric<any>;

export type AppInfoRequest = { installed_app_id: InstalledAppId }
export type AppInfoResponse = InstalledAppInfo
export type AppInfoRequest = { installed_app_id: InstalledAppId };
export type AppInfoResponse = InstalledAppInfo;

export type AppSignal = {
type: string,
type: string;
data: {
cellId: CellId,
payload: any
}
}
cellId: CellId;
payload: any;
};
};

export type AppSignalCb = (signal: AppSignal) => void
export type AppSignalCb = (signal: AppSignal) => void;

export type SignalResponseGeneric<Payload> = Payload
export type SignalResponseGeneric<Payload> = Payload;

export interface AppApi {
appInfo: Requester<AppInfoRequest, AppInfoResponse>,
callZome: Requester<CallZomeRequest, CallZomeResponse>,
appInfo: Requester<AppInfoRequest, AppInfoResponse>;
callZome: Requester<CallZomeRequest, CallZomeResponse>;
}
55 changes: 55 additions & 0 deletions src/api/state-dump.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {
AgentPubKey,
CellId,
DnaHash,
HeaderHash,
KitsuneAgent,
KitsuneSpace,
Signature,
} from "../types/common";
import { DhtOp } from "../types/dht-ops";
import { Entry } from "../types/entry";
import { Header } from "../types/header";

export interface AgentInfoDump {
kitsune_agent: KitsuneAgent;
kitsune_space: KitsuneSpace;
dump: string;
}

export interface P2pAgentsDump {
/// The info of this agents cell.
this_agent_info: AgentInfoDump | undefined;
/// The dna as a [`DnaHash`] and [`kitsune_p2p::KitsuneSpace`].
this_dna: [DnaHash, KitsuneSpace] | undefined;
/// The agent as [`AgentPubKey`] and [`kitsune_p2p::KitsuneAgent`].
this_agent: [AgentPubKey, KitsuneAgent] | undefined;
/// All other agent info.
peers: Array<AgentInfoDump>;
}

export interface FullIntegrationStateDump {
validation_limbo: Array<DhtOp>;
integration_limbo: Array<DhtOp>;
integrated: Array<DhtOp>;

dht_ops_cursor: number;
}

export interface SourceChainJsonElement {
signature: Signature;
header_address: HeaderHash;
header: Header;
entry: Entry | undefined;
}

export interface SourceChainJsonDump {
elements: Array<SourceChainJsonElement>;
published_ops_count: number;
}

export interface FullStateDump {
peer_dump: P2pAgentsDump;
source_chain_dump: SourceChainJsonDump;
integration_dump: FullIntegrationStateDump;
}
37 changes: 14 additions & 23 deletions src/api/types.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
export type HoloHash = Buffer; // length 39
export type AgentPubKey = HoloHash;
export type InstalledAppId = string;
export type CapSecret = Buffer;
export type CellId = [HoloHash, AgentPubKey];
export type DnaProperties = any;
export type RoleId = string;

export type InstalledCell = {
cell_id: CellId;
role_id: RoleId;
};
import { InstalledAppId, InstalledCell } from "../types/common";

export type DeactivationReason =
| { never_activated: null }
Expand All @@ -21,23 +10,23 @@ export type PausedAppReason = {
};
export type DisabledAppReason =
| {
never_started: null;
}
never_started: null;
}
| { user: null }
| { error: string };

export type InstalledAppInfoStatus =
| {
paused: { reason: PausedAppReason };
}
paused: { reason: PausedAppReason };
}
| {
disabled: {
reason: DisabledAppReason;
};
}
disabled: {
reason: DisabledAppReason;
};
}
| {
running: null;
};
running: null;
};

export type InstalledAppInfo = {
installed_app_id: InstalledAppId;
Expand All @@ -53,4 +42,6 @@ export const fakeAgentPubKey = () =>
.split("")
.map((x) => parseInt(x, 10))
)
)
);

export interface Header {}
2 changes: 1 addition & 1 deletion src/environments/launcher.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InstalledAppId } from "../api/types"
import { InstalledAppId } from "../types/common"
import fetch from "cross-fetch"

// This is coupled with https://github.com/holochain/launcher/blob/develop/src-tauri/src/uis/caddy.rs#L13
Expand Down
11 changes: 6 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './api/admin'
export * from './api/app'
export * from './api/types'
export * from './websocket/admin'
export * from './websocket/app'
export * from "./api/admin";
export * from "./api/state-dump";
export * from "./api/app";
export * from "./websocket/admin";
export * from "./websocket/app";
export * from "./types/index";
30 changes: 30 additions & 0 deletions src/types/capabilities.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { AgentPubKey } from "./common";

export type CapSecret = Uint8Array;

export interface CapClaim {
tag: string;
grantor: AgentPubKey;
secret: CapSecret;
}

export interface ZomeCallCapGrant {
tag: string;
access: CapAccess;
functions: Array<{ zome: string; fn_name: string }>;
}

export type CapAccess =
| "Unrestricted"
| {
Transferable: { secret: CapSecret };
}
| { Assigned: { secret: CapSecret; assignees: AgentPubKey[] } };

export type CapGrant =
| {
ChainAuthor: AgentPubKey;
}
| {
RemoteAgent: ZomeCallCapGrant;
};
23 changes: 23 additions & 0 deletions src/types/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export type HoloHash = Uint8Array; // length 39
export type AgentPubKey = HoloHash;
export type DnaHash = HoloHash;
export type EntryHash = HoloHash;
export type HeaderHash = HoloHash;
export type AnyDhtHash = HoloHash;

export type KitsuneAgent = Uint8Array;
export type KitsuneSpace = Uint8Array;

export type InstalledAppId = string;

export type Signature = Uint8Array;

export type CellId = [HoloHash, AgentPubKey];

export type DnaProperties = any;
export type RoleId = string;

export type InstalledCell = {
cell_id: CellId;
role_id: RoleId;
};
Loading