Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed Apr 10, 2024
1 parent 8596fb9 commit 31925fd
Show file tree
Hide file tree
Showing 34 changed files with 684 additions and 244 deletions.
42 changes: 21 additions & 21 deletions flake.lock

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

6 changes: 2 additions & 4 deletions run_test_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ hc-scaffold link-type agent:creator post --delete false --bidirectional false

git add .

hc-scaffold zome profiles --integrity dnas/forum/zomes/integrity/ --coordinator dnas/forum/zomes/coordinator/
rm -rf dnas/forum/zomes/coordinator/profiles
rm -rf dnas/forum/zomes/integrity/profiles
head -n -5 Cargo.toml > Cargo.tmp && mv Cargo.tmp Cargo.toml
nix run github:holochain-open-dev/profiles/nixify#scaffold --refresh -- --local-dna-to-add-the-zome-to forum --local-npm-package-to-add-the-ui-to ui
sed -i 's/TODO:REPLACE_ME_WITH_THE_DNA_WITH_THE_PROFILES_ZOME/forum/g' ui/src/holochain-app.ts

pnpm i

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
#![allow(unused_variables)]
#![allow(unused_imports)]

use std::time::Duration;

use hdk::prelude::*;
use holochain::test_utils::consistency_10s;
use holochain::{conductor::config::ConductorConfig, sweettest::*};

mod common;
Expand Down Expand Up @@ -31,9 +32,11 @@ async fn create_a_{{snake_case referenceable.name}}_and_get_{{snake_case collect

// Alice creates a {{pascal_case referenceable.name}}
let record: Record = create_{{snake_case referenceable.name}}(&conductors[0], &alice_zome, sample.clone()).await;

consistency_10s([&alice, &bobbo]).await;


await_consistency(Duration::from_secs(30), [&alice, &bobbo])
.await
.expect("Timed out waiting for consistency");

let links: Vec<Link> = conductors[1]
.call(&bob_zome, "get_{{snake_case collection_name}}", {{#if (eq collection_type.type "Global")}}(){{else}}alice_zome.cell_id().agent_pubkey().clone(){{/if}})
.await;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{#merge previous_file_content}}
{{#match_scope "zomes = {"}}
{{previous_scope_content}}
{{zome_manifest.name}} = self'.packages.{{zome_manifest.name}};
{{zome_manifest.name}} = self'.packages.{{zome_manifest.name}};
{{/match_scope}}
{{/merge}}
36 changes: 1 addition & 35 deletions templates/app/coordinator-zome/ui/src/holochain-app.ts.hbs
Original file line number Diff line number Diff line change
@@ -1,41 +1,9 @@
{{#if (eq (pascal_case zome_manifest.name) "Profiles")}}

{{#merge previous_file_content}}
{{#match_scope "export class HolochainApp extends LitElement {"}}
{{#merge previous_scope_content}}
{{#match_scope "async initStores(appAgentClient: AppAgentClient) {"}}
{{previous_scope_content}}
this._profilesStore = new ProfilesStore(new ProfilesClient(appAgentClient, '{{dna_role_name}}'));
{{/match_scope}}
{{/merge}}
{{/match_scope}}
{{/merge}}

{{else}}
{{#if (eq (pascal_case zome_manifest.name) "FileStorage")}}
import { fileStorageClientContext, FileStorageClient } from '@holochain-open-dev/file-storage';

{{#merge previous_file_content}}
{{#match_scope "export class HolochainApp extends LitElement {"}}
@provide({ context: fileStorageClientContext })
@property()
_fileStorageClient!: FileStorageClient;

{{#merge previous_scope_content}}
{{#match_scope "async initStores(appAgentClient: AppAgentClient) {"}}
{{previous_scope_content}}
this._fileStorageClient = new FileStorageClient(appAgentClient, '{{dna_role_name}}');
{{/match_scope}}
{{/merge}}
{{/match_scope}}
{{/merge}}
{{else}}
import { {{camel_case zome_manifest.name}}StoreContext } from './{{dna_role_name}}/{{kebab_case zome_manifest.name}}/context.js';
import { {{pascal_case zome_manifest.name}}Client } from './{{dna_role_name}}/{{kebab_case zome_manifest.name}}/{{kebab_case zome_manifest.name}}-client.js';
import { {{pascal_case zome_manifest.name}}Store } from './{{dna_role_name}}/{{kebab_case zome_manifest.name}}/{{kebab_case zome_manifest.name}}-store.js';

{{#merge previous_file_content}}
{{#match_scope "export class HolochainApp extends LitElement {"}}
{{#match_scope "export class {{pascal_case app_name}}App extends LitElement {"}}
@provide({ context: {{camel_case zome_manifest.name}}StoreContext })
@property()
_{{camel_case zome_manifest.name}}Store!: {{pascal_case zome_manifest.name}}Store;
Expand All @@ -48,5 +16,3 @@ import { {{pascal_case zome_manifest.name}}Store } from './{{dna_role_name}}/{{k
{{/merge}}
{{/match_scope}}
{{/merge}}
{{/if}}
{{/if}}
10 changes: 5 additions & 5 deletions templates/app/dna.instructions.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ If you want the UI to work, you must include the profiles zome in one of your DN

Do you want the profiles zome to be installed in the DNA you just scaffolded?

If you do, scaffold the profiles zome in this DNA by running these commands:
If you do, scaffold the profiles zome in this DNA by running this command:

hc-scaffold zome profiles --coordinator dnas/{{dna_name}}/zomes/coordinator --integrity dnas/{{dna_name}}/zomes/integrity
rm -rf dnas/{{dna_name}}/zomes/coordinator/profiles
rm -rf dnas/{{dna_name}}/zomes/integrity/profiles
head -n -5 Cargo.toml > Cargo.tmp && mv Cargo.tmp Cargo.toml
nix run github:holochain-open-dev/profiles/nixify#scaffold
sed -i 's/TODO:REPLACE_ME_WITH_THE_DNA_WITH_THE_PROFILES_ZOME/{{dna_name}}/g' ui/src/holochain-app.ts

Note that the UI for this app won't work until the profiles zome is scaffolded.
10 changes: 3 additions & 7 deletions templates/app/entry-type.instructions.hbs
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
{{#each entry_type.fields}}
{{#if (and widget (eq widget "Image"))}}
You have scaffolded an entry type with an image field.
You have scaffolded an entry type with an image field. The image must be stored in the "file-storage" zome, that you can find at https://github.com/holochain-open-dev/file-storage. You must include this zome at least once in your app to enable "Image" as a field type.

Scaffold the file-storage zome in one of your DNAs by running these commands, if you haven't already:
If you haven't already, scaffold the file-storage zome in one of your DNAs by running these commands:

pnpm add -F ui github:holochain-open-dev/file-storage#main&path:ui
hc-scaffold zome file_storage --coordinator dnas/{{../dna_role_name}}/zomes/coordinator --integrity dnas/{{../dna_role_name}}/zomes/integrity
rm -rf dnas/{{../dna_role_name}}/zomes/coordinator/file-storage
rm -rf dnas/{{../dna_role_name}}/zomes/integrity/file-storage
head -n -5 Cargo.toml > Cargo.tmp && mv Cargo.tmp Cargo.toml
nix run github:holochain-open-dev/file-storage/nixify#scaffold
{{/if}}
{{/each}}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
#![allow(unused_variables)]
#![allow(unused_imports)]

use std::time::Duration;

use hdk::prelude::*;
use holochain::test_utils::consistency_10s;
use holochain::{conductor::config::ConductorConfig, sweettest::*};

use {{snake_case coordinator_zome_manifest.name}}_integrity::*;
Expand Down Expand Up @@ -74,7 +75,9 @@ async fn create_and_read_{{snake_case entry_type.name}}() {
// Alice creates a {{pascal_case entry_type.name}}
let record: Record = create_{{snake_case entry_type.name}}(&conductors[0], &alice_zome, sample.clone()).await;

consistency_10s([&alice, &bobbo]).await;
await_consistency(Duration::from_secs(30), [&alice, &bobbo])
.await
.expect("Timed out waiting for consistency");

{{#if crud.update}}
let get_record: Option<Record> = conductors[1]
Expand Down Expand Up @@ -114,7 +117,9 @@ async fn create_and_update_{{snake_case entry_type.name}}() {
let record: Record = create_{{snake_case entry_type.name}}(&conductors[0], &alice_zome, sample_1.clone()).await;
let original_action_hash = record.signed_action.hashed.hash.clone();

consistency_10s([&alice, &bobbo]).await;
await_consistency(Duration::from_secs(30), [&alice, &bobbo])
.await
.expect("Timed out waiting for consistency");

let sample_2 = sample_{{snake_case entry_type.name}}_2(&conductors[0], &alice_zome).await;
let input = Update{{pascal_case entry_type.name}}Input {
Expand All @@ -133,7 +138,9 @@ async fn create_and_update_{{snake_case entry_type.name}}() {
let entry: {{pascal_case entry_type.name}} = update_record.entry().to_app_option().unwrap().unwrap();
assert_eq!(sample_2, entry);

consistency_10s([&alice, &bobbo]).await;
await_consistency(Duration::from_secs(30), [&alice, &bobbo])
.await
.expect("Timed out waiting for consistency");

let get_record: Option<Record> = conductors[1]
.call(&bob_zome, "get_latest_{{snake_case entry_type.name}}", original_action_hash.clone())
Expand All @@ -157,7 +164,9 @@ async fn create_and_update_{{snake_case entry_type.name}}() {
let entry: {{pascal_case entry_type.name}} = update_record.entry().to_app_option().unwrap().unwrap();
assert_eq!(sample_1, entry);

consistency_10s([&alice, &bobbo]).await;
await_consistency(Duration::from_secs(30), [&alice, &bobbo])
.await
.expect("Timed out waiting for consistency");

let get_record: Option<Record> = conductors[1]
.call(&bob_zome, "get_latest_{{snake_case entry_type.name}}", original_action_hash.clone())
Expand Down Expand Up @@ -197,7 +206,9 @@ async fn create_and_delete_{{snake_case entry_type.name}}() {
.call(&alice_zome, "delete_{{snake_case entry_type.name}}", original_action_hash.clone())
.await;

consistency_10s([&alice, &bobbo]).await;
await_consistency(Duration::from_secs(30), [&alice, &bobbo])
.await
.expect("Timed out waiting for consistency");

let deletes: Vec<SignedActionHashed> = conductors[1]
.call(&bob_zome, "get_all_deletes_for_{{snake_case entry_type.name}}", original_action_hash.clone())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{#merge previous_file_content}}
{{#match_scope "zomes = {"}}
{{previous_scope_content}}
{{zome_manifest.name}} = self'.packages.{{zome_manifest.name}};
{{/match_scope}}
{{/merge}}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#![allow(unused_variables)]
#![allow(unused_imports)]

use std::time::Duration;
use hdk::prelude::*;
use holochain::test_utils::consistency_10s;
use holochain::{conductor::config::ConductorConfig, sweettest::*};

use {{snake_case coordinator_zome_manifest.name}}::{{snake_case link_type_name}}::{{#if delete}}{Remove{{pascal_case to_referenceable.name}}For{{pascal_case from_referenceable.name}}Input, Add{{pascal_case to_referenceable.name}}For{{pascal_case from_referenceable.name}}Input }{{else}}Add{{pascal_case to_referenceable.name}}For{{pascal_case from_referenceable.name}}Input{{/if}};
Expand Down Expand Up @@ -70,7 +70,9 @@ async fn link_a_{{snake_case from_referenceable.name}}_to_a_{{snake_case to_refe
target_{{snake_case to_referenceable.singular_arg}}: target_address.clone()
}).await;

consistency_10s([&alice, &bobbo]).await;
await_consistency(Duration::from_secs(30), [&alice, &bobbo])
.await
.expect("Timed out waiting for consistency");

// Bob gets the links again
let links_output: Vec<Link> = conductors[1]
Expand Down Expand Up @@ -98,7 +100,9 @@ async fn link_a_{{snake_case from_referenceable.name}}_to_a_{{snake_case to_refe
target_{{snake_case to_referenceable.singular_arg}}: target_address.clone()
}).await;

consistency_10s([&alice, &bobbo]).await;
await_consistency(Duration::from_secs(30), [&alice, &bobbo])
.await
.expect("Timed out waiting for consistency");

// Bob gets the links again
let links_output: Vec<Link> = conductors[1]
Expand Down
61 changes: 0 additions & 61 deletions templates/app/web-app/.github/actions/extend-space/action.yaml.hbs

This file was deleted.

Loading

0 comments on commit 31925fd

Please sign in to comment.