Skip to content

Commit

Permalink
add missing polkadot client tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
NorbertBodziony committed Sep 21, 2023
1 parent 9be1668 commit a138691
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
25 changes: 25 additions & 0 deletions sdk/apps/docs/docs/client/connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,31 @@ const message: Connect = {
await client.connect(message)
```

</TabItem>
<TabItem value="Polkadot" label="Polkadot">

```js
import { ClientPolkadot } from '@nightlylabs/nightly-connect-polkadot'

const client: ClientPolkadot = await ClientPolkadot.create({
url: RELAY_ENDPOINT // default: https://nc2.nightly.app
})
const info: GetInfoResponse = await client.getInfo(sessionId)

const message: Connect = {
publicKeys: ['5EnRWxJwqLuexBZtbJVTmfAzzc6Fwpw2Gv9AYs1gYHsgvzfH'],
sessionId: sessionId,
walletsMetadata: [
{
address: '5EnRWxJwqLuexBZtbJVTmfAzzc6Fwpw2Gv9AYs1gYHsgvzfH',
name: 'Alice',
type: 'ed25519'
}
]
}
await client.connect(message)
```

</TabItem>
</Tabs>

Expand Down
19 changes: 19 additions & 0 deletions sdk/apps/docs/docs/client/sign.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,24 @@ client.on('signTransactions', async (e) => {
})
```

</TabItem>
<TabItem value="Polkadot" label="Polkadot">

```js

const alice_keypair = new Keyring()
alice_keypair.setSS58Format(42)
const aliceKeyringPair = alice_keypair.createFromUri('//Alice')

client.on('signTransactions', async (e) => {
const payload = e.transactions[0] as SignerPayloadRaw
const signature = aliceKeyringPair.sign(payload.data, { withType: true })
await client.resolveSignTransaction({
requestId: e.requestId,
signedTransactions: [{ signature: u8aToHex(signature), id: new Date().getTime() }]
})
})
```

</TabItem>
</Tabs>
3 changes: 3 additions & 0 deletions sdk/apps/docs/docs/client/signMessage.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,8 @@ client.on('signMessages', async (e) => {
})
```

</TabItem>
<TabItem value="Polkadot" label="Polkadot">
Signing messages on Polkadot works the same way as signing transactions
</TabItem>
</Tabs>

0 comments on commit a138691

Please sign in to comment.