-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved | ||
|
||
from dataclasses import dataclass | ||
from typing import Any, Mapping | ||
|
||
|
||
@dataclass | ||
class FailHtlcsInput: | ||
invoice_id: str | ||
"""The id of invoice which the pending HTLCs that need to be failed are paying for.""" | ||
|
||
cancel_invoice: bool | ||
"""Whether the invoice needs to be canceled after failing the htlcs. If yes, the invoice cannot be paid anymore.""" | ||
|
||
def to_json(self) -> Mapping[str, Any]: | ||
return { | ||
"fail_htlcs_input_invoice_id": self.invoice_id, | ||
"fail_htlcs_input_cancel_invoice": self.cancel_invoice, | ||
} | ||
|
||
|
||
def from_json(obj: Mapping[str, Any]) -> FailHtlcsInput: | ||
return FailHtlcsInput( | ||
invoice_id=obj["fail_htlcs_input_invoice_id"], | ||
cancel_invoice=obj["fail_htlcs_input_cancel_invoice"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved | ||
|
||
from dataclasses import dataclass | ||
from typing import Any, Mapping | ||
|
||
from lightspark.requests.requester import Requester | ||
|
||
|
||
@dataclass | ||
class FailHtlcsOutput: | ||
requester: Requester | ||
|
||
invoice_id: str | ||
|
||
def to_json(self) -> Mapping[str, Any]: | ||
return { | ||
"fail_htlcs_output_invoice": {"id": self.invoice_id}, | ||
} | ||
|
||
|
||
FRAGMENT = """ | ||
fragment FailHtlcsOutputFragment on FailHtlcsOutput { | ||
__typename | ||
fail_htlcs_output_invoice: invoice { | ||
id | ||
} | ||
} | ||
""" | ||
|
||
|
||
def from_json(requester: Requester, obj: Mapping[str, Any]) -> FailHtlcsOutput: | ||
return FailHtlcsOutput( | ||
requester=requester, | ||
invoice_id=obj["fail_htlcs_output_invoice"]["id"], | ||
) |
55 changes: 55 additions & 0 deletions
55
lightspark/objects/WithdrawalRequestToWithdrawalsConnection.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved | ||
|
||
from dataclasses import dataclass | ||
from typing import Any, List, Mapping | ||
|
||
from lightspark.requests.requester import Requester | ||
|
||
from .Withdrawal import Withdrawal | ||
from .Withdrawal import from_json as Withdrawal_from_json | ||
|
||
|
||
@dataclass | ||
class WithdrawalRequestToWithdrawalsConnection: | ||
requester: Requester | ||
|
||
count: int | ||
"""The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field).""" | ||
|
||
entities: List[Withdrawal] | ||
"""The withdrawals for the current page of this connection.""" | ||
|
||
def to_json(self) -> Mapping[str, Any]: | ||
return { | ||
"withdrawal_request_to_withdrawals_connection_count": self.count, | ||
"withdrawal_request_to_withdrawals_connection_entities": [ | ||
e.to_json() for e in self.entities | ||
], | ||
} | ||
|
||
|
||
FRAGMENT = """ | ||
fragment WithdrawalRequestToWithdrawalsConnectionFragment on WithdrawalRequestToWithdrawalsConnection { | ||
__typename | ||
withdrawal_request_to_withdrawals_connection_count: count | ||
withdrawal_request_to_withdrawals_connection_entities: entities { | ||
id | ||
} | ||
} | ||
""" | ||
|
||
|
||
def from_json( | ||
requester: Requester, obj: Mapping[str, Any] | ||
) -> WithdrawalRequestToWithdrawalsConnection: | ||
return WithdrawalRequestToWithdrawalsConnection( | ||
requester=requester, | ||
count=obj["withdrawal_request_to_withdrawals_connection_count"], | ||
entities=list( | ||
map( | ||
# pylint: disable=unnecessary-lambda | ||
lambda e: Withdrawal_from_json(requester, e), | ||
obj["withdrawal_request_to_withdrawals_connection_entities"], | ||
) | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved | ||
|
||
FAIL_HTLCS_MUTATION = f""" | ||
mutation FailHtlcs($invoice_id: ID!, $cancel_invoice: Boolean!) {{ | ||
fail_htlcs(input: {{ invoice_id: $invoice_id, cancel_invoice: $cancel_invoice }}) {{ | ||
invoice {{ | ||
id | ||
}} | ||
}} | ||
}} | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved | ||
|
||
from lightspark.objects.OutgoingPayment import FRAGMENT as OutgoingPaymentFragment | ||
|
||
OUTGOING_PAYMENTS_FOR_PAYMENT_HASH_QUERY = f""" | ||
query OutgoingPaymentsForPaymentHash( | ||
$payment_hash: String!, | ||
$transaction_statuses: [TransactionStatus!] = null | ||
) {{ | ||
outgoing_payments_for_payment_hash(input: {{ | ||
payment_hash: $payment_hash, | ||
statuses: $transaction_statuses | ||
}}) {{ | ||
payments {{ | ||
...OutgoingPaymentFragment | ||
}} | ||
}} | ||
}} | ||
{OutgoingPaymentFragment} | ||
""" |