Skip to content

Commit 253c290

Browse files
committed
prefer fields
1 parent f19313b commit 253c290

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

crates/wallets/src/wallet_browser/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ mod tests {
6767
connect_wallet(&client, &server, Connection::new(ALICE, 1)).await;
6868

6969
// Check connection state
70-
let Connection(address, chain_id) =
70+
let Connection { address, chain_id } =
7171
server.get_connection().expect("expected an active wallet connection");
7272
assert_eq!(address, ALICE);
7373
assert_eq!(chain_id, 1);
@@ -82,7 +82,7 @@ mod tests {
8282
connect_wallet(&client, &server, Connection::new(BOB, 42)).await;
8383

8484
// Check connection state
85-
let Connection(address, chain_id) =
85+
let Connection { address, chain_id } =
8686
server.get_connection().expect("expected an active wallet connection");
8787
assert_eq!(address, BOB);
8888
assert_eq!(chain_id, 42);
@@ -99,14 +99,14 @@ mod tests {
9999

100100
// Connect Alice, assert connected
101101
connect_wallet(&client, &server, Connection::new(ALICE, 1)).await;
102-
let Connection(address, chain_id) =
102+
let Connection { address, chain_id } =
103103
server.get_connection().expect("expected an active wallet connection");
104104
assert_eq!(address, ALICE);
105105
assert_eq!(chain_id, 1);
106106

107107
// Connect Bob, assert switched
108108
connect_wallet(&client, &server, Connection::new(BOB, 42)).await;
109-
let Connection(address, chain_id) =
109+
let Connection { address, chain_id } =
110110
server.get_connection().expect("expected an active wallet connection");
111111
assert_eq!(address, BOB);
112112
assert_eq!(chain_id, 42);
@@ -317,7 +317,7 @@ mod tests {
317317
let mut server = create_server();
318318
let client = client_with_token(&server);
319319
server.start().await.unwrap();
320-
connect_wallet(&client, &server, Connection(ALICE, 1)).await;
320+
connect_wallet(&client, &server, Connection::new(ALICE, 1)).await;
321321

322322
// Create a browser transaction request
323323
let (tx_request_id, tx_request) = create_browser_transaction_request();

crates/wallets/src/wallet_browser/signer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl BrowserSigner {
4444
let start = Instant::now();
4545

4646
loop {
47-
if let Some(Connection(address, chain_id)) = server.get_connection() {
47+
if let Some(Connection { address, chain_id }) = server.get_connection() {
4848
let _ = sh_println!("Wallet connected: {}", address);
4949
let _ = sh_println!("Chain ID: {}", chain_id);
5050

crates/wallets/src/wallet_browser/types.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,16 @@ pub(crate) struct BrowserSignResponse {
112112

113113
/// Represents an active connection to a browser wallet.
114114
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
115-
pub struct Connection(pub Address, pub ChainId);
115+
pub struct Connection {
116+
/// The address of the connected wallet.
117+
pub address: Address,
118+
/// The chain ID of the connected wallet.
119+
pub chain_id: ChainId,
120+
}
116121

117122
impl Connection {
118123
/// Create a new connection instance.
119124
pub fn new(address: Address, chain_id: ChainId) -> Self {
120-
Self(address, chain_id)
125+
Self { address, chain_id }
121126
}
122127
}

0 commit comments

Comments
 (0)