0.2.0 • Published 4 years ago

fabric-wallet-migration v0.2.0

Weekly downloads
233
License
Apache-2.0
Repository
github
Last release
4 years ago

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