From 3c2ba6565b30eaabf5f0d4d927234d21f106324d Mon Sep 17 00:00:00 2001 From: Andrei Marinica Date: Tue, 1 Oct 2024 01:20:55 +0300 Subject: [PATCH 1/2] gateway request refactor --- sdk/core/src/gateway.rs | 76 ++++++++ sdk/core/src/gateway/gateway_account.rs | 40 +++++ .../src/gateway/gateway_account_esdt_roles.rs | 39 +++++ .../gateway/gateway_account_esdt_tokens.rs | 40 +++++ .../src/gateway/gateway_account_storage.rs | 37 ++++ sdk/core/src/gateway/gateway_block.rs | 47 +++++ .../src/gateway/gateway_network_config.rs | 28 +++ .../src/gateway/gateway_network_economics.rs | 28 +++ .../src/gateway/gateway_network_status.rs | 38 ++++ sdk/core/src/gateway/gateway_tx_cost.rs | 34 ++++ sdk/core/src/gateway/gateway_tx_info.rs | 55 ++++++ .../src/gateway/gateway_tx_process_status.rs | 36 ++++ sdk/core/src/gateway/gateway_tx_send.rs | 32 ++++ sdk/core/src/gateway/gateway_tx_send_multi.rs | 40 +++++ sdk/core/src/gateway/gateway_tx_status.rs | 36 ++++ sdk/core/src/gateway/gateway_tx_vmquery.rs | 32 ++++ sdk/core/src/lib.rs | 1 + .../examples/get_hyper_block_by_hash.rs | 2 +- .../examples/get_hyper_block_by_nonce.rs | 2 +- sdk/reqwest/examples/sign_tx.rs | 5 +- sdk/reqwest/examples/sign_txs.rs | 5 +- sdk/reqwest/examples/vm_query.rs | 13 +- sdk/reqwest/src/gateway/gateway_account.rs | 93 ++-------- sdk/reqwest/src/gateway/gateway_block.rs | 53 +----- sdk/reqwest/src/gateway/gateway_network.rs | 39 +---- sdk/reqwest/src/gateway/gateway_proxy.rs | 33 ++++ sdk/reqwest/src/gateway/gateway_tx.rs | 162 +++--------------- 27 files changed, 732 insertions(+), 314 deletions(-) create mode 100644 sdk/core/src/gateway.rs create mode 100644 sdk/core/src/gateway/gateway_account.rs create mode 100644 sdk/core/src/gateway/gateway_account_esdt_roles.rs create mode 100644 sdk/core/src/gateway/gateway_account_esdt_tokens.rs create mode 100644 sdk/core/src/gateway/gateway_account_storage.rs create mode 100644 sdk/core/src/gateway/gateway_block.rs create mode 100644 sdk/core/src/gateway/gateway_network_config.rs create mode 100644 sdk/core/src/gateway/gateway_network_economics.rs create mode 100644 sdk/core/src/gateway/gateway_network_status.rs create mode 100644 sdk/core/src/gateway/gateway_tx_cost.rs create mode 100644 sdk/core/src/gateway/gateway_tx_info.rs create mode 100644 sdk/core/src/gateway/gateway_tx_process_status.rs create mode 100644 sdk/core/src/gateway/gateway_tx_send.rs create mode 100644 sdk/core/src/gateway/gateway_tx_send_multi.rs create mode 100644 sdk/core/src/gateway/gateway_tx_status.rs create mode 100644 sdk/core/src/gateway/gateway_tx_vmquery.rs diff --git a/sdk/core/src/gateway.rs b/sdk/core/src/gateway.rs new file mode 100644 index 0000000000..7b40532231 --- /dev/null +++ b/sdk/core/src/gateway.rs @@ -0,0 +1,76 @@ +mod gateway_account; +mod gateway_account_esdt_roles; +mod gateway_account_esdt_tokens; +mod gateway_account_storage; +mod gateway_block; +mod gateway_network_config; +mod gateway_network_economics; +mod gateway_network_status; +mod gateway_tx_cost; +mod gateway_tx_info; +mod gateway_tx_process_status; +mod gateway_tx_send; +mod gateway_tx_send_multi; +mod gateway_tx_status; +mod gateway_tx_vmquery; + +pub use gateway_account::GetAccountRequest; +pub use gateway_account_esdt_roles::GetAccountEsdtRolesRequest; +pub use gateway_account_esdt_tokens::GetAccountEsdtTokensRequest; +pub use gateway_account_storage::GetAccountStorageRequest; +pub use gateway_block::GetHyperBlockRequest; +pub use gateway_network_config::NetworkConfigRequest; +pub use gateway_network_economics::NetworkEconimicsRequest; +pub use gateway_network_status::NetworkStatusRequest; +pub use gateway_tx_cost::GetTxCost; +pub use gateway_tx_info::GetTxInfo; +pub use gateway_tx_process_status::GetTxProcessStatus; +pub use gateway_tx_send::SendTxRequest; +pub use gateway_tx_send_multi::SendMultiTxRequest; +pub use gateway_tx_status::GetTxStatus; +pub use gateway_tx_vmquery::VMQueryRequest; + +pub const MAINNET_GATEWAY: &str = "https://gateway.multiversx.com"; +pub const TESTNET_GATEWAY: &str = "https://testnet-gateway.multiversx.com"; +pub const DEVNET_GATEWAY: &str = "https://devnet-gateway.multiversx.com"; + +// MetachainShardId will be used to identify a shard ID as metachain +pub const METACHAIN_SHARD_ID: u32 = 0xFFFFFFFF; + +const ACCOUNT_ENDPOINT: &str = "address/"; +const KEYS_ENDPOINT: &str = "/keys/"; +const NETWORK_CONFIG_ENDPOINT: &str = "network/config"; +const NETWORK_ECONOMICS_ENDPOINT: &str = "network/economics"; +const GET_NETWORK_STATUS_ENDPOINT: &str = "network/status"; +const GET_HYPER_BLOCK_BY_NONCE_ENDPOINT: &str = "hyperblock/by-nonce"; +const GET_HYPER_BLOCK_BY_HASH_ENDPOINT: &str = "hyperblock/by-hash"; +const COST_TRANSACTION_ENDPOINT: &str = "transaction/cost"; +const SEND_TRANSACTION_ENDPOINT: &str = "transaction/send"; +const SEND_MULTIPLE_TRANSACTIONS_ENDPOINT: &str = "transaction/send-multiple"; +const GET_TRANSACTION_INFO_ENDPOINT: &str = "transaction/"; +const WITH_RESULTS_QUERY_PARAM: &str = "?withResults=true"; +const VM_VALUES_ENDPOINT: &str = "vm-values/query"; + +pub enum GatewayRequestType { + Get, + Post, +} + +/// Models requests to the gateway. +pub trait GatewayRequest { + type Payload: serde::ser::Serialize + ?Sized; + + type DecodedJson: serde::de::DeserializeOwned; + + type Result; + + fn request_type(&self) -> GatewayRequestType; + + fn get_endpoint(&self) -> String; + + fn get_payload(&self) -> Option<&Self::Payload> { + None + } + + fn process_json(&self, decoded: Self::DecodedJson) -> anyhow::Result; +} diff --git a/sdk/core/src/gateway/gateway_account.rs b/sdk/core/src/gateway/gateway_account.rs new file mode 100644 index 0000000000..f6b97c8ebd --- /dev/null +++ b/sdk/core/src/gateway/gateway_account.rs @@ -0,0 +1,40 @@ +use crate::data::{ + account::{Account, AccountResponse}, + address::Address, +}; +use anyhow::anyhow; + +use super::ACCOUNT_ENDPOINT; +use super::{GatewayRequest, GatewayRequestType}; + +/// Retrieves an account info from the network (nonce, balance). +pub struct GetAccountRequest<'a> { + pub address: &'a Address, +} + +impl<'a> GetAccountRequest<'a> { + pub fn new(address: &'a Address) -> Self { + Self { address } + } +} + +impl<'a> GatewayRequest for GetAccountRequest<'a> { + type Payload = (); + type DecodedJson = AccountResponse; + type Result = Account; + + fn request_type(&self) -> GatewayRequestType { + GatewayRequestType::Get + } + + fn get_endpoint(&self) -> String { + format!("{ACCOUNT_ENDPOINT}{}", self.address) + } + + fn process_json(&self, decoded: Self::DecodedJson) -> anyhow::Result { + match decoded.data { + None => Err(anyhow!("{}", decoded.error)), + Some(b) => Ok(b.account), + } + } +} diff --git a/sdk/core/src/gateway/gateway_account_esdt_roles.rs b/sdk/core/src/gateway/gateway_account_esdt_roles.rs new file mode 100644 index 0000000000..5152ec99c1 --- /dev/null +++ b/sdk/core/src/gateway/gateway_account_esdt_roles.rs @@ -0,0 +1,39 @@ +use crate::data::{address::Address, esdt::EsdtRolesResponse}; +use anyhow::anyhow; +use std::collections::HashMap; + +use super::{GatewayRequest, GatewayRequestType}; + +const ACCOUNT_ENDPOINT: &str = "address/"; + +/// Retrieves an all esdt roles of an account from the network. +pub struct GetAccountEsdtRolesRequest<'a> { + pub address: &'a Address, +} + +impl<'a> GetAccountEsdtRolesRequest<'a> { + pub fn new(address: &'a Address) -> Self { + Self { address } + } +} + +impl<'a> GatewayRequest for GetAccountEsdtRolesRequest<'a> { + type Payload = (); + type DecodedJson = EsdtRolesResponse; + type Result = HashMap>; + + fn request_type(&self) -> GatewayRequestType { + GatewayRequestType::Get + } + + fn get_endpoint(&self) -> String { + format!("{ACCOUNT_ENDPOINT}/{}/esdts/roles", self.address) + } + + fn process_json(&self, decoded: Self::DecodedJson) -> anyhow::Result { + match decoded.data { + None => Err(anyhow!("{}", decoded.error)), + Some(b) => Ok(b.roles), + } + } +} diff --git a/sdk/core/src/gateway/gateway_account_esdt_tokens.rs b/sdk/core/src/gateway/gateway_account_esdt_tokens.rs new file mode 100644 index 0000000000..e539521511 --- /dev/null +++ b/sdk/core/src/gateway/gateway_account_esdt_tokens.rs @@ -0,0 +1,40 @@ +use crate::data::{ + address::Address, + esdt::{EsdtBalance, EsdtBalanceResponse}, +}; +use anyhow::anyhow; +use std::collections::HashMap; + +use super::{GatewayRequest, GatewayRequestType, ACCOUNT_ENDPOINT}; + +/// Retrieves an all esdt tokens of an account from the network. +pub struct GetAccountEsdtTokensRequest<'a> { + pub address: &'a Address, +} + +impl<'a> GetAccountEsdtTokensRequest<'a> { + pub fn new(address: &'a Address) -> Self { + Self { address } + } +} + +impl<'a> GatewayRequest for GetAccountEsdtTokensRequest<'a> { + type Payload = (); + type DecodedJson = EsdtBalanceResponse; + type Result = HashMap; + + fn request_type(&self) -> GatewayRequestType { + GatewayRequestType::Get + } + + fn get_endpoint(&self) -> String { + format!("{ACCOUNT_ENDPOINT}{}/esdt", self.address) + } + + fn process_json(&self, decoded: Self::DecodedJson) -> anyhow::Result { + match decoded.data { + None => Err(anyhow!("{}", decoded.error)), + Some(b) => Ok(b.esdts), + } + } +} diff --git a/sdk/core/src/gateway/gateway_account_storage.rs b/sdk/core/src/gateway/gateway_account_storage.rs new file mode 100644 index 0000000000..4793c84053 --- /dev/null +++ b/sdk/core/src/gateway/gateway_account_storage.rs @@ -0,0 +1,37 @@ +use crate::data::{account_storage::AccountStorageResponse, address::Address}; +use anyhow::anyhow; +use std::collections::HashMap; + +use super::{GatewayRequest, GatewayRequestType, ACCOUNT_ENDPOINT, KEYS_ENDPOINT}; + +/// Retrieves an account storage from the network. +pub struct GetAccountStorageRequest<'a> { + pub address: &'a Address, +} + +impl<'a> GetAccountStorageRequest<'a> { + pub fn new(address: &'a Address) -> Self { + Self { address } + } +} + +impl<'a> GatewayRequest for GetAccountStorageRequest<'a> { + type Payload = (); + type DecodedJson = AccountStorageResponse; + type Result = HashMap; + + fn request_type(&self) -> GatewayRequestType { + GatewayRequestType::Get + } + + fn get_endpoint(&self) -> String { + format!("{ACCOUNT_ENDPOINT}{}{KEYS_ENDPOINT}", self.address) + } + + fn process_json(&self, decoded: Self::DecodedJson) -> anyhow::Result { + match decoded.data { + None => Err(anyhow!("{}", decoded.error)), + Some(b) => Ok(b.pairs), + } + } +} diff --git a/sdk/core/src/gateway/gateway_block.rs b/sdk/core/src/gateway/gateway_block.rs new file mode 100644 index 0000000000..7131584a20 --- /dev/null +++ b/sdk/core/src/gateway/gateway_block.rs @@ -0,0 +1,47 @@ +use crate::data::hyperblock::{HyperBlock, HyperBlockResponse}; +use anyhow::anyhow; + +use super::{ + GatewayRequest, GatewayRequestType, GET_HYPER_BLOCK_BY_HASH_ENDPOINT, + GET_HYPER_BLOCK_BY_NONCE_ENDPOINT, +}; + +/// Retrieves the data of a hyper block. +pub struct GetHyperBlockRequest { + pub query: String, +} + +impl GetHyperBlockRequest { + pub fn by_nonce(nonce: u64) -> Self { + Self { + query: format!("{GET_HYPER_BLOCK_BY_NONCE_ENDPOINT}/{nonce}"), + } + } + + pub fn by_hash(hash: &str) -> Self { + Self { + query: format!("{GET_HYPER_BLOCK_BY_HASH_ENDPOINT}/{hash}"), + } + } +} + +impl GatewayRequest for GetHyperBlockRequest { + type Payload = (); + type DecodedJson = HyperBlockResponse; + type Result = HyperBlock; + + fn request_type(&self) -> GatewayRequestType { + GatewayRequestType::Get + } + + fn get_endpoint(&self) -> String { + self.query.clone() + } + + fn process_json(&self, decoded: Self::DecodedJson) -> anyhow::Result { + match decoded.data { + None => Err(anyhow!("{}", decoded.error)), + Some(b) => Ok(b.hyperblock), + } + } +} diff --git a/sdk/core/src/gateway/gateway_network_config.rs b/sdk/core/src/gateway/gateway_network_config.rs new file mode 100644 index 0000000000..342c92046b --- /dev/null +++ b/sdk/core/src/gateway/gateway_network_config.rs @@ -0,0 +1,28 @@ +use crate::data::network_config::{NetworkConfig, NetworkConfigResponse}; +use anyhow::anyhow; + +use super::{GatewayRequest, GatewayRequestType, NETWORK_CONFIG_ENDPOINT}; + +/// Retrieves the network configuration from the proxy. +pub struct NetworkConfigRequest; + +impl GatewayRequest for NetworkConfigRequest { + type Payload = (); + type DecodedJson = NetworkConfigResponse; + type Result = NetworkConfig; + + fn request_type(&self) -> GatewayRequestType { + GatewayRequestType::Get + } + + fn get_endpoint(&self) -> String { + NETWORK_CONFIG_ENDPOINT.to_owned() + } + + fn process_json(&self, decoded: Self::DecodedJson) -> anyhow::Result { + match decoded.data { + None => Err(anyhow!("{}", decoded.error)), + Some(b) => Ok(b.config), + } + } +} diff --git a/sdk/core/src/gateway/gateway_network_economics.rs b/sdk/core/src/gateway/gateway_network_economics.rs new file mode 100644 index 0000000000..e8faf3946a --- /dev/null +++ b/sdk/core/src/gateway/gateway_network_economics.rs @@ -0,0 +1,28 @@ +use crate::data::network_economics::{NetworkEconomics, NetworkEconomicsResponse}; +use anyhow::anyhow; + +use super::{GatewayRequest, GatewayRequestType, NETWORK_ECONOMICS_ENDPOINT}; + +/// Retrieves the network economics from the proxy. +pub struct NetworkEconimicsRequest; + +impl GatewayRequest for NetworkEconimicsRequest { + type Payload = (); + type DecodedJson = NetworkEconomicsResponse; + type Result = NetworkEconomics; + + fn request_type(&self) -> GatewayRequestType { + GatewayRequestType::Get + } + + fn get_endpoint(&self) -> String { + NETWORK_ECONOMICS_ENDPOINT.to_owned() + } + + fn process_json(&self, decoded: Self::DecodedJson) -> anyhow::Result { + match decoded.data { + None => Err(anyhow!("{}", decoded.error)), + Some(b) => Ok(b.metrics), + } + } +} diff --git a/sdk/core/src/gateway/gateway_network_status.rs b/sdk/core/src/gateway/gateway_network_status.rs new file mode 100644 index 0000000000..4790f3ea6d --- /dev/null +++ b/sdk/core/src/gateway/gateway_network_status.rs @@ -0,0 +1,38 @@ +use crate::data::network_status::{NetworkStatus, NetworkStatusResponse}; +use anyhow::anyhow; + +use super::{GatewayRequest, GatewayRequestType, GET_NETWORK_STATUS_ENDPOINT, METACHAIN_SHARD_ID}; + +/// Retrieves the network status from the proxy. +pub struct NetworkStatusRequest { + shard: u32, +} + +impl Default for NetworkStatusRequest { + fn default() -> Self { + Self { + shard: METACHAIN_SHARD_ID, + } + } +} + +impl GatewayRequest for NetworkStatusRequest { + type Payload = (); + type DecodedJson = NetworkStatusResponse; + type Result = NetworkStatus; + + fn request_type(&self) -> GatewayRequestType { + GatewayRequestType::Get + } + + fn get_endpoint(&self) -> String { + format!("{GET_NETWORK_STATUS_ENDPOINT}/{}", self.shard) + } + + fn process_json(&self, decoded: Self::DecodedJson) -> anyhow::Result { + match decoded.data { + None => Err(anyhow!("{}", decoded.error)), + Some(b) => Ok(b.status), + } + } +} diff --git a/sdk/core/src/gateway/gateway_tx_cost.rs b/sdk/core/src/gateway/gateway_tx_cost.rs new file mode 100644 index 0000000000..333b0324c5 --- /dev/null +++ b/sdk/core/src/gateway/gateway_tx_cost.rs @@ -0,0 +1,34 @@ +use crate::data::transaction::{ResponseTxCost, Transaction, TxCostResponseData}; +use anyhow::anyhow; + +use super::{GatewayRequest, GatewayRequestType, COST_TRANSACTION_ENDPOINT}; + +/// Verifies the cost of a transaction. +/// +/// Note: it is a POST request. +pub struct GetTxCost<'a>(pub &'a Transaction); + +impl<'a> GatewayRequest for GetTxCost<'a> { + type Payload = Transaction; + type DecodedJson = ResponseTxCost; + type Result = TxCostResponseData; + + fn request_type(&self) -> GatewayRequestType { + GatewayRequestType::Post + } + + fn get_payload(&self) -> Option<&Self::Payload> { + Some(self.0) + } + + fn get_endpoint(&self) -> String { + COST_TRANSACTION_ENDPOINT.to_owned() + } + + fn process_json(&self, decoded: Self::DecodedJson) -> anyhow::Result { + match decoded.data { + None => Err(anyhow!("{}", decoded.error)), + Some(b) => Ok(b), + } + } +} diff --git a/sdk/core/src/gateway/gateway_tx_info.rs b/sdk/core/src/gateway/gateway_tx_info.rs new file mode 100644 index 0000000000..64ec5c31b5 --- /dev/null +++ b/sdk/core/src/gateway/gateway_tx_info.rs @@ -0,0 +1,55 @@ +use crate::data::transaction::{TransactionInfo, TransactionOnNetwork}; +use anyhow::anyhow; + +use super::{ + GatewayRequest, GatewayRequestType, GET_TRANSACTION_INFO_ENDPOINT, WITH_RESULTS_QUERY_PARAM, +}; + +/// Retrieves transaction data from the network. +pub struct GetTxInfo<'a> { + pub hash: &'a str, + pub with_results: bool, +} + +impl<'a> GetTxInfo<'a> { + pub fn new(hash: &'a str) -> Self { + Self { + hash, + with_results: true, + } + } + + pub fn with_results(self) -> Self { + Self { + hash: self.hash, + with_results: true, + } + } +} + +impl<'a> GatewayRequest for GetTxInfo<'a> { + type Payload = (); + type DecodedJson = TransactionInfo; + type Result = TransactionOnNetwork; + + fn request_type(&self) -> GatewayRequestType { + GatewayRequestType::Get + } + + fn get_endpoint(&self) -> String { + let mut endpoint = format!("{GET_TRANSACTION_INFO_ENDPOINT}{}", self.hash); + + if self.with_results { + endpoint += WITH_RESULTS_QUERY_PARAM; + } + + endpoint + } + + fn process_json(&self, decoded: Self::DecodedJson) -> anyhow::Result { + match decoded.data { + None => Err(anyhow!("{}", decoded.error)), + Some(b) => Ok(b.transaction), + } + } +} diff --git a/sdk/core/src/gateway/gateway_tx_process_status.rs b/sdk/core/src/gateway/gateway_tx_process_status.rs new file mode 100644 index 0000000000..d829cb60fe --- /dev/null +++ b/sdk/core/src/gateway/gateway_tx_process_status.rs @@ -0,0 +1,36 @@ +use crate::data::transaction::TransactionProcessStatus; +use anyhow::anyhow; + +use super::{GatewayRequest, GatewayRequestType}; + +/// Retrieves a transaction's status from the network using process-status API. +pub struct GetTxProcessStatus<'a> { + pub hash: &'a str, +} + +impl<'a> GetTxProcessStatus<'a> { + pub fn new(hash: &'a str) -> Self { + Self { hash } + } +} + +impl<'a> GatewayRequest for GetTxProcessStatus<'a> { + type Payload = (); + type DecodedJson = TransactionProcessStatus; + type Result = (String, String); + + fn request_type(&self) -> GatewayRequestType { + GatewayRequestType::Get + } + + fn get_endpoint(&self) -> String { + format!("transaction/{}/process-status", self.hash) + } + + fn process_json(&self, decoded: Self::DecodedJson) -> anyhow::Result { + match decoded.data { + None => Err(anyhow!("{}", decoded.error)), + Some(b) => Ok((b.status, b.reason)), + } + } +} diff --git a/sdk/core/src/gateway/gateway_tx_send.rs b/sdk/core/src/gateway/gateway_tx_send.rs new file mode 100644 index 0000000000..a76354df8e --- /dev/null +++ b/sdk/core/src/gateway/gateway_tx_send.rs @@ -0,0 +1,32 @@ +use crate::data::transaction::{SendTransactionResponse, Transaction}; +use anyhow::anyhow; + +use super::{GatewayRequest, GatewayRequestType, SEND_TRANSACTION_ENDPOINT}; + +/// Sends a single transaction. +pub struct SendTxRequest<'a>(pub &'a Transaction); + +impl<'a> GatewayRequest for SendTxRequest<'a> { + type Payload = Transaction; + type DecodedJson = SendTransactionResponse; + type Result = String; + + fn request_type(&self) -> GatewayRequestType { + GatewayRequestType::Post + } + + fn get_payload(&self) -> Option<&Self::Payload> { + Some(self.0) + } + + fn get_endpoint(&self) -> String { + SEND_TRANSACTION_ENDPOINT.to_owned() + } + + fn process_json(&self, decoded: Self::DecodedJson) -> anyhow::Result { + match decoded.data { + None => Err(anyhow!("{}", decoded.error)), + Some(b) => Ok(b.tx_hash), + } + } +} diff --git a/sdk/core/src/gateway/gateway_tx_send_multi.rs b/sdk/core/src/gateway/gateway_tx_send_multi.rs new file mode 100644 index 0000000000..472beaf5ba --- /dev/null +++ b/sdk/core/src/gateway/gateway_tx_send_multi.rs @@ -0,0 +1,40 @@ +use crate::data::transaction::{SendTransactionsResponse, Transaction}; +use anyhow::anyhow; +use itertools::Itertools; + +use super::{GatewayRequest, GatewayRequestType, SEND_MULTIPLE_TRANSACTIONS_ENDPOINT}; + +/// Sends multiple transactions at once. +pub struct SendMultiTxRequest<'a>(pub &'a [Transaction]); + +impl<'a> GatewayRequest for SendMultiTxRequest<'a> { + type Payload = [Transaction]; + type DecodedJson = SendTransactionsResponse; + type Result = Vec; + + fn request_type(&self) -> GatewayRequestType { + GatewayRequestType::Post + } + + fn get_payload(&self) -> Option<&Self::Payload> { + Some(self.0) + } + + fn get_endpoint(&self) -> String { + SEND_MULTIPLE_TRANSACTIONS_ENDPOINT.to_owned() + } + + fn process_json(&self, decoded: Self::DecodedJson) -> anyhow::Result { + match decoded.data { + None => Err(anyhow!("{}", decoded.error)), + Some(b) => { + let mut tx_hashs: Vec = vec![]; + for key in b.txs_hashes.keys().sorted() { + tx_hashs.push(b.txs_hashes[key].clone()); + } + + Ok(tx_hashs) + }, + } + } +} diff --git a/sdk/core/src/gateway/gateway_tx_status.rs b/sdk/core/src/gateway/gateway_tx_status.rs new file mode 100644 index 0000000000..ac4e37e6b4 --- /dev/null +++ b/sdk/core/src/gateway/gateway_tx_status.rs @@ -0,0 +1,36 @@ +use crate::data::transaction::TransactionStatus; +use anyhow::anyhow; + +use super::{GatewayRequest, GatewayRequestType}; + +/// Retrieves a transaction's status from the network. +pub struct GetTxStatus<'a> { + pub hash: &'a str, +} + +impl<'a> GetTxStatus<'a> { + pub fn new(hash: &'a str) -> Self { + Self { hash } + } +} + +impl<'a> GatewayRequest for GetTxStatus<'a> { + type Payload = (); + type DecodedJson = TransactionStatus; + type Result = String; + + fn request_type(&self) -> GatewayRequestType { + GatewayRequestType::Get + } + + fn get_endpoint(&self) -> String { + format!("transaction/{}/status", self.hash) + } + + fn process_json(&self, decoded: Self::DecodedJson) -> anyhow::Result { + match decoded.data { + None => Err(anyhow!("{}", decoded.error)), + Some(b) => Ok(b.status), + } + } +} diff --git a/sdk/core/src/gateway/gateway_tx_vmquery.rs b/sdk/core/src/gateway/gateway_tx_vmquery.rs new file mode 100644 index 0000000000..7ab448a529 --- /dev/null +++ b/sdk/core/src/gateway/gateway_tx_vmquery.rs @@ -0,0 +1,32 @@ +use crate::data::vm::{ResponseVmValue, VmValueRequest, VmValuesResponseData}; +use anyhow::anyhow; + +use super::{GatewayRequest, GatewayRequestType, VM_VALUES_ENDPOINT}; + +/// Executes a VM query. +pub struct VMQueryRequest<'a>(pub &'a VmValueRequest); + +impl<'a> GatewayRequest for VMQueryRequest<'a> { + type Payload = VmValueRequest; + type DecodedJson = ResponseVmValue; + type Result = VmValuesResponseData; + + fn request_type(&self) -> GatewayRequestType { + GatewayRequestType::Post + } + + fn get_payload(&self) -> Option<&Self::Payload> { + Some(self.0) + } + + fn get_endpoint(&self) -> String { + VM_VALUES_ENDPOINT.to_owned() + } + + fn process_json(&self, decoded: Self::DecodedJson) -> anyhow::Result { + match decoded.data { + None => Err(anyhow!("{}", decoded.error)), + Some(b) => Ok(b), + } + } +} diff --git a/sdk/core/src/lib.rs b/sdk/core/src/lib.rs index e19f3cf2cb..3a1db99fd7 100644 --- a/sdk/core/src/lib.rs +++ b/sdk/core/src/lib.rs @@ -1,4 +1,5 @@ pub mod crypto; pub mod data; +pub mod gateway; pub mod utils; pub mod wallet; diff --git a/sdk/reqwest/examples/get_hyper_block_by_hash.rs b/sdk/reqwest/examples/get_hyper_block_by_hash.rs index 5f43dece66..f4bf399eb3 100644 --- a/sdk/reqwest/examples/get_hyper_block_by_hash.rs +++ b/sdk/reqwest/examples/get_hyper_block_by_hash.rs @@ -7,5 +7,5 @@ async fn main() { .get_hyper_block_by_hash("d59e0dc7d407b1175655357cb8056ec3bb77961192753cddda2fb700c6ce71c6") .await; - println!("block by hash result: {result:?}"); + println!("block by hash result: {result:#?}"); } diff --git a/sdk/reqwest/examples/get_hyper_block_by_nonce.rs b/sdk/reqwest/examples/get_hyper_block_by_nonce.rs index 7b2653b5e4..776a7deb3f 100644 --- a/sdk/reqwest/examples/get_hyper_block_by_nonce.rs +++ b/sdk/reqwest/examples/get_hyper_block_by_nonce.rs @@ -5,5 +5,5 @@ async fn main() { let blockchain = GatewayProxy::new(DEVNET_GATEWAY.to_string(), DEFAULT_USE_CHAIN_SIMULATOR); let result = blockchain.get_hyper_block_by_nonce(7468).await; - println!("block by nonce result: {result:?}") + println!("block by nonce result: {result:#?}") } diff --git a/sdk/reqwest/examples/sign_tx.rs b/sdk/reqwest/examples/sign_tx.rs index a0ab37edfd..ec83f5796d 100644 --- a/sdk/reqwest/examples/sign_tx.rs +++ b/sdk/reqwest/examples/sign_tx.rs @@ -1,7 +1,4 @@ -use multiversx_sdk::{ - data::transaction::Transaction, - wallet::Wallet, -}; +use multiversx_sdk::{data::transaction::Transaction, wallet::Wallet}; use multiversx_sdk_reqwest::gateway::{GatewayProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY}; #[tokio::main] diff --git a/sdk/reqwest/examples/sign_txs.rs b/sdk/reqwest/examples/sign_txs.rs index 50aad886a3..1c52e2d6aa 100644 --- a/sdk/reqwest/examples/sign_txs.rs +++ b/sdk/reqwest/examples/sign_txs.rs @@ -1,7 +1,4 @@ -use multiversx_sdk::{ - data::transaction::Transaction, - wallet::Wallet, -}; +use multiversx_sdk::{data::transaction::Transaction, wallet::Wallet}; use multiversx_sdk_reqwest::gateway::{GatewayProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY}; #[tokio::main] diff --git a/sdk/reqwest/examples/vm_query.rs b/sdk/reqwest/examples/vm_query.rs index e98fc6c97b..964abb5ffb 100644 --- a/sdk/reqwest/examples/vm_query.rs +++ b/sdk/reqwest/examples/vm_query.rs @@ -6,17 +6,16 @@ use multiversx_sdk_reqwest::gateway::{GatewayProxy, DEFAULT_USE_CHAIN_SIMULATOR, #[tokio::main] async fn main() { - let wl = Wallet::from_pem_file("sdk/core/tests/alice.pem").unwrap(); - let addr = wl.address(); let blockchain = GatewayProxy::new(DEVNET_GATEWAY.to_string(), DEFAULT_USE_CHAIN_SIMULATOR); + let sc_address = Address::from_bech32_string( + "erd1qqqqqqqqqqqqqpgq5dvvkmka7sujfsx7cfmygnx0n7luv8k0d8sskpqcec", + ) + .unwrap(); let req = VmValueRequest { - sc_address: Address::from_bech32_string( - "erd1qqqqqqqqqqqqqpgq5dvvkmka7sujfsx7cfmygnx0n7luv8k0d8sskpqcec", - ) - .unwrap(), + sc_address: sc_address.clone(), func_name: "empty".to_string(), args: vec![], - caller: addr.clone(), + caller: sc_address, value: "0".to_string(), }; let result = blockchain.execute_vmquery(&req).await; diff --git a/sdk/reqwest/src/gateway/gateway_account.rs b/sdk/reqwest/src/gateway/gateway_account.rs index d35ff86edb..55a066dfd1 100644 --- a/sdk/reqwest/src/gateway/gateway_account.rs +++ b/sdk/reqwest/src/gateway/gateway_account.rs @@ -1,38 +1,19 @@ -use anyhow::{anyhow, Result}; -use multiversx_sdk::data::{ - account::{Account, AccountResponse}, - account_storage::AccountStorageResponse, - address::Address, - esdt::{EsdtBalance, EsdtBalanceResponse, EsdtRolesResponse}, +use anyhow::Result; +use multiversx_sdk::{ + data::{account::Account, address::Address, esdt::EsdtBalance}, + gateway::{ + GetAccountEsdtRolesRequest, GetAccountEsdtTokensRequest, GetAccountRequest, + GetAccountStorageRequest, + }, }; use std::collections::HashMap; use super::GatewayProxy; -const ACCOUNT_ENDPOINT: &str = "address/"; -const KEYS_ENDPOINT: &str = "/keys/"; - impl GatewayProxy { // get_account retrieves an account info from the network (nonce, balance) pub async fn get_account(&self, address: &Address) -> Result { - if !address.is_valid() { - return Err(anyhow!("invalid address")); - } - - let endpoint = ACCOUNT_ENDPOINT.to_string() + address.to_string().as_str(); - let endpoint = self.get_endpoint(endpoint.as_str()); - let resp = self - .client - .get(endpoint) - .send() - .await? - .json::() - .await?; - - match resp.data { - None => Err(anyhow!("{}", resp.error)), - Some(b) => Ok(b.account), - } + self.request(GetAccountRequest::new(address)).await } // get_account_esdt_roles retrieves an all esdt roles of an account from the network @@ -40,24 +21,7 @@ impl GatewayProxy { &self, address: &Address, ) -> Result>> { - if !address.is_valid() { - return Err(anyhow!("invalid address")); - } - - let endpoint = ACCOUNT_ENDPOINT.to_string() + address.to_string().as_str() + "/esdts/roles"; - let endpoint = self.get_endpoint(endpoint.as_str()); - let resp = self - .client - .get(endpoint) - .send() - .await? - .json::() - .await?; - - match resp.data { - None => Err(anyhow!("{}", resp.error)), - Some(b) => Ok(b.roles), - } + self.request(GetAccountEsdtRolesRequest::new(address)).await } // get_account_esdt_tokens retrieves an all esdt token of an account from the network @@ -65,24 +29,8 @@ impl GatewayProxy { &self, address: &Address, ) -> Result> { - if !address.is_valid() { - return Err(anyhow!("invalid address")); - } - - let endpoint = ACCOUNT_ENDPOINT.to_string() + address.to_string().as_str() + "/esdt"; - let endpoint = self.get_endpoint(endpoint.as_str()); - let resp = self - .client - .get(endpoint) - .send() - .await? - .json::() - .await?; - - match resp.data { - None => Err(anyhow!("{}", resp.error)), - Some(b) => Ok(b.esdts), - } + self.request(GetAccountEsdtTokensRequest::new(address)) + .await } // get_account_esdt_tokens retrieves an all esdt token of an account from the network @@ -90,23 +38,6 @@ impl GatewayProxy { &self, address: &Address, ) -> Result> { - if !address.is_valid() { - return Err(anyhow!("invalid address")); - } - - let endpoint = ACCOUNT_ENDPOINT.to_string() + address.to_string().as_str() + KEYS_ENDPOINT; - let endpoint = self.get_endpoint(endpoint.as_str()); - let resp = self - .client - .get(endpoint) - .send() - .await? - .json::() - .await?; - - match resp.data { - None => Err(anyhow!("{}", resp.error)), - Some(b) => Ok(b.pairs), - } + self.request(GetAccountStorageRequest::new(address)).await } } diff --git a/sdk/reqwest/src/gateway/gateway_block.rs b/sdk/reqwest/src/gateway/gateway_block.rs index 00fdc28995..a45e9ed458 100644 --- a/sdk/reqwest/src/gateway/gateway_block.rs +++ b/sdk/reqwest/src/gateway/gateway_block.rs @@ -1,62 +1,25 @@ -use anyhow::{anyhow, Result}; -use multiversx_sdk::data::{ - hyperblock::{HyperBlock, HyperBlockResponse}, - network_status::NetworkStatusResponse, +use anyhow::Result; +use multiversx_sdk::{ + data::hyperblock::HyperBlock, + gateway::{GetHyperBlockRequest, NetworkStatusRequest}, }; use super::GatewayProxy; -use super::METACHAIN_SHARD_ID; - -const GET_HYPER_BLOCK_BY_NONCE_ENDPOINT: &str = "hyperblock/by-nonce/"; -const GET_HYPER_BLOCK_BY_HASH_ENDPOINT: &str = "hyperblock/by-hash/"; -const GET_NETWORK_STATUS_ENDPOINT: &str = "network/status"; impl GatewayProxy { - async fn get_hyper_block(&self, endpoint: &str) -> Result { - let endpoint = self.get_endpoint(endpoint); - let resp = self - .client - .get(endpoint) - .send() - .await? - .json::() - .await?; - - match resp.data { - None => Err(anyhow!("{}", resp.error)), - Some(b) => Ok(b.hyperblock), - } - } - // get_hyper_block_by_hash retrieves a hyper block's info by hash from the network pub async fn get_hyper_block_by_hash(&self, hash: &str) -> Result { - let endpoint = GET_HYPER_BLOCK_BY_HASH_ENDPOINT.to_string() + hash; - self.get_hyper_block(endpoint.as_str()).await + self.request(GetHyperBlockRequest::by_hash(hash)).await } // get_hyper_block_by_nonce retrieves a hyper block's info by nonce from the network pub async fn get_hyper_block_by_nonce(&self, nonce: u64) -> Result { - let endpoint = GET_HYPER_BLOCK_BY_NONCE_ENDPOINT.to_string() + nonce.to_string().as_str(); - self.get_hyper_block(endpoint.as_str()).await + self.request(GetHyperBlockRequest::by_nonce(nonce)).await } // get_latest_hyper_block_nonce retrieves the latest hyper block (metachain) nonce from the network pub async fn get_latest_hyper_block_nonce(&self) -> Result { - let endpoint = format!("{GET_NETWORK_STATUS_ENDPOINT}/{METACHAIN_SHARD_ID}"); - - let endpoint = self.get_endpoint(endpoint.as_str()); - - let resp = self - .client - .get(endpoint) - .send() - .await? - .json::() - .await?; - - match resp.data { - None => Err(anyhow!("{}", resp.error)), - Some(b) => Ok(b.status.nonce), - } + let network_status = self.request(NetworkStatusRequest::default()).await?; + Ok(network_status.nonce) } } diff --git a/sdk/reqwest/src/gateway/gateway_network.rs b/sdk/reqwest/src/gateway/gateway_network.rs index 9763a61b37..aa40f240eb 100644 --- a/sdk/reqwest/src/gateway/gateway_network.rs +++ b/sdk/reqwest/src/gateway/gateway_network.rs @@ -1,46 +1,19 @@ -use anyhow::{anyhow, Result}; -use multiversx_sdk::data::{ - network_config::{NetworkConfig, NetworkConfigResponse}, - network_economics::{NetworkEconomics, NetworkEconomicsResponse}, +use anyhow::Result; +use multiversx_sdk::{ + data::{network_config::NetworkConfig, network_economics::NetworkEconomics}, + gateway::{NetworkConfigRequest, NetworkEconimicsRequest}, }; use super::GatewayProxy; -const NETWORK_CONFIG_ENDPOINT: &str = "network/config"; -const NETWORK_ECONOMICS_ENDPOINT: &str = "network/economics"; - impl GatewayProxy { // get_network_config retrieves the network configuration from the proxy pub async fn get_network_config(&self) -> Result { - let endpoint = self.get_endpoint(NETWORK_CONFIG_ENDPOINT); - let resp = self - .client - .get(endpoint) - .send() - .await? - .json::() - .await?; - - match resp.data { - None => Err(anyhow!("{}", resp.error)), - Some(b) => Ok(b.config), - } + self.request(NetworkConfigRequest).await } // get_network_economics retrieves the network economics from the proxy pub async fn get_network_economics(&self) -> Result { - let endpoint = self.get_endpoint(NETWORK_ECONOMICS_ENDPOINT); - let resp = self - .client - .get(endpoint) - .send() - .await? - .json::() - .await?; - - match resp.data { - None => Err(anyhow!("{}", resp.error)), - Some(b) => Ok(b.metrics), - } + self.request(NetworkEconimicsRequest).await } } diff --git a/sdk/reqwest/src/gateway/gateway_proxy.rs b/sdk/reqwest/src/gateway/gateway_proxy.rs index 46e48455e5..d097581a8e 100644 --- a/sdk/reqwest/src/gateway/gateway_proxy.rs +++ b/sdk/reqwest/src/gateway/gateway_proxy.rs @@ -1,3 +1,4 @@ +use multiversx_sdk::gateway::GatewayRequest; use reqwest::Client; /// Allows communication with the MultiversX gateway API. @@ -20,4 +21,36 @@ impl GatewayProxy { pub(crate) fn get_endpoint(&self, endpoint: &str) -> String { format!("{}/{}", self.proxy_uri, endpoint) } + + /// Performs a request to the gateway. + /// Can be either GET or POST, depending on the argument. + /// + /// + pub async fn request(&self, request: G) -> anyhow::Result + where + G: GatewayRequest, + { + let url = format!("{}/{}", self.proxy_uri, request.get_endpoint()); + let mut request_builder; + match request.request_type() { + multiversx_sdk::gateway::GatewayRequestType::Get => { + request_builder = self.client.get(url); + }, + multiversx_sdk::gateway::GatewayRequestType::Post => { + request_builder = self.client.post(url); + }, + } + + if let Some(payload) = request.get_payload() { + request_builder = request_builder.json(&payload); + } + + let decoded = request_builder + .send() + .await? + .json::() + .await?; + + request.process_json(decoded) + } } diff --git a/sdk/reqwest/src/gateway/gateway_tx.rs b/sdk/reqwest/src/gateway/gateway_tx.rs index 24e2377a13..28bab4ec7d 100644 --- a/sdk/reqwest/src/gateway/gateway_tx.rs +++ b/sdk/reqwest/src/gateway/gateway_tx.rs @@ -1,73 +1,31 @@ -use anyhow::{anyhow, Result}; -use itertools::Itertools; -use multiversx_sdk::data::{ - address::Address, - network_config::NetworkConfig, - transaction::{ - ArgCreateTransaction, ResponseTxCost, SendTransactionResponse, SendTransactionsResponse, - Transaction, TransactionInfo, TransactionOnNetwork, TransactionProcessStatus, - TransactionStatus, TxCostResponseData, +use anyhow::Result; +use multiversx_sdk::{ + data::{ + address::Address, + network_config::NetworkConfig, + transaction::{ + ArgCreateTransaction, Transaction, TransactionOnNetwork, TxCostResponseData, + }, + vm::{VmValueRequest, VmValuesResponseData}, + }, + gateway::{ + GetTxCost, GetTxInfo, GetTxProcessStatus, GetTxStatus, SendMultiTxRequest, SendTxRequest, + VMQueryRequest, }, - vm::{ResponseVmValue, VmValueRequest, VmValuesResponseData}, }; use super::GatewayProxy; -const COST_TRANSACTION_ENDPOINT: &str = "transaction/cost"; -const SEND_TRANSACTION_ENDPOINT: &str = "transaction/send"; -const SEND_MULTIPLE_TRANSACTIONS_ENDPOINT: &str = "transaction/send-multiple"; -const GET_TRANSACTION_INFO_ENDPOINT: &str = "transaction/"; -const WITH_RESULTS_QUERY_PARAM: &str = "?withResults=true"; -const VM_VALUES_ENDPOINT: &str = "vm-values/query"; - impl GatewayProxy { // request_transaction_cost retrieves how many gas a transaction will consume pub async fn request_transaction_cost(&self, tx: &Transaction) -> Result { - let endpoint = self.get_endpoint(COST_TRANSACTION_ENDPOINT); - let resp = self - .client - .post(endpoint) - .json(tx) - .send() - .await? - .json::() - .await?; - - match resp.data { - None => Err(anyhow!("{}", resp.error)), - Some(b) => Ok(b), - } - } - - async fn get_transaction_info_internal( - &self, - hash: &str, - with_results: bool, - ) -> Result { - let mut endpoint = GET_TRANSACTION_INFO_ENDPOINT.to_string() + hash; - - if with_results { - endpoint += WITH_RESULTS_QUERY_PARAM - } - - let endpoint = self.get_endpoint(endpoint.as_str()); - let resp = self - .client - .get(endpoint) - .send() - .await? - .json::() - .await?; - - match resp.data { - None => Err(anyhow!("{}", resp.error)), - Some(b) => Ok(b.transaction), - } + self.request(GetTxCost(tx)).await } // get_transaction_info retrieves a transaction's details from the network pub async fn get_transaction_info(&self, hash: &str) -> Result { - self.get_transaction_info_internal(hash, false).await + // self.get_transaction_info_internal(hash, false).await + self.request(GetTxInfo::new(hash)).await } // get_transaction_info_with_results retrieves a transaction's details from the network with events @@ -75,45 +33,18 @@ impl GatewayProxy { &self, hash: &str, ) -> Result { - self.get_transaction_info_internal(hash, true).await + // self.get_transaction_info_internal(hash, true).await + self.request(GetTxInfo::new(hash).with_results()).await } // get_transaction_status retrieves a transaction's status from the network pub async fn get_transaction_status(&self, hash: &str) -> Result { - let endpoint = format!("transaction/{hash}/status"); - let endpoint = self.get_endpoint(endpoint.as_str()); - - let resp = self - .client - .get(endpoint) - .send() - .await? - .json::() - .await?; - - match resp.data { - None => Err(anyhow!("{}", resp.error)), - Some(b) => Ok(b.status), - } + self.request(GetTxStatus::new(hash)).await } // get_transaction_process_status retrieves a transaction's status from the network using process-status API pub async fn get_transaction_process_status(&self, hash: &str) -> Result<(String, String)> { - let endpoint = format!("transaction/{hash}/process-status"); - let endpoint = self.get_endpoint(endpoint.as_str()); - - let resp = self - .client - .get(endpoint) - .send() - .await? - .json::() - .await?; - - match resp.data { - None => Err(anyhow!("{}", resp.error)), - Some(b) => Ok((b.status, b.reason)), - } + self.request(GetTxProcessStatus::new(hash)).await } // get_default_transaction_arguments will prepare the transaction creation argument by querying the account's info @@ -141,44 +72,12 @@ impl GatewayProxy { } pub async fn send_transaction(&self, tx: &Transaction) -> Result { - let endpoint = self.get_endpoint(SEND_TRANSACTION_ENDPOINT); - let resp = self - .client - .post(endpoint) - .json(tx) - .send() - .await? - .json::() - .await?; - - match resp.data { - None => Err(anyhow!("{}", resp.error)), - Some(b) => Ok(b.tx_hash), - } + self.request(SendTxRequest(tx)).await } + #[allow(clippy::ptr_arg)] pub async fn send_transactions(&self, txs: &Vec) -> Result> { - let endpoint = self.get_endpoint(SEND_MULTIPLE_TRANSACTIONS_ENDPOINT); - let resp = self - .client - .post(endpoint) - .json(txs) - .send() - .await? - .json::() - .await?; - - match resp.data { - None => Err(anyhow!("{}", resp.error)), - Some(b) => { - let mut tx_hashs: Vec = vec![]; - for key in b.txs_hashes.keys().sorted() { - tx_hashs.push(b.txs_hashes[key].clone()); - } - - Ok(tx_hashs) - }, - } + self.request(SendMultiTxRequest(txs)).await } // execute_vmquery retrieves data from existing SC trie through the use of a VM @@ -186,19 +85,6 @@ impl GatewayProxy { &self, vm_request: &VmValueRequest, ) -> Result { - let endpoint = self.get_endpoint(VM_VALUES_ENDPOINT); - let resp = self - .client - .post(endpoint) - .json(vm_request) - .send() - .await? - .json::() - .await?; - - match resp.data { - None => Err(anyhow!("{}", resp.error)), - Some(b) => Ok(b), - } + self.request(VMQueryRequest(vm_request)).await } } From 842ddae8e6a1825dff4084a9fa2dad60356f1048 Mon Sep 17 00:00:00 2001 From: Andrei Marinica Date: Tue, 1 Oct 2024 10:22:30 +0300 Subject: [PATCH 2/2] cleanup --- sdk/reqwest/examples/vm_query.rs | 5 +---- sdk/reqwest/src/gateway/gateway_tx.rs | 2 -- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/sdk/reqwest/examples/vm_query.rs b/sdk/reqwest/examples/vm_query.rs index 964abb5ffb..b5747aba05 100644 --- a/sdk/reqwest/examples/vm_query.rs +++ b/sdk/reqwest/examples/vm_query.rs @@ -1,7 +1,4 @@ -use multiversx_sdk::{ - data::{address::Address, vm::VmValueRequest}, - wallet::Wallet, -}; +use multiversx_sdk::data::{address::Address, vm::VmValueRequest}; use multiversx_sdk_reqwest::gateway::{GatewayProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY}; #[tokio::main] diff --git a/sdk/reqwest/src/gateway/gateway_tx.rs b/sdk/reqwest/src/gateway/gateway_tx.rs index 28bab4ec7d..7e3f7e9084 100644 --- a/sdk/reqwest/src/gateway/gateway_tx.rs +++ b/sdk/reqwest/src/gateway/gateway_tx.rs @@ -24,7 +24,6 @@ impl GatewayProxy { // get_transaction_info retrieves a transaction's details from the network pub async fn get_transaction_info(&self, hash: &str) -> Result { - // self.get_transaction_info_internal(hash, false).await self.request(GetTxInfo::new(hash)).await } @@ -33,7 +32,6 @@ impl GatewayProxy { &self, hash: &str, ) -> Result { - // self.get_transaction_info_internal(hash, true).await self.request(GetTxInfo::new(hash).with_results()).await }