Skip to content

Commit 23431ad

Browse files
committed
add decryptKey
1 parent c0c66e5 commit 23431ad

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@meshsdk/web3-sdk",
3-
"version": "0.0.27",
3+
"version": "0.0.28",
44
"description": "SDK for Mesh Web3 Services",
55
"main": "./dist/index.cjs",
66
"browser": "./dist/index.js",

src/sdk/wallet-developer-controlled/index.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class WalletDeveloperControlled {
2626
* @param {Object} [options] - Optional parameters for wallet creation.
2727
* @param {string} [options.tag] - An optional tag to associate with the wallet.
2828
*
29-
* @returns {Promise<MeshWallet>} A promise that resolves to the created wallet instance.
29+
* @returns {Promise<Web3ProjectWallet>} A promise that resolves to the created wallet instance.
3030
*
3131
* @throws {Error} If the project's public key is not found.
3232
* @throws {Error} If the wallet creation request to the backend fails.
@@ -66,7 +66,7 @@ export class WalletDeveloperControlled {
6666
// create wallet
6767

6868
const web3Wallet: Web3ProjectWallet = {
69-
id: uuidv4(), // todo, to be removed should be generated at DB
69+
id: uuidv4(),
7070
key: encryptedMnemonic,
7171
tags: tags || [],
7272
projectId: this.sdk.projectId,
@@ -110,12 +110,16 @@ export class WalletDeveloperControlled {
110110
* Retrieves a wallet by its ID and decrypts the key with the project's private key.
111111
*
112112
* @param walletId - The unique identifier of the wallet to retrieve.
113+
* @param networkId - The network ID associated with the wallet (0 or 1).
114+
* @param decryptKey - A boolean indicating whether to decrypt the wallet key (default: false).
115+
*
113116
* @returns A promise that resolves to an initialized `MeshWallet` instance.
114117
* @throws Will throw an error if the private key is not found or if the wallet retrieval fails.
115118
*/
116119
async getWallet(
117120
walletId: string,
118-
networkId: 0 | 1
121+
networkId: 0 | 1,
122+
decryptKey = false
119123
): Promise<{
120124
info: Web3ProjectWallet;
121125
wallet: MeshWallet;
@@ -136,6 +140,10 @@ export class WalletDeveloperControlled {
136140
encryptedDataJSON: web3Wallet.key,
137141
});
138142

143+
if (decryptKey) {
144+
web3Wallet.key = mnemonic;
145+
}
146+
139147
const wallet = new MeshWallet({
140148
networkId: networkId,
141149
key: {

0 commit comments

Comments
 (0)