|
@@ -1,4 +1,4 @@
|
|
|
-import { ApiPromise } from "@polkadot/api";
|
|
|
+import { ApiPromise, WsProvider } from "@polkadot/api";
|
|
|
import moment from "moment";
|
|
|
|
|
|
// types
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
Moment,
|
|
|
} from "@polkadot/types/interfaces";
|
|
|
import { SignedBlock } from "@polkadot/types/interfaces/runtime";
|
|
|
-
|
|
|
+import { types } from "@joystream/types";
|
|
|
import { PostId, ThreadId } from "@joystream/types/common";
|
|
|
import { CategoryId, Category, Thread, Post } from "@joystream/types/forum";
|
|
|
import {
|
|
@@ -47,6 +47,11 @@ import { ProposalOf, ProposalDetailsOf } from "@joystream/types/augment/types";
|
|
|
|
|
|
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
|
|
|
export const getBlock = (api: ApiPromise, hash: Hash): Promise<SignedBlock> =>
|
|
|
api.rpc.chain.getBlock(hash);
|