Expand identity derive fields (incl. all) (#1680)
This commit is contained in:
@@ -9,11 +9,19 @@ import { DeriveAccountInfo, DeriveAccountRegistration } from '../types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { Bytes, Option, u32 } from '@polkadot/types';
|
||||
import { Bytes, Data, Option, u32 } from '@polkadot/types';
|
||||
import { u8aToString } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
function dataAsString (data: Data): string | undefined {
|
||||
return data.isRaw
|
||||
? u8aToString(data.asRaw.toU8a(true))
|
||||
: data.isSha256
|
||||
? data.asSha256.toHex()
|
||||
: undefined;
|
||||
}
|
||||
|
||||
function retrieveNick (api: ApiInterfaceRx, accountId?: AccountId): Observable<string | undefined> {
|
||||
return ((
|
||||
accountId && api.query.nicks?.nameOf
|
||||
@@ -42,9 +50,15 @@ function retrieveIdentity (api: ApiInterfaceRx, accountId?: AccountId): Observab
|
||||
const { info, judgements } = identityOfOpt.unwrap();
|
||||
|
||||
return {
|
||||
displayName: info.display.isRaw
|
||||
? u8aToString(info.display.asRaw.toU8a(true))
|
||||
display: dataAsString(info.display),
|
||||
email: dataAsString(info.email),
|
||||
image: dataAsString(info.image),
|
||||
legal: dataAsString(info.legal),
|
||||
pgp: info.pgpFingerprint.isSome
|
||||
? info.pgpFingerprint.unwrap().toHex()
|
||||
: undefined,
|
||||
riot: dataAsString(info.riot),
|
||||
web: dataAsString(info.web),
|
||||
judgements
|
||||
};
|
||||
})
|
||||
|
||||
@@ -10,7 +10,13 @@ import { u32, Vec } from '@polkadot/types';
|
||||
export type AccountIndexes = Record<string, AccountIndex>;
|
||||
|
||||
export interface DeriveAccountRegistration {
|
||||
displayName?: string;
|
||||
display?: string;
|
||||
email?: string;
|
||||
image?: string;
|
||||
legal?: string;
|
||||
pgp?: string;
|
||||
riot?: string;
|
||||
web?: string;
|
||||
judgements: RegistrationJudgement[];
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import { isString, isU8a, u8aToU8a } from '@polkadot/util';
|
||||
import Enum from '../codec/Enum';
|
||||
import { createType } from '../codec/create/createType';
|
||||
import Bytes from './Bytes';
|
||||
import H256 from './H256';
|
||||
|
||||
function decodeDataU8a (registry: Registry, value: Uint8Array): [any, number | undefined] {
|
||||
if (!value.length) {
|
||||
@@ -66,10 +67,18 @@ export default class Data extends Enum {
|
||||
return this.raw as Bytes;
|
||||
}
|
||||
|
||||
get asSha256 (): H256 {
|
||||
return this.raw as H256;
|
||||
}
|
||||
|
||||
get isRaw (): boolean {
|
||||
return this.index === 1;
|
||||
}
|
||||
|
||||
get isSha256 (): boolean {
|
||||
return this.index === 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The encoded length
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user