Skip to content

Commit

Permalink
Fix WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed Oct 12, 2023
1 parent 20a85ed commit 9202a70
Show file tree
Hide file tree
Showing 22 changed files with 46 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/** {{title_case collection_name}} */

async get{{pascal_case collection_name}}({{#if (eq collection_type.type "ByAuthor")}}author: AgentPubKey{{else}}{{/if}}): Promise<Array<EntryRecord<{{pascal_case referenceable.name}}>>> {
const records: Record[] = await this.callZome('get_{{snake_case collection_name}}', {{#if (eq collection_type.type "ByAuthor")}}author{{else}}null{{/if}});
const records: Record[] = await this.callZome('get_{{snake_case collection_name}}', {{#if (eq collection_type.type "ByAuthor")}}author{{else}}undefined{{/if}});
return records.map(r => new EntryRecord(r));
}

Expand Down
6 changes: 3 additions & 3 deletions .templates/app/entry-type.instructions.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ You have scaffolded an entry type with an image field.

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

npm i -w ui @holochain-open-dev/file-storage@0.3.0
npm i -w ui @holochain-open-dev/file-storage
hc-scaffold zome file_storage --coordinator dnas/{{../dna_role_name}}/zomes/coordinator --integrity dnas/{{../dna_role_name}}/zomes/integrity
cargo add -p file_storage hc_zome_file_storage_coordinator@0.1
cargo add -p file_storage hc_zome_file_storage_coordinator
echo "extern crate hc_zome_file_storage_coordinator;" > dnas/{{../dna_role_name}}/zomes/coordinator/file_storage/src/lib.rs
cargo add -p file_storage_integrity hc_zome_file_storage_integrity@0.1
cargo add -p file_storage_integrity hc_zome_file_storage_integrity
echo "extern crate hc_zome_file_storage_integrity;" > dnas/{{../dna_role_name}}/zomes/integrity/file_storage/src/lib.rs

{{/if}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function sample{{pascal_case entry_type.name}}(client: {{pascal_cas
{{/if}}
{{else}}
{{#if (eq (pascal_case linked_from.name) (pascal_case ../entry_type.name))}}
{{field_name}}: null,
{{field_name}}: undefined,
{{else}}
{{#if (eq linked_from.hash_type "ActionHash")}}
{{field_name}}: partial{{pascal_case ../entry_type.name}}.{{field_name}} || (await create{{pascal_case linked_from.name}}(client)).actionHash,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export async function sample{{pascal_case entry_type.name}}(client: {{pascal_cas
{{/if}}
{{else}}
{{#if (eq (pascal_case linked_from.name) (pascal_case ../entry_type.name))}}
{{field_name}}: null,
{{field_name}}: undefined,
{{else}}
{{#if (eq linked_from.hash_type "ActionHash")}}
{{field_name}}: partial{{pascal_case ../entry_type.name}}.{{field_name}} || (await client.create{{pascal_case linked_from.name}}(await sample{{pascal_case linked_from.name}}(client))).actionHash,
Expand Down
1 change: 1 addition & 0 deletions .templates/app/field-types/ActionHash/sample-js.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fakeActionHash()
1 change: 1 addition & 0 deletions .templates/app/field-types/AgentPubKey/sample-js.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(await fakeAgentPubKey())
1 change: 1 addition & 0 deletions .templates/app/field-types/DnaHash/sample-js.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(await fakeDnaHash())
1 change: 1 addition & 0 deletions .templates/app/field-types/EntryHash/sample-js.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fakeEntryHash()
1 change: 1 addition & 0 deletions .templates/app/field-types/Enum/sample-js.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ type: '{{lookup field_type.variants 0}}' }
1 change: 1 addition & 0 deletions .templates/app/field-types/String/sample-js.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"Lorem ipsum 2"
1 change: 1 addition & 0 deletions .templates/app/field-types/Timestamp/sample-js.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Date.now() * 1000
1 change: 1 addition & 0 deletions .templates/app/field-types/bool/sample-js.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
true
1 change: 1 addition & 0 deletions .templates/app/field-types/f32/sample-js.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.5
1 change: 1 addition & 0 deletions .templates/app/field-types/i32/sample-js.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3
1 change: 1 addition & 0 deletions .templates/app/field-types/u32/sample-js.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3
18 changes: 15 additions & 3 deletions .templates/app/web-app.instructions.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,22 @@ In order to be able to revert any next scaffolding steps, it is also recommended
git add .
git commit -m "web-app skeleton scaffolded"

To continue scaffolding your module, add new entry types:
To continue scaffolding your app, add a new dna:

hc scaffold entry-type
hc scaffold dna

Then, at any point in time you can start the demo with:
And then adding a zome to that dna:

hc scaffold zome

After that, at any point in time you can start the demo with:

npm start

You can run the tests with:

npm test

And you can build the .webhapp production package with:

npm package
2 changes: 1 addition & 1 deletion .templates/app/web-app/ui/src/holochain-app.ts.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class HolochainApp extends LitElement {
_myProfile!: StoreSubscriber<AsyncStatus<Profile | undefined>>;

async firstUpdated() {
this._client = await AppAgentWebsocket.connect('', '{{app_name}}');
this._client = await AppAgentWebsocket.connect(new URL('ws://localhost'), '{{app_name}}');

await this.initStores(this._client);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/** {{title_case collection_name}} */

async get{{pascal_case collection_name}}({{#if (eq collection_type.type "ByAuthor")}}author: AgentPubKey{{else}}{{/if}}): Promise<Array<EntryRecord<{{pascal_case referenceable.name}}>>> {
const records: Record[] = await this.callZome('get_{{snake_case collection_name}}', {{#if (eq collection_type.type "ByAuthor")}}author{{else}}null{{/if}});
const records: Record[] = await this.callZome('get_{{snake_case collection_name}}', {{#if (eq collection_type.type "ByAuthor")}}author{{else}}undefined{{/if}});
return records.map(r => new EntryRecord(r));
}

Expand Down
1 change: 1 addition & 0 deletions .templates/module/field-types/Timestamp/sample-js.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Date.now() * 1000
10 changes: 9 additions & 1 deletion .templates/module/web-app.instructions.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ To continue scaffolding your module, add new entry types:

hc scaffold entry-type

Then, at any point in time you can start the demo with:
After that, at any point in time you can start the demo with:

npm start

You can run the tests with:

npm test

And you can build the .webhapp production package with:

npm package
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { {{pascal_case app_name}}Store, {{pascal_case app_name}}Client } from "@
import { AppAgentWebsocket } from "@holochain/client";

async function setup{{pascal_case app_name}}Store() {
const client = await AppAgentWebsocket.connect('', '')
const client = await AppAgentWebsocket.connect(new URL('ws://localhost'), '')

// TODO: change "MY_CELL_ROLE" for the roleId that you can find in your "happ.yaml"
return new {{pascal_case app_name}}Store(new {{pascal_case app_name}}Client(client, '<MY_CELL_ROLE>'));
Expand Down
2 changes: 1 addition & 1 deletion .templates/module/web-app/ui/demo/index.html.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class DemoApp extends LitElement {
}
async firstUpdated() {
this._client = await AppAgentWebsocket.connect('', '{{app_name}}');
this._client = await AppAgentWebsocket.connect(new URL('ws://localhost'), '{{app_name}}');
await this.initStores(this._client);
Expand Down

0 comments on commit 9202a70

Please sign in to comment.