# @nekoproject/wallets

A complete crypto wallet base support for cross-chain

Table of contents
=================
<!--ts-->
  * [Re-Build](#build)
  * [Install](#install)
  * [Documents](#documents)
    * [Load or create wallet](#load-or-create-wallet)
    * [Getter](#getter)
  * [Notice](#notice)
<!--te-->

Build
========
Re-build project from scratch
  - Clean project
    ```bash
      npm run clean
    ```
  - Build
    ```bash
      npm run build
    ```
  - Unit test
    ```bash
      npm run test:cover
    ```
Install
=======
  Install `@nekoproject/wallets` with `npm`
  ```bash
    npm i @nekoproject/wallets
  ```
  Import
  ```ts
    import { Wallet, SPLWallet } from '@nekoproject/wallets'
  ```
Documents
=========
Solana Keypair defined in `@nekoproject/wallets`
```ts
 interface SolanaKeypair {
   publicKey: web3.PublicKey;
   secretKey: Uint8Array;
 }
```
### Wallet methods
 #### Load or Create wallet
   - Generate new wallet
       ```ts
         let wallet: Wallet;
         // generate new solana wallet
         wallet = SPLWallet.generateWallet()
       ```
   - Load wallet from seed pharse
       ```ts
         let wallet: Wallet;
         // load solana wallet
         const mnemonic = 'seeds pharse'
         wallet = SPLWallet.fromMnemonic(mnemonic)
       ```
   - Load wallet from secret Key
       ```ts
         import fs from 'mz/fs';
         const filePath = path/to/json/secretKey/file
         const secretKeyString = await fs.readFile(filePath, { encoding: 'utf8' });
         const secretKey = Uint8Array.from(JSON.parse(secretKeyString));
         let wallet: Wallet;
         // load solana wallet
         wallet = SPLWallet.fromSecretKey(secretKey)
       ```
   - Load wallet from string secret Key
       ```ts
         const secretStringKey = '2PU5z5WF9oteEcMfrKswairtm4H69XakqPFNRVBoadw4uTFEPDtUWzp6YirXtVSuybJ2kYVchCPxKisbdTRurcMM'
         let wallet: Wallet;
         // load solana wallet
         wallet = SPLWallet.fromStringSecretKey(secretStringKey)
       ```
 #### Getter 
   - Signer
       ```ts
           const signer: SolanaKeypair = wallet.signer
       ```
   - Address
       ```ts
          const publicKey = wallet.address
       ```

Notice
========
# Ref
