Skip to content

Commit

Permalink
Add get_payment docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dangeross committed Oct 14, 2024
1 parent f8198f9 commit 9556419
Show file tree
Hide file tree
Showing 22 changed files with 391 additions and 30 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ on:
workflow_dispatch:
inputs:
sdk-ref:
description: 'sdk commit/tag/branch reference. Defaults to 0.3.4'
description: 'sdk commit/tag/branch reference. Defaults to 0.4.0-rc3'
required: false
type: string
default: 0.3.4
default: 0.4.0-rc3

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand All @@ -26,9 +26,9 @@ jobs:
runs-on: ubuntu-latest
outputs:
# Used only for Rust snippets
sdk-ref: ${{ inputs.sdk-ref || '0.3.4' }}
sdk-ref: ${{ inputs.sdk-ref || '0.4.0-rc3' }}
# Used for RN and Flutter snippets
package-version: '0.3.4'
package-version: '0.4.0-rc3'
steps:
- run: echo "set pre-setup output variables"

Expand Down
2 changes: 1 addition & 1 deletion examples/python/cli/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ readme = "README.md"

[tool.poetry.dependencies]
python = "^3.8.1"
breez-sdk-liquid = "^0.3.4"
breez-sdk-liquid = "^0.4.0-rc3"
argparse = "^1.4.0"
qrcode = "^7.4.2"
colorama = "^0.4.6"
Expand Down
17 changes: 17 additions & 0 deletions snippets/csharp/ListPayments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

public class ListPaymentsSnippets
{
public void GetPayment(BindingLiquidSdk sdk)
{
// ANCHOR: get-payment
try
{
var paymentHash = "<payment hash>";
var payment = sdk.GetPayment(
new GetPaymentRequest.Lightning(paymentHash)
);
}
catch (Exception)
{
// Handle error
}
// ANCHOR_END: get-payment
}

public void ListPayments(BindingLiquidSdk sdk)
{
// ANCHOR: list-payments
Expand Down
9 changes: 9 additions & 0 deletions snippets/dart_snippets/lib/list_payments.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import 'package:dart_snippets/sdk_instance.dart';
import 'package:flutter_breez_liquid/flutter_breez_liquid.dart';

Future<Payment?> getPayment() async {
// ANCHOR: get-payment
String paymentHash = "<payment hash>";
GetPaymentRequest req = GetPaymentRequest.lightning(paymentHash: paymentHash);
Payment? payment = await breezSDKLiquid.instance!.getPayment(req: req);
// ANCHOR_END: get-payment
return payment;
}

Future<List<Payment>> listPayments() async {
// ANCHOR: list-payments
ListPaymentsRequest req = ListPaymentsRequest();
Expand Down
8 changes: 4 additions & 4 deletions snippets/dart_snippets/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ packages:
description:
path: "."
ref: HEAD
resolved-ref: fe172bab450a18f166c533e28868a3d68180ca41
resolved-ref: 399a455a3618de58c97dc25380a5166239835b52
url: "https://github.com/breez/breez-sdk-liquid-dart"
source: git
version: "0.3.4"
version: "0.4.0-rc3"
build_cli_annotations:
dependency: transitive
description:
Expand Down Expand Up @@ -140,10 +140,10 @@ packages:
description:
path: "."
ref: HEAD
resolved-ref: bf303dff81a6915249712761b768d58337e3e833
resolved-ref: 7659a0ca7405247c2dbbcd94ac6aec62ddf60570
url: "https://github.com/breez/breez-sdk-liquid-flutter"
source: git
version: "0.3.4"
version: "0.4.0-rc3"
flutter_rust_bridge:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions snippets/dart_snippets/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ dependencies:
breez_liquid:
git:
url: https://github.com/breez/breez-sdk-liquid-dart
tag: 0.3.4
tag: 0.4.0-rc3
flutter_breez_liquid:
git:
url: https://github.com/breez/breez-sdk-liquid-flutter
tag: 0.3.4
tag: 0.4.0-rc3
rxdart: ^0.28.0

dependency_overrides:
Expand Down
2 changes: 1 addition & 1 deletion snippets/go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ module main

go 1.19

require github.com/breez/breez-sdk-liquid-go v0.3.4
require github.com/breez/breez-sdk-liquid-go v0.4.0-rc3

//replace github.com/breez/breez-sdk-liquid-go => ./packages/breez-sdk-liquid-go
12 changes: 12 additions & 0 deletions snippets/go/list_payments.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ import (
"github.com/breez/breez-sdk-liquid-go/breez_sdk_liquid"
)

func GetPayment(sdk *breez_sdk_liquid.BindingLiquidSdk) {
// ANCHOR: get-payment
paymentHash := "<payment hash>"
req := breez_sdk.GetPaymentRequestLightning{
PaymentHash: paymentHash
}
if payment, err := sdk.GetPayment(req); err == nil {
log.Printf("%#v", payment)
}
// ANCHOR_END: get-payment
}

func ListPayments(sdk *breez_sdk_liquid.BindingLiquidSdk) {
// ANCHOR: list-payments
if payments, err := sdk.ListPayments(breez_sdk_liquid.ListPaymentsRequest{}); err == nil {
Expand Down
2 changes: 1 addition & 1 deletion snippets/kotlin_mpp_lib/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ kotlin {
}
val commonMain by getting {
dependencies {
implementation("technology.breez.liquid:breez-sdk-liquid-kmp:0.3.4")
implementation("technology.breez.liquid:breez-sdk-liquid-kmp:0.4.0-rc3")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ package com.example.kotlinmpplib

import breez_sdk_liquid.*
class ListPayments {
fun getPayment(sdk: BindingLiquidSdk) {
// ANCHOR: get-payment
try {
val paymentHash = "<payment hash>";
val payment = sdk.getPayment(GetPaymentRequest.Lightning(paymentHash))
} catch (e: Exception) {
// handle error
}
// ANCHOR_END: get-payment
}

fun listPayments(sdk: BindingLiquidSdk) {
// ANCHOR: list-payments
try {
Expand Down
12 changes: 11 additions & 1 deletion snippets/python/src/list_payments.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
from breez_sdk_liquid import BindingLiquidSdk, ListPaymentsRequest, PaymentType
from breez_sdk_liquid import BindingLiquidSdk, GetPaymentRequest, ListPaymentsRequest, PaymentType
import logging


def get_payment(sdk: BindingLiquidSdk):
try:
# ANCHOR: get-payment
payment_hash = "<payment hash>"
sdk.get_payment(GetPaymentRequest.LIGHTNING(payment_hash))
# ANCHOR_END: get-payment
except Exception as error:
logging.error(error)
raise

def list_payments(sdk: BindingLiquidSdk):
try:
# ANCHOR: list-payments
Expand Down
12 changes: 12 additions & 0 deletions snippets/react-native/list_payments.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
import {
getPayment,
GetPaymentRequestVariant,
listPayments,
PaymentType
} from '@breeztech/react-native-breez-sdk-liquid'

const exampleGetPayment = async () => {
// ANCHOR: get-payment
const paymentHash = '<payment hash>'
const payment = await getPayment({
type: GetPaymentRequestVariant.LIGHTNING,
paymentHash
})
// ANCHOR_END: get-payment
}

const exampleListPayments = async () => {
// ANCHOR: list-payments
const payments = await listPayments({})
Expand Down
2 changes: 1 addition & 1 deletion snippets/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"compile": "tsc"
},
"dependencies": {
"@breeztech/react-native-breez-sdk-liquid": "^0.3.4",
"@breeztech/react-native-breez-sdk-liquid": "^0.4.0-rc3",
"react": "18.1.0",
"react-native": "0.70.6"
},
Expand Down
8 changes: 4 additions & 4 deletions snippets/react-native/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -703,10 +703,10 @@
"@babel/helper-validator-identifier" "^7.24.7"
to-fast-properties "^2.0.0"

"@breeztech/react-native-breez-sdk-liquid@^0.3.4":
version "0.3.4"
resolved "https://registry.yarnpkg.com/@breeztech/react-native-breez-sdk-liquid/-/react-native-breez-sdk-liquid-0.3.4.tgz#2519e19e4268850d15b72ea29cfb6e145261b321"
integrity sha512-c0L3n9suD1Y2poIfOyjSlWzCfNxy42TsZcAkvfG5uOEoAIZccTwPGHwHla+x/vZFugQ7QTBC+AGrJtTQKUZ+aQ==
"@breeztech/react-native-breez-sdk-liquid@^0.4.0-rc3":
version "0.4.0-rc3"
resolved "https://registry.yarnpkg.com/@breeztech/react-native-breez-sdk-liquid/-/react-native-breez-sdk-liquid-0.4.0-rc3.tgz#9a99abcc792e54302e54ebdddc4d72a9173ebeaa"
integrity sha512-3uMMz6BfYmx4KDs+YU+OwAYIJQTfJbtRzEHpa3PE7j4QBtfpffTp2MqN/HxkKqhw/98u/kfDdbklO5PmF+BrFg==

"@esbuild/[email protected]":
version "0.18.20"
Expand Down
Loading

0 comments on commit 9556419

Please sign in to comment.