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

feat: support for public credentials #669

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions packages/type-definitions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { types10800 } from './types_10800.js'

import { calls as didCalls } from './runtime/did.js'
import { calls as parachainStakingCalls } from './runtime/parachainStaking.js'
import { calls as publicCredentialsCalls } from './runtime/publicCredentials.js'

export {
types8,
Expand All @@ -50,6 +51,7 @@ export {

export { calls as didCalls } from './runtime/did.js'
export { calls as parachainStakingCalls } from './runtime/parachainStaking.js'
export { calls as publicCredentialsCalls } from './runtime/publicCredentials.js'

const defaultTypesBundle: OverrideVersionedType[] = [
{
Expand Down Expand Up @@ -117,25 +119,29 @@ export const typesBundle: OverrideBundleType = {
runtime: {
...didCalls,
...parachainStakingCalls,
...publicCredentialsCalls,
},
types: defaultTypesBundle,
},
'KILT Peregrine': {
runtime: {
...didCalls,
...parachainStakingCalls,
...publicCredentialsCalls,
},
types: defaultTypesBundle,
},
'KILT Mashnet': {
runtime: {
...didCalls,
...publicCredentialsCalls,
},
types: defaultTypesBundle,
},
Development: {
runtime: {
...didCalls,
...publicCredentialsCalls,
},
types: defaultTypesBundle,
},
Expand Down
44 changes: 44 additions & 0 deletions packages/type-definitions/src/runtime/publicCredentials.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Copyright (c) 2018-2022, BOTLabs GmbH.
*
* This source code is licensed under the BSD 4-Clause "Original" license
* found in the LICENSE file in the root directory of this source tree.
*/

import type { DefinitionsCall } from '@polkadot/types/types'

export const calls: DefinitionsCall = {
PublicCredentials: [
{
methods: {
get_credential: {
description:
'Return the public credential with the specified ID, if found.',
params: [
{
name: 'credential_id',
type: 'Hash',
},
],
type: 'Option<PublicCredentialsCredentialsCredentialEntry>',
},
get_credentials: {
description:
'Return all the public credentials linked to the specified subject.',
params: [
{
name: 'subject',
type: 'Text',
},
{
name: 'filter',
type: 'Option<PublicCredentialsFilter>',
},
],
type: 'Result<Vec<(Hash, PublicCredentialsCredentialsCredentialEntry)>, PublicCredentialApiError>',
},
},
version: 1,
},
],
}
12 changes: 12 additions & 0 deletions packages/type-definitions/src/types_10800.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,16 @@ export const types10800: RegistryTypes = {
...types10720,
// DID state_call v2
DidApiAccountId: 'PalletDidLookupLinkableAccountLinkableAccountId',

// Public credentials state_calls (types are somehow not exported in the metadata info)
// FIXME: if exported in the metadata, remove these type definitions from future versions
PublicCredentialsFilter: {
_enum: {
ctypeHash: 'Hash',
attester: 'AccountId32',
},
},
PublicCredentialApiError: {
_enum: ['InvalidSubjectId'],
},
}