Skip to content

fix+feat: unbreak CI + Arbitrum AgentAccount primitives#4

Merged
abhicris merged 1 commit into
mainfrom
fix-ci-and-arbitrum-agent-account
Apr 21, 2026
Merged

fix+feat: unbreak CI + Arbitrum AgentAccount primitives#4
abhicris merged 1 commit into
mainfrom
fix-ci-and-arbitrum-agent-account

Conversation

@abhicris
Copy link
Copy Markdown
Contributor

CI root cause

cargo clippy -- -D warnings has been red for 16 days due to 7 accumulated lint errors:

  • 3 unused imports (SwapParams in dex/router.rs, Address in dex/types.rs, U256 in oracle/mod.rs)
  • chain field on UniswapV3Router never read
  • Manual impl Default for AgentBuilder when #[derive(Default)] suffices
  • type_complexity on the alloy filled-provider in ChainConnector
  • WalletManager::next shadowing Iterator::next

Fixes

  • Drop stale imports.
  • Expose UniswapV3Router::chain() (now the field is read, also useful surface).
  • #[derive(Default)] for AgentBuilder.
  • Alias the alloy provider as DefaultFilledProvider; add ChainConnector::provider() so downstream modules can call contracts against it.
  • Rename WalletManager::next -> next_wallet.
  • cargo fmt normalized a few pre-existing formatting drifts.

Feature: Arbitrum AgentAccount primitives

Why this matters (agent-economy thesis)

arka is the Rust SDK layer that sits under agent-registry interactions. The first agent-economy deployments target Arbitrum with USDC settlement — that substrate needs first-class support in the SDK.

An agent's lifecycle on chain looks like: register -> deposit USDC -> earn fees -> execute paid tasks -> withdraw. This PR turns that lifecycle into a chain-agnostic trait (AgentAccount) with a working Arbitrum client as the first concrete implementation. Future registries (Base, Optimism, Tempo) plug in behind the same trait without the agent logic needing to know.

What's new

  • src/agent/account.rsAgentAccount trait: deposit, balance, withdraw, execute_task. Shape matches AgentDeposit-style registries, ERC-4337 smart accounts, and x402 escrows. Ships with InMemoryAgentAccount, a working (not stubbed) registry for tests and local simulation. TaskReceipt carries task id, agent, fee, and success.
  • src/chains/arbitrum.rsArbitrumContracts static addresses (native USDC, USDC.e, USDT, WETH, Uniswap V3 router + quoter) + AgentDepositClient. The client builds calldata for an IAgentAccount Solidity interface via alloy::sol!deposit(uint256), balanceOf(address), withdraw(uint256), executeTask(bytes32,bytes). Calldata-only by design: callers feed it into their signing/broadcast pipeline, so the client is testable without an RPC.
  • examples/agent_account.rs — runs the in-memory flow end to end and prints real Arbitrum deposit calldata ready for submission.
  • PreludeAgentAccount, InMemoryAgentAccount, TaskReceipt, AgentDepositClient, ArbitrumContracts are now in arka::prelude::*.

Tests

14 unit tests, all green locally:

  • chains::arbitrum::* — exact selector bytes (0xb6b55f25 deposit, 0x70a08231 balanceOf), calldata lengths, USDC wiring, chain-id alignment, custom settlement-token override, executeTask layout.
  • agent::account::* — deposit/balance roundtrip, withdraw math, overdraw rejection, fee-charging + receipt emission, registered-agent counting.

Test plan

  • cargo check --all-features (clean)
  • cargo clippy --all-targets -- -D warnings (clean)
  • cargo fmt -- --check (clean)
  • cargo test --lib — 14/14 pass
  • CI green on push

-- kcolbchain / Abhishek Krishna

CI root cause
-------------
`cargo clippy -- -D warnings` surfaced 7 lint failures that had accumulated:
unused imports (`SwapParams`, `Address`, `U256`), an unread `chain` field
on `UniswapV3Router`, a manual `Default` impl on `AgentBuilder`, a
`type_complexity` violation on the alloy filled-provider, and `WalletManager::next`
shadowing `Iterator::next`. CI was red for 16 days.

Fixes
-----
- Drop the stale imports.
- Expose the router chain via `UniswapV3Router::chain()` instead of suppressing.
- `#[derive(Default)]` for `AgentBuilder`.
- Alias the alloy provider type as `DefaultFilledProvider` and expose `provider()` on
  `ChainConnector` (enables contract-typed calls downstream).
- Rename `WalletManager::next` -> `next_wallet`.
- `cargo fmt` normalized a handful of unrelated formatting drifts.

Feature
-------
Arbitrum agent-economy primitives aligned with the AI-agent thesis:

- `src/agent/account.rs` — new `AgentAccount` trait (deposit / balance /
  withdraw / execute_task) matching the shape of AgentDeposit-style registries,
  ERC-4337 smart accounts, and x402 escrows. Ships with `InMemoryAgentAccount`,
  a working (not stubbed) registry for tests and local simulation.
- `src/chains/arbitrum.rs` — `ArbitrumContracts` (native USDC, USDC.e, USDT,
  WETH, Uniswap V3 router + quoter) and `AgentDepositClient`, a typed
  calldata builder for an `IAgentAccount` Solidity interface. Builds
  `deposit(uint256)`, `balanceOf(address)`, `withdraw(uint256)`, and
  `executeTask(bytes32,bytes)` calldata via `alloy::sol!`.
- `examples/agent_account.rs` — demonstrates the in-memory flow end-to-end
  and builds the Arbitrum deposit calldata an agent would broadcast.
- Prelude re-exports the new types so `use arka::prelude::*;` covers the
  full agent-account surface.

Tests
-----
14 unit tests, all green locally:
- `chains::arbitrum` — selector bytes (`0xb6b55f25` deposit, `0x70a08231`
  balanceOf), calldata lengths, USDC wiring, chain-id alignment, custom
  settlement-token override, executeTask layout.
- `agent::account` — deposit/balance roundtrip, withdraw math, overdraw
  rejection, fee-charging + receipt emission, and registered-agent counting.

Why this matters
----------------
arka is the SDK layer that sits under agent-registry interactions. The
first agent-economy deployments target Arbitrum with USDC settlement, so
first-class Arbitrum primitives and an `AgentAccount` abstraction are
on-path: an agent registers, deposits USDC, earns fees, executes paid
tasks — all through one chain-agnostic trait, with a working Arbitrum
client as the first concrete implementation. On-chain implementations of
other registries (Base, Optimism, Tempo) plug in behind the same trait.

— [kcolbchain](https://kcolbchain.com) / [Abhishek Krishna](https://abhishekkrishna.com)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.

1 participant