Skip to content

Commit

Permalink
Introduce a replaceable RestClient (#1175)
Browse files Browse the repository at this point in the history
* Integrate RestClient trait

* Cleanup docs and redundant response status

* Fix C# CI test

* Cargo fmt

* Fix withdraw timeout handling

* Pass RestClient impl as reference

* Remove domain validation

* Simplify RestClient interface naming

* Move success check to another fn

* Move check outside of trait

* Remove superfluous test dependencies

* Improve tests
  • Loading branch information
dangeross authored Mar 5, 2025
1 parent fb93dc5 commit 0017f7d
Show file tree
Hide file tree
Showing 27 changed files with 1,046 additions and 1,197 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ jobs:
build-bindings:
name: Test sdk-bindings
runs-on: macOS-latest
env:
DOTNET_INSTALL_DIR: "${{ github.workspace }}/dotnet"
steps:
- name: Checkout repo
uses: actions/checkout@v4
Expand Down Expand Up @@ -112,7 +114,7 @@ jobs:
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
dotnet-version: '7.0.x'

- name: Setup go
uses: actions/setup-go@v5
Expand Down
57 changes: 0 additions & 57 deletions libs/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion libs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ hex = "0.4"
lightning = "=0.0.118" # Same version as used in gl-client
lightning-invoice = "=0.26.0" # Same version as used in gl-client
log = "0.4"
mockito = "1"
once_cell = "1"
prost = "^0.11"
regex = "1.8.1"
Expand Down
12 changes: 1 addition & 11 deletions libs/sdk-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,12 @@ wasm-bindgen = "0.2.100"

[dev-dependencies]
bitcoin = { workspace = true, features = ["rand"] }
once_cell = { workspace = true }

[target.'cfg(not(all(target_family = "wasm", target_os = "unknown")))'.dev-dependencies]
mockito = { workspace = true }
tokio = { workspace = true, features = ["sync", "rt"] }

[target.'cfg(all(target_family = "wasm", target_os = "unknown"))'.dev-dependencies]
js-sys = "0.3"
wasm-bindgen-test = "0.3.33"
wasm-bindgen-futures = "0.4"
web-sys = { version = "0.3", features = [
"Navigator",
"ServiceWorkerContainer",
"ServiceWorker",
"ServiceWorkerRegistration",
"ServiceWorkerState",
] }

[target.'cfg(not(all(target_family = "wasm", target_os = "unknown")))'.build-dependencies]
tonic-build = { workspace = true }
Expand All @@ -77,3 +66,4 @@ tonic-build = "0.12"

[features]
liquid = ["dep:elements", "dep:lightning-125"]
test-utils = []
97 changes: 0 additions & 97 deletions libs/sdk-common/mock_service_worker.js

This file was deleted.

5 changes: 2 additions & 3 deletions libs/sdk-common/src/dns_resolver/resolver_wasm.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use anyhow::{anyhow, Result};
use dns_parser::{Builder, Packet, RData, ResponseCode};
use dns_parser::{QueryClass, QueryType};

use crate::utils::rest_client;
use reqwest::Client;

pub(crate) async fn txt_lookup(dns_name: String) -> Result<Vec<String>> {
let mut builder = Builder::new_query(1, true);
builder.add_question(&dns_name, false, QueryType::TXT, QueryClass::IN);
let req_bytes = builder
.build()
.map_err(|_| anyhow!("Error building DNS query"))?;
let client = rest_client::get_reqwest_client()?;
let client = Client::builder().build()?;
let res_bytes = client
.post("https://cloudflare-dns.com/dns-query")
.body(req_bytes)
Expand Down
Loading

0 comments on commit 0017f7d

Please sign in to comment.