Skip to content
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

Update ManageIdentity #914

Closed
Closed
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
24 changes: 18 additions & 6 deletions packages/extension-polkagate/src/popup/manageIdentity/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ export type SubIdsParams = (string | Data | undefined)[][] | undefined;
export type IdJudgement = 'Reasonable' | 'KnownGood' | 'FeePaid' | null | undefined;

function getRawValue(value: Data) {
const text = u8aToString(value.asRaw.toU8a(true));
// const text = u8aToString(value.asRaw.toU8a(true));
const text = value.Raw as unknown as string;

return text === ''
? undefined
Expand Down Expand Up @@ -181,7 +182,19 @@ export default function ManageIdentity(): React.ReactElement {
api?.query.identity.identityOf(address)
.then((id) => {
if (!id.isEmpty) {
const { info, judgements } = id.unwrap() as PalletIdentityRegistration;
const IdToHuman = id.toHuman() as string[];

if (!IdToHuman) {
setIdentity(null);
setRefresh(false);
setFetching(false);

return;
}

const _IdToHuman = IdToHuman?.[0] || IdToHuman;

const { info, judgements } = _IdToHuman as unknown as PalletIdentityRegistration;

const idToSet: DeriveAccountRegistration | null = {
display: getRawValue(info.display),
Expand All @@ -194,16 +207,15 @@ export default function ManageIdentity(): React.ReactElement {
judgements
};

if (judgements.isEmpty) {
if (judgements.length === 0) {
setIdJudgement(null);
} else {
const judgementInHuman = judgements.toHuman();
const judgementType = judgementInHuman[0][1] as string;
const judgementType = judgements[0][1] as unknown as string;

if (['Reasonable', 'KnownGood'].includes(judgementType)) {
setIdJudgement(judgementType as 'Reasonable' | 'KnownGood');
} else {
const feePaidReg = judgementInHuman[0][0] as string;
const feePaidReg = judgements[0][0] as unknown as string;

setIdJudgement('FeePaid');
setSelectedRegistrar(feePaidReg);
Expand Down