Skip to content

Conversation

@uwezukwechibuzor
Copy link
Contributor

Summary

Added an interactive CLI tool to auto-generate pegged asset adapter boilerplate

What's New

Command:

npm run create-adapter

Two modes:

  • Interactive - Guided with prompts
  • Non-interactive - One-line command with flags
npm run create-adapter -- \
  --name "PUSD" \
  --id "pusd" \
  --chains "ethereum,bsc" \
  --addresses "0x...,0x..." \
  --types "m,b"

Generates:
index.ts - Properly configured adapter
README.md - Complete documentation

Key Features
✅ supports all chains in chain.json
✅ 18 peg types (USD, EUR, GBP, etc.)
✅ Minted/bridged token handling
✅ Reserve address configuration
✅ Duplicate adapter detection

Files Changed

4 files changed
 README.md                       |  32 ++ (Quick start section)
 package.json                    |   1 +  (npm script)
 src/cli/CREATE_ADAPTER_GUIDE.md | 308 +++++ (User guide)
 src/cli/createAdapter.ts        | 709 +++++ (Core implementation)

Benefits

For Contributors:

  • Instant adapter scaffolding
  • No more copy-paste errors
  • Built-in best practices
    For Maintainers:
  • Consistent adapter structure
  • Faster process

Testing

Tested with:
Single/multi-chain adapters ✓
All peg types ✓
Minted/bridged configurations ✓
Reserve addresses ✓
Edge cases (duplicates) ✓

Example Output

Generated index.ts:

import { addChainExports } from "../helper/getSupply";

const chainContracts = {
  ethereum: {
    issued: ["0x..."]
  },
  bsc: {
    bridgedFromETH: ["0x..."]
  }
};

const adapter = addChainExports(chainContracts, undefined, {
  pegType: "peggedUSD",
  decimals: 18,
});

export default adapter;

Documentation

Quick start in main README
Detailed guide: src/cli/CREATE_ADAPTER_GUIDE.md
Built-in help: npm run create-adapter -- --help

Type: Feature (Tooling)
Breaking Changes: None
Branch: feat/cli-adapter-template-generator

@Define101
Copy link
Member

@uwezukwechibuzor Thanks a lot for the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants