Skip to content

Commit 74758b9

Browse files
committed
Merge branch 'keypath-seq'
2 parents fd02ba4 + 0acf2d6 commit 74758b9

File tree

8 files changed

+292
-248
lines changed

8 files changed

+292
-248
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ hidapi = { version = "2.3", optional = true }
3535
js-sys = { version = "0.3.64", optional = true }
3636
rlp = { version = "0.5", optional = true }
3737
serde = { version = "1.0", features = ["derive"] }
38-
serde-wasm-bindgen = { version = "0.5.0", optional = true }
38+
serde-wasm-bindgen = { version = "0.6.5", optional = true }
3939
tokio = { version = "1", optional = true, features = ["time"] }
40-
wasm-bindgen = { version = "0.2.63", optional = true }
41-
wasm-bindgen-futures = { version ="0.4.37", optional = true }
40+
wasm-bindgen = { version = "0.2.92", optional = true }
41+
wasm-bindgen-futures = { version ="0.4.42", optional = true }
4242
web-sys = { version = "0.3.64", features = ["Storage", "Window"], optional = true }
4343

4444
[dev-dependencies]
45-
wasm-bindgen-test = "0.3.13"
45+
wasm-bindgen-test = "0.3.42"
4646

4747
[build-dependencies]
4848
prost-build = { version = "0.11" }

NPM_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3.2
1+
0.4.0

ci.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ cargo fmt --check
2424
for feature_set in "${features[@]}"; do
2525
echo $feature_set
2626
cargo test --locked --features="$feature_set" --all-targets
27-
cargo clippy --locked --features="$feature_set" --all-targets -- -D warnings
27+
cargo clippy --locked --features="$feature_set" --all-targets -- -D warnings -A clippy::empty-docs
2828
done
2929

3030
for example in "${examples[@]}"; do
3131
cargo test $example
32-
cargo clippy $example -- -D warnings
32+
cargo clippy $example -- -D warnings -A clippy::empty-docs
3333
done

sandbox/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/communication.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ pub enum Product {
157157
pub struct Info {
158158
pub version: semver::Version,
159159
pub product: Product,
160+
#[allow(dead_code)]
160161
pub unlocked: bool,
161162
}
162163

src/keypath.rs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,35 @@ impl<'de> serde::Deserialize<'de> for Keypath {
7878
where
7979
D: serde::Deserializer<'de>,
8080
{
81-
let s = String::deserialize(deserializer)?;
82-
s.as_str().try_into().map_err(serde::de::Error::custom)
81+
struct KeypathVisitor;
82+
83+
impl<'de> serde::de::Visitor<'de> for KeypathVisitor {
84+
type Value = Keypath;
85+
86+
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
87+
formatter.write_str("a string or a number sequence")
88+
}
89+
90+
fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
91+
where
92+
E: serde::de::Error,
93+
{
94+
value.try_into().map_err(serde::de::Error::custom)
95+
}
96+
97+
fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
98+
where
99+
A: serde::de::SeqAccess<'de>,
100+
{
101+
let mut vec = Vec::<u32>::new();
102+
while let Some(elem) = seq.next_element()? {
103+
vec.push(elem);
104+
}
105+
Ok(Keypath(vec))
106+
}
107+
}
108+
109+
deserializer.deserialize_any(KeypathVisitor)
83110
}
84111
}
85112

src/wasm/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type Product = 'unknown' | 'bitbox02-multi' | 'bitbox02-btconly';
1515
type BtcCoin = 'btc' | 'tbtc' | 'ltc' | 'tltc';
1616
type BtcFormatUnit = 'default' | 'sat';
1717
type XPubType = 'tpub' | 'xpub' | 'ypub' | 'zpub' | 'vpub' | 'upub' | 'Vpub' | 'Zpub' | 'Upub' | 'Ypub';
18-
type Keypath = string;
18+
type Keypath = string | number[];
1919
type XPub = string;
2020
type DeviceInfo = {
2121
name: string;

0 commit comments

Comments
 (0)