From 976967b7bb605c4d6efd4b711758f9f3ecc61a65 Mon Sep 17 00:00:00 2001 From: kirahsapong <102400653+kirahsapong@users.noreply.github.com> Date: Wed, 7 Feb 2024 15:36:57 -0800 Subject: [PATCH] Modify sample to use did:dht instead of did:ion (#22) * update relative path in readme * update pfi did method ion to dht * publish did * adding me and kirah to codeowners * update example script did methods ion to dht * set publish true --------- Co-authored-by: Jiyoon Koo --- README.md | 2 +- src/client-test.ts | 3 ++- src/config.ts | 6 +++--- src/example/utils.ts | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 54eb044..6c2fe75 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ based on your OS' package manager. > Make sure you have all the [prerequisites](#development-prerequisites) 1. Clone the repo and `cd` into the project directory -2. `/db/scripts/start-pg` from your command line to start a `psql` container by +2. `./db/scripts/start-pg` from your command line to start a `psql` container by running. 3. `./db/scripts/migrate` to perform database migrations * This only needs to be done once and then whenever changes are made in diff --git a/src/client-test.ts b/src/client-test.ts index 626ddc2..d47c228 100644 --- a/src/client-test.ts +++ b/src/client-test.ts @@ -1,4 +1,5 @@ import { TbdexHttpClient, DevTools, Rfq } from '@tbdex/http-client' +import { DidDhtMethod } from '@web5/dids' import fs from 'fs/promises' // @@ -101,7 +102,7 @@ async function createOrLoadDid(filename: string) { } catch (error) { // If the file doesn't exist, generate a new DID if (error.code === 'ENOENT') { - const did = await DevTools.createDid() + const did = await DidDhtMethod.create({ publish: true }) await fs.writeFile(filename, JSON.stringify(did, null, 2)) return did } diff --git a/src/config.ts b/src/config.ts index 50e6ca4..f114c03 100644 --- a/src/config.ts +++ b/src/config.ts @@ -5,7 +5,7 @@ import fs from 'node:fs' import 'dotenv/config' -import { DidIonMethod, PortableDid } from '@web5/dids' +import { PortableDid, DidDhtMethod } from '@web5/dids' export type Environment = 'local' | 'staging' | 'production' @@ -39,11 +39,11 @@ export const config: Config = { // a new one will be generated every time the process starts. if (!config.did) { console.log('Creating an ephemeral DID.....') - const DidIon = await DidIonMethod.create({ + const DidDht = await DidDhtMethod.create({ publish: true, services: [{ id: 'pfi', type: 'PFI', serviceEndpoint: config.host }] }) - config.did = DidIon + config.did = DidDht fs.writeFileSync('server-did.txt', config.did.did) } \ No newline at end of file diff --git a/src/example/utils.ts b/src/example/utils.ts index 6c49e6b..4c8eaef 100644 --- a/src/example/utils.ts +++ b/src/example/utils.ts @@ -1,4 +1,4 @@ -import { DevTools } from '@tbdex/http-client' +import { DidDhtMethod } from '@web5/dids' import fs from 'fs/promises' @@ -11,7 +11,7 @@ export async function createOrLoadDid(filename: string) { } catch (error) { // If the file doesn't exist, generate a new DID if (error.code === 'ENOENT') { - const did = await DevTools.createDid() + const did = await DidDhtMethod.create({ publish: true }) await fs.writeFile(filename, JSON.stringify(did, null, 2)) return did }