zano_web3 3.0.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/zanoWallet.ts +12 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zano_web3",
3
- "version": "3.0.0",
3
+ "version": "3.2.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/zanoWallet.ts CHANGED
@@ -31,6 +31,7 @@ interface WalletCredentials {
31
31
  nonce: string;
32
32
  signature: string;
33
33
  publicKey: string;
34
+ address: string;
34
35
  }
35
36
 
36
37
  class ZanoWallet {
@@ -83,6 +84,10 @@ class ZanoWallet {
83
84
  }
84
85
  }
85
86
 
87
+ cleanWalletCredentials() {
88
+ this.setWalletCredentials(undefined);
89
+ }
90
+
86
91
  async connect() {
87
92
 
88
93
  if (this.params.beforeConnect) {
@@ -111,7 +116,9 @@ class ZanoWallet {
111
116
 
112
117
  const existingWallet = this.params.useLocalStorage ? this.getSavedWalletCredentials() : undefined;
113
118
 
114
- if (existingWallet) {
119
+ const existingWalletValid = existingWallet && existingWallet.address === walletData.address;
120
+
121
+ if (existingWalletValid) {
115
122
  nonce = existingWallet.nonce;
116
123
  signature = existingWallet.signature;
117
124
  publicKey = existingWallet.publicKey;
@@ -142,7 +149,7 @@ class ZanoWallet {
142
149
  signature,
143
150
  pkey: publicKey,
144
151
  message: nonce,
145
- isSavedData: !!existingWallet
152
+ isSavedData: existingWalletValid
146
153
  }
147
154
 
148
155
  if (this.params.onLocalConnectEnd) {
@@ -171,11 +178,12 @@ class ZanoWallet {
171
178
  return this.handleError({ message: result.error });
172
179
  }
173
180
 
174
- if (!existingWallet && this.params.useLocalStorage) {
181
+ if (!existingWalletValid && this.params.useLocalStorage) {
175
182
  this.setWalletCredentials({
176
183
  publicKey,
177
184
  signature,
178
- nonce
185
+ nonce,
186
+ address: walletData.address
179
187
  });
180
188
  }
181
189