├── .github ├── nix.conf └── workflows │ ├── build-electron.yml │ ├── build-webhapps.yml │ ├── release.yml │ └── test.yml ├── .gitignore ├── Cargo.toml ├── LICENSE ├── README.md ├── default.nix ├── dna ├── workdir │ ├── dna-ludotheque │ │ └── dna.yaml │ ├── dna-where │ │ └── dna.yaml │ ├── happ-ludotheque │ │ └── happ.yaml │ ├── happ-where-standalone │ │ └── happ.yaml │ └── happ-where │ │ └── happ.yaml └── zomes │ ├── ludotheque │ ├── Cargo.toml │ └── src │ │ ├── export_playset.rs │ │ ├── lib.rs │ │ └── playset.rs │ ├── ludotheque_integrity │ ├── Cargo.toml │ └── src │ │ ├── lib.rs │ │ └── playset.rs │ ├── playset │ ├── Cargo.toml │ └── src │ │ ├── export_piece.rs │ │ ├── export_space.rs │ │ ├── get_inventory.rs │ │ ├── import_piece.rs │ │ ├── lib.rs │ │ └── pieces │ │ ├── emoji_group.rs │ │ ├── mod.rs │ │ ├── space.rs │ │ ├── svg_marker.rs │ │ └── template.rs │ ├── playset_integrity │ ├── Cargo.toml │ └── src │ │ ├── lib.rs │ │ └── pieces │ │ ├── emoji_group.rs │ │ ├── mod.rs │ │ ├── space.rs │ │ ├── svg_marker.rs │ │ └── template.rs │ ├── profiles │ ├── Cargo.toml │ └── src │ │ └── lib.rs │ ├── profiles_integrity │ ├── Cargo.toml │ └── src │ │ └── lib.rs │ ├── where │ ├── Cargo.toml │ └── src │ │ ├── here.rs │ │ ├── hide.rs │ │ ├── lib.rs │ │ ├── placement_session.rs │ │ ├── play.rs │ │ └── signals.rs │ └── where_integrity │ ├── Cargo.toml │ └── src │ ├── entries.rs │ └── lib.rs ├── electron ├── .gitignore ├── afterSignHook.js ├── bin │ └── .gitignore ├── package.json ├── src │ ├── constants.ts │ ├── holochain.ts │ ├── index.ts │ ├── init.ts │ ├── localization │ │ ├── en.json │ │ ├── fr.json │ │ └── i18n.js │ ├── logger.ts │ ├── preload.js │ └── userSettings.ts ├── tsconfig.json └── web │ ├── favicon.ico │ ├── logo │ ├── icon.icns │ ├── icon.ico │ ├── icon512.png │ ├── logo.svg │ ├── logo16.png │ ├── logo256.png │ └── splash.png │ ├── splashscreen.css │ ├── splashscreen.html │ ├── switching.css │ └── switching.html ├── nix ├── sources.json └── sources.nix ├── package.json ├── scripts ├── clean-npm.sh ├── clean.sh ├── install-submodules.sh ├── ts-bindings.sh ├── update-version-number.sh └── write-zome-hash.sh ├── spec ├── DESIGN.md ├── where-happ-structure.png └── where.gif ├── tsconfig.json ├── we-applet ├── .gitignore ├── icon.png ├── index.html ├── package.json ├── rollup.config.js ├── src │ ├── appletServices │ │ ├── getAttachableInfo.ts │ │ └── search.ts │ ├── createLudoApplet.ts │ ├── createWhereApplet.ts │ ├── createWhereWeServicesMock.ts │ └── index.ts ├── tsconfig.json ├── web-dev-server.config.mjs └── webhapp.workdir │ └── web-happ.yaml ├── we.prodtest.config.json ├── webapp.ludotheque ├── .gitignore ├── index.html ├── package.json ├── rollup.config.js ├── src │ ├── index.ts │ └── ludotheque-standalone-app.ts ├── tsconfig.json └── web-dev-server.config.mjs ├── webapp ├── .gitignore ├── favicon.ico ├── index.html ├── lit-localize.json ├── logo.svg ├── package.json ├── rollup.config.js ├── src │ ├── globals.ts │ ├── index.ts │ ├── localization.ts │ └── where-app.ts ├── tsconfig.json ├── web-dev-server.config.mjs ├── webhapp.workdir │ └── web-happ.yaml └── xliff │ └── fr-fr.xlf └── webcomponents ├── .editorconfig ├── .eslintrc.js ├── .gitignore ├── lit-localize.json ├── package.json ├── src ├── bindings │ ├── ludotheque.fn.ts │ ├── ludotheque.proxy.ts │ ├── ludotheque.types.ts │ ├── playset.fn.ts │ ├── playset.proxy.ts │ ├── playset.types.ts │ ├── where.fn.ts │ ├── where.proxy.ts │ └── where.types.ts ├── contexts.ts ├── dialogs │ ├── where-archive-dialog.ts │ ├── where-clone-ludo-dialog.ts │ ├── where-emoji-dialog.ts │ ├── where-emoji-group-dialog.ts │ ├── where-location-dialog.ts │ ├── where-ludo-dialog.ts │ ├── where-play-dialog.ts │ ├── where-play-info-dialog.ts │ ├── where-playset-dialog.ts │ ├── where-space-dialog.ts │ ├── where-svg-marker-dialog.ts │ └── where-template-dialog.ts ├── elements │ ├── edit-profile.ts │ ├── hrl-link.ts │ ├── ludotheque-page.ts │ ├── where-dashboard.ts │ ├── where-page.ts │ ├── where-peer-list.ts │ └── where-space.ts ├── examples.ts ├── index.ts ├── sharedRender.ts ├── sharedStyles.ts ├── stringStore.ts ├── templates.ts ├── utils.ts └── viewModels │ ├── happDef.ts │ ├── ludotheque.dvm.ts │ ├── ludotheque.zvm.ts │ ├── playset.perspective.ts │ ├── playset.zvm.ts │ ├── where.dvm.ts │ ├── where.perspective.ts │ └── where.zvm.ts ├── tsconfig.json └── xliff └── fr-fr.xlf /.github/nix.conf: -------------------------------------------------------------------------------- 1 | substituters = https://cache.nixos.org/ https://cache.holo.host/ 2 | trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= cache.holo.host-1:lNXIXtJgS9Iuw4Cu6X0HINLu9sTfcjEntnrgwMQIMcE= cache.holo.host-2:ZJCkX3AUYZ8soxTLfTb60g+F3MkWD7hkH9y8CgqwhDQ= 3 | -------------------------------------------------------------------------------- /.github/workflows/build-electron.yml: -------------------------------------------------------------------------------- 1 | name: build-electron 2 | 3 | on: 4 | workflow_call: 5 | 6 | env: 7 | USE_HARD_LINKS: false 8 | 9 | jobs: 10 | # Build the dna & happ 11 | call-build-webhapps: 12 | uses: ./.github/workflows/build-webhapps.yml 13 | 14 | # upload the app package for each target os 15 | build-binaries: 16 | needs: call-build-webhapps 17 | strategy: 18 | fail-fast: false 19 | matrix: 20 | os: 21 | - ubuntu-latest 22 | - macos-latest 23 | - windows-latest 24 | runs-on: ${{ matrix.os }} 25 | steps: 26 | # Checkout repo 27 | - uses: actions/checkout@v3 28 | # Set NPM shell (windows-only) 29 | - name: Set NPM shell (windows-only) 30 | if: ${{ runner.os == 'Windows' }} 31 | shell: bash 32 | run: | 33 | npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe" 34 | # Download previously uploaded artifacts 35 | - uses: actions/download-artifact@master 36 | with: 37 | name: all-happ-artifact 38 | path: artifacts 39 | # Display artifacts folder 40 | - name: Display artifacts folder 41 | run: ls 42 | working-directory: artifacts 43 | # Dispatch artifacts 44 | - name: Dispatch artifacts 45 | run: | 46 | cp artifacts/where.happ ./electron/bin 47 | cp artifacts/where_zome_hash.txt ./electron/bin 48 | cp artifacts/ludotheque_zome_hash.txt ./electron/bin 49 | # Install npm dependencies 50 | - name: Install npm dependencies 51 | run: | 52 | npm install 53 | # Download submodules 54 | - name: Download submodules 55 | shell: bash 56 | run: | 57 | npm run install:submodules 58 | # Build webapp 59 | - name: Build webapp 60 | run: | 61 | npm run build:webapp 62 | # Build electron app 63 | - name: Build electron app 64 | shell: bash 65 | env: 66 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 67 | run: | 68 | npm run build -w electron 69 | # Dist Electron 70 | - name: Dist Electron 71 | shell: bash 72 | env: 73 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 74 | run: | 75 | npm run dist:electron 76 | # List out-builder folder 77 | - name: list out-builder folder 78 | continue-on-error: true 79 | run: ls -R 80 | working-directory: electron/out-builder 81 | # list bin folder 82 | - name: list bin folder 83 | continue-on-error: true 84 | run: ls 85 | working-directory: electron/bin 86 | # Move binary for each platform 87 | - name: Move binary 88 | env: 89 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 90 | run: | 91 | cp electron/out-builder/Where* ./artifacts 92 | # List uploaded files 93 | - name: List artifacts folder 94 | run: ls -R 95 | working-directory: artifacts 96 | # "upload" artifacts 97 | - uses: actions/upload-artifact@master 98 | with: 99 | name: all-happ-artifact 100 | path: artifacts 101 | -------------------------------------------------------------------------------- /.github/workflows/build-webhapps.yml: -------------------------------------------------------------------------------- 1 | name: build-webhapps 2 | 3 | on: 4 | workflow_call: 5 | 6 | jobs: 7 | build-webhapps: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v3 11 | # Install npm dependencies 12 | - name: Install npm dependencies 13 | shell: bash 14 | run: | 15 | npm install 16 | # Download submodules 17 | - name: Download submodules 18 | shell: bash 19 | run: | 20 | npm run install:submodules 21 | # install rust tools 22 | - name: install rust tools 23 | shell: bash 24 | run: | 25 | npm run install:rust 26 | # install hc tool 27 | - name: Install hc tool 28 | shell: bash 29 | run: | 30 | npm run install:hc 31 | # Install hash-zome 32 | - name: Install hash-zome 33 | run: | 34 | npm run install:hash-zome 35 | # Build happ 36 | - name: Build happ 37 | shell: bash 38 | run: | 39 | npm run build:happ 40 | # Build webapp 41 | - name: Build webapp 42 | run: | 43 | npm run build:webapp 44 | # Build ludotheque 45 | - name: Build ludotheque 46 | run: | 47 | npm run build -w webapp.ludotheque 48 | # Package web-happ 49 | - name: Package web-happ 50 | run: | 51 | npm run package:webapp 52 | # build we-applet 53 | - name: build we-applet 54 | shell: bash 55 | run: | 56 | npm run dist -w we-applet 57 | # Package we-applet 58 | - name: Package we-applet 59 | shell: bash 60 | run: | 61 | npm run package:we 62 | # Regroup artifacts 63 | - name: Regroup artifacts 64 | run: | 65 | cp electron/bin/where_zome_hash.txt ./artifacts 66 | cp electron/bin/ludotheque_zome_hash.txt ./artifacts 67 | cp target/wasm32-unknown-unknown/release/where_playset_integrity_zome.wasm ./artifacts 68 | cp target/wasm32-unknown-unknown/release/where_playset_zome.wasm ./artifacts 69 | cp target/wasm32-unknown-unknown/release/where_ludotheque_integrity_zome.wasm ./artifacts 70 | cp target/wasm32-unknown-unknown/release/where_ludotheque_zome.wasm ./artifacts 71 | cp target/wasm32-unknown-unknown/release/where_integrity_zome.wasm ./artifacts 72 | cp target/wasm32-unknown-unknown/release/where_zome.wasm ./artifacts 73 | cp target/wasm32-unknown-unknown/release/profiles_zome.wasm ./artifacts 74 | cp target/wasm32-unknown-unknown/release/profiles_integrity_zome.wasm ./artifacts 75 | # List uploaded files 76 | - name: List uploaded files 77 | run: ls -R 78 | working-directory: ./artifacts 79 | # "upload" artifacts 80 | - uses: actions/upload-artifact@master 81 | with: 82 | name: all-happ-artifact 83 | path: artifacts/ 84 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release x64 2 | 3 | on: 4 | push: 5 | tags: 6 | - v[0-9]+.* 7 | 8 | jobs: 9 | call-build-electron: 10 | uses: ./.github/workflows/build-electron.yml 11 | secrets: inherit 12 | 13 | # upload the artifacts 14 | upload-assets: 15 | needs: call-build-electron 16 | runs-on: ubuntu-latest 17 | steps: 18 | - uses: actions/checkout@v3 19 | # Download previously uploaded artifacts 20 | - uses: actions/download-artifact@v3 21 | with: 22 | name: all-happ-artifact 23 | path: artifacts 24 | # Display artifacts folder 25 | - name: Display artifacts folder 26 | run: ls 27 | working-directory: artifacts 28 | # upload all artifacts 29 | - name: upload binary (ubuntu only) 30 | if: ${{ runner.os == 'Linux' }} 31 | env: 32 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 33 | working-directory: artifacts 34 | run: | 35 | rm -f *.blockmap 36 | echo ludotheque 37 | gh release upload "${GITHUB_REF#refs/tags/}" ludotheque* --clobber 38 | echo where* 39 | gh release upload "${GITHUB_REF#refs/tags/}" where* --clobber 40 | echo Where* 41 | gh release upload "${GITHUB_REF#refs/tags/}" Where* --clobber 42 | echo profiles* 43 | gh release upload "${GITHUB_REF#refs/tags/}" profiles_zome.wasm --clobber 44 | gh release upload "${GITHUB_REF#refs/tags/}" profiles_integrity_zome.wasm --clobber 45 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: test-workflow x64 2 | 3 | on: workflow_dispatch 4 | 5 | jobs: 6 | call-build-electron: 7 | uses: ./.github/workflows/build-electron.yml 8 | secrets: inherit 9 | 10 | # upload the artifacts 11 | upload-assets: 12 | needs: call-build-electron 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v3 16 | # Download previously uploaded artifacts 17 | - uses: actions/download-artifact@v3 18 | with: 19 | name: all-happ-artifact 20 | path: artifacts 21 | # Display artifacts folder 22 | - name: Display artifacts folder 23 | run: ls 24 | working-directory: artifacts 25 | # upload all artifacts 26 | - name: upload binary (ubuntu only) 27 | if: ${{ runner.os == 'Linux' }} 28 | env: 29 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 30 | working-directory: artifacts 31 | run: | 32 | rm -f *.blockmap 33 | echo ludotheque 34 | gh release upload "manual-release" ludotheque* --clobber 35 | echo where* 36 | gh release upload "manual-release" where* --clobber 37 | echo Where* 38 | gh release upload "manual-release" Where* --clobber 39 | echo profiles* 40 | gh release upload "manual-release" profiles_zome.wasm --clobber 41 | gh release upload "manual-release" profiles_integrity_zome.wasm --clobber 42 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## editors 2 | /.idea 3 | /.vscode 4 | 5 | 6 | ## system files 7 | .DS_Store 8 | 9 | target/ 10 | node_modules/ 11 | dist/ 12 | .cargo/ 13 | .hc* 14 | dna/workdir/dna*/*.dna 15 | dna/workdir/happ*/*.happ 16 | webapp/webhapp.workdir/*.webhapp 17 | *.tsbuildinfo 18 | .running 19 | dna/*.txt 20 | 21 | 22 | release/ 23 | artifacts/* 24 | submodules/**/* 25 | bin/ 26 | 27 | *.map 28 | 29 | 30 | # Specific files 31 | Cargo.lock 32 | hash_zome* 33 | package-lock.json 34 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = [ 3 | "dna/zomes/where_integrity", 4 | "dna/zomes/where", 5 | "dna/zomes/playset_integrity", 6 | "dna/zomes/playset", 7 | "dna/zomes/ludotheque_integrity", 8 | "dna/zomes/ludotheque", 9 | "dna/zomes/profiles_integrity", 10 | "dna/zomes/profiles" 11 | ] 12 | 13 | [workspace.package] 14 | version = "2.0.0" 15 | rust-version = "1.65.0" 16 | edition = "2021" 17 | 18 | [workspace.dependencies] 19 | serde = { version = "=1.0.163", default-features = false } 20 | hdi = { version = "0.3.6", default-features = false } 21 | hdk = { version = "0.2.6", default-features = false } 22 | zome_utils = { git = "https://github.com/ddd-mtl/zome-utils", branch = "hdk-2.6" } 23 | 24 | 25 | [profile.dev] 26 | lto = false 27 | opt-level = 0 28 | overflow-checks = false 29 | 30 | [profile.release] 31 | opt-level = "z" 32 | lto = true 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # where 2 | 3 | Tooling for group self-awareness on holochain 4 | 5 | ## Background 6 | 7 | Groups, especially remote colaborative groups, often lack contextual information about collaborators that makes working together harder. Co-locating oneself across a number of spaces in the context of a group (or groups) provides an important avenue for improving both sense-making and working together. **Where** provides a generalized pattern for creating shared maps for groups to see the emergent "whereness" of each other across self-evolved sets of maps. 8 | 9 | Initial prototype: 10 | ![screencast](spec/where.gif) 11 | 12 | ## Design 13 | 14 | For more details read the [design documents](spec/DESIGN.md). 15 | 16 | ## Dev testing 17 | 18 | ### Setup 19 | 1. Install the required tools 20 | 1. Rust wasm target: `npm run install:rust` 21 | 1. [`holochain`](https://github.com/holochain/holochain): `cargo install holochain` (or use nix-shell) 22 | 4. `npm run install:hc` 23 | 3. `npm run install:zits` 24 | 4. `npm install` 25 | 5. `npm run install:submodules` 26 | 5. `npm run install:hash-zome` 27 | 5. `npm run build:localize` 28 | 29 | ### Web 30 | `npm run devtest` 31 | 32 | ### Electron 33 | `npm run devtest:electron` 34 | 35 | 36 | ## Network 37 | 38 | To bootstrap a network of N agents: 39 | 40 | ``` bash 41 | npm run network 3 42 | ``` 43 | 44 | Replace the "3" for the number of agents you want to bootstrap. 45 | ## Package 46 | 47 | To package the web-happ: 48 | 49 | ``` bash 50 | npm run package:webapp 51 | ``` 52 | 53 | All output files (`*.webhapp`, `*.dna`, `*.happ`, etc.) will be in the `artifacts` folder. 54 | 55 | 56 | ## Project structure 57 | 58 | | Directory | Description | 59 | |:-------------------------------------------| :-------------------------------------------------------------------------------------------------------------------------- | 60 | | `/dna/` | DNA source code 61 | | `/electron/` | Electron app directory 62 | |     `bin/` | All the binaries we are dependent on and must ship with the app 63 | |     `src/` | The electron app source code 64 | |     `web/` | Final artifacts for the electron app (includes output from `webapp`) 65 | | `/webapp/` | The Where webapp source code 66 | |     `webhapp.workdir/` | webhapp work directory 67 | | `/webapp.ludotheque/` | The Ludotheque standalone webapp source code 68 | | `/webcomponents/` | The web components source code 69 | | `/we-applet/` | The applet for We integration 70 | 71 | ## License 72 | [![License: CAL 1.0](https://img.shields.io/badge/License-CAL%201.0-blue.svg)](https://github.com/holochain/cryptographic-autonomy-license) 73 | 74 | Copyright (C) 2021, Harris-Braun Enterprises, LLC 75 | 76 | This program is free software: you can redistribute it and/or modify it under the terms of the license 77 | provided in the LICENSE file (CAL-1.0). This program is distributed in the hope that it will be useful, 78 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 79 | -------------------------------------------------------------------------------- /default.nix: -------------------------------------------------------------------------------- 1 | let 2 | holonixPath = (import ./nix/sources.nix).holonix; # points to the current state of the Holochain repository 3 | holonix = import (holonixPath) { 4 | holochainVersionId = "v0_0_127"; # specifies the Holochain version 5 | }; 6 | nixpkgs = holonix.pkgs; 7 | in nixpkgs.mkShell { 8 | inputsFrom = [ holonix.main ]; 9 | packages = with nixpkgs; [ 10 | niv 11 | # any additional packages needed for this project, e. g. Nodejs 12 | ]; 13 | } -------------------------------------------------------------------------------- /dna/workdir/dna-ludotheque/dna.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | manifest_version: "1" 3 | name: dLudotheque 4 | integrity: 5 | origin_time: 2022-09-25T13:55:49.200Z 6 | zomes: 7 | - name: playset_integrity 8 | bundled: ../../../target/wasm32-unknown-unknown/release/where_playset_integrity_zome.wasm 9 | - name: ludotheque_integrity 10 | bundled: ../../../target/wasm32-unknown-unknown/release/where_ludotheque_integrity_zome.wasm 11 | coordinator: 12 | zomes: 13 | - name: zPlayset 14 | bundled: ../../../target/wasm32-unknown-unknown/release/where_playset_zome.wasm 15 | dependencies: 16 | - name: playset_integrity 17 | - name: zLudotheque 18 | bundled: ../../../target/wasm32-unknown-unknown/release/where_ludotheque_zome.wasm 19 | dependencies: 20 | - name: ludotheque_integrity 21 | -------------------------------------------------------------------------------- /dna/workdir/dna-where/dna.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | manifest_version: "1" 3 | name: dWhere 4 | integrity: 5 | origin_time: 2022-09-25T13:55:49.200Z 6 | zomes: 7 | - name: playset_integrity 8 | bundled: ../../../target/wasm32-unknown-unknown/release/where_playset_integrity_zome.wasm 9 | - name: where_integrity 10 | bundled: ../../../target/wasm32-unknown-unknown/release/where_integrity_zome.wasm 11 | - name: profiles_integrity 12 | bundled: ../../../target/wasm32-unknown-unknown/release/profiles_integrity_zome.wasm 13 | coordinator: 14 | zomes: 15 | - name: zPlayset 16 | bundled: ../../../target/wasm32-unknown-unknown/release/where_playset_zome.wasm 17 | dependencies: 18 | - name: playset_integrity 19 | - name: zWhere 20 | bundled: ../../../target/wasm32-unknown-unknown/release/where_zome.wasm 21 | dependencies: 22 | - name: where_integrity 23 | - name: profiles 24 | bundled: ../../../target/wasm32-unknown-unknown/release/profiles_zome.wasm 25 | dependencies: 26 | - name: profiles_integrity 27 | -------------------------------------------------------------------------------- /dna/workdir/happ-ludotheque/happ.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | manifest_version: "1" 3 | name: hLudotheque 4 | description: Ludotheque standalone happ 5 | roles: 6 | - name: rLudotheque 7 | provisioning: 8 | strategy: create 9 | deferred: true 10 | dna: 11 | bundled: "../../../artifacts/ludotheque.dna" 12 | clone_limit: 0 13 | -------------------------------------------------------------------------------- /dna/workdir/happ-where-standalone/happ.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | manifest_version: "1" 3 | name: where-standalone 4 | description: Standalone happ for Where for testing purpose 5 | roles: 6 | - name: rWhere 7 | provisioning: 8 | strategy: create 9 | deferred: true 10 | dna: 11 | bundled: "../../../artifacts/where.dna" 12 | clone_limit: 0 13 | -------------------------------------------------------------------------------- /dna/workdir/happ-where/happ.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | manifest_version: "1" 3 | name: hWhere 4 | description: Where happ (with Ludotheque clones) 5 | roles: 6 | - name: rLudotheque 7 | provisioning: 8 | strategy: create 9 | deferred: true 10 | dna: 11 | bundled: "../../../artifacts/ludotheque.dna" 12 | clone_limit: 10 13 | - name: rWhere 14 | provisioning: 15 | strategy: create 16 | deferred: true 17 | dna: 18 | bundled: "../../../artifacts/where.dna" 19 | clone_limit: 10 20 | -------------------------------------------------------------------------------- /dna/zomes/ludotheque/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "where_ludotheque_zome" 3 | version.workspace = true 4 | rust-version.workspace = true 5 | edition.workspace = true 6 | 7 | [lib] 8 | crate-type = ["cdylib", "rlib"] 9 | 10 | [dependencies] 11 | serde.workspace = true 12 | hdk.workspace = true 13 | zome_utils.workspace = true 14 | 15 | ludotheque_integrity = { package = "where_ludotheque_integrity_zome", path = "../ludotheque_integrity" } 16 | -------------------------------------------------------------------------------- /dna/zomes/ludotheque/src/export_playset.rs: -------------------------------------------------------------------------------- 1 | use hdk::prelude::*; 2 | use holo_hash::EntryHashB64; 3 | 4 | use zome_utils::*; 5 | use ludotheque_integrity::*; 6 | 7 | 8 | #[derive(Debug, Serialize, Deserialize)] 9 | #[serde(rename_all = "camelCase")] 10 | pub struct ExportPlaysetInput { 11 | pub destination_cell_id: CellId, 12 | pub playset_eh: EntryHashB64, 13 | } 14 | 15 | #[hdk_extern] 16 | fn export_playset(ExportPlaysetInput{playset_eh, destination_cell_id}: ExportPlaysetInput) -> ExternResult> { 17 | /* Get Playset */ 18 | let playset: Playset = get_typed_from_eh(playset_eh.into())?; 19 | /* Export each template */ 20 | for eh in playset.templates { 21 | let entry = get_entry_from_eh(eh.into())?; 22 | export_piece_inner("Template", entry, destination_cell_id.clone())?; 23 | } 24 | /* Export each svg marker */ 25 | for eh in playset.svg_markers { 26 | let entry = get_entry_from_eh(eh.into())?; 27 | export_piece_inner("SvgMarker", entry, destination_cell_id.clone())?; 28 | } 29 | /* Export each svg marker */ 30 | for eh in playset.emoji_groups { 31 | let entry = get_entry_from_eh(eh.into())?; 32 | export_piece_inner("EmojiGroup", entry, destination_cell_id.clone())?; 33 | } 34 | /* Export each space */ 35 | for spaceEh in playset.spaces.clone() { 36 | let space_entry = get_entry_from_eh(spaceEh.into())?; 37 | export_piece_inner("Space", space_entry, destination_cell_id.clone())?; 38 | } 39 | /* Done */ 40 | Ok(playset.spaces) 41 | } 42 | 43 | 44 | /// warning: duplicate struct in ludotheque zome 45 | #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] 46 | pub struct ImportPieceInput { 47 | pub piece_type_name: String, 48 | pub piece_entry: Entry, 49 | } 50 | 51 | /// 52 | fn export_piece_inner(entry_type_name: &str, piece_entry: Entry, cell_id: CellId) -> ExternResult<()> { 53 | debug!("export_piece_inner() called: {}", entry_type_name); 54 | let input = ImportPieceInput { 55 | piece_type_name: entry_type_name.to_string(), 56 | piece_entry 57 | }; 58 | let res = call( 59 | CallTargetCell::OtherCell(cell_id), 60 | "zPlayset", 61 | "import_piece".into(), 62 | None, 63 | input, 64 | )?; 65 | let _: () = decode_response(res)?; 66 | Ok(()) 67 | } 68 | -------------------------------------------------------------------------------- /dna/zomes/ludotheque/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_upper_case_globals)] 2 | #![allow(unused_doc_comments)] 3 | #![allow(non_camel_case_types)] 4 | #![allow(non_snake_case)] 5 | #![allow(unused_attributes)] 6 | 7 | mod playset; 8 | mod export_playset; 9 | 10 | 11 | -------------------------------------------------------------------------------- /dna/zomes/ludotheque/src/playset.rs: -------------------------------------------------------------------------------- 1 | use hdk::hash_path::path::TypedPath; 2 | use hdk::prelude::*; 3 | use holo_hash::EntryHashB64; 4 | use zome_utils::*; 5 | 6 | use ludotheque_integrity::*; 7 | 8 | #[derive(Clone, Serialize, Deserialize, Debug)] 9 | pub struct PlaysetOutput { 10 | hash: EntryHashB64, 11 | content: Playset, 12 | } 13 | 14 | 15 | /// 16 | fn get_playset_path() -> TypedPath { 17 | Path::from("playsets").typed(LudothequeLinkType::All).unwrap() 18 | } 19 | 20 | 21 | /// 22 | #[hdk_extern] 23 | fn create_playset(input: Playset) -> ExternResult { 24 | let _hh = create_entry(&LudothequeEntry::Playset(input.clone()))?; 25 | let eh = hash_entry(input.clone())?; 26 | let path = get_playset_path(); 27 | path.ensure()?; 28 | let anchor_eh = path.path_entry_hash()?; 29 | create_link(anchor_eh, eh.clone(), LudothequeLinkType::All, LinkTag::from(()))?; 30 | let eh64: EntryHashB64 = eh.clone().into(); 31 | // let me = agent_info()?.agent_latest_pubkey.into(); 32 | // emit_signal(&SignalPayload::new(None, me, eh64)?; 33 | Ok(eh64) 34 | } 35 | 36 | 37 | #[hdk_extern] 38 | fn get_playset(input: EntryHashB64) -> ExternResult> { 39 | let maybe_record = get(input, GetOptions::content())?; 40 | let Some(record) = maybe_record 41 | else {return Ok(None)}; 42 | let typed = get_typed_from_record::(record)?; 43 | Ok(Some(typed)) 44 | } 45 | 46 | 47 | #[hdk_extern] 48 | fn get_all_playsets(_: ()) -> ExternResult> { 49 | let path = get_playset_path(); 50 | let playsets = get_all_inner(path.path_entry_hash()?)?; 51 | Ok(playsets) 52 | } 53 | 54 | fn get_all_inner(base: EntryHash) -> ExternResult> { 55 | let entries = get_typed_from_links(base, LudothequeLinkType::All, None) 56 | .map_err(|err| wasm_error!(WasmErrorInner::Guest(err.to_string())))?; 57 | let mut playsets = vec![]; 58 | for pair in entries { 59 | playsets.push(PlaysetOutput {hash: hash_entry(&pair.0)?.into(), content: pair.0}); 60 | } 61 | Ok(playsets) 62 | } 63 | -------------------------------------------------------------------------------- /dna/zomes/ludotheque_integrity/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "where_ludotheque_integrity_zome" 3 | version.workspace = true 4 | rust-version.workspace = true 5 | edition.workspace = true 6 | 7 | [lib] 8 | crate-type = ["cdylib", "rlib"] 9 | 10 | 11 | [dependencies] 12 | serde.workspace = true 13 | hdi.workspace = true 14 | -------------------------------------------------------------------------------- /dna/zomes/ludotheque_integrity/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_upper_case_globals)] 2 | #![allow(unused_doc_comments)] 3 | #![allow(non_camel_case_types)] 4 | #![allow(non_snake_case)] 5 | #![allow(unused_attributes)] 6 | 7 | mod playset; 8 | pub use playset::*; 9 | 10 | 11 | ///------------------------------------------------------------------------------------------------- 12 | /// Declaration of this zome's entry types 13 | ///------------------------------------------------------------------------------------------------- 14 | 15 | use hdi::prelude::*; 16 | 17 | #[hdk_entry_defs] 18 | #[unit_enum(LudothequeEntryTypes)] 19 | pub enum LudothequeEntry { 20 | #[entry_def(required_validations = 2, visibility = "public")] 21 | Playset(Playset), 22 | } 23 | 24 | 25 | ///------------------------------------------------------------------------------------------------- 26 | /// Declaration of this zome's link types 27 | ///------------------------------------------------------------------------------------------------- 28 | 29 | /// List of all link kinds handled by this Zome 30 | #[hdk_link_types] 31 | #[derive(Serialize, Deserialize)] 32 | pub enum LudothequeLinkType { 33 | All, 34 | } 35 | 36 | -------------------------------------------------------------------------------- /dna/zomes/ludotheque_integrity/src/playset.rs: -------------------------------------------------------------------------------- 1 | use hdi::prelude::*; 2 | use holo_hash::EntryHashB64; 3 | 4 | /// Playset Entry 5 | #[hdk_entry_helper] 6 | #[derive(Clone)] 7 | #[serde(rename_all = "camelCase")] 8 | pub struct Playset { 9 | pub name: String, 10 | pub description: String, 11 | pub templates: Vec, 12 | pub svg_markers: Vec, 13 | pub emoji_groups: Vec, 14 | pub spaces: Vec, 15 | } 16 | -------------------------------------------------------------------------------- /dna/zomes/playset/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "where_playset_zome" 3 | version.workspace = true 4 | rust-version.workspace = true 5 | edition.workspace = true 6 | 7 | [lib] 8 | crate-type = ["cdylib", "rlib"] 9 | 10 | 11 | [dependencies] 12 | serde.workspace = true 13 | hdk.workspace = true 14 | zome_utils.workspace = true 15 | 16 | playset_integrity = { package = "where_playset_integrity_zome", path = "../playset_integrity" } 17 | -------------------------------------------------------------------------------- /dna/zomes/playset/src/export_piece.rs: -------------------------------------------------------------------------------- 1 | use hdk::prelude::*; 2 | use hdk::prelude::CellId; 3 | use holo_hash::EntryHashB64; 4 | 5 | use zome_utils::*; 6 | use crate::import_piece::ImportPieceInput; 7 | 8 | 9 | #[derive(Debug, Serialize, Deserialize)] 10 | #[serde(rename_all = "camelCase")] 11 | pub struct ExportPieceInput { 12 | pub cell_id: CellId, 13 | pub piece_eh: EntryHashB64, 14 | pub piece_type_name: String, // FIXME use UnitEntryTypes and AppEntryTypeName 15 | } 16 | 17 | #[hdk_extern] 18 | pub fn export_piece(input: ExportPieceInput) -> ExternResult<()> { 19 | if input.piece_type_name == "Space" { 20 | return zome_error!("space piece should be exported with 'export_space()' zome function"); 21 | } 22 | if input.piece_type_name != "Template" 23 | && input.piece_type_name != "SvgMarker" 24 | && input.piece_type_name != "EmojiGroup" { 25 | return zome_error!("unknown piece type: '{}'", input.piece_type_name); 26 | } 27 | let entry = get_entry_from_eh(input.piece_eh.into())?; 28 | export_entry(&input.piece_type_name, entry, input.cell_id.clone())?; 29 | Ok(()) 30 | } 31 | 32 | 33 | /// 34 | pub fn export_entry(entry_type_name: &str, entry: Entry, cell_id: CellId) -> ExternResult<()> { 35 | debug!("export_entry(): {} - {:?}", entry_type_name, cell_id); 36 | let input = ImportPieceInput { 37 | piece_type_name: entry_type_name.to_string(), 38 | piece_entry: entry, 39 | }; 40 | let res = call( 41 | CallTargetCell::OtherCell(cell_id), 42 | "zPlayset", 43 | "import_piece".into(), 44 | None, 45 | input, 46 | )?; 47 | let _: () = decode_response(res)?; 48 | Ok(()) 49 | } 50 | -------------------------------------------------------------------------------- /dna/zomes/playset/src/export_space.rs: -------------------------------------------------------------------------------- 1 | use hdk::prelude::*; 2 | use holo_hash::EntryHashB64; 3 | 4 | use zome_utils::*; 5 | use playset_integrity::*; 6 | 7 | use crate::export_piece::*; 8 | 9 | #[derive(Debug, Serialize, Deserialize)] 10 | #[serde(rename_all = "camelCase")] 11 | pub struct ExportSpaceInput { 12 | pub cell_id: CellId, 13 | pub space_eh: EntryHashB64, 14 | } 15 | 16 | 17 | #[derive(Debug, Serialize, Deserialize)] 18 | #[serde(rename_all = "camelCase")] 19 | pub struct ExportSpaceOutput { 20 | pub template: EntryHashB64, 21 | pub maybe_svg: Option, 22 | pub maybe_emoji_group: Option, 23 | } 24 | 25 | 26 | #[hdk_extern] 27 | fn export_space(ExportSpaceInput{cell_id, space_eh}: ExportSpaceInput) -> ExternResult { 28 | let space_eh: EntryHash = space_eh.into(); 29 | let space_entry = get_entry_from_eh(space_eh)?; 30 | let space = Space::try_from(space_entry.clone())?; 31 | /// Export template 32 | let piece_info = ExportPieceInput { 33 | piece_eh: space.origin.clone(), 34 | cell_id: cell_id.clone(), 35 | piece_type_name: "Template".to_string(), 36 | }; 37 | let mut output = ExportSpaceOutput{template: space.origin, maybe_svg: None, maybe_emoji_group: None}; 38 | export_piece(piece_info)?; 39 | /// Export marker 40 | if let Some(marker_piece) = space.maybe_marker_piece { 41 | let piece_info = ExportPieceInput { 42 | cell_id: cell_id.clone(), 43 | piece_eh: marker_piece.eh().to_owned().into(), 44 | piece_type_name: marker_piece.type_name().to_string(), 45 | }; 46 | export_piece(piece_info)?; 47 | /// Add to output 48 | match marker_piece { 49 | MarkerPiece::Svg(eh) => output.maybe_svg = Some(eh), 50 | MarkerPiece::EmojiGroup(eh) => output.maybe_emoji_group = Some(eh), 51 | } 52 | } 53 | /// Export space 54 | export_entry("Space", space_entry, cell_id.clone())?; 55 | /// Done 56 | Ok(output) 57 | } 58 | -------------------------------------------------------------------------------- /dna/zomes/playset/src/get_inventory.rs: -------------------------------------------------------------------------------- 1 | use hdk::prelude::*; 2 | use holo_hash::EntryHashB64; 3 | 4 | use playset_integrity::*; 5 | 6 | use crate::*; 7 | 8 | 9 | #[derive(Debug, Serialize, Deserialize)] 10 | #[serde(rename_all = "camelCase")] 11 | pub struct GetInventoryOutput { 12 | pub templates: Vec, 13 | pub svg_markers: Vec, 14 | pub emoji_groups: Vec, 15 | pub spaces: Vec, 16 | } 17 | 18 | #[hdk_extern] 19 | pub fn get_inventory(_: ()) -> ExternResult { 20 | /// Get templates 21 | let base = get_templates_path().path_entry_hash()?; 22 | let links = get_links(base, PlaysetLinkType::All, None)?; 23 | let templates = links.iter().map(|link| link.target.clone().into_entry_hash().unwrap().into()).collect(); 24 | /// Get svg_markers 25 | let base = get_svg_marker_path().path_entry_hash()?; 26 | let links = get_links(base, PlaysetLinkType::All, None)?; 27 | let svg_markers = links.iter().map(|link| link.target.clone().into_entry_hash().unwrap().into()).collect(); 28 | /// Get emoji_groups 29 | let base = get_emoji_group_path().path_entry_hash()?; 30 | let links = get_links(base, PlaysetLinkType::All, None)?; 31 | let emoji_groups = links.iter().map(|link| link.target.clone().into_entry_hash().unwrap().into()).collect(); 32 | /// Get spaces 33 | let base = get_spaces_path().path_entry_hash()?; 34 | let links = get_links(base, PlaysetLinkType::All, None)?; 35 | let spaces = links.iter().map(|link| link.target.clone().into_entry_hash().unwrap().into()).collect(); 36 | /// Done 37 | let inventory = GetInventoryOutput { 38 | spaces, 39 | svg_markers, 40 | emoji_groups, 41 | templates, 42 | }; 43 | Ok(inventory) 44 | } 45 | -------------------------------------------------------------------------------- /dna/zomes/playset/src/import_piece.rs: -------------------------------------------------------------------------------- 1 | use hdk::prelude::*; 2 | use zome_utils::*; 3 | use playset_integrity::*; 4 | use crate::*; 5 | 6 | 7 | #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] 8 | pub struct ImportPieceInput { 9 | pub piece_type_name: String, // FIXME use UnitEntryTypes and AppEntryTypeName 10 | pub piece_entry: Entry, 11 | } 12 | 13 | /// Zome Function Callback 14 | /// Should not be called directly. Only via remote call to self by ludotheque 15 | #[hdk_extern] 16 | fn import_piece(ImportPieceInput{piece_entry, piece_type_name}: ImportPieceInput) -> ExternResult<()> { 17 | debug!("import_piece() entry_def_id = {:?} | {}", piece_type_name, zome_info()?.name); 18 | /// Bail if we already have it 19 | let eh = hash_entry(piece_entry.clone())?; 20 | let maybe_entry = get_entry_from_eh(eh); 21 | if maybe_entry.is_ok() { 22 | return Ok(()); 23 | } 24 | /// Import depending on type 25 | match piece_type_name.as_str() { 26 | "Template" => { 27 | let template = Template::try_from(piece_entry)?; 28 | create_template(template)?; 29 | }, 30 | "Space" => { 31 | let space = Space::try_from(piece_entry)?; 32 | create_space(space)?; 33 | }, 34 | "SvgMarker" => { 35 | let e = SvgMarker::try_from(piece_entry)?; 36 | create_svg_marker(e)?; 37 | }, 38 | "EmojiGroup" => { 39 | let e = EmojiGroup::try_from(piece_entry)?; 40 | create_emoji_group(e)?; 41 | }, 42 | _ => return error(&format!("Unknown entry type: {}", piece_type_name)), 43 | }; 44 | /// Done 45 | Ok(()) 46 | } 47 | -------------------------------------------------------------------------------- /dna/zomes/playset/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_upper_case_globals)] 2 | #![allow(unused_doc_comments)] 3 | #![allow(non_camel_case_types)] 4 | #![allow(non_snake_case)] 5 | #![allow(unused_attributes)] 6 | 7 | mod pieces; 8 | mod import_piece; 9 | mod export_piece; 10 | mod export_space; 11 | mod get_inventory; 12 | 13 | pub use pieces::*; 14 | pub use export_piece::*; 15 | -------------------------------------------------------------------------------- /dna/zomes/playset/src/pieces/emoji_group.rs: -------------------------------------------------------------------------------- 1 | use hdk::prelude::*; 2 | use hdk::hash_path::path::TypedPath; 3 | use holo_hash::EntryHashB64; 4 | use zome_utils::*; 5 | use playset_integrity::*; 6 | 7 | #[derive(Clone, Serialize, Deserialize, Debug)] 8 | pub struct EmojiGroupOutput { 9 | hash: EntryHashB64, 10 | content: EmojiGroup, 11 | } 12 | 13 | 14 | /// 15 | pub fn get_emoji_group_path() -> TypedPath { 16 | Path::from("emoji-groups").typed(PlaysetLinkType::EmojiGroups).unwrap() 17 | } 18 | 19 | 20 | /// 21 | #[hdk_extern] 22 | pub fn create_emoji_group(input: EmojiGroup) -> ExternResult { 23 | let _hh = create_entry(&PlaysetEntry::EmojiGroup(input.clone()))?; 24 | let eh = hash_entry(input.clone())?; 25 | let path = get_emoji_group_path(); 26 | path.ensure()?; 27 | let anchor_eh = path.path_entry_hash()?; 28 | create_link(anchor_eh, eh.clone(), PlaysetLinkType::All, LinkTag::from(()))?; 29 | let eh64: EntryHashB64 = eh.clone().into(); 30 | // let me = agent_info()?.agent_latest_pubkey.into(); 31 | // emit_signal(&SignalPayload::new(None, me, Message::NewEmojiGroup((eh64.clone(), input))))?; 32 | Ok(eh64) 33 | } 34 | 35 | 36 | /// 37 | #[hdk_extern] 38 | fn get_emoji_group(input: EntryHashB64) -> ExternResult> { 39 | let maybe_record = get(input, GetOptions::content())?; 40 | let Some(record) = maybe_record 41 | else {return Ok(None)}; 42 | let typed = get_typed_from_record::(record)?; 43 | Ok(Some(typed)) 44 | } 45 | 46 | 47 | /// 48 | #[hdk_extern] 49 | fn get_all_emoji_groups(_: ()) -> ExternResult> { 50 | let path = get_emoji_group_path(); 51 | let groups = get_all_inner(path.path_entry_hash()?)?; 52 | Ok(groups) 53 | } 54 | 55 | fn get_all_inner(base: EntryHash) -> ExternResult> { 56 | let entries = get_typed_from_links(base, PlaysetLinkType::All, None) 57 | .map_err(|err| wasm_error!(WasmErrorInner::Guest(err.to_string())))?; 58 | let mut groups = vec![]; 59 | for pair in entries { 60 | groups.push(EmojiGroupOutput {hash: hash_entry(&pair.0)?.into(), content: pair.0}); 61 | } 62 | Ok(groups) 63 | } 64 | -------------------------------------------------------------------------------- /dna/zomes/playset/src/pieces/mod.rs: -------------------------------------------------------------------------------- 1 | mod template; 2 | mod emoji_group; 3 | mod svg_marker; 4 | mod space; 5 | 6 | pub use template::*; 7 | pub use emoji_group::*; 8 | pub use svg_marker::*; 9 | pub use space::*; 10 | -------------------------------------------------------------------------------- /dna/zomes/playset/src/pieces/space.rs: -------------------------------------------------------------------------------- 1 | use hdk::prelude::*; 2 | use hdk::hash_path::path::TypedPath; 3 | use zome_utils::*; 4 | use holo_hash::EntryHashB64; 5 | 6 | use playset_integrity::*; 7 | 8 | 9 | pub fn get_spaces_path() -> TypedPath { 10 | Path::from("spaces").typed(PlaysetLinkType::Spaces).unwrap() 11 | } 12 | 13 | 14 | /// 15 | #[hdk_extern] 16 | pub fn create_space(input: Space) -> ExternResult { 17 | debug!("create_space(): {:?}", input); 18 | let _hh = create_entry(PlaysetEntry::Space(input.clone()))?; 19 | let space_eh = hash_entry(input.clone())?; 20 | let path = get_spaces_path(); 21 | path.ensure()?; 22 | let anchor_eh = path.path_entry_hash()?; 23 | create_link(anchor_eh, space_eh.clone(), PlaysetLinkType::All, LinkTag::from(()))?; 24 | let eh64: EntryHashB64 = space_eh.clone().into(); 25 | // let me = agent_info()?.agent_latest_pubkey.into(); 26 | // emit_signal(&SignalPayload::new(None, me, Message::NewSpace(eh64.clone())))?; 27 | Ok(eh64) 28 | } 29 | 30 | 31 | /// 32 | #[hdk_extern] 33 | pub fn get_space(space_eh: EntryHashB64) -> ExternResult> { 34 | let maybe_record = get(space_eh, GetOptions::content())?; 35 | let Some(record) = maybe_record 36 | else {return Ok(None)}; 37 | let typed = get_typed_from_record::(record)?; 38 | Ok(Some(typed)) 39 | } 40 | 41 | 42 | /// 43 | #[derive(Clone, Serialize, Deserialize, Debug)] 44 | pub struct SpaceOutput { 45 | hash: EntryHashB64, 46 | content: Space, 47 | } 48 | 49 | /// 50 | #[hdk_extern] 51 | fn get_spaces(_: ()) -> ExternResult> { 52 | let path = get_spaces_path(); 53 | let anchor_eh = path.path_entry_hash()?; 54 | let spaces = get_spaces_inner(anchor_eh)?; 55 | Ok(spaces) 56 | } 57 | 58 | fn get_spaces_inner(base: EntryHash) -> ExternResult> { 59 | let entries = get_typed_from_links(base, PlaysetLinkType::All, None) 60 | .map_err(|err| wasm_error!(WasmErrorInner::Guest(err.to_string())))?; 61 | let mut spaces = vec![]; 62 | for pair in entries { 63 | spaces.push(SpaceOutput {hash: hash_entry(&pair.0)?.into(), content: pair.0}); 64 | } 65 | Ok(spaces) 66 | } 67 | 68 | -------------------------------------------------------------------------------- /dna/zomes/playset/src/pieces/svg_marker.rs: -------------------------------------------------------------------------------- 1 | use hdk::prelude::*; 2 | use hdk::hash_path::path::TypedPath; 3 | use zome_utils::*; 4 | use holo_hash::EntryHashB64; 5 | use playset_integrity::*; 6 | 7 | #[derive(Clone, Serialize, Deserialize, Debug)] 8 | pub struct SvgMarkerOutput { 9 | hash: EntryHashB64, 10 | content: SvgMarker, 11 | } 12 | 13 | pub fn get_svg_marker_path() -> TypedPath { 14 | Path::from("svg-marker").typed(PlaysetLinkType::SvgMarkers).unwrap() 15 | } 16 | 17 | #[hdk_extern] 18 | pub fn create_svg_marker(input: SvgMarker) -> ExternResult { 19 | let _hh = create_entry(PlaysetEntry::SvgMarker(input.clone()))?; 20 | let eh = hash_entry(input.clone())?; 21 | let path = get_svg_marker_path(); 22 | path.ensure()?; 23 | let anchor_eh = path.path_entry_hash()?; 24 | create_link(anchor_eh, eh.clone(), PlaysetLinkType::All, LinkTag::from(()))?; 25 | let eh64: EntryHashB64 = eh.clone().into(); 26 | // let me = agent_info()?.agent_latest_pubkey.into(); 27 | // emit_signal(&SignalPayload::new(None, me, Message::NewSvgMarker((eh64.clone(), input))))?; 28 | Ok(eh64) 29 | } 30 | 31 | #[hdk_extern] 32 | fn get_svg_marker(input: EntryHashB64) -> ExternResult> { 33 | let maybe_record = get(input, GetOptions::content())?; 34 | let Some(record) = maybe_record 35 | else {return Ok(None)}; 36 | let typed = get_typed_from_record::(record)?; 37 | Ok(Some(typed)) 38 | } 39 | 40 | #[hdk_extern] 41 | fn get_svg_markers(_: ()) -> ExternResult> { 42 | let path = get_svg_marker_path(); 43 | let templates = get_inner(path.path_entry_hash()?)?; 44 | Ok(templates) 45 | } 46 | 47 | fn get_inner(base: EntryHash) -> ExternResult> { 48 | let entries = get_typed_from_links(base, PlaysetLinkType::All, None) 49 | .map_err(|err| wasm_error!(WasmErrorInner::Guest(err.to_string())))?; 50 | let mut templates = vec![]; 51 | for pair in entries { 52 | templates.push(SvgMarkerOutput {hash: hash_entry(&pair.0)?.into(), content: pair.0}); 53 | } 54 | Ok(templates) 55 | } 56 | -------------------------------------------------------------------------------- /dna/zomes/playset/src/pieces/template.rs: -------------------------------------------------------------------------------- 1 | use hdk::prelude::*; 2 | use hdk::hash_path::path::TypedPath; 3 | use holo_hash::EntryHashB64; 4 | use zome_utils::*; 5 | use playset_integrity::*; 6 | 7 | 8 | #[derive(Clone, Serialize, Deserialize, Debug)] 9 | pub struct TemplateOutput { 10 | hash: EntryHashB64, 11 | content: Template, 12 | } 13 | 14 | 15 | /// 16 | pub fn get_templates_path() -> TypedPath { 17 | Path::from("templates").typed(PlaysetLinkType::Templates).unwrap() 18 | } 19 | 20 | 21 | /// 22 | #[hdk_extern] 23 | pub fn create_template(input: Template) -> ExternResult { 24 | let _hh = create_entry(PlaysetEntry::Template(input.clone()))?; 25 | let eh = hash_entry(input.clone())?; 26 | let path = get_templates_path(); 27 | path.ensure()?; 28 | let anchor_eh = path.path_entry_hash()?; 29 | create_link(anchor_eh, eh.clone(), PlaysetLinkType::All, LinkTag::from(()))?; 30 | let eh64: EntryHashB64 = eh.clone().into(); 31 | // let me = agent_info()?.agent_latest_pubkey.into(); 32 | // emit_signal(&SignalPayload::new(None, me, Message::NewTemplate((eh64.clone(), input))))?; 33 | Ok(eh64) 34 | } 35 | 36 | #[hdk_extern] 37 | fn get_template(input: EntryHashB64) -> ExternResult> { 38 | let maybe_record = get(input, GetOptions::content())?; 39 | let Some(record) = maybe_record 40 | else {return Ok(None)}; 41 | let typed = get_typed_from_record::