1234567891011121314151617 |
- import { ApiPromise, WsProvider } from '@polkadot/api'
- import { types } from '@joystream/types'
- import { wsLocation } from '../config.json'
- export const connectUpstream = async (): Promise<ApiPromise> => {
- console.debug(`[Joystream] Connecting to ${wsLocation}`)
- try {
- const provider = new WsProvider(wsLocation)
- const api = await ApiPromise.create({ provider, types })
- await api.isReady
- console.debug(`[Joystream] Connected to ${wsLocation}`)
- return api
- } catch (e) {
- console.error(`[Joystream] upstream connection failed`, e)
- throw new Error()
- }
- }
|