Skip to content

Commit

Permalink
bug: sloppy clone wrecks Uint8Array (#419)
Browse files Browse the repository at this point in the history
In CLI I was seeing a mess come through that used to be Uint8 but had
been flattened by a sloppy clone.
Lets use a legit clone!
  • Loading branch information
frankiebee authored Oct 2, 2024
2 parents c8bc2ab + e40435d commit d80f73a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@
"@entropyxyz/entropy-protocol-nodejs": "^0.2.0",
"@entropyxyz/entropy-protocol-web": "^0.2.0",
"@polkadot/api": "^10.13.1",
"@types/lodash.clonedeep": "^4.5.9",
"@types/node": "^20.12.12",
"debug": "^4.3.4",
"hpke-js": "^1.2.7",
"lodash.clonedeep": "^4.5.0",
"uuid": "^9.0.1",
"xtend": "^4.0.2"
},
Expand Down
4 changes: 2 additions & 2 deletions src/keys/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import EventEmitter from 'node:events'
import { deepCopy } from '../utils/housekeeping'
import { default as cloneDeep } from 'lodash.clonedeep'
import * as utils from './utils'
import { EntropyAccount, KeyMaterial, PairMaterial } from './types/json'
import {
Expand Down Expand Up @@ -185,7 +185,7 @@ export default class Keyring {
const entropyAccount: EntropyAccount = { debug, seed, type, verifyingKeys }
this.#used.forEach((accountName) => {
if (this.accounts[accountName] === undefined) return
entropyAccount[accountName] = deepCopy(this.accounts[accountName] as PairMaterial)
entropyAccount[accountName] = cloneDeep(this.accounts[accountName] as PairMaterial)
})
entropyAccount.admin = entropyAccount.registration
return entropyAccount
Expand Down
13 changes: 0 additions & 13 deletions src/utils/housekeeping/index.ts

This file was deleted.

17 changes: 17 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,18 @@
resolved "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz"
integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==

"@types/lodash.clonedeep@^4.5.9":
version "4.5.9"
resolved "https://registry.yarnpkg.com/@types/lodash.clonedeep/-/lodash.clonedeep-4.5.9.tgz#ea48276c7cc18d080e00bb56cf965bcceb3f0fc1"
integrity sha512-19429mWC+FyaAhOLzsS8kZUsI+/GmBAQ0HFiCPsKGU+7pBXOQWhyrY6xNNDwUSX8SMZMJvuFVMF9O5dQOlQK9Q==
dependencies:
"@types/lodash" "*"

"@types/lodash@*":
version "4.17.9"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.17.9.tgz#0dc4902c229f6b8e2ac5456522104d7b1a230290"
integrity sha512-w9iWudx1XWOHW5lQRS9iKpK/XuRhnN+0T7HvdCCd802FYkT1AMTnxndJHGrNJwRoRHkslGr4S29tjm1cT7x/7w==

"@types/minimatch@^3.0.3":
version "3.0.5"
resolved "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.5.tgz"
Expand Down Expand Up @@ -3331,6 +3343,11 @@ locate-path@^6.0.0:
dependencies:
p-locate "^5.0.0"

lodash.clonedeep@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
integrity sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==

lodash.flattendeep@^4.4.0:
version "4.4.0"
resolved "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz"
Expand Down

0 comments on commit d80f73a

Please sign in to comment.