From d0e0daef32dadf1d154c23a0c239c813be0d3bca Mon Sep 17 00:00:00 2001 From: "patrwinfspam+github@gmail.com" Date: Mon, 18 Sep 2023 16:52:39 -0600 Subject: [PATCH 1/9] add hpos zome call --- src/stores/useHoloportAPIStore.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/stores/useHoloportAPIStore.js b/src/stores/useHoloportAPIStore.js index 3251ea9..6e393ee 100644 --- a/src/stores/useHoloportAPIStore.js +++ b/src/stores/useHoloportAPIStore.js @@ -22,7 +22,16 @@ const makeUseHoloportAPIStore = ({ useHolochainStore }) => defineStore('holoport }, async callZome(args) { - useHolochainStore().callZome(args) + const zomeCallArgs = { + appId: installed_app_id, + roleId: args.role_name, + zomeName: args.zome_name, + fnName: args.fn_name, + payload: args.payload + } + + const response = await this.hposHolochainCall({path: 'zome_call', headers: {}, params: zomeCallArgs}) + return response }, setCredentials(cellId) { this.signingCredentials = new Promise(async (resolve, reject) => { From 9581d4e09282c574e9f4afa4ab1bb190a764951a Mon Sep 17 00:00:00 2001 From: "patrwinfspam+github@gmail.com" Date: Tue, 19 Sep 2023 14:20:00 -0600 Subject: [PATCH 2/9] update isReady flag for hpos api store --- src/stores/useHoloportAPIStore.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/stores/useHoloportAPIStore.js b/src/stores/useHoloportAPIStore.js index 6e393ee..883478b 100644 --- a/src/stores/useHoloportAPIStore.js +++ b/src/stores/useHoloportAPIStore.js @@ -9,16 +9,18 @@ const makeUseHoloportAPIStore = ({ useHolochainStore }) => defineStore('holoport client: useHolochainStore().client, // These two values are subscribed to by clientStore appInfo: useHolochainStore().appInfo, - isReady: useHolochainStore().isReady, + isReady: false, signingCredentials: useHolochainStore().signingCredentials }), actions: { async initialize() { useHolochainStore().initialize() + this.isReady = true }, async loadAppInfo() { useHolochainStore().loadAppInfo() + this.isReady = true }, async callZome(args) { From ceee25c5cbc2dc87d5af030313ec837e9924c349 Mon Sep 17 00:00:00 2001 From: "patrwinfspam+github@gmail.com" Date: Tue, 19 Sep 2023 14:54:54 -0600 Subject: [PATCH 3/9] more hpos store tweaks --- src/stores/useHoloportAPIStore.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/stores/useHoloportAPIStore.js b/src/stores/useHoloportAPIStore.js index 883478b..c6874c1 100644 --- a/src/stores/useHoloportAPIStore.js +++ b/src/stores/useHoloportAPIStore.js @@ -10,16 +10,15 @@ const makeUseHoloportAPIStore = ({ useHolochainStore }) => defineStore('holoport // These two values are subscribed to by clientStore appInfo: useHolochainStore().appInfo, isReady: false, - signingCredentials: useHolochainStore().signingCredentials + signingCredentials: null }), actions: { async initialize() { - useHolochainStore().initialize() this.isReady = true }, async loadAppInfo() { - useHolochainStore().loadAppInfo() + // useHolochainStore().loadAppInfo() this.isReady = true }, From 056cc8e140d2f6720d9400147fbc2408b14c017f Mon Sep 17 00:00:00 2001 From: "patrwinfspam+github@gmail.com" Date: Tue, 19 Sep 2023 15:55:34 -0600 Subject: [PATCH 4/9] tweak isReady --- src/stores/useHoloportAPIStore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stores/useHoloportAPIStore.js b/src/stores/useHoloportAPIStore.js index c6874c1..d910ca6 100644 --- a/src/stores/useHoloportAPIStore.js +++ b/src/stores/useHoloportAPIStore.js @@ -14,7 +14,7 @@ const makeUseHoloportAPIStore = ({ useHolochainStore }) => defineStore('holoport }), actions: { async initialize() { - this.isReady = true + // this.isReady = true }, async loadAppInfo() { From 08660f41a756305bd4a39bfc5ad2d0291402e472 Mon Sep 17 00:00:00 2001 From: "patrwinfspam+github@gmail.com" Date: Tue, 19 Sep 2023 17:15:06 -0600 Subject: [PATCH 5/9] tweaking app info --- src/stores/useClientStore.js | 2 +- src/stores/useHoloportAPIStore.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/stores/useClientStore.js b/src/stores/useClientStore.js index aabe342..60af810 100644 --- a/src/stores/useClientStore.js +++ b/src/stores/useClientStore.js @@ -19,7 +19,7 @@ const makeUseClientStore = ({ useInterfaceStore, onInit }) => defineStore('clien useInterfaceStore().$subscribe((_, state) => { // This could be more efficient by inspecting the contents of mutation - this.isReady = state.isReady + this.isReady = useInterfaceStore().isReady if (state.appInfo?.agent_pub_key) { this.agentKey = state.appInfo.agent_pub_key diff --git a/src/stores/useHoloportAPIStore.js b/src/stores/useHoloportAPIStore.js index d910ca6..5f82a49 100644 --- a/src/stores/useHoloportAPIStore.js +++ b/src/stores/useHoloportAPIStore.js @@ -14,11 +14,11 @@ const makeUseHoloportAPIStore = ({ useHolochainStore }) => defineStore('holoport }), actions: { async initialize() { - // this.isReady = true + this.isReady = true }, async loadAppInfo() { - // useHolochainStore().loadAppInfo() + useHolochainStore().loadAppInfo() this.isReady = true }, From 0fa34fb5e65e4e90629b994e0be49a12c1820f41 Mon Sep 17 00:00:00 2001 From: "patrwinfspam+github@gmail.com" Date: Tue, 19 Sep 2023 20:10:30 -0600 Subject: [PATCH 6/9] re-add loadAppInfo --- src/stores/useHoloportAPIStore.js | 37 ++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/src/stores/useHoloportAPIStore.js b/src/stores/useHoloportAPIStore.js index 5f82a49..544c5db 100644 --- a/src/stores/useHoloportAPIStore.js +++ b/src/stores/useHoloportAPIStore.js @@ -6,7 +6,7 @@ import { kycLevel2 } from '../services/hbs' const makeUseHoloportAPIStore = ({ useHolochainStore }) => defineStore('holoportAPI', { state: () => ({ - client: useHolochainStore().client, + client: null, // These two values are subscribed to by clientStore appInfo: useHolochainStore().appInfo, isReady: false, @@ -14,12 +14,43 @@ const makeUseHoloportAPIStore = ({ useHolochainStore }) => defineStore('holoport }), actions: { async initialize() { - this.isReady = true + try { + const holochainClient = await AppWebsocket.connect( + app_ws_url, + HC_APP_TIMEOUT, + signal => useSignalStore().handleSignal(presentHcSignal(signal)) + ) + + this.client = holochainClient + + holochainClient.client.socket.onclose = function(e) { + console.log( + 'Socket to Holochain App Interface has closed.', + inspect(e) + ) + this.client = null + this.isReady = false + } + + this.loadAppInfo() + } catch (e) { + console.error('Holochain connection error ', e) + this.isReady = false + } }, async loadAppInfo() { - useHolochainStore().loadAppInfo() + try { + const appInfo = await this.client.appInfo({ + installed_app_id + }) + this.appInfo = appInfo this.isReady = true + + return appInfo + } catch (error) { + console.error('appInfo() returned error.', inspect(error)) + } }, async callZome(args) { From a1ba0a5a00cef2e850ca61b9d38916ad94fd33a9 Mon Sep 17 00:00:00 2001 From: "patrwinfspam+github@gmail.com" Date: Tue, 19 Sep 2023 20:20:12 -0600 Subject: [PATCH 7/9] revert change to client store --- src/stores/useClientStore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stores/useClientStore.js b/src/stores/useClientStore.js index 60af810..5d49818 100644 --- a/src/stores/useClientStore.js +++ b/src/stores/useClientStore.js @@ -19,7 +19,7 @@ const makeUseClientStore = ({ useInterfaceStore, onInit }) => defineStore('clien useInterfaceStore().$subscribe((_, state) => { // This could be more efficient by inspecting the contents of mutation - this.isReady = useInterfaceStore().isReady + this.isReady = state if (state.appInfo?.agent_pub_key) { this.agentKey = state.appInfo.agent_pub_key From 595cbabe325087c7621dde0a957eff67634a79e0 Mon Sep 17 00:00:00 2001 From: "patrwinfspam+github@gmail.com" Date: Tue, 19 Sep 2023 20:29:20 -0600 Subject: [PATCH 8/9] remove holochain store from holoport store --- src/stores/useHoloportAPIStore.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stores/useHoloportAPIStore.js b/src/stores/useHoloportAPIStore.js index 544c5db..00a4f77 100644 --- a/src/stores/useHoloportAPIStore.js +++ b/src/stores/useHoloportAPIStore.js @@ -4,11 +4,11 @@ import { defineStore } from 'pinia' import { listify } from '../utils' import { kycLevel2 } from '../services/hbs' -const makeUseHoloportAPIStore = ({ useHolochainStore }) => defineStore('holoportAPI', { +const makeUseHoloportAPIStore = () => defineStore('holoportAPI', { state: () => ({ client: null, // These two values are subscribed to by clientStore - appInfo: useHolochainStore().appInfo, + appInfo: null, isReady: false, signingCredentials: null }), From 801732809bd6e37db6b60f3fc2bf742cb50890df Mon Sep 17 00:00:00 2001 From: "patrwinfspam+github@gmail.com" Date: Tue, 19 Sep 2023 21:03:17 -0600 Subject: [PATCH 9/9] add missing import --- src/stores/useHoloportAPIStore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stores/useHoloportAPIStore.js b/src/stores/useHoloportAPIStore.js index 00a4f77..182fb0d 100644 --- a/src/stores/useHoloportAPIStore.js +++ b/src/stores/useHoloportAPIStore.js @@ -1,5 +1,5 @@ import axios from 'axios' -import { generateSigningKeyPair, setSigningCredentials } from '@holochain/client' +import { AppWebsocket, generateSigningKeyPair, setSigningCredentials } from '@holochain/client' import { defineStore } from 'pinia' import { listify } from '../utils' import { kycLevel2 } from '../services/hbs'