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

Commit 2ea6dfa

Browse files
committed
token-cli: let clients return signature or txn
1 parent c5caba0 commit 2ea6dfa

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

token/client/src/client.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,14 @@ pub trait SendTransactionRpc: SendTransaction {
6262
#[derive(Debug, Clone, Copy, Default)]
6363
pub struct ProgramRpcClientSendTransaction;
6464

65+
#[derive(Debug, Clone, PartialEq, Eq)]
66+
pub enum RpcClientResponse {
67+
Signature(Signature),
68+
Transaction(Transaction),
69+
}
70+
6571
impl SendTransaction for ProgramRpcClientSendTransaction {
66-
type Output = Signature;
72+
type Output = RpcClientResponse;
6773
}
6874

6975
impl SendTransactionRpc for ProgramRpcClientSendTransaction {
@@ -76,12 +82,12 @@ impl SendTransactionRpc for ProgramRpcClientSendTransaction {
7682
client
7783
.send_and_confirm_transaction(transaction)
7884
.await
85+
.map(RpcClientResponse::Signature)
7986
.map_err(Into::into)
8087
})
8188
}
8289
}
8390

84-
//
8591
pub type ProgramClientError = Box<dyn std::error::Error + Send + Sync>;
8692
pub type ProgramClientResult<T> = Result<T, ProgramClientError>;
8793

@@ -265,7 +271,7 @@ impl<ST> ProgramOfflineClient<ST> {
265271
#[async_trait]
266272
impl<ST> ProgramClient<ST> for ProgramOfflineClient<ST>
267273
where
268-
ST: SendTransaction<Output = Signature> + Send + Sync,
274+
ST: SendTransaction<Output = RpcClientResponse> + Send + Sync,
269275
{
270276
async fn get_minimum_balance_for_rent_exemption(
271277
&self,
@@ -279,7 +285,7 @@ where
279285
}
280286

281287
async fn send_transaction(&self, transaction: &Transaction) -> ProgramClientResult<ST::Output> {
282-
Ok(*transaction.signatures.first().expect("need a signature"))
288+
Ok(RpcClientResponse::Transaction(transaction.clone()))
283289
}
284290

285291
async fn get_account(&self, _address: Pubkey) -> ProgramClientResult<Option<Account>> {

0 commit comments

Comments
 (0)