Class: UnsupportedInteraction

interaction.UnsupportedInteraction(options)

Class used for describing an unsupported interaction.

  • Always returns false when the isSupported method is called.

  • Has a keystore state unsupported message at the error level.

  • Throws errors when attempting to call API methods such as run, request, and parse.

Constructor

new UnsupportedInteraction(options)

Accepts parameters to describe what is unsupported and why.

The text should be human-readable. The code is for machines.

Parameters:
Name Type Description
options object

options argument

Properties
Name Type Description
text string

the text of the error message

code string

the code of the error message

Source:
Example
import {UnsupportedInteraction} from "unchained-wallets";
const interaction = new UnsupportedInteraction({text: "failure text", code: "fail"});
console.log(interaction.isSupported()); // false

Extends

Methods

hasMessagesFor(options) → {boolean}

Return whether there are any messages matching the given options.

Parameters:
Name Type Description
options object

options argument

Properties
Name Type Description
state string

must equal this keystore state

level string

must equal this message level

code string | regexp

code must match this regular expression

text string | regexp

text must match this regular expression

version string | regexp

version must match this regular expression

Overrides:
Source:
Returns:
  • whether any messages match the given filters
Type
boolean

isSupported() → {false}

By design, this method always returns false.

Overrides:
Source:
Returns:

Always.

Type
false

messageFor(options) → {module:interaction.Message|null}

Return the first message matching the given options (or null if none is found).

Parameters:
Name Type Description
options object

options argument

Properties
Name Type Description
state string

must equal this keystore state

level string

must equal this message level

code string | regexp

code must match this regular expression

text string | regexp

text must match this regular expression

version string | regexp

version must match this regular expression

Overrides:
Source:
Returns:

the first matching Message object (or null if none is found)

Type
module:interaction.Message | null

messages() → {Array.<module:interaction.Message>}

Returns a single error level message at the unsupported state.

Overrides:
Source:
Returns:

the messages for this class

Type
Array.<module:interaction.Message>

messagesFor(options) → {Array.<module:interaction.Message>}

Return messages filtered by the given options.

Multiple options can be given at once to filter along multiple dimensions.

Parameters:
Name Type Description
options object

options argument

Properties
Name Type Description
state string

must equal this keystore state

level string

must equal this message level

code string | regexp

code must match this regular expression

text string | regexp

text must match this regular expression

version string | regexp

version must match this regular expression

Overrides:
Source:
Returns:

matching Message objects

Type
Array.<module:interaction.Message>
Example
import {PENDING, ACTIVE} from "unchained-bitcoin";
// Create any interaction instance
interaction.messages().forEach(msg => console.log(msg));
  { code: "device.connect", state: "pending", level: "info", text: "Please plug in your device."}
  { code: "device.active", state: "active", level: "info", text: "Communicating with your device..."}
  { code: "device.active.warning", state: "active", level: "warning", text: "Your device will warn you about...", version: "2.x"}
interaction.messagesFor({state: PENDING}).forEach(msg => console.log(msg));
  { code: "device.connect", state: "pending", level: "info", text: "Please plug in your device."}
interaction.messagesFor({code: ACTIVE}).forEach(msg => console.log(msg));
  { code: "device.active", state: "active", level: "info", text: "Communicating with your device..."}
  { code: "device.active.warning", state: "active", level: "warning", text: "Your device will warn you about...", version: "2.x"}
interaction.messagesFor({version: /^2/}).forEach(msg => console.log(msg));
  { code: "device.active", state: "active", level: "warning", text: "Your device will warn you about...", version: "2.x"}

messageTextFor(options) → {string|null}

Retrieve the text of the first message matching the given options (or null if none is found).

Parameters:
Name Type Description
options object

options argument

Properties
Name Type Description
state string

must equal this keystore state

level string

must equal this message level

code string | regexp

code must match this regular expression

text string | regexp

text must match this regular expression

version string | regexp

version must match this regular expression

Overrides:
Source:
Returns:

the text of the first matching message (or null if none is found)

Type
string | null

parse() → {void}

Throws an error.

Source:
Throws:

An error containing this this.text.

Returns:
Type
void

request() → {void}

Throws an error.

Source:
Throws:

An error containing this this.text.

Returns:
Type
void

(async) run() → {void}

Throws an error.

Source:
Throws:

An error containing this this.text.

Returns:
Type
void