Skip to content
This repository was archived by the owner on Oct 10, 2022. It is now read-only.

Commit 8ceabbf

Browse files
committed
add public credentials definition
1 parent 19fdbca commit 8ceabbf

File tree

4 files changed

+86
-1
lines changed

4 files changed

+86
-1
lines changed

src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { types2700 } from "./types_2700"
1515
import { types10700 } from "./types_10700"
1616

1717
import runtime from "./runtime"
18+
import rpc from "./rpc"
1819

1920
// Export type definitions
2021
export {
@@ -37,6 +38,9 @@ export {
3738
// Export runtime APIs definitions
3839
export { runtime }
3940

41+
// Export custom RPC definitions
42+
export { rpc }
43+
4044
// Export complete package
4145
export const typeBundleForPolkadot: OverrideBundleDefinition = {
4246
types: [
@@ -93,5 +97,6 @@ export const typeBundleForPolkadot: OverrideBundleDefinition = {
9397
types: types10700,
9498
},
9599
],
96-
runtime: runtime
100+
runtime: runtime,
101+
rpc: rpc
97102
}

src/rpc.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import type {
2+
DefinitionRpc, DefinitionRpcSub
3+
} from "@polkadot/types/types"
4+
5+
const rpc: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>> = {
6+
credentials: {
7+
getCredential: {
8+
description: "Test",
9+
params: [
10+
{
11+
name: "credential_id",
12+
type: "Hash",
13+
},
14+
{
15+
name: "at",
16+
type: "Hash",
17+
isOptional: true,
18+
},
19+
],
20+
type: "Option<PublicCredentialsCredentialsCredentialEntry>"
21+
},
22+
getCredentials: {
23+
description: "Return all the credentials issued to the provided subject, optionally filtering with the provided logic.",
24+
params: [
25+
{
26+
name: "subject",
27+
type: "String",
28+
},
29+
{
30+
name: "filter",
31+
type: "PublicCredentialFilter",
32+
isOptional: true,
33+
},
34+
{
35+
name: "at",
36+
type: "Hash",
37+
isOptional: true,
38+
},
39+
],
40+
type: "Vec<(Hash, PublicCredentialsCredentialsCredentialEntry)>"
41+
}
42+
}
43+
}
44+
45+
export default rpc

src/runtime.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,33 @@ const runtime: DefinitionsCall = {
4040
version: 1
4141
}
4242
],
43+
PublicCredentialsApi: [
44+
{
45+
methods: {
46+
get_credential: {
47+
description: "Test",
48+
params: [
49+
{
50+
name: "credentialId",
51+
type: "Hash",
52+
},
53+
],
54+
type: "Option<PublicCredentialsCredentialsCredentialEntry>"
55+
},
56+
get_credentials: {
57+
description: "Test",
58+
params: [
59+
{
60+
name: "subject",
61+
type: "RuntimeCommonAssetsAssetDid",
62+
},
63+
],
64+
type: "Vec<(Hash, PublicCredentialsCredentialsCredentialEntry)>"
65+
},
66+
},
67+
version: 1
68+
}
69+
],
4370
}
4471

4572
export default runtime

src/types_10700.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,12 @@ export const types10700: RegistryTypes = {
2525
lastTxCounter: "BlockNumber",
2626
deposit: "KiltSupportDeposit<AccountId32, Balance>"
2727
},
28+
29+
// Public credentials RPC
30+
PublicCredentialFilter: {
31+
_enum: {
32+
ctypeHash: "Hash",
33+
attester: "DidIdentifier",
34+
}
35+
}
2836
}

0 commit comments

Comments
 (0)