Skip to content

Commit

Permalink
refactor!: remove queries for did, web3names, and didLookup in …
Browse files Browse the repository at this point in the history
…favor of the `api.call.didApi` call (#643)

* refactor!: remove queryWeb3Name

(cherry picked from commit cce62a6)

* wip: Add RPC support for DIDs

* wip: Add tests for RPC stuff

* wip: fix tests

* DidResolver unit tests passing

* Remove DID RPC file from test coverage

* Last fixes

* PR fixes

* Fix bundle tests

* Fix DID migration integration test case

* Fix failing account link integration tests

* Fix bundle tests

* Update metadata to latest-develop

* Update TS augmentation

* Fix lint issues

* Remove unnecessary dependencies

* Support DID runtime API versioning

* Fix TS augmentation

* Code compiling

* Fix dependencies

* Fixed integration tests

* Remove any web3name query stuff

* Remove leftovers of api.query.{did,web3Names,didLookup}

* Fix integration tests

* Fix unit tests

* Remove lint warning disable

Co-authored-by: Antonio Antonino <[email protected]>
  • Loading branch information
arty-name and ntn-x2 authored Oct 14, 2022
1 parent b6fc55f commit 3bc648a
Show file tree
Hide file tree
Showing 51 changed files with 2,069 additions and 2,013 deletions.
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ module.exports = {
'!utils/src/json-schema/*',
'!testing/**',
'!augment-api/**',
// TODO: write tests for these files and remove here
'!**/*.chain.ts',
'!did/src/Did.chain.ts',
'!did/src/Did.rpc.ts',
'!did/src/Did.utils.ts',
'!utils/src/jsonabc.ts',
],
Expand Down
2 changes: 1 addition & 1 deletion packages/augment-api/metadata/spiritnet.json

Large diffs are not rendered by default.

21 changes: 18 additions & 3 deletions packages/augment-api/src/interfaces/augment-api-consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import '@polkadot/api-base/types/consts';

import type { ApiTypes, AugmentedConst } from '@polkadot/api-base/types';
import type { Option, bool, u128, u16, u32, u64, u8 } from '@polkadot/types-codec';
import type { Percent, Permill, Perquintill } from '@polkadot/types/interfaces/runtime';
import type { Percent, Permill, Perquintill, Weight } from '@polkadot/types/interfaces/runtime';
import type { FrameSupportPalletId, FrameSupportWeightsRuntimeDbWeight, FrameSystemLimitsBlockLength, FrameSystemLimitsBlockWeights, SpVersionRuntimeVersion } from '@polkadot/types/lookup';

export type __AugmentedConst<ApiType extends ApiTypes> = AugmentedConst<ApiType>;
Expand Down Expand Up @@ -354,12 +354,27 @@ declare module '@polkadot/api-base/types/consts' {
**/
proxyDepositFactor: u128 & AugmentedConst<ApiType>;
};
publicCredentials: {
/**
* The amount of tokens to reserve when attesting a public credential.
**/
deposit: u128 & AugmentedConst<ApiType>;
/**
* The maximum length in bytes of the encoded claims of a credential.
**/
maxEncodedClaimsLength: u32 & AugmentedConst<ApiType>;
/**
* The maximum length in bytes of the raw credential subject
* identifier.
**/
maxSubjectIdLength: u32 & AugmentedConst<ApiType>;
};
scheduler: {
/**
* The maximum weight that may be scheduled per block for any dispatchables of less
* priority than `schedule::HARD_DEADLINE`.
**/
maximumWeight: u64 & AugmentedConst<ApiType>;
maximumWeight: Weight & AugmentedConst<ApiType>;
/**
* The maximum number of scheduled calls in the queue for a single block.
* Not strictly enforced, but used for weight estimation.
Expand All @@ -384,7 +399,7 @@ declare module '@polkadot/api-base/types/consts' {
**/
dbWeight: FrameSupportWeightsRuntimeDbWeight & AugmentedConst<ApiType>;
/**
* The designated SS85 prefix of this chain.
* The designated SS58 prefix of this chain.
*
* This replaces the "ss58Format" property declared in the chain spec. Reason is
* that the runtime should know about the prefix in order to make use of it as
Expand Down
31 changes: 28 additions & 3 deletions packages/augment-api/src/interfaces/augment-api-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,6 @@ declare module '@polkadot/api-base/types/errors' {
**/
Unknown: AugmentedError<ApiType>;
};
dynFilter: {
};
indices: {
/**
* The index was not available.
Expand Down Expand Up @@ -854,7 +852,34 @@ declare module '@polkadot/api-base/types/errors' {
**/
Unproxyable: AugmentedError<ApiType>;
};
relayMigration: {
publicCredentials: {
/**
* A credential with the same root hash has already issued to the
* specified subject.
**/
CredentialAlreadyIssued: AugmentedError<ApiType>;
/**
* No credential with the specified root hash has been issued to the
* specified subject.
**/
CredentialNotFound: AugmentedError<ApiType>;
/**
* Catch-all for any other errors that should not happen, yet it
* happened.
**/
InternalError: AugmentedError<ApiType>;
/**
* The credential input is invalid.
**/
InvalidInput: AugmentedError<ApiType>;
/**
* Not enough tokens to pay for the fees or the deposit.
**/
UnableToPayFees: AugmentedError<ApiType>;
/**
* The caller is not authorized to performed the operation.
**/
Unauthorized: AugmentedError<ApiType>;
};
scheduler: {
/**
Expand Down
47 changes: 26 additions & 21 deletions packages/augment-api/src/interfaces/augment-api-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import '@polkadot/api-base/types/events';
import type { ApiTypes, AugmentedEvent } from '@polkadot/api-base/types';
import type { Bytes, Null, Option, Result, U8aFixed, Vec, bool, u128, u16, u32, u64, u8 } from '@polkadot/types-codec';
import type { ITuple } from '@polkadot/types-codec/types';
import type { AccountId32, H256, Perquintill } from '@polkadot/types/interfaces/runtime';
import type { DelegationDelegationHierarchyPermissions, FrameSupportScheduleLookupError, FrameSupportTokensMiscBalanceStatus, FrameSupportWeightsDispatchInfo, PalletDemocracyVoteAccountVote, PalletDemocracyVoteThreshold, PalletDynFilterSettingFilterSettings, RuntimeCommonAuthorizationAuthorizationId, SpRuntimeDispatchError, SpiritnetRuntimeProxyType, XcmV1MultiLocation, XcmV2Response, XcmV2TraitsError, XcmV2TraitsOutcome, XcmV2Xcm, XcmVersionedMultiAssets, XcmVersionedMultiLocation } from '@polkadot/types/lookup';
import type { AccountId32, H256, Perquintill, Weight } from '@polkadot/types/interfaces/runtime';
import type { DelegationDelegationHierarchyPermissions, FrameSupportScheduleLookupError, FrameSupportTokensMiscBalanceStatus, FrameSupportWeightsDispatchInfo, PalletDemocracyVoteAccountVote, PalletDemocracyVoteThreshold, PalletDidLookupLinkableAccountLinkableAccountId, RuntimeCommonAssetsAssetDid, RuntimeCommonAuthorizationAuthorizationId, SpRuntimeDispatchError, SpiritnetRuntimeProxyType, XcmV1MultiLocation, XcmV2Response, XcmV2TraitsError, XcmV2TraitsOutcome, XcmV2Xcm, XcmVersionedMultiAssets, XcmVersionedMultiLocation } from '@polkadot/types/lookup';

export type __AugmentedEvent<ApiType extends ApiTypes> = AugmentedEvent<ApiType>;

Expand Down Expand Up @@ -283,11 +283,11 @@ declare module '@polkadot/api-base/types/events' {
/**
* A new association between a DID and an account ID was created.
**/
AssociationEstablished: AugmentedEvent<ApiType, [AccountId32, AccountId32]>;
AssociationEstablished: AugmentedEvent<ApiType, [PalletDidLookupLinkableAccountLinkableAccountId, AccountId32]>;
/**
* An association between a DID and an account ID was removed.
**/
AssociationRemoved: AugmentedEvent<ApiType, [AccountId32, AccountId32]>;
AssociationRemoved: AugmentedEvent<ApiType, [PalletDidLookupLinkableAccountLinkableAccountId, AccountId32]>;
};
dmpQueue: {
/**
Expand All @@ -301,22 +301,19 @@ declare module '@polkadot/api-base/types/events' {
/**
* Downward message is overweight and was placed in the overweight queue.
**/
OverweightEnqueued: AugmentedEvent<ApiType, [messageId: U8aFixed, overweightIndex: u64, requiredWeight: u64], { messageId: U8aFixed, overweightIndex: u64, requiredWeight: u64 }>;
OverweightEnqueued: AugmentedEvent<ApiType, [messageId: U8aFixed, overweightIndex: u64, requiredWeight: Weight], { messageId: U8aFixed, overweightIndex: u64, requiredWeight: Weight }>;
/**
* Downward message from the overweight queue was executed.
**/
OverweightServiced: AugmentedEvent<ApiType, [overweightIndex: u64, weightUsed: u64], { overweightIndex: u64, weightUsed: u64 }>;
OverweightServiced: AugmentedEvent<ApiType, [overweightIndex: u64, weightUsed: Weight], { overweightIndex: u64, weightUsed: Weight }>;
/**
* Downward message is unsupported version of XCM.
**/
UnsupportedVersion: AugmentedEvent<ApiType, [messageId: U8aFixed], { messageId: U8aFixed }>;
/**
* The weight limit for handling downward messages was reached.
**/
WeightExhausted: AugmentedEvent<ApiType, [messageId: U8aFixed, remainingWeight: u64, requiredWeight: u64], { messageId: U8aFixed, remainingWeight: u64, requiredWeight: u64 }>;
};
dynFilter: {
NewFilterRules: AugmentedEvent<ApiType, [rules: PalletDynFilterSettingFilterSettings], { rules: PalletDynFilterSettingFilterSettings }>;
WeightExhausted: AugmentedEvent<ApiType, [messageId: U8aFixed, remainingWeight: Weight, requiredWeight: Weight], { messageId: U8aFixed, remainingWeight: Weight, requiredWeight: Weight }>;
};
indices: {
/**
Expand Down Expand Up @@ -456,7 +453,7 @@ declare module '@polkadot/api-base/types/events' {
/**
* Downward messages were processed using the given weight.
**/
DownwardMessagesProcessed: AugmentedEvent<ApiType, [weightUsed: u64, dmqHead: H256], { weightUsed: u64, dmqHead: H256 }>;
DownwardMessagesProcessed: AugmentedEvent<ApiType, [weightUsed: Weight, dmqHead: H256], { weightUsed: Weight, dmqHead: H256 }>;
/**
* Some downward messages have been received and will be processed.
**/
Expand Down Expand Up @@ -540,7 +537,7 @@ declare module '@polkadot/api-base/types/events' {
*
* \[ id, pallet index, call index, actual weight, max budgeted weight \]
**/
NotifyOverweight: AugmentedEvent<ApiType, [u64, u8, u8, u64, u64]>;
NotifyOverweight: AugmentedEvent<ApiType, [u64, u8, u8, Weight, Weight]>;
/**
* A given location which had a version change subscription was dropped owing to an error
* migrating the location to our new XCM format.
Expand Down Expand Up @@ -633,15 +630,23 @@ declare module '@polkadot/api-base/types/events' {
**/
ProxyRemoved: AugmentedEvent<ApiType, [delegator: AccountId32, delegatee: AccountId32, proxyType: SpiritnetRuntimeProxyType, delay: u64], { delegator: AccountId32, delegatee: AccountId32, proxyType: SpiritnetRuntimeProxyType, delay: u64 }>;
};
relayMigration: {
publicCredentials: {
/**
* A public credentials has been removed.
**/
CredentialRemoved: AugmentedEvent<ApiType, [subjectId: RuntimeCommonAssetsAssetDid, credentialId: H256], { subjectId: RuntimeCommonAssetsAssetDid, credentialId: H256 }>;
/**
* A public credential has been revoked.
**/
CredentialRevoked: AugmentedEvent<ApiType, [credentialId: H256], { credentialId: H256 }>;
/**
* The parachain lease swap was initiated.
* A new public credential has been issued.
**/
LeaseSwapInitiated: AugmentedEvent<ApiType, []>;
CredentialStored: AugmentedEvent<ApiType, [subjectId: RuntimeCommonAssetsAssetDid, credentialId: H256], { subjectId: RuntimeCommonAssetsAssetDid, credentialId: H256 }>;
/**
* The requirement for associated relay block numbers was set
* A public credential has been unrevoked.
**/
RelayNumberCheckSet: AugmentedEvent<ApiType, [strict: bool], { strict: bool }>;
CredentialUnrevoked: AugmentedEvent<ApiType, [credentialId: H256], { credentialId: H256 }>;
};
scheduler: {
/**
Expand Down Expand Up @@ -909,19 +914,19 @@ declare module '@polkadot/api-base/types/events' {
/**
* Some XCM failed.
**/
Fail: AugmentedEvent<ApiType, [messageHash: Option<H256>, error: XcmV2TraitsError, weight: u64], { messageHash: Option<H256>, error: XcmV2TraitsError, weight: u64 }>;
Fail: AugmentedEvent<ApiType, [messageHash: Option<H256>, error: XcmV2TraitsError, weight: Weight], { messageHash: Option<H256>, error: XcmV2TraitsError, weight: Weight }>;
/**
* An XCM exceeded the individual message weight budget.
**/
OverweightEnqueued: AugmentedEvent<ApiType, [sender: u32, sentAt: u32, index: u64, required: u64], { sender: u32, sentAt: u32, index: u64, required: u64 }>;
OverweightEnqueued: AugmentedEvent<ApiType, [sender: u32, sentAt: u32, index: u64, required: Weight], { sender: u32, sentAt: u32, index: u64, required: Weight }>;
/**
* An XCM from the overweight queue was executed with the given actual weight used.
**/
OverweightServiced: AugmentedEvent<ApiType, [index: u64, used: u64], { index: u64, used: u64 }>;
OverweightServiced: AugmentedEvent<ApiType, [index: u64, used: Weight], { index: u64, used: Weight }>;
/**
* Some XCM was executed ok.
**/
Success: AugmentedEvent<ApiType, [messageHash: Option<H256>, weight: u64], { messageHash: Option<H256>, weight: u64 }>;
Success: AugmentedEvent<ApiType, [messageHash: Option<H256>, weight: Weight], { messageHash: Option<H256>, weight: Weight }>;
/**
* An upward message was sent to the relay chain.
**/
Expand Down
Loading

0 comments on commit 3bc648a

Please sign in to comment.