1 import { createContext, useContext, useMemo } from 'react';
3 import { type WasmProtonWalletApiClient } from '@proton/andromeda';
5 export const ExtendedApiContext = createContext<{ walletApi: WasmProtonWalletApiClient } | undefined>(undefined);
7 export const useWalletApi = () => {
8 const extendedApiContext = useContext(ExtendedApiContext);
10 if (!extendedApiContext) {
11 throw new Error('extended wallet API can only be used in ExtendedApiContext');
14 return extendedApiContext.walletApi;
17 export const useWalletApiClients = () => {
18 const walletApi = useWalletApi();
19 return useMemo(() => walletApi.clients(), [walletApi]);