Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.5.0 docs #165

Merged
merged 16 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ jobs:
name: setup
runs-on: ubuntu-latest
outputs:
sdk-ref: ${{ inputs.sdk-ref || '0.4.0' }}
package-version: '0.4.0'
sdk-ref: ${{ inputs.sdk-ref || '83740c3595ac16b29896c76a2e8790fba0535ab3' }}
package-version: '0.5.0'
steps:
- run: echo "set pre-setup output variables"

Expand All @@ -47,7 +47,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

# Set up Rust environment and run checks
- name: Install rust
Expand All @@ -66,7 +66,7 @@ jobs:
workspaces: snippets/rust -> snippets/rust/target

- name: temporarily get sdk
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: breez/breez-sdk
ref: ${{ needs.setup.outputs.sdk-ref }}
Expand Down Expand Up @@ -100,15 +100,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

# Set up the flutter environment and run checks
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: breez-sdk-flutter-${{ needs.setup.outputs.package-version }}
path: snippets/dart_snippets/packages/breez-sdk-flutter
Expand All @@ -129,15 +129,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup dotnet
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: '7.0.x'

- name: Download archived package
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: Breez.Sdk.${{ needs.setup.outputs.package-version }}.nupkg
path: .
Expand Down Expand Up @@ -165,15 +165,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set Node.js 20.x
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Download archived package
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: react-native-${{ needs.setup.outputs.package-version }}
path: snippets/react-native/packages
Expand All @@ -198,14 +198,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: '1.21'

- name: Download archived package
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: breez-sdk-go-${{ needs.setup.outputs.package-version }}
path: snippets/go/packages/breez-sdk-go
Expand Down Expand Up @@ -243,12 +243,12 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.8'

- name: Download archived package
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: python-wheel-3.8-manylinux_2_31_x86_64
path: snippets/python/packages
Expand Down Expand Up @@ -293,10 +293,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Java 17
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: 17
Expand All @@ -312,7 +312,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install rust
run: |
Expand All @@ -334,7 +334,7 @@ jobs:
run: mdbook build

- name: Archive book
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: book
path: book
Expand Down
6 changes: 3 additions & 3 deletions snippets/csharp/Production.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ public NodeConfig ProductionNodeConfig() {
// ANCHOR: moving-to-production
// Read in your Greenlight credentials from the file
// system, environment variable or build config
var deviceKey = new List<byte>();
var deviceCert = new List<byte>();
var greenlightCredentials = new GreenlightCredentials(deviceKey, deviceCert);
var developerKey = new List<byte>();
var developerCert = new List<byte>();
var greenlightCredentials = new GreenlightCredentials(developerKey, developerCert);

var nodeConfig = new NodeConfig.Greenlight(
new GreenlightNodeConfig(greenlightCredentials, null)
Expand Down
14 changes: 7 additions & 7 deletions snippets/csharp/Webhook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@

public class ServiceStatusSnippets
{
public void Webhook(BlockingBreezServices sdk)
public void RegisterWebhook(BlockingBreezServices sdk)
{
// ANCHOR: register-webook
try
{
sdk.RegisterWebhook("https://yourapplication.com");
sdk.RegisterWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>");
}
catch (Exception)
{
// Handle error
}
// ANCHOR_END: register-webook
}

public void PaymentWebhook(BlockingBreezServices sdk)
public void UnregisterWebhook(BlockingBreezServices sdk)
{
// ANCHOR: register-payment-webook
// ANCHOR: unregister-webook
try
{
sdk.RegisterWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>");
sdk.UnregisterWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>");
}
catch (Exception)
{
// Handle error
}
// ANCHOR_END: register-payment-webook
// ANCHOR_END: unregister-webook
}
}
4 changes: 2 additions & 2 deletions snippets/dart_snippets/bin/dart_snippets.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:breez_sdk/breez_sdk.dart';
import 'package:dart_snippets/sdk_instance.dart';

void main(List<String> arguments) {
BreezSDK().initialize();
breezSDK.initialize();
}
4 changes: 2 additions & 2 deletions snippets/dart_snippets/lib/buy_btc.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'package:breez_sdk/breez_sdk.dart';
import 'package:breez_sdk/bridge_generated.dart';
import 'package:dart_snippets/sdk_instance.dart';

Future<BuyBitcoinResponse> buyBitcoin() async {
// ANCHOR: buy-btc
BuyBitcoinRequest req = const BuyBitcoinRequest(provider: BuyBitcoinProvider.Moonpay);
BuyBitcoinResponse resp = await BreezSDK().buyBitcoin(req: req);
BuyBitcoinResponse resp = await breezSDK.buyBitcoin(req: req);
// ANCHOR_END: buy-btc
return resp;
}
6 changes: 3 additions & 3 deletions snippets/dart_snippets/lib/closed_channel.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:breez_sdk/breez_sdk.dart';
import 'package:dart_snippets/sdk_instance.dart';
import 'package:breez_sdk/bridge_generated.dart';

Future<PrepareRedeemOnchainFundsResponse> prepareRedeemOnchainFunds(
Expand All @@ -8,7 +8,7 @@ Future<PrepareRedeemOnchainFundsResponse> prepareRedeemOnchainFunds(
toAddress: "bc1..",
satPerVbyte: satPerVbyte,
);
final resp = await BreezSDK().prepareRedeemOnchainFunds(req: req);
final resp = await breezSDK.prepareRedeemOnchainFunds(req: req);
// ANCHOR_END: prepare-redeem-onchain-funds
return resp;
}
Expand All @@ -20,7 +20,7 @@ Future<RedeemOnchainFundsResponse> redeemOnchainFunds(
toAddress: "bc1..",
satPerVbyte: satPerVbyte,
);
final resp = await BreezSDK().redeemOnchainFunds(req: req);
final resp = await breezSDK.redeemOnchainFunds(req: req);
// ANCHOR_END: redeem-onchain-funds
return resp;
}
10 changes: 5 additions & 5 deletions snippets/dart_snippets/lib/communicating_fees.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import 'package:breez_sdk/breez_sdk.dart';
import 'package:dart_snippets/sdk_instance.dart';
import 'package:breez_sdk/bridge_generated.dart';

Future<void> getFeeInfoBeforeInvoiceCreated() async {
// ANCHOR: get-fee-info-before-receiving-payment
NodeState? nodeInfo = await BreezSDK().nodeInfo();
NodeState? nodeInfo = await breezSDK.nodeInfo();
if (nodeInfo != null) {
int inboundLiquiditySat = nodeInfo.inboundLiquidityMsats ~/ 1000;

OpenChannelFeeResponse openingFeeResponse = await BreezSDK().openChannelFee(req: OpenChannelFeeRequest());
OpenChannelFeeResponse openingFeeResponse = await breezSDK.openChannelFee(req: OpenChannelFeeRequest());

OpeningFeeParams openingFees = openingFeeResponse.feeParams;
double feePercentage = (openingFees.proportional * 100) / 1000000;
Expand All @@ -31,12 +31,12 @@ Future<void> getFeeInfoAfterInvoiceCreated({required ReceivePaymentResponse rece

Future<void> getFeeInfoReceiveOnchain() async {
// ANCHOR: get-fee-info-receive-onchain
SwapInfo swapInfo = await BreezSDK().receiveOnchain(req: ReceiveOnchainRequest());
SwapInfo swapInfo = await breezSDK.receiveOnchain(req: ReceiveOnchainRequest());

int minDepositSat = swapInfo.minAllowedDeposit;
int maxDepositSat = swapInfo.maxAllowedDeposit;

NodeState? nodeInfo = await BreezSDK().nodeInfo();
NodeState? nodeInfo = await breezSDK.nodeInfo();
if (nodeInfo != null) {
int inboundLiquiditySat = nodeInfo.inboundLiquidityMsats ~/ 1000;

Expand Down
10 changes: 5 additions & 5 deletions snippets/dart_snippets/lib/connecting_lsp.dart
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import 'package:breez_sdk/breez_sdk.dart';
import 'package:dart_snippets/sdk_instance.dart';
import 'package:breez_sdk/bridge_generated.dart';

Future<void> getLspInfo() async {
// ANCHOR: get-lsp-info
String? lspId = await BreezSDK().lspId();
LspInformation? lspInfo = await BreezSDK().lspInfo();
String? lspId = await breezSDK.lspId();
LspInformation? lspInfo = await breezSDK.lspInfo();
print(lspId);
print(lspInfo);
// ANCHOR_END: get-lsp-info
}

Future<List<LspInformation>> listLsps() async {
// ANCHOR: list-lsps
List<LspInformation> availableLsps = await BreezSDK().listLsps();
List<LspInformation> availableLsps = await breezSDK.listLsps();
// ANCHOR_END: list-lsps
return availableLsps;
}

Future<void> connectLsp(String lspId) async {
// ANCHOR: connect-lsp
await BreezSDK().connectLSP(lspId);
await breezSDK.connectLSP(lspId);
// ANCHOR_END: connect-lsp
}
6 changes: 3 additions & 3 deletions snippets/dart_snippets/lib/fiat_currencies.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import 'package:breez_sdk/breez_sdk.dart';
import 'package:dart_snippets/sdk_instance.dart';
import 'package:breez_sdk/bridge_generated.dart';

Future<List<FiatCurrency>> listFiatCurrencies() async {
// ANCHOR: list-fiat-currencies
List<FiatCurrency> fiatCurrencyList = await BreezSDK().listFiatCurrencies();
List<FiatCurrency> fiatCurrencyList = await breezSDK.listFiatCurrencies();
// ANCHOR_END: list-fiat-currencies
return fiatCurrencyList;
}

Future<Map<String, Rate>> fetchFiatRates(String lspId) async {
// ANCHOR: fetch-fiat-rates
Map<String, Rate> fiatRatesMap = await BreezSDK().fetchFiatRates();
Map<String, Rate> fiatRatesMap = await breezSDK.fetchFiatRates();
// print your desired rate
print(fiatRatesMap["USD"]?.value);
// ANCHOR_END: fetch-fiat-rates
Expand Down
25 changes: 18 additions & 7 deletions snippets/dart_snippets/lib/getting_started.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
import 'dart:typed_data';

import 'package:breez_sdk/breez_sdk.dart';
import 'package:dart_snippets/sdk_instance.dart';
import 'package:breez_sdk/bridge_generated.dart';

Future<void> initializeSDK() async {
// ANCHOR: init-sdk

// Initialize SDK logs listener
BreezSDK().initialize();
// It is recommended to use a single instance of BreezSDK across your Dart/Flutter app.
//
// All of the snippets assume a BreezSDK object is created on entrypoint of the app as such:
//
// BreezSDK breezSDK = BreezSDK();
//
// and is accessible throughout the app. There are various approaches on how to achieve this; creating a Singleton class using factory constructor, using state management libraries such as 'provider', 'GetX', 'Riverpod' and 'Redux' to name a few.

// Initializes SDK events & log streams.
//
// Call once on your Dart entrypoint file, e.g.; `lib/main.dart`.
breezSDK.initialize();

// Create the default config
Uint8List seed = await BreezSDK().mnemonicToSeed("<mnemonic words>");
Uint8List seed = await breezSDK.mnemonicToSeed("<mnemonic words>");
String inviteCode = "<invite code>";
String apiKey = "<api key>";
NodeConfig nodeConfig = NodeConfig.greenlight(
Expand All @@ -19,7 +30,7 @@ Future<void> initializeSDK() async {
inviteCode: inviteCode,
),
);
Config config = await BreezSDK().defaultConfig(
Config config = await breezSDK.defaultConfig(
envType: EnvironmentType.Production,
apiKey: apiKey,
nodeConfig: nodeConfig,
Expand All @@ -30,20 +41,20 @@ Future<void> initializeSDK() async {

// Connect to the Breez SDK make it ready for use
ConnectRequest connectRequest = ConnectRequest(config: config, seed: seed);
return await BreezSDK().connect(req: connectRequest);
return await breezSDK.connect(req: connectRequest);
// ANCHOR_END: init-sdk
}

Future<void> connectRestoreOnly(Config config, Uint8List seed) async {
// ANCHOR: init-sdk-restore-only
ConnectRequest connectRequest = ConnectRequest(config: config, seed: seed, restoreOnly: true);
return await BreezSDK().connect(req: connectRequest);
return await breezSDK.connect(req: connectRequest);
// ANCHOR_END: init-sdk-restore-only
}

Future<void> fetchBalance(String lspId) async {
// ANCHOR: fetch-balance
NodeState? nodeInfo = await BreezSDK().nodeInfo();
NodeState? nodeInfo = await breezSDK.nodeInfo();
if (nodeInfo != null) {
int lnBalance = nodeInfo.channelsBalanceMsat;
int onchainBalance = nodeInfo.onchainBalanceMsat;
Expand Down
Loading
Loading