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

@coolwallet/terra

v1.2.5

Published

Coolwallet Terra sdk

Downloads

104

Readme

CoolWallet Terra SDK

Version

Typescript library with support for the integration of Terra for third party application, include the functionalities of generation of addresses and signed transactions.

What's new?

Added CHAIN_ID.CLASSIC, DENOMTYPE_CLASSIC and TOKENTYPE_CLASSIC for Terra Classic. CHAIN_ID.MAIN, DENOMTYPE and TOKENTYPE are used for Terra 2.0.

Limitation

  • Transaction memo is limited to 128 Bytes.
  • Smart contract and CW20 token for Terra 2.0 is still under development.

Install

npm i @coolwallet/terra

Usage

import Terra, { CHAIN_ID, DENOMTYPE, SignDataType } from '@coolwallet/terra';
import { crypto } from '@coolwallet/core';
import { createTransport } from '@coolwallet/transport-web-ble';

const coinTerra = new Terra();

const transport = await createTransport();

const { privateKey: appPrivateKey } = crypto.key.generateKeyPair();

const appId = 'appId that had been registered by wallet';

const addressIndex = 0;

const address = await coinTerra.getAddress(transport, appPrivateKey, appId, addressIndex);

// Normal transfer with signTransferTransaction
const transaction = {
  chainId: CHAIN_ID.MAIN,
  accountNumber: 1, // account_number from rpc
  sequence: 1, // sequence from rpc
  fromAddress: address,
  toAddress: 'toAddress'
  coin: {
    denom: DENOMTYPE.LUNA,
    amount: 1000 // transaction amount
  },
  fee: {
    gas_limit: 100000,
    denom: DENOMTYPE.LUNA,
    amount: 5000,
  },
  memo: 'test signature',
};

const signTxData: SignDataType = {
  appPrivateKey: props.appPrivateKey,
  appId: props.appId,
  addressIndex: 0,
  transaction,
  transport,
};

const signedTx = await coinTerra.signTransferTransaction(signTxData);

// Normal transfer with signTransaction

const transaction = {
  chainId: CHAIN_ID.MAIN,
  accountNumber: 1, // account_number from rpc
  sequence: 1, // sequence from rpc
  msgs: [
    {
      '@type': '/cosmos.bank.v1beta1.MsgSend',
      amount: [{ 
        amount: 1000, // transaction amount, 
        denom: 'uluna'
      }],
      from_address: address,
      to_address: 'toAddress',
    },
  ],
  fee: {
    amount: [{ amount: '5000000', denom: 'uluna' }],
    gas_limit: '100000',
    granter: '',
    payer: '',
  },
  memo: 'test signature',
};
const signTxData = {
  appPrivateKey: props.appPrivateKey,
  appId: props.appId,
  addressIndex: 0,
  transaction,
  transport,
};

// This signedTx should be same as signedTx above.
const signedTx = await coinTerra.signTransaction(signTxData);

For more example, please refer to tests/index.spec.ts.

Methods

getAddress

Description

The address generated is compatible to BIP44 with account and change set to 0, which means calling getAddress with addressIndex = i will get the address of folllowing BIP44 path:

m/44'/330'/0'/0/{i}

In the design of current hardware, we only support path m/44'/330'/0'/0/{i} for speed optimization. This might change in the future and we will then open a more general interface to deal with custom path.

async getAddress(
    transport: types.Transport,
    appPrivateKey: string,
    appId: string,
    addressIndex: number
): Promise<string>

signTransaction

Description

Sign transaction with multiple msgs, useful when user cannot specify which signing function should be called.

async signTransaction(signData: types.SignMsgBlindType): Promise<string>

signTransferTransaction

Description

Sign single transfer transaction with CoolWallet Pro.

async signTransferTransaction(signData: types.SignMsgSendType): Promise<string>;

signDelegateTransaction

Description

Sign single delegate transaction with CoolWallet Pro.

async signDelegateTransaction(signData: types.SignMsgSendType): Promise<string>;

signUndelegateTransaction

Description

Sign single undelegate transaction with CoolWallet Pro.

async signUndelegateTransaction(signData: types.SignMsgSendType): Promise<string>;

signWithdrawTransaction

Description

Sign single withdraw transaction with CoolWallet Pro.

async signWithdrawTransaction(signData: types.SignMsgSendType): Promise<string>;

signMsgExecuteContractTransaction

Description

Sign single MsgExecuteContract transaction with CoolWallet Pro.

async signMsgExecuteContractTransaction(signData: types.SignMsgSendType): Promise<string>;

signMsgCW20Transaction

Description

Sign single MsgExecuteContract transaction with CoolWallet Pro.

async signMsgCW20Transaction(signData: types.SignMsgSendType): Promise<string>;