-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Brainstorm * Basic idea * Add encrypted db * Seems to work * Define types in migration, refactor * where in stronghold is the data? * Make stronghold snapshot migration work * Add migration to bindings, add get_chrysalis_data() * Save chrysalis data from snapshot in db * Address some TODOs * Address todos * Add chrysalis-backup-work-factor-0.stronghold * Fix wasm * Don't error on ClientDataNotPresent * Clippy * Address review comments * Remove extra function * Update bindings/nodejs/CHANGELOG.md Co-authored-by: Thibault Martinez <[email protected]> * Remove `from` * Clippy * Changelog * Update sdk/src/wallet/storage/constants.rs * Move function to storage * Address review comments * Address review comments * Review suggestions * Address review comments * Add db_encryption_key to Rust, export migrateDbChrysalisToStardust and add nodejs example * Single import, lint * Address review comments --------- Co-authored-by: Thibault Martinez <[email protected]> Co-authored-by: Thibault Martinez <[email protected]>
- Loading branch information
1 parent
5cfc4aa
commit ce77da1
Showing
41 changed files
with
982 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
bindings/nodejs/examples/wallet/migrate-db-chrysalis-to-stardust.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2023 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { WalletOptions, Wallet, migrateDbChrysalisToStardust } from '@iota/sdk'; | ||
require('dotenv').config({ path: '.env' }); | ||
|
||
// Run with command: | ||
// yarn run-example wallet/migrate-db-chrysalis-to-stardust.ts | ||
|
||
const walletDbPath = './chrysalis-db'; | ||
|
||
async function run() { | ||
const { initLogger } = require('@iota/sdk'); | ||
initLogger({ | ||
name: './wallet.log', | ||
levelFilter: 'debug', | ||
targetExclusions: ['h2', 'hyper', 'rustls'], | ||
}); | ||
if (!process.env.NODE_URL) { | ||
throw new Error('.env NODE_URL is undefined, see .env.example'); | ||
} | ||
if (!process.env.STRONGHOLD_PASSWORD) { | ||
throw new Error( | ||
'.env STRONGHOLD_PASSWORD is undefined, see .env.example', | ||
); | ||
} | ||
|
||
migrateDbChrysalisToStardust(walletDbPath, 'password'); | ||
|
||
const walletOptions: WalletOptions = { | ||
storagePath: walletDbPath, | ||
clientOptions: { | ||
nodes: [process.env.NODE_URL], | ||
}, | ||
secretManager: { | ||
stronghold: { | ||
snapshotPath: walletDbPath + 'wallet.stronghold', | ||
password: process.env.STRONGHOLD_PASSWORD, | ||
}, | ||
}, | ||
}; | ||
console.log(walletOptions); | ||
const wallet = new Wallet(walletOptions); | ||
|
||
// Accounts migrated from the Chrysalis db | ||
const accounts = await wallet.getAccounts(); | ||
console.log(accounts); | ||
|
||
const historicChrysalisData = await wallet.getChrysalisData(); | ||
console.log(historicChrysalisData); | ||
} | ||
|
||
run().then(() => process.exit()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.