@@ -2248,13 +2248,23 @@ $(document).ready(function() {
2248
2248
} ) ;
2249
2249
2250
2250
const passportCredential = ( ( ) => {
2251
-
2252
- const _3BOX_SPACE = 'gitcoin' ;
2253
- const _3BOX_FIELD = 'popp' ;
2251
+ const CERAMIC_DOC_FAMILY = 'popp' ;
2252
+ const CERAMIC_DOC_TAGS = [
2253
+ 'gitcoin' ,
2254
+ 'PoPP' ,
2255
+ 'ProofOfPersonhoodPassport' ,
2256
+ 'VerifiableCredential' ,
2257
+ 'DIDKit'
2258
+ ] ;
2254
2259
2255
2260
let credential ;
2256
2261
let verifier ;
2257
2262
2263
+ const CERAMIC_DOC_OPTIONS = {
2264
+ family : CERAMIC_DOC_FAMILY ,
2265
+ tags : CERAMIC_DOC_TAGS
2266
+ } ;
2267
+
2258
2268
const params = ( ) => ( {
2259
2269
'network' : networkName ,
2260
2270
'coinbase' : selectedAccount
@@ -2291,26 +2301,26 @@ $(document).ready(function() {
2291
2301
<a ${ style } href="${ verifier } " target="_blank" class="btn btn-success">Verify</a>
2292
2302
<a ${ style } href="${ href } " class="btn btn-link" download="gitcoin-popp-vc.json"">Download</a>
2293
2303
</div>
2294
- <button ${ style } type="button" class="btn btn-primary" id="vc-3box ">Save to 3Box </button>
2304
+ <button ${ style } type="button" class="btn btn-primary" id="vc-ceramic ">Save to Ceramic </button>
2295
2305
</div>
2296
2306
` ;
2297
2307
} ;
2298
2308
2299
2309
const messages = {
2300
- auth : [
2301
- 'Authenticate with 3Box ' ,
2302
- 'Authenticating with 3Box ' ,
2303
- 'Authenticated with 3Box '
2310
+ init : [
2311
+ 'Initialize Ceramic client ' ,
2312
+ 'Initializing Ceramic client ' ,
2313
+ 'Initialized Ceramic client '
2304
2314
] ,
2305
- storage : [
2306
- `Open ' ${ _3BOX_SPACE } ' storage space on 3Box` ,
2307
- `Opening ' ${ _3BOX_SPACE } ' storage space on 3Box` ,
2308
- `Opened ' ${ _3BOX_SPACE } ' storage space on 3Box`
2315
+ auth : [
2316
+ 'Authenticate with Ceramic client' ,
2317
+ 'Authenticating with Ceramic client' ,
2318
+ 'Authenticated with Ceramic client'
2309
2319
] ,
2310
- variable : [
2311
- ` Save passport credential as ' ${ _3BOX_FIELD } '` ,
2312
- ` Saving passport credential as ' ${ _3BOX_FIELD } '` ,
2313
- ` Saved passport credential as ' ${ _3BOX_FIELD } '`
2320
+ write : [
2321
+ ' Save passport credential' ,
2322
+ ' Saving passport credential' ,
2323
+ ' Saved passport credential'
2314
2324
]
2315
2325
} ;
2316
2326
@@ -2323,26 +2333,29 @@ $(document).ready(function() {
2323
2333
return '<em>' + source [ 0 ] + '</em>' ;
2324
2334
} ;
2325
2335
2326
- const get3BoxContent = ( auth , storage , variable ) => {
2336
+ const getContent = ( init , auth , write ) => {
2327
2337
let list = '<ul>' ;
2328
2338
2329
2339
list += '<li>' ;
2330
- list += getMessage ( messages . auth , auth ) ;
2340
+ list += getMessage ( messages . init , init ) ;
2331
2341
list += '</li>' ;
2332
2342
2333
2343
list += '<li>' ;
2334
- list += getMessage ( messages . storage , storage ) ;
2344
+ list += getMessage ( messages . auth , auth ) ;
2335
2345
list += '</li>' ;
2336
2346
2337
2347
list += '<li>' ;
2338
- list += getMessage ( messages . variable , variable ) ;
2348
+ list += getMessage ( messages . write , write ) ;
2339
2349
list += '</li>' ;
2340
2350
2341
2351
list += '</ul>' ;
2342
2352
2343
2353
return `
2344
2354
<div>
2345
- <p><strong>3Box integration:</strong> you can save a POPP credential to 3Box.</p>
2355
+ <p>
2356
+ <strong>Ceramic integration:</strong>
2357
+ you can save a POPP credential to Ceramic.
2358
+ </p>
2346
2359
${ list }
2347
2360
</div>
2348
2361
` ;
@@ -2378,35 +2391,34 @@ $(document).ready(function() {
2378
2391
}
2379
2392
} ;
2380
2393
2381
- const vc3Box = async ( ) => {
2394
+ const vcCeramic = async ( ) => {
2382
2395
const modal = $ ( '.modal-body' ) ;
2383
2396
const base = baseContent ( ) ;
2384
2397
2385
- modal . html ( `${ base } <hr /> ${ get3BoxContent ( false ) } ` ) ;
2398
+ modal . html ( `${ base } <hr /> ${ getContent ( false ) } ` ) ;
2399
+
2400
+ const client = await Ceramic . initializeClient ( ) ;
2386
2401
2387
- const storageBox = await Box . openBox ( selectedAccount , provider ) ;
2388
2402
2389
- modal . html ( `${ base } <hr /> ${ get3BoxContent ( true , false ) } ` ) ;
2403
+ modal . html ( `${ base } <hr /> ${ getContent ( true , false ) } ` ) ;
2390
2404
2391
- const storageSpace = await storageBox . openSpace ( _3BOX_SPACE ) ;
2405
+ await Ceramic . authenticateEthAddress ( client , selectedAccount ) ;
2392
2406
2393
- await storageSpace . syncDone ;
2394
2407
2395
- modal . html ( `${ base } <hr /> ${ get3BoxContent ( true , true , false ) } ` ) ;
2408
+ modal . html ( `${ base } <hr /> ${ getContent ( true , true , false ) } ` ) ;
2396
2409
2397
- const json = JSON . stringify ( credential ) ;
2410
+ await Ceramic . writeDocument ( client , credential , CERAMIC_DOC_OPTIONS ) ;
2398
2411
2399
- await storageSpace . public . set ( _3BOX_FIELD , json ) ;
2400
2412
2401
- modal . html ( `${ base } <hr /> ${ get3BoxContent ( true , true , true ) } ` ) ;
2413
+ modal . html ( `${ base } <hr /> ${ getContent ( true , true , true ) } ` ) ;
2402
2414
2403
- _alert ( 'Your passport has been uploaded to 3Box ' , 'success' , 5000 ) ;
2415
+ _alert ( 'Your passport has been uploaded to Ceramic ' , 'success' , 5000 ) ;
2404
2416
} ;
2405
2417
2406
- return { vcPassport, vc3Box } ;
2418
+ return { vcPassport, vcCeramic } ;
2407
2419
} ) ( ) ;
2408
2420
2409
2421
$ ( document ) . on ( 'click' , '#vc-passport' , passportCredential . vcPassport ) ;
2410
- $ ( document ) . on ( 'click' , '#vc-3box ' , passportCredential . vc3Box ) ;
2422
+ $ ( document ) . on ( 'click' , '#vc-ceramic ' , passportCredential . vcCeramic ) ;
2411
2423
2412
2424
} ) ;
0 commit comments