@@ -86,6 +86,9 @@ export const Zklogin = ({
86
86
( async function ( ) {
87
87
await completeZkLogin ( ) ;
88
88
const userData = accounts . current [ 0 ] ;
89
+ if ( typeof window !== undefined && userData !== undefined ) {
90
+ localStorage . setItem ( "subId" , userData . sub ) ;
91
+ }
89
92
if ( userData ) {
90
93
setUserSubId ( userData . sub ) ;
91
94
setUserAddress ( userData . userAddr ) ;
@@ -117,7 +120,6 @@ export const Zklogin = ({
117
120
118
121
// if there is some value in userData then set the userId in local storage
119
122
if ( typeof window !== "undefined" && getUserData !== undefined ) {
120
- localStorage . setItem ( "subId" , getUserData . sub_id ) ;
121
123
localStorage . setItem ( "userId" , getUserData . id ) ;
122
124
}
123
125
// if getUserData is undefined means there is no value then post the data of new user
@@ -144,6 +146,7 @@ export const Zklogin = ({
144
146
. then ( ( data ) => console . log ( data ) )
145
147
. catch ( ( error ) => console . error ( "Error:" , error ) ) ;
146
148
}
149
+ await sendTransaction ( userData ) ;
147
150
}
148
151
} ) ( ) ;
149
152
fetchBalances ( accounts . current ) ;
@@ -153,7 +156,6 @@ export const Zklogin = ({
153
156
} ;
154
157
// eslint-disable-next-line
155
158
} , [ ] ) ;
156
-
157
159
/* zkLogin end-to-end */
158
160
159
161
/**
@@ -199,25 +201,6 @@ export const Zklogin = ({
199
201
loginUrl = `https://accounts.google.com/o/oauth2/v2/auth?${ urlParams . toString ( ) } ` ;
200
202
break ;
201
203
}
202
- // case "Twitch": {
203
- // const urlParams = new URLSearchParams({
204
- // ...urlParamsBase,
205
- // client_id: config.CLIENT_ID_TWITCH,
206
- // force_verify: "true",
207
- // lang: "en",
208
- // login_type: "login",
209
- // });
210
- // loginUrl = `https://id.twitch.tv/oauth2/authorize?${urlParams.toString()}`;
211
- // break;
212
- // }
213
- // case "Facebook": {
214
- // const urlParams = new URLSearchParams({
215
- // ...urlParamsBase,
216
- // client_id: config.CLIENT_ID_FACEBOOK,
217
- // });
218
- // loginUrl = `https://www.facebook.com/v19.0/dialog/oauth?${urlParams.toString()}`;
219
- // break;
220
- // }
221
204
}
222
205
window . location . replace ( loginUrl ) ;
223
206
}
@@ -372,17 +355,34 @@ export const Zklogin = ({
372
355
* https://docs.sui.io/concepts/cryptography/zklogin#assemble-the-zklogin-signature-and-submit-the-transaction
373
356
*/
374
357
async function sendTransaction ( account : AccountData ) {
375
- setModalContent ( "🚀 Sending transaction..." ) ;
376
-
377
358
// Sign the transaction bytes with the ephemeral private key
359
+ let userId ;
360
+ if ( typeof window !== undefined ) {
361
+ userId = localStorage . getItem ( "userId" ) ;
362
+ }
378
363
const txb = new TransactionBlock ( ) ;
364
+ const packageObjectId =
365
+ "0x234604afac20711ef396f60601eeb8c0a97b7d9f0c4d33c5d02dafe6728d41be" ;
366
+ txb . moveCall ( {
367
+ target : `${ packageObjectId } ::voyagerprofile::mint` ,
368
+ arguments : [
369
+ txb . pure ( userId ) , // user id
370
+ txb . pure ( "voyager platform NFT" ) , // Description argument
371
+ txb . pure ( "url" ) , //url
372
+ ] ,
373
+ } ) ;
379
374
txb . setSender ( account . userAddr ) ;
375
+ console . log ( "[mint] Account address:" , account . userAddr ) ;
380
376
381
377
const ephemeralKeyPair = keypairFromSecretKey ( account . ephemeralPrivateKey ) ;
382
378
const { bytes, signature : userSignature } = await txb . sign ( {
383
379
client : suiClient ,
384
380
signer : ephemeralKeyPair ,
385
381
} ) ;
382
+ console . log ( "[sendTransaction] Transaction signed:" , {
383
+ bytes,
384
+ userSignature,
385
+ } ) ;
386
386
387
387
// Generate an address seed by combining userSalt, sub (subject ID), and aud (audience)
388
388
const addressSeed = genAddressSeed (
@@ -427,7 +427,7 @@ export const Zklogin = ({
427
427
return null ;
428
428
} )
429
429
. finally ( ( ) => {
430
- setModalContent ( "" ) ;
430
+ // you can set here modal content
431
431
} ) ;
432
432
}
433
433
/**
0 commit comments