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-ada

v3.0.4

Published

SecuX Hardware Wallet ADA API

Downloads

6

Readme

lerna view on npm npm module downloads

@secux/app-ada

SecuX Hardware Wallet ADA API

Usage

import { SecuxADA, AddressType } from "@secux/app-ada";

First, create instance of ITransport

Examples

  1. Get shelley address

    • base address
    const path = "m/1852'/1815'/0'";
    const address = await device.getAddress(path, AddressType.BASE);
    
    /*
    
    // transfer data to hardware wallet by custom transport layer
    const data = SecuxADA.prepareAddress(path);
    const response = await device.Exchange(data);
    const address = SecuxADA.resolveAddress(response, AddressType.BASE);
    
    */
    • reward address
    const path = "m/1852'/1815'/0'";
    const address = await device.getAddress(path, AddressType.REWARD);
  2. Sign transaction

    • transfer asset
    const inputs = [
        {
            path: "m/1852'/1815'/0'",
            txId: "75c7d745c5212a11a0bfc2719c35bcc2f57fda88d7afb2eb3c5f2b02c3e99ccb",
            index: 1,
            amount: 12663894,
            // for custom transport layer, each utxo needs xpublickey.
            // xpublickey: "c232950d7c27b78542795ce4cad053e8dfaab7679ba5477563be5c60c1a4d0613fc81fd9bb8f30822c1252c29cc6af147831da44fb86acad6c04fcc95700b92b"
        },
        {
            path: "m/1852'/1815'/0'",
            txId: "6552b8f8b8b282542b07d6187fe80daa5b7a60461c97231f45c06fd97f8a3385",
            index: 1,
            amount: 2330624,
            // for custom transport layer, each utxo needs xpublickey.
            // xpublickey: "c232950d7c27b78542795ce4cad053e8dfaab7679ba5477563be5c60c1a4d0613fc81fd9bb8f30822c1252c29cc6af147831da44fb86acad6c04fcc95700b92b"
        },
    ];
    
    const output = {
        // daedalus or shelley address is accepted.
        address: "DdzFFzCqrhsjZHKn8Y9Txr4B9PaEtYcYp8TGa4gQTfJfjvuNLqvB8hPG35WRgK4FjcSYhgK7b2H24jLMeqmPoS3YhJq6bjStsx4BZVnn",
        amount: 13000000
    };
    
    const { raw_tx } = await device.sign(inputs, output, {
        changeAddress: "addr1qyk54vyyc856ngxermdzqhxnlk376ykkupru8rxcyryvg4kxs4un3x4r4rq422kwrtvc8p2a20dzhyr5v0n9lhwy2u6sfjujuz",
    });
    
    /*
    
    // transfer data to hardware wallet by custom transport layer.
    const { commandData, serialized } = SecuxADA.prepareSign(inputs, output, {
        changeAddress: "addr1qyk54vyyc856ngxermdzqhxnlk376ykkupru8rxcyryvg4kxs4un3x4r4rq422kwrtvc8p2a20dzhyr5v0n9lhwy2u6sfjujuz",
    });
    const response = await device.Exchange(commandData);
    const raw_tx = SecuxADA.resloveTransaction(response, serialized);
    
    */
    • stake
    const input = {
        path: "m/1852'/1815'/0'",
        utxo: [
            {
                txId: "75c7d745c5212a11a0bfc2719c35bcc2f57fda88d7afb2eb3c5f2b02c3e99ccb",
                index: 1,
                amount: 12663894,
            }
        ],
        changeAddress: "addr1qyk54vyyc856ngxermdzqhxnlk376ykkupru8rxcyryvg4kxs4un3x4r4rq422kwrtvc8p2a20dzhyr5v0n9lhwy2u6sfjujuz",
        // for custom transport layer, each utxo needs xpublickey.
        // xpublickey: "c232950d7c27b78542795ce4cad053e8dfaab7679ba5477563be5c60c1a4d0613fc81fd9bb8f30822c1252c29cc6af147831da44fb86acad6c04fcc95700b92b"
    };
    
    // pool id (support bech32 encoded)
    const pool = "ea595c6f726db925b6832af51795fd8a46e700874c735d204f7c5841";
    
    const { raw_tx } = await device.sign(
        input,
        pool,
        {
            // An account needs to have a stake pool registration certificate 
            // before it can participate in stake delegation between stake pools.
            needRegistration: true
        }
    );
    
    /*
    
    // transfer data to hardware wallet by custom transport layer.
    const { commandData, serialized } = SecuxADA.prepareStake(
        input,
        pool,
        {
            needRegistration: true
        }
    );
    const response = await device.Exchange(commandData);
    const raw_tx = SecuxADA.resolveTransaction(response, serialized);
    
    */
    • withdrawal
    const withdrawAmount = 150000;
    const { raw_tx } = await device.sign(input, withdrawAmount);
    
    /*
    
    // transfer data to hardware wallet by custom transport layer.
    const { commandData, serialized } = SecuxADA.prepareStake(input, withdrawAmount);
    const response = await device.Exchange(commandData);
    const raw_tx = SecuxADA.resolveTransaction(response, serialized);
    
    */
    • unstake (de-register staking key)
    const { raw_tx } = await device.sign(
        input, 
        {
            // With de-registration operation, the balance of reward address must be 0.
            withdrawAmount
        }
    );
    
    /*
    
    // transfer data to hardware wallet by custom transport layer.
    const { commandData, serialized } = SecuxADA.prepareUnstake(input, { withdrawAmount });
    const response = await device.Exchange(commandData);
    const raw_tx = SecuxADA.resolveTransaction(response, serialized);
    
    */

API Reference

ADA package for SecuX device

Kind: global class

SecuxADA.addressConvert(xpublickey, type, [option]) ⇒ string

Convert bip32-publickey to ADA address.

Returns: string - address

| Param | Type | Description | | --- | --- | --- | | xpublickey | string | Buffer | ada bip32-publickey | | type | AddressType | | | [option] | AddressOption | |

SecuxADA.prepareAddress(pathWith3Depth) ⇒ communicationData

Prepare data for address generation.

Returns: communicationData - data for sending to device

| Param | Type | Description | | --- | --- | --- | | pathWith3Depth | string | m/1852'/1815'/... |

SecuxADA.resolveAddress(response, type, [option]) ⇒ string

Resolve address from response data.

Returns: string - address

| Param | Type | Description | | --- | --- | --- | | response | communicationData | data from device | | type | AddressType | | | [option] | AddressOption | |

SecuxADA.prepareXPublickey(pathWith3Depth) ⇒ communicationData

Prepare data for bip32-publickey.

Returns: communicationData - data for sending to device

| Param | Type | Description | | --- | --- | --- | | pathWith3Depth | string | m/1852'/1815'/... |

SecuxADA.resolveXPublickey(response) ⇒ string

Resolve bip32-publickey from response data.

Returns: string - bip32-publickey (hex string)

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

SecuxADA.prepareSign(inputs, output, [option]) ⇒ prepared

Prepare data for signing.

| Param | Type | | --- | --- | | inputs | Array.<txInput> | | output | txOutput | | [option] | signOption |

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

Reslove signatures from response data.

Returns: Array.<string> - signature array of hex string

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

SecuxADA.resolveTransaction(response, serialized) ⇒ string

Resolve transaction for broadcasting.

Returns: string - signed transaction (base64 encoded)

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

SecuxADA.prepareStake(input, pool, [option]) ⇒ prepared

Prepare data for signing.

| Param | Type | Description | | --- | --- | --- | | input | stakeInput | | | pool | string | pool hash or id | | [option] | stakeOption | |

SecuxADA.prepareUnstake(input, [option]) ⇒ prepared

Prepare data for signing.

| Param | Type | | --- | --- | | input | stakeInput | | [option] | unstakeOption |

SecuxADA.prepareWithdraw(input, amount, [option]) ⇒ prepared

Prepare data for signing.

| Param | Type | Description | | --- | --- | --- | | input | stakeInput | | | amount | number | string | rewards | | [option] | withdrawOption | |

AddressType : enum

Properties

| Name | Type | Description | | --- | --- | --- | | BASE | number | 0 | | ENTERPRISE | number | 1 | | POINTER | number | 2 | | REWARD | number | 3 | | BOOTSTRAPv1 | number | 4 | | BOOTSTRAPv2 | number | 5 |

PointerOption : object

Properties

| Name | Type | | --- | --- | | slot | number | | txIndex | number | | certIndex | number |

AddressOption : object

Properties

| Name | Type | Description | | --- | --- | --- | | [addressIndex] | number | account index | | [stakeIndex] | number | stake key index | | [pointer] | PointerOption | option for Pointer address |

txInput : object

Properties

| Name | Type | Description | | --- | --- | --- | | path | string | 3-depth path of CIP-1852 | | xpublickey | string | Buffer | ED25519 publickey from path | | txId | string | referenced transaction hash | | index | number | referenced transaction output index | | amount | number | string | referenced transaction output amount | | [addressIndex] | number | default: 0 | | [stakeIndex] | number | default: 0 |

txOutput : object

Properties

| Name | Type | Description | | --- | --- | --- | | address | string | receiver's address | | amount | number | string | amount of payment |

signOption : object

Properties

| Name | Type | Description | | --- | --- | --- | | [changeAddress] | string | default: sender's address | | [fee] | number | string | | | [TimeToLive] | number | |

stakeOption : object

Properties

| Name | Type | Description | | --- | --- | --- | | [stakeIndex] | number | default: 0 | | [needRegistration] | boolean | include registration or not | | [fee] | number | string | | | [TimeToLive] | number | |

withdrawOption : object

Properties

| Name | Type | Description | | --- | --- | --- | | [stakeIndex] | number | default: 0 | | [fee] | number | string | | | [TimeToLive] | number | |

unstakeOption : object

Properties

| Name | Type | Description | | --- | --- | --- | | [stakeIndex] | number | default: 0 | | [withdrawAmount] | boolean | withdraw and de-registration | | [fee] | number | string | | | [TimeToLive] | number | |

utxo : object

Properties

| Name | Type | Description | | --- | --- | --- | | txId | string | referenced transaction hash | | index | number | referenced transaction output index | | amount | number | string | referenced transaction output amount | | [addressIndex] | number | default: 0 |

stakeInput : object

Properties

| Name | Type | Description | | --- | --- | --- | | path | string | 3-depth path of CIP-1852 | | utxo | Array.<utxo> | | | changeAddress | string | owner's account | | xpublickey | string | Buffer | cardano bip32-publickey | | [stakeIndex] | number | default: 0 |

prepared : object

Properties

| Name | Type | Description | | --- | --- | --- | | commandData | communicationData | data for sending to device | | serialized | communicationData | |


© 2018-21 SecuX Technology Inc.

authors: [email protected]