Skip to content

Commit b2a6dcb

Browse files
committed
feat(wallet): auto-open browser
1 parent 0e19b8a commit b2a6dcb

File tree

5 files changed

+150
-104
lines changed

5 files changed

+150
-104
lines changed

Cargo.lock

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,5 @@ strum_macros = "0.26"
7878

7979
# wallet-integration
8080
axum = "0.7.9"
81+
open = "5.3.1"
8182
tower-http = "0.6.2"

crates/pop-cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pop-common = { path = "../pop-common", version = "0.5.0" }
4949

5050
# wallet-integration
5151
axum.workspace = true
52+
open.workspace = true
5253
tower-http = { workspace = true, features = ["fs", "cors"] }
5354

5455
[dev-dependencies]

crates/pop-cli/src/assets/index.html

Lines changed: 101 additions & 101 deletions
Large diffs are not rendered by default.

crates/pop-cli/src/common/wallet.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,22 @@ pub const USE_WALLET_PROMPT: &str = "Do you want to use your browser wallet to s
1616
/// * `url` - Chain rpc.
1717
/// # Returns
1818
/// * The signed payload, if it exists.
19-
pub async fn request_signature(call_data: Vec<u8>, url: String) -> anyhow::Result<Option<String>> {
19+
pub async fn request_signature(call_data: Vec<u8>, rpc: String) -> anyhow::Result<Option<String>> {
2020
let ui = FrontendFromString::new(include_str!("../assets/index.html").to_string());
2121

22-
let transaction_data = TransactionData::new(url, call_data);
22+
let transaction_data = TransactionData::new(rpc, call_data);
2323
// Starts server with random port.
2424
let mut wallet = WalletIntegrationManager::new(ui, transaction_data, None);
25-
log::step(format!("Wallet signing portal started at http://{}", wallet.server_url))?;
25+
let url = wallet.server_url.clone();
26+
log::step(format!("Wallet signing portal started at http://{url}."))?;
2627

2728
let spinner = spinner();
29+
spinner.start(format!("Opening browser to http://{url}"));
30+
let res = open::that(format!("http://{url}"));
31+
if let Err(e) = res {
32+
spinner.error(format!("Failed to launch browser. Please open link manually. {e}"));
33+
}
34+
2835
spinner.start("Waiting for signature... Press Ctrl+C to terminate early.");
2936
loop {
3037
// Display error, if any.

0 commit comments

Comments
 (0)