Skip to content

Commit

Permalink
schemas: use sat and sat_or_all again where appropiate
Browse files Browse the repository at this point in the history
Changelog-None
  • Loading branch information
daywalker90 authored and endothermicdev committed May 28, 2024
1 parent 964c073 commit 0eb65e4
Show file tree
Hide file tree
Showing 20 changed files with 79 additions and 48 deletions.
48 changes: 24 additions & 24 deletions cln-grpc/src/convert.rs

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

4 changes: 4 additions & 0 deletions contrib/msggen/msggen/gen/grpc/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ def generate_composite(self, prefix, field: CompositeField, override=None):
"u16?": f"c.{name}.map(|v| v.into())",
"msat": f"Some(c.{name}.into())",
"msat?": f"c.{name}.map(|f| f.into())",
"sat": f"Some(c.{name}.into())",
"sat?": f"c.{name}.map(|f| f.into())",
"pubkey": f"c.{name}.serialize().to_vec()",
"pubkey?": f"c.{name}.map(|v| v.serialize().to_vec())",
"hex": f"hex::decode(&c.{name}).unwrap()",
Expand All @@ -115,6 +117,8 @@ def generate_composite(self, prefix, field: CompositeField, override=None):
"msat_or_any": f"Some(c.{name}.into())",
"msat_or_all": f"Some(c.{name}.into())",
"msat_or_all?": f"c.{name}.map(|o|o.into())",
"sat_or_all": f"Some(c.{name}.into())",
"sat_or_all?": f"c.{name}.map(|o|o.into())",
"feerate?": f"c.{name}.map(|o|o.into())",
"feerate": f"Some(c.{name}.into())",
"outpoint?": f"c.{name}.map(|o|o.into())",
Expand Down
4 changes: 4 additions & 0 deletions contrib/msggen/msggen/gen/grpc/unconvert.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ def generate_composite(self, prefix, field: CompositeField, override=None) -> No
"msat_or_all?": f"c.{name}.map(|a| a.into())",
"msat_or_any": f"c.{name}.unwrap().into()",
"msat_or_any?": f"c.{name}.map(|a| a.into())",
"sat": f"c.{name}.unwrap().into()",
"sat?": f"c.{name}.map(|a| a.into())",
"sat_or_all": f"c.{name}.unwrap().into()",
"sat_or_all?": f"c.{name}.map(|a| a.into())",
"feerate": f"c.{name}.unwrap().into()",
"feerate?": f"c.{name}.map(|a| a.into())",
"outpoint?": f"c.{name}.map(|a| a.into())",
Expand Down
2 changes: 2 additions & 0 deletions contrib/msggen/msggen/gen/grpc/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"msat": "Amount",
"msat_or_all": "AmountOrAll",
"msat_or_any": "AmountOrAny",
"sat": "Amount",
"sat_or_all": "AmountOrAll",
"currency": "string",
"number": "double",
"pubkey": "bytes",
Expand Down
5 changes: 5 additions & 0 deletions contrib/msggen/msggen/gen/grpc2py.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def __init__(self, dest: TextIO):
"boolean": "m.{name}",
"short_channel_id": "m.{name}",
"msat": "amount2msat(m.{name})",
"sat": "amount2sat(m.{name})",
"currency": "m.{name}",
"number": "m.{name}",
}
Expand Down Expand Up @@ -87,6 +88,10 @@ def amount2msat(a):
return a.msat
def amount2sat(a):
return a.msat / 1000
def remove_default(d):
# grpc is really not good at empty values, they get replaced with the type's default value...
return {k: v for k, v in d.items() if v is not None and v != ""}
Expand Down
2 changes: 2 additions & 0 deletions contrib/msggen/msggen/gen/rpc/rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"msat": "Amount",
"msat_or_all": "AmountOrAll",
"msat_or_any": "AmountOrAny",
"sat": "Amount",
"sat_or_all": "AmountOrAll",
"currency": "String",
"number": "f64",
"pubkey": "PublicKey",
Expand Down
2 changes: 2 additions & 0 deletions contrib/msggen/msggen/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,8 @@ class PrimitiveField(Field):
"msat",
"msat_or_any",
"msat_or_all",
"sat",
"sat_or_all",
"currency",
"hex",
"short_channel_id",
Expand Down
Loading

0 comments on commit 0eb65e4

Please sign in to comment.