caelum0x 67daa6c18c feat(rust): clawchain-alloy write path — Cosmos tx signing + broadcast (V3 complete)
Completes V3 of the vendored-integration plan. The alloy-style ClawProvider can now
build, sign (SIGN_MODE_DIRECT), and broadcast Cosmos txs, not just read:
- src/signer.rs: ClawSigner from a 32-byte hex secp256k1 key, derives the claw bech32
  address (Debug never leaks key material).
- src/tx.rs: PURE network-free builders — compute_fee, build_msg_send (bank MsgSend),
  build_msg_execute (CosmWasm MsgExecuteContract, validates JSON), build_sign_doc,
  sign_tx, encode_tx_bytes, build_and_sign. TxContext carries chain_id/account_number/
  sequence/fee as plain params.
- src/query.rs: account_query_path, broadcast_tx_sync_path, parse_account,
  parse_broadcast_sync (surfaces CheckTx code != 0).
- src/provider.rs: account(), send(...), execute_contract(...) — the one network step
  fetches chain_id + account/sequence then delegates to the pure builders + broadcasts.
Uses cosmrs 0.22.

Offline signing tests: fixed key + fixed context, decode-back via Tx::from_bytes,
assert type_url, single 64-byte secp256k1 sig, memo round-trip, and that changing
account_number changes sign-bytes (context binding). cargo build clean; 32 unit + 1
doc test pass (was 11 read-only); clippy + fmt clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-01 00:36:33 +03:00

23 lines
906 B
TOML

[package]
name = "clawchain-alloy"
version = "0.1.0"
edition = "2021"
description = "An alloy-style provider for ClawChain, backed by Tendermint RPC + Cosmos REST (not eth_* JSON-RPC)."
license = "MIT OR Apache-2.0"
# Standalone crate intentionally OUTSIDE the vendored `alloy/` workspace.
# Do not add to `alloy/Cargo.toml` members — that upstream is a read-only reference.
[package.metadata]
note = "ClawChain-native; reuses alloy's Provider naming/ergonomics, but speaks Cosmos transport."
[dependencies]
reqwest = { version = "0.12", features = ["blocking", "json"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
base64 = "0.22"
thiserror = "1"
# Cosmos SDK tx builder + signer (write path): tx::Body/Fee/SignDoc,
# crypto::secp256k1::SigningKey, and cosmwasm MsgExecuteContract via cosmrs::cosmwasm.
cosmrs = { version = "0.22", features = ["cosmwasm", "bip32"] }
hex = "0.4"