npm package: @skate-org/amm-contracts-binding
Description: TypeScript bindings for Skate AMM contracts
Author: Skate
Latest version: 1.0.0

# @skate-org/amm-contracts-binding

TypeScript bindings for Skate AMM contracts - providing type-safe access to ABIs and function selectors.

## Features

- ✅ **Type-safe ABIs** - All contract ABIs exported as TypeScript constants with proper typing
- ✅ **Function Selectors** - Enums for all contract function selectors
- ✅ **Dual Build** - ESM and CJS support via tsup
- ✅ **Auto-generated** - Automatically generated from contract artifacts
- ✅ **Tree-shakeable** - Import only what you need
- ✅ **Source Maps** - Full source map support for debugging

## Installation

```bash
npm install @skate-org/amm-contracts-binding
# or
yarn add @skate-org/amm-contracts-binding
# or
pnpm add @skate-org/amm-contracts-binding
```

## Usage

### Importing ABIs

```typescript
import { KernelManagerABI, PeripheryPoolABI } from '@skate-org/amm-contracts-binding';

// Use with viem
import { createPublicClient, http } from 'viem';

const client = createPublicClient({
  transport: http(),
});

const data = await client.readContract({
  address: '0x...',
  abi: KernelManagerABI,
  functionName: 'getPool',
  args: [token0, token1, fee],
});
```

### Importing Selectors

```typescript
import {
  KernelManagerSelectors,
  KernelManagerSelectorsMap
} from '@skate-org/amm-contracts-binding';

// Use enum values
const selector = KernelManagerSelectors.createPool;
console.log(selector); // '0x...'

// Use selector map for signature lookups
const sig = 'createPool(address,address,uint24)';
const selector2 = KernelManagerSelectorsMap[sig];
console.log(selector2); // '0x...'
```

### Importing Everything

```typescript
import { ABIs, Selectors } from '@skate-org/amm-contracts-binding';

// Access all ABIs
const kernelManagerABI = ABIs.KernelManager;
const peripheryPoolABI = ABIs.PeripheryPool;

// Access all selectors
const kernelSelectors = Selectors.KernelManager;
const peripherySelectors = Selectors.PeripheryPool;
```

## Available Contracts

### AMM Contracts

**Kernel:**
- `KernelManager` / `KernelManagerABI` / `KernelManagerSelectors`
- `KernelPool` / `KernelPoolABI` / `KernelPoolSelectors`
- `KernelEventEmitter` / `KernelEventEmitterABI` / `KernelEventEmitterSelectors`
- `KernelManagerStorage` / `KernelManagerStorageABI` / `KernelManagerStorageSelectors`

**Periphery:**
- `PeripheryManager` / `PeripheryManagerABI` / `PeripheryManagerSelectors`
- `PeripheryPool` / `PeripheryPoolABI` / `PeripheryPoolSelectors`
- `PeripheryEventEmitter` / `PeripheryEventEmitterABI` / `PeripheryEventEmitterSelectors`

**Interfaces:**
- All kernel and periphery interfaces (`IKernelManager`, `IPeripheryPool`, etc.)

### Skate Contracts

**Kernel:**
- `AccountRegistry` / `AccountRegistryABI` / `AccountRegistrySelectors`
- `MessageBox` / `MessageBoxABI` / `MessageBoxSelectors`
- `SkateApp` / `SkateAppABI` / `SkateAppSelectors`

**Periphery:**
- `SkateGateway` / `SkateGatewayABI` / `SkateGatewaySelectors`
- `SkateAppPeriphery` / `SkateAppPeripheryABI` / `SkateAppPeripherySelectors`
- `ActionBox` / `ActionBoxABI` / `ActionBoxSelectors`

**Common:**
- `ExecutorRegistry` / `ExecutorRegistryABI` / `ExecutorRegistrySelectors`
- `Multicall` / `MulticallABI` / `MulticallSelectors`

## Development

### Regenerate Bindings

```bash
# From the package directory (packages/ts-binding)
npm run generate
# or
make generate

# From the root repository
make gen-all
cd packages/ts-binding && make generate
```

### Build

```bash
npm run build
# or
make build
```

### Clean

```bash
npm run clean
# or
make clean
```

### Available Make Commands

Run `make help` to see all available commands:
- `make install` - Install dependencies
- `make generate` - Generate TypeScript from ABIs/selectors
- `make build` - Build the package
- `make clean` - Clean generated files
- `make check` - Verify generated files are up-to-date
- `make all` - Clean, install, generate, and build

## Package Structure

```
dist/
├── index.js          # ESM build
├── index.cjs         # CommonJS build
├── index.d.ts        # TypeScript declarations (ESM)
├── index.d.cts       # TypeScript declarations (CJS)
└── *.map             # Source maps
```

## TypeScript Support

This package is built with TypeScript and includes full type definitions. ABIs are typed as `const` assertions, providing maximum type safety.

```typescript
import { KernelManagerABI } from '@skate-org/amm-contracts-binding';

// The ABI type is inferred from the const assertion
type KernelManagerABIType = typeof KernelManagerABI;
```

## License

MIT

## Publishing

### Prerequisites

1. **NPM Account**: You need an npm account with publish access to `@skate-org`
2. **Authentication**: Login to npm (only needed once per machine)

```bash
npm login
```

### Publishing Workflow

```bash
# 1. Update version in package.json
# Follow semantic versioning: major.minor.patch

# 2. Generate and build
make build

# 3. Test the package locally (dry run)
npm run publish:dry
# or
make publish-dry

# 4. Publish to npm
npm run publish:release
# or
make publish
```

### Automated Publishing (CI/CD)

For CI/CD pipelines, set the `NPM_TOKEN` environment variable:

```yaml
# GitHub Actions example
- name: Publish to npm
  run: npm publish
  env:
    NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
```

## Contributing

This package is auto-generated from the contract artifacts. To update:

1. Update the contracts in the main repository
2. Run `make gen-all` to regenerate ABIs and selectors
3. Run `npm run build` in this package to rebuild bindings
4. Commit the generated files

## Links

- [Skate Documentation](https://docs.skate.com)
- [GitHub Repository](https://github.com/skate-org)