Skip to content

Commit

Permalink
Chore: update dev dependencies (cashubtc#658)
Browse files Browse the repository at this point in the history
* update dev dependencies

* test

* revert tests

* fix event loop scope

* ruff format

* add old test

* remove custom event loop

* default loop scope

* skip earlier

* trigger

* trigger again
  • Loading branch information
callebtc authored Nov 1, 2024
1 parent 9262739 commit e9d4689
Show file tree
Hide file tree
Showing 11 changed files with 632 additions and 648 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
- id: mixed-line-ending
- id: check-case-conflict
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
rev: v0.7.1
hooks:
- id: ruff
args: [--fix]
Expand Down
36 changes: 14 additions & 22 deletions cashu/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ class Proof(BaseModel):
time_created: Union[None, str] = ""
time_reserved: Union[None, str] = ""
derivation_path: Union[None, str] = "" # derivation path of the proof
mint_id: Union[
None, str
] = None # holds the id of the mint operation that created this proof
melt_id: Union[
None, str
] = None # holds the id of the melt operation that destroyed this proof
mint_id: Union[None, str] = (
None # holds the id of the mint operation that created this proof
)
melt_id: Union[None, str] = (
None # holds the id of the melt operation that destroyed this proof
)

def __init__(self, **data):
super().__init__(**data)
Expand Down Expand Up @@ -825,43 +825,35 @@ def generate_keys(self):
class Token(ABC):
@property
@abstractmethod
def proofs(self) -> List[Proof]:
...
def proofs(self) -> List[Proof]: ...

@property
@abstractmethod
def amount(self) -> int:
...
def amount(self) -> int: ...

@property
@abstractmethod
def mint(self) -> str:
...
def mint(self) -> str: ...

@property
@abstractmethod
def keysets(self) -> List[str]:
...
def keysets(self) -> List[str]: ...

@property
@abstractmethod
def memo(self) -> Optional[str]:
...
def memo(self) -> Optional[str]: ...

@memo.setter
@abstractmethod
def memo(self, memo: Optional[str]):
...
def memo(self, memo: Optional[str]): ...

@property
@abstractmethod
def unit(self) -> str:
...
def unit(self) -> str: ...

@unit.setter
@abstractmethod
def unit(self, unit: str):
...
def unit(self, unit: str): ...


class TokenV3Token(BaseModel):
Expand Down
6 changes: 3 additions & 3 deletions cashu/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ class PostMeltQuoteResponse(BaseModel):
quote: str # quote id
amount: int # input amount
fee_reserve: int # input fee reserve
paid: Optional[
bool
] = None # whether the request has been paid # DEPRECATED as per NUT PR #136
paid: Optional[bool] = (
None # whether the request has been paid # DEPRECATED as per NUT PR #136
)
state: Optional[str] # state of the quote
expiry: Optional[int] # expiry of the quote
payment_preimage: Optional[str] = None # payment preimage
Expand Down
74 changes: 26 additions & 48 deletions cashu/mint/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ async def get_keyset(
derivation_path: str = "",
seed: str = "",
conn: Optional[Connection] = None,
) -> List[MintKeyset]:
...
) -> List[MintKeyset]: ...

@abstractmethod
async def get_proofs_used(
Expand All @@ -42,8 +41,7 @@ async def get_proofs_used(
Ys: List[str],
db: Database,
conn: Optional[Connection] = None,
) -> List[Proof]:
...
) -> List[Proof]: ...

@abstractmethod
async def invalidate_proof(
Expand All @@ -53,17 +51,15 @@ async def invalidate_proof(
proof: Proof,
quote_id: Optional[str] = None,
conn: Optional[Connection] = None,
) -> None:
...
) -> None: ...

@abstractmethod
async def get_all_melt_quotes_from_pending_proofs(
self,
*,
db: Database,
conn: Optional[Connection] = None,
) -> List[MeltQuote]:
...
) -> List[MeltQuote]: ...

@abstractmethod
async def get_pending_proofs_for_quote(
Expand All @@ -72,8 +68,7 @@ async def get_pending_proofs_for_quote(
quote_id: str,
db: Database,
conn: Optional[Connection] = None,
) -> List[Proof]:
...
) -> List[Proof]: ...

@abstractmethod
async def get_proofs_pending(
Expand All @@ -82,8 +77,7 @@ async def get_proofs_pending(
Ys: List[str],
db: Database,
conn: Optional[Connection] = None,
) -> List[Proof]:
...
) -> List[Proof]: ...

@abstractmethod
async def set_proof_pending(
Expand All @@ -93,8 +87,7 @@ async def set_proof_pending(
proof: Proof,
quote_id: Optional[str] = None,
conn: Optional[Connection] = None,
) -> None:
...
) -> None: ...

@abstractmethod
async def unset_proof_pending(
Expand All @@ -103,8 +96,7 @@ async def unset_proof_pending(
proof: Proof,
db: Database,
conn: Optional[Connection] = None,
) -> None:
...
) -> None: ...

@abstractmethod
async def store_keyset(
Expand All @@ -113,8 +105,7 @@ async def store_keyset(
db: Database,
keyset: MintKeyset,
conn: Optional[Connection] = None,
) -> None:
...
) -> None: ...

@abstractmethod
async def update_keyset(
Expand All @@ -123,16 +114,14 @@ async def update_keyset(
db: Database,
keyset: MintKeyset,
conn: Optional[Connection] = None,
) -> None:
...
) -> None: ...

@abstractmethod
async def get_balance(
self,
db: Database,
conn: Optional[Connection] = None,
) -> int:
...
) -> int: ...

@abstractmethod
async def store_promise(
Expand All @@ -146,8 +135,7 @@ async def store_promise(
e: str = "",
s: str = "",
conn: Optional[Connection] = None,
) -> None:
...
) -> None: ...

@abstractmethod
async def get_promise(
Expand All @@ -156,8 +144,7 @@ async def get_promise(
db: Database,
b_: str,
conn: Optional[Connection] = None,
) -> Optional[BlindedSignature]:
...
) -> Optional[BlindedSignature]: ...

@abstractmethod
async def get_promises(
Expand All @@ -166,8 +153,7 @@ async def get_promises(
db: Database,
b_s: List[str],
conn: Optional[Connection] = None,
) -> List[BlindedSignature]:
...
) -> List[BlindedSignature]: ...

@abstractmethod
async def store_mint_quote(
Expand All @@ -176,8 +162,7 @@ async def store_mint_quote(
quote: MintQuote,
db: Database,
conn: Optional[Connection] = None,
) -> None:
...
) -> None: ...

@abstractmethod
async def get_mint_quote(
Expand All @@ -188,8 +173,7 @@ async def get_mint_quote(
request: Optional[str] = None,
db: Database,
conn: Optional[Connection] = None,
) -> Optional[MintQuote]:
...
) -> Optional[MintQuote]: ...

@abstractmethod
async def get_mint_quote_by_request(
Expand All @@ -198,8 +182,7 @@ async def get_mint_quote_by_request(
request: str,
db: Database,
conn: Optional[Connection] = None,
) -> Optional[MintQuote]:
...
) -> Optional[MintQuote]: ...

@abstractmethod
async def update_mint_quote(
Expand All @@ -208,8 +191,7 @@ async def update_mint_quote(
quote: MintQuote,
db: Database,
conn: Optional[Connection] = None,
) -> None:
...
) -> None: ...

@abstractmethod
async def store_melt_quote(
Expand All @@ -218,8 +200,7 @@ async def store_melt_quote(
quote: MeltQuote,
db: Database,
conn: Optional[Connection] = None,
) -> None:
...
) -> None: ...

@abstractmethod
async def get_melt_quote(
Expand All @@ -230,8 +211,7 @@ async def get_melt_quote(
request: Optional[str] = None,
db: Database,
conn: Optional[Connection] = None,
) -> Optional[MeltQuote]:
...
) -> Optional[MeltQuote]: ...

@abstractmethod
async def get_melt_quote_by_request(
Expand All @@ -240,8 +220,7 @@ async def get_melt_quote_by_request(
request: str,
db: Database,
conn: Optional[Connection] = None,
) -> Optional[MeltQuote]:
...
) -> Optional[MeltQuote]: ...

@abstractmethod
async def update_melt_quote(
Expand All @@ -250,8 +229,7 @@ async def update_melt_quote(
quote: MeltQuote,
db: Database,
conn: Optional[Connection] = None,
) -> None:
...
) -> None: ...


class LedgerCrudSqlite(LedgerCrud):
Expand Down Expand Up @@ -359,7 +337,7 @@ async def get_all_melt_quotes_from_pending_proofs(
SELECT * from {db.table_with_schema('melt_quotes')} WHERE quote in (SELECT DISTINCT melt_quote FROM {db.table_with_schema('proofs_pending')})
"""
)
return [MeltQuote.from_row(r) for r in rows]
return [MeltQuote.from_row(r) for r in rows] # type: ignore

async def get_pending_proofs_for_quote(
self,
Expand Down Expand Up @@ -601,7 +579,7 @@ async def get_melt_quote(
""",
values,
)
return MeltQuote.from_row(row) if row else None
return MeltQuote.from_row(row) if row else None # type: ignore

async def get_melt_quote_by_request(
self,
Expand All @@ -617,7 +595,7 @@ async def get_melt_quote_by_request(
""",
{"request": request},
)
return MeltQuote.from_row(row) if row else None
return MeltQuote.from_row(row) if row else None # type: ignore

async def update_melt_quote(
self,
Expand Down Expand Up @@ -685,7 +663,7 @@ async def get_balance(
db: Database,
conn: Optional[Connection] = None,
) -> int:
row: List = await (conn or db).fetchone(
row = await (conn or db).fetchone(
f"""
SELECT * from {db.table_with_schema('balance')}
"""
Expand Down
1 change: 0 additions & 1 deletion cashu/nostr/bech32.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

"""Reference implementation for Bech32/Bech32m and segwit addresses."""


from enum import Enum


Expand Down
22 changes: 12 additions & 10 deletions cashu/nostr/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def __init__(self, private_key: str = "", relays: List[str] = [], connect=True):
def connect(self):
for relay in self.relays:
self.relay_manager.add_relay(relay)
self.relay_manager.open_connections({
"cert_reqs": ssl.CERT_NONE
}) # NOTE: This disables ssl certificate verification
self.relay_manager.open_connections(
{"cert_reqs": ssl.CERT_NONE}
) # NOTE: This disables ssl certificate verification

def close(self):
self.relay_manager.close_connections()
Expand Down Expand Up @@ -105,13 +105,15 @@ def dm(self, message: str, to_pubkey: PublicKey):
self.relay_manager.publish_event(dm)

def get_dm(self, sender_publickey: PublicKey, callback_func=None, filter_kwargs={}):
filters = Filters([
Filter(
kinds=[EventKind.ENCRYPTED_DIRECT_MESSAGE],
pubkey_refs=[sender_publickey.hex()],
**filter_kwargs,
)
])
filters = Filters(
[
Filter(
kinds=[EventKind.ENCRYPTED_DIRECT_MESSAGE],
pubkey_refs=[sender_publickey.hex()],
**filter_kwargs,
)
]
)
subscription_id = os.urandom(4).hex()
self.relay_manager.add_subscription(subscription_id, filters)

Expand Down
Loading

0 comments on commit e9d4689

Please sign in to comment.