This package is home to the Joystream.js libraries which provide everything required to work with Joystream network.
-
@joystream/js/utils
Common utilities used by different Joystreamjs packages -
@joystream/js/content
Interact with content directory module - managing videos, channels, payouts, assets, categories and curator groups
yarn install @joystream/js
- Run
yarn
to install dependencies - Run
yarn build
to build the package
Interact with content directory module - managing payouts, channels, videos, assets, categories and curator groups
This function gets the payout record from the remote source. It first fetches the payload
header and then uses the offset
of given channel Id from header to fetch the record.
import { channelPayoutProof } from '@joystream/js/content'
const channelId = 1
const payoutRecord = await channelPayoutProof(channelId)
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(
readBytesFromFile(readContext, inputFilePath), byteOffset
)
import { serializedPayloadHeader } from '@joystream/js/content'
import { ChannelPayoutsMetadata } from '@joystream/metadata-protobuf'
import { readBytesFromFile } from '@joystream/js/utils'
const readContext = 'PATH' // 'PATH' | 'URL'
const inputFilePath = './payload'
const serializedHeader = await serializedPayloadHeader(
readBytesFromFile(readContext, inputFilePath)
)
// decode header
const header = ChannelPayoutsMetadata.Header.decode(serializedHeader)
console.log(
header.payloadLengthInBytes,
header.headerLengthInBytes,
header.numberOfChannels,
header.channelPayoutByteOffsets
)
import { generateCommitmentFromPayloadFile } from '@joystream/js/content'
const inputFilePath = './payload'
const readContext = 'PATH' // 'PATH' | 'URL'
const merkleRoot = await generateCommitmentFromPayloadFile(
readBytesFromFile(readContext, inputFilePath)
)
Common utilities used by different Joystreamjs packages.
Submodule structure:
-
src/schemas/json/
JSON schemas -
typings/
Type definitions generated from JSON schemas usingjson-schema-to-typescript
Read a range of bytes from input file provided start
and end
values.
Both start
and end
are inclusive
import { readBytesFromFile } from '@joystream/js/utils'
const readContext = 'PATH' // 'PATH' | 'URL'
const inputFilePath = './payload'
const start = 10
const end = 20
const bytesReader = readBytesFromFile(readContext, inputFilePath)
const bytes = await bytesReader(start, end)