From 5d3f6d70c2e274a826c897cfd6c0f13e76f093a0 Mon Sep 17 00:00:00 2001 From: DarkNebula0 Date: Fri, 12 Nov 2021 01:00:16 +0100 Subject: [PATCH 1/2] Remove version --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 5d59e58..9ff484d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,6 @@ { "name": "substra-hooks", "private": true, - "version": "0.0.17", "engines": { "node": ">=14", "yarn": "^1.22.11" From cbe5cba9b04034bd76d2f644d4c81b5655141848 Mon Sep 17 00:00:00 2001 From: DarkNebula0 Date: Fri, 12 Nov 2021 01:01:20 +0100 Subject: [PATCH 2/2] Add optional types to ApiPromise --- .../providers/substrahooks-provider/provider.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/core/src/providers/substrahooks-provider/provider.tsx b/packages/core/src/providers/substrahooks-provider/provider.tsx index 88e74a6..fea9a0f 100644 --- a/packages/core/src/providers/substrahooks-provider/provider.tsx +++ b/packages/core/src/providers/substrahooks-provider/provider.tsx @@ -4,10 +4,14 @@ import { ApiProviders, SubstraHooksContext } from './context'; import { fetchSystemProperties } from '../../helpers/fetch-system-properties'; import { ExtensionProvider } from '../extension'; import { useIsMountedRef } from '../../helpers/use-is-mounted-ref'; +import { RegistryTypes } from '@polkadot/types/types'; const apiProviders: ApiProviders = {}; -export type ApiProviderConfig = Record; +export type ApiProviderConfig = Record< + string, + { id: string; wsProviderUrl: string; types?: RegistryTypes } +>; interface ISubstraHooksProviderProps { apiProviderConfig: ApiProviderConfig | null; @@ -16,10 +20,14 @@ interface ISubstraHooksProviderProps { children: ReactNode; } -export const initPolkadotPromise = async (id: string, wsProviderUrl: string) => { +export const initPolkadotPromise = async ( + id: string, + wsProviderUrl: string, + types?: RegistryTypes, +) => { if (apiProviders[id]) return apiProviders[id]; const wsProvider = new WsProvider(wsProviderUrl); - const polkadotApi = await ApiPromise.create({ provider: wsProvider }); + const polkadotApi = await ApiPromise.create({ provider: wsProvider, types: types }); await polkadotApi.isReady; const systemProperties = await fetchSystemProperties(polkadotApi); apiProviders[id] = { @@ -35,6 +43,7 @@ const initAllApis = async (apiProviderConfig: ApiProviderConfig) => { initPolkadotPromise( apiProviderConfig[configId].id, apiProviderConfig[configId].wsProviderUrl, + apiProviderConfig[configId].types, ), ), );