Skip to content

Commit

Permalink
Added mdBook, expanded Block interfaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
markopoloparadox committed Oct 29, 2024
1 parent 76e76d1 commit 61bd169
Show file tree
Hide file tree
Showing 30 changed files with 527 additions and 125 deletions.
82 changes: 0 additions & 82 deletions avail-js/docs/advanced_examples/block_abstraction.ts

This file was deleted.

2 changes: 1 addition & 1 deletion avail-js/docs/advanced_examples/multisig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const main = async () => {

async function fundMultisigAccount(sdk: SDK, alice: KeyringPair, multisigAddress: string): Promise<string> {
console.log("Funding multisig account...")
const amount = new BN(10).pow(new BN(18)).mul(new BN(100)) // 100 Avail
const amount = SDK.oneAvail().mul(new BN(100)) // 100 Avail
const result = await sdk.tx.balances.transferKeepAlive(multisigAddress, amount, WaitFor.BlockInclusion, alice)
if (result.isErr) {
console.log(result.reason)
Expand Down
1 change: 1 addition & 0 deletions avail-js/docs/cookbook/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
book
6 changes: 6 additions & 0 deletions avail-js/docs/cookbook/book.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[book]
authors = ["Marko Petrlic"]
language = "en"
multilingual = false
src = "src"
title = "Avail JS SDK Cookbook"
7 changes: 7 additions & 0 deletions avail-js/docs/cookbook/src/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Summary

- [Overview](./overview.md)
- [Blocks](./blocks.md)
- [Block Hashes](./block_hashes.md)
- [Block Abstraction](./block_abstraction.md)
- [Questions](./questions.md)
93 changes: 93 additions & 0 deletions avail-js/docs/cookbook/src/block_abstraction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Block Abstraction

## Transactions

### Via SDK

```ts
{{#include ./code/block_abstraction.ts:16:19}}
```

```ts
{{#include ./code/block_abstraction.ts:23:25}}
```

```ts
{{#include ./code/block_abstraction.ts:27:34}}
```

```ts
{{#include ./code/block_abstraction.ts:36:38}}
```

```ts
{{#include ./code/block_abstraction.ts:40:42}}
```

### Via Free functions

```ts
{{#include ./code/block_abstraction.ts:46:49}}
```

```ts
{{#include ./code/block_abstraction.ts:51:58}}
```

```ts
{{#include ./code/block_abstraction.ts:60:62}}
```

```ts
{{#include ./code/block_abstraction.ts:64:66}}
```

## Data Submissions

### Via SDK

```ts
{{#include ./code/block_abstraction.ts:70:72}}
```

```ts
{{#include ./code/block_abstraction.ts:74:81}}
```

```ts
{{#include ./code/block_abstraction.ts:83:90}}
```

```ts
{{#include ./code/block_abstraction.ts:92:94}}
```

### Via Free functions

```ts
{{#include ./code/block_abstraction.ts:98:100}}
```

```ts
{{#include ./code/block_abstraction.ts:102:109}}
```

```ts
{{#include ./code/block_abstraction.ts:111:118}}
```

```ts
{{#include ./code/block_abstraction.ts:120:122}}
```

### Data Submission Structure

```ts
{{#include ./code/block_abstraction.ts:124:144}}
```

## Full Example

```ts
{{#include ./code/block_abstraction.ts}}
```
65 changes: 65 additions & 0 deletions avail-js/docs/cookbook/src/block_hashes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Block Hashes

## Fetching Block Hash

```ts
{{#include ./code/fetch_block_hash.ts:7:9}}
```

```ts
{{#include ./code/fetch_block_hash.ts:11:13}}
```

```ts
{{#include ./code/fetch_block_hash.ts:15:19}}
```

```ts
{{#include ./code/fetch_block_hash.ts:21:28}}
```

### Full Example

```ts
{{#include ./code/fetch_block_hash.ts}}
```

## Conversion

### From Hex String to H256 (BlockHash)

```ts
{{#include ./code/block_hash_conversion.ts:7:15}}
```

```ts
{{#include ./code/block_hash_conversion.ts:17:19}}
```

```ts
{{#include ./code/block_hash_conversion.ts:21:28}}
```

```ts
{{#include ./code/block_hash_conversion.ts:30:32}}
```

```ts
{{#include ./code/block_hash_conversion.ts:39:44}}
```

```ts
{{#include ./code/block_hash_conversion.ts:46:51}}
```

### From H256 (BlockHash) to Hex String

```ts
{{#include ./code/block_hash_conversion.ts:34:37}}
```

### Full Example

```ts
{{#include ./code/block_hash_conversion.ts}}
```
4 changes: 4 additions & 0 deletions avail-js/docs/cookbook/src/blocks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Blocks

Make sure that you have already read [Polkadot JS docs](https://polkadot.js.org/docs/api/cookbook/blocks) about Blocks.
Here we will cover only the additional abstraction that was added on top of existing polkadot js objects.
Loading

0 comments on commit 61bd169

Please sign in to comment.