Skip to content

Commit

Permalink
Forgot to git add
Browse files Browse the repository at this point in the history
  • Loading branch information
jklein24 committed May 11, 2024
1 parent 93359ab commit 4e47bba
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lightspark/objects/FailHtlcsInput.py
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"],
)
35 changes: 35 additions & 0 deletions lightspark/objects/FailHtlcsOutput.py
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 lightspark/objects/WithdrawalRequestToWithdrawalsConnection.py
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"],
)
),
)
11 changes: 11 additions & 0 deletions lightspark/scripts/fail_htlcs.py
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"""

Check warning on line 3 in lightspark/scripts/fail_htlcs.py

View workflow job for this annotation

GitHub Actions / sdk-test (3.10)

W1309 f-string-without-interpolation

Using an f-string that does not have any interpolated variables
mutation FailHtlcs($invoice_id: ID!, $cancel_invoice: Boolean!) {{
fail_htlcs(input: {{ invoice_id: $invoice_id, cancel_invoice: $cancel_invoice }}) {{
invoice {{
id
}}
}}
}}
"""
21 changes: 21 additions & 0 deletions lightspark/scripts/outgoing_payments_for_payment_hash.py
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}
"""

0 comments on commit 4e47bba

Please sign in to comment.