Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Bump client-js and update usage #419

Merged
merged 3 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pub const TRYORAMA_VERSION: &str = "^0.18.0-dev.1";

/// npm: <https://www.npmjs.com/package/@holochain/client>
pub const HOLOCHAIN_CLIENT_VERSION: &str = "^0.19.0-dev.3";
pub const HOLOCHAIN_CLIENT_VERSION: &str = "^0.19.0-dev.5";

/// npm: <https://www.npmjs.com/package/@holochain/hc-spin>
pub const HC_SPIN_VERSION: &str = "^0.400.0-dev.3";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test('create a {{pascal_case referenceable.name}} and get {{lower_case collectio
// This assumes app bundle created by the `hc app pack` command.
const testAppPath = process.cwd() + '/../workdir/{{app_name}}.happ';

// Set up the app to be installed
// Set up the app to be installed
const appSource = { appBundleSource: { path: testAppPath } };

// Add 2 players with the test app to the Scenario. The returned players
Expand All @@ -36,16 +36,16 @@ test('create a {{pascal_case referenceable.name}} and get {{lower_case collectio
let collectionOutput: Link[] = await bob.cells[0].callZome({
zome_name: "{{coordinator_zome_manifest.name}}",
fn_name: "get_{{snake_case collection_name}}",
payload: {{#if (eq collection_type.type "Global")}}null{{else}}alice.agentPubKey{{/if}}
{{#if (eq collection_type.type "ByAuthor")}}payload: alice.agentPubKey,{{/if}}
});
assert.equal(collectionOutput.length, 0);

// Alice creates a {{pascal_case referenceable.name}}
const createRecord: Record = await create{{pascal_case referenceable.name}}(alice.cells[0]);
assert.ok(createRecord);

await dhtSync([alice, bob], alice.cells[0].cell_id[0]);

// Bob gets {{lower_case collection_name}} again
collectionOutput = await bob.cells[0].callZome({
zome_name: "{{coordinator_zome_manifest.name}}",
Expand Down Expand Up @@ -74,4 +74,4 @@ test('create a {{pascal_case referenceable.name}} and get {{lower_case collectio
assert.equal(collectionOutput.length, 0);
{{/if}}
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ export class {{pascal_case collection_name}} extends LitElement {
signaledHashes: Array<{{referenceable.hash_type}}> = [];

_fetch{{pascal_case (plural referenceable.name)}} = new Task(this, ([{{#if (eq collection_type.type "ByAuthor")}}author{{/if}}]: any) => this.client.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{coordinator_zome_manifest.name}}',
fn_name: 'get_{{snake_case collection_name}}',
payload: {{#if (eq collection_type.type "ByAuthor")}}author{{else}}null{{/if}},
{{#if (eq collection_type.type "ByAuthor")}}payload: this.author,{{/if}}
}) as Promise<Array<Link>>, () => [{{#if (eq collection_type.type "ByAuthor")}}this.author{{/if}}]);

firstUpdated() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ export class Create{{pascal_case entry_type.name}} extends LitElement {

try {
const record: Record = await this.client.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{coordinator_zome_manifest.name}}',
fn_name: 'create_{{snake_case entry_type.name}}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export class {{pascal_case (plural ../entry_type.name)}}For{{pascal_case linked_
hashes: Array<ActionHash> = [];

_fetch{{pascal_case (plural ../entry_type.name)}} = new Task(this, ([{{camel_case linked_from.singular_arg}}]: Array<{{linked_from.hash_type}}>) => this.client.callZome({
cap_secret: null,
role_name: '{{../dna_role_name}}',
zome_name: '{{../coordinator_zome_manifest.name}}',
fn_name: 'get_{{snake_case (plural ../entry_type.name)}}_for_{{snake_case linked_from.name}}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ export class Edit{{pascal_case entry_type.name}} extends LitElement {

try {
const updateRecord: Record = await this.client.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{coordinator_zome_manifest.name}}',
fn_name: 'update_{{snake_case entry_type.name}}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export class {{pascal_case entry_type.name}}Detail extends LitElement {
{{camel_case entry_type.name}}Hash!: {{#if entry_type.reference_entry_hash}}EntryHash{{else}}ActionHash{{/if}};

_fetchRecord = new Task(this, ([{{camel_case entry_type.name}}Hash]: Array<{{#if entry_type.reference_entry_hash}}EntryHash{{else}}ActionHash{{/if}}>) => this.client.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{coordinator_zome_manifest.name}}',
fn_name: '{{#if crud.update}}get_latest_{{snake_case entry_type.name}}{{else}}get_{{snake_case entry_type.name}}{{/if}}',
Expand All @@ -53,7 +52,6 @@ export class {{pascal_case entry_type.name}}Detail extends LitElement {
async delete{{pascal_case entry_type.name}}() {
try {
await this.client.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{coordinator_zome_manifest.name}}',
fn_name: 'delete_{{snake_case entry_type.name}}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export class {{pascal_case (plural from_referenceable.name)}}For{{pascal_case to
{{camel_case to_referenceable.singular_arg}}!: {{to_referenceable.hash_type}};

_fetch{{pascal_case (plural from_referenceable.name)}} = new Task(this, ([{{camel_case to_referenceable.singular_arg}}]: Array<{{to_referenceable.hash_type}}>) => this.client.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{coordinator_zome_manifest.name}}',
fn_name: 'get_{{snake_case (plural from_referenceable.name)}}_for_{{snake_case to_referenceable.name}}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export class {{pascal_case (plural to_referenceable.name)}}For{{pascal_case from
signaledHashes: Array<{{to_referenceable.hash_type}}> = [];

_fetch{{pascal_case (plural to_referenceable.name)}} = new Task(this, ([{{camel_case from_referenceable.singular_arg}}]: Array<{{from_referenceable.hash_type}}>) => this.client.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{coordinator_zome_manifest.name}}',
fn_name: 'get_{{snake_case (plural to_referenceable.name)}}_for_{{snake_case from_referenceable.name}}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ const {{pascal_case collection_name}}: FC{{#if (eq collection_type.type "ByAutho
setLoading(true)
try {
const links: Link[] = await client?.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{snake_case coordinator_zome_manifest.name}}',
fn_name: 'get_{{snake_case collection_name}}',
payload: {{#if (eq collection_type.type "ByAuthor")}}author{{else}}null{{/if}},
{{#if (eq collection_type.type "ByAuthor")}}payload: author,{{/if}}
});
if (links?.length) {
setHashes(links.map((l) => l.target));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@ const Create{{pascal_case entry_type.name}}: FC<Create{{pascal_case entry_type.n
const [is{{pascal_case entry_type.name}}Valid, setIs{{pascal_case entry_type.name}}Valid] = useState(false);

const create{{pascal_case entry_type.name}} = async () => {
const {{camel_case entry_type.name}}Entry: {{pascal_case entry_type.name}} = {
const {{camel_case entry_type.name}}Entry: {{pascal_case entry_type.name}} = {
{{#each entry_type.fields}}
{{snake_case field_name}}: {{camel_case field_name}}{{#if (eq cardinality "single")}}!{{/if}},
{{/each}}
};
try {
const record = await client?.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{coordinator_zome_manifest.name}}',
fn_name: 'create_{{snake_case entry_type.name}}',
Expand Down Expand Up @@ -84,4 +83,4 @@ interface Create{{pascal_case entry_type.name}}Props {
{{/each}}
}

export default Create{{pascal_case entry_type.name}};
export default Create{{pascal_case entry_type.name}};
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const {{pascal_case (plural ../entry_type.name)}}For{{pascal_case linked_from.na
setLoading(true)
try {
const links: Link[] = await client?.callZome({
cap_secret: null,
role_name: '{{../dna_role_name}}',
zome_name: '{{../coordinator_zome_manifest.name}}',
fn_name: 'get_{{snake_case (plural ../entry_type.name)}}_for_{{snake_case linked_from.name}}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ const Edit{{pascal_case entry_type.name}}: FC<Edit{{pascal_case entry_type.name}
};
try {
const updateRecord = await client?.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{coordinator_zome_manifest.name}}',
fn_name: 'update_{{snake_case entry_type.name}}',
Expand Down Expand Up @@ -135,4 +134,4 @@ interface Edit{{pascal_case entry_type.name}}Props {
on{{pascal_case entry_type.name}}UpdateError?: (error: HolochainError) => void,
}

export default Edit{{pascal_case entry_type.name}};
export default Edit{{pascal_case entry_type.name}};
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const {{pascal_case entry_type.name}}Detail: FC<{{pascal_case entry_type.name}}D
setRecord(undefined);
try {
const result = await client?.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{coordinator_zome_manifest.name}}',
fn_name: '{{#if crud.update}}get_latest_{{snake_case entry_type.name}}{{else}}get_{{snake_case entry_type.name}}{{/if}}',
Expand All @@ -50,7 +49,6 @@ const {{pascal_case entry_type.name}}Detail: FC<{{pascal_case entry_type.name}}D
setLoading(true)
try {
await client?.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{coordinator_zome_manifest.name}}',
fn_name: 'delete_{{snake_case entry_type.name}}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const {{pascal_case (plural from_referenceable.name)}}For{{pascal_case to_refere
setLoading(true)
try {
const links: Link[] = await client?.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{snake_case coordinator_zome_manifest.name}}',
fn_name: 'get_{{snake_case (plural from_referenceable.name)}}_for_{{snake_case to_referenceable.name}}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const {{pascal_case (plural to_referenceable.name)}}For{{pascal_case from_refere
setLoading(true)
try {
const links: Link[] = await client?.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{coordinator_zome_manifest.name}}',
fn_name: 'get_{{snake_case (plural to_referenceable.name)}}_for_{{snake_case from_referenceable.name}}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@ async function fetch{{pascal_case (plural referenceable.name)}}() {
loading = true;
try {
const links: Array<Link> = await client.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{snake_case coordinator_zome_manifest.name}}',
fn_name: 'get_{{snake_case collection_name}}',
payload: {{#if (eq collection_type.type "ByAuthor")}}author{{else}}null{{/if}},
{{#if (eq collection_type.type "ByAuthor")}}payload: author,{{/if}}
});
if (links.length) {
hashes = links.map(l => l.target);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ async function create{{pascal_case entry_type.name}}() {

try {
const record: Record = await client.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{coordinator_zome_manifest.name}}',
fn_name: 'create_{{snake_case entry_type.name}}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ async function fetch{{pascal_case (plural ../entry_type.name)}}() {
loading = true;
try {
const links: Array<Link> = await client.callZome({
cap_secret: null,
role_name: '{{../dna_role_name}}',
zome_name: '{{../coordinator_zome_manifest.name}}',
fn_name: 'get_{{snake_case (plural ../entry_type.name)}}_for_{{snake_case linked_from.name}}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ async function update{{pascal_case entry_type.name}}() {

try {
const updateRecord: Record = await client.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{coordinator_zome_manifest.name}}',
fn_name: 'update_{{snake_case entry_type.name}}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ async function fetch{{pascal_case entry_type.name}}() {
loading = true;
try {
record = await client.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{coordinator_zome_manifest.name}}',
fn_name: '{{#if crud.update}}get_latest_{{snake_case entry_type.name}}{{else}}get_{{snake_case entry_type.name}}{{/if}}',
Expand All @@ -62,7 +61,6 @@ async function fetch{{pascal_case entry_type.name}}() {
async function delete{{pascal_case entry_type.name}}() {
try {
await client.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{coordinator_zome_manifest.name}}',
fn_name: 'delete_{{snake_case entry_type.name}}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ onMount(async () => {
try {
loading = true;
const links: Array<Link> = await client.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{snake_case coordinator_zome_manifest.name}}',
fn_name: 'get_{{snake_case (plural from_referenceable.name)}}_for_{{snake_case to_referenceable.name}}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ onMount(async () => {
try {
loading = true;
const links: Array<Link> = await client.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{coordinator_zome_manifest.name}}',
fn_name: 'get_{{snake_case (plural to_referenceable.name)}}_for_{{snake_case from_referenceable.name}}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ test('create a {{pascal_case referenceable.name}} and get {{lower_case collectio
let collectionOutput: Link[] = await bob.cells[0].callZome({
zome_name: "{{coordinator_zome_manifest.name}}",
fn_name: "get_{{snake_case collection_name}}",
payload: {{#if (eq collection_type.type "Global")}}null{{else}}alice.agentPubKey{{/if}}
{{#if (eq collection_type.type "ByAuthor")}}alice.agentPubKey,{{/if}}
});
assert.equal(collectionOutput.length, 0);

Expand Down
4 changes: 1 addition & 3 deletions templates/ui-frameworks/vanilla/example/ui/index.html.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
const hellos = ["hello world","hola mundo","bonjur monde","guten Tag Welt","salve mondo","你好世界","مرحبا بالعالم","こんにちは 世界","olá mundo","Привет, мир","Selam Dünya","Witaj świecie"];
const message = hellos[getRandomInt(hellos.length)];
const result = await client.callZome({
cap_secret: null,
role_name: 'hello_world',
zome_name: 'hello_world',
fn_name: 'hello_world',
Expand All @@ -66,7 +65,6 @@

async function getHellos() {
const result = await client.callZome({
cap_secret: null,
role_name: 'hello_world',
zome_name: 'hello_world',
fn_name: 'get_hellos',
Expand Down Expand Up @@ -98,4 +96,4 @@

</script>
</body>
</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default defineComponent({

{{/if}}
await this.fetch{{pascal_case referenceable.name}}();
toRaw(this.client).on('signal', signal => {
toRaw(this.client)?.on('signal', signal => {
if (!(SignalType.App in signal)) return;
if (signal.App.zome_name !== '{{coordinator_zome_manifest.name}}') return;
const payload = signal.App.payload as {{pascal_case coordinator_zome_manifest.name}}Signal;
Expand All @@ -66,11 +66,10 @@ export default defineComponent({
try {
this.loading = true;
const links: Array<Link> = await this.client.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{snake_case coordinator_zome_manifest.name}}',
fn_name: 'get_{{snake_case collection_name}}',
payload: {{#if (eq collection_type.type "ByAuthor")}}this.author{{else}}null{{/if}},
{{#if (eq collection_type.type "ByAuthor")}}payload: this.author,{{/if}}
});
this.hashes = links.map(l => l.target);
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ export default defineComponent({

try {
const record: Record = await this.client.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{coordinator_zome_manifest.name}}',
fn_name: 'create_{{snake_case entry_type.name}}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default defineComponent({

await this.fetch{{pascal_case (plural ../entry_type.name)}}();

toRaw(this.client).on('signal', async signal => {
toRaw(this.client)?.on('signal', async signal => {
if (!(SignalType.App in signal)) return;
if (signal.App.zome_name !== '{{../coordinator_zome_manifest.name}}') return;
const payload = signal.App.payload as {{pascal_case ../coordinator_zome_manifest.name}}Signal;
Expand All @@ -57,7 +57,6 @@ export default defineComponent({
this.loading = true;
try {
const links: Array<Link> = await this.client.callZome({
cap_secret: null,
role_name: '{{../dna_role_name}}',
zome_name: '{{../coordinator_zome_manifest.name}}',
fn_name: 'get_{{snake_case (plural ../entry_type.name)}}_for_{{snake_case linked_from.name}}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ export default defineComponent({

try {
const updateRecord: Record = await this.client.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{coordinator_zome_manifest.name}}',
fn_name: 'update_{{snake_case entry_type.name}}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ export default defineComponent({
try {
this.loading = true;
this.record = await this.client.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{coordinator_zome_manifest.name}}',
fn_name: '{{#if crud.update}}get_latest_{{snake_case entry_type.name}}{{else}}get_{{snake_case entry_type.name}}{{/if}}',
Expand All @@ -121,7 +120,6 @@ export default defineComponent({
try {
this.loading = true
await this.client.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{coordinator_zome_manifest.name}}',
fn_name: 'delete_{{snake_case entry_type.name}}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export default defineComponent({
try {
this.loading = true;
const links: Array<Link> = await this.client.callZome({
cap_secret: null,
role_name: '{{dna_role_name}}',
zome_name: '{{coordinator_zome_manifest.name}}',
fn_name: 'get_{{snake_case (plural from_referenceable.name)}}_for_{{snake_case to_referenceable.name}}',
Expand All @@ -59,7 +58,7 @@ export default defineComponent({
this.loading = false;
}

toRaw(this.client).on('signal', signal => {
toRaw(this.client)?.on('signal', signal => {
if (!(SignalType.App in signal)) return;
if (signal.App.zome_name !== '{{coordinator_zome_manifest.name}}') return;
const payload = signal.App.payload as {{pascal_case coordinator_zome_manifest.name}}Signal;
Expand Down
Loading