Skip to content

Commit

Permalink
Add flag to to allow for querying the fullnode with an API key
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmaayan committed Nov 21, 2024
1 parent 1a4fe24 commit 749fff9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
5 changes: 5 additions & 0 deletions crates/aptos/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
21 changes: 18 additions & 3 deletions crates/aptos/src/move_tool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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 <key>`
#[clap(long)]
pub(crate) node_api_key: Option<String>,
}

impl FromStr for ReplayNetworkSelection {
Expand Down Expand Up @@ -2216,10 +2221,20 @@ impl CliCommand<TransactionSummary> 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
Expand Down

0 comments on commit 749fff9

Please sign in to comment.