diff --git a/code_examples/sdk_examples/package.json b/code_examples/sdk_examples/package.json index b89417470..d18131962 100644 --- a/code_examples/sdk_examples/package.json +++ b/code_examples/sdk_examples/package.json @@ -13,7 +13,7 @@ "test": "ts-node src/test.ts" }, "dependencies": { - "@kiltprotocol/sdk-js": "1", + "@kiltprotocol/sdk-js": "^1.0.0", "axios": "^1.5.1", "commander": "^11.1.0", "dotenv": "^16.3.1", @@ -36,4 +36,4 @@ "ts-node": "^10.9.1", "typescript": "^5.2.2" } -} +} \ No newline at end of file diff --git a/code_examples/sdk_examples/src/core_features/getting_started/04_fetch_endpoints.ts b/code_examples/sdk_examples/src/core_features/getting_started/04_fetch_endpoints.ts index 341339d64..e7b5414af 100644 --- a/code_examples/sdk_examples/src/core_features/getting_started/04_fetch_endpoints.ts +++ b/code_examples/sdk_examples/src/core_features/getting_started/04_fetch_endpoints.ts @@ -1,8 +1,8 @@ import * as Kilt from '@kiltprotocol/sdk-js' -import * as Did from '@kiltprotocol/did' +import {Did} from "@kiltprotocol/types" -export async function main(id: String): Promise { - const kiltnerd123DidDocument = await Did.resolve(id) +export async function main(id: Did): Promise { + const kiltnerd123DidDocument = await Kilt.DidResolver.resolve(id) console.log(`kiltnerd123's DID Document:`) console.log(JSON.stringify(kiltnerd123DidDocument, null, 2)) diff --git a/code_examples/sdk_examples/src/core_features/getting_started/05_fetch_endpoint_data.ts b/code_examples/sdk_examples/src/core_features/getting_started/05_fetch_endpoint_data.ts index e24ee209a..c55f7f195 100644 --- a/code_examples/sdk_examples/src/core_features/getting_started/05_fetch_endpoint_data.ts +++ b/code_examples/sdk_examples/src/core_features/getting_started/05_fetch_endpoint_data.ts @@ -1,12 +1,12 @@ import axios from 'axios' import * as Kilt from '@kiltprotocol/sdk-js' -import { VerifiableCredential } from '@kiltprotocol/credentials/lib/cjs/V1/types' +import { types } from '@kiltprotocol/credentials' export async function main( - endpoints: Kilt.Service[] -): Promise { - const { data: credential } = await axios.get( + endpoints: types.DidUrl[] +): Promise { + const { data: credential } = await axios.get( endpoints[0].serviceEndpoint[0] ) console.log(`Credentials: ${JSON.stringify(credential, null, 2)}`) diff --git a/docs/develop/01_sdk/01_quickstart.md b/docs/develop/01_sdk/01_quickstart.md index 3e5cf1f06..44370e77d 100644 --- a/docs/develop/01_sdk/01_quickstart.md +++ b/docs/develop/01_sdk/01_quickstart.md @@ -68,10 +68,11 @@ To enable ES modules in your project, add `"type": "module"` to the `package.jso Declare an `async main` function in the `quickstart.ts` file that executes the rest of the code in this quickstart and call the `main()` function by default: -{/_ TODO: Do we need to test this or provide JS/TS equivalent? _/} +{/* TODO: Do we need to test this or provide JS/TS equivalent? */} ```js -async function main() {} +async function main() { +} main() ``` @@ -83,8 +84,10 @@ main() Begin by importing the **KILT SDK** and **Axios** at the top of the file: ```js -import * as Kilt from '@kiltprotocol/sdk-js' -import axios from 'axios' +import * as Kilt from "@kiltprotocol/sdk-js"; +import axios from "axios"; +import * as Did from "@kiltprotocol/did"; +import {types}from "@kiltprotocol/credentials" ``` Now, you can access the SDK and all its functionality. @@ -124,9 +127,9 @@ You should add all other code before this function call: {Disconnect} -> +> +{Disconnect} + By adding `await Kilt.disconnect()`, you ensure that the connection to the blockchain node is properly closed when the script finishes executing, which helps maintain the integrity of your application and is a good practice to follow. @@ -166,9 +169,9 @@ Between the `Kilt.connect()` and `Kilt.disconnect()` lines, add the following co {FetchDid} -> +> +{FetchDid} + Try running the code and check the result. @@ -188,9 +191,9 @@ It retrieves the services exposed by the DID found for `kiltnerd123`: {FetchEndpoints} -> +> +{FetchEndpoints} + The code should print endpoints as JSON. @@ -212,15 +215,15 @@ Add it before `await Kilt.disconnect()`: {VerifyCredential} -> +> +{VerifyCredential} + Run the code and wait to see if you can retrieve **and** verify one of kiltnerd123's credentials! :::info Next steps -- If you want to explore more of KILT's features, read our [Concepts section](../../concepts/01_what_is_kilt.md). -- If you want to dive deeper into the SDK, read the next section, [the KILT Cookbook](./02_cookbook/01_dids/01_light_did_creation.md). +- If you want to explore more of KILT's features, read our [Concepts section](../../concepts/01_what_is_kilt.md). +- If you want to dive deeper into the SDK, read the next section, [the KILT Cookbook](./02_cookbook/01_dids/01_light_did_creation.md). ::: diff --git a/package.json b/package.json index f0549e80e..9a7c5918b 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,6 @@ "@docusaurus/preset-classic": "^3.1.0", "@docusaurus/remark-plugin-npm2yarn": "^3.1.0", "@docusaurus/theme-mermaid": "^3.1.0", - "@kiltprotocol/sdk-js": "1.0", "@mdx-js/react": "^3.0.0", "archiver": "^6.0.1", "clsx": "^2.1.0",