Skip to content

Commit

Permalink
sdk http crate rename
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-marinica committed Oct 2, 2024
1 parent a5d9948 commit db46f48
Show file tree
Hide file tree
Showing 37 changed files with 72 additions and 70 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ members = [
"framework/wasm-adapter",

"sdk/core",
"sdk/reqwest",
"sdk/http",
"sdk/wbg",
"sdk/scenario-format",

Expand Down
4 changes: 2 additions & 2 deletions framework/snippets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ path = "../scenario"
version = "0.23.0"
path = "../../sdk/scenario-format"

[dependencies.multiversx-sdk-reqwest]
[dependencies.multiversx-sdk-http]
version = "=0.6.1"
path = "../../sdk/reqwest"
path = "../../sdk/http"

[dev-dependencies]
serde_json = "1.0"
2 changes: 1 addition & 1 deletion framework/snippets/src/account_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use multiversx_sc_scenario::{
imports::Bech32Address,
scenario_model::{Account, BytesKey, BytesValue, Scenario, SetStateStep, Step},
};
use multiversx_sdk_reqwest::gateway::GatewayHttpProxy;
use multiversx_sdk_http::GatewayHttpProxy;
use std::collections::{BTreeMap, HashMap};

/// Called directly from CLI, from `sc-meta`.
Expand Down
2 changes: 1 addition & 1 deletion framework/snippets/src/interactor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use multiversx_sc_scenario::{
mandos_system::{run_list::ScenarioRunnerList, run_trace::ScenarioTraceFile},
multiversx_sc::types::Address,
};
use multiversx_sdk_reqwest::gateway::GatewayHttpProxy;
use multiversx_sdk_http::GatewayHttpProxy;
use std::{
collections::HashMap,
path::{Path, PathBuf},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use multiversx_sc_scenario::{
scenario::ScenarioRunner,
scenario_model::{ScCallStep, SetStateStep, TxCall},
};
use multiversx_sdk_reqwest::core::{data::transaction::Transaction, utils::base64_encode};
use multiversx_sdk_http::core::{data::transaction::Transaction, utils::base64_encode};

impl Interactor {
pub async fn sc_call<S>(&mut self, mut sc_call_step: S)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use multiversx_sc_scenario::{
mandos_system::ScenarioRunner,
scenario_model::{ScDeployStep, SetStateStep},
};
use multiversx_sdk_reqwest::core::{data::transaction::Transaction, utils::base64_encode};
use multiversx_sdk_http::core::{data::transaction::Transaction, utils::base64_encode};

impl Interactor {
pub(crate) fn sc_deploy_to_blockchain_tx(&self, sc_deploy_step: &ScDeployStep) -> Transaction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use multiversx_sc_scenario::{
multiversx_sc::{abi::TypeAbiFrom, codec::TopDecodeMulti, types::ContractCall},
scenario_model::{ScQueryStep, TxResponse},
};
use multiversx_sdk_reqwest::core::{data::vm::VMQueryInput, utils::base64_decode};
use multiversx_sdk_http::core::{data::vm::VMQueryInput, utils::base64_decode};

impl Interactor {
pub async fn sc_query<S>(&mut self, mut step: S) -> &mut Self
Expand Down
4 changes: 2 additions & 2 deletions framework/snippets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ pub use interactor_tx::*;
pub use log;
pub use multi::*;
pub use multiversx_sc_scenario::{self, multiversx_sc};
pub use multiversx_sdk_reqwest::core as sdk_core;
pub use multiversx_sdk_reqwest::core as sdk;
pub use multiversx_sdk_http::core as sdk_core;
pub use multiversx_sdk_http::core as sdk;
pub use tokio;

/// Imports normally needed in interactors, grouped together.
Expand Down
6 changes: 4 additions & 2 deletions sdk/core/src/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ pub trait GatewayRequest: Send {
}

pub trait GatewayAsyncService: Send {
fn request<G>(&self, request: G) -> impl std::future::Future<Output = anyhow::Result<G::Result>> + Send
fn request<G>(
&self,
request: G,
) -> impl std::future::Future<Output = anyhow::Result<G::Result>> + Send
where
G: GatewayRequest;
}

2 changes: 1 addition & 1 deletion sdk/reqwest/Cargo.toml → sdk/http/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "multiversx-sdk-reqwest"
name = "multiversx-sdk-http"
version = "0.6.1"
edition = "2021"

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use multiversx_sdk::data::address::Address;
use multiversx_sdk_reqwest::gateway::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};
use multiversx_sdk_http::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};

#[tokio::main]
async fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use multiversx_sdk::data::address::Address;
use multiversx_sdk_reqwest::gateway::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};
use multiversx_sdk_http::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};

#[tokio::main]
async fn main() {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use multiversx_sdk::data::address::Address;
use multiversx_sdk_reqwest::gateway::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};
use multiversx_sdk_http::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};

#[tokio::main]
async fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use multiversx_sdk_reqwest::gateway::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};
use multiversx_sdk_http::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};

#[tokio::main]
async fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use multiversx_sdk_reqwest::gateway::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};
use multiversx_sdk_http::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};

#[tokio::main]
async fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use multiversx_sdk_reqwest::gateway::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};
use multiversx_sdk_http::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};

#[tokio::main]
async fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use multiversx_sdk_reqwest::gateway::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};
use multiversx_sdk_http::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};

#[tokio::main]
async fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use multiversx_sdk_reqwest::gateway::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};
use multiversx_sdk_http::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};

#[tokio::main]
async fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use multiversx_sdk::{data::transaction::Transaction, wallet::Wallet};
use multiversx_sdk_reqwest::gateway::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};
use multiversx_sdk_http::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};

#[tokio::main]
async fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use multiversx_sdk::{data::transaction::Transaction, wallet::Wallet};
use multiversx_sdk_reqwest::gateway::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};
use multiversx_sdk_http::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};

#[tokio::main]
async fn main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use multiversx_sdk::{
data::{address::Address, transaction::Transaction},
utils::base64_encode,
};
use multiversx_sdk_reqwest::gateway::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};
use multiversx_sdk_http::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};

#[tokio::main]
async fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use multiversx_sdk::data::address::Address;
use multiversx_sdk_reqwest::gateway::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};
use multiversx_sdk_http::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};

#[tokio::main]
async fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use multiversx_sdk_reqwest::gateway::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};
use multiversx_sdk_http::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};

#[tokio::main]
async fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use multiversx_sdk::data::{address::Address, vm::VMQueryInput};
use multiversx_sdk_reqwest::gateway::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};
use multiversx_sdk_http::{GatewayHttpProxy, DEFAULT_USE_CHAIN_SIMULATOR, DEVNET_GATEWAY};

#[tokio::main]
async fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
use multiversx_sdk::gateway::GatewayRequest;
use reqwest::Client;
mod http_account;
mod http_block;
mod http_chain_simulator;
mod http_network;
mod http_tx;
mod http_tx_retrieve;

use multiversx_sdk::gateway::{GatewayAsyncService, GatewayRequest};

/// Allows communication with the MultiversX gateway API.
#[derive(Clone, Debug)]
pub struct GatewayHttpProxy {
pub(crate) proxy_uri: String,
pub(crate) client: Client,
pub(crate) client: reqwest::Client,
pub chain_simulator: bool,
}

impl GatewayHttpProxy {
pub fn new(proxy_uri: String, chain_simulator: bool) -> Self {
Self {
proxy_uri,
client: Client::new(),
client: reqwest::Client::new(),
chain_simulator,
}
}
Expand Down Expand Up @@ -53,3 +59,14 @@ impl GatewayHttpProxy {
}
}

impl GatewayAsyncService for GatewayHttpProxy {
fn request<G>(
&self,
request: G,
) -> impl std::future::Future<Output = anyhow::Result<G::Result>> + Send
where
G: multiversx_sdk::gateway::GatewayRequest,
{
self.http_request(request)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ impl GatewayHttpProxy {
&self,
address: &Address,
) -> Result<HashMap<String, Vec<String>>> {
self.http_request(GetAccountEsdtRolesRequest::new(address)).await
self.http_request(GetAccountEsdtRolesRequest::new(address))
.await
}

// get_account_esdt_tokens retrieves an all esdt token of an account from the network
Expand All @@ -38,6 +39,7 @@ impl GatewayHttpProxy {
&self,
address: &Address,
) -> Result<HashMap<String, String>> {
self.http_request(GetAccountStorageRequest::new(address)).await
self.http_request(GetAccountStorageRequest::new(address))
.await
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ impl GatewayHttpProxy {

// 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<HyperBlock> {
self.http_request(GetHyperBlockRequest::by_nonce(nonce)).await
self.http_request(GetHyperBlockRequest::by_nonce(nonce))
.await
}

// get_latest_hyper_block_nonce retrieves the latest hyper block (metachain) nonce from the network
Expand Down
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions sdk/http/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
mod gateway_http_proxy;

pub use gateway_http_proxy::GatewayHttpProxy;

pub use multiversx_sdk as core;

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;

pub const DEFAULT_USE_CHAIN_SIMULATOR: bool = false;
31 changes: 0 additions & 31 deletions sdk/reqwest/src/gateway.rs

This file was deleted.

3 changes: 0 additions & 3 deletions sdk/reqwest/src/lib.rs

This file was deleted.

0 comments on commit db46f48

Please sign in to comment.