Skip to content

Latest commit

 

History

History
24 lines (19 loc) · 920 Bytes

README.md

File metadata and controls

24 lines (19 loc) · 920 Bytes

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);
        }
    }
}