Skip to content

Commit 2fb4bf2

Browse files
committed
fix: new-sdk-draft2
1 parent 1816e43 commit 2fb4bf2

File tree

5 files changed

+30
-28
lines changed

5 files changed

+30
-28
lines changed

code_examples/sdk_examples/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"test": "ts-node src/test.ts"
1414
},
1515
"dependencies": {
16-
"@kiltprotocol/sdk-js": "1",
16+
"@kiltprotocol/sdk-js": "^1.0.0",
1717
"axios": "^1.5.1",
1818
"commander": "^11.1.0",
1919
"dotenv": "^16.3.1",
@@ -36,4 +36,4 @@
3636
"ts-node": "^10.9.1",
3737
"typescript": "^5.2.2"
3838
}
39-
}
39+
}

code_examples/sdk_examples/src/core_features/getting_started/04_fetch_endpoints.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as Kilt from '@kiltprotocol/sdk-js'
2-
import * as Did from '@kiltprotocol/did'
2+
import {Did} from "@kiltprotocol/types"
33

4-
export async function main(id: String): Promise<Object[]> {
5-
const kiltnerd123DidDocument = await Did.resolve(id)
4+
export async function main(id: Did): Promise<Object[]> {
5+
const kiltnerd123DidDocument = await Kilt.DidResolver.resolve(id)
66
console.log(`kiltnerd123's DID Document:`)
77
console.log(JSON.stringify(kiltnerd123DidDocument, null, 2))
88

code_examples/sdk_examples/src/core_features/getting_started/05_fetch_endpoint_data.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import axios from 'axios'
22

33
import * as Kilt from '@kiltprotocol/sdk-js'
4-
import { VerifiableCredential } from '@kiltprotocol/credentials/lib/cjs/V1/types'
4+
import { types } from '@kiltprotocol/credentials'
55

66
export async function main(
7-
endpoints: Kilt.Service<DidUrl>[]
8-
): Promise<VerifiableCredential> {
9-
const { data: credential } = await axios.get<VerifiableCredential>(
7+
endpoints: types.DidUrl[]
8+
): Promise<types.VerifiableCredential> {
9+
const { data: credential } = await axios.get<types.VerifiableCredential>(
1010
endpoints[0].serviceEndpoint[0]
1111
)
1212
console.log(`Credentials: ${JSON.stringify(credential, null, 2)}`)

docs/develop/01_sdk/01_quickstart.md

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ To enable ES modules in your project, add `"type": "module"` to the `package.jso
6868

6969
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:
7070

71-
{/_ TODO: Do we need to test this or provide JS/TS equivalent? _/}
71+
{/* TODO: Do we need to test this or provide JS/TS equivalent? */}
7272

7373
```js
74-
async function main() {}
74+
async function main() {
75+
}
7576

7677
main()
7778
```
@@ -83,8 +84,10 @@ main()
8384
Begin by importing the **KILT SDK** and **Axios** at the top of the file:
8485

8586
```js
86-
import * as Kilt from '@kiltprotocol/sdk-js'
87-
import axios from 'axios'
87+
import * as Kilt from "@kiltprotocol/sdk-js";
88+
import axios from "axios";
89+
import * as Did from "@kiltprotocol/did";
90+
import {types}from "@kiltprotocol/credentials"
8891
```
8992

9093
Now, you can access the SDK and all its functionality.
@@ -124,9 +127,9 @@ You should add all other code before this function call:
124127

125128
<SnippetBlock
126129
className="language-ts"
127-
128-
> {Disconnect}
129-
> </SnippetBlock>
130+
>
131+
{Disconnect}
132+
</SnippetBlock>
130133

131134
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.
132135

@@ -166,9 +169,9 @@ Between the `Kilt.connect()` and `Kilt.disconnect()` lines, add the following co
166169
<SnippetBlock
167170
className="language-ts"
168171
dropTail="1"
169-
170-
> {FetchDid}
171-
> </SnippetBlock>
172+
>
173+
{FetchDid}
174+
</SnippetBlock>
172175

173176
Try running the code and check the result.
174177

@@ -188,9 +191,9 @@ It retrieves the services exposed by the DID found for `kiltnerd123`:
188191
<SnippetBlock
189192
className="language-ts"
190193
dropTail="1"
191-
192-
> {FetchEndpoints}
193-
> </SnippetBlock>
194+
>
195+
{FetchEndpoints}
196+
</SnippetBlock>
194197

195198
The code should print endpoints as JSON.
196199

@@ -212,15 +215,15 @@ Add it before `await Kilt.disconnect()`:
212215

213216
<SnippetBlock
214217
className="language-ts"
215-
216-
> {VerifyCredential}
217-
> </SnippetBlock>
218+
>
219+
{VerifyCredential}
220+
</SnippetBlock>
218221

219222
Run the code and wait to see if you can retrieve **and** verify one of kiltnerd123's credentials!
220223

221224
:::info Next steps
222225

223-
- If you want to explore more of KILT's features, read our [Concepts section](../../concepts/01_what_is_kilt.md).
224-
- 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).
226+
- If you want to explore more of KILT's features, read our [Concepts section](../../concepts/01_what_is_kilt.md).
227+
- 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).
225228

226229
:::

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
"@docusaurus/preset-classic": "^3.1.0",
4040
"@docusaurus/remark-plugin-npm2yarn": "^3.1.0",
4141
"@docusaurus/theme-mermaid": "^3.1.0",
42-
"@kiltprotocol/sdk-js": "1.0",
4342
"@mdx-js/react": "^3.0.0",
4443
"archiver": "^6.0.1",
4544
"clsx": "^2.1.0",

0 commit comments

Comments
 (0)