@@ -12,12 +12,12 @@ SpringWallet - A simple wallet for flexible identity management for your fronten
12
12
13
13
1 . Install ` springwallet ` with ` npm ` .
14
14
15
- ``` npm install springwallet --save ``` or ``` yarn add springwallet ```
15
+ ``` npm install @springrole/ springwallet --save ``` or ``` yarn add @springrole/ springwallet ```
16
16
17
17
2 . Import springwallet into your project.
18
18
19
19
``` js
20
- import SpringWallet from ' @springrole/springwallet' ;
20
+ import { SpringWallet } from ' @springrole/springwallet' ;
21
21
```
22
22
3. Generate 12 words random mnemonic
23
23
@@ -28,7 +28,7 @@ SpringWallet - A simple wallet for flexible identity management for your fronten
28
28
29
29
` ` ` js
30
30
async function createWallet(plainTextMnemonic, password) {
31
- const encryptedMnemonic = await encryptMnemonic(plainTextMnemonic, password); // encrypting mnemonic
31
+ const encryptedMnemonic = await SpringWallet. encryptMnemonic(plainTextMnemonic, password); // encrypting mnemonic
32
32
const wallet = await SpringWallet.initializeWalletFromMnemonic(plainTextMnemonic); // initializing wallet
33
33
const address = wallet.getChecksumAddressString(); // wallet address
34
34
const key = wallet.getPrivateKey().toString('hex'); // private key
@@ -51,7 +51,7 @@ SpringWallet - A simple wallet for flexible identity management for your fronten
51
51
async function unlockWallet(encryptedMnemonic, password) {
52
52
let plainTextMnemonic;
53
53
try {
54
- plainTextMnemonic = await decryptMnemonic(encryptedMnemonic, password);
54
+ plainTextMnemonic = await SpringWallet. decryptMnemonic(encryptedMnemonic, password);
55
55
} catch {
56
56
return false;
57
57
}
@@ -78,10 +78,9 @@ SpringWallet - A simple wallet for flexible identity management for your fronten
78
78
79
79
```js
80
80
async function changeWalletPassword(address, encryptedMnemonic, oldPassword, newPassword) {
81
- const mnemonicPhrase = await decryptMnemonic(encryptedMnemonic, oldPassword);
82
- const newEncryptedMnemonic = await encryptMnemonic(mnemonicPhrase, newPassword);
83
- const status = await updateEncryptedMnemonic(address, newEncryptedMnemonic);
84
- return status;
81
+ const mnemonicPhrase = await SpringWallet.decryptMnemonic(encryptedMnemonic, oldPassword);
82
+ const newEncryptedMnemonic = await SpringWallet.encryptMnemonic(mnemonicPhrase, newPassword);
83
+ return true;
85
84
}
86
85
```
87
86
**NOTE** This will decrypt mnemonic with old password and reencrypts it using new password which will create new encrypted mnemonic
@@ -90,11 +89,10 @@ SpringWallet - A simple wallet for flexible identity management for your fronten
90
89
91
90
```js
92
91
async function resetWalletPassword(plainTextMnemonic, newPassword) {
93
- const newEncryptedMnemonic = await encryptMnemonic(plainTextMnemonic, newPassword);
92
+ const newEncryptedMnemonic = await SpringWallet. encryptMnemonic(plainTextMnemonic, newPassword);
94
93
const wallet = await SpringWallet.initializeWalletFromMnemonic(plainTextMnemonic);
95
94
const walletAddress = wallet.getChecksumAddressString();
96
- const status = await updateEncryptedMnemonic(walletAddress, newEncryptedMnemonic);
97
- return status;
95
+ return true;
98
96
}
99
97
```
100
98
0 commit comments