Skip to content

Commit

Permalink
Update to hdk 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ddd-mtl committed Sep 22, 2023
1 parent 82f201d commit 24bd55a
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ use crate::participation_protocols::*;
#[serde(rename_all = "camelCase")]
pub struct CreatePpInput {
pub pp: ParticipationProtocol,
pub applet_id: EntryHash,
pub applet_hash: EntryHash,
pub dna_hash: DnaHash,
}


/// Create a Pp off anything
#[hdk_extern]
pub fn create_participation_protocol(input: CreatePpInput) -> ExternResult<(ActionHash, Timestamp)> {
return create_pp(input.pp, input.applet_id, input.dna_hash, None);
return create_pp(input.pp, input.applet_hash, input.dna_hash, None);
}


Expand Down
93 changes: 54 additions & 39 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,58 @@
"we-applet"
],
"scripts": {
"postinstall": "mkdir -p artifacts",
"install:submodules": "bash scripts/install-submodules.sh $npm_package_config_hc_version",
"install:rust": "bash submodules/hc-prebuilt/install-rust.sh",
"install:hc": "bash submodules/hc-prebuilt/install-hc-cli.sh $npm_package_config_bin $npm_package_config_hc_version",
"install:hash-zome": "bash submodules/hc-prebuilt/install-hash-zome.sh $npm_package_config_bin",
"install:zits": "cargo install zits --version $npm_package_config_zits_version",
"version": "$npm_package_config_bin/hc --version & holochain --version & lair-keystore --version & tsc --version",
"build:zome": "CARGO_TARGET_DIR=target cargo build --release --target wasm32-unknown-unknown",
"build:dna": "npm run build:zome && mkdir -p artifacts && $npm_package_config_bin/hc dna pack -o artifacts/threads.dna dna/workdir",
"build:happ": "npm run build:dna && $npm_package_config_bin/hc app pack -o artifacts/threads.happ dna/workdir",
"build:webapp": "npm run build -w webcomponents && npm run dist -w webapp",
"build:devtest": "npm run clean:hc & npm run build:happ && bash scripts/ts-bindings.sh && npm run build -w webcomponents && npm run build -w webapp",
"dev:components": "npm run build:watch -w webcomponents",
"devtest": "npm run build:devtest && concurrently \"npm run build:watch -w webcomponents\" \"npm run build:watch -w webapp\" \"npm run start\"",
"devtest:we": "npm run build:devtest && npm run devtest -w we-applet",
"network": "npm run build:happ && concurrently-repeat \"npm run start:proxied\"",
"network-playground": "npm run build:happ && concurrently-repeat \"npm run start:playground\"",
"network-mem": "npm run build:happ && concurrently-repeat \"npm run start\"",
"prodtest": "npm run dist -w webapp && cross-env HC_APP_PORT=$(port) HC_ADMIN_PORT=$(port) concurrently \"npm run dev:components\" \"npm run start:happ\" \"sleep 7 && npm run start:ui -w webapp\"",
"start:proxied": "cross-env HC_APP_PORT=$(port) HC_ADMIN_PORT=$(port) BUILD_MODE='dev' concurrently \"npm run dev:components\" \"npm run start:happ:proxied\" \"sleep 7 && npm run start:ui -w webapp\"",
"start": "cross-env HC_APP_PORT=$(port) HC_ADMIN_PORT=$(port) BUILD_MODE='dev' concurrently \"npm run dev:components\" \"npm run start:happ\" \"sleep 7 && npm run start:ui -w webapp\"",
"start:playground": "cross-env HC_APP_PORT=$(port) HC_ADMIN_PORT=$(port) BUILD_MODE='dev' concurrently \"npm run playground\" \"npm run dev:components\" \"npm run start:happ\" \"sleep 7 && npm run start:ui -w webapp\"",
"start-rerun": "cross-env HC_APP_PORT=8888 concurrently -k \"npm run build:watch -w webcomponents\" \"$npm_package_config_bin/hc s run 0 -p 8888\" \"npm run start:ui -w webapp\"",
"start:happ": "RUST_LOG=warn WASM_LOG=warn echo \"pass\" | $npm_package_config_bin/hc s --piped -f=$HC_ADMIN_PORT generate artifacts/threads.happ -a threads --run=$HC_APP_PORT network mem",
"start:happ:proxied": "RUST_LOG=warn WASM_LOG=warn echo \"pass\" | $npm_package_config_bin/hc s --piped -f=$HC_ADMIN_PORT generate artifacts/threads.happ --run=$HC_APP_PORT -a threads network --bootstrap https://bootstrap.holo.host/ webrtc wss://signal.holo.host",
"launch": "echo pass | hc-launch --piped -n 1 artifacts/threads.webhapp network mem",
"launch:we": "echo pass | hc-launch --piped -n 1 artifacts/threads-we_applet.webhapp network mem",
"postinstall" : "mkdir -p artifacts",
"install:submodules" : "bash scripts/install-submodules.sh $npm_package_config_hc_version",
"install:rust" : "bash submodules/hc-prebuilt/install-rust.sh",
"install:hc" : "bash submodules/hc-prebuilt/install-hc-cli.sh $npm_package_config_bin $npm_package_config_hc_version",
"install:hash-zome" : "bash submodules/hc-prebuilt/install-hash-zome.sh $npm_package_config_bin",
"install:zits" : "cargo install zits --version $npm_package_config_zits_version",
"version" : "$npm_package_config_bin/hc --version & holochain --version & lair-keystore --version & tsc --version",
"build:zome" : "CARGO_TARGET_DIR=target cargo build --release --target wasm32-unknown-unknown",
"build:dna" : "npm run build:zome && mkdir -p artifacts && $npm_package_config_bin/hc dna pack -o artifacts/threads.dna dna/workdir",
"build:happ" : "npm run build:dna && $npm_package_config_bin/hc app pack -o artifacts/threads.happ dna/workdir",
"build:webapp" : "npm run build -w webcomponents && npm run dist -w webapp",
"build:devtest" : "npm run clean:hc & npm run build:happ && bash scripts/ts-bindings.sh && npm run build -w webcomponents && npm run build -w webapp",
"dev:components" : "npm run build:watch -w webcomponents",

"devtest" : "npm run build:devtest && concurrently \"npm run build:watch -w webcomponents\" \"npm run build:watch -w webapp\" \"npm run start:mem\"",
"devtest:we" : "npm run build:devtest && npm run devtest -w we-applet",

"prodtest" : "npm run dist -w webapp && cross-env HC_APP_PORT=$(port) HC_ADMIN_PORT=$(port) concurrently \"npm run dev:components\" \"npm run new-sandbox:mem\" \"sleep 7 && npm run start:ui -w webapp\"",

"start:mem" : "cross-env HC_APP_PORT=$(port) HC_ADMIN_PORT=$(port) BUILD_MODE='dev' concurrently \"npm run dev:components\" \"npm run new-sandbox:mem\" \"sleep 7 && npm run start:ui -w webapp\"",
"start:local" : "cross-env HC_APP_PORT=$(port) HC_ADMIN_PORT=$(port) BUILD_MODE='dev' concurrently \"npm run dev:components\" \"npm run new-sandbox:local\" \"sleep 7 && npm run start:ui -w webapp\"",

"new-sandbox:mem" : "RUST_LOG=warn WASM_LOG=warn echo \"pass\" | $npm_package_config_bin/hc s --piped -f=$HC_ADMIN_PORT generate artifacts/threads.happ --run=$HC_APP_PORT -a threads network mem",
"new-sandbox:local" : "RUST_LOG=warn WASM_LOG=warn echo \"pass\" | $npm_package_config_bin/hc s --piped -f=$HC_ADMIN_PORT generate artifacts/threads.happ --run=$HC_APP_PORT -a threads network --bootstrap http://127.0.0.1:$BOOT_PORT webrtc ws://127.0.0.1:$SIGNAL_PORT",

"serve" : "cross-env BOOT_PORT=$(cat .hc_bootenv) SIGNAL_PORT=$(cat .hc_signalenv) npm run serve:run",
"serve:run" : "hc run-local-services --bootstrap-port $BOOT_PORT --signal-port $SIGNAL_PORT",
"serve:save" : "echo SIGNAL_PORT=$SIGNAL_PORT && echo $SIGNAL_PORT > .hc_signalenv && echo $BOOT_PORT > .hc_bootenv && echo BOOT_PORT=$BOOT_PORT",
"network2" : "npm run clean:hc & npm run build:devtest && cross-env BOOT_PORT=$(port) SIGNAL_PORT=$(port) concurrently \"npm run serve:save\" \"npm run serve:run\" \"cross-env INDEX=0 npm run start:local\" \"sleep 1 && cross-env INDEX=1 npm run start:local\"",
"network3" : "npm run clean:hc & npm run build:devtest && cross-env BOOT_PORT=$(port) SIGNAL_PORT=$(port) concurrently \"npm run serve:save\" \"npm run serve:run\" \"cross-env INDEX=0 npm run start:local\" \"sleep 1 && cross-env INDEX=1 npm run start:local\" \"sleep 2 && cross-env INDEX=2 npm run start:local\"",
"network:we" : "npm run clean:hc & npm run network2 -w we-applet",
"_sandbox" : "echo INDEX $INDEX & echo PORTS $BOOT_PORT $SIGNAL_PORT $HC_APP_PORT $HC_ADMIN_PORT & RUST_LOG=warn WASM_LOG=warn echo \"pass\" | $npm_package_config_bin/hc s --piped -f=$HC_ADMIN_PORT run $INDEX",
"_local" : "cross-env BOOT_PORT=$(cat .hc_bootenv) SIGNAL_PORT=$(cat .hc_signalenv) HC_APP_PORT=$(cat .hc_app_$INDEX) HC_ADMIN_PORT=$(cat .hc_admin_$INDEX) BUILD_MODE='dev' ADD_PROFILES=1 concurrently \"npm run _sandbox\" \"sleep 7 && npm run start:ui-only -w webapp\"",
"local0" : "cross-env INDEX=0 npm run _local",
"local1" : "cross-env INDEX=1 npm run _local",
"local2" : "cross-env INDEX=2 npm run _local",

"launch" : "echo pass | hc-launch --piped -n 1 artifacts/threads.webhapp network mem",
"launch:we" : "echo pass | hc-launch --piped -n 1 artifacts/threads-we_applet.webhapp network mem",

"test" : "npm run build:happ && npm run build -w @threads/elements && npm t -w @threads/tests",
"package:webapp" : "rm -rf artifacts/threads-webapp-ui.zip && cd webapp/dist && rm -f *.map && bestzip ../../artifacts/threads-webapp-ui.zip * && cd ../../ && $npm_package_config_bin/hc web-app pack webapp/webhapp.workdir -o artifacts/threads.webhapp",
"package:we" : "rm -rf artifacts/threads-we_applet-ui.zip & cd we-applet/dist && rm -f *.map && bestzip ../../artifacts/threads-we_applet-ui.zip * && cd ../../ && $npm_package_config_bin/hc web-app pack we-applet/webhapp.workdir -o artifacts/threads-we_applet.webhapp",

"update-version" : "bash scripts/update-version-number.sh $npm_package_version",
"dl-test-release" : "rm -rf release & mkdir -p release & gh release download manual-release -D release -R lightningrodlabs/threads",

"clean" : "bash scripts/clean.sh",
"clean:npm" : "bash scripts/clean-npm.sh",
"clean:hc" : "rm -rf .hc* && rm -rf we-applet/.hc*",
"clean:all" : "npm run clean:hc && npm run clean:npm && npm run clean"

"test": "npm run build:happ && npm run build -w @threads/elements && npm t -w @threads/tests",
"package:webapp": "rm -rf artifacts/threads-webapp-ui.zip && cd webapp/dist && rm -f *.map && bestzip ../../artifacts/threads-webapp-ui.zip * && cd ../../ && $npm_package_config_bin/hc web-app pack webapp/webhapp.workdir -o artifacts/threads.webhapp",
"package:we": "rm -rf artifacts/threads-we_applet-ui.zip & cd we-applet/dist && rm -f *.map && bestzip ../../artifacts/threads-we_applet-ui.zip * && cd ../../ && $npm_package_config_bin/hc web-app pack we-applet/webhapp.workdir -o artifacts/threads-we_applet.webhapp",
"update-version": "bash scripts/update-version-number.sh $npm_package_version",
"dl-test-release": "rm -rf release & mkdir -p release & gh release download manual-release -D release -R lightningrodlabs/threads",
"clean": "bash scripts/clean.sh",
"clean:npm": "bash scripts/clean-npm.sh",
"clean:hc": "rm -rf .hc* && rm -rf we-applet/.hc*",
"clean:all": "npm run clean:hc && npm run clean:npm && npm run clean"
},
"devDependencies": {
"@types/jest": "^29.5.1",
Expand All @@ -65,10 +80,10 @@
"typescript": "^4.9.5"
},
"dependencies": {
"@ddd-qc/cell-proxy": "0.19.4",
"@ddd-qc/lit-happ": "0.19.4",
"@ddd-qc/cell-proxy": "=0.19.11",
"@ddd-qc/lit-happ": "=0.19.11",
"@ddd-qc/path-explorer": "0.1.6",
"@holochain/client": "=0.14.1",
"@holochain/client": "=0.16.2",
"@holochain-open-dev/core-types": "0.6.3",
"@lit-labs/context": "^0.2.0",
"lit": "2.6.0"
Expand Down
2 changes: 1 addition & 1 deletion we-applet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"typescript": "^4.9.0"
},
"dependencies": {
"@lightningrodlabs/we-applet": "0.6.1",
"@lightningrodlabs/we-applet": "0.8.0",
"@threads/app": "file:../webapp",
"@mdi/js": "^7.2.0"
}
Expand Down
2 changes: 1 addition & 1 deletion we-applet/src/attachment-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function attachmentTypes(appletClient: AppAgentClient, appletId: En
subjectHash: attachToHrl[1],
subjectType: "unknown type", //FIXME: 'We' should provide entryInfo.type
},
appletId: entryInfo.appletId,
appletHash: entryInfo.appletHash,
dnaHash: attachToHrl[0],
};

Expand Down
2 changes: 1 addition & 1 deletion we-applet/src/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async function generateFakeProfilesAppInfo(myKey: AgentPubKey): Promise<AppInfo>
cell_id: [await fakeDnaHash(), myKey],
dna_modifiers: {
network_seed: "profiles-mock-ns",
properties: {},
properties: new Uint8Array(),
origin_time: HOLOCHAIN_EPOCH,
quantum_time: {secs: 1, nanos: 0},
}
Expand Down
4 changes: 2 additions & 2 deletions webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
},
"dependencies": {
"@holochain-open-dev/core-types": "0.6.3",
"@holochain-open-dev/profiles": "^0.14.0",
"@lightningrodlabs/we-applet": "0.6.1",
"@holochain-open-dev/profiles": "^0.16.1",
"@lightningrodlabs/we-applet": "0.8.0",
"@threads/elements": "file:../webcomponents"
}
}
2 changes: 1 addition & 1 deletion webapp/src/threads-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class ThreadsApp extends HappElement {
console.log("hvmConstructed()", this._adminWs, this._canAuthorizeZfns)
/** Authorize all zome calls */
if (!this._adminWs && this._canAuthorizeZfns) {
this._adminWs = await AdminWebsocket.connect(`ws://localhost:${HC_ADMIN_PORT}`);
this._adminWs = await AdminWebsocket.connect(new URL(`ws://localhost:${HC_ADMIN_PORT}`));
console.log("hvmConstructed() connect() called", this._adminWs);
}
if (this._adminWs && this._canAuthorizeZfns) {
Expand Down
2 changes: 1 addition & 1 deletion webcomponents/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"dependencies": {
"@types/functional-red-black-tree": "^1.0.2",
"@lightningrodlabs/we-applet": "0.6.1",
"@lightningrodlabs/we-applet": "0.8.0",
"functional-red-black-tree": "^1.0.1",
"js-base64": "^3.7.3",
"@msgpack/msgpack": "^2.7.2",
Expand Down
2 changes: 1 addition & 1 deletion webcomponents/src/bindings/threads.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export interface ProbeAllLatestOutput {

export interface CreatePpInput {
pp: ParticipationProtocol
appletId: EntryHash
appletHash: EntryHash
dnaHash: DnaHash
}

Expand Down
2 changes: 1 addition & 1 deletion webcomponents/src/elements/applet-threads-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ export class AppletThreadsTree extends ZomeElement<ThreadsPerspective, ThreadsZv

//const topicHasUnreads = this.perspective.unreadSubjects.includes(topicHash);
return html`<ui5-tree-item-custom id=${pathHash} level="1" has-children>
<div slot="content" style="display:flex;align-items:center;font-weight:normal;text-decoration:;">
<div slot="content" style="display:flex;align-items:center;font-weight:normal;text-decoration:none;">
<span>${subjectType}</span>
${commentButton}
${newBadge}
Expand Down
10 changes: 5 additions & 5 deletions webcomponents/src/elements/semantic-threads-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ export class SemanticThreadsPage extends DnaElement<unknown, ThreadsDvm> {
subjectHash: decodeHashFromBase64(request.subjectHash),
subjectType: request.subjectType,
},
appletId: decodeHashFromBase64(this.appletId),
appletHash: decodeHashFromBase64(this.appletId),
dnaHash: decodeHashFromBase64(this.cell.dnaHash),
};
const [ppAh, _ppMat] = await this._dvm.threadsZvm.publishParticipationProtocol(ppInput);
Expand Down Expand Up @@ -780,10 +780,10 @@ export class SemanticThreadsPage extends DnaElement<unknown, ThreadsDvm> {
/*border: 1px solid dimgray;*/
}
//#topicBar::part(root) {
// background: #DBE3EF;
// /*border: 1px solid dimgray;*/
//}
#topicBar::part(root) {
/*background: #DBE3EF;*/
/*border: 1px solid dimgray;*/
}
#rightSide {
Expand Down
16 changes: 15 additions & 1 deletion webcomponents/src/viewModels/threads.zvm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ export class ThreadsZvm extends ZomeViewModel {
}


/** Notify subscribers */
/** FIXME: structuredClone() fails because of Thread class. Refactor to a state object instead */
protected notifySubscribers(): boolean {
if (!this.hasChanged()) return false;
//this._previousPerspective = structuredClone(this.perspective);
this._previousPerspective = this.perspective;
for (const [host, propName] of this._providedHosts) {
(host as any)[propName] = this._previousPerspective;
}
this._dvmParent.zvmChanged(this);
return true;
}


/** -- Perspective -- */

/* */
Expand Down Expand Up @@ -585,7 +599,7 @@ export class ThreadsZvm extends ZomeViewModel {
}
const [ah, ts] = await this.zomeProxy.createParticipationProtocol({
pp,
appletId: decodeHashFromBase64(appletId),
appletHash: decodeHashFromBase64(appletId),
dnaHash: decodeHashFromBase64(dnaHash),
});
const ahB64 = encodeHashToBase64(ah);
Expand Down

0 comments on commit 24bd55a

Please sign in to comment.