-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
check for funds on the ppl chain and add warning and info
- Loading branch information
Showing
19 changed files
with
151 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { useMemo } from 'react' | ||
import { useApi } from '../contexts/ApiContext' | ||
import { usePplApi } from '../contexts/PeopleChainApiContext' | ||
|
||
interface Props { | ||
withPplApi: boolean | ||
} | ||
|
||
export const useAnyApi = ({ withPplApi }: Props) => { | ||
const normalCtx = useApi() | ||
const { | ||
api: normalApi, | ||
compatibilityToken: normalCompatibilityToken, | ||
chainInfo: normalChainInfo, | ||
client: normalClient | ||
} = normalCtx | ||
const pplCtx = usePplApi() | ||
const { pplApi, pplCompatibilityToken, pplChainInfo, pplClient } = pplCtx | ||
|
||
const api = useMemo(() => (withPplApi ? pplApi : normalApi), [withPplApi, normalApi, pplApi]) | ||
const compatibilityToken = useMemo( | ||
() => (withPplApi ? pplCompatibilityToken : normalCompatibilityToken), | ||
[withPplApi, normalCompatibilityToken, pplCompatibilityToken] | ||
) | ||
const chainInfo = useMemo( | ||
() => (withPplApi ? pplChainInfo : normalChainInfo), | ||
[withPplApi, normalChainInfo, pplChainInfo] | ||
) | ||
const client = useMemo( | ||
() => (withPplApi ? pplClient : normalClient), | ||
[withPplApi, normalClient, pplClient] | ||
) | ||
|
||
return { api, compatibilityToken, chainInfo, client } | ||
} |
Oops, something went wrong.