pwc-sdk-wallet 0.6.9 → 0.7.1

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.
package/dist/Vault.js CHANGED
@@ -48,12 +48,45 @@ class Vault {
48
48
  * @throws Error if mnemonic generation or keyring initialization fails
49
49
  */
50
50
  static async createNew(password, chainType = 'evm', config) {
51
+ // ADD LOG HERE: Input parameters
52
+ console.log('[VAULT_CREATE] Input:', {
53
+ password: password,
54
+ passwordLength: password.length,
55
+ chainType,
56
+ config: config,
57
+ hasConfig: !!config,
58
+ configKeys: config ? Object.keys(config) : []
59
+ });
51
60
  const mnemonic = EncryptionService_1.EncryptionService.generateMnemonic();
52
61
  if (chainType === 'solana') {
53
62
  const solanaKeyring = new SolanaKeyring_1.SolanaKeyring(mnemonic);
54
63
  const vault = new Vault([solanaKeyring], config);
55
64
  vault.chainId = 'solana'; // Set Solana chain ID
56
65
  const encryptedVault = await vault.encrypt(password);
66
+ // ADD LOG HERE: After encrypt
67
+ console.log('[VAULT_CREATE] Encrypted output:', {
68
+ encryptedData: encryptedVault.encryptedData,
69
+ encryptedDataLength: encryptedVault.encryptedData.length,
70
+ iv: encryptedVault.iv,
71
+ ivLength: encryptedVault.iv.length,
72
+ salt: encryptedVault.salt,
73
+ saltLength: encryptedVault.salt.length
74
+ });
75
+ // ADD LOG HERE: Decrypt để so sánh
76
+ const decryptedString = await EncryptionService_1.EncryptionService.decrypt(encryptedVault, password);
77
+ console.log('[VAULT_CREATE] Decrypted content:', {
78
+ decryptedString: decryptedString,
79
+ decryptedStringLength: decryptedString.length,
80
+ isJsonValid: (() => {
81
+ try {
82
+ JSON.parse(decryptedString);
83
+ return true;
84
+ }
85
+ catch {
86
+ return false;
87
+ }
88
+ })()
89
+ });
57
90
  return { vault, encryptedVault };
58
91
  }
59
92
  else {
@@ -62,6 +95,30 @@ class Vault {
62
95
  const vault = new Vault([hdKeyring], config);
63
96
  vault.chainId = '1'; // Set Ethereum mainnet as default
64
97
  const encryptedVault = await vault.encrypt(password);
98
+ // ADD LOG HERE: After encrypt
99
+ console.log('[VAULT_CREATE] Encrypted output:', {
100
+ encryptedData: encryptedVault.encryptedData,
101
+ encryptedDataLength: encryptedVault.encryptedData.length,
102
+ iv: encryptedVault.iv,
103
+ ivLength: encryptedVault.iv.length,
104
+ salt: encryptedVault.salt,
105
+ saltLength: encryptedVault.salt.length
106
+ });
107
+ // ADD LOG HERE: Decrypt để so sánh
108
+ const decryptedString = await EncryptionService_1.EncryptionService.decrypt(encryptedVault, password);
109
+ console.log('[VAULT_CREATE] Decrypted content:', {
110
+ decryptedString: decryptedString,
111
+ decryptedStringLength: decryptedString.length,
112
+ isJsonValid: (() => {
113
+ try {
114
+ JSON.parse(decryptedString);
115
+ return true;
116
+ }
117
+ catch {
118
+ return false;
119
+ }
120
+ })()
121
+ });
65
122
  return { vault, encryptedVault };
66
123
  }
67
124
  }
@@ -98,18 +155,138 @@ class Vault {
98
155
  * @throws Error if password is incorrect or decryption fails
99
156
  */
100
157
  static async load(password, encryptedVault, config) {
158
+ // ADD LOG HERE: Input parameters
159
+ console.log('[VAULT_LOAD] Input:', {
160
+ password: password,
161
+ passwordLength: password.length,
162
+ encryptedData: encryptedVault.encryptedData,
163
+ encryptedDataLength: encryptedVault.encryptedData.length,
164
+ iv: encryptedVault.iv,
165
+ ivLength: encryptedVault.iv.length,
166
+ salt: encryptedVault.salt,
167
+ saltLength: encryptedVault.salt.length,
168
+ config: config,
169
+ hasConfig: !!config,
170
+ configKeys: config ? Object.keys(config) : []
171
+ });
101
172
  const decryptedString = await EncryptionService_1.EncryptionService.decrypt(encryptedVault, password);
102
- const serializedKeyrings = JSON.parse(decryptedString);
173
+ // ADD LOG HERE: After decrypt
174
+ console.log('[VAULT_LOAD] Decrypted content:', {
175
+ decryptedString: decryptedString,
176
+ decryptedStringLength: decryptedString.length,
177
+ isJsonValid: (() => {
178
+ try {
179
+ JSON.parse(decryptedString);
180
+ return true;
181
+ }
182
+ catch {
183
+ return false;
184
+ }
185
+ })()
186
+ });
187
+ // ADD LOG HERE: Compare with expected format
188
+ const expectedFormat = '[{"type":"HD","mnemonic":"...","accounts":["..."]}]';
189
+ console.log('[VAULT_LOAD] Expected format check:', {
190
+ startsWithBracket: decryptedString.startsWith('['),
191
+ endsWithBracket: decryptedString.endsWith(']'),
192
+ containsType: decryptedString.includes('"type"'),
193
+ containsMnemonic: decryptedString.includes('"mnemonic"'),
194
+ containsAccounts: decryptedString.includes('"accounts"'),
195
+ expectedFormat: expectedFormat
196
+ });
197
+ let serializedKeyrings;
198
+ try {
199
+ serializedKeyrings = JSON.parse(decryptedString);
200
+ }
201
+ catch (error) {
202
+ console.error('[VAULT_LOAD] FAILED HERE: JSON parse failed');
203
+ console.error('[VAULT_LOAD] FAILED DATA:', {
204
+ decryptedString: decryptedString,
205
+ decryptedStringLength: decryptedString.length,
206
+ error: error instanceof Error ? error.message : String(error)
207
+ });
208
+ // ADD LOG HERE: Analyze what's wrong with the data
209
+ console.error('[VAULT_LOAD] DATA ANALYSIS:', {
210
+ isNull: decryptedString === null,
211
+ isUndefined: decryptedString === undefined,
212
+ isEmpty: decryptedString === '',
213
+ isString: typeof decryptedString === 'string',
214
+ firstChar: decryptedString ? decryptedString.charAt(0) : 'N/A',
215
+ lastChar: decryptedString ? decryptedString.charAt(decryptedString.length - 1) : 'N/A',
216
+ containsSpecialChars: decryptedString ? /[^\x00-\x7F]/.test(decryptedString) : false,
217
+ containsControlChars: decryptedString ? /[\x00-\x1F\x7F]/.test(decryptedString) : false
218
+ });
219
+ throw error;
220
+ }
221
+ // ADD LOG HERE: After JSON parse
222
+ console.log('[VAULT_LOAD] Parsed keyrings:', {
223
+ keyringCount: serializedKeyrings.length,
224
+ keyringTypes: serializedKeyrings.map((k) => k.type),
225
+ keyringDetails: serializedKeyrings.map((k) => ({
226
+ type: k.type,
227
+ hasMnemonic: !!k.mnemonic,
228
+ hasAccounts: !!k.accounts,
229
+ accountsCount: k.accounts ? k.accounts.length : 0
230
+ }))
231
+ });
232
+ // ADD LOG HERE: Validate keyring structure
233
+ serializedKeyrings.forEach((keyring, index) => {
234
+ console.log(`[VAULT_LOAD] Keyring ${index} validation:`, {
235
+ hasType: !!keyring.type,
236
+ type: keyring.type,
237
+ hasMnemonic: !!keyring.mnemonic,
238
+ mnemonicLength: keyring.mnemonic ? keyring.mnemonic.length : 0,
239
+ hasAccounts: !!keyring.accounts,
240
+ accountsLength: keyring.accounts ? keyring.accounts.length : 0,
241
+ isAccountsArray: Array.isArray(keyring.accounts),
242
+ expectedFields: ['type', 'mnemonic', 'accounts'],
243
+ actualFields: Object.keys(keyring)
244
+ });
245
+ });
103
246
  const keyrings = [];
104
247
  for (const sKeyring of serializedKeyrings) {
105
- if (sKeyring.type === 'HD') {
106
- keyrings.push(await HDKeyring_1.HDKeyring.deserialize(sKeyring));
107
- }
108
- else if (sKeyring.type === 'Simple') {
109
- keyrings.push(SimpleKeyring_1.SimpleKeyring.deserialize(sKeyring));
248
+ try {
249
+ if (sKeyring.type === 'HD') {
250
+ keyrings.push(await HDKeyring_1.HDKeyring.deserialize(sKeyring));
251
+ }
252
+ else if (sKeyring.type === 'Simple') {
253
+ keyrings.push(SimpleKeyring_1.SimpleKeyring.deserialize(sKeyring));
254
+ }
255
+ else if (sKeyring.type === 'Solana') {
256
+ keyrings.push(await SolanaKeyring_1.SolanaKeyring.deserialize(sKeyring));
257
+ }
258
+ else {
259
+ console.error('[VAULT_LOAD] FAILED HERE: Unknown keyring type');
260
+ console.error('[VAULT_LOAD] FAILED DATA:', {
261
+ keyringType: sKeyring.type,
262
+ keyringData: sKeyring
263
+ });
264
+ throw new Error(`Unknown keyring type: ${sKeyring.type}`);
265
+ }
110
266
  }
111
- else if (sKeyring.type === 'Solana') {
112
- keyrings.push(await SolanaKeyring_1.SolanaKeyring.deserialize(sKeyring));
267
+ catch (error) {
268
+ console.error('[VAULT_LOAD] FAILED HERE: Keyring deserialize failed');
269
+ console.error('[VAULT_LOAD] FAILED DATA:', {
270
+ keyringType: sKeyring.type,
271
+ keyringData: sKeyring,
272
+ error: error instanceof Error ? error.message : String(error)
273
+ });
274
+ // ADD LOG HERE: Analyze keyring data issues
275
+ console.error('[VAULT_LOAD] KEYRING DATA ANALYSIS:', {
276
+ keyringType: sKeyring.type,
277
+ hasType: !!sKeyring.type,
278
+ hasMnemonic: !!sKeyring.mnemonic,
279
+ hasAccounts: !!sKeyring.accounts,
280
+ mnemonicType: typeof sKeyring.mnemonic,
281
+ accountsType: typeof sKeyring.accounts,
282
+ isAccountsArray: Array.isArray(sKeyring.accounts),
283
+ expectedFields: sKeyring.type === 'HD' ? ['type', 'mnemonic', 'accounts'] : ['type', 'privateKey'],
284
+ actualFields: Object.keys(sKeyring),
285
+ missingFields: sKeyring.type === 'HD'
286
+ ? ['type', 'mnemonic', 'accounts'].filter(field => !sKeyring[field])
287
+ : ['type', 'privateKey'].filter(field => !sKeyring[field])
288
+ });
289
+ throw error;
113
290
  }
114
291
  }
115
292
  const vault = new Vault(keyrings, config);
@@ -291,9 +468,51 @@ class Vault {
291
468
  * @throws Error if encryption fails
292
469
  */
293
470
  async encrypt(password) {
471
+ // ADD LOG HERE: Before serialize
472
+ console.log('[VAULT_ENCRYPT] Before serialize:', {
473
+ keyringCount: this.keyrings.length,
474
+ keyringTypes: this.keyrings.map(k => k.type)
475
+ });
294
476
  const serializedKeyrings = this.keyrings.map(k => k.serialize());
295
- const jsonString = JSON.stringify(serializedKeyrings);
296
- return EncryptionService_1.EncryptionService.encrypt(jsonString, password);
477
+ // ADD LOG HERE: After serialize
478
+ console.log('[VAULT_ENCRYPT] Serialized keyrings:', {
479
+ serializedCount: serializedKeyrings.length,
480
+ serializedTypes: serializedKeyrings.map(k => k.type)
481
+ });
482
+ let jsonString;
483
+ try {
484
+ jsonString = JSON.stringify(serializedKeyrings);
485
+ }
486
+ catch (error) {
487
+ console.error('[VAULT_ENCRYPT] FAILED HERE: JSON stringify failed');
488
+ console.error('[VAULT_ENCRYPT] FAILED DATA:', {
489
+ serializedKeyrings: serializedKeyrings,
490
+ error: error instanceof Error ? error.message : String(error)
491
+ });
492
+ throw error;
493
+ }
494
+ // ADD LOG HERE: JSON string
495
+ console.log('[VAULT_ENCRYPT] JSON string:', {
496
+ jsonString: jsonString,
497
+ jsonStringLength: jsonString.length,
498
+ isJsonValid: (() => {
499
+ try {
500
+ JSON.parse(jsonString);
501
+ return true;
502
+ }
503
+ catch {
504
+ return false;
505
+ }
506
+ })()
507
+ });
508
+ // ADD LOG HERE: After encrypt
509
+ const result = await EncryptionService_1.EncryptionService.encrypt(jsonString, password);
510
+ console.log('[VAULT_ENCRYPT] Encrypted result:', {
511
+ encryptedDataLength: result.encryptedData.length,
512
+ ivLength: result.iv.length,
513
+ saltLength: result.salt.length
514
+ });
515
+ return result;
297
516
  }
298
517
  /**
299
518
  * Retrieves the private key for a specific address from the appropriate keyring.
@@ -67,7 +67,7 @@ function getPBKDF2Iterations() {
67
67
  // }
68
68
  // React Native environment - use production values by default for security
69
69
  // Mobile apps should be considered production by default
70
- return 4000;
70
+ return 6000;
71
71
  }
72
72
  /**
73
73
  * Network configuration constants
@@ -73,6 +73,16 @@ class EncryptionService {
73
73
  * @throws Error if encryption fails
74
74
  */
75
75
  static async encrypt(data, password) {
76
+ // ADD LOG HERE: Input parameters
77
+ console.log('[ENCRYPTION_ENCRYPT] Input:', {
78
+ data: data,
79
+ dataLength: data.length,
80
+ password: password,
81
+ passwordLength: password.length
82
+ });
83
+ // ADD LOG HERE: PBKDF2 iterations
84
+ const iterations = (0, constants_1.getPBKDF2Iterations)();
85
+ console.log('[ENCRYPTION_ENCRYPT] PBKDF2 iterations:', iterations);
76
86
  const salt = CryptoJS.lib.WordArray.random(SALT_LENGTH);
77
87
  const iv = CryptoJS.lib.WordArray.random(IV_LENGTH);
78
88
  const key = CryptoJS.PBKDF2(password, salt, {
@@ -85,11 +95,18 @@ class EncryptionService {
85
95
  mode: CryptoJS.mode.CBC,
86
96
  padding: CryptoJS.pad.Pkcs7,
87
97
  });
88
- return {
98
+ const result = {
89
99
  encryptedData: encrypted.toString(),
90
100
  iv: CryptoJS.enc.Base64.stringify(iv),
91
101
  salt: CryptoJS.enc.Base64.stringify(salt),
92
102
  };
103
+ // ADD LOG HERE: Output
104
+ console.log('[ENCRYPTION_ENCRYPT] Output:', {
105
+ encryptedDataLength: result.encryptedData.length,
106
+ ivLength: result.iv.length,
107
+ saltLength: result.salt.length
108
+ });
109
+ return result;
93
110
  }
94
111
  /**
95
112
  * Decrypts data that was encrypted using the encrypt method.
@@ -99,6 +116,20 @@ class EncryptionService {
99
116
  * @throws Error if decryption fails due to incorrect password or corrupted data
100
117
  */
101
118
  static async decrypt(encryptedData, password) {
119
+ // ADD LOG HERE: Input parameters
120
+ console.log('[ENCRYPTION_DECRYPT] Input:', {
121
+ encryptedData: encryptedData.encryptedData,
122
+ encryptedDataLength: encryptedData.encryptedData.length,
123
+ iv: encryptedData.iv,
124
+ ivLength: encryptedData.iv.length,
125
+ salt: encryptedData.salt,
126
+ saltLength: encryptedData.salt.length,
127
+ password: password,
128
+ passwordLength: password.length
129
+ });
130
+ // ADD LOG HERE: PBKDF2 iterations
131
+ const iterations = (0, constants_1.getPBKDF2Iterations)();
132
+ console.log('[ENCRYPTION_DECRYPT] PBKDF2 iterations:', iterations);
102
133
  const salt = CryptoJS.enc.Base64.parse(encryptedData.salt);
103
134
  const iv = CryptoJS.enc.Base64.parse(encryptedData.iv);
104
135
  const key = CryptoJS.PBKDF2(password, salt, {
@@ -112,7 +143,37 @@ class EncryptionService {
112
143
  padding: CryptoJS.pad.Pkcs7,
113
144
  });
114
145
  const decryptedText = decrypted.toString(CryptoJS.enc.Utf8);
146
+ // ADD LOG HERE: Result
147
+ console.log('[ENCRYPTION_DECRYPT] Result:', {
148
+ decryptedText: decryptedText,
149
+ decryptedTextLength: decryptedText.length,
150
+ isEmpty: !decryptedText
151
+ });
152
+ // ADD LOG HERE: Error if any
115
153
  if (!decryptedText) {
154
+ console.error('[ENCRYPTION_DECRYPT] FAILED HERE: Decryption failed - empty result');
155
+ console.error('[ENCRYPTION_DECRYPT] FAILED DATA:', {
156
+ encryptedData: encryptedData.encryptedData,
157
+ iv: encryptedData.iv,
158
+ salt: encryptedData.salt,
159
+ password: password,
160
+ pbkdf2Iterations: iterations
161
+ });
162
+ // ADD LOG HERE: Analyze encryption parameters
163
+ console.error('[ENCRYPTION_DECRYPT] ENCRYPTION ANALYSIS:', {
164
+ encryptedDataLength: encryptedData.encryptedData.length,
165
+ ivLength: encryptedData.iv.length,
166
+ saltLength: encryptedData.salt.length,
167
+ passwordLength: password.length,
168
+ encryptedDataIsBase64: /^[A-Za-z0-9+/]*={0,2}$/.test(encryptedData.encryptedData),
169
+ ivIsBase64: /^[A-Za-z0-9+/]*={0,2}$/.test(encryptedData.iv),
170
+ saltIsBase64: /^[A-Za-z0-9+/]*={0,2}$/.test(encryptedData.salt),
171
+ passwordIsString: typeof password === 'string',
172
+ expectedIvLength: 16,
173
+ expectedSaltLength: 24,
174
+ ivLengthCorrect: encryptedData.iv.length === 16,
175
+ saltLengthCorrect: encryptedData.salt.length === 24
176
+ });
116
177
  throw new Error("Decryption failed. Invalid password or corrupted data.");
117
178
  }
118
179
  return decryptedText;
@@ -101,11 +101,27 @@ class HDKeyring {
101
101
  * @returns An object containing the keyring type, mnemonic, and account addresses
102
102
  */
103
103
  serialize() {
104
- return {
104
+ // ADD LOG HERE: Before serialize
105
+ console.log('[HDKEYRING_SERIALIZE] Input:', {
106
+ mnemonic: this.mnemonic,
107
+ accounts: this.accounts,
108
+ accountsCount: this.accounts.length,
109
+ hasMnemonic: !!this.mnemonic
110
+ });
111
+ const result = {
105
112
  type: this.type,
106
113
  mnemonic: this.mnemonic,
107
114
  accounts: this.accounts
108
115
  };
116
+ // ADD LOG HERE: After serialize
117
+ console.log('[HDKEYRING_SERIALIZE] Output:', {
118
+ type: result.type,
119
+ mnemonic: result.mnemonic,
120
+ accounts: result.accounts,
121
+ hasMnemonic: !!result.mnemonic,
122
+ accountsCount: result.accounts.length
123
+ });
124
+ return result;
109
125
  }
110
126
  /**
111
127
  * Deserializes data into an HDKeyring instance.
@@ -114,7 +130,53 @@ class HDKeyring {
114
130
  * @throws Error if the data is invalid or missing required fields
115
131
  */
116
132
  static async deserialize(data) {
117
- if (data.type !== 'HD' || !data.mnemonic) {
133
+ // ADD LOG HERE: Input data
134
+ console.log('[HDKEYRING_DESERIALIZE] Input:', {
135
+ type: data.type,
136
+ mnemonic: data.mnemonic,
137
+ accounts: data.accounts,
138
+ hasMnemonic: !!data.mnemonic,
139
+ hasAccounts: !!data.accounts,
140
+ accountsCount: data.accounts ? data.accounts.length : 0
141
+ });
142
+ if (data.type !== 'HD') {
143
+ console.error('[HDKEYRING_DESERIALIZE] FAILED HERE: Wrong keyring type');
144
+ console.error('[HDKEYRING_DESERIALIZE] FAILED DATA:', {
145
+ expectedType: 'HD',
146
+ actualType: data.type,
147
+ data: data
148
+ });
149
+ // ADD LOG HERE: Analyze type mismatch
150
+ console.error('[HDKEYRING_DESERIALIZE] TYPE ANALYSIS:', {
151
+ expectedType: 'HD',
152
+ actualType: data.type,
153
+ typeIsString: typeof data.type === 'string',
154
+ typeIsNull: data.type === null,
155
+ typeIsUndefined: data.type === undefined,
156
+ typeLength: data.type ? data.type.length : 0,
157
+ availableTypes: ['HD', 'Simple', 'Solana'],
158
+ isKnownType: ['HD', 'Simple', 'Solana'].includes(data.type)
159
+ });
160
+ throw new Error('Invalid data for HDKeyring deserialization.');
161
+ }
162
+ if (!data.mnemonic) {
163
+ console.error('[HDKEYRING_DESERIALIZE] FAILED HERE: Missing mnemonic');
164
+ console.error('[HDKEYRING_DESERIALIZE] FAILED DATA:', {
165
+ data: data,
166
+ hasMnemonic: !!data.mnemonic
167
+ });
168
+ // ADD LOG HERE: Analyze mnemonic issues
169
+ console.error('[HDKEYRING_DESERIALIZE] MNEMONIC ANALYSIS:', {
170
+ hasMnemonic: !!data.mnemonic,
171
+ mnemonicType: typeof data.mnemonic,
172
+ mnemonicIsNull: data.mnemonic === null,
173
+ mnemonicIsUndefined: data.mnemonic === undefined,
174
+ mnemonicIsEmpty: data.mnemonic === '',
175
+ mnemonicLength: data.mnemonic ? data.mnemonic.length : 0,
176
+ expectedMnemonicLength: '12 words = ~132 chars, 24 words = ~264 chars',
177
+ availableFields: Object.keys(data),
178
+ missingFields: ['type', 'mnemonic', 'accounts'].filter(field => !data[field])
179
+ });
118
180
  throw new Error('Invalid data for HDKeyring deserialization.');
119
181
  }
120
182
  const keyring = new HDKeyring(data.mnemonic);
@@ -134,6 +196,12 @@ class HDKeyring {
134
196
  else {
135
197
  await keyring.initialize();
136
198
  }
199
+ // ADD LOG HERE: After deserialize
200
+ console.log('[HDKEYRING_DESERIALIZE] Output:', {
201
+ mnemonic: keyring.mnemonic,
202
+ accounts: keyring.accounts,
203
+ accountsCount: keyring.accounts.length
204
+ });
137
205
  return keyring;
138
206
  }
139
207
  /**
@@ -28,10 +28,25 @@ class SimpleKeyring {
28
28
  * @returns An object containing the keyring type and private key
29
29
  */
30
30
  serialize() {
31
- return {
31
+ // ADD LOG HERE: Before serialize
32
+ console.log('[SIMPLEKEYRING_SERIALIZE] Input:', {
33
+ privateKey: this.privateKey,
34
+ hasPrivateKey: !!this.privateKey,
35
+ privateKeyLength: this.privateKey.length,
36
+ address: this.address
37
+ });
38
+ const result = {
32
39
  type: this.type,
33
40
  privateKey: this.privateKey,
34
41
  };
42
+ // ADD LOG HERE: After serialize
43
+ console.log('[SIMPLEKEYRING_SERIALIZE] Output:', {
44
+ type: result.type,
45
+ privateKey: result.privateKey,
46
+ hasPrivateKey: !!result.privateKey,
47
+ privateKeyLength: result.privateKey.length
48
+ });
49
+ return result;
35
50
  }
36
51
  /**
37
52
  * Deserializes a plain object back into a SimpleKeyring instance.
@@ -40,10 +55,38 @@ class SimpleKeyring {
40
55
  * @throws Error if the data is invalid or missing required fields
41
56
  */
42
57
  static deserialize(data) {
43
- if (data.type !== 'Simple' || !data.privateKey) {
58
+ // ADD LOG HERE: Input data
59
+ console.log('[SIMPLEKEYRING_DESERIALIZE] Input:', {
60
+ type: data.type,
61
+ privateKey: data.privateKey,
62
+ hasPrivateKey: !!data.privateKey,
63
+ privateKeyLength: data.privateKey ? data.privateKey.length : 0
64
+ });
65
+ if (data.type !== 'Simple') {
66
+ console.error('[SIMPLEKEYRING_DESERIALIZE] FAILED HERE: Wrong keyring type');
67
+ console.error('[SIMPLEKEYRING_DESERIALIZE] FAILED DATA:', {
68
+ expectedType: 'Simple',
69
+ actualType: data.type,
70
+ data: data
71
+ });
72
+ throw new Error('Invalid data for SimpleKeyring deserialization.');
73
+ }
74
+ if (!data.privateKey) {
75
+ console.error('[SIMPLEKEYRING_DESERIALIZE] FAILED HERE: Missing private key');
76
+ console.error('[SIMPLEKEYRING_DESERIALIZE] FAILED DATA:', {
77
+ data: data,
78
+ hasPrivateKey: !!data.privateKey
79
+ });
44
80
  throw new Error('Invalid data for SimpleKeyring deserialization.');
45
81
  }
46
- return new SimpleKeyring(data.privateKey);
82
+ const keyring = new SimpleKeyring(data.privateKey);
83
+ // ADD LOG HERE: After deserialize
84
+ console.log('[SIMPLEKEYRING_DESERIALIZE] Output:', {
85
+ privateKey: keyring.getPrivateKey(),
86
+ address: keyring.address,
87
+ hasPrivateKey: !!keyring.getPrivateKey()
88
+ });
89
+ return keyring;
47
90
  }
48
91
  }
49
92
  exports.SimpleKeyring = SimpleKeyring;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pwc-sdk-wallet",
3
- "version": "0.6.9",
3
+ "version": "0.7.1",
4
4
  "description": "A comprehensive wallet SDK for React Native (pwc), supporting multi-chain and multi-account features.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",