Skip to content

Latest commit

 

History

History
183 lines (138 loc) · 4.94 KB

index.md

File metadata and controls

183 lines (138 loc) · 4.94 KB

Pluto React Native SDK Documentation

The Pluto React Native SDK provides components and functions for generating proofs in React Native applications.

Installation

To use any of the components or functions in this SDK, install the package:

npm install @plutoxyz/react-native-sdk
# or
yarn add @plutoxyz/react-native-sdk

After installing, for iOS projects, run pod install:

cd ios && pod install

Note: This SDK currently supports iOS only. Android support is planned for future releases.

Components

Functions

Types

  • Types Reference - Detailed type definitions for manifests and related types

Features

  • RequestBuilder: A component for building and customizing requests with browser-based user interaction
  • ProofGenerator: A component that combines RequestBuilder with proof generation
  • Direct API functions: For programmatic proof generation

Platform Support

Platform Support Status
iOS ✅ Fully Supported
Android ❌ Not yet supported (planned for future releases)

When used in an Android application, all methods and components will gracefully throw errors with clear messages indicating the lack of Android support. This ensures your cross-platform app doesn't crash, but you'll need to implement platform-specific logic to handle these cases.

import { Platform } from "react-native";
import { ProofGenerator } from "@plutoxyz/react-native-sdk";

// Only use the component on iOS
{
  Platform.OS === "ios" && (
    <ProofGenerator
      manifestUrl="https://example.com/manifest.json"
      onProofGenerated={(proof) => {
        console.log("Proof generated:", proof);
      }}
      onError={(error) => {
        console.error("Error:", error);
      }}
    />
  );
}

For Developers

Directory Structure

  • src/: Source code for the library

    • components/: React components
      • RequestBuilder.tsx: Wrapper for the Swift RequestBuilder
      • ProofGenerator.tsx: Component that combines RequestBuilder with proof generation
    • bridge/: Native bridging code
      • NativeBridge.tsx: Bridge functions to the Swift SDK
    • types/: TypeScript type definitions
    • index.ts: Main entry point that exports everything
  • example/: Example/test app

    • App.tsx: Test application for the library
  • ios/: iOS native code

    • PLUTO_SWIFT_SDK/: Reference files from the PlutoSwiftSDK pod

Contributing

Contributions are welcome! Here's how you can contribute to this project:

  1. Fork the repository
  2. Clone your fork:
    git clone https://github.com/your-username/react-native-pluto-sdk.git
    cd react-native-pluto-sdk
  3. Install dependencies:
    npm install
  4. Create a feature branch:
    git checkout -b feature/amazing-feature
  5. Make your changes and commit them:
    git commit -m 'Add some amazing feature'
  6. Push to the branch:
    git push origin feature/amazing-feature
  7. Open a Pull Request

Please make sure your code follows the existing style and include appropriate tests.

Building and Testing

To build the library:

npm run build

To run tests:

npm test

To try the example app:

# Navigate to the example directory
cd example
# Install dependencies
npm install
# Run the app on iOS
npm run ios

Releasing

This library uses release-it to manage releases with automatic versioning and changelog generation.

To release a new version:

  1. Make sure all changes are committed and pushed
  2. Update the CHANGELOG.md file:
    • Add a new section for the upcoming version at the top of the file
    • Document all notable changes under appropriate categories (Added, Changed, Fixed, etc.)
    • Follow the Keep a Changelog format
  3. Commit the changelog update:
    git add CHANGELOG.md
    git commit -m 'Update changelog for version X.Y.Z'
  4. Run the release command:
    npm run release
  5. Follow the prompts to choose the version type (major, minor, patch, or prerelease)
  6. The tool will automatically:
    • Bump the version in package.json
    • Create a git tag
    • Push to GitHub
    • Publish to npm

For a prerelease version (alpha/beta):

# For alpha releases
npm run release -- --preRelease=alpha

# For beta releases
npm run release -- --preRelease=beta