From 29dbcf37237e1dd151307f55898c240e1ea427c4 Mon Sep 17 00:00:00 2001 From: jaswinder6991 Date: Mon, 24 Jun 2024 13:40:21 +0530 Subject: [PATCH] removed create_account function from examples and removed TransactionBuilder from near-accounts as well. --- near-accounts/examples/access_keys.rs | 44 ++++++++--- near-accounts/examples/async_tx.rs | 40 +++++----- near-accounts/examples/create_account.rs | 25 +++++- near-accounts/examples/create_subaccount.rs | 29 ++++++- near-accounts/examples/delete_account.rs | 23 +++++- near-accounts/examples/delete_key.rs | 23 +++++- near-accounts/examples/deploy_contract.rs | 25 +++++- near-accounts/examples/function_call.rs | 19 +++-- near-accounts/examples/multi-thread.rs | 1 - near-accounts/examples/send_money.rs | 24 +++++- near-accounts/src/accounts.rs | 85 ++++++++++++--------- near-transactions/src/lib.rs | 1 + 12 files changed, 256 insertions(+), 83 deletions(-) diff --git a/near-accounts/examples/access_keys.rs b/near-accounts/examples/access_keys.rs index fac4790..b804058 100644 --- a/near-accounts/examples/access_keys.rs +++ b/near-accounts/examples/access_keys.rs @@ -1,6 +1,6 @@ mod example_config; use near_accounts::Account; -use near_crypto::InMemorySigner; +use near_crypto::{InMemorySigner, SecretKey}; use near_primitives::types::Balance; use near_providers::JsonRpcProvider; use std::sync::Arc; @@ -8,10 +8,27 @@ mod utils; use near_primitives::types::AccountId; async fn add_full_access() -> Result<(), Box> { - let new_secret_key = near_crypto::SecretKey::from_random(near_crypto::KeyType::ED25519); + // Get test account and rpc details. + let config = example_config::get_test_config(); + + //Create a signer + let signer_account_id: AccountId = config.near_account.account_id.parse().unwrap(); + let signer_secret_key: SecretKey = config.near_account.secret_key.parse().unwrap(); + let signer = Arc::new(InMemorySigner::from_secret_key( + signer_account_id.clone(), + signer_secret_key, + )); - let account = example_config::create_account(); + //Creat a Provider + let provider = Arc::new(JsonRpcProvider::new(config.rpc_testnet_endpoint.as_str())); + //Create an Account object + let account = Account::new(signer_account_id, signer, provider); + + //Generate a secret Key for new access key + let new_secret_key = near_crypto::SecretKey::from_random(near_crypto::KeyType::ED25519); + + //Call add_key function on an Account let result = account .add_key(new_secret_key.public_key(), None, None, None) .await; @@ -27,17 +44,26 @@ async fn add_full_access() -> Result<(), Box> { } async fn add_function_call_key() -> Result<(), Box> { - let signer_account_id: AccountId = utils::input("Enter the signer Account ID: ")?.parse()?; - let signer_secret_key = utils::input("Enter the signer's private key: ")?.parse()?; - let signer = InMemorySigner::from_secret_key(signer_account_id.clone(), signer_secret_key); + // Get test account and rpc details. + let config = example_config::get_test_config(); - let new_secret_key = near_crypto::SecretKey::from_random(near_crypto::KeyType::ED25519); + //Create a signer + let signer_account_id: AccountId = config.near_account.account_id.parse().unwrap(); + let signer_secret_key: SecretKey = config.near_account.secret_key.parse().unwrap(); + let signer = Arc::new(InMemorySigner::from_secret_key( + signer_account_id.clone(), + signer_secret_key, + )); - let provider = Arc::new(JsonRpcProvider::new("https://rpc.testnet.near.org")); - let signer = Arc::new(signer); + //Creat a Provider + let provider = Arc::new(JsonRpcProvider::new(config.rpc_testnet_endpoint.as_str())); + //Create an Account object let account = Account::new(signer_account_id, signer, provider); + // Create a secret key for the new function call access key + let new_secret_key = near_crypto::SecretKey::from_random(near_crypto::KeyType::ED25519); + let allowance: Balance = 1_000_000_000_000_000_000_000_000; // Example amount in yoctoNEAR let contract_id = "contract.near-api-rs.testnet".to_string(); //Create an array of methods diff --git a/near-accounts/examples/async_tx.rs b/near-accounts/examples/async_tx.rs index 3638f3a..1b28d38 100644 --- a/near-accounts/examples/async_tx.rs +++ b/near-accounts/examples/async_tx.rs @@ -7,6 +7,8 @@ use near_providers::JsonRpcProvider; use near_providers::Provider; use std::sync::Arc; mod utils; +use near_accounts::Account; +use near_crypto::{InMemorySigner, SecretKey}; use near_primitives::types::AccountId; use serde_json::json; use tokio::time; @@ -14,27 +16,40 @@ use tokio::time; #[tokio::main] async fn main() -> Result<(), Box> { env_logger::init(); - let contract_id: AccountId = "contract.near-api-rs.testnet".parse::()?; + // Get test account and rpc details. + let config = example_config::get_test_config(); - let gas: Gas = 100_000_000_000_000; // Example amount in yoctoNEAR + //Create a signer + let signer_account_id: AccountId = config.near_account.account_id.parse().unwrap(); + let signer_secret_key: SecretKey = config.near_account.secret_key.parse().unwrap(); + let signer = Arc::new(InMemorySigner::from_secret_key( + signer_account_id.clone(), + signer_secret_key, + )); - let provider = Arc::new(JsonRpcProvider::new("https://rpc.testnet.near.org")); + //Creat a Provider + let provider = Arc::new(JsonRpcProvider::new(config.rpc_testnet_endpoint.as_str())); - let account = example_config::create_account(); - let method_name = "set_status".to_string(); + //Create an Account object + let account = Account::new(signer_account_id, signer, provider.clone()); + //Create argumements for function_call + //Contract id, method_name, method args, gas and deposit. + let contract_id: AccountId = "contract.near-api-rs.testnet".parse::()?; + let method_name = "set_status".to_string(); let args_json = json!({"message": "working1"}); + let gas: Gas = 100_000_000_000_000; // Example amount in yoctoNEAR + //Create a Transaction Sender Object; let transaction_sender = account .function_call(&contract_id, method_name, args_json, gas, 0) .await?; - + //Get the transaction hash to query the chain later. let tx_hash = transaction_sender.clone().get_transaction_hash().unwrap(); - let t1 = time::Instant::now(); + //Send the transaction //Different Wait_until values: None, Included, ExecutedOptimistic, IncludedFinal, Executed, Final let result = transaction_sender.transact_advanced("NONE").await; - let t2 = time::Instant::now(); match result { Ok(res) => match &res.final_execution_outcome { //Final Execution outcome for finality NONE would always be empty. @@ -58,22 +73,13 @@ async fn main() -> Result<(), Box> { sender_account_id: account.account_id, }; let wait_until = TxExecutionStatus::ExecutedOptimistic; - - time::sleep(time::Duration::from_secs(5)).await; - - let t3 = time::Instant::now(); let tx_status = provider.tx_status(transaction_info, wait_until).await; - let t4 = time::Instant::now(); match tx_status { Ok(response) => { - //println!("response gotten after: {}s", delta); println!("response: {:#?}", response); } Err(err) => println!("Error: {:#?}", err), } - - println!("Time taken for async request: {:?}", t2 - t1); - println!("Time taken for status request: {:?}", t4 - t3); Ok(()) } diff --git a/near-accounts/examples/create_account.rs b/near-accounts/examples/create_account.rs index 0503cc6..c5c279b 100644 --- a/near-accounts/examples/create_account.rs +++ b/near-accounts/examples/create_account.rs @@ -1,19 +1,40 @@ mod example_config; +use near_accounts::Account; +use near_crypto::{InMemorySigner, SecretKey}; use near_primitives::{types::Gas, views::FinalExecutionOutcomeViewEnum}; mod utils; use near_primitives::types::{AccountId, Balance}; +use near_providers::JsonRpcProvider; use serde_json::json; +use std::sync::Arc; #[tokio::main] async fn main() -> Result<(), Box> { env_logger::init(); + + // Get test account and rpc details. + let config = example_config::get_test_config(); + + //Create a signer + let signer_account_id: AccountId = config.near_account.account_id.parse().unwrap(); + let signer_secret_key: SecretKey = config.near_account.secret_key.parse().unwrap(); + let signer = Arc::new(InMemorySigner::from_secret_key( + signer_account_id.clone(), + signer_secret_key, + )); + + //Creat a Provider + let provider = Arc::new(JsonRpcProvider::new(config.rpc_testnet_endpoint.as_str())); + + //Create an Account object + let account = Account::new(signer_account_id, signer, provider.clone()); + + //Ask the user for the new Account id. let new_account_id: AccountId = utils::input("Enter new account name: ")?.parse()?; // Amount to transfer to the new account let gas: Gas = 100_000_000_000_000; // Example amount in yoctoNEAR let amount: Balance = 10_000_000_000_000_000_000_000; // Example amount in yoctoNEAR - let account = example_config::create_account(); - let contract_id: AccountId = "testnet".parse::()?; let method_name = "create_account".to_string(); diff --git a/near-accounts/examples/create_subaccount.rs b/near-accounts/examples/create_subaccount.rs index 268138e..3fe549a 100644 --- a/near-accounts/examples/create_subaccount.rs +++ b/near-accounts/examples/create_subaccount.rs @@ -1,12 +1,34 @@ -//use near_providers::Provider; mod example_config; -use near_primitives::types::Balance; +use near_accounts::Account; +use near_crypto::{InMemorySigner, SecretKey}; mod utils; -use near_primitives::types::AccountId; +use near_primitives::types::{AccountId, Balance}; +use near_providers::JsonRpcProvider; +use std::sync::Arc; #[tokio::main] async fn main() -> Result<(), Box> { env_logger::init(); + + // Get test account and rpc details. + let config = example_config::get_test_config(); + + //Create a signer + let signer_account_id: AccountId = config.near_account.account_id.parse().unwrap(); + let signer_secret_key: SecretKey = config.near_account.secret_key.parse().unwrap(); + let signer = Arc::new(InMemorySigner::from_secret_key( + signer_account_id.clone(), + signer_secret_key, + )); + + //Creat a Provider + let provider = Arc::new(JsonRpcProvider::new(config.rpc_testnet_endpoint.as_str())); + + //Create an Account object + let account = Account::new(signer_account_id, signer, provider.clone()); + + //Ask user for the new account id, it should be of the form something.near-api-rs.testnet + //or whatever signer account you are using. let new_account_id: AccountId = utils::input("Enter the account name of new account ")?.parse()?; @@ -15,7 +37,6 @@ async fn main() -> Result<(), Box> { let new_key_pair = near_crypto::SecretKey::from_random(near_crypto::KeyType::ED25519); - let account = example_config::create_account(); // Call create_account let result = account .create_account(&new_account_id, new_key_pair.public_key(), amount) diff --git a/near-accounts/examples/delete_account.rs b/near-accounts/examples/delete_account.rs index 74faa46..d5b1d6c 100644 --- a/near-accounts/examples/delete_account.rs +++ b/near-accounts/examples/delete_account.rs @@ -1,13 +1,34 @@ mod example_config; +use near_accounts::Account; +use near_crypto::{InMemorySigner, SecretKey}; +use near_providers::JsonRpcProvider; +use std::sync::Arc; mod utils; use near_primitives::types::AccountId; #[tokio::main] async fn main() -> Result<(), Box> { env_logger::init(); + + // Get test account and rpc details. + let config = example_config::get_test_config(); + + //Create a signer + let signer_account_id: AccountId = config.near_account.account_id.parse().unwrap(); + let signer_secret_key: SecretKey = config.near_account.secret_key.parse().unwrap(); + let signer = Arc::new(InMemorySigner::from_secret_key( + signer_account_id.clone(), + signer_secret_key, + )); + + //Creat a Provider + let provider = Arc::new(JsonRpcProvider::new(config.rpc_testnet_endpoint.as_str())); + + //Create an Account object + let account = Account::new(signer_account_id, signer, provider.clone()); + let beneficiary_account_id: AccountId = utils::input("Enter the account name where you want to transfer current account balance before deleting it")?.parse()?; - let account = example_config::create_account(); let response = account.delete_account(beneficiary_account_id.clone()).await; diff --git a/near-accounts/examples/delete_key.rs b/near-accounts/examples/delete_key.rs index 9f932f9..46f03b6 100644 --- a/near-accounts/examples/delete_key.rs +++ b/near-accounts/examples/delete_key.rs @@ -1,11 +1,30 @@ mod example_config; -use near_crypto::PublicKey; +use near_accounts::Account; +use near_crypto::{InMemorySigner, PublicKey, SecretKey}; +use near_providers::JsonRpcProvider; +use std::sync::Arc; mod utils; +use near_primitives::types::AccountId; #[tokio::main] async fn main() -> Result<(), Box> { env_logger::init(); - let account = example_config::create_account(); + // Get test account and rpc details. + let config = example_config::get_test_config(); + + //Create a signer + let signer_account_id: AccountId = config.near_account.account_id.parse().unwrap(); + let signer_secret_key: SecretKey = config.near_account.secret_key.parse().unwrap(); + let signer = Arc::new(InMemorySigner::from_secret_key( + signer_account_id.clone(), + signer_secret_key, + )); + + //Creat a Provider + let provider = Arc::new(JsonRpcProvider::new(config.rpc_testnet_endpoint.as_str())); + + //Create an Account object + let account = Account::new(signer_account_id, signer, provider.clone()); let public_key: PublicKey = "ed25519:EohEtHT8Dt8jURC3DcJ661hWCx6ExPRtDV82FpT4jfNB".parse::()?; diff --git a/near-accounts/examples/deploy_contract.rs b/near-accounts/examples/deploy_contract.rs index f25ca6a..9f510b0 100644 --- a/near-accounts/examples/deploy_contract.rs +++ b/near-accounts/examples/deploy_contract.rs @@ -1,15 +1,34 @@ -use near_accounts::Account; mod example_config; +use near_accounts::Account; +use near_crypto::{InMemorySigner, SecretKey}; +use near_providers::JsonRpcProvider; +use std::sync::Arc; mod utils; +use near_primitives::types::AccountId; #[tokio::main] async fn main() -> Result<(), Box> { env_logger::init(); - let account: Account = example_config::create_account(); + // Get test account and rpc details. + let config = example_config::get_test_config(); - let wasm_code = example_config::read_wasm_file()?; + //Create a signer + let signer_account_id: AccountId = config.near_account.account_id.parse().unwrap(); + let signer_secret_key: SecretKey = config.near_account.secret_key.parse().unwrap(); + let signer = Arc::new(InMemorySigner::from_secret_key( + signer_account_id.clone(), + signer_secret_key, + )); + //Creat a Provider + let provider = Arc::new(JsonRpcProvider::new(config.rpc_testnet_endpoint.as_str())); + + //Create an Account object + let account = Account::new(signer_account_id, signer, provider.clone()); + + //wasm code to deploy + let wasm_code = example_config::read_wasm_file()?; let response = account.deploy_contract(&wasm_code).await; match response { diff --git a/near-accounts/examples/function_call.rs b/near-accounts/examples/function_call.rs index f0cba84..d8f43bb 100644 --- a/near-accounts/examples/function_call.rs +++ b/near-accounts/examples/function_call.rs @@ -13,29 +13,34 @@ use serde_json::json; async fn main() -> Result<(), Box> { env_logger::init(); + //Read test account details from config file let config = example_config::get_test_config(); let signer_account_id: AccountId = config.near_account.account_id.parse().unwrap(); let signer_secret_key: SecretKey = config.near_account.secret_key.parse().unwrap(); - let contract_id: AccountId = config.contract_account.account_id.parse().unwrap(); - let signer = InMemorySigner::from_secret_key(signer_account_id.clone(), signer_secret_key); - - let gas: Gas = 100_000_000_000_000; // Example amount in yoctoNEAR + //Create a signer + let signer = Arc::new(InMemorySigner::from_secret_key( + signer_account_id.clone(), + signer_secret_key, + )); + //Create a provider let provider = Arc::new(JsonRpcProvider::new(config.rpc_testnet_endpoint.as_str())); - let signer = Arc::new(signer); + //Create an Account let account = Account::new(signer_account_id, signer, provider); - let method_name = "set_status".to_string(); + let contract_id: AccountId = config.contract_account.account_id.parse().unwrap(); + let method_name = "set_status".to_string(); let args_json = json!({"message": "working1"}); + let gas: Gas = 100_000_000_000_000; // Example amount in yoctoNEAR let result = account .function_call(&contract_id, method_name, args_json, gas, 0) .await? .transact() .await; - println!("response: {:#?}", result); + println!("response: {:#?}", result); Ok(()) } diff --git a/near-accounts/examples/multi-thread.rs b/near-accounts/examples/multi-thread.rs index 28d09cb..217a8ca 100644 --- a/near-accounts/examples/multi-thread.rs +++ b/near-accounts/examples/multi-thread.rs @@ -17,7 +17,6 @@ async fn main() -> Result<(), Box> { let signer_secret_key = "ed25519:29nYmQCZMsQeYtztXZzm57ayQt2uBHXdn2SAjK4ccMGSQaNUFNJ7Aoteno81eKTex9cGBbk1FuDuqJRsdzx34xDY".parse::()?; let provider = Arc::new(JsonRpcProvider::new("https://rpc.testnet.near.org")); - //let provider = JsonRpcProvider::new("https://rpc.testnet.near.org"); let signer = Arc::new(InMemorySigner::from_secret_key( signer_account_id.clone(), signer_secret_key, diff --git a/near-accounts/examples/send_money.rs b/near-accounts/examples/send_money.rs index d4f45fe..82cc239 100644 --- a/near-accounts/examples/send_money.rs +++ b/near-accounts/examples/send_money.rs @@ -1,19 +1,39 @@ mod example_config; +use near_accounts::Account; +use near_crypto::{InMemorySigner, SecretKey}; use near_primitives::types::Balance; +use near_providers::JsonRpcProvider; +use std::sync::Arc; mod utils; use near_primitives::types::AccountId; #[tokio::main] async fn main() -> Result<(), Box> { env_logger::init(); + + // Get test account and rpc details. + let config = example_config::get_test_config(); + + //Create a signer + let signer_account_id: AccountId = config.near_account.account_id.parse().unwrap(); + let signer_secret_key: SecretKey = config.near_account.secret_key.parse().unwrap(); + let signer = Arc::new(InMemorySigner::from_secret_key( + signer_account_id.clone(), + signer_secret_key, + )); + + //Creat a Provider + let provider = Arc::new(JsonRpcProvider::new(config.rpc_testnet_endpoint.as_str())); + + //Create an Account object + let account = Account::new(signer_account_id, signer, provider.clone()); + let receiver_account_id: AccountId = utils::input("Enter the account name of receiver account ")?.parse()?; // Amount to transfer to the receiver account let amount: Balance = 10_000_000_000; // Example amount in yoctoNEAR - let account = example_config::create_account(); - // Call create_account let result = account.send_money(&receiver_account_id, amount).await; println!("response: {:#?}", result); diff --git a/near-accounts/src/accounts.rs b/near-accounts/src/accounts.rs index d18c8a6..113e0a4 100644 --- a/near-accounts/src/accounts.rs +++ b/near-accounts/src/accounts.rs @@ -7,13 +7,13 @@ use crate::access_keys::{full_access_key, function_call_access_key}; use crate::transaction_sender::TransactionSender; use near_crypto::{PublicKey, Signer}; use near_primitives::account::AccessKey; -use near_primitives::transaction::SignedTransaction; use near_primitives::types::{AccountId, Balance, BlockReference, Finality, Gas}; use near_primitives::views::{FinalExecutionOutcomeView, QueryRequest}; +use near_transactions::transaction::Transaction; use near_providers::types::query::{QueryResponseKind, RpcQueryResponse}; use near_providers::Provider; -use near_transactions::{ActionBuilder, TransactionBuilder}; +use near_transactions::ActionBuilder; use serde::{Deserialize, Serialize}; use serde_json::Value; use std::ops::{Add, Mul, Sub}; @@ -62,7 +62,7 @@ impl Account { } } - /// Create a `SignedTransaction` for constructing a signed transaction. + /// Create a `Transaction` for constructing a signed transaction later. /// /// # Arguments /// @@ -71,13 +71,14 @@ impl Account { /// /// # Returns /// - /// A result containing a `SignedTransaction` instance or an error if fetching the nonce or block hash failed. - async fn create_signed_transaction( + /// A result containing a `Transaction` instance or an error if fetching the nonce or block hash failed. + async fn create_transaction( &self, receiver_id: &AccountId, - actions: &ActionBuilder, - ) -> Result> { + action_builder: &ActionBuilder, + ) -> Result> { // Fetch the current nonce for the signer account and latest block hash + // cache nonce as well, fetching it everytime is slow. let nonce = self .fetch_nonce(&self.account_id, &self.signer.public_key()) .await?; @@ -87,17 +88,15 @@ impl Account { let block = self.provider.block(block_reference).await?; let block_hash = block.header.hash; - // Use TransactionBuilder to construct the transaction - let signed_transaction: SignedTransaction = TransactionBuilder::new( - self.account_id.clone(), - self.signer.public_key(), - receiver_id.clone(), - nonce + 1, + let tx: Transaction = Transaction { + signer_id: self.account_id.clone(), + public_key: self.signer.public_key(), + nonce: nonce + 1, + receiver_id: receiver_id.clone(), block_hash, - ) - .set_action(&actions.build()) - .sign_transaction(&*self.signer); - Ok(signed_transaction) + actions: action_builder.build(), + }; + Ok(tx) } /// Fetches the current nonce for an account's access key. @@ -156,14 +155,19 @@ impl Account { .transfer(amount) .add_key(public_key.clone(), full_access_key()); - let signed_txn = self - .create_signed_transaction(new_account_id, &action_builder) + let tx = self + .create_transaction(new_account_id, &action_builder) .await?; - // Use TransactionBuilder to construct the transaction + + //Notice the derefencing here. + let signed_tx = tx.sign(&*self.signer); // Send the transaction - let transaction_result = self.provider.send_transaction(signed_txn.clone()).await?; - Ok(transaction_result) + let transaction_result = self.provider.send_transaction(signed_tx.clone()).await; + match transaction_result { + Ok(transaction_result) => Ok(transaction_result), + Err(err) => Err(Box::new(err)), + } } /// Adds a full or function call access key to an account @@ -196,13 +200,14 @@ impl Account { None => full_access_key(), }; - let signed_tx = self - .create_signed_transaction( + let tx = self + .create_transaction( &self.account_id, ActionBuilder::new().add_key(public_key, access_key), ) .await?; - // Use TransactionBuilder to construct the transaction + + let signed_tx = tx.sign(&*self.signer); // Send the transaction let transaction_result = self.provider.send_transaction(signed_tx).await; @@ -225,13 +230,15 @@ impl Account { &self, public_key: PublicKey, ) -> Result> { - let signed_tx = self - .create_signed_transaction( + let tx = self + .create_transaction( &self.account_id, ActionBuilder::new().delete_key(public_key), ) .await?; + let signed_tx = tx.sign(&*self.signer); + // Send the transaction let transaction_result = self.provider.send_transaction(signed_tx).await; match transaction_result { @@ -253,13 +260,15 @@ impl Account { &self, byte_code: &[u8], ) -> Result> { - let signed_tx = self - .create_signed_transaction( + let tx = self + .create_transaction( &self.account_id, ActionBuilder::new().deploy_contract(byte_code), ) .await?; + let signed_tx = tx.sign(&*self.signer); + // Send the transaction let transaction_result = self.provider.send_transaction(signed_tx).await; match transaction_result { @@ -281,12 +290,14 @@ impl Account { &self, beneficiary_id: AccountId, ) -> Result> { - let signed_tx = self - .create_signed_transaction( + let tx = self + .create_transaction( &self.account_id, ActionBuilder::new().delete_account(beneficiary_id), ) .await?; + + let signed_tx = tx.sign(&*self.signer); // Send the transaction let transaction_result = self.provider.send_transaction(signed_tx).await; match transaction_result { @@ -311,9 +322,11 @@ impl Account { receiver_id: &AccountId, amount: Balance, ) -> Result> { - let signed_tx = self - .create_signed_transaction(receiver_id, ActionBuilder::new().transfer(amount)) + let tx = self + .create_transaction(receiver_id, ActionBuilder::new().transfer(amount)) .await?; + + let signed_tx = tx.sign(&*self.signer); // Send the transaction let transaction_result = self.provider.send_transaction(signed_tx).await; match transaction_result { @@ -346,12 +359,14 @@ impl Account { // Serialize the JSON to a Vec let args = serde_json::to_vec(&args)?; - let signed_tx = self - .create_signed_transaction( + let tx = self + .create_transaction( contract_id, ActionBuilder::new().function_call(method_name, args, gas, deposit), ) .await?; + + let signed_tx = tx.sign(&*self.signer); // To-do. Needs error handling here. Ok(TransactionSender::new(signed_tx, self.provider.clone())) } diff --git a/near-transactions/src/lib.rs b/near-transactions/src/lib.rs index a512b37..776f702 100644 --- a/near-transactions/src/lib.rs +++ b/near-transactions/src/lib.rs @@ -29,6 +29,7 @@ pub use crate::action_builder::ActionBuilder; pub use crate::delegate_action::{create_delegate_action, create_signed_delegate_action}; pub use crate::transaction_builder::TransactionBuilder; +pub use near_primitives::transaction; mod action_builder; mod delegate_action;