-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
63 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { CellType, type AppInfo, AdminWebsocket, AppAgentWebsocket } from '@holochain/client'; | ||
|
||
export const HOLOCHAIN_APP_ID = 'mewsfeed'; | ||
export const IS_LAUNCHER = import.meta.env.VITE_IS_LAUNCHER; | ||
export const IS_HOLO_HOSTED = import.meta.env.VITE_IS_HOLO_HOSTED; | ||
|
||
export const setupHolochain = async () => { | ||
try { | ||
// console.log(import.meta.env); | ||
// const client = await AppAgentWebsocket.connect( | ||
// IS_LAUNCHER ? `ws://UNUSED` : `ws://localhost:${import.meta.env.VITE_HC_PORT}`, | ||
// HOLOCHAIN_APP_ID, | ||
// 60000 | ||
// ); | ||
// if (typeof window === 'object' && !('__HC_LAUNCHER_ENV__' in window)) { | ||
// const appInfo = await client.appInfo(); | ||
// await authorizeClient(appInfo); | ||
// } | ||
// return client; | ||
} catch (e) { | ||
console.log('Holochain client setup error', e); | ||
throw e; | ||
} | ||
}; | ||
|
||
// set up zome call signing when run outside of launcher | ||
export const authorizeClient = async (appInfo: AppInfo) => { | ||
if (typeof window === 'object' && !('__HC_LAUNCHER_ENV__' in window)) { | ||
if (!(CellType.Provisioned in appInfo.cell_info.mewsfeed[0])) { | ||
throw new Error('mewsfeed cell not provisioned'); | ||
} | ||
const { cell_id } = appInfo.cell_info.mewsfeed[0][CellType.Provisioned]; | ||
const adminWs = await AdminWebsocket.connect( | ||
`ws://localhost:${import.meta.env.VITE_HC_ADMIN_PORT}` | ||
); | ||
await adminWs.authorizeSigningCredentials(cell_id); | ||
console.log('Holochain app client authorized for zome calls'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import fs from 'fs'; | ||
import { bestzip } from 'bestzip'; | ||
// import { execSync } from 'child_process'; | ||
|
||
fs.renameSync('./build/200.html', './build/index.html'); | ||
|
||
// Change working directory to 'build' and zip its contents | ||
try { | ||
process.chdir('./build'); | ||
bestzip({ | ||
source: './*', | ||
destination: '../dist.zip' | ||
}) | ||
.then(() => { | ||
console.log('Zip file was created successfully.'); | ||
}) | ||
.catch((err) => { | ||
console.error(err.stack); | ||
}); | ||
} catch (err) { | ||
console.error(`chdir: ${err}`); | ||
} |