import React from 'react';
import { APIProvider } from './api/provider.js';
import { BlockHeaderProvider } from './blockHeader/mod.js';
import { Config, ConfigProvider } from './config/mod.js';
import { ContractEventsProvider } from './contractEvents/mod.js';
import { ExtensionProvider } from './extension/mod.js';
import { NotificationsProvider } from './notifications/mod.js';

export type InkConfig = {
  config?: Config;
};

export const UseInkProvider: React.FC<React.PropsWithChildren<InkConfig>> = (
  { children, config },
) => (
  <ConfigProvider config={config}>
    <ExtensionProvider>
      <APIProvider>
        <BlockHeaderProvider>
          <ContractEventsProvider>
            <NotificationsProvider>
              {children}
            </NotificationsProvider>
          </ContractEventsProvider>
        </BlockHeaderProvider>
      </APIProvider>
    </ExtensionProvider>
  </ConfigProvider>
);
