@gnosis-guild/enclave-react
Version:
React hooks and utilities for Enclave SDK
56 lines (53 loc) • 1.96 kB
TypeScript
import { EnclaveSDK, AllEventTypes, EventCallback, EnclaveEventType, RegistryEventType } from '@gnosis-guild/enclave-sdk';
export { AllEventTypes, CiphernodeAddedData, CiphernodeRemovedData, CiphertextOutputPublishedData, CommitteePublishedData, CommitteeRequestedData, E3ActivatedData, E3RequestedData, EnclaveEvent, EnclaveEventType, EventCallback, InputPublishedData, PlaintextOutputPublishedData, RegistryEventType } from '@gnosis-guild/enclave-sdk';
interface UseEnclaveSDKConfig {
contracts?: {
enclave: `0x${string}`;
ciphernodeRegistry: `0x${string}`;
};
chainId?: number;
autoConnect?: boolean;
}
interface UseEnclaveSDKReturn {
sdk: EnclaveSDK | null;
isInitialized: boolean;
error: string | null;
requestE3: typeof EnclaveSDK.prototype.requestE3;
activateE3: typeof EnclaveSDK.prototype.activateE3;
publishInput: typeof EnclaveSDK.prototype.publishInput;
onEnclaveEvent: <T extends AllEventTypes>(eventType: T, callback: EventCallback<T>) => void;
off: <T extends AllEventTypes>(eventType: T, callback: EventCallback<T>) => void;
EnclaveEventType: typeof EnclaveEventType;
RegistryEventType: typeof RegistryEventType;
}
/**
* React hook for interacting with Enclave SDK
*
* @param config Configuration for the SDK initialization
* @returns Object containing SDK instance and helper methods
*
* @example
* ```tsx
* import { useEnclaveSDK } from '@gnosis-guild/enclave-react';
*
* function MyComponent() {
* const {
* sdk,
* isInitialized,
* error,
* requestE3,
* onEnclaveEvent
* } = useEnclaveSDK({
* autoConnect: true,
* contracts: {
* enclave: '0x...',
* ciphernodeRegistry: '0x...'
* }
* });
*
* // Use the SDK...
* }
* ```
*/
declare const useEnclaveSDK: (config: UseEnclaveSDKConfig) => UseEnclaveSDKReturn;
export { type UseEnclaveSDKConfig, type UseEnclaveSDKReturn, useEnclaveSDK };