Skip to content

Commit c7763d1

Browse files
committed
chore: typos, bindings, helpers
Signed-off-by: Gregory Hill <gregorydhill@outlook.com>
1 parent 61f6b0b commit c7763d1

File tree

7 files changed

+39
-22
lines changed

7 files changed

+39
-22
lines changed

contracts/src/swap/Marketplace.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {ERC2771Recipient} from "../ERC2771/ERC2771Recipient.sol";
88
using SafeERC20 for IERC20;
99

1010
contract MarketPlace is ERC2771Recipient {
11-
mapping(uint256 => Order) public ercErcOrders; // cant have struct as key, nor tupple
11+
mapping(uint256 => Order) public ercErcOrders; // can't have struct as key, nor tuple
1212

1313
event placeOrder(
1414
uint256 indexed orderId,

crates/bindings/src/full_relay.rs

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

crates/bindings/src/full_relay_with_verify.rs

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

crates/bindings/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![allow(unused_imports, clippy::all, dead_code, rustdoc::all)]
1+
#![allow(unused_imports, clippy::all, rustdoc::all)]
22
//! This module contains the sol! generated bindings for solidity contracts.
33
//! This is autogenerated code.
44
//! Do not manually edit these files.

crates/utils/src/bitcoin_client.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,16 @@ impl BitcoinClient {
259259
}
260260
}
261261

262+
pub fn new_with_wallet(
263+
url: &str,
264+
wallet_name: &str,
265+
rpc_user: impl Into<String>,
266+
rpc_pass: impl Into<String>,
267+
) -> Self {
268+
let rpc_url_with_wallet = format!("{}/wallet/{}", url.trim_end_matches('/'), wallet_name);
269+
Self::new(&rpc_url_with_wallet, rpc_user, rpc_pass)
270+
}
271+
262272
pub async fn connect(&self, connection_timeout: Duration) -> Result<(), Error> {
263273
info!("Connecting to bitcoin...");
264274
timeout(connection_timeout, async move {

crates/utils/src/esplora_client.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use bitcoin::{
2-
block::Header, consensus, hashes::hex::FromHex, BlockHash, CompactTarget, MerkleBlock, Network,
3-
Transaction, TxMerkleNode, Txid,
2+
block::Header, consensus, constants::ChainHash, hashes::hex::FromHex, BlockHash, CompactTarget,
3+
MerkleBlock, Network, Transaction, TxMerkleNode, Txid,
44
};
55
use eyre::{Error, Result};
66
use reqwest::{Client, Url};
@@ -257,15 +257,8 @@ impl EsploraClient {
257257
}
258258

259259
pub async fn get_bitcoin_network(&self) -> Result<Network> {
260-
let url_str = self.url.as_str();
261-
262-
match url_str {
263-
_ if url_str.contains(ESPLORA_MAINNET_URL) => Ok(Network::Bitcoin),
264-
_ if url_str.contains(ESPLORA_TESTNET_URL) => Ok(Network::Testnet),
265-
_ if url_str.contains(ESPLORA_LOCALHOST_URL) => Ok(Network::Regtest),
266-
_ if url_str.contains(ESPLORA_SIGNET_URL) => Ok(Network::Signet),
267-
_ => Err(Error::msg("Unknown network for URL: {url_str}")),
268-
}
260+
let genesis_hash = self.get_block_hash(0).await?;
261+
Ok(Network::try_from(ChainHash::from_genesis_block_hash(genesis_hash))?)
269262
}
270263
}
271264

@@ -351,4 +344,18 @@ mod tests {
351344
);
352345
Ok(())
353346
}
347+
348+
#[tokio::test]
349+
async fn test_get_network() -> Result<()> {
350+
let esplora_client = EsploraClient::new(Network::Bitcoin)?;
351+
matches!(esplora_client.get_bitcoin_network().await?, Network::Bitcoin);
352+
353+
let esplora_client = EsploraClient::new(Network::Testnet)?;
354+
matches!(esplora_client.get_bitcoin_network().await?, Network::Testnet);
355+
356+
let esplora_client = EsploraClient::new(Network::Signet)?;
357+
matches!(esplora_client.get_bitcoin_network().await?, Network::Signet);
358+
359+
Ok(())
360+
}
354361
}

deploy-all.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ npx gsn deploy --network https://l2-puff-bob-jznbxtoq7h.t.conduit.xyz --privateK
3737
# Paymaster (Default): 0x0000000000000000000000000000000000000000
3838
```
3939

40-
## Miscelaneous deployments
40+
## Miscellaneous deployments
4141

4242
### Tokens
4343

0 commit comments

Comments
 (0)