Skip to main content

Guardian

Usage scenario: guardian management

Detailed functions

  • View guardian list
  • Set or remove login guardian
  • Add, edit, or remove guardian

UI

Display the guardian list of the current account

Example: a list that contains four types of guardians, i.e. Google account, Telegram, Apple ID, and email.

Add guardians

  • Select guarfian type: Google account, Telegram, Apple ID, and email
  • Select verifier

Guardian details

Set the current guardian as a login guardian or remove it

Edit Guardians

  • Can only change the verifier of the guardian
  • Remove the guardian

Guardian

Manage the current account's guardians, integrating GuardianPageList, GuardianAdd, GuardianView, and GuardianEdit

Usage

import { Guardian } from "@portkey/did-ui-react";

const App = () => (
<Guardian
caHash={"xxxxxxx"}
originChainId={"AELF"}
accelerateChainId={"tDVV"}
onBack={() => {
// back callback
}}
networkType="MAINNET"
/>
);

export default App;

API

PropertyDescriptionTypeDefaultVersion
caHashcaHash of the Portkey accountstring-V1.5.1
classNameCustomised class namestring-V1.5.1
originChainIdID of the chain where user account is registeredChainId-V1.5.1
accelerateChainIdID of the chain where synchronisation of guardian is accelerated, done by initiating a transaction to quickly add the guardianChainId-V1.5.1
chainTypeChainTypeaelfV1.5.1
isErrorTipIs error tip set as defaultbooleantrueV1.5.1
onErrorCallback of error(error: {errorFields:string, error: any}) => void-V1.5.1
onBackCallback of back() => void-V1.5.1
networkTypeNetwork typeMAINNET | TESTNET-V2.0.0

Guardian Page List

Dsiplay the guardian list of the current account

Usage

import { GuardianPageList } from "@portkey/did-ui-react";

const App = () => (
<GuardianPageList
header={<div>Guardian List Header</div>}
guardianList={[
{
isLoginGuardian: true,
verifier: {
endPoints: ["your endPoints"],
verifierAddresses: ["your verifierAddresses"],
id: "your verifier id",
name: "your verifier name",
imageUrl: "your verifier imageUrl",
},
identifier: "identifier",
guardianType: "Phone",
key: "",
},
]}
onViewGuardian={(item: UserGuardianStatus) => {
// view guardian item
}}
/>
);

export default App;

API

PropertyDescriptionTypeDefaultVersion
headerHeader UI componentReactNode-V1.5.1
classNameCustomised class namestring-V1.5.1
guardianListGuardian list of the current accountUserGuardianStatus[]-V1.5.1
tipContainerCustomized contentReactNode-V2.0.0
onViewGuardianCallback when guardian item is clicked(item: UserGuardianStatus) => void-V1.5.1

Guardian Add

Add guardian

Usage

import { GuardianAdd } from '@portkey/did-ui-react';

const verifierList = [{
id: "594ebf...94b76b"
imageUrl: "https://xxx/Portkey.png"
name: "Portkey"
}];
const guardianList = [
{
isLoginGuardian: true,
verifier: {
endPoints: ['your endPoints'],
verifierAddresses: ['your verifierAddresses'],
id: 'your verifier id',
name: 'your verifier name',
imageUrl: 'your verifier imageUrl',
},
identifier: 'identifier',
guardianType: 'Phone',
key: '',
},
];

const App = () => (
<GuardianAdd
header={<div>Guardian Add Header</div>}
originChainId="AELF"
verifierList={verifierList}
guardianList={guardianList}
handleAddGuardian={function() {
// to add guardian
}}
/>
);

export default App;

API

PropertyDescriptionTypeDefaultVersion
headerHeader UI componentReactNode-V1.5.1
classNameCustomised class namestring-V1.5.1
caHashcaHash of the Portkey accountstring-V2.0.0
originChainIdID of the chain where user account is registeredChainId-V1.5.1
chainTypeChainType-V2.0.0
phoneCountryCountry calling codeIPhoneCountry-V1.5.1
guardianListGuardian list of the current accountUserGuardianStatus[]-V1.5.1
verifierListList of verifiers supportedVerifierItem[]-V1.5.1
networkTypeNetwork typeMAINNET | TESTNET-V2.0.0
sandboxIdstring-V2.0.0
isErrorTipIs error tip set as defaultbooleantrueV1.5.1
onErrorCallback of error(error: {errorFields:string, error: any}) => void-V1.5.1
handleAddGuardianExecute contract method that adds guardian(currentGuardian: UserGuardianStatus, approvalInfo: GuardiansApproved[]) => Promise\<any>-V1.5.1

Guardian View

View guardian item

Usage

import { GuardianView } from "@portkey/did-ui-react";

const currentGuardian = {
isLoginGuardian: true,
verifier: {
endPoints: ["your endPoints"],
verifierAddresses: ["your verifierAddresses"],
id: "your verifier id",
name: "your verifier name",
imageUrl: "your verifier imageUrl",
},
identifier: "identifier",
guardianType: "Phone",
key: "",
};
const guardianList = [
{
isLoginGuardian: true,
verifier: {
endPoints: ["your endPoints"],
verifierAddresses: ["your verifierAddresses"],
id: "your verifier id",
name: "your verifier name",
imageUrl: "your verifier imageUrl",
},
identifier: "identifier",
guardianType: "Phone",
key: "",
},
];

const App = () => (
<GuardianView
networkType="MAINNET"
header={<div>Guardian View Header</div>}
currentGuardian={currentGuardian}
handleSetLoginGuardian={async (
currentGuardian: UserGuardianStatus,
approvalInfo: GuardiansApproved[]
) => {
// operate set login guardian
}}
guardianList={guardianList}
/>
);

export default App;

API

PropertyDescriptionTypeDefaultVersion
headerHeader UI componentReactNode-V1.5.1
classNameCustomised class namestring-V1.5.1
originChainIdID of the chain where user account is registeredChainId-V1.5.1
currentGuardianCurrent guardian itemUserGuardianStatus-V1.5.1
guardianListGuardian list of the current accountUserGuardianStatus[]-V1.5.1
networkTypeNetwork typeMAINNET | TESTNET-V2.0.0
isErrorTipIs error tip set as defaultbooleantrueV1.5.1
onErrorCallback of error(error: {errorFields:string, error: any}) => void-V1.5.1
onEditGuardianExecute contract method that edits guardian() => void-V1.5.1
handleSetLoginGuardianExecute contract method that sets or removes guardian(currentGuardian: UserGuardianStatus, approvalInfo: GuardiansApproved[]) => Promise\<any>-V2.0.0

Guardian Edit

Edit guardian item

Usage

import { GuardianEdit } from '@portkey/did-ui-react';

const verifierList = [{
id: "594ebf...94b76b"
imageUrl: "https://xxx/Portkey.png"
name: "Portkey"
}];
const currentGuardian = {
isLoginGuardian: true,
verifier: {
endPoints: ['your endPoints'],
verifierAddresses: ['your verifierAddresses'],
id: 'your verifier id',
name: 'your verifier name',
imageUrl: 'your verifier imageUrl',
},
identifier: 'identifier',
guardianType: 'Phone',
key: '',
};
const guardianList = [
{
isLoginGuardian: true,
verifier: {
endPoints: ['your endPoints'],
verifierAddresses: ['your verifierAddresses'],
id: 'your verifier id',
name: 'your verifier name',
imageUrl: 'your verifier imageUrl',
},
identifier: 'identifier',
guardianType: 'Phone',
key: '',
},
];
const preGuardian = {
isLoginGuardian: true,
verifier: {
endPoints: ['your endPoints'],
verifierAddresses: ['your verifierAddresses'],
id: 'your verifier id',
name: 'your verifier name',
imageUrl: 'your verifier imageUrl',
},
identifier: 'identifier',
guardianType: 'Phone',
key: '',
};

const App = () => (
<GuardianEdit
caHash="cahash"
networkType="MAINNET"
header={<div>Guardian Edit Header</div>}
verifierList={verifierList}
currentGuardian={currentGuardian}
guardianList={guardianList}
preGuardian={preGuardian}
handleEditGuardian={async (currentGuardian: UserGuardianStatus, approvalInfo: GuardiansApproved[]) => {
// update current guardian
}}
handleRemoveGuardian={async (approvalInfo: GuardiansApproved[]) => {
// remove current guardian
}}
handleSetLoginGuardian={async (currentGuardian: UserGuardianStatus, approvalInfo: GuardiansApproved[]) => {
// set or unset login guardian
}}
/>
);

export default App;

API

PropertyDescriptionTypeDefaultVersion
headerHeader UI componentReactNode-V1.5.1
classNameCustomised class namestring-V1.5.1
originChainIdID of the chain where user account is registeredChainId-V1.5.1
caHashcaHash of the Portkey accountstring-V2.0.0
chainTypeChainTypeaelfV2.0.0
sandboxIdstring-V2.0.0
networkTypeNetwork typeMAINNET | TESTNET-V2.0.0
currentGuardianGuardian item after the editUserGuardianStatus-V1.5.1
preGuardianCurrent guardian itemUserGuardianStatus-V1.5.1
guardianListGuardian list of the current accountUserGuardianStatus[]-V1.5.1
verifierListList of verifiers supportedVerifierItem[]-V1.5.1
isErrorTipIs error tip set as defaultbooleantrueV1.5.1
onErrorCallback of error(error: {errorFields:string, error: any}) => void-V1.5.1
handleEditGuardianExecute contract method that edits guardian(currentGuardian: UserGuardianStatus, approvalInfo: GuardiansApproved[]) => Promise\<any>-V1.5.1
handleRemoveGuardianExecute contract method that removes guardian(approvalInfo: GuardiansApproved[]) => Promise\<any>-V1.5.1
handleSetLoginGuardianExecute contract method that sets or cancels guardian(currentGuardian: UserGuardianStatus, approvalInfo: GuardiansApproved[]) => Promise\<any>;-V2.0.0