npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@gnosis-guild/enclave-react

v0.0.6-test

Published

React hooks and utilities for Enclave SDK

Readme

@gnosis-guild/enclave-react

React hooks and utilities for Enclave SDK.

Installation

npm install @gnosis-guild/enclave-react @gnosis-guild/enclave
# or
yarn add @gnosis-guild/enclave-react @gnosis-guild/enclave
# or
pnpm add @gnosis-guild/enclave-react @gnosis-guild/enclave

Usage

useEnclaveSDK

A React hook for interacting with the Enclave SDK. This hook provides a clean interface for managing SDK state, handling contract interactions, and listening to events.

import { useEnclaveSDK } from '@gnosis-guild/enclave-react';

function MyComponent() {
  const {
    sdk,
    isInitialized,
    error,
    requestE3,
    activateE3,
    publishInput,
    onEnclaveEvent,
    off,
    EnclaveEventType,
    RegistryEventType
  } = useEnclaveSDK({
    autoConnect: true,
    contracts: {
      enclave: '0x...',
      ciphernodeRegistry: '0x...'
    },
    chainId: 1
  });

  // Listen to events
  React.useEffect(() => {
    if (!isInitialized) return;

    const handleE3Requested = (event) => {
      console.log('E3 requested:', event.data);
    };

    onEnclaveEvent(EnclaveEventType.E3_REQUESTED, handleE3Requested);

    return () => {
      off(EnclaveEventType.E3_REQUESTED, handleE3Requested);
    };
  }, [isInitialized, onEnclaveEvent, off, EnclaveEventType]);

  // Request computation
  const handleRequest = async () => {
    try {
      const hash = await requestE3({
        filter: '0x...',
        threshold: [2, 3],
        startWindow: [BigInt(Date.now()), BigInt(Date.now() + 300000)],
        duration: BigInt(1800),
        e3Program: '0x...',
        e3ProgramParams: '0x...',
        computeProviderParams: '0x...',
        value: BigInt('1000000000000000') // 0.001 ETH
      });
      console.log('E3 requested with hash:', hash);
    } catch (error) {
      console.error('Failed to request E3:', error);
    }
  };

  if (error) {
    return <div>Error: {error}</div>;
  }

  if (!isInitialized) {
    return <div>Initializing SDK...</div>;
  }

  return (
    <div>
      <button onClick={handleRequest}>
        Request E3 Computation
      </button>
    </div>
  );
}

Features

  • Automatic Wallet Integration: Seamlessly integrates with wagmi for wallet management
  • Event Handling: Simple event subscription and cleanup
  • Error Handling: Comprehensive error states and messages
  • TypeScript Support: Full type safety with TypeScript
  • Optimized: Automatic cleanup and efficient re-renders

Requirements

  • React 18+
  • wagmi 2.0+
  • viem 2.0+

API

useEnclaveSDK(config)

Parameters

  • config.autoConnect (boolean, optional): Automatically initialize SDK when wallet is connected
  • config.contracts (object, optional): Contract addresses for Enclave and CiphernodeRegistry
  • config.chainId (number, optional): Chain ID for the network

Returns

  • sdk: The raw SDK instance
  • isInitialized: Boolean indicating if SDK is ready
  • error: Error message if initialization failed
  • requestE3: Function to request E3 computation
  • activateE3: Function to activate E3 environment
  • publishInput: Function to publish encrypted inputs
  • onEnclaveEvent: Function to subscribe to events
  • off: Function to unsubscribe from events
  • EnclaveEventType: Event type constants
  • RegistryEventType: Registry event type constants

License

MIT