12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- import { ApiPromise, WsProvider } from '@polkadot/api'
- import { types as joyTypes } from '@joystream/types'
- import { Keyring } from '@polkadot/keyring'
- import { InputParser } from '@joystream/cd-schemas'
- import { ChannelEntity } from '@joystream/cd-schemas/types/entities'
- async function main() {
-
- const provider = new WsProvider('ws://127.0.0.1:9944')
- const api = await ApiPromise.create({ provider, types: joyTypes })
-
- const keyring = new Keyring()
- keyring.addFromUri('//Alice', undefined, 'sr25519')
- const [ALICE] = keyring.getPairs()
- const channel: ChannelEntity = {
- handle: 'Example channel',
- description: 'This is an example channel',
-
-
-
- language: { existing: { code: 'EN' } },
- coverPhotoUrl: '',
- avatarPhotoUrl: '',
- isPublic: true,
- }
-
- const parser = InputParser.createWithKnownSchemas(
- api,
-
- [
- {
- className: 'Channel',
- entries: [channel],
- },
- ]
- )
-
- const operations = await parser.getEntityBatchOperations()
- await api.tx.contentDirectory
- .transaction(
- { Member: 0 },
- operations
- )
- .signAndSend(ALICE)
- }
- main()
- .then(() => process.exit())
- .catch(console.error)
|