import React from 'react'
import { createContext } from 'react'

import { SolanaWalletAdapterState } from '../../core'

export interface SolanaConnectionPromise {
  resolve: (extensionState: SolanaWalletAdapterState) => void
  reject: (e: Error) => void
}

interface SolanaConnectorContextProps {
  visible: boolean
  setVisible: React.Dispatch<React.SetStateAction<boolean>>
  connectionPromise?: SolanaConnectionPromise
  setConnectionPromise: React.Dispatch<React.SetStateAction<SolanaConnectionPromise | undefined>>
}

export const SolanaConnectorContext = createContext<SolanaConnectorContextProps>({
  visible: false,
  setVisible: () => {},
  connectionPromise: undefined,
  setConnectionPromise: () => {}
})
