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

v3.0.0

Published

SecuX Hardware Wallet LUNA API

Downloads

2

Readme

lerna ![view on npm](https://badgen.net/npm/v/@secux/app-luna npm module downloads

@secux/app-luna

SecuX Hardware Wallet LUNA API

Usage

import { SecuxLUNA } from "@secux/app-luna";

First, create instance of ITransport

Examples

  1. Get account address
const path = "m/44'/330'/0'/0/0";
const address = await device.getAddress(path);

/*

// transfer data to hardware wallet by custom transport layer
const data = SecuxLUNA.prepareAddress(path);
const response = await device.Exchange(data);
const address = SecuxLUNA.resolveAddress(response);

*/
  1. Sign transaction

    • transfer asset (MsgSend)
    const signer = {
        path: "m/44'/330'/0'/0/0",
        accountNumber: 12345,
        sequence: 1,
    };
    const params = {
        fee: { uluna: 3000 },
        gasLimit: 12345,
    };
    const send = new SecuxLUNA.MsgSend(from, to, { uluna: 1e6 });
    
    const { multi_command, serialized } = await device.sign(
        [signer],
        [send],
        params
    );
    const responseList = [];
    for (const data of multi_command) {
        const rsp = await device.Exchange(data);
        responseList.push(rsp);
    }
    const raw_tx = SecuxLUNA.resolveTransaction(responseList, serialized);
    
    /*
    
    // transfer data to hardware wallet by custom transport layer.
    const { commands, serialized } = SecuxLUNA.prepareSign(
        [
            { ...signer, publickey: "02acb4bc267db7774614bf6011c59929b006c2554386a3090baff0b3fc418ec044" }
        ],
        [send],
        params
    });
    const responseList = [];
    for (const data of commands) {
        const rsp = await device.Exchange(data);
        responseList.push(rsp);
    }
    const raw_tx = SecuxLUNA.resolveTransaction(responseList, serialized);
    
    */
    • execute contract
    const swap = new SecuxLUNA.MsgExecuteContract(
        "terra1amdttz2937a3dytmxmkany53pp6ma6dy4vsllv", 
        "terra156v8s539wtz0sjpn8y8a8lfg8fhmwa7fy22aff", 
        {
            swap: {
                offer_asset: {
                    amount: 1e6,
                    info: {
                        native_token: { denom: "uluna" },
                    },
                },
            },
        },
        { uluna: 1e6 }
    );
    
    const { multi_command, serialized } = await device.sign(
        [signer],
        [swap],
        params
    );
       
    // ... (same as above)
    • delegate
    const delegate = new SecuxLUNA.MsgDelegate(
        "terra1amdttz2937a3dytmxmkany53pp6ma6dy4vsllv", 
        "terravaloper1vf2209f5y7s4a66n5ng7wmup5gcc2kghhzy89w", 
        "1000000"
    );
    
    const { multi_command, serialized } = await device.sign(
        [signer],
        [delegate],
        params
    );
       
    // ... (same as above)
    • withdraw
    const withdraw = new SecuxLUNA.MsgWithdrawDelegatorReward(
        "terra1amdttz2937a3dytmxmkany53pp6ma6dy4vsllv", 
        "terravaloper1vf2209f5y7s4a66n5ng7wmup5gcc2kghhzy89w" 
    );
    
    const { multi_command, serialized } = await device.sign(
        [signer],
        [withdraw],
        params
    );
       
    // ... (same as above)
    • undelegate
    const undelegate = new SecuxLUNA.MsgUndelegate(
        "terra1amdttz2937a3dytmxmkany53pp6ma6dy4vsllv", 
        "terravaloper1vf2209f5y7s4a66n5ng7wmup5gcc2kghhzy89w",
        "1000000"
    );
    
    const { multi_command, serialized } = await device.sign(
        [signer],
        [undelegate],
        params
    );
       
    // ... (same as above)
    • redelegate
    const redelegate = new SecuxLUNA.MsgBeginRedelegate(
        "terra1amdttz2937a3dytmxmkany53pp6ma6dy4vsllv", 
        "terravaloper1vf2209f5y7s4a66n5ng7wmup5gcc2kghhzy89w",
        "terravaloper1vk20anceu6h9s00d27pjlvslz3avetkvnwmr35",
        "1000000"
    );
    
    const { multi_command, serialized } = await device.sign(
        [signer],
        [redelegate],
        params
    );
       
    // ... (same as above)

API Reference

LUNA package for SecuX device

Kind: global class

SecuxLUNA.addressConvert(publickey, type) ⇒ string

Convert secp256k1 publickey to LUNA address.

Returns: string - LUNA address

| Param | Type | Description | | --- | --- | --- | | publickey | string | Buffer | secp256k1 publickey | | type | AddressType | account/validator/pubkey address |

SecuxLUNA.prepareAddress(path) ⇒ communicationData

Prepare data for address generation.

Returns: communicationData - data for sending to device

| Param | Type | Description | | --- | --- | --- | | path | string | BIP32 path, ex: m/44'/330'/0'/0/0 |

SecuxLUNA.resolveAddress(response, type) ⇒ string

Generate address from response data.

Returns: string - LUNA address

| Param | Type | Description | | --- | --- | --- | | response | communicationData | data from device | | type | AddressType | account/validator/pubkey address |

SecuxLUNA.preparePublickey(path) ⇒ communicationData

Prepare data for secp256k1 publickey.

Returns: communicationData - data for sending to device

| Param | Type | Description | | --- | --- | --- | | path | string | BIP32 path, ex: m/44'/330'/0'/0/0 |

SecuxLUNA.resolvePublickey(response) ⇒ string

Resolve secp256k1 publickey from response data.

Returns: string - secp256k1 publickey (base64-encoded string)

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

SecuxLUNA.prepareXPublickey(path) ⇒ communicationData

Prepare data for xpub.

Returns: communicationData - data for sending to device

| Param | Type | Description | | --- | --- | --- | | path | string | BIP32 path, ex: m/44'/330'/0'/0/0 |

SecuxLUNA.resolveXPublickey(response, path) ⇒ string

Resolve xpub from response data.

Returns: string - xpub

| Param | Type | Description | | --- | --- | --- | | response | communicationData | data from device | | path | string | BIP32 path, ex: m/44'/330'/0'/0/0 |

SecuxLUNA.prepareSign(signers, messages, params) ⇒ prepared

Prepare data for signing.

| Param | Type | Description | | --- | --- | --- | | signers | Signer | array of signer | | messages | Array.<IMessage> | each message represents a instruction | | params | TxOption | |

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

Reslove signature from response data.

Returns: Array.<string> - signature array of base64-encoded string

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

SecuxLUNA.resolveTransaction(response, serialized) ⇒ string

Serialize transaction wtih signature for broadcasting.

Returns: string - signed raw transaction

| Param | Type | Description | | --- | --- | --- | | response | communicationData | Array.<communicationData> | data from device | | serialized | communicationData | |

SecuxLUNA.simulate(signers, messages, [params]) ⇒ string

Simulate a transaction for estimating gas.

Returns: string - simulated transaction

| Param | Type | Description | | --- | --- | --- | | signers | Array.<Signer> | array of signer | | messages | Array.<IMessage> | each message represents a instruction | | [params] | TxOption | |

AddressType : enum

Properties

| Name | Type | Description | | --- | --- | --- | | account | string | account | | validator | string | validator | | pubkey | string | pubkey |

Signer : object

Properties

| Name | Type | Description | | --- | --- | --- | | path | string | BIP32 path, ex: m/44'/330'/0'/0/0 | | publickey | string | Buffer | secp256k1 publickey from path | | sequence | number | the number of transactions sent from this address | | accountNumber | number | the account number from blockchain |

IMessage : interface

Properties

| Name | Type | | --- | --- | | toAmino | function | | toData | function | | toProto | function | | packAny | function |

TxOption : object

Properties

| Name | Type | Description | | --- | --- | --- | | fee | string | Coins | the amount of coins to be paid as a fee | | gasLimit | number | the maximum gas that can be used in transaction processing | | [chainId] | string | blockchain network identifier | | [memo] | string | | | [timeoutHeight] | string | timeout height relative to the current block height | | [payer] | string | payer’s account address | | [granter] | string | granter’s account address |

prepared : object

Properties

| Name | Type | Description | | --- | --- | --- | | commands | Array.<communicationData> | data for sending to device | | serialized | communicationData | unsigned raw transaction |


© 2018-22 SecuX Technology Inc.

authors: [email protected]