Constructor
new LedgerGetMetadata()
Example
import {LedgerGetMetadata} from "unchained-wallets";
const interaction = new LedgerGetMetadata();
const result = await interaction.run();
console.log(result);
{
spec: "Nano S v1.4.2 (MCU v1.7)",
model: "Nano S",
version: {
major: "1",
minor: "4",
patch: "2",
string: "1.4.2",
},
mcuVersion: {
major: "1",
minor: "7",
string: "1.7",
}
}
Extends
Methods
closeTransport() → {Promise}
Close the Transport to free the interface (E.g. could be used in another tab now that the interaction is over)
The way the pubkey/xpub/fingerprints are grabbed makes this a little tricky. Instead of re-writing how that works, let's just add a way to explicitly close the transport.
- Inherited From:
- Source:
Returns:
- promise to close the transport
- Type
- Promise
messages() → {Array.<module:interaction.Message>}
Adds pending
and active
messages at the info
level urging
the user to be in the Ledger dashboard, not the bitcoin app
(ledger.app.dashboard
).
- Inherited From:
- Source:
Returns:
messages for this interaction
- Type
- Array.<module:interaction.Message>
parse() → {void}
Throws an error.
- Inherited From:
- Source:
Throws:
An error since this is a direct interaction.
Returns:
- Type
- void
parseMetadata(response) → {Object}
Parses the binary data returned from the Ledger API call into a metadata object.
Parameters:
Name | Type | Description |
---|---|---|
response |
ByteArray | binary response data |
Returns:
- device metadata
- Type
- Object
request() → {void}
Throws an error.
- Inherited From:
- Source:
Throws:
An error since this is a direct interaction.
Returns:
- Type
- void
(async) run() → {Promise}
Initiate the intended interaction and return a result.
Subclasses must override this function. This function must
always return a promise as it is designed to be called within an
await
block.
- Overrides:
- Source:
Returns:
Does the work of interacting with the keystore.
- Type
- Promise
withApp(callback) → {Promise}
Can be called by a subclass during its run()
method.
Creates a transport layer connection, initializes a bitcoin app
object, and passes control to the callback
function, with the
app API as the first argument to the function and the transport
API as the second.
See the Ledger API for general information or the bitcoin app API for examples of API calls.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function |
|
- Inherited From:
- Source:
Returns:
does the work of setting up an app instance (and transport connection)
- Type
- Promise
Example
async run() {
return await this.withApp(async (app, transport) => {
return app.doSomething(); // Not a real Ledger bitcoin app API call
});
}
(async) withTransport(callback) → {Promise}
Can be called by a subclass during its run()
method.
Creates a transport layer connection and passes control to the
callback
function, with the transport API as the first argument
to the function.
See the Ledger API for general information or a specific transport API for examples of API calls.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function |
|
- Inherited From:
- Source:
Returns:
does the work of setting up a transport connection
- Type
- Promise
Example
async run() {
return await this.withTransport(async (transport) => {
return transport.doSomething(); // Not a real Ledger transport API call
});
}