Skip to content

Commit 08b74b2

Browse files
author
Chris Chinchilla
committed
Fix links and start changes to Snippet component
Signed-off-by: Chris Chinchilla <[email protected]>
1 parent 232c02b commit 08b74b2

File tree

16 files changed

+75
-153
lines changed

16 files changed

+75
-153
lines changed

code_examples/sdk_examples/src/workshop/index.ts

Lines changed: 22 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,25 @@
55
* found in the LICENSE file in the root directory of this source tree.
66
*/
77

8-
import type {
9-
KiltAddress,
10-
SignerInterface,
11-
KeyringPair,
12-
MultibaseKeyPair,
13-
TransactionSigner,
14-
ICType
15-
} from '@kiltprotocol/types'
16-
import { Keyring } from '@polkadot/keyring'
17-
import { BN } from '@polkadot/util'
188
import * as Kilt from '@kiltprotocol/sdk-js'
19-
import { Multikey } from '@kiltprotocol/utils'
20-
import { Blockchain, BalanceUtils } from '@kiltprotocol/chain-helpers'
219
import { CType } from '@kiltprotocol/credentials'
2210
// TODO: Look into tidier way with PD Keyring…
2311
import { getFunds } from '../getFunds'
24-
// import { releaseWeb3Name } from '../core_features/web3names/04_release'
2512

2613
export function generateAccounts() {
2714
const issuerAccount = Kilt.generateKeypair({ type: 'ed25519' })
2815
const submitterAccount = Kilt.generateKeypair({ type: 'ed25519' })
2916
const holderAccount = Kilt.generateKeypair({ type: 'ed25519' })
17+
const verifierAccount = Kilt.generateKeypair({ type: 'ed25519' })
3018

3119
console.log('keypair generation complete')
32-
console.log(`ISSUER_ACCOUNT_ADDRESS=${issuerAccount}`)
33-
console.log(`SUBMITTER_ACCOUNT_ADDRESS=${submitterAccount}`)
34-
console.log(`HOLDER_ACCOUNT_ADDRESS=${holderAccount}`)
20+
console.log(`ISSUER_ACCOUNT_ADDRESS=${issuerAccount.publicKeyMultibase}`)
21+
console.log(
22+
`SUBMITTER_ACCOUNT_ADDRESS=${submitterAccount.publicKeyMultibase}`
23+
)
24+
console.log(`HOLDER_ACCOUNT_ADDRESS=${holderAccount.publicKeyMultibase}`)
3525

36-
return { issuerAccount, submitterAccount, holderAccount }
26+
return { issuerAccount, submitterAccount, holderAccount, verifierAccount }
3727
}
3828

3929
export async function generateIssuerDid(
@@ -56,7 +46,7 @@ export async function generateIssuerDid(
5646
}
5747

5848
let { didDocument, signers } = didDocumentTransactionResult.asConfirmed
59-
console.log(`ISSUER_DID_URI=${didDocument}`)
49+
console.log(`ISSUER_DID_URI=${didDocument.id}`)
6050
// TODO: Don't need to pass signers? but explain that it's more flexible in real use
6151
return { didDocument, signers }
6252
}
@@ -82,12 +72,11 @@ export async function generateHolderDid(
8272
}
8373

8474
let { didDocument, signers } = didDocumentTransactionResult.asConfirmed
85-
console.log(`HOLDER_DID_URI=${didDocument}`)
75+
console.log(`HOLDER_DID_URI=${didDocument.id}`)
8676
// TODO: Don't need to pass signers? but explain that it's more flexible in real use
8777
return { didDocument, signers }
8878
}
8979

90-
9180
export async function generateVerifierDid(
9281
submitterAccount,
9382
authenticationKeyPair
@@ -113,7 +102,6 @@ export async function generateVerifierDid(
113102
return { didDocument, signers }
114103
}
115104

116-
117105
export async function verifyDid(submitterAccount, didDocument, signers) {
118106
// TODO: DID verify step currently. What step?
119107
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
@@ -154,20 +142,16 @@ export async function verifyDid(submitterAccount, didDocument, signers) {
154142
console.log('assertion method added')
155143
return { didDocument, signers }
156144
}
157-
//Issuer
158-
// add into tutorial. Actually does it make sense?
145+
// TODO: Add into tutorial. Actually does it make sense?
159146
export async function claimWeb3Name(submitterAccount, didDocument, signers) {
160-
// ┏━━━━━━━━━━━━━━━━━┓
161-
// ┃ Claim web3name ┃
162-
// ┗━━━━━━━━━━━━━━━━━┛
163147
const api = Kilt.ConfigService.get('api')
164148

165149
const claimW3nTransactionResult = await Kilt.DidHelpers.claimWeb3Name({
166150
api,
167151
didDocument,
168152
submitter: submitterAccount,
169153
signers,
170-
name: 'testtest7865348'
154+
name: 'testtest7865348999'
171155
}).submit()
172156

173157
if (claimW3nTransactionResult.status !== 'confirmed') {
@@ -181,24 +165,24 @@ export async function claimWeb3Name(submitterAccount, didDocument, signers) {
181165
}
182166

183167
// Issuer
184-
export async function issueCredential(didDocument, signers, submitterAccount) {
168+
export async function issueCredential(issuerDid, holderDid, signers, submitterAccount) {
185169
const passportCType = await CType.fetchFromChain(
186170
'kilt:ctype:0x5f6634bc0edf08ced5fc7a7bec24a2019228570b912703c834955e0d00f69bf4'
187171
)
188172

189173
const passportCredential = await Kilt.Issuer.createCredential({
190-
issuer: didDocument.id,
174+
issuer: issuerDid.id,
191175
credentialSubject: {
192-
id: didDocument.id,
193-
age: 22,
176+
id: holderDid.id,
177+
age: 22
194178
},
195179
cType: passportCType.cType
196180
})
197181

198182
const credential = await Kilt.Issuer.issue({
199183
credential: passportCredential,
200184
issuer: {
201-
didDocument,
185+
didDocument: issuerDid,
202186
signers: [...signers, submitterAccount],
203187
submitter: submitterAccount
204188
}
@@ -209,20 +193,11 @@ export async function issueCredential(didDocument, signers, submitterAccount) {
209193
}
210194

211195
export async function createPresentation(credential, didDocument, signers) {
212-
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
213-
// ┃ Create a Presentation ┃
214-
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
215-
//
216-
// Create a derived credential (a copy) that only contains selected properties (selective disclosure), then create a credential presentation for it.
217-
// The presentation includes a proof of ownership and is scoped to a verified and time frame to prevent unauthorized re-use.
218-
// Not on chain
219-
// TODO: Why DID then? Because credential is attactached to a DID
220196
const derived = await Kilt.Holder.deriveProof({
221197
credential,
222-
// Change
223198
proofOptions: { includeClaims: ['/credentialSubject/age'] }
224199
})
225-
200+
226201
const presentation = await Kilt.Holder.createPresentation({
227202
credentials: [derived],
228203
holder: {
@@ -261,17 +236,7 @@ export async function removeVerificationMethod(
261236
submitterAccount,
262237
signers
263238
) {
264-
// More for internal tests, not part of workshop, links
265239
// TODO: Need more now to tear down all created assets
266-
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
267-
// ┃ Remove a Verification Method ┃
268-
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
269-
//
270-
// Removing a verification method can be done by specifying its id.
271-
//
272-
// Note:
273-
// - The provided `didDocument` must include the specified verification method.
274-
// - The authentication verification method can not be removed.
275240
const api = Kilt.ConfigService.get('api')
276241

277242
const removeVmTransactionResult =
@@ -294,11 +259,6 @@ export async function removeVerificationMethod(
294259
}
295260

296261
export async function releaseWeb3Name(didDocument, submitterAccount, signers) {
297-
// ┏━━━━━━━━━━━━━━━━━━┓
298-
// ┃ Release web3name ┃
299-
// ┗━━━━━━━━━━━━━━━━━━┛
300-
//
301-
// A web3name can be released from a DID and potentially claimed by another DID.
302262
const api = Kilt.ConfigService.get('api')
303263

304264
const releaseW3nTransactionResult = await Kilt.DidHelpers.releaseWeb3Name({
@@ -317,11 +277,6 @@ export async function releaseWeb3Name(didDocument, submitterAccount, signers) {
317277
}
318278

319279
export async function removeService(didDocument, submitterAccount, signers) {
320-
// ┏━━━━━━━━━━━━━━━━━━┓
321-
// ┃ Remove a service ┃
322-
// ┗━━━━━━━━━━━━━━━━━━┛
323-
//
324-
// Services can be removed by specifying the service `id`
325280
const api = Kilt.ConfigService.get('api')
326281

327282
const removeServiceTransactionResult = await Kilt.DidHelpers.removeService({
@@ -341,12 +296,6 @@ export async function removeService(didDocument, submitterAccount, signers) {
341296
}
342297

343298
export async function deactivateDid(didDocument, submitterAccount, signers) {
344-
// ┏━━━━━━━━━━━━━━━━━━┓
345-
// ┃ Deactivate a DID ┃
346-
// ┗━━━━━━━━━━━━━━━━━━┛
347-
//
348-
// _Permanently_ deactivate the DID, removing all verification methods and services from its document.
349-
// Deactivating a DID cannot be undone, once a DID has been deactivated, all operations on it (including attempts at re-creation) are permanently disabled.
350299
const api = Kilt.ConfigService.get('api')
351300

352301
const deactivateDidTransactionResult = await Kilt.DidHelpers.deactivateDid({
@@ -369,7 +318,6 @@ export async function deactivateDid(didDocument, submitterAccount, signers) {
369318
}
370319

371320
export async function runAll() {
372-
// Setup code
373321
const api = await Kilt.connect(
374322
process.env.WSS_ADDRESS || 'wss://peregrine.kilt.io'
375323
)
@@ -380,20 +328,12 @@ export async function runAll() {
380328
seed: '0xe566550fec3ca23d80dfe9e9529ada463b93fc33f17219c1089de906f7253f1c'
381329
})
382330

383-
const { issuerAccount, submitterAccount, holderAccount } = generateAccounts()
384-
const verifierAccount = generateAccounts()
385-
386-
// ┏━━━━━━━━━━━━┓
387-
// ┃ Get funds ┃
388-
// ┗━━━━━━━━━━━━┛
389-
//
390-
391-
await getFunds(faucetAccount, submitterAccount, 5)
331+
const { issuerAccount, submitterAccount, holderAccount, verifierAccount } = generateAccounts()
332+
333+
await getFunds(faucetAccount, submitterAccount, 10)
392334
console.log('Successfully transferred tokens')
393335
let issuerDid = await generateIssuerDid(submitterAccount, issuerAccount)
394-
395336
let holderDid = await generateHolderDid(submitterAccount, holderAccount)
396-
397337
let verifierDid = await generateVerifierDid(submitterAccount, verifierAccount)
398338

399339
issuerDid = await verifyDid(
@@ -403,11 +343,12 @@ const verifierAccount = generateAccounts()
403343
)
404344
issuerDid = await claimWeb3Name(
405345
submitterAccount,
406-
issuerDid,
346+
issuerDid.didDocument,
407347
issuerDid.signers
408348
)
409349
const credential = await issueCredential(
410350
issuerDid.didDocument,
351+
holderDid.didDocument,
411352
issuerDid.signers,
412353
submitterAccount
413354
)
@@ -444,7 +385,6 @@ const verifierAccount = generateAccounts()
444385
holderDid.signers
445386
)
446387

447-
// Release the connection to the blockchain.
448388
await api.disconnect()
449389

450390
console.log('disconnected')

code_examples/sdk_examples/tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
"target": "ES2020"
77
},
88
"exclude": [
9-
"src/test.ts"
9+
"src/test.ts",
10+
"src/core_features",
11+
"src/dapp",
12+
"src/staking"
1013
]
1114
}

develop/02_chain/04_fullnode.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ This can either be `peregrine` or `spiritnet`.
4141

4242
Hence, to start a full node for the Spiritnet network, the parameter would be `--chain=spiritnet`.
4343
Unfortunately, there is no hardcoded chain spec for the Peregrine network, so the full path of the chainspec file must be provided `--chain=/node/dev-specs/kilt-parachain/peregrine-kilt.json`.
44-
Please refer to the [KILT node repository](https://github.com/KILTprotocol/kilt-node/blob/master/dev-specs/kilt-parachain/peregrine-kilt.json) or the [Docker image](https://hub.docker.com/r/kiltprotocol/kilt-node/tags) for more information.
44+
Please refer to the [KILT node repository](https://github.com/KILTprotocol/kilt-node/blob/master/chainspecs/peregrine/peregrine-paseo.json) or the [Docker image](https://hub.docker.com/r/kiltprotocol/kilt-node/tags) for more information.
4545

4646
### Specify the Blockchain Storage Path
4747

docusaurus.config.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,12 @@ module.exports = {
5454
srcDark: 'img/logo_dark.svg',
5555
},
5656
items: [
57-
{
58-
type: 'docsVersionDropdown',
59-
position: 'right',
60-
dropdownActiveClassDisabled: true,
61-
},
57+
// TODO: Not working right now…
58+
// {
59+
// type: 'docsVersionDropdown',
60+
// position: 'right',
61+
// dropdownActiveClassDisabled: true,
62+
// },
6263
{
6364
to: '/concepts/what-is-kilt',
6465
label: 'What is KILT?',

participate/01_staking/01_become_a_collator/03_setup_node.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ This can either be `peregrine` or `spiritnet`.
7474

7575
Hence, to start a collator node for the Spiritnet network, the parameter would be `--chain=spiritnet`.
7676
Unfortunately, there is no hardcoded chain spec for the Peregrine network, so the full path of the chainspec file must be provided `--chain=/node/dev-specs/kilt-parachain/peregrine-kilt.json`.
77-
Please refer to the [KILT node repository](https://github.com/KILTprotocol/kilt-node/blob/master/dev-specs/kilt-parachain/peregrine-kilt.json) or the [Docker image](https://hub.docker.com/r/kiltprotocol/kilt-node/tags) for more information.
77+
Please refer to the [KILT node repository](https://github.com/KILTprotocol/kilt-node/blob/master/chainspecs/peregrine/peregrine-paseo.json) or the [Docker image](https://hub.docker.com/r/kiltprotocol/kilt-node/tags) for more information.
7878

7979
### Specify the Blockchain Storage Path
8080

sdk/02_tutorial/03_overview.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,6 @@ A presentation is derived from a credential and doesn't need to contain all attr
5656
After the request, the <span className="label-role holder">Holder</span> can choose to hide elements of their credentials that aren't relevant to the claim.
5757
For example, hide their address from their ID if the <span className="label-role issuer">Issuer</span> is only interested in their age.
5858

59-
:::info
60-
61-
A later step in the workshop [explains CTypes in more detail](./04_issuer/03_ctype.md).
62-
63-
:::
64-
6559
```mermaid
6660
sequenceDiagram
6761
actor C as Holder

sdk/02_tutorial/04_accounts.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import TsJsBlock from '@site/src/components/TsJsBlock';
77
import Tabs from '@theme/Tabs';
88
import TabItem from '@theme/TabItem';
99

10-
import GenerateAccount from '!!raw-loader!@site/code_examples/sdk_examples/src/workshop/index.ts';
11-
1210
With the [project structure setup](./) in the last step, you can create your <span className="label-role issuer">Issuer</span> account.
1311

1412
With KILT, an account is an object that interacts with the blockchain.

0 commit comments

Comments
 (0)