|
@@ -1,4 +1,4 @@
|
|
-import { ApiPromise } from "@polkadot/api";
|
|
|
|
|
|
+import { ApiPromise, WsProvider } from "@polkadot/api";
|
|
import moment from "moment";
|
|
import moment from "moment";
|
|
|
|
|
|
// types
|
|
// types
|
|
@@ -17,7 +17,7 @@ import {
|
|
Moment,
|
|
Moment,
|
|
} from "@polkadot/types/interfaces";
|
|
} from "@polkadot/types/interfaces";
|
|
import { SignedBlock } from "@polkadot/types/interfaces/runtime";
|
|
import { SignedBlock } from "@polkadot/types/interfaces/runtime";
|
|
-
|
|
|
|
|
|
+import { types } from "@joystream/types";
|
|
import { PostId, ThreadId } from "@joystream/types/common";
|
|
import { PostId, ThreadId } from "@joystream/types/common";
|
|
import { CategoryId, Category, Thread, Post } from "@joystream/types/forum";
|
|
import { CategoryId, Category, Thread, Post } from "@joystream/types/forum";
|
|
import {
|
|
import {
|
|
@@ -47,6 +47,11 @@ import { ProposalOf, ProposalDetailsOf } from "@joystream/types/augment/types";
|
|
|
|
|
|
import { WorkerOf } from "@joystream/types/augment-codec/all";
|
|
import { WorkerOf } from "@joystream/types/augment-codec/all";
|
|
|
|
|
|
|
|
+export const connectApi = async (url: string): Promise<ApiPromise> => {
|
|
|
|
+ const provider = new WsProvider(url);
|
|
|
|
+ return await ApiPromise.create({ provider, types });
|
|
|
|
+};
|
|
|
|
+
|
|
// blocks
|
|
// blocks
|
|
export const getBlock = (api: ApiPromise, hash: Hash): Promise<SignedBlock> =>
|
|
export const getBlock = (api: ApiPromise, hash: Hash): Promise<SignedBlock> =>
|
|
api.rpc.chain.getBlock(hash);
|
|
api.rpc.chain.getBlock(hash);
|