diff --git a/src/index.ts b/src/index.ts index 6d265fa..5f43062 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,6 +15,7 @@ import { types2700 } from "./types_2700" import { types10700 } from "./types_10700" import runtime from "./runtime" +import rpc from "./rpc" // Export type definitions export { @@ -37,6 +38,9 @@ export { // Export runtime APIs definitions export { runtime } +// Export custom RPC definitions +export { rpc } + // Export complete package export const typeBundleForPolkadot: OverrideBundleDefinition = { types: [ @@ -93,5 +97,6 @@ export const typeBundleForPolkadot: OverrideBundleDefinition = { types: types10700, }, ], - runtime: runtime + runtime: runtime, + rpc: rpc } diff --git a/src/rpc.ts b/src/rpc.ts new file mode 100644 index 0000000..c724a08 --- /dev/null +++ b/src/rpc.ts @@ -0,0 +1,45 @@ +import type { + DefinitionRpc, DefinitionRpcSub +} from "@polkadot/types/types" + +const rpc: Record> = { + credentials: { + getCredential: { + description: "Test", + params: [ + { + name: "credential_id", + type: "Hash", + }, + { + name: "at", + type: "Hash", + isOptional: true, + }, + ], + type: "Option" + }, + getCredentials: { + description: "Return all the credentials issued to the provided subject, optionally filtering with the provided logic.", + params: [ + { + name: "subject", + type: "String", + }, + { + name: "filter", + type: "PublicCredentialFilter", + isOptional: true, + }, + { + name: "at", + type: "Hash", + isOptional: true, + }, + ], + type: "Vec<(Hash, PublicCredentialsCredentialsCredentialEntry)>" + } + } +} + +export default rpc \ No newline at end of file diff --git a/src/runtime.ts b/src/runtime.ts index 6f5b1e5..c57f44c 100644 --- a/src/runtime.ts +++ b/src/runtime.ts @@ -40,6 +40,33 @@ const runtime: DefinitionsCall = { version: 1 } ], + PublicCredentialsApi: [ + { + methods: { + get_credential: { + description: "Test", + params: [ + { + name: "credentialId", + type: "Hash", + }, + ], + type: "Option" + }, + get_credentials: { + description: "Test", + params: [ + { + name: "subject", + type: "RuntimeCommonAssetsAssetDid", + }, + ], + type: "Vec<(Hash, PublicCredentialsCredentialsCredentialEntry)>" + }, + }, + version: 1 + } + ], } export default runtime \ No newline at end of file diff --git a/src/types_10700.ts b/src/types_10700.ts index f0468ac..61eb6a6 100644 --- a/src/types_10700.ts +++ b/src/types_10700.ts @@ -25,4 +25,12 @@ export const types10700: RegistryTypes = { lastTxCounter: "BlockNumber", deposit: "KiltSupportDeposit" }, + + // Public credentials RPC + PublicCredentialFilter: { + _enum: { + ctypeHash: "Hash", + attester: "DidIdentifier", + } + } }