diff --git a/crates/aptos/CHANGELOG.md b/crates/aptos/CHANGELOG.md index af13bddb60bfb..e1635f52de462 100644 --- a/crates/aptos/CHANGELOG.md +++ b/crates/aptos/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to the Aptos CLI will be captured in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and the format set out by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +# Unreleased + +- Add `--node-api-key` flag to `aptos move replay` to allow for querying the fullnode with an API key. + + ## [4.5.0] - 2024/11/15 - Determine network from URL to make explorer links better for legacy users - Add support for AIP-80 compliant strings when importing using the CLI arguments or manual input. diff --git a/crates/aptos/src/move_tool/mod.rs b/crates/aptos/src/move_tool/mod.rs index a59f28e5c966f..bd0da93576ca6 100644 --- a/crates/aptos/src/move_tool/mod.rs +++ b/crates/aptos/src/move_tool/mod.rs @@ -45,7 +45,7 @@ use aptos_move_debugger::aptos_debugger::AptosDebugger; use aptos_rest_client::{ aptos_api_types::{EntryFunctionId, HexEncodedBytes, IdentifierWrapper, MoveModuleId}, error::RestError, - Client, + AptosBaseUrl, Client, }; use aptos_types::{ account_address::{create_resource_address, AccountAddress}, @@ -2179,6 +2179,11 @@ pub struct Replay { /// If present, skip the comparison against the expected transaction output. #[clap(long)] pub(crate) skip_comparison: bool, + + /// Key to use for ratelimiting purposes with the node API. This value will be used + /// as `Authorization: Bearer ` + #[clap(long)] + pub(crate) node_api_key: Option, } impl FromStr for ReplayNetworkSelection { @@ -2216,10 +2221,20 @@ impl CliCommand for Replay { RestEndpoint(url) => url, }; - let debugger = AptosDebugger::rest_client(Client::new( + // Build the client + let client = Client::builder(AptosBaseUrl::Custom( Url::parse(rest_endpoint) .map_err(|_err| CliError::UnableToParse("url", rest_endpoint.to_string()))?, - ))?; + )); + + // add the node API key if it is provided + let client = if let Some(api_key) = self.node_api_key { + client.api_key(&api_key).unwrap().build() + } else { + client.build() + }; + + let debugger = AptosDebugger::rest_client(client)?; // Fetch the transaction to replay. let (txn, txn_info) = debugger