Skip to content

Commit

Permalink
build: bump holochain-lair-signer to fix delay when signing zome calls
Browse files Browse the repository at this point in the history
  • Loading branch information
mattyg committed Sep 26, 2023
1 parent e2f71ef commit e0d5dfb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 74 deletions.
24 changes: 9 additions & 15 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import initAgent, {
APP_PORT_EVENT,
LAIR_SOCKET_EVENT,
} from '@lightningrodlabs/electron-holochain';
import { signZomeCallWithClient, ZomeCallUnsignedNapi } from 'holochain-lair-signer';
import { ZomeCallSigner, ZomeCallUnsignedNapi } from 'holochain-lair-signer';
import console from "console";

const HAPP_FILE = "mewsfeed.happ"; // replace-me Enter the path to your happ
Expand All @@ -20,14 +20,12 @@ if (require('electron-squirrel-startup')) {
app.quit();
}

let LAIR_SOCKET_URL: string | undefined;
let APP_INTERFACE_PORT: number | undefined;
let ZOME_CALL_SIGNER: ZomeCallSigner | undefined;

const handleSignZomeCall = (e: Event, zomeCall: ZomeCallUnsignedNapi) => {
if(!LAIR_SOCKET_URL) throw Error('Lair socket url is not defined');
if(!LAIR_PASSWORD) throw Error('Lair password is not defined');

return signZomeCallWithClient(zomeCall, LAIR_SOCKET_URL, LAIR_PASSWORD);
if(!ZOME_CALL_SIGNER) throw Error('Lair signer is not ready');
return ZOME_CALL_SIGNER.signZomeCall(zomeCall);
};

export function stateSignalToText(state: StateSignal): string {
Expand Down Expand Up @@ -109,6 +107,7 @@ const createSplashWindow = (): BrowserWindow => {
backgroundColor: "#fbf9f7",
webPreferences: {
sandbox: true,
preload: path.join(__dirname, 'preload.js'),
},
})

Expand Down Expand Up @@ -137,11 +136,6 @@ app.on('ready', async () => {
passphrase: LAIR_PASSWORD,
keystorePath: path.join(app.getPath('userData'), 'holochain-data/keystore'),
datastorePath: path.join(app.getPath('userData'), 'holochain-data/databases'),
// appWsPort?: number
// adminWsPort?: number
// webrtcSignalUrl?: string
// membraneProof?: string
// networkSeed: NETWORK_SEED,
};

// shutdown will be called automatically on application
Expand All @@ -162,12 +156,12 @@ app.on('ready', async () => {
}
});

statusEmitter.on(APP_PORT_EVENT, (port: string) => {
APP_INTERFACE_PORT = parseInt(port);
statusEmitter.on(APP_PORT_EVENT, (app_port: string) => {
APP_INTERFACE_PORT = parseInt(app_port);
});

statusEmitter.on(LAIR_SOCKET_EVENT, (path: string) => {
LAIR_SOCKET_URL = path;
statusEmitter.on(LAIR_SOCKET_EVENT, async (lair_socket_url: string) => {
ZOME_CALL_SIGNER = await ZomeCallSigner.connect(lair_socket_url, LAIR_PASSWORD);
});

app.whenReady().then(() => {
Expand Down
71 changes: 14 additions & 57 deletions package-lock.json

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

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"main": ".vite/build/main.js",
"scripts": {
"dist": "rimraf holochain-data && rimraf main_window && make-dir ./main_window && ncp ./electron/ ./main_window/ && cross-unzip ./pouch/ui.zip ./main_window && make-dir binaries && ncp node_modules/@lightningrodlabs/electron-holochain/binaries/ ./binaries/",
"build-rs": "cd lair-sign && napi build --platform --release",
"start": "npm run dist && electron-forge start",
"package": "npm run dist && electron-forge package",
"make": "npm run dist && electron-forge make",
Expand Down Expand Up @@ -48,6 +47,6 @@
"@lightningrodlabs/electron-holochain": "^0.7.8",
"@napi-rs/cli": "^2.16.3",
"electron-squirrel-startup": "^1.0.0",
"holochain-lair-signer": "^0.0.4"
"holochain-lair-signer": "^0.1.0"
}
}

0 comments on commit e0d5dfb

Please sign in to comment.