Skip to content

Commit

Permalink
metatdata update companion for pallet-identity update
Browse files Browse the repository at this point in the history
  • Loading branch information
smohan-dw committed Mar 21, 2024
1 parent b38fca1 commit 6964ff2
Show file tree
Hide file tree
Showing 10 changed files with 802 additions and 447 deletions.
3 changes: 2 additions & 1 deletion demo/src/utils/createRegistrar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ export async function provideJudgement(
const api = Cord.ConfigService.get('api')

const identityInfos = await api.query.identity.identityOf(account)
const identityHash = identityInfos.unwrap().info.hash.toHex()
const [registration, _additionalData] = identityInfos.unwrap()

const identityHash = registration.info.hash.toHex()
const callTx = api.tx.identity.provideJudgement(
account,
'Reasonable',
Expand Down
2 changes: 1 addition & 1 deletion packages/augment-api/metadata/cord.json

Large diffs are not rendered by default.

22 changes: 16 additions & 6 deletions packages/augment-api/src/interfaces/augment-api-consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,27 @@ declare module '@polkadot/api-base/types/consts' {
maxEventsHistory: u32 & AugmentedConst<ApiType>;
};
identity: {
/**
* Maximum number of additional fields that may be stored in an ID.
* Needed to bound the I/O required to access an identity, but can be
* pretty high.
**/
maxAdditionalFields: u32 & AugmentedConst<ApiType>;
/**
* Maxmimum number of registrars allowed in the system. Needed to bound
* the complexity of, e.g., updating judgements.
**/
maxRegistrars: u32 & AugmentedConst<ApiType>;
/**
* The maximum number of sub-accounts allowed per identified account.
**/
maxSubAccounts: u32 & AugmentedConst<ApiType>;
/**
* The maximum length of a suffix.
**/
maxSuffixLength: u32 & AugmentedConst<ApiType>;
/**
* The maximum length of a username, including its suffix and any system-added delimiters.
**/
maxUsernameLength: u32 & AugmentedConst<ApiType>;
/**
* The number of blocks within which a username grant must be accepted.
**/
pendingUsernameExpiration: u32 & AugmentedConst<ApiType>;
};
imOnline: {
/**
Expand Down
48 changes: 48 additions & 0 deletions packages/augment-api/src/interfaces/augment-api-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,10 +538,22 @@ declare module '@polkadot/api-base/types/errors' {
* Invalid judgement.
**/
InvalidJudgement: AugmentedError<ApiType>;
/**
* The signature on a username was not valid.
**/
InvalidSignature: AugmentedError<ApiType>;
/**
* The provided suffix is too long.
**/
InvalidSuffix: AugmentedError<ApiType>;
/**
* The target is invalid.
**/
InvalidTarget: AugmentedError<ApiType>;
/**
* The username does not meet the requirements.
**/
InvalidUsername: AugmentedError<ApiType>;
/**
* The provided judgement was for a different identity.
**/
Expand All @@ -554,10 +566,18 @@ declare module '@polkadot/api-base/types/errors' {
* Error that occurs when there is an issue paying for judgement.
**/
JudgementPaymentFailed: AugmentedError<ApiType>;
/**
* The authority cannot allocate any more usernames.
**/
NoAllocation: AugmentedError<ApiType>;
/**
* No identity found.
**/
NoIdentity: AugmentedError<ApiType>;
/**
* The username cannot be forcefully removed because it can still be accepted.
**/
NotExpired: AugmentedError<ApiType>;
/**
* Account isn't found.
**/
Expand All @@ -566,6 +586,22 @@ declare module '@polkadot/api-base/types/errors' {
* Account isn't named.
**/
NotNamed: AugmentedError<ApiType>;
/**
* Sub-account isn't owned by sender.
**/
NotOwned: AugmentedError<ApiType>;
/**
* Sender is not a sub-account.
**/
NotSub: AugmentedError<ApiType>;
/**
* The sender does not have permission to issue a username.
**/
NotUsernameAuthority: AugmentedError<ApiType>;
/**
* The requested username does not exist.
**/
NoUsername: AugmentedError<ApiType>;
/**
* Registrar already exists.
**/
Expand All @@ -574,6 +610,10 @@ declare module '@polkadot/api-base/types/errors' {
* Registrar not found.
**/
RegistrarNotFound: AugmentedError<ApiType>;
/**
* Setting this username requires a signature, but none was provided.
**/
RequiresSignature: AugmentedError<ApiType>;
/**
* Sticky judgement.
**/
Expand All @@ -586,6 +626,14 @@ declare module '@polkadot/api-base/types/errors' {
* Maximum amount of registrars reached. Cannot add any more.
**/
TooManyRegistrars: AugmentedError<ApiType>;
/**
* Too many subs-accounts.
**/
TooManySubAccounts: AugmentedError<ApiType>;
/**
* The username is already taken.
**/
UsernameTaken: AugmentedError<ApiType>;
};
imOnline: {
/**
Expand Down
42 changes: 42 additions & 0 deletions packages/augment-api/src/interfaces/augment-api-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,19 @@ declare module '@polkadot/api-base/types/events' {
Resumed: AugmentedEvent<ApiType, []>;
};
identity: {
/**
* A username authority was added.
**/
AuthorityAdded: AugmentedEvent<ApiType, [authority: AccountId32], { authority: AccountId32 }>;
/**
* A username authority was removed.
**/
AuthorityRemoved: AugmentedEvent<ApiType, [authority: AccountId32], { authority: AccountId32 }>;
/**
* A dangling username (as in, a username corresponding to an account that has removed its
* identity) has been removed.
**/
DanglingUsernameRemoved: AugmentedEvent<ApiType, [who: AccountId32, username: Bytes], { who: AccountId32, username: Bytes }>;
/**
* A name was cleared, and the given balance returned.
**/
Expand All @@ -362,6 +375,14 @@ declare module '@polkadot/api-base/types/events' {
* A judgement request was retracted.
**/
JudgementUnrequested: AugmentedEvent<ApiType, [who: AccountId32, registrar: AccountId32], { who: AccountId32, registrar: AccountId32 }>;
/**
* A queued username passed its expiration without being claimed and was removed.
**/
PreapprovalExpired: AugmentedEvent<ApiType, [whose: AccountId32], { whose: AccountId32 }>;
/**
* A username was set as a primary and can be looked up from `who`.
**/
PrimaryUsernameSet: AugmentedEvent<ApiType, [who: AccountId32, username: Bytes], { who: AccountId32, username: Bytes }>;
/**
* A registrar was added.
**/
Expand All @@ -370,6 +391,27 @@ declare module '@polkadot/api-base/types/events' {
* A registrar was removed.
**/
RegistrarRemoved: AugmentedEvent<ApiType, [registrar: AccountId32], { registrar: AccountId32 }>;
/**
* A sub-identity was added to an identity and the deposit paid.
**/
SubIdentityAdded: AugmentedEvent<ApiType, [sub: AccountId32, main: AccountId32], { sub: AccountId32, main: AccountId32 }>;
/**
* A sub-identity was removed from an identity and the deposit freed.
**/
SubIdentityRemoved: AugmentedEvent<ApiType, [sub: AccountId32, main: AccountId32], { sub: AccountId32, main: AccountId32 }>;
/**
* A sub-identity was cleared, and the given deposit repatriated from the
* main identity account to the sub-identity account.
**/
SubIdentityRevoked: AugmentedEvent<ApiType, [sub: AccountId32, main: AccountId32], { sub: AccountId32, main: AccountId32 }>;
/**
* A username was queued, but `who` must accept it prior to `expiration`.
**/
UsernameQueued: AugmentedEvent<ApiType, [who: AccountId32, username: Bytes, expiration: u32], { who: AccountId32, username: Bytes, expiration: u32 }>;
/**
* A username was set for `who`.
**/
UsernameSet: AugmentedEvent<ApiType, [who: AccountId32, username: Bytes], { who: AccountId32, username: Bytes }>;
};
imOnline: {
/**
Expand Down
39 changes: 37 additions & 2 deletions packages/augment-api/src/interfaces/augment-api-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
import '@polkadot/api-base/types/storage';

import type { ApiTypes, AugmentedQuery, QueryableStorageEntry } from '@polkadot/api-base/types';
import type { Data } from '@polkadot/types';
import type { BTreeSet, Bytes, Null, Option, U8aFixed, Vec, bool, u128, u32, u64 } from '@polkadot/types-codec';
import type { AnyNumber, ITuple } from '@polkadot/types-codec/types';
import type { OpaquePeerId } from '@polkadot/types/interfaces/imOnline';
import type { AccountId32, Call, H256 } from '@polkadot/types/interfaces/runtime';
import type { CordIdentifierEventEntry, CordIdentifierIdentifierTypeOf, CordRuntimeSessionKeys, FrameSupportDispatchPerDispatchClassWeight, FrameSystemAccountInfo, FrameSystemCodeUpgradeAuthorization, FrameSystemEventRecord, FrameSystemLastRuntimeUpgradeInfo, FrameSystemPhase, PalletAssetAssetDistributionEntry, PalletAssetAssetEntry, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesIdAmountRuntimeFreezeReason, PalletBalancesIdAmountRuntimeHoldReason, PalletBalancesReserveData, PalletChainSpaceSpaceAuthorization, PalletChainSpaceSpaceDetails, PalletCollectiveVotes, PalletDidDidDetails, PalletDidNameDidNameDidNameOwnership, PalletDidServiceEndpointsDidEndpoint, PalletGrandpaStoredPendingChange, PalletGrandpaStoredState, PalletIdentityRegistrarInfo, PalletIdentityRegistration, PalletImOnlineSr25519AppSr25519Public, PalletMultisigMultisig, PalletNetworkMembershipMemberData, PalletNetworkScoreAggregatedEntryOf, PalletNetworkScoreRatingEntry, PalletNetworkScoreRatingTypeOf, PalletNodeAuthorizationNodeInfo, PalletPreimageOldRequestStatus, PalletPreimageRequestStatus, PalletSchedulerRetryConfig, PalletSchedulerScheduled, PalletSchemaSchemaEntry, PalletStatementStatementDetails, PalletStatementStatementEntryStatus, PalletStatementStatementPresentationDetails, SpAuthorityDiscoveryAppPublic, SpConsensusBabeAppPublic, SpConsensusBabeBabeEpochConfiguration, SpConsensusBabeDigestsNextConfigDescriptor, SpConsensusBabeDigestsPreDigest, SpConsensusGrandpaAppPublic, SpCoreCryptoKeyTypeId, SpRuntimeDigest, SpStakingOffenceOffenceDetails } from '@polkadot/types/lookup';
import type { CordIdentifierEventEntry, CordIdentifierIdentifierTypeOf, CordRuntimeSessionKeys, FrameSupportDispatchPerDispatchClassWeight, FrameSystemAccountInfo, FrameSystemCodeUpgradeAuthorization, FrameSystemEventRecord, FrameSystemLastRuntimeUpgradeInfo, FrameSystemPhase, PalletAssetAssetDistributionEntry, PalletAssetAssetEntry, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesIdAmountRuntimeFreezeReason, PalletBalancesIdAmountRuntimeHoldReason, PalletBalancesReserveData, PalletChainSpaceSpaceAuthorization, PalletChainSpaceSpaceDetails, PalletCollectiveVotes, PalletDidDidDetails, PalletDidNameDidNameDidNameOwnership, PalletDidServiceEndpointsDidEndpoint, PalletGrandpaStoredPendingChange, PalletGrandpaStoredState, PalletIdentityAuthorityProperties, PalletIdentityRegistrarInfo, PalletIdentityRegistration, PalletImOnlineSr25519AppSr25519Public, PalletMultisigMultisig, PalletNetworkMembershipMemberData, PalletNetworkScoreAggregatedEntryOf, PalletNetworkScoreRatingEntry, PalletNetworkScoreRatingTypeOf, PalletNodeAuthorizationNodeInfo, PalletPreimageOldRequestStatus, PalletPreimageRequestStatus, PalletSchedulerRetryConfig, PalletSchedulerScheduled, PalletSchemaSchemaEntry, PalletStatementStatementDetails, PalletStatementStatementEntryStatus, PalletStatementStatementPresentationDetails, SpAuthorityDiscoveryAppPublic, SpConsensusBabeAppPublic, SpConsensusBabeBabeEpochConfiguration, SpConsensusBabeDigestsNextConfigDescriptor, SpConsensusBabeDigestsPreDigest, SpConsensusGrandpaAppPublic, SpCoreCryptoKeyTypeId, SpRuntimeDigest, SpStakingOffenceOffenceDetails } from '@polkadot/types/lookup';
import type { Observable } from '@polkadot/types/types';

export type __AugmentedQuery<ApiType extends ApiTypes> = AugmentedQuery<ApiType, () => unknown>;
Expand Down Expand Up @@ -381,15 +382,49 @@ declare module '@polkadot/api-base/types/storage' {
identifiers: AugmentedQuery<ApiType, (arg1: Bytes | string | Uint8Array, arg2: CordIdentifierIdentifierTypeOf | 'Asset' | 'Auth' | 'ChainSpace' | 'Did' | 'Rating' | 'Registry' | 'Statement' | 'Schema' | 'Template' | number | Uint8Array) => Observable<Option<Vec<CordIdentifierEventEntry>>>, [Bytes, CordIdentifierIdentifierTypeOf]>;
};
identity: {
/**
* Reverse lookup from `username` to the `AccountId` that has registered it. The value should
* be a key in the `IdentityOf` map, but it may not if the user has cleared their identity.
*
* Multiple usernames may map to the same `AccountId`, but `IdentityOf` will only map to one
* primary username.
**/
accountOfUsername: AugmentedQuery<ApiType, (arg: Bytes | string | Uint8Array) => Observable<Option<AccountId32>>, [Bytes]>;
/**
* Information that is pertinent to identify the entity behind an account.
**/
identityOf: AugmentedQuery<ApiType, (arg: AccountId32 | string | Uint8Array) => Observable<Option<PalletIdentityRegistration>>, [AccountId32]>;
identityOf: AugmentedQuery<ApiType, (arg: AccountId32 | string | Uint8Array) => Observable<Option<ITuple<[PalletIdentityRegistration, Option<Bytes>]>>>, [AccountId32]>;
/**
* Usernames that an authority has granted, but that the account controller has not confirmed
* that they want it. Used primarily in cases where the `AccountId` cannot provide a signature
* because they are a pure proxy, multisig, etc. In order to confirm it, they should call
* [`Call::accept_username`].
*
* First tuple item is the account and second is the acceptance deadline.
**/
pendingUsernames: AugmentedQuery<ApiType, (arg: Bytes | string | Uint8Array) => Observable<Option<ITuple<[AccountId32, u32]>>>, [Bytes]>;
/**
* The set of registrars. Not expected to get very big as can only be added
* through a special origin (likely a council motion).
**/
registrars: AugmentedQuery<ApiType, () => Observable<Vec<Option<PalletIdentityRegistrarInfo>>>, []>;
/**
* Alternative "sub" identities of this account.
*
* The first item is the deposit, the second is a vector of the accounts.
*
* TWOX-NOTE: OK ― `AccountId` is a secure hash.
**/
subsOf: AugmentedQuery<ApiType, (arg: AccountId32 | string | Uint8Array) => Observable<Vec<AccountId32>>, [AccountId32]>;
/**
* The super-identity of an alternative "sub" identity together with its name, within that
* context. If the account is not some other account's sub-identity, then just `None`.
**/
superOf: AugmentedQuery<ApiType, (arg: AccountId32 | string | Uint8Array) => Observable<Option<ITuple<[AccountId32, Data]>>>, [AccountId32]>;
/**
* A map of the accounts who are authorized to grant usernames.
**/
usernameAuthorities: AugmentedQuery<ApiType, (arg: AccountId32 | string | Uint8Array) => Observable<Option<PalletIdentityAuthorityProperties>>, [AccountId32]>;
};
imOnline: {
/**
Expand Down
Loading

0 comments on commit 6964ff2

Please sign in to comment.