Skip to content

Commit

Permalink
example app working
Browse files Browse the repository at this point in the history
  • Loading branch information
chopan123 committed Nov 6, 2024
1 parent 9d66469 commit 709ef7c
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 2 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
31 changes: 30 additions & 1 deletion packages/defindex-dart-sdk/example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -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());
Expand Down Expand Up @@ -50,7 +51,7 @@ class _MyHomePageState extends State<MyHomePage> {
String? transactionHash = await defiIndex.deposit(
'GCW36WQUHJASZVNFIIL7VZQWL6Q72XT6TAU6N3XMFGTLSNE2L7LMJNWT',
100.0,
(transaction) async => 'your_signed_transaction',
(transaction) async => signerFunction(transaction),
);

print('Transaction hash: $transactionHash');
Expand Down Expand Up @@ -99,3 +100,31 @@ class _MyHomePageState extends State<MyHomePage> {
);
}
}

// Future<String> 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();
}
2 changes: 1 addition & 1 deletion packages/defindex-dart-sdk/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions packages/defindex-dart-sdk/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 709ef7c

Please sign in to comment.