-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e856a90
commit 9602c10
Showing
15 changed files
with
3,457 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
contracts/feature-tests/composability/forwarder-interactor/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Pem files are used for interactions, but shouldn't be committed | ||
*.pem |
32 changes: 32 additions & 0 deletions
32
contracts/feature-tests/composability/forwarder-interactor/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[package] | ||
name = "forwarder-interact" | ||
version = "0.0.0" | ||
authors = ["you"] | ||
edition = "2021" | ||
publish = false | ||
|
||
[[bin]] | ||
name = "forwarder-interact" | ||
path = "src/interactor_main.rs" | ||
|
||
[lib] | ||
path = "src/interact.rs" | ||
|
||
[dependencies.forwarder] | ||
path = "../forwarder" | ||
|
||
[dependencies.multiversx-sc-snippets] | ||
version = "0.54.5" | ||
path = "../../../../framework/snippets" | ||
|
||
[dependencies.multiversx-sc] | ||
version = "0.54.5" | ||
path = "../../../../framework/base" | ||
|
||
[dependencies] | ||
clap = { version = "4.4.7", features = ["derive"] } | ||
serde = { version = "1.0", features = ["derive"] } | ||
toml = "0.8.6" | ||
|
||
[features] | ||
chain-simulator-tests = [] |
7 changes: 7 additions & 0 deletions
7
contracts/feature-tests/composability/forwarder-interactor/config.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
# chain_type = 'simulator' | ||
# gateway_uri = 'http://localhost:8085' | ||
|
||
chain_type = 'real' | ||
gateway_uri = 'https://devnet-gateway.multiversx.com' | ||
|
51 changes: 51 additions & 0 deletions
51
contracts/feature-tests/composability/forwarder-interactor/src/config.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#![allow(unused)] | ||
|
||
use serde::Deserialize; | ||
use std::io::Read; | ||
|
||
/// Config file | ||
const CONFIG_FILE: &str = "config.toml"; | ||
|
||
#[derive(Debug, Deserialize)] | ||
#[serde(rename_all = "lowercase")] | ||
pub enum ChainType { | ||
Real, | ||
Simulator, | ||
} | ||
|
||
/// Contract Interact configuration | ||
#[derive(Debug, Deserialize)] | ||
pub struct Config { | ||
pub gateway_uri: String, | ||
pub chain_type: ChainType, | ||
} | ||
|
||
impl Config { | ||
// Deserializes config from file | ||
pub fn new() -> Self { | ||
let mut file = std::fs::File::open(CONFIG_FILE).unwrap(); | ||
let mut content = String::new(); | ||
file.read_to_string(&mut content).unwrap(); | ||
toml::from_str(&content).unwrap() | ||
} | ||
|
||
pub fn chain_simulator_config() -> Self { | ||
Config { | ||
gateway_uri: "http://localhost:8085".to_owned(), | ||
chain_type: ChainType::Simulator, | ||
} | ||
} | ||
|
||
// Returns the gateway URI | ||
pub fn gateway_uri(&self) -> &str { | ||
&self.gateway_uri | ||
} | ||
|
||
// Returns if chain type is chain simulator | ||
pub fn use_chain_simulator(&self) -> bool { | ||
match self.chain_type { | ||
ChainType::Real => false, | ||
ChainType::Simulator => true, | ||
} | ||
} | ||
} |
Oops, something went wrong.