npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@secux/app-sol

v3.0.11

Published

SecuX Hardware Wallet SOL API

Downloads

18

Readme

lerna view on npm npm module downloads

@secux/app-sol

SecuX Hardware Wallet SOL API

Usage

import { SecuxSOL } from "@secux/app-sol";

First, create instance of ITransport.

Examples

  1. Get address of bip-32 path.

    • main account
      const path = "m/44'/501'/0'";
      const address = await device.getAddress(path);
      
      /*
      
      // transfer data to hardware wallet by custom transport layer.
      const data = SecuxBTC.prepareAddress(path);
      const response = await device.Exchange(data);
      const address = SecuxBTC.resolveAddress(response, path);
      
      */
    • associated account
      const address = await device.getAddress(
          "m/44'/501'/0'", 
          // USDC
          { mintAccount: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" }
      );
    • account with seed
      const address = await device.getAddress(
          "m/44'/501'/0'",
          { 
              seed: "seed",
              programId: "Stake11111111111111111111111111111111111111"
          }
      );
  2. Sign transaction.

    • transfer asset

      const { raw_tx } = await device.sign(
          "<recentBlockhash>",
          instructions: [
              {
                  type: "transfer",
                  params: {
                      to: "<reciever account>",
                      lamports: 1e9,
                      path: "m/44'/501'/0'"
                  }
              }
          ]
      );
      
      /*
      
      // transfer data to hardware wallet by custom transport layer.
      const { commandData, serialized } = SecuxSOL.prepareSign(
          "<recentBlockhash>",
          instructions: [
              {
                  type: "transfer",
                  params: {
                      from: "<sender's account>",
                      to: "<reciever's account>",
                      lamports: 1e9,
                      path: "m/44'/501'/0'"
                  }
              }
          ]
      );
      const response = await device.Exchange(commandData);
      const raw_tx = SecuxSOL.resloveTransaction(response, serialized);
      
      */
    • transfer SPL token

      const { raw_tx } = await device.sign(
          "<recentBlockhash>",
          instructions: 
              SecuxSOL.Action.transferToken(
                  {
                      to: "<reciever's account>",
                      owner: "<sender's account>",
                      amount: 1e6,
                      mint: "<token mint account>",
                      decimal: 6,
                      path: "m/44'/501'/0'",
                      // create ATA for reciever
                      createAccount: true
                  }
              )
      );
    • native staking

      const { raw_tx } = await device.sign(
          "<recentBlockhash>",
          instructions: 
              SecuxSOL.Action.stake(
                  {
                      owner: "<main account>",
                      stake: "<stake account>",
                      vote: "<vote account>",
                      lamports: 1e9,
                      path: "m/44'/501'/0'",
      
                      // if give a seed, the createWithSeed instruction will be included.
                      // stake: "<arbitrary string>"
                  }
              )
      );
    • unstake

      const { raw_tx } = await device.sign(
          "<recentBlockhash>",
          instructions: 
              SecuxSOL.Action.unstake(
                  {
                      owner: "<main account>",
                      stake: "<stake account or seed>",
                      lamports: <withdraw amount>,
                      path: "m/44'/501'/0'"
                  }
              )
      );

API Reference

SOL package for SecuX device

Kind: global class

SecuxSOL.addressConvert(publickey, [option]) ⇒ string

Convert ed25519 publickey to SOL address.

Returns: string - address

| Param | Type | Description | | --- | --- | --- | | publickey | string | Buffer | ed25519 publickey | | [option] | ATAOption | SeedOption | |

SecuxSOL.prepareAddress(path) ⇒ communicationData

Prepare data for SOL address.

Returns: communicationData - data for sending to device

| Param | Type | Description | | --- | --- | --- | | path | string | BIP32 path (hardened child key), ex: m/44'/501'/0'/0' |

SecuxSOL.resolveAddress(response, [option]) ⇒ string

Generate SOL address from response data.

Returns: string - SOL address

| Param | Type | Description | | --- | --- | --- | | response | communicationData | data from device | | [option] | ATAOption | SeedOption | |

SecuxSOL.preparePublickey(path) ⇒ communicationData

Prepare data for ed25519 publickey.

Returns: communicationData - data for sending to device

| Param | Type | Description | | --- | --- | --- | | path | string | BIP32 path (hardened child key), ex: m/44'/501'/0'/0' |

SecuxSOL.resolvePublickey(response) ⇒ string

Resove ed25519 publickey from response data.

Returns: string - ed25519 publickey (hex string)

| Param | Type | Description | | --- | --- | --- | | response | communicationData | data from device |

SecuxSOL.prepareSign(feePayer, content) ⇒ prepared

Prepare data for signing.

Returns: prepared - prepared object

| Param | Type | Description | | --- | --- | --- | | feePayer | string | solana account | | content | txDetail | transaction object |

SecuxSOL.resolveSignatureList(response) ⇒ Array.<string>

Reslove signatures from response data.

Returns: Array.<string> - signature array (base58 encoded)

| Param | Type | Description | | --- | --- | --- | | response | communicationData | data from device |

SecuxSOL.resolveTransaction(response, serialized) ⇒ string

Resolve transaction for broadcasting.

Returns: string - signed transaction (hex)

| Param | Type | Description | | --- | --- | --- | | response | communicationData | data from device | | serialized | communicationData | |

ATAOption : object

Properties

| Name | Type | Description | | --- | --- | --- | | mintAccount | string | token mint address |

SeedOption : object

Properties

| Name | Type | Description | | --- | --- | --- | | seed | string | arbitary string (UTF-8) | | programId | string | program address |

accounts : object

Properties

| Name | Type | Description | | --- | --- | --- | | publickey | string | Buffer | Ed25519 publickey | | isSigner | boolean | | | isWritable | boolean | | | [path] | string | the path for signing |

Instruction : object

Properties

| Name | Type | Description | | --- | --- | --- | | programId | string | program address | | accounts | accounts | | | data | string | Buffer | hex string or buffer |

BuiltinInstruction : object

Properties

| Name | Type | Description | | --- | --- | --- | | type | string | instruction type | | params | any | parameters |

txDetail : object

Properties

| Name | Type | Description | | --- | --- | --- | | recentBlockhash | string | a recent blockhash | | instructions | Array.<(Instruction|BuiltinInstruction)> | a least one instruction in a transaction | | [feepayerPath] | string | option for signing via SecuX wallet |

prepared : object

Properties

| Name | Type | Description | | --- | --- | --- | | commandData | communicationData | data for sending to device | | rawTx | string | unsigned raw transaction |


© 2018-22 SecuX Technology Inc.

authors: [email protected]