Skip to content

Add page to configure the main application #109

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

Merged
merged 2 commits into from
Jun 11, 2025
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
55 changes: 55 additions & 0 deletions snippets/dart_snippets/lib/notification_plugin.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import 'dart:async';
import 'dart:io';

import 'package:dart_snippets/sdk_instance.dart';
import 'package:flutter_breez_liquid/flutter_breez_liquid.dart';
import 'package:flutter/foundation.dart';
// ANCHOR: init-sdk-app-group
import 'package:app_group_directory/app_group_directory.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:path_provider/path_provider.dart';

const String appGroup = 'group.com.example.application';
const String mnemonicKey = 'BREEZ_SDK_LIQUID_SEED_MNEMONIC';

Future<void> initSdk() async {
// Read the mnemonic from secure storage using the app group
final FlutterSecureStorage storage = const FlutterSecureStorage(
iOptions: IOSOptions(
accessibility: KeychainAccessibility.first_unlock,
groupId: appGroup,
),
);
final String? mnemonic = await storage.read(key: mnemonicKey);
if (mnemonic == null) {
throw Exception('Mnemonic not found');
}

// Create the default config, providing your Breez API key
Config config = defaultConfig(network: LiquidNetwork.mainnet, breezApiKey: "<your-Breez-API-key>");

// Set the working directory to the app group path
config = config.copyWith(workingDir: await getWorkingDir());

ConnectRequest connectRequest = ConnectRequest(mnemonic: mnemonic, config: config);

await breezSDKLiquid.connect(req: connectRequest);
}

Future<String> getWorkingDir() async {
String path = '';
if (defaultTargetPlatform == TargetPlatform.android) {
final Directory documentsDir = await getApplicationDocumentsDirectory();
path = documentsDir.path;
} else if (defaultTargetPlatform == TargetPlatform.iOS) {
final Directory? sharedDirectory = await AppGroupDirectory.getAppGroupDirectory(
appGroup,
);
if (sharedDirectory == null) {
throw Exception('Could not get shared directory');
}
path = sharedDirectory.path;
}
return "$path/breezSdkLiquid";
}
// ANCHOR_END: init-sdk-app-group
152 changes: 143 additions & 9 deletions snippets/dart_snippets/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "7.4.5"
app_group_directory:
dependency: "direct main"
description:
name: app_group_directory
sha256: ad89800fd55133b46e1f6940ac6b974562f7fb6394c662c0f4422b90167f2416
url: "https://pub.dev"
source: hosted
version: "2.0.0"
args:
dependency: transitive
description:
Expand Down Expand Up @@ -45,11 +53,11 @@ packages:
dependency: "direct main"
description:
path: "."
ref: HEAD
resolved-ref: f5248578a28b591b142cf185d55fdf3b86971579
ref: "v0.9.1"
resolved-ref: aea162366cfda2efeca6790b4d72816c3363885e
url: "https://github.com/breez/breez-sdk-liquid-dart"
source: git
version: "0.9.2-rc1"
version: "0.9.1"
build_cli_annotations:
dependency: transitive
description:
Expand Down Expand Up @@ -155,19 +163,19 @@ packages:
source: hosted
version: "7.0.1"
flutter:
dependency: transitive
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_breez_liquid:
dependency: "direct main"
description:
path: "."
ref: HEAD
resolved-ref: "5f4a675d6084e06e0e6659e6f783eecbfc92c58a"
ref: "v0.9.1"
resolved-ref: b2dd7a6f8f2e573b564e2804b43ddaef07045779
url: "https://github.com/breez/breez-sdk-liquid-flutter"
source: git
version: "0.9.2-rc1"
version: "0.9.1"
flutter_rust_bridge:
dependency: transitive
description:
Expand All @@ -176,6 +184,59 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.9.0"
flutter_secure_storage:
dependency: "direct main"
description:
name: flutter_secure_storage
sha256: de957362e046bc68da8dcf6c1d922cb8bdad8dd4979ec69480cf1a3c481abe8e
url: "https://pub.dev"
source: hosted
version: "6.1.0"
flutter_secure_storage_linux:
dependency: transitive
description:
name: flutter_secure_storage_linux
sha256: be76c1d24a97d0b98f8b54bce6b481a380a6590df992d0098f868ad54dc8f688
url: "https://pub.dev"
source: hosted
version: "1.2.3"
flutter_secure_storage_macos:
dependency: transitive
description:
name: flutter_secure_storage_macos
sha256: "388f76fd0f093e7415a39ec4c169ae7cceeee6d9f9ba529d788a13f2be4de7bd"
url: "https://pub.dev"
source: hosted
version: "1.1.2"
flutter_secure_storage_platform_interface:
dependency: transitive
description:
name: flutter_secure_storage_platform_interface
sha256: cf91ad32ce5adef6fba4d736a542baca9daf3beac4db2d04be350b87f69ac4a8
url: "https://pub.dev"
source: hosted
version: "1.1.2"
flutter_secure_storage_web:
dependency: transitive
description:
name: flutter_secure_storage_web
sha256: f4ebff989b4f07b2656fb16b47852c0aab9fed9b4ec1c70103368337bc1886a9
url: "https://pub.dev"
source: hosted
version: "1.2.1"
flutter_secure_storage_windows:
dependency: transitive
description:
name: flutter_secure_storage_windows
sha256: ca89c8059cf439985aa83c59619b3674c7ef6cc2e86943d169a7369d6a69cab5
url: "https://pub.dev"
source: hosted
version: "1.1.3"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
freezed_annotation:
dependency: transitive
description:
Expand Down Expand Up @@ -228,10 +289,10 @@ packages:
dependency: transitive
description:
name: js
sha256: "53385261521cc4a0c4658fd0ad07a7d14591cf8fc33abbceae306ddb974888dc"
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev"
source: hosted
version: "0.7.2"
version: "0.6.7"
json_annotation:
dependency: transitive
description:
Expand Down Expand Up @@ -312,6 +373,70 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.9.1"
path_provider:
dependency: "direct main"
description:
name: path_provider
sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd"
url: "https://pub.dev"
source: hosted
version: "2.1.5"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
sha256: d0d310befe2c8ab9e7f393288ccbb11b60c019c6b5afc21973eeee4dda2b35e9
url: "https://pub.dev"
source: hosted
version: "2.2.17"
path_provider_foundation:
dependency: transitive
description:
name: path_provider_foundation
sha256: "4843174df4d288f5e29185bd6e72a6fbdf5a4a4602717eed565497429f179942"
url: "https://pub.dev"
source: hosted
version: "2.4.1"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279
url: "https://pub.dev"
source: hosted
version: "2.2.1"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7
url: "https://pub.dev"
source: hosted
version: "2.3.0"
platform:
dependency: transitive
description:
name: platform
sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984"
url: "https://pub.dev"
source: hosted
version: "3.1.6"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
url: "https://pub.dev"
source: hosted
version: "2.1.8"
pool:
dependency: transitive
description:
Expand Down Expand Up @@ -533,6 +658,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.2.1"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
yaml:
dependency: transitive
description:
Expand All @@ -551,3 +684,4 @@ packages:
version: "2.2.2"
sdks:
dart: ">=3.7.0 <4.0.0"
flutter: ">=3.27.0"
18 changes: 12 additions & 6 deletions snippets/dart_snippets/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,30 @@ publish_to: 'none'

environment:
sdk: '>=3.0.0 <4.0.0'
flutter: ">=3.27.0"

dependencies:
flutter:
sdk: flutter
flutter_secure_storage: ^6.0.0
app_group_directory: ^2.0.0
path_provider: ^2.0.0
breez_liquid:
git:
url: https://github.com/breez/breez-sdk-liquid-dart
tag: 0.9.0
ref: v0.9.1
flutter_breez_liquid:
git:
url: https://github.com/breez/breez-sdk-liquid-flutter
tag: 0.9.0
ref: v0.9.1
rxdart: ^0.28.0

dependency_overrides:
# Comment out to use published packages
breez_liquid:
path: ./packages/breez-sdk-liquid-dart
flutter_breez_liquid:
path: ./packages/breez-sdk-liquid-flutter
#breez_liquid:
# path: ./packages/breez-sdk-liquid-dart
#flutter_breez_liquid:
# path: ./packages/breez-sdk-liquid-flutter
# Enable overrides below to work with Liquid SDK packages locally
#breez_liquid:
# path: ../../../breez-sdk-liquid/packages/dart
Expand Down
36 changes: 36 additions & 0 deletions snippets/react-native/notification_plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {
defaultConfig,
connect,
LiquidNetwork
} from '@breeztech/react-native-breez-sdk-liquid'
import { Platform } from 'react-native'

// ANCHOR: init-sdk-app-group
import SecureStorage, { ACCESSIBLE } from 'react-native-secure-storage'
import * as RNFS from 'react-native-fs'

const APP_GROUP = 'group.com.example.application'
const MNEMONIC_KEY = 'BREEZ_SDK_LIQUID_SEED_MNEMONIC'

const initSdk = async () => {
// Read the mnemonic from secure storage using the app group
const mnemonic = await SecureStorage.getItem(MNEMONIC_KEY, {
accessGroup: APP_GROUP,
accessible: ACCESSIBLE.AFTER_FIRST_UNLOCK
})

// Create the default config, providing your Breez API key
const config = await defaultConfig(
LiquidNetwork.MAINNET,
'<your-Breez-API-key>'
)

// Set the working directory to the app group path
if (Platform.OS === 'ios') {
const groupPath = await RNFS.pathForGroup(APP_GROUP)
config.workingDir = `${groupPath}/breezSdkLiquid`
}

await connect({ mnemonic, config })
}
// ANCHOR_END: init-sdk-app-group
2 changes: 2 additions & 0 deletions snippets/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
},
"dependencies": {
"@breeztech/react-native-breez-sdk-liquid": "^0.9.0",
"react-native-fs": "^2.20.0",
"react-native-secure-storage": "https://github.com/breez/react-native-secure-storage",
"react": "18.1.0",
"react-native": "0.70.6"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module 'react-native-secure-storage'
Loading
Loading