@@ -259,6 +259,48 @@ The web worker client code resides in the `04-zkapp-browser-ui/ui/app/zkappWorke
259
259
` ` `
260
260
- With ` Comlink .wrap ` , create a proxy object ` remoteApi ` that provides typesafe access the worker's API methods.
261
261
262
+ - Define methods in the ZkappWorkerClient class that call the corresponding method on ` remoteApi ` , effectively forwarding the calls to the worker.
263
+
264
+ ` ` ` ts
265
+ async setActiveInstanceToDevnet () {
266
+ return this .remoteApi .setActiveInstanceToDevnet ();
267
+ }
268
+
269
+ async loadContract () {
270
+ return this .remoteApi .loadContract ();
271
+ }
272
+
273
+ async compileContract () {
274
+ return this .remoteApi .compileContract ();
275
+ }
276
+
277
+ async fetchAccount (publicKeyBase58 : string ) {
278
+ return this .remoteApi .fetchAccount (publicKeyBase58 );
279
+ }
280
+
281
+ async initZkappInstance (publicKeyBase58 : string ) {
282
+ return this .remoteApi .initZkappInstance (publicKeyBase58 );
283
+ }
284
+
285
+ async getNum (): Promise < Field > {
286
+ const result = await this .remoteApi .getNum ();
287
+ return Field.fromJSON(JSON.parse(result as string ));
288
+ }
289
+
290
+ async createUpdateTransaction () {
291
+ return this .remoteApi .createUpdateTransaction ();
292
+ }
293
+
294
+ async proveUpdateTransaction () {
295
+ return this .remoteApi .proveUpdateTransaction ();
296
+ }
297
+
298
+ async getTransactionJSON () {
299
+ return this .remoteApi .getTransactionJSON ();
300
+ }
301
+ ` ` `
302
+
303
+
262
304
` ` ` ts
263
305
// Wrap the worker with Comlink to enable direct method invocation
264
306
this .remoteApi = Comlink .wrap (this .worker );
0 commit comments