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

chore: fellowship identities derived read example #1102

Merged
merged 1 commit into from
Jun 23, 2023
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
26 changes: 26 additions & 0 deletions examples/read/fellowship_identities.eg.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* @title Read Polkadot Identities of Fellowship Members
* @description Read the collectives chain fellowship member public keys.
* Then use those keys to read their identities on Polkadot.
*/

import { collectives } from "@capi/collectives"
import { $registration, polkadot } from "@capi/polkadot"
import { $, ArrayRune } from "capi"

/// Reference the total number of members.
const limit = collectives.FellowshipCollective.MemberCount.value(0)

/// Reference the `Members` map keys.
const members = collectives.FellowshipCollective.Members.keys({ limit })

/// For each member, retrieve the associated `Registration` (or `undefined`)
/// from Polkadot's Identity pallet storage.
const memberIdentities = await members
.into(ArrayRune)
.mapArray((member) => polkadot.Identity.IdentityOf.value(member))
.run()

/// Ensure the result is as expected.
console.log(memberIdentities)
$.assert($.array($.option($registration)), memberIdentities)
2 changes: 1 addition & 1 deletion import_map.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"imports": {
"@capi/": "http://localhost:4646/d5de72ca4087cd41/"
"@capi/": "http://localhost:4646/ed956cd5bde67584/"
},
"scopes": {
"examples/": {
Expand Down
4 changes: 4 additions & 0 deletions nets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,7 @@ export const rococoDevXcmStatemine = rococoDevXcm.parachain({
chain: "statemine-local",
id: 1000,
})

export const collectives = net.ws({
url: "wss://collectives.api.onfinality.io/public-ws",
})
1 change: 1 addition & 0 deletions words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ multihash
multisigs
noninteractive
offchain
onfinality
parachain
parachains
paritydb
Expand Down