Skip to content

Commit

Permalink
Merge branch 'master' into v2
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Jul 21, 2023
2 parents aaec4fc + ab801c7 commit c1cd055
Show file tree
Hide file tree
Showing 12 changed files with 284 additions and 314 deletions.
364 changes: 190 additions & 174 deletions Cargo.lock

Large diffs are not rendered by default.

16 changes: 6 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ path = "src/bin/mcw.rs"
required-features = ["cli"]

[dependencies]
gtk = "0.15.5"
relm = "0.23.0"
relm-derive = "0.23.0"
gladis = "2.1.2"
gtk = "0.16.2"
relm = "0.24.1"
relm-derive = "0.24.0"
glade = "2.2.0"
once_cell = "1.10.0"
chrono = "0.4.19"
urlencoding = "2.1.0"
Expand All @@ -45,7 +45,7 @@ rgb-contracts = { version = "0.10.0-beta.2", features = ["electrum"] }
bitcoin_scripts = "0.10.0"
bitcoin_blockchain = "0.10.0"
descriptor-wallet = { version = "0.10.0", features = ["miniscript", "keygen", "hwi", "construct"] }
bpro = { version = "0.4.0", features = ["electrum"] }
bpro = { version = "0.5.0", features = ["electrum"] }
hwi = "0.6.0"
electrum-client = "0.14.0"

Expand All @@ -67,8 +67,4 @@ serde = ["serde_with", "serde_yaml",
"amplify/serde", "chrono/serde", "bitcoin/serde", "miniscript/serde", "descriptor-wallet/serde"]

[patch.crates-io]
rgb-core = { git = "https://github.com/RGB-WG/rgb-core" }
rgb-std = { git = "https://github.com/RGB-WG/rgb-wallet" }
rgb-wallet = { git = "https://github.com/RGB-WG/rgb-wallet" }
rgb-contracts = { git = "https://github.com/RGB-WG/rgb" }
bpro = { git = "https://github.com/pandora-prime/bpro" }
bpro = { git = "https://github.com/pandora-prime/bpro", branch = "v0.5" }
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ extern crate relm_derive;
#[cfg(feature = "serde")]
extern crate serde_crate as serde;

extern crate glade as gladis;

pub mod model;
#[cfg(feature = "ui")]
pub mod view;
Expand Down
19 changes: 6 additions & 13 deletions src/view/devices/device_row/view_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,7 @@ impl ObjectImpl for DeviceDataInner {
PROPERTIES.as_ref()
}

fn set_property(
&self,
_obj: &Self::Type,
_id: usize,
value: &glib::Value,
pspec: &glib::ParamSpec,
) {
fn set_property(&self, _id: usize, value: &glib::Value, pspec: &glib::ParamSpec) {
match pspec.name() {
"name" => {
let name = value
Expand Down Expand Up @@ -160,7 +154,7 @@ impl ObjectImpl for DeviceDataInner {
}
}

fn property(&self, _obj: &Self::Type, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
fn property(&self, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
match pspec.name() {
"name" => self.name.borrow().to_value(),
"fingerprint" => self.fingerprint.borrow().to_value(),
Expand Down Expand Up @@ -189,7 +183,6 @@ impl DeviceData {
("xpub", &xpub.to_string()),
("account", &account),
])
.expect("Failed to create row data")
}

pub fn fingerprint(&self) -> Fingerprint {
Expand All @@ -213,9 +206,9 @@ impl ObjectSubclass for DeviceModelInner {
impl ObjectImpl for DeviceModelInner {}

impl ListModelImpl for DeviceModelInner {
fn item_type(&self, _list_model: &Self::Type) -> glib::Type { DeviceData::static_type() }
fn n_items(&self, _list_model: &Self::Type) -> u32 { self.0.borrow().len() as u32 }
fn item(&self, _list_model: &Self::Type, position: u32) -> Option<glib::Object> {
fn item_type(&self) -> glib::Type { DeviceData::static_type() }
fn n_items(&self) -> u32 { self.0.borrow().len() as u32 }
fn item(&self, position: u32) -> Option<glib::Object> {
self.0
.borrow()
.get(position as usize)
Expand All @@ -230,7 +223,7 @@ glib::wrapper! {

impl DeviceModel {
#[allow(clippy::new_without_default)]
pub fn new() -> DeviceModel { glib::Object::new(&[]).expect("Failed to create DeviceModel") }
pub fn new() -> DeviceModel { glib::Object::new(&[]) }

pub fn refresh(&self, devices: &HardwareList) {
self.clear();
Expand Down
19 changes: 6 additions & 13 deletions src/view/psbt/sign_row/view_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,7 @@ impl ObjectImpl for SigningInner {
PROPERTIES.as_ref()
}

fn set_property(
&self,
_obj: &Self::Type,
_id: usize,
value: &glib::Value,
pspec: &glib::ParamSpec,
) {
fn set_property(&self, _id: usize, value: &glib::Value, pspec: &glib::ParamSpec) {
match pspec.name() {
"name" => {
let value = value
Expand Down Expand Up @@ -149,7 +143,7 @@ impl ObjectImpl for SigningInner {
}
}

fn property(&self, _obj: &Self::Type, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
fn property(&self, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
match pspec.name() {
"name" => self.name.borrow().to_value(),
"master-fp" => self.master_fp.borrow().to_value(),
Expand Down Expand Up @@ -188,7 +182,6 @@ impl Signing {
("sigs-required", &sigs_required),
("signable", &(sigs_present < sigs_required)),
])
.expect("Failed to create row data")
}

pub fn master_fp(&self) -> Fingerprint {
Expand All @@ -214,9 +207,9 @@ impl ObjectSubclass for SigningModelInner {
impl ObjectImpl for SigningModelInner {}

impl ListModelImpl for SigningModelInner {
fn item_type(&self, _list_model: &Self::Type) -> glib::Type { Signing::static_type() }
fn n_items(&self, _list_model: &Self::Type) -> u32 { self.0.borrow().len() as u32 }
fn item(&self, _list_model: &Self::Type, position: u32) -> Option<glib::Object> {
fn item_type(&self) -> glib::Type { Signing::static_type() }
fn n_items(&self) -> u32 { self.0.borrow().len() as u32 }
fn item(&self, position: u32) -> Option<glib::Object> {
self.0
.borrow()
.get(position as usize)
Expand All @@ -234,7 +227,7 @@ impl Default for SigningModel {
}

impl SigningModel {
pub fn new() -> SigningModel { glib::Object::new(&[]).expect("Failed to create SigningModel") }
pub fn new() -> SigningModel { glib::Object::new(&[]) }

pub fn append(&self, obj: &Signing) {
let imp = self.imp();
Expand Down
5 changes: 1 addition & 4 deletions src/view/psbt/sign_row/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ impl RowWidgets {
.build();
signing
.bind_property("master-fp", &self.fingerprint_lbl, "label")
.transform_to(|_, value| {
let s: String = value.clone().get().expect("non-string fingerprint");
Some(format!("[{}]", s).to_value())
})
.transform_to(|_, s: String| Some(format!("[{}]", s).to_value()))
.flags(flags_ro)
.build();
signing
Expand Down
22 changes: 7 additions & 15 deletions src/view/settings/spending_row/view_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,7 @@ impl ObjectImpl for ConditionInner {
PROPERTIES.as_ref()
}

fn set_property(
&self,
_obj: &Self::Type,
_id: usize,
value: &glib::Value,
pspec: &glib::ParamSpec,
) {
fn set_property(&self, _id: usize, value: &glib::Value, pspec: &glib::ParamSpec) {
match pspec.name() {
"sigs-all" => {
let value = value
Expand Down Expand Up @@ -329,7 +323,7 @@ impl ObjectImpl for ConditionInner {
}
}

fn property(&self, _obj: &Self::Type, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
fn property(&self, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
match pspec.name() {
"sigs-all" => self.sigs_all.borrow().to_value(),
"sigs-at-least" => self.sigs_at_least.borrow().to_value(),
Expand Down Expand Up @@ -374,7 +368,7 @@ glib::wrapper! {
}

impl Default for Condition {
fn default() -> Self { glib::Object::new(&[]).expect("Failed to create row data") }
fn default() -> Self { glib::Object::new(&[]) }
}

impl From<&Condition> for SpendingCondition {
Expand Down Expand Up @@ -423,9 +417,9 @@ impl ObjectSubclass for SpendingModelInner {
impl ObjectImpl for SpendingModelInner {}

impl ListModelImpl for SpendingModelInner {
fn item_type(&self, _list_model: &Self::Type) -> glib::Type { Condition::static_type() }
fn n_items(&self, _list_model: &Self::Type) -> u32 { self.conditions.borrow().len() as u32 }
fn item(&self, _list_model: &Self::Type, position: u32) -> Option<glib::Object> {
fn item_type(&self) -> glib::Type { Condition::static_type() }
fn n_items(&self) -> u32 { self.conditions.borrow().len() as u32 }
fn item(&self, position: u32) -> Option<glib::Object> {
self.conditions
.borrow()
.get(position as usize)
Expand All @@ -440,9 +434,7 @@ glib::wrapper! {

impl SpendingModel {
#[allow(clippy::new_without_default)]
pub fn new() -> SpendingModel {
glib::Object::new(&[]).expect("Failed to create SpendingModel")
}
pub fn new() -> SpendingModel { glib::Object::new(&[]) }

pub fn refresh(&self, signers: BTreeSet<Signer>) {
let imp = self.imp();
Expand Down
67 changes: 35 additions & 32 deletions src/view/settings/spending_row/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ impl RowWidgets {
condition
.bind_property("sigs-all", &self.sig_lbl, "label")
.flags(flags_ro)
.transform_to(|_, val| {
if val.get().unwrap() {
.transform_to(|_, val: bool| {
if val {
Some("All signatures".to_value())
} else {
None
Expand All @@ -183,8 +183,8 @@ impl RowWidgets {
condition
.bind_property("sigs-any", &self.sig_lbl, "label")
.flags(flags_ro)
.transform_to(|_, val| {
if val.get().unwrap() {
.transform_to(|_, val: bool| {
if val {
Some("Any signature".to_value())
} else {
None
Expand All @@ -194,8 +194,8 @@ impl RowWidgets {
condition
.bind_property("sigs-at-least", &self.sig_lbl, "label")
.flags(flags_ro)
.transform_to(|_, val| {
if val.get().unwrap() {
.transform_to(|_, val: bool| {
if val {
Some("At least".to_value())
} else {
None
Expand Down Expand Up @@ -251,8 +251,8 @@ impl RowWidgets {
condition
.bind_property("lock-none", &self.lock_lbl, "label")
.flags(flags_ro)
.transform_to(|_, val| {
if val.get().unwrap() {
.transform_to(|_, val: bool| {
if val {
Some("at any time".to_value())
} else {
None
Expand All @@ -262,19 +262,21 @@ impl RowWidgets {
condition
.bind_property("lock-after", &self.lock_lbl, "label")
.flags(flags_ro)
.transform_to(|_, val| {
if val.get().unwrap() {
Some("after".to_value())
} else {
None
}
})
.transform_to(
|_, val: bool| {
if val {
Some("after".to_value())
} else {
None
}
},
)
.build();
condition
.bind_property("lock-older", &self.lock_lbl, "label")
.flags(flags_ro)
.transform_to(|_, val| {
if val.get().unwrap() {
.transform_to(|_, val: bool| {
if val {
Some("starting from".to_value())
} else {
None
Expand Down Expand Up @@ -305,8 +307,8 @@ impl RowWidgets {
condition
.bind_property("period-years", &self.period_lbl, "label")
.flags(flags_ro)
.transform_to(|_, val| {
if val.get().unwrap() {
.transform_to(|_, val: bool| {
if val {
Some("year(s)".to_value())
} else {
None
Expand All @@ -316,8 +318,8 @@ impl RowWidgets {
condition
.bind_property("period-weeks", &self.period_lbl, "label")
.flags(flags_ro)
.transform_to(|_, val| {
if val.get().unwrap() {
.transform_to(|_, val: bool| {
if val {
Some("week(s)".to_value())
} else {
None
Expand All @@ -327,8 +329,8 @@ impl RowWidgets {
condition
.bind_property("period-months", &self.period_lbl, "label")
.flags(flags_ro)
.transform_to(|_, val| {
if val.get().unwrap() {
.transform_to(|_, val: bool| {
if val {
Some("month(s)".to_value())
} else {
None
Expand All @@ -338,13 +340,15 @@ impl RowWidgets {
condition
.bind_property("period-days", &self.period_lbl, "label")
.flags(flags_ro)
.transform_to(|_, val| {
if val.get().unwrap() {
Some("day(s)".to_value())
} else {
None
}
})
.transform_to(
|_, val: bool| {
if val {
Some("day(s)".to_value())
} else {
None
}
},
)
.build();

condition
Expand All @@ -353,8 +357,7 @@ impl RowWidgets {
.build();
condition
.bind_property("after-month", &self.calendar, "month")
.transform_to(|_, value| {
let month: u32 = value.get().unwrap();
.transform_to(|_, month: u32| {
let month = month as i32 - 1;
Some(month.to_value())
})
Expand Down
13 changes: 8 additions & 5 deletions src/view/settings/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,11 +445,14 @@ impl Widgets {

pub fn update_network(&self) {
let network = self.network();
self.devices_btn.set_tooltip_text(if network.is_testnet() {
Some("Hardware signers can be only used on mainnet")
} else {
None
});
WidgetExt::set_tooltip_text(
&self.devices_btn,
if network.is_testnet() {
Some("Hardware signers can be only used on mainnet")
} else {
None
},
);
}

pub fn electrum_server(&self) -> String { self.electrum_fld.text().to_string() }
Expand Down
Loading

0 comments on commit c1cd055

Please sign in to comment.