Skip to content

Commit

Permalink
refactor!: Bump dependencies (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
iho authored Dec 22, 2023
1 parent e0217b7 commit 4c64a40
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 38 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ rust-version = "1.67.1"

[dependencies]
log = "0.4.17"
borsh = "0.10.2"
borsh = "1.3.0"
serde = "1.0.145"
reqwest = { version = "0.11.12", features = ["json"], default-features = false }
thiserror = "1.0.37"
serde_json = "1.0.85"
lazy_static = "1.4.0"

near-crypto = "0.17.0"
near-primitives = "0.17.0"
near-chain-configs = "0.17.0"
near-jsonrpc-primitives = "0.17.0"
near-crypto = "0.19.0"
near-primitives = "0.19.0"
near-chain-configs = "0.19.0"
near-jsonrpc-primitives = "0.19.0"

[dev-dependencies]
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
Expand Down
8 changes: 4 additions & 4 deletions examples/contract_change_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
nonce: current_nonce + 1,
receiver_id: "nosedive.testnet".parse()?,
block_hash: access_key_query_response.block_hash,
actions: vec![Action::FunctionCall(FunctionCallAction {
actions: vec![Action::FunctionCall(Box::new(FunctionCallAction {
method_name: "rate".to_string(),
args: json!({
"account_id": other_account,
Expand All @@ -54,7 +54,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.into_bytes(),
gas: 100_000_000_000_000, // 100 TeraGas
deposit: 0,
})],
}))],
};

let request = methods::broadcast_tx_async::RpcBroadcastTxAsyncRequest {
Expand All @@ -68,8 +68,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let response = client
.call(methods::tx::RpcTransactionStatusRequest {
transaction_info: TransactionInfo::TransactionId {
hash: tx_hash,
account_id: signer.account_id.clone(),
tx_hash,
sender_account_id: signer.account_id.clone(),
},
})
.await;
Expand Down
4 changes: 2 additions & 2 deletions examples/contract_change_method_commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
nonce: current_nonce + 1,
receiver_id: "nosedive.testnet".parse()?,
block_hash: access_key_query_response.block_hash,
actions: vec![Action::FunctionCall(FunctionCallAction {
actions: vec![Action::FunctionCall(Box::new(FunctionCallAction {
method_name: "rate".to_string(),
args: json!({
"account_id": other_account,
Expand All @@ -52,7 +52,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.into_bytes(),
gas: 100_000_000_000_000, // 100 TeraGas
deposit: 0,
})],
}))],
};

let request = methods::broadcast_tx_commit::RpcBroadcastTxCommitRequest {
Expand Down
12 changes: 6 additions & 6 deletions examples/create_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
block_hash: latest_hash,
actions: vec![
Action::CreateAccount(CreateAccountAction {}),
Action::AddKey(AddKeyAction {
Action::AddKey(Box::new(AddKeyAction {
access_key: near_primitives::account::AccessKey {
nonce: 0,
permission: near_primitives::account::AccessKeyPermission::FullAccess,
},
public_key: new_key_pair.public_key(),
}),
})),
Action::Transfer(TransferAction {
deposit: initial_deposit,
}),
Expand All @@ -166,7 +166,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
nonce: current_nonce + 1,
receiver_id: contract_id,
block_hash: latest_hash,
actions: vec![Action::FunctionCall(FunctionCallAction {
actions: vec![Action::FunctionCall(Box::new(FunctionCallAction {
method_name: "create_account".to_string(),
args: json!({
"new_account_id": new_account_id,
Expand All @@ -176,7 +176,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.into_bytes(),
gas: 300_000_000_000_000,
deposit: initial_deposit,
})],
}))],
}
};

Expand All @@ -202,8 +202,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let response = client
.call(methods::tx::RpcTransactionStatusRequest {
transaction_info: TransactionInfo::TransactionId {
hash: tx_hash,
account_id: signer.account_id.clone(),
tx_hash,
sender_account_id: signer.account_id.clone(),
},
})
.await;
Expand Down
4 changes: 2 additions & 2 deletions examples/query_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
match client
.call(methods::tx::RpcTransactionStatusRequest {
transaction_info: methods::tx::TransactionInfo::TransactionId {
hash: tx_hash,
account_id,
tx_hash,
sender_account_id: account_id,
},
})
.await
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
//!
//! let tx_status_request = methods::tx::RpcTransactionStatusRequest {
//! transaction_info: TransactionInfo::TransactionId {
//! hash: "9FtHUFBQsZ2MG77K3x3MJ9wjX3UT8zE1TczCrhZEcG8U".parse()?,
//! account_id: "miraclx.near".parse()?,
//! tx_hash: "9FtHUFBQsZ2MG77K3x3MJ9wjX3UT8zE1TczCrhZEcG8U".parse()?,
//! sender_account_id: "miraclx.near".parse()?,
//! },
//! };
//!
Expand Down Expand Up @@ -450,7 +450,7 @@ mod tests {
matches!(
tx_status,
Ok(methods::tx::RpcTransactionStatusResponse { ref transaction, .. })
if transaction.signer_id.as_ref() == "miraclx.near"
if transaction.signer_id == "miraclx.near"
&& transaction.hash == "9FtHUFBQsZ2MG77K3x3MJ9wjX3UT8zE1TczCrhZEcG8U".parse()?
),
"expected an Ok(RpcTransactionStatusResponse) with matching signer_id + hash, found [{:?}]",
Expand Down
3 changes: 2 additions & 1 deletion src/methods/broadcast_tx_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ pub struct RpcBroadcastTxAsyncRequest {
}

impl From<RpcBroadcastTxAsyncRequest>
for near_jsonrpc_primitives::types::transactions::RpcBroadcastTransactionRequest
for near_jsonrpc_primitives::types::transactions::RpcSendTransactionRequest
{
fn from(this: RpcBroadcastTxAsyncRequest) -> Self {
Self {
signed_transaction: this.signed_transaction,
wait_until: near_primitives::views::TxExecutionStatus::None,
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/methods/broadcast_tx_commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ pub struct RpcBroadcastTxCommitRequest {
}

impl From<RpcBroadcastTxCommitRequest>
for near_jsonrpc_primitives::types::transactions::RpcBroadcastTransactionRequest
for near_jsonrpc_primitives::types::transactions::RpcSendTransactionRequest
{
fn from(this: RpcBroadcastTxCommitRequest) -> Self {
Self {
signed_transaction: this.signed_transaction,
wait_until: near_primitives::views::TxExecutionStatus::None,
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/methods/experimental/check_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ pub struct RpcCheckTxRequest {
}

impl From<RpcCheckTxRequest>
for near_jsonrpc_primitives::types::transactions::RpcBroadcastTransactionRequest
for near_jsonrpc_primitives::types::transactions::RpcSendTransactionRequest
{
fn from(this: RpcCheckTxRequest) -> Self {
Self {
signed_transaction: this.signed_transaction,
wait_until: near_primitives::views::TxExecutionStatus::None,
}
}
}
Expand Down
13 changes: 9 additions & 4 deletions src/methods/experimental/tx_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ pub struct RpcTransactionStatusRequest {
}

impl From<RpcTransactionStatusRequest>
for near_jsonrpc_primitives::types::transactions::RpcTransactionStatusCommonRequest
for near_jsonrpc_primitives::types::transactions::RpcTransactionStatusRequest
{
fn from(this: RpcTransactionStatusRequest) -> Self {
Self {
transaction_info: this.transaction_info,
wait_until: near_primitives::views::TxExecutionStatus::None,
}
}
}
Expand All @@ -34,10 +35,14 @@ impl RpcMethod for RpcTransactionStatusRequest {
fn params(&self) -> Result<serde_json::Value, io::Error> {
Ok(match &self.transaction_info {
TransactionInfo::Transaction(signed_transaction) => {
json!([common::serialize_signed_transaction(signed_transaction)?])
match signed_transaction {
near_jsonrpc_primitives::types::transactions::SignedTransaction::SignedTransaction(tx) => {
json!([common::serialize_signed_transaction(tx)?])
},
}
}
TransactionInfo::TransactionId { hash, account_id } => {
json!([hash, account_id])
TransactionInfo::TransactionId { tx_hash,sender_account_id } => {
json!([tx_hash, sender_account_id])
}
})
}
Expand Down
4 changes: 1 addition & 3 deletions src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,7 @@ mod common {
pub fn serialize_signed_transaction(
tx: &near_primitives::transaction::SignedTransaction,
) -> Result<String, io::Error> {
Ok(near_primitives::serialize::to_base64(
&borsh::BorshSerialize::try_to_vec(&tx)?,
))
Ok(near_primitives::serialize::to_base64(&borsh::to_vec(&tx)?))
}

// adv_*
Expand Down
17 changes: 11 additions & 6 deletions src/methods/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
//!
//! let request = methods::tx::RpcTransactionStatusRequest {
//! transaction_info: methods::tx::TransactionInfo::TransactionId {
//! hash: tx_hash,
//! account_id: "itranscend.near".parse()?,
//! tx_hash,
//! sender_account_id: "itranscend.near".parse()?,
//! }
//! };
//!
Expand All @@ -38,11 +38,12 @@ pub struct RpcTransactionStatusRequest {
}

impl From<RpcTransactionStatusRequest>
for near_jsonrpc_primitives::types::transactions::RpcTransactionStatusCommonRequest
for near_jsonrpc_primitives::types::transactions::RpcTransactionStatusRequest
{
fn from(this: RpcTransactionStatusRequest) -> Self {
Self {
transaction_info: this.transaction_info,
wait_until: near_primitives::views::TxExecutionStatus::None,
}
}
}
Expand All @@ -58,10 +59,14 @@ impl RpcMethod for RpcTransactionStatusRequest {
fn params(&self) -> Result<serde_json::Value, io::Error> {
Ok(match &self.transaction_info {
TransactionInfo::Transaction(signed_transaction) => {
json!([common::serialize_signed_transaction(signed_transaction)?])
match signed_transaction {
near_jsonrpc_primitives::types::transactions::SignedTransaction::SignedTransaction(tx) => {
json!([common::serialize_signed_transaction(tx)?])
}
}
}
TransactionInfo::TransactionId { hash, account_id } => {
json!([hash, account_id])
TransactionInfo::TransactionId { tx_hash,sender_account_id, ..} => {
json!([tx_hash, sender_account_id])
}
})
}
Expand Down

0 comments on commit 4c64a40

Please sign in to comment.