feat: add Rust SDK with full x402 payment support#63
Open
kmjones1979 wants to merge 4 commits intoedgeandnode:mainfrom
Open
feat: add Rust SDK with full x402 payment support#63kmjones1979 wants to merge 4 commits intoedgeandnode:mainfrom
kmjones1979 wants to merge 4 commits intoedgeandnode:mainfrom
Conversation
Adds a Rust implementation of the ampersend SDK with feature parity to the TypeScript SDK, including: - Core x402 traits (X402Treasurer, X402Wallet) and types - Wallet implementations (AccountWallet for EOA, SmartAccountWallet with ERC-3009/ERC-1271) - Treasurer implementations (NaiveTreasurer, AmpersendTreasurer with SIWE auth) - Ampersend API client (SIWE authentication, payment authorization, event reporting) - Ampersend Management client (agent deployment and listing) - MCP client with automatic x402 payment retry - MCP proxy server (axum) with x402 bridge middleware - FastMCP server middleware for payment requirements - HTTP adapter with automatic 402 handling - v1/v2 protocol adapter (CAIP-2 network conversion) - CLI binary (ampersend-proxy) with environment-based config - 91 unit tests + 5 integration tests against live Ampersend API - CI workflow (build, clippy, fmt, test) - Release workflow (crates.io publish on rs-v* tags) - README with quick start examples for all entry points - CLAUDE.md updated with Rust setup, testing, and architecture docs Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fills test coverage gaps identified against the TypeScript and Python SDKs: - MCP client middleware: 402 detection, payment retry with _meta, treasurer decline/approve, status lifecycle (sending→accepted/rejected), no-retry when payment already present, non-402 passthrough - HTTP adapter: 402→retry with X-PAYMENT header, treasurer decline, rejected retry (second 402), error on 500 retry, non-JSON/non-x402 402 handling, request body preservation, base64 header encoding - ERC-3009 signing: signature structure (85 bytes = 20 validator + 65 EOA), validator address prefix, v value validation, nonce uniqueness, invalid key rejection Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Apply cargo fmt to test files (http_adapter, mcp_client, signing) - Replace server_url unwrap() with expect() in MCP client connect flow - Add test job to rust-release workflow; publish depends on verify-version + test Made-with: Cursor
- Add wallet_creates_payment_from_env: create payment from env config (EOA or smart account), assert payload shape - Add management_list_agents: optional test when AMPERSEND_API_KEY is set - Update module doc to describe treasurer, wallet, and management coverage Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rust/ampersend-sdk/) with feature parity to the TypeScript SDKX402Treasurer,X402Wallet), wallet implementations (EOA + Smart Account with ERC-3009/ERC-1271), and treasurer implementations (NaiveTreasurer+AmpersendTreasurerwith SIWE auth)ampersend-proxy) with environment-based configurationWhat's included
x402/x402/wallets/x402/treasurers/smart_account/ampersend/mcp/client/mcp/proxy/mcp/server/http/bin/ampersend-proxyCLITest plan
cargo build --all-features— clean build, zero warningscargo clippy --all-features -- -D warnings— zero clippy warningscargo fmt --check— properly formattedcargo test— 114 unit tests pass across 13 test files:cargo test --test integration_test -- --ignored— 5 integration tests pass against live Ampersend API (SIWE auth, payment authorization, full lifecycle, rejection/error reporting)🤖 Generated with Claude Code