1.1.15 • Published 19 hours ago

@ledgerhq/wallet-api-simulator v1.1.15

Weekly downloads
-
License
MIT
Repository
-
Last release
19 hours ago

Overview

The Ledger Wallet Simulator is a comprehensive tool designed to emulate the behavior of a Ledger device simulating responses and interactions with the wallet-API. It aids developers in testing and interacting with Ledger-related applications without requiring a physical Ledger device or necessitating the run of your application inside the WebView of the LedgerLive software. This documentation will guide you through the process of setting up and using the simulator.

By following this documentation, you'll be equipped to install, set up, and make the most out of this simulator. If any issues arise or further customization is needed, consider diving deeper into the source code or consulting the official documentation.

Table of Contents


Installation

To install the Ledger Wallet Simulator, you'll first need to include the necessary dependencies in your project.

npm install @ledgerhq/wallet-api-client

Then, install the simulator package:

npm install @ledgerHQ/simulator

Getting Started

1. Setting Up Transport:

Begin by setting up the transport using the getSimulatorTransport function.

import { getSimulatorTransport, profiles } from "@ledgerHQ/simulator";

const transport = getSimulatorTransport(profiles.STANDARD);
transport.onMessage = handleMessageFunction; // Replace with your message handler.

2. Creating Client:

Create a createClient function that return a new client. The provided simulated transport should be passed to the WalletAPIClient() as a parameter to effectively interact with the WalletAPIClient. Normally, WalletAPIClient only works with real transport, but the simulator provides a simulated transport for this purpose.

Here's a basic form:

function createClient() {
  // insert the transport created above
  return new WalletAPIClient(transport);
}

Working with Profiles

The simulator comes with predefined profiles (STANDARD and DEVICE), which determine the behavior and data of the simulator. You can easily extend these profiles by spreading inside the profile object:

const extendedProfile = {
  ...profiles.STANDARD,
  yourInfo: "yourValue", // Add any custom information here.
};

Using the Simulator

The primary use case for the simulator is to emulate a Ledger device's behavior for development and testing purposes. Here's a basic example:

// Create a client
const client = createClient();

// List accounts
const response = await client.transaction.list();

console.log(response);
1.1.15

19 hours ago

1.1.14

11 days ago

1.1.13

1 month ago

1.1.12

1 month ago

1.1.11

3 months ago

1.1.10

3 months ago

1.1.9

3 months ago

1.1.8

3 months ago

1.1.7

3 months ago

1.1.6

4 months ago

1.1.5

4 months ago

1.1.4

5 months ago

1.1.3

5 months ago

1.1.1

6 months ago

1.0.2

9 months ago

1.1.0

7 months ago

1.0.1

10 months ago

1.0.0

10 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.1.2

5 months ago

1.0.3

9 months ago

0.12.4

1 year ago

0.12.5

12 months ago

0.12.0

1 year ago

0.12.1

1 year ago

0.12.2

1 year ago

0.12.3

1 year ago

0.11.0

1 year ago

0.10.1

1 year ago

0.10.2

1 year ago

0.10.0

1 year ago

0.9.0

1 year ago

0.8.1

1 year ago

0.7.2

1 year ago

0.6.3

1 year ago

0.8.0

1 year ago

0.7.1

1 year ago

0.6.2

1 year ago

0.9.1

1 year ago

0.8.2

1 year ago

0.7.3

1 year ago

0.6.4

1 year ago

0.6.1

1 year ago

0.6.0

1 year ago

0.5.4

2 years ago

0.5.3

2 years ago

0.5.2

2 years ago

0.5.1

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago