Skip to content

Commit

Permalink
Merge pull request #4961 from mnaamani/joystream-js-readme
Browse files Browse the repository at this point in the history
update joystream/js README
  • Loading branch information
mnaamani authored Nov 8, 2023
2 parents a487937 + 1e5a1a3 commit b11c831
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
25 changes: 17 additions & 8 deletions joystreamjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ header and then uses the `offset` of given channel Id from header to fetch the r
```javascript
import { channelPayoutProof } from '@joystream/js/content'

const readContext = 'PATH' // 'PATH' | 'URL'
const inputFilePath = './payload'
const channelId = 1
const payoutRecord = await channelPayoutProof(channelId)
```
Expand All @@ -40,21 +38,28 @@ const payoutRecord = await channelPayoutProof(channelId)

```javascript
import { channelPayoutProofAtByteOffset } from '@joystream/js/content'
import { readBytesFromFile } from '@joystream/js/utils'

const readContext = 'PATH' // 'PATH' | 'URL'
const inputFilePath = './payload'
const byteOffset = 40
const payoutRecord = await channelPayoutProofAtByteOffset(readContext, input, byteOffset)
const payoutRecord = await channelPayoutProofAtByteOffset(
readBytesFromFile(readContext, inputFilePath), byteOffset
)
```

### Get header from serialized channel payouts payload file

```javascript
import { serializedPayloadHeader } from '@joystream/js/content'
import { ChannelPayoutsMetadata } from '@joystream/metadata-protobuf'
import { readBytesFromFile } from '@joystream/js/utils'

const readContext = 'PATH' // 'PATH' | 'URL'
const serializedHeader = await serializedPayloadHeader(readContext, input)
const inputFilePath = './payload'
const serializedHeader = await serializedPayloadHeader(
readBytesFromFile(readContext, inputFilePath)
)
// decode header
const header = ChannelPayoutsMetadata.Header.decode(serializedHeader)
console.log(
Expand All @@ -68,11 +73,13 @@ console.log(
### Generate merkle root from serialized channel payouts payload

```javascript
import { generateMerkleRoot } from '@joystream/js/content'
import { generateCommitmentFromPayloadFile } from '@joystream/js/content'

const inputFilePath = './payload'
const readContext = 'PATH' // 'PATH' | 'URL'
const merkleRoot = await generateCommitmentFromPayloadFile(inputFilePath)
const merkleRoot = await generateCommitmentFromPayloadFile(
readBytesFromFile(readContext, inputFilePath)
)
```

# Utils Submodule (@joystream/js/utils)
Expand All @@ -92,10 +99,12 @@ Read a range of bytes from input file provided `start` and `end` values.
Both `start` and `end` are inclusive

```javascript
import { getByteSequenceFromFile } from '@joystream/js/utils'
import { readBytesFromFile } from '@joystream/js/utils'

const readContext = 'PATH' // 'PATH' | 'URL'
const inputFilePath = './payload'
const start = 10
const end = 20
const bytes = await getByteSequenceFromFile(inputFilePath, start, end)
const bytesReader = readBytesFromFile(readContext, inputFilePath)
const bytes = await bytesReader(start, end)
```
2 changes: 1 addition & 1 deletion joystreamjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@joystream/js",
"version": "1.6.0",
"version": "1.6.1",
"license": "GPL-3.0-only",
"description": "Joystream JS package provides utilities required to work with Joystream network.",
"main": "lib/index.js",
Expand Down

0 comments on commit b11c831

Please sign in to comment.