Skip to content

Change web3name in docs #307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import * as Kilt from '@kiltprotocol/sdk-js'

export async function main(): Promise<Kilt.DidUri | null> {
let apiConfig = Kilt.ConfigService.get('api')
const encodedJohnDoeDetails =
const encodedKiltnerd123Details =
await apiConfig.call.did.queryByWeb3Name('kiltnerd123')

// This function will throw if johnDoeOwner does not exist
// This function will throw if kiltnerd123 does not exist
const {
document: { uri }
} = Kilt.Did.linkedInfoFromChain(encodedJohnDoeDetails)
} = Kilt.Did.linkedInfoFromChain(encodedKiltnerd123Details)
console.log(`My name is kiltnerd123 and this is my DID: "${uri}"`)

return uri
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import * as Kilt from '@kiltprotocol/sdk-js'
export async function main(
uri: Kilt.DidUri
): Promise<Kilt.DidServiceEndpoint[]> {
const johnDoeDidDocument = await Kilt.Did.resolve(uri)
console.log(`John Doe's DID Document:`)
console.log(JSON.stringify(johnDoeDidDocument, null, 2))
const kiltnerd123DidDocument = await Kilt.Did.resolve(uri)
console.log(`kiltnerd123's DID Document:`)
console.log(JSON.stringify(kiltnerd123DidDocument, null, 2))

const endpoints = johnDoeDidDocument?.document?.service
const endpoints = kiltnerd123DidDocument?.document?.service
if (!endpoints) {
console.log('No endpoints for the DID.')
return []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ export async function main(credential: Kilt.ICredential): Promise<void> {
throw new Error('The credential has been revoked, hence it is not valid.')
}
console.log(
`John Doe's credential is valid and has been attested by ${attester}!`
`kiltnerd123's credential is valid and has been attested by ${attester}!`
)
} catch {
console.log("John Doe's credential is not valid.")
console.log("kiltnerd123's credential is not valid.")
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import * as Kilt from '@kiltprotocol/sdk-js'

import { main as connectToPeregrine } from './02_connect_spirit'
import { main as connectToSpiritnet } from './02_connect_spirit'
import { main as connectToPeregrine } from './02_connect_pere'
import { main as disconnect } from './07_disconnect'
import { main as fetchEndpointData } from './05_fetch_endpoint_data'
import { main as fetchJohnDoeDid } from './03_fetch_did'
import { main as fetchJohnDoeEndpoints } from './04_fetch_endpoints'
import { main as fetchkiltnerd123Did } from './03_fetch_did'
import { main as fetchkiltnerd123Endpoints } from './04_fetch_endpoints'
import { main as printHelloWorld } from './01_print_hello_world'
import { main as verifyCredential } from './06_verify_credential'

async function fetchDidAndCredential() {
const johnDoeDid = await fetchJohnDoeDid()
if (!johnDoeDid)
const kiltnerd123Did = await fetchkiltnerd123Did()
if (!kiltnerd123Did)
throw new Error('"kiltnerd123" is not associated to any DID on Spiritnet')
const endpoints = await fetchJohnDoeEndpoints(johnDoeDid)
const endpoints = await fetchkiltnerd123Endpoints(kiltnerd123Did)
if (!endpoints || !endpoints.length)
throw new Error(`DID doesn't include services`)

Expand All @@ -33,14 +32,6 @@ async function fetchDidAndCredential() {
export async function runAll(): Promise<void> {
await printHelloWorld()

// check that the getting started works with both spiritnet and peregine
await connectToSpiritnet()
try {
await fetchDidAndCredential()
} finally {
await disconnect()
}

await connectToPeregrine()
try {
await fetchDidAndCredential()
Expand Down
4 changes: 2 additions & 2 deletions docs/develop/01_sdk/01_quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ The next step is to see if `kiltnerd123` has any publicly linked KILT credential
A **KILT DID** can expose services that allow external resources to be linked to the DID.
**KILT credentials** represent one type of external resource.

You can retrieve the **services** attached to John Doe's DID and see if they link to any public credentials to **query** and **verify**.
You can retrieve the **services** attached to kiltnerd123's DID and see if they link to any public credentials to **query** and **verify**.

Add the following code after the code you added in the previous step but before the `await Kilt.disconnect()`.
It retrieves the services exposed by the DID found for `kiltnerd123`:
Expand Down Expand Up @@ -217,7 +217,7 @@ className="language-ts"
{VerifyCredential}
</SnippetBlock>

Run the code and wait to see if you can retrieve **and** verify one of John Doe's credentials!
Run the code and wait to see if you can retrieve **and** verify one of kiltnerd123's credentials!

:::info Next steps

Expand Down
Loading