diff --git a/README.md b/README.md index d2498b95..9307fd02 100644 --- a/README.md +++ b/README.md @@ -101,3 +101,24 @@ To build all apps and packages, run the following command: cd my-turborepo yarn build ``` + +## Dart Package development + +First, get the specific dart container up by running: +```sh +docker compose up -d dart +``` +The genereal docker compose won't launch the dart service. + +then, once the container is up, run: +```sh +docker exec -it dart-defindex bash +``` +Then you can launch the example app by running: +```sh +cd example +flutter run -d web-server --web-port 8080 --web-hostname 0.0.0.0 +``` +This will launch the example app on the port 8080 of your localhost. so you can go to +`http://localhost:8080` to see the app. + diff --git a/docker-compose.yml b/docker-compose.yml index 748ff77c..9d939112 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,6 +27,8 @@ services: dart: image: ghcr.io/cirruslabs/flutter:3.24.4 container_name: dart-defindex + profiles: + - on-demand networks: - defindex-network volumes: diff --git a/packages/defindex-dart-sdk/example/lib/main.dart b/packages/defindex-dart-sdk/example/lib/main.dart index 4766e23b..a12dee4c 100644 --- a/packages/defindex-dart-sdk/example/lib/main.dart +++ b/packages/defindex-dart-sdk/example/lib/main.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:defindex/defindex.dart'; +import 'package:stellar_flutter_sdk/stellar_flutter_sdk.dart'; void main() { runApp(const MyApp()); @@ -50,7 +51,7 @@ class _MyHomePageState extends State { String? transactionHash = await defiIndex.deposit( 'GCW36WQUHJASZVNFIIL7VZQWL6Q72XT6TAU6N3XMFGTLSNE2L7LMJNWT', 100.0, - (transaction) async => 'your_signed_transaction', + (transaction) async => signerFunction(transaction), ); print('Transaction hash: $transactionHash'); @@ -99,3 +100,31 @@ class _MyHomePageState extends State { ); } } + +// Future signerFunction(String transactionString) async { +// // Decode the transaction from the base64 string +// final transaction = Transaction.fromEnvelopeXdrBase64(transactionString); + +// // Create KeyPair from the user's secret seed +// KeyPair keyPair = KeyPair.fromSecretSeed('your_secret_key'); + +// // Sign the transaction with the KeyPair +// transaction.sign(keyPair, Network.TESTNET); + +// // Return the signed transaction as a base64 string +// return transaction.toEnvelopeXdrBase64(); +// } + +String signerFunction(String transactionXdr) { + // Create transaction from XDR + AbstractTransaction transaction = AbstractTransaction.fromEnvelopeXdrString( + transactionXdr, + ); + + // Create keypair and sign + KeyPair keyPair = KeyPair.fromSecretSeed("SC352W6PEHWSHYKP5IYO3HWAEVGLTVLZW5WE3UXPWSGKBST5K6DKRT7F"); + transaction.sign(keyPair, Network.TESTNET); + + // Return signed XDR + return transaction.toEnvelopeXdrBase64(); +} \ No newline at end of file diff --git a/packages/defindex-dart-sdk/example/pubspec.lock b/packages/defindex-dart-sdk/example/pubspec.lock index ce226da5..c831dafd 100644 --- a/packages/defindex-dart-sdk/example/pubspec.lock +++ b/packages/defindex-dart-sdk/example/pubspec.lock @@ -280,7 +280,7 @@ packages: source: hosted version: "1.11.1" stellar_flutter_sdk: - dependency: transitive + dependency: "direct main" description: name: stellar_flutter_sdk sha256: a25506529d40a040227cd565de6e1b4cc0a9ffc756472cf3c43420512e8a269b diff --git a/packages/defindex-dart-sdk/example/pubspec.yaml b/packages/defindex-dart-sdk/example/pubspec.yaml index 8f46febc..912d0014 100644 --- a/packages/defindex-dart-sdk/example/pubspec.yaml +++ b/packages/defindex-dart-sdk/example/pubspec.yaml @@ -32,6 +32,7 @@ dependencies: sdk: flutter defindex: path: ../ + stellar_flutter_sdk: ^1.8.9 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons.