diff --git a/.hc b/.hc index 12fedd3..9c203cb 100644 --- a/.hc +++ b/.hc @@ -1,2 +1,2 @@ -/tmp/nix-shell.ApOFsz/5KjOe8iNe5iVwFbsAEWm8 -/tmp/nix-shell.ApOFsz/iv8MJFw8Xq5ntkyXxj-EC +/tmp/nix-shell.3VqZ6c/GFgWpDW5ORfo45Iu-XQaI +/tmp/nix-shell.3VqZ6c/z0_HkroFusuerN55z0I1x diff --git a/flake.lock b/flake.lock index ad8619f..1513942 100644 --- a/flake.lock +++ b/flake.lock @@ -175,16 +175,16 @@ "holochain": { "flake": false, "locked": { - "lastModified": 1694632043, - "narHash": "sha256-5QWUpWnwuzUi3hROrOZyQNla8iGdr+oGCH2nniRePBE=", + "lastModified": 1700660424, + "narHash": "sha256-hDYMjiu8Q38f9MsfpLGFYKIjSDNhXO6ta+pgxT1NGQY=", "owner": "holochain", "repo": "holochain", - "rev": "1f59d33623031eefe76b5f3573970c9c33f21877", + "rev": "b61c9baa77c7f469386727a80064a21803a17cc3", "type": "github" }, "original": { "owner": "holochain", - "ref": "holochain-0.2.2", + "ref": "holochain-0.2.3", "repo": "holochain", "type": "github" } @@ -224,11 +224,11 @@ ] }, "locked": { - "lastModified": 1699425244, - "narHash": "sha256-nQkJiwgO0WpPoVEngnEzgMbMxxz0YeOZzfgvjCvnmVM=", + "lastModified": 1701152506, + "narHash": "sha256-O47SHwudGHZgZBcy5K2UX7VWLIQQT8jwNwHp1gUU00Q=", "owner": "holochain", "repo": "holochain", - "rev": "5f8aecdff743313675522a12fd66fb195c03d282", + "rev": "93fcc367a4575eb5159c06d9168a958ee0b6a366", "type": "github" }, "original": { @@ -246,11 +246,11 @@ }, "locked": { "dir": "versions/0_2", - "lastModified": 1699464531, - "narHash": "sha256-cYelIGio2Nych9Ph7KeVZ/VDbYS247leWEPVDwr7zbg=", + "lastModified": 1701152506, + "narHash": "sha256-O47SHwudGHZgZBcy5K2UX7VWLIQQT8jwNwHp1gUU00Q=", "owner": "holochain", "repo": "holochain", - "rev": "7d0238324809639e5fbf440822ea31b705fe7c28", + "rev": "93fcc367a4575eb5159c06d9168a958ee0b6a366", "type": "github" }, "original": { @@ -311,11 +311,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1699099776, - "narHash": "sha256-X09iKJ27mGsGambGfkKzqvw5esP1L/Rf8H3u3fCqIiU=", + "lastModified": 1700794826, + "narHash": "sha256-RyJTnTNKhO0yqRpDISk03I/4A67/dp96YRxc86YOPgU=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "85f1ba3e51676fa8cc604a3d863d729026a6b8eb", + "rev": "5a09cb4b393d58f9ed0d9ca1555016a8543c2ac8", "type": "github" }, "original": { @@ -420,11 +420,11 @@ ] }, "locked": { - "lastModified": 1699409596, - "narHash": "sha256-L3g1smIol3dGTxkUQOlNShJtZLvjLzvtbaeTRizwZBU=", + "lastModified": 1701137803, + "narHash": "sha256-0LcPAdql5IhQSUXJx3Zna0dYTgdIoYO7zUrsKgiBd04=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "58240e1ac627cef3ea30c7732fedfb4f51afd8e7", + "rev": "9dd940c967502f844eacea52a61e9596268d4f70", "type": "github" }, "original": { diff --git a/package-lock.json b/package-lock.json index 6589a2b..65c3af5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2942,53 +2942,6 @@ "@types/trusted-types": "^2.0.2" } }, - "node_modules/@holochain-open-dev/stores/node_modules/lit-svelte-stores": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/lit-svelte-stores/-/lit-svelte-stores-0.3.0.tgz", - "integrity": "sha512-B7KbLYb+lFiYOz6/i+Xm1jkp9JF+9jT9ch9Vcs+9F5jsmHdOgocUhs0jblcSH8PE8WIuI8j1oHgonUVmeIHbDw==", - "dependencies": { - "@lit-labs/task": "^1.1.2", - "lit": "^2.0.0", - "lodash-es": "^4.17.21", - "svelte": "^3.38.3" - } - }, - "node_modules/@holochain-open-dev/stores/node_modules/lit-svelte-stores/node_modules/@lit/reactive-element": { - "version": "1.6.3", - "resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-1.6.3.tgz", - "integrity": "sha512-QuTgnG52Poic7uM1AN5yJ09QMe0O28e10XzSvWDz02TJiiKee4stsiownEIadWm8nYzyDAyT+gKzUoZmiWQtsQ==", - "dependencies": { - "@lit-labs/ssr-dom-shim": "^1.0.0" - } - }, - "node_modules/@holochain-open-dev/stores/node_modules/lit-svelte-stores/node_modules/lit": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/lit/-/lit-2.8.0.tgz", - "integrity": "sha512-4Sc3OFX9QHOJaHbmTMk28SYgVxLN3ePDjg7hofEft2zWlehFL3LiAuapWc4U/kYwMYJSh2hTCPZ6/LIC7ii0MA==", - "dependencies": { - "@lit/reactive-element": "^1.6.0", - "lit-element": "^3.3.0", - "lit-html": "^2.8.0" - } - }, - "node_modules/@holochain-open-dev/stores/node_modules/lit-svelte-stores/node_modules/lit-element": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/lit-element/-/lit-element-3.3.3.tgz", - "integrity": "sha512-XbeRxmTHubXENkV4h8RIPyr8lXc+Ff28rkcQzw3G6up2xg5E8Zu1IgOWIwBLEQsu3cOVFqdYwiVi0hv0SlpqUA==", - "dependencies": { - "@lit-labs/ssr-dom-shim": "^1.1.0", - "@lit/reactive-element": "^1.3.0", - "lit-html": "^2.8.0" - } - }, - "node_modules/@holochain-open-dev/stores/node_modules/lit-svelte-stores/node_modules/lit-html": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-2.8.0.tgz", - "integrity": "sha512-o9t+MQM3P4y7M7yNzqAyjp7z+mQGa4NS4CxiyLqFPyFWyc4O+nodLrkrxSaCTrla6M5YOLaT3RpbbqjszB5g3Q==", - "dependencies": { - "@types/trusted-types": "^2.0.2" - } - }, "node_modules/@holochain-open-dev/utils": { "version": "0.15.2", "resolved": "https://registry.npmjs.org/@holochain-open-dev/utils/-/utils-0.15.2.tgz", @@ -3012,9 +2965,9 @@ } }, "node_modules/@holochain/client": { - "version": "0.16.2", - "resolved": "https://registry.npmjs.org/@holochain/client/-/client-0.16.2.tgz", - "integrity": "sha512-1Msw6tSdCDI3f2UIdSAYtiAqxxdHt6ufmQSw+GEbvDaIjVXPQWi39IQe5Zzep4VPJoproyurrBRNG1l+/3YrjA==", + "version": "0.16.6", + "resolved": "https://registry.npmjs.org/@holochain/client/-/client-0.16.6.tgz", + "integrity": "sha512-p6Vt8Ka6bLNAgCOXKs+wwgSg9vF9ZLp6iEJaNcmv71wmtf3d8YuqCtQXn6fL7/IW/I/SxPHvlihjo9jstdeC7w==", "dependencies": { "@holochain/serialization": "^0.1.0-beta-rc.3", "@msgpack/msgpack": "^2.8.0", @@ -3027,7 +2980,7 @@ "ws": "^8.14.2" }, "engines": { - "node": ">=16.0.0 || >=18.0.0" + "node": ">=18.0.0 || >=20.0.0" } }, "node_modules/@holochain/serialization": { @@ -3335,14 +3288,6 @@ "resolved": "https://registry.npmjs.org/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.1.2.tgz", "integrity": "sha512-jnOD+/+dSrfTWYfSXBXlo5l5f0q1UuJo3tkbMDCYA2lKUYq79jaxqtGEvnRoh049nt1vdo1+45RinipU6FGY2g==" }, - "node_modules/@lit-labs/task": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@lit-labs/task/-/task-1.1.3.tgz", - "integrity": "sha512-Ta5rdbmuDaYAZwlkjezCoqcnn+J54XBAGI0X4PsCjycY1nJ/Ntbd+YY/eMdfnu777qrvznuqanTa4r1ptPXXxA==", - "dependencies": { - "@lit/reactive-element": "^1.1.0" - } - }, "node_modules/@lit/context": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@lit/context/-/context-1.0.1.tgz", @@ -12877,6 +12822,52 @@ "@types/trusted-types": "^2.0.2" } }, + "node_modules/lit-svelte-stores": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/lit-svelte-stores/-/lit-svelte-stores-0.3.2.tgz", + "integrity": "sha512-igOf4kFdpCTT+dtRJXbfhNWvNOn849MUfFJTQALE7LUsMLwaoCSvUa0DDFpTHqeMS4EjW5GEOycMy5AR+BH3PA==", + "dependencies": { + "lit": "^3.0.0", + "lodash-es": "^4.17.21", + "svelte": "^3.38.3" + } + }, + "node_modules/lit-svelte-stores/node_modules/@lit/reactive-element": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-2.0.2.tgz", + "integrity": "sha512-SVOwLAWUQg3Ji1egtOt1UiFe4zdDpnWHyc5qctSceJ5XIu0Uc76YmGpIjZgx9YJ0XtdW0Jm507sDvjOu+HnB8w==", + "dependencies": { + "@lit-labs/ssr-dom-shim": "^1.1.2" + } + }, + "node_modules/lit-svelte-stores/node_modules/lit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/lit/-/lit-3.1.0.tgz", + "integrity": "sha512-rzo/hmUqX8zmOdamDAeydfjsGXbbdtAFqMhmocnh2j9aDYqbu0fjXygjCa0T99Od9VQ/2itwaGrjZz/ZELVl7w==", + "dependencies": { + "@lit/reactive-element": "^2.0.0", + "lit-element": "^4.0.0", + "lit-html": "^3.1.0" + } + }, + "node_modules/lit-svelte-stores/node_modules/lit-element": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/lit-element/-/lit-element-4.0.2.tgz", + "integrity": "sha512-/W6WQZUa5VEXwC7H9tbtDMdSs9aWil3Ou8hU6z2cOKWbsm/tXPAcsoaHVEtrDo0zcOIE5GF6QgU55tlGL2Nihg==", + "dependencies": { + "@lit-labs/ssr-dom-shim": "^1.1.2", + "@lit/reactive-element": "^2.0.0", + "lit-html": "^3.1.0" + } + }, + "node_modules/lit-svelte-stores/node_modules/lit-html": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-3.1.0.tgz", + "integrity": "sha512-FwAjq3iNsaO6SOZXEIpeROlJLUlrbyMkn4iuv4f4u1H40Jw8wkeR/OUXZUHUoiYabGk8Y4Y0F/rgq+R4MrOLmA==", + "dependencies": { + "@types/trusted-types": "^2.0.2" + } + }, "node_modules/loader-runner": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.0.tgz", @@ -18098,11 +18089,11 @@ }, "ui": { "name": "@holochain-open-dev/cancellations", - "version": "0.2.0", + "version": "0.3.0", "dependencies": { "@holochain-open-dev/elements": "^0.8.2", "@holochain-open-dev/profiles": "^0.17.1", - "@holochain-open-dev/stores": "^0.7.11", + "@holochain-open-dev/stores": "^0.8.2", "@holochain-open-dev/utils": "^0.16.2", "@holochain/client": "^0.16.0", "@lit/context": "^1.0.0", @@ -18128,6 +18119,21 @@ "vite-plugin-checker": "^0.5.3" } }, + "ui/node_modules/@holochain-open-dev/stores": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/@holochain-open-dev/stores/-/stores-0.8.2.tgz", + "integrity": "sha512-gv94/4Gm3jWXUa/clKgeCLsTX7JtOQFVSRCxaW8hkMDYgAhyE1LIcv470phrDvX/I/wl5VgTjXMisEX695h44A==", + "dependencies": { + "@alenaksu/json-viewer": "^2.0.1", + "@holochain-open-dev/utils": "^0.16.2", + "@holochain/client": "^0.16.5", + "@scoped-elements/cytoscape": "^0.2.0", + "@shoelace-style/shoelace": "^2.11.2", + "lit": "^3.0.2", + "lit-svelte-stores": "^0.3.0", + "svelte": "^3.53.1" + } + }, "ui/node_modules/@holochain-open-dev/utils": { "version": "0.16.2", "resolved": "https://registry.npmjs.org/@holochain-open-dev/utils/-/utils-0.16.2.tgz", diff --git a/tests/src/cancellation.test.ts b/tests/src/cancellation.test.ts index 4396e29..6d81642 100644 --- a/tests/src/cancellation.test.ts +++ b/tests/src/cancellation.test.ts @@ -108,12 +108,12 @@ test('create and delete Cancellation', async () => { let cancellactionsFor = await toPromise( alice.store.cancellationsFor.get(cancelledHash).live ); - assert.equal(cancellactionsFor.length, 0); + assert.equal(cancellactionsFor.size, 0); let undoneCancellactionsFor = await toPromise( alice.store.cancellationsFor.get(cancelledHash).undone ); - assert.equal(undoneCancellactionsFor.length, 0); + assert.equal(undoneCancellactionsFor.size, 0); // Alice creates a Cancellation const cancellation: EntryRecord = @@ -126,7 +126,7 @@ test('create and delete Cancellation', async () => { cancellactionsFor = await toPromise( alice.store.cancellationsFor.get(cancelledHash).live ); - assert.equal(cancellactionsFor.length, 1); + assert.equal(cancellactionsFor.size, 1); // Alice deletes the Cancellation await alice.store.client.undoCancellation(cancellation.actionHash); @@ -134,7 +134,7 @@ test('create and delete Cancellation', async () => { cancellactionsFor = await toPromise( alice.store.cancellationsFor.get(cancelledHash).live ); - assert.equal(cancellactionsFor.length, 0); + assert.equal(cancellactionsFor.size, 0); // Wait for the created entry to be propagated to the other node. await dhtSync([alice.player, bob.player], alice.player.cells[0].cell_id[0]); @@ -153,6 +153,6 @@ test('create and delete Cancellation', async () => { undoneCancellactionsFor = await toPromise( alice.store.cancellationsFor.get(cancelledHash).undone ); - assert.equal(undoneCancellactionsFor.length, 1); + assert.equal(undoneCancellactionsFor.size, 1); }); }); diff --git a/ui/custom-elements.json b/ui/custom-elements.json index a25450a..477a9b1 100644 --- a/ui/custom-elements.json +++ b/ui/custom-elements.json @@ -266,7 +266,7 @@ "name": "getCancellationsFor", "return": { "type": { - "text": "Promise>" + "text": "Promise>" } }, "parameters": [ @@ -283,7 +283,7 @@ "name": "getUndoneCancellationsFor", "return": { "type": { - "text": "Promise>]>>" + "text": "Promise<\n Array<\n [SignedActionHashed, Array>]\n >\n >" } }, "parameters": [ @@ -342,7 +342,7 @@ { "kind": "field", "name": "cancellationsFor", - "default": "new LazyHoloHashMap((cancelledHash: ActionHash) => ({\n live: pipe(\n liveLinksTargetsStore(\n this.client,\n cancelledHash,\n () => this.client.getCancellationsFor(cancelledHash),\n 'Cancellations'\n ),\n hashes => slice(this.cancellations, hashes)\n ),\n undone: pipe(\n deletedLinksTargetsStore(\n this.client,\n cancelledHash,\n () => this.client.getUndoneCancellationsFor(cancelledHash),\n 'Cancellations'\n ),\n linksDeleted =>\n slice(\n this.cancellations,\n linksDeleted.map(([cl]) => cl.target_address)\n )\n ),\n }))" + "default": "new LazyHoloHashMap((cancelledHash: ActionHash) => ({\n live: pipe(\n liveLinksStore(\n this.client,\n cancelledHash,\n () => this.client.getCancellationsFor(cancelledHash),\n 'Cancellations'\n ),\n links =>\n slice(\n this.cancellations,\n links.map(l => l.target)\n )\n ),\n undone: pipe(\n deletedLinksStore(\n this.client,\n cancelledHash,\n () => this.client.getUndoneCancellationsFor(cancelledHash),\n 'Cancellations'\n ),\n linksDeleted =>\n slice(\n this.cancellations,\n linksDeleted.map(([cl]) => cl.hashed.content.target_address)\n )\n ),\n }))" }, { "kind": "field", diff --git a/ui/package.json b/ui/package.json index 1661618..e3c0510 100644 --- a/ui/package.json +++ b/ui/package.json @@ -1,6 +1,6 @@ { "name": "@holochain-open-dev/cancellations", - "version": "0.3.0", + "version": "0.4.0", "scripts": { "start": "vite --clearScreen false --port $UI_PORT", "build": "npm run lint && tsc && npm run analyze -- --exclude dist", @@ -27,7 +27,7 @@ "@holochain/client": "^0.16.0", "@holochain-open-dev/elements": "^0.8.2", "@holochain-open-dev/profiles": "^0.17.1", - "@holochain-open-dev/stores": "^0.7.11", + "@holochain-open-dev/stores": "^0.8.2", "@holochain-open-dev/utils": "^0.16.2", "@lit/context": "^1.0.0", "@lit/localize": "^0.12.0", diff --git a/ui/src/cancellations-client.ts b/ui/src/cancellations-client.ts index 7fd5006..8fbc38e 100644 --- a/ui/src/cancellations-client.ts +++ b/ui/src/cancellations-client.ts @@ -5,7 +5,7 @@ import { CreateLink, Delete, DeleteLink, - HoloHash, + Link, Record, SignedActionHashed, } from '@holochain/client'; @@ -69,13 +69,17 @@ export class CancellationsClient extends ZomeClient { return new EntryRecord(record); } - getCancellationsFor(actionHash: ActionHash): Promise> { + getCancellationsFor(actionHash: ActionHash): Promise> { return this.callZome('get_cancellations_for', actionHash); } getUndoneCancellationsFor( actionHash: ActionHash - ): Promise>]>> { + ): Promise< + Array< + [SignedActionHashed, Array>] + > + > { return this.callZome('get_undone_cancellations_for', actionHash); } diff --git a/ui/src/cancellations-store.ts b/ui/src/cancellations-store.ts index 18ff368..39c8d2f 100644 --- a/ui/src/cancellations-store.ts +++ b/ui/src/cancellations-store.ts @@ -1,9 +1,9 @@ import { - deletedLinksTargetsStore, + deletedLinksStore, deletesForEntryStore, immutableEntryStore, latestVersionOfEntryStore, - liveLinksTargetsStore, + liveLinksStore, pipe, } from '@holochain-open-dev/stores'; import { LazyHoloHashMap, slice } from '@holochain-open-dev/utils'; @@ -16,16 +16,20 @@ export class CancellationsStore { cancellationsFor = new LazyHoloHashMap((cancelledHash: ActionHash) => ({ live: pipe( - liveLinksTargetsStore( + liveLinksStore( this.client, cancelledHash, () => this.client.getCancellationsFor(cancelledHash), 'Cancellations' ), - hashes => slice(this.cancellations, hashes) + links => + slice( + this.cancellations, + links.map(l => l.target) + ) ), undone: pipe( - deletedLinksTargetsStore( + deletedLinksStore( this.client, cancelledHash, () => this.client.getUndoneCancellationsFor(cancelledHash), @@ -34,7 +38,7 @@ export class CancellationsStore { linksDeleted => slice( this.cancellations, - linksDeleted.map(([cl]) => cl.target_address) + linksDeleted.map(([cl]) => cl.hashed.content.target_address) ) ), })); diff --git a/zomes/coordinator/cancellations/src/cancellation.rs b/zomes/coordinator/cancellations/src/cancellation.rs index 3adebf7..524cd26 100644 --- a/zomes/coordinator/cancellations/src/cancellation.rs +++ b/zomes/coordinator/cancellations/src/cancellation.rs @@ -117,27 +117,18 @@ pub fn undo_cancellation(original_cancellation_hash: ActionHash) -> ExternResult } #[hdk_extern] -pub fn get_cancellations_for(action_hash: ActionHash) -> ExternResult> { - let links = get_links(action_hash, LinkTypes::Cancellations, None)?; - let action_hashes: Vec = links - .into_iter() - .filter_map(|link| link.target.into_action_hash()) - .collect(); - Ok(action_hashes) +pub fn get_cancellations_for(action_hash: ActionHash) -> ExternResult> { + get_links(action_hash, LinkTypes::Cancellations, None) } #[hdk_extern] pub fn get_undone_cancellations_for( action_hash: ActionHash, -) -> ExternResult)>> { +) -> ExternResult)>> { let details = get_link_details(action_hash, LinkTypes::Cancellations, None)?; Ok(details .into_inner() .into_iter() .filter(|(_link, deletes)| deletes.len() > 0) - .filter_map(|(link, deletes)| match link.hashed.content { - Action::CreateLink(cl) => Some((cl, deletes)), - _ => None, - }) .collect()) }