Skip to content

A Flutter Ledger App Plugin for the Cardano blockchain

License

Notifications You must be signed in to change notification settings

vespr-wallet/ledger-cardano-plus

 
 

Repository files navigation


ledger-cardano-plus

A Flutter Ledger App Plugin for the Cardano blockchain
Report Bug · Request Feature · Ledger Cardano Plus



Overview

Ledger Nano devices are the perfect hardware wallets for managing your crypto & NFTs on the go. This Flutter package is a plugin for the ledger_flutter_plus package to get accounts and sign transactions using the Cardano blockchain.

Getting started

Installation

Install the latest version of this package via pub.dev:

ledger_cardano_plus: ^latest-version
ledger_flutter_plus: ^latest-version

For integration with the Ledger Flutter Plus package, check out the documentation here.

Setup and Usage

Get an instance of an CardanoLedger and then use it to scan and connect to devices.

final CardanoLedger cardanoLedgerConnector = CardanoLedger.ble(
    onPermissionRequest: (status) async {
      // if ([AvailabilityState.unsupported].contains(status)) {
      //   return false;
      // }

      // this is using permission_handler package
      Map<Permission, PermissionStatus> statuses = await [
        Permission.location,
        Permission.bluetoothScan,
        Permission.bluetoothConnect,
        Permission.bluetoothAdvertise,
      ].request();

      return statuses.values.where((status) => status.isDenied).isEmpty;
    },
  );

// FOR USB
// final CardanoLedger cardanoLedgerConnector = CardanoLedger.usb();

final devicesStream = cardanoLedgerConnector.scanForDevices();

// Best is to actually listen to the stream and then allow the user to select
//  the wanted ledger device
final firstLedgerDevice = await devicesStream.first;

final cardanoApp = cardanoLedgerConnector.connect(firstLedgerDevice);

// To derive receive address
final receiveAddress = await cardanoApp.deriveReceiveAddress(
      addressIndex: addressIndex,
      network: CardanoNetwork.mainnet(),
    );

For moe in depth sample including device selection dialog, check out the example project in this repo

Sponsors

Our top sponsors are shown below!

Project Catalyst

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag enhancement.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/my-feature)
  3. Commit your Changes (git commit -m 'feat: my new feature)
  4. Push to the Branch (git push origin feature/my-feature)
  5. Open a Pull Request

Please read our Contributing guidelines and try to follow Conventional Commits.

Running Integration Tests

To run the integration tests for the ledger-cardano-plus SDK, follow these steps:

  1. Set Up Your Environment:

  2. Clone the Repository:

    • If you haven't already, clone the ledger-cardano-plus repository from GitHub:
    git clone https://github.com/vespr-wallet/ledger-cardano-plus.git
    cd ledger-cardano-plus
  3. Navigate to the Integration Tests Directory:

    • Change to the directory containing the integration tests:
    cd example/integration_test
  4. Run the Tests:

    • Use the following Flutter command to execute all the integration tests:
    cd example
    flutter test integration_test/*_tests.dart
    • To run a specific integration test file, provide the path to the test file:
    cd example
    flutter test integration_test/cardano_ledger_serial_version_tests.dart
    • To run a specific test case within a test file, use the -n flag followed by the test name:
    cd example
    flutter test integration_test/cardano_ledger_serial_version_tests.dart -n "Should correctly get the serial number of the device"

    Make sure your development environment is properly set up to communicate with the Ledger device, and that the device is connected and unlocked before running the tests.

License

The ledger_cardano_plus SDK is released under the MIT License (MIT). See LICENSE for details.

About

A Flutter Ledger App Plugin for the Cardano blockchain

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Dart 99.4%
  • Other 0.6%