Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

feat: add kilt example #1114

Merged
merged 11 commits into from
Jul 7, 2023
Merged

feat: add kilt example #1114

merged 11 commits into from
Jul 7, 2023

Conversation

kratico
Copy link
Contributor

@kratico kratico commented Jun 28, 2023

No description provided.

Copy link
Contributor

@harrysolovay harrysolovay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually... perhaps examples/read/kilt.eg.ts for now?

@kratico
Copy link
Contributor Author

kratico commented Jun 28, 2023

Example to get the first 10 owners

import { $didPublicKeyDetails, spiritnet } from "@capi/spiritnet"
import { $, ArrayRune, is } from "capi"
import { equals } from "../../deps/std/bytes.ts"

const didPublicKeyDetails = await spiritnet.Web3Names.Owner
  .entries({ limit: 10 })
  .into(ArrayRune)
  .mapArray((entry) =>
    spiritnet.Did.Did
      .value(entry.access(1, "owner"))
      .unhandle(is(undefined))
      .map(({ authenticationKey, publicKeys }) =>
        [...publicKeys.entries()].find(([k, _v]) => equals(k, authenticationKey))
      )
      .unhandle(is(undefined))
  )
  .run()

console.log("DID public key details:", didPublicKeyDetails)
$.assert($.array($.tuple($.sizedUint8Array(32), $didPublicKeyDetails)), didPublicKeyDetails)

@harrysolovay harrysolovay added this pull request to the merge queue Jul 7, 2023
Merged via the queue into main with commit f96ad89 Jul 7, 2023
@harrysolovay harrysolovay deleted the feat/spiritnet-example branch July 7, 2023 15:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants