UNPKG

@shogun-sdk/one-shot

Version:

Shogun SDK - One Shot: React Components and hooks for cross-chain swaps

25 lines 838 B
import React, { createContext, useContext } from 'react'; /** * Creates a React context for storing the API key. */ const ShogunBalancesContext = createContext(null); /** * Provider component for wrapping parts of the app that need access to the API key. */ export function ShogunLegoProvider({ children, apiKey }) { // Context value containing the API key const value = { API_KEY: apiKey }; return React.createElement(ShogunBalancesContext.Provider, { value: value }, children); } /** * * Ensures the hook is only used within a `ShogunLegoProvider`. */ export function useShogunLego() { const context = useContext(ShogunBalancesContext); if (!context) { throw new Error('useShogunLego must be used within a ShogunLegoProvider'); } return context; } //# sourceMappingURL=ShogunLegoContext.js.map