1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import { ApiPromise, WsProvider } from '@polkadot/api'
- import { types as joyTypes } from '@joystream/types'
- import { Keyring } from '@polkadot/keyring'
- import { InputParser } from 'cd-schemas'
- import { ChannelEntity } from 'cd-schemas/types/entities'
- import { FlattenRelations } from 'cd-schemas/types/utility'
- 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 channelUpdateInput: Partial<FlattenRelations<ChannelEntity>> = {
- title: 'Updated channel title 2',
- }
-
- const parser = InputParser.createWithKnownSchemas(api)
-
-
-
- const CHANNEL_ID = await parser.findEntityIdByUniqueQuery({ title: 'Example channel 2' }, 'Channel')
-
- const newPropertyValues = await parser.parseToInputEntityValuesMap(channelUpdateInput, 'Channel')
- await api.tx.contentDirectory
- .updateEntityPropertyValues(
- { Member: 0 },
- CHANNEL_ID,
- newPropertyValues
- )
- .signAndSend(ALICE)
- }
- main()
- .then(() => process.exit())
- .catch(console.error)
|