fabric-wallet-migration
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

This module provides a custom WalletStore implementation that allows a Hyperledger Fabric version 1.4 wallet to be used with the Hyperledger Fabric version 2.0 SDK for Node.

Example migration from v1.4 to v2 wallet format

import * as WalletMigration from "fabric-wallet-migration";
import { Wallet, Wallets } from "fabric-network"; // fabric-network v2
 
async function migrateWallet(oldWalletDirectory: string, newWalletDirectory: string) {
    const walletStore = await WalletMigration.newFileSystemWalletStore(oldWalletDirectory);
    const oldWallet = new Wallet(walletStore);
 
    const newWallet = await Wallets.newFileSystemWallet(newWalletDirectory);
 
    const identityLabels = await oldWallet.list();
    for (const label of identityLabels) {
        const identity = await oldWallet.get(label);
        if (identity) {
            await newWallet.put(label, identity);
        }
    }
}

Readme

Keywords

none

Package Sidebar

Install

npm i fabric-wallet-migration

Weekly Downloads

13

Version

0.2.0

License

Apache-2.0

Unpacked Size

27.7 kB

Total Files

17

Last publish

Collaborators

  • bestbeforetoday