diff --git a/src/interfaces/fulaNativeModule.ts b/src/interfaces/fulaNativeModule.ts index a4495d1..42ac499 100644 --- a/src/interfaces/fulaNativeModule.ts +++ b/src/interfaces/fulaNativeModule.ts @@ -1,7 +1,7 @@ import { NativeModules, Platform } from 'react-native'; interface FulaNativeModule { - init: ( + initFula: ( identity: string, //Private key of did identity storePath: string, //You can leave empty bloxAddr: string, //Blox multiadddr needs to be manually entered now diff --git a/src/protocols/chain-api.ts b/src/protocols/chain-api.ts index c94ffab..7979fb3 100644 --- a/src/protocols/chain-api.ts +++ b/src/protocols/chain-api.ts @@ -74,6 +74,10 @@ export const listPools = async ( if (api === undefined) { api = await init(); } + // Type guard to assure TypeScript that api is not undefined + if (!api || !api.query || !api.query.pool || !api.query.pool.lastPoolId || !api.query.pool.pools) { + throw new Error('Failed to initialize api or api.query.pool'); + } const pools: BType.PoolListResponse = { pools: [] }; const lastPoolId = await api.query.pool.lastPoolId(); let finalReturnedId: number = Number(lastPoolId.toHuman()); @@ -111,6 +115,10 @@ export const checkJoinRequest = async ( if (api === undefined) { api = await init(); } + // Type guard to assure TypeScript that api is not undefined + if (!api || !api.query || !api.query.pool || !api.query.pool.poolRequests) { + throw new Error('Failed to initialize api or api.query.pool'); + } const poolRequest = await api.query.pool.poolRequests(poolId, accountId);