import { bytes, dec, hex, utf8 } from '../convert'
import { Rpc } from '../rpc'
import { Wallet } from '../wallet'
-import { enqueue } from './queue'
+import { queue } from './queue'
type LedgerStatus = 'UNSUPPORTED' | 'DISCONNECTED' | 'BUSY' | 'LOCKED' | 'CONNECTED'
* @returns Response object containing command status, public key, and address
*/
static async account (index: number = 0, show: boolean = false): Promise<LedgerAccountResponse> {
- return enqueue(async () => {
+ return queue(async () => {
try {
if (typeof index !== 'number' || index < 0 || index >= HARDENED_OFFSET) {
throw new TypeError('Invalid account index')
* connection updates.
*/
static async disconnect (): Promise<void> {
- enqueue(async () => {
+ queue(async () => {
try {
this.#isPolling = false
const hidDevices = await navigator?.hid?.getDevices?.() ?? []
* @returns Status of command
*/
static async #cacheBlock (index: number = 0, block: Block): Promise<LedgerResponse> {
- return enqueue(async () => {
+ return queue(async () => {
try {
if (typeof index !== 'number' || index < 0 || index >= HARDENED_OFFSET) {
throw new TypeError('Invalid account index')
* @returns Status of command
*/
static async #close (): Promise<LedgerResponse> {
- return enqueue(async () => {
+ return queue(async () => {
const transport = await this.#transport.create(this.#openTimeout, this.#listenTimeout)
const response = await transport
.send(0xb0, 0xa7, this.#ADPU_CODES.paramUnused, this.#ADPU_CODES.paramUnused)
* @returns Status of command
*/
static async #open (): Promise<LedgerResponse> {
- return enqueue(async () => {
+ return queue(async () => {
const name = new TextEncoder().encode('Nano')
const transport = await this.#transport.create(this.#openTimeout, this.#listenTimeout)
const response = await transport
if (block.signature !== undefined) {
throw new TypeError('Block signature already exists', { cause: block.signature })
}
- return enqueue(async () => {
+ return queue(async () => {
try {
if (typeof index !== 'number' || index < 0 || index >= HARDENED_OFFSET) {
throw new TypeError('Invalid account index')
* @returns {Promise} Status and signature
*/
static async #signNonce (index: number, nonce: Uint8Array<ArrayBuffer>): Promise<LedgerSignResponse> {
- return enqueue(async () => {
+ return queue(async () => {
if (typeof index !== 'number' || index < 0 || index >= HARDENED_OFFSET) {
throw new TypeError('Invalid account index')
}
* @returns Status, process name, and version
*/
static async #version (): Promise<LedgerVersionResponse> {
- return enqueue(async () => {
+ return queue(async () => {
try {
const transport = await this.#transport.create(this.#openTimeout, this.#listenTimeout)
const response = await transport