npm package: @hyr0-xyz/client-js
Description: Auto-generated TypeScript client for Hyro Protocol programs. This package contains Codama-generated artifacts exported as an npm module.
Latest version: 1.0.4

# @hyr0-xyz/client-js

Auto-generated TypeScript client for Hyro Protocol programs. This package contains Codama-generated artifacts exported as an npm module.

## Packages

This repository publishes two separate packages:

- **@hyr0-xyz/client-js** - For mainnet/devnet deployment with production program addresses
- **@hyr0-xyz/client-js-local** - For local development with local program addresses

## Installation

**For production/mainnet:**
```bash
npm install @hyr0-xyz/client-js @solana/kit
# or
yarn add @hyr0-xyz/client-js @solana/kit
# or
pnpm add @hyr0-xyz/client-js @solana/kit
```

**For local development:**
```bash
npm install @hyr0-xyz/client-js-local @solana/kit
# or
yarn add @hyr0-xyz/client-js-local @solana/kit
# or
pnpm add @hyr0-xyz/client-js-local @solana/kit
```

## What's Inside

This package contains auto-generated code for:

- **Instructions**: Functions to create program instructions
- **Accounts**: Type definitions and fetch helpers for program accounts
- **Types**: All custom types used by the programs
- **Errors**: Program error definitions
- **PDAs**: Helper functions for deriving Program Derived Addresses

## Available Programs

The package exports clients for all Hyro Protocol programs:

- `hyroProtocol` - Core vault and transaction management
- `policyOwners` - Owner-based policy validation
- `policyMultisig` - Multisig policy validation
- `policyManagerAccess` - Manager access control policy
- `policyLimitTransfer` - Transfer limit policy
- `policyChallenges` - Trading challenge policy
- `policyAllowAny` - Permissive policy
- `policyDenyAll` - Restrictive policy
- `feeCollection` - Fee collection program
- `feeCollectionAllInOne` - All-in-one fee collection
- `feeCollectionFractions` - Fractional fee collection
- `feeCollectionTimeBased` - Time-based fee collection
- `dropper` - Airdrop management
- `revenueGenerator` - Revenue generation

## Usage Example

```typescript
import { hyroProtocol } from '@hyr0-xyz/client-js';
import { createSolanaRpc } from '@solana/kit';

// Get RPC connection
const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');

// Use generated instruction builders
const instruction = hyroProtocol.getInitializeVaultInstruction({
  // ... instruction parameters
});

// Fetch account data
const vaultAddress = '...';
const vault = await hyroProtocol.fetchVault(rpc, vaultAddress);
```

## Generation

The packages are automatically generated from the parent repository's Anchor programs:

**For mainnet/devnet (production):**
```bash
# From repository root
cd ..
anchor build -- --features mainnet
cd client-js
bun create-codama-client.ts
bun run build
```

**For local development:**
```bash
# From repository root
cd ..
anchor build
cd client-js
bun create-codama-client.ts
bun run build
```

The generation process:

1. Builds all Anchor programs at repository root to generate IDL files (with or without `--features mainnet`)
2. Reads IDL files from `../target/idl/`
3. Uses Codama to generate TypeScript clients
4. Outputs generated code to `src/`

## Publishing

Both packages are automatically published to NPM via GitHub Actions (at repository root `.github/workflows/publish-client-js.yml`) when changes are pushed to the `main` branch:

1. **Mainnet job**: Builds Anchor programs with mainnet feature → Generates client → Publishes `@hyr0-xyz/client-js`
2. **Local job**: Builds Anchor programs for localnet → Generates client → Publishes `@hyr0-xyz/client-js-local`

The workflow is triggered on changes to:
- `programs/**`
- `client-js/**`
- `Anchor.toml`
- `Cargo.toml`

## Development

```bash
# Install dependencies
bun install

# Build package only (assumes IDL already generated)
bun run build

# Watch mode for development
bun run dev
```

**Note:** For generation, use the commands from the "Generation" section above, as they require building the entire Anchor workspace from the repository root.

## License

ISC