Giter VIP home page Giter VIP logo

wallet-core's Introduction

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

wallet-core's People

Contributors

beemi avatar monokh avatar skeremidchiev avatar kraikov avatar github-actions[bot] avatar tima-t avatar jennievon avatar andonmitev avatar adilmezghouti avatar koderholic avatar bradleysuira avatar amritkumarj avatar johannafransn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.