Skip to content

Commit 6de4b3c

Browse files
WGB5445gregnazario
authored andcommitted
refactor: remove MultiEd25519 variant from TransactionAuthenticator match; update transaction submission and simulation methods to use SignedTransaction
1 parent 9f3ef8d commit 6de4b3c

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

crates/aptos-rust-sdk-types/src/api_types/transaction_authenticator.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ impl TransactionAuthenticator {
253253
Self::Ed25519 { .. }
254254
| Self::MultiAgent { .. }
255255
| Self::SingleSender { .. }
256-
| Self::MultiEd25519 { .. }
257256
| Self::MultiEd25519 { .. } => None,
258257
Self::FeePayer {
259258
sender: _,

crates/aptos-rust-sdk/src/client/rest_api.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ use crate::client::builder::AptosClientBuilder;
22
use crate::client::config::AptosNetwork;
33
use crate::client::response::{FullnodeResponse, ParsableResponse};
44
use aptos_rust_sdk_types::api_types::account::AccountResource;
5-
use aptos_rust_sdk_types::api_types::transaction::{RawTransaction, SignedTransaction};
6-
use aptos_rust_sdk_types::api_types::transaction_authenticator::TransactionAuthenticator;
5+
use aptos_rust_sdk_types::api_types::transaction::SignedTransaction;
76
use aptos_rust_sdk_types::mime_types::{ACCEPT_BCS, BCS_SIGNED_TRANSACTION, JSON};
87
use aptos_rust_sdk_types::state::State;
98
use aptos_rust_sdk_types::AptosResult;
@@ -78,16 +77,15 @@ impl AptosFullnodeClient {
7877
/// submit a transaction to the network. This is a blocking call and will wait for the
7978
pub async fn submit_transaction(
8079
&self,
81-
raw_txn: RawTransaction,
82-
authenticator: TransactionAuthenticator,
80+
signed_transaction: SignedTransaction,
8381
) -> AptosResult<FullnodeResponse<serde_json::Value>> {
8482
let url = self.build_rest_path("v1/transactions")?;
8583
let response = self
8684
.rest_client
8785
.post(url)
8886
.header(CONTENT_TYPE, BCS_SIGNED_TRANSACTION)
8987
.header(ACCEPT, JSON)
90-
.body(SignedTransaction::new(raw_txn, authenticator).to_vec())
88+
.body(signed_transaction.to_vec())
9189
.send()
9290
.await?;
9391

@@ -98,16 +96,15 @@ impl AptosFullnodeClient {
9896
/// simulate a transaction to the network. This is a blocking call and will wait for the
9997
pub async fn simulate_transaction(
10098
&self,
101-
raw_txn: RawTransaction,
102-
authenticator: TransactionAuthenticator,
99+
signed_transaction: SignedTransaction,
103100
) -> AptosResult<FullnodeResponse<serde_json::Value>> {
104101
let url = self.build_rest_path("v1/transactions/simulate")?;
105102
let response = self
106103
.rest_client
107104
.post(url)
108105
.header(CONTENT_TYPE, BCS_SIGNED_TRANSACTION)
109106
.header(ACCEPT, JSON)
110-
.body(SignedTransaction::new(raw_txn, authenticator).to_vec())
107+
.body(signed_transaction.to_vec())
111108
.send()
112109
.await?;
113110

crates/examples/src/lib.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,18 @@
22
mod tests {
33
use aptos_crypto::compat::Sha3_256;
44
use aptos_crypto::ed25519::{Ed25519PrivateKey, Ed25519PublicKey};
5-
use aptos_crypto::{PrivateKey, SigningKey};
65
use aptos_rust_sdk::client::builder::AptosClientBuilder;
76
use aptos_rust_sdk::client::config::AptosNetwork;
87
use aptos_rust_sdk_types::api_types::address::AccountAddress;
98
use aptos_rust_sdk_types::api_types::chain_id::ChainId;
109
use aptos_rust_sdk_types::api_types::module_id::ModuleId;
1110
use aptos_rust_sdk_types::api_types::transaction::{
12-
EntryFunction, RawTransaction, TransactionPayload,
11+
EntryFunction, RawTransaction, SignedTransaction, TransactionPayload
1312
};
1413
use aptos_rust_sdk_types::api_types::transaction_authenticator::{
1514
AccountAuthenticator, AuthenticationKey, TransactionAuthenticator,
1615
};
17-
use aptos_rust_sdk_types::mime_types::JSON;
1816
use ed25519_dalek::Digest;
19-
use serde::de::DeserializeOwned;
20-
use serde::ser::Serialize;
21-
use serde::Serializer;
22-
use std::str::FromStr;
2317

2418
#[tokio::test]
2519
async fn submit_transaction() {
@@ -88,17 +82,21 @@ mod tests {
8882

8983
let simulate_transaction = client
9084
.simulate_transaction(
91-
raw_txn.clone(),
85+
SignedTransaction::new(
86+
raw_txn.clone(),
9287
TransactionAuthenticator::single_sender(AccountAuthenticator::no_authenticator()),
88+
)
9389
)
9490
.await;
9591

9692
println!("Simulate Transaction: {:?}", simulate_transaction);
9793

9894
let transaction = client
9995
.submit_transaction(
100-
raw_txn.clone(),
101-
TransactionAuthenticator::ed25519(Ed25519PublicKey::from(&key), signature),
96+
SignedTransaction::new(
97+
raw_txn.clone(),
98+
TransactionAuthenticator::ed25519(Ed25519PublicKey::from(&key), signature),
99+
)
102100
)
103101
.await;
104102

0 commit comments

Comments
 (0)