Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
Use cloneDeep of lodash library to deep copy
Browse files Browse the repository at this point in the history
  • Loading branch information
jimni1222 committed Dec 15, 2020
1 parent cc30d35 commit 4e1d8bf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions packages/caver-klay/caver-klay-accounts/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1394,9 +1394,7 @@ Accounts.prototype.decrypt = function(v3Keystore, password, nonStrict) {
}

// To deep copy an object, using JSON.parse and JSON.stringify (object -> string -> object)
const json = _.isObject(v3Keystore)
? JSON.parse(JSON.stringify(v3Keystore))
: JSON.parse(nonStrict ? v3Keystore.toLowerCase() : v3Keystore)
const json = _.isObject(v3Keystore) ? _.cloneDeep(v3Keystore) : JSON.parse(nonStrict ? v3Keystore.toLowerCase() : v3Keystore)

if (json.version !== 3 && json.version !== 4) {
console.warn('This is not a V3 or V4 wallet.')
Expand Down
2 changes: 1 addition & 1 deletion packages/caver-wallet/src/keyring/keyringFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class KeyringFactory {
*/
static decrypt(keystore, password) {
// To deep copy an object, using JSON.parse and JSON.stringify (object -> string -> object)
const json = _.isObject(keystore) ? JSON.parse(JSON.stringify(keystore)) : JSON.parse(keystore)
const json = _.isObject(keystore) ? _.cloneDeep(keystore) : JSON.parse(keystore)

if (json.version !== 3 && json.version !== 4) console.warn('This is not a V3 or V4 wallet.')

Expand Down

0 comments on commit 4e1d8bf

Please sign in to comment.