@@ -4,65 +4,51 @@ import type { Add } from '../../../contracts/src/Add';
4
4
5
5
type Transaction = Awaited < ReturnType < typeof Mina . transaction > > ;
6
6
7
- // ---------------------------------------------------------------------------------------
8
-
9
-
10
7
const state = {
11
8
Add : null as null | typeof Add ,
12
9
zkapp : null as null | Add ,
13
10
transaction : null as null | Transaction ,
14
11
} ;
15
12
16
- // ---------------------------------------------------------------------------------------
17
-
18
- // Define the worker's methods
19
- export const api = {
20
- setActiveInstanceToDevnet : async ( args : { } ) => {
21
- const Network = Mina . Network (
22
- 'https://api.minascan.io/node/devnet/v1/graphql'
23
- ) ;
24
- console . log ( 'Devnet network instance configured.' ) ;
13
+ const api = {
14
+ async setActiveInstanceToDevnet ( ) {
15
+ const Network = Mina . Network ( 'https://api.minascan.io/node/devnet/v1/graphql' ) ;
25
16
Mina . setActiveInstance ( Network ) ;
26
17
} ,
27
- loadContract : async ( args : { } ) => {
18
+ async loadContract ( ) {
28
19
const { Add } = await import ( '../../../contracts/build/src/Add.js' ) ;
29
20
state . Add = Add ;
30
21
} ,
31
- compileContract : async ( args : { } ) => {
22
+ async compileContract ( ) {
32
23
await state . Add ! . compile ( ) ;
33
24
} ,
34
- fetchAccount : async ( publicKey : PublicKey ) => {
35
- // console.log('args', args )
36
- // const publicKey = PublicKey.fromBase58(args.publicKey58);
37
- return await fetchAccount ( publicKey ) ;
25
+ async fetchAccount ( publicKey58 : string ) {
26
+ console . log ( `fetchAccount Received publicKey58: ${ publicKey58 } ` ) ;
27
+
28
+ const publicKey = PublicKey . fromBase58 ( publicKey58 ) ;
29
+ return fetchAccount ( { publicKey } ) ;
38
30
} ,
39
- initZkappInstance : async ( publicKey : PublicKey ) => {
40
- console . log ( publicKey )
41
- // const publicKey = PublicKey.fromBase58(args.publicKey58);
42
- // const pk = PublicKey.toBase58(publicKey)
43
- // console.log('pk', pk)
44
- console . log ( state . Add )
31
+ async initZkappInstance ( publicKey58 : string ) {
32
+ console . log ( `initZkappInstance Received publicKey58: ${ publicKey58 } ` ) ;
33
+ const publicKey = PublicKey . fromBase58 ( publicKey58 ) ;
45
34
state . zkapp = new state . Add ! ( publicKey ) ;
46
35
} ,
47
- getNum : async ( args : { } ) => {
36
+ async getNum ( ) {
48
37
const currentNum = await state . zkapp ! . num . get ( ) ;
49
38
return JSON . stringify ( currentNum . toJSON ( ) ) ;
50
39
} ,
51
- createUpdateTransaction : async ( args : { } ) => {
52
- const transaction = await Mina . transaction ( async ( ) => {
40
+ async createUpdateTransaction ( ) {
41
+ state . transaction = await Mina . transaction ( async ( ) => {
53
42
await state . zkapp ! . update ( ) ;
54
43
} ) ;
55
- state . transaction = transaction ;
56
44
} ,
57
- proveUpdateTransaction : async ( args : { } ) => {
45
+ async proveUpdateTransaction ( ) {
58
46
await state . transaction ! . prove ( ) ;
59
47
} ,
60
- getTransactionJSON : async ( args : { } ) => {
48
+ async getTransactionJSON ( ) {
61
49
return state . transaction ! . toJSON ( ) ;
62
50
} ,
63
51
} ;
64
52
65
- // ---------------------------------------------------------------------------------------
66
-
67
- // Expose the API to be used by the main thread
53
+ // Expose the API to be used by the main thread
68
54
Comlink . expose ( api ) ;
0 commit comments