Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit c5caba0

Browse files
committed
token-cli: use program_client for blockhash
1 parent 3d42786 commit c5caba0

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

token/cli/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl<'a> Config<'a> {
6969
));
7070
let sign_only = matches.is_present(SIGN_ONLY_ARG.name);
7171
let program_client: Arc<dyn ProgramClient<ProgramRpcClientSendTransaction>> = if sign_only {
72-
let blockhash = value_of(matches, BLOCKHASH_ARG.name);
72+
let blockhash = value_of(matches, BLOCKHASH_ARG.name).unwrap_or_default();
7373
Arc::new(ProgramOfflineClient::new(
7474
blockhash,
7575
ProgramRpcClientSendTransaction,

token/cli/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3138,7 +3138,7 @@ async fn handle_tx<'a>(
31383138
) -> Result<TransactionReturnData, Error> {
31393139
let fee_payer = Some(&config.fee_payer);
31403140

3141-
let recent_blockhash = config.rpc_client.get_latest_blockhash().await?;
3141+
let recent_blockhash = config.program_client.get_latest_blockhash().await?;
31423142
let message = if let Some(nonce_account) = config.nonce_account.as_ref() {
31433143
let mut message = Message::new_with_nonce(
31443144
instructions,
@@ -3151,9 +3151,9 @@ async fn handle_tx<'a>(
31513151
} else {
31523152
Message::new_with_blockhash(&instructions, fee_payer, &recent_blockhash)
31533153
};
3154-
let fee = config.rpc_client.get_fee_for_message(&message).await?;
31553154

31563155
if !config.sign_only {
3156+
let fee = config.rpc_client.get_fee_for_message(&message).await?;
31573157
check_fee_payer_balance(config, minimum_balance_for_rent_exemption + fee).await?;
31583158
}
31593159

token/client/src/client.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ where
243243

244244
/// Program client for offline signing.
245245
pub struct ProgramOfflineClient<ST> {
246-
maybe_blockhash: Option<Hash>,
246+
blockhash: Hash,
247247
_send: ST,
248248
}
249249

@@ -254,9 +254,9 @@ impl<ST> fmt::Debug for ProgramOfflineClient<ST> {
254254
}
255255

256256
impl<ST> ProgramOfflineClient<ST> {
257-
pub fn new(maybe_blockhash: Option<Hash>, send: ST) -> Self {
257+
pub fn new(blockhash: Hash, send: ST) -> Self {
258258
Self {
259-
maybe_blockhash,
259+
blockhash,
260260
_send: send,
261261
}
262262
}
@@ -275,7 +275,7 @@ where
275275
}
276276

277277
async fn get_latest_blockhash(&self) -> ProgramClientResult<Hash> {
278-
Ok(self.maybe_blockhash.unwrap())
278+
Ok(self.blockhash)
279279
}
280280

281281
async fn send_transaction(&self, transaction: &Transaction) -> ProgramClientResult<ST::Output> {

0 commit comments

Comments
 (0)