Accept any TxSigner in PerpClient; add aws feature for KMS signing#62
Conversation
PerpClient::new/new_arbitrum/new_arbitrum_sepolia are now generic over S: TxSigner<Signature> + Send + Sync + 'static instead of requiring a concrete PrivateKeySigner. Signing already flowed through EthereumWallet asynchronously, so remote signers drop in with no pipeline changes, and existing PrivateKeySigner callers compile unchanged. New opt-in `aws` cargo feature enables alloy/signer-aws, and examples/aws_kms_signer.rs shows the end-to-end flow: AWS credential chain -> KMS client -> AwsSigner -> PerpClient. This lets bots sign with a KMS asymmetric secp256k1 key that never leaves AWS, gated by IAM. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughPerpClient constructor methods ( ChangesGeneric Signer Support and AWS KMS Example
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Example as aws_kms_signer.rs
participant KmsClient as aws_sdk_kms::Client
participant AwsSigner
participant PerpClient
participant Chain as Arbitrum Sepolia
Example->>KmsClient: create client from AWS config
Example->>AwsSigner: create with KMS key id
Example->>PerpClient: new_arbitrum_sepolia(transport, AwsSigner, deployments)
PerpClient->>Chain: sync_nonce, refresh_gas, ensure_approval
Example->>PerpClient: open_taker(...)
PerpClient->>AwsSigner: sign transaction via KMS
PerpClient->>Chain: submit tx
Example->>PerpClient: adjust_taker(...) to close position
PerpClient->>AwsSigner: sign transaction via KMS
PerpClient->>Chain: submit tx
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
examples/aws_kms_signer.rs (1)
73-97: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueExample uses no slippage bounds (
amt1_limit: 0/u128::MAX).For a demo this is fine, but since this example is likely to be copy-pasted into real bots, consider a brief comment noting these are placeholder values and production code should set real slippage limits.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@examples/aws_kms_signer.rs` around lines 73 - 97, The example in aws_kms_signer.rs uses placeholder slippage bounds in open_taker and adjust_taker, which can be misleading if copied into production code. Add a brief inline comment near the OpenTakerParams and AdjustTakerParams setup explaining that amt1_limit values like 0 and u128::MAX are demo placeholders, and that real bots should set explicit slippage limits before using client.open_taker and client.adjust_taker.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@examples/aws_kms_signer.rs`:
- Around line 73-97: The example in aws_kms_signer.rs uses placeholder slippage
bounds in open_taker and adjust_taker, which can be misleading if copied into
production code. Add a brief inline comment near the OpenTakerParams and
AdjustTakerParams setup explaining that amt1_limit values like 0 and u128::MAX
are demo placeholders, and that real bots should set explicit slippage limits
before using client.open_taker and client.adjust_taker.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: df1d0297-2246-496e-8766-8c440dab7b5e
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (5)
CHANGELOG.mdCargo.tomlexamples/aws_kms_signer.rssrc/client/mod.rssrc/lib.rs
PerpClient::new/new_arbitrum/new_arbitrum_sepolia are now generic over S: TxSigner + Send + Sync + 'static instead of requiring a concrete PrivateKeySigner. Signing already flowed through EthereumWallet asynchronously, so remote signers drop in with no pipeline changes, and existing PrivateKeySigner callers compile unchanged.
New opt-in
awscargo feature enables alloy/signer-aws, and examples/aws_kms_signer.rs shows the end-to-end flow: AWS credential chain -> KMS client -> AwsSigner -> PerpClient. This lets bots sign with a KMS asymmetric secp256k1 key that never leaves AWS, gated by IAM.Summary by CodeRabbit
New Features
Bug Fixes
Documentation