-
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.
Merge pull request #23 from zkonduit/fix-artifact-paths
fix: update artifacts paths + mobile UI
- Loading branch information
Showing
43 changed files
with
8,893 additions
and
5,443 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,5 @@ | ||
{ | ||
"semi": false, | ||
"singleQuote": true, | ||
"jsxSingleQuote": true | ||
} |
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 |
---|---|---|
@@ -1,50 +1,54 @@ | ||
// Initialize the engine and util imports in the SharedResourcesProvider component: | ||
// Note: must import Uitls as a module instead of a component for engine to work (or else you will get 'self' is undefined wasm errors) | ||
'use client' | ||
import React, { createContext, useContext, useState, useEffect } from 'react'; | ||
type Utils = typeof import("./Utils") | ||
type Engine = typeof import("@ezkljs/engine/web/ezkl") | ||
import React, { createContext, useContext, useState, useEffect } from 'react' | ||
type Utils = typeof import('./Utils') | ||
type Engine = typeof import('@ezkljs/engine/web/ezkl') | ||
|
||
interface SharedResources { | ||
engine: Engine; | ||
utils: Utils; | ||
engine: Engine | ||
utils: Utils | ||
} | ||
|
||
const SharedResourcesContext = createContext<SharedResources | null>(null); | ||
const SharedResourcesContext = createContext<SharedResources | null>(null) | ||
export const useSharedResources = (): SharedResources => { | ||
const context = useContext(SharedResourcesContext); | ||
if (!context) { | ||
throw new Error('useSharedResources must be used within a SharedResourcesProvider'); | ||
} | ||
return context; | ||
}; | ||
const context = useContext(SharedResourcesContext) | ||
if (!context) { | ||
throw new Error( | ||
'useSharedResources must be used within a SharedResourcesProvider', | ||
) | ||
} | ||
return context | ||
} | ||
|
||
interface SharedResourcesProviderProps { | ||
children: React.ReactNode; | ||
children: React.ReactNode | ||
} | ||
|
||
export const SharedResourcesProvider: React.FC<SharedResourcesProviderProps> = ({ children }) => { | ||
const [engine, setEngine] = useState<any>(null); // Replace 'any' with the actual type of 'engine' | ||
const [utils, setUtils] = useState<any>(null); // Replace 'any' with the actual type of 'utils' | ||
export const SharedResourcesProvider: React.FC< | ||
SharedResourcesProviderProps | ||
> = ({ children }) => { | ||
const [engine, setEngine] = useState<any>(null) // Replace 'any' with the actual type of 'engine' | ||
const [utils, setUtils] = useState<any>(null) // Replace 'any' with the actual type of 'utils' | ||
|
||
useEffect(() => { | ||
async function initializeResources() { | ||
// Initialize the WASM module | ||
const engine = await import("@ezkljs/engine/web/ezkl.js"); | ||
setEngine(engine) | ||
await (engine as any).default() | ||
// For human readable wasm debug errors call this function | ||
engine.init_panic_hook() | ||
// Initialize the utils module | ||
const utils = await import("./Utils"); | ||
setUtils(utils) | ||
} | ||
initializeResources(); | ||
}, []); | ||
useEffect(() => { | ||
async function initializeResources() { | ||
// Initialize the WASM module | ||
const engine = await import('@ezkljs/engine/web/ezkl.js') | ||
setEngine(engine) | ||
await (engine as any).default(undefined, new WebAssembly.Memory({ initial: 20, maximum: 4096, shared: true })) | ||
// For human readable wasm debug errors call this function | ||
engine.init_panic_hook() | ||
// Initialize the utils module | ||
const utils = await import('./Utils') | ||
setUtils(utils) | ||
} | ||
initializeResources() | ||
}, []) | ||
|
||
return ( | ||
<SharedResourcesContext.Provider value={{ engine, utils }}> | ||
{children} | ||
</SharedResourcesContext.Provider> | ||
); | ||
}; | ||
return ( | ||
<SharedResourcesContext.Provider value={{ engine, utils }}> | ||
{children} | ||
</SharedResourcesContext.Provider> | ||
) | ||
} |
Oops, something went wrong.