0.1.1 • Published 10 months ago

@keystonehq/hw-app-sol v0.1.1

Weekly downloads
-
License
ISC
Repository
-
Last release
10 months ago

@keystonehq/hw-app-solana

Keystone Hardware Wallet Solana JavaScript bindings. this package is compitiable with Ledger js solana sdk on the api level.

API

Table of Contents

constructor

Constructs a new instance of the class.

Parameters

  • transport TransportWebUSB An object of type TransportWebUSB
  • mfp string? Optional parameter of type string, default is undefined, but the mfp should exist in the signing process.

getAddress

Retrieves the public key (address) for a given derivation path from the hardware device.

This method sends a request to the connected hardware device to derive the public key for the specified path using the ED25519 curve and SLIP-10 derivation algorithm. It also updates the master fingerprint (mfp) of the instance.

Parameters

  • path string The derivation path for the desired public key, e.g., "m/44'/501'/0'"
  • dislay boolean A boolean flag to indicate whether to display the address on the device (not used in current implementation due to compitable with ledger js sdk) (optional, default false)

Examples

solana.getAddress("44'/501'/0'").then(r => r.address)
  • Throws any Will throw an error if the device communication fails or if the response is incomplete

Returns Promise<{address: Buffer, mfp: string}> A Promise that resolves to an object containing: - address: A Buffer containing the derived public key - mfp: A string representing the master fingerprint of the wallet

signTransaction

Signs a Solana transaction using the specified derivation path.

This method sends the transaction to the hardware device for signing using the private key derived from the given path.

Parameters

  • path string The derivation path of the private key to use for signing, e.g., "m/44'/501'/0'/0'"
  • txBuffer Buffer A Buffer containing the serialized transaction to be signed

Examples

solana.signTransaction("44'/501'/0'", txBuffer).then(r => r.signature)
  • Throws any Will throw an error if the signing process fails or if the device is not properly initialized

Returns Promise<{signature: Buffer}> A Promise that resolves to an object containing: - signature: A Buffer containing the transaction signature

signOffchainMessage

Signs an off-chain message using the specified derivation path.

This method sends the message to the hardware device for signing using the private key derived from the given path.

Parameters

  • path string The derivation path of the private key to use for signing, e.g., "m/44'/501'/0'"
  • msgBuffer Buffer A Buffer containing the off-chain message to be signed
  • Throws any Will throw an error if the signing process fails or if the device is not properly initialized

Returns Promise<{signature: Buffer}> A Promise that resolves to an object containing: - signature: A Buffer containing the message signature

getAppConfig

Retrieves the configuration information of the connected hardware device.

This method sends a request to the device to get its version information, then parses the response to extract the firmware version and wallet master fingerprint.

  • Throws any Will throw an error if the device communication fails or if the response cannot be parsed

Returns Promise\ A Promise that resolves to an object containing: - version: A string representing the firmware version of the device - mfp: A string representing the master fingerprint of the wallet