Skip to content

Commit 0125540

Browse files
authored
Link to lab after deploying contract, so users can interact with it. (#2309)
1 parent fc2cc45 commit 0125540

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

cmd/soroban-cli/src/commands/contract/deploy/wasm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ impl NetworkRunnable for Cmd {
327327
data::write(get_txn_resp.clone().try_into()?, &network.rpc_uri()?)?;
328328
}
329329

330-
if let Some(url) = utils::explorer_url_for_contract(&network, &contract_id) {
330+
if let Some(url) = utils::lab_url_for_contract(&network, &contract_id) {
331331
print.linkln(url);
332332
}
333333

cmd/soroban-cli/src/utils.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,24 @@ static EXPLORERS: phf::Map<&'static str, &'static str> = phf_map! {
4141
"Public Global Stellar Network ; September 2015" => "https://stellar.expert/explorer/public",
4242
};
4343

44+
static LAB_CONTRACT_URLS: phf::Map<&'static str, &'static str> = phf_map! {
45+
"Test SDF Network ; September 2015" => "https://lab.stellar.org/r/testnet/contract/{contract_id}",
46+
"Public Global Stellar Network ; September 2015" => "https://lab.stellar.org/r/mainnet/contract/{contract_id}",
47+
};
48+
4449
pub fn explorer_url_for_transaction(network: &Network, tx_hash: &str) -> Option<String> {
4550
EXPLORERS
4651
.get(&network.network_passphrase)
4752
.map(|base_url| format!("{base_url}/tx/{tx_hash}"))
4853
}
4954

50-
pub fn explorer_url_for_contract(
55+
pub fn lab_url_for_contract(
5156
network: &Network,
5257
contract_id: &stellar_strkey::Contract,
5358
) -> Option<String> {
54-
EXPLORERS
59+
LAB_CONTRACT_URLS
5560
.get(&network.network_passphrase)
56-
.map(|base_url| format!("{base_url}/contract/{contract_id}"))
61+
.map(|base_url| base_url.replace("{contract_id}", &contract_id.to_string()))
5762
}
5863

5964
/// # Errors

0 commit comments

Comments
 (0)