Skip to content

debridge-finance/liquality-wallet-core

 
 

Repository files navigation

Wallet Core

 _       __      ____     __     ______              
| |     / /___ _/ / /__  / /_   / ____/___  ________ 
| | /| / / __ `/ / / _ \/ __/  / /   / __ \/ ___/ _ \
| |/ |/ / /_/ / / /  __/ /_   / /___/ /_/ / /  /  __/
|__/|__/\__,_/_/_/\___/\__/   \____/\____/_/   \___/ 

master

Wallet Core is a cryptocurrency wallet library in Typescript. It provides an abstracted interface that handles all the necessary internals of a muilti chain wallet. Featuring:

  • State management
  • Seed management and security
  • Account management
  • Blockchain communication under a common interface, powered by Chainify
  • Retriving balances
  • Sending transactions
  • Intra and cross chain swaps supporting a host of decentralised exchanges - Liquality, Thorchain, Uniswap, 1inch, Sovryn, Astroport etc.
  • Hardware wallet support

Install

npm install @liquality/wallet-core

yarn add @liquality/wallet-core

Usage

import { setupWallet } from '@liquality/wallet-core';
import defaultOptions from '@liquality/wallet-core/dist/walletOptions/defaultOptions'; // Default options

const wallet = setupWallet({
  ...defaultOptions,
});

(async () => {
  await wallet.dispatch.createWallet({
    key: 'satoshi',
    mnemonic: 'never gonna give you up never gonna let you down never gonna',
    imported: true,
  });
  await wallet.dispatch.unlockWallet({ key: 'satoshi' });
  await wallet.dispatch.changeActiveNetwork({ network: 'mainnet' });
  console.log(wallet.state); // State will include default accounts
})();

Options

See WalletOptions in types

  {
    initialState?: RootState; // The initial state of the wallet
    crypto: { // Implmenetation for platform specific crypto
      pbkdf2(password: string, salt: string, iterations: number, length: number, digest: string): Promise<string>;
      encrypt(value: string, key: string): Promise<any>;
      decrypt(value: any, key: string): Promise<any>;
    };
    // Handle notifications
    createNotification(notification: Notification): void;
    ...
  }

Examples

How to run tests

Integration tests are written in Jest.

yarn test

Publish to npm

  • GitHub actions will publish to NPM automatically after a successful pull request merge, follow the below steps to publish to NPM.
yarn changeset

Alt text

Alt text

Under changeset you will notice a new markdown file (its name is randomly generated), with the change-type and summary.

Alt text

Push the file along with the rest of the changes, and let the GitHub actions do the heavy-lifting for you. As for the markdown file, it will be deleted by our GitHub action when the entry that's referencing is added to the changelog.

Alt text

How to do prerelease version from a branch

  • Create a changed file with the version you want to release, for example v0.1.0-alpha.1
 yarn changeset

Note: Ensure pre.json file is present in the .changeset directory of the project, then create a pull request with the changeset file and merge it to the develop branch.

If pre.json file is not present, create a new file with the following command & it will to the .changeset directory of the project,push the changes and create a pull request with the changeset file and merge it to the develop branch.

yarn changeset pre enter next

About

Liquality wallet core library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 99.7%
  • Other 0.3%