Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
jaswinder6991 committed May 17, 2024
1 parent b5ad317 commit 754c81e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
24 changes: 16 additions & 8 deletions near-accounts/examples/multi-thread.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use near_accounts::Account;
use near_crypto::{InMemorySigner,SecretKey};
use near_crypto::{InMemorySigner, SecretKey};
use near_primitives::{types::Gas, views::FinalExecutionOutcomeViewEnum};
use near_providers::JsonRpcProvider;
use std::sync::Arc;
Expand All @@ -18,14 +18,16 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

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));
let signer = Arc::new(InMemorySigner::from_secret_key(
signer_account_id.clone(),
signer_secret_key,
));
let account = Account::new(signer_account_id, signer.clone(), provider.clone());

let contract_id: AccountId = "contract.near-api-rs.testnet".parse::<AccountId>()?;

// This spawns a new asynchronous task to handle account creation
let handle = tokio::spawn(async move {

let method_name = "set_status".to_string();
let args_json = json!({"message": "working1"});

Expand All @@ -35,18 +37,24 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

let result = account
.function_call(&contract_id, method_name, args_json, gas, amount)
.await.expect("Reason")
.await
.expect("Reason")
.transact()
.await;

match result {
Ok(res) => match &res.final_execution_outcome {
Some(FinalExecutionOutcomeViewEnum::FinalExecutionOutcome(outcome)) => {
println!("Final Execution outcome: {:#?}", outcome);
},
Some(FinalExecutionOutcomeViewEnum::FinalExecutionOutcomeWithReceipt(outcome_receipt)) => {
println!("Final Execution outcome with receipt: {:#?}", outcome_receipt);
},
}
Some(FinalExecutionOutcomeViewEnum::FinalExecutionOutcomeWithReceipt(
outcome_receipt,
)) => {
println!(
"Final Execution outcome with receipt: {:#?}",
outcome_receipt
);
}
None => println!("No Final execution outcome."),
},
Err(err) => println!("Error: {:#?}", err),
Expand Down
7 changes: 5 additions & 2 deletions near-accounts/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ impl TransactionSender {
/// # Returns
///
/// A new `Account` instance.
pub fn new(signed_transaction: SignedTransaction, provider: Arc<dyn Provider + Send + Sync>) -> Self {
pub fn new(
signed_transaction: SignedTransaction,
provider: Arc<dyn Provider + Send + Sync>,
) -> Self {
Self {
signed_transaction,
provider,
Expand Down Expand Up @@ -113,7 +116,7 @@ impl TransactionSender {
pub struct Account {
pub account_id: AccountId,
//pub signer: Arc<dyn Signer>, // Use your Signer abstraction
pub signer: Arc<dyn Signer + Send + Sync>, // Use your Signer abstraction
pub signer: Arc<dyn Signer + Send + Sync>, // Use your Signer abstraction
//pub provider: Arc<dyn Provider>, // Use your Provider abstraction
provider: Arc<dyn Provider + Send + Sync>,
}
Expand Down

0 comments on commit 754c81e

Please sign in to comment.