diff --git a/packages/helpers/utils/package.json b/packages/helpers/utils/package.json index d34ff3dea..ae50bd2db 100644 --- a/packages/helpers/utils/package.json +++ b/packages/helpers/utils/package.json @@ -63,6 +63,7 @@ "webpack-cli": "3.3.10" }, "dependencies": { + "@exodus/walletconnect-crypto": "^1.0.1-exodus.0", "@exodus/walletconnect-encoding": "^1.0.0-exodus.0", "@exodus/walletconnect-jsonrpc-utils": "^1.0.0-exodus.0", "@exodus/walletconnect-types": "^1.7.0-exodus.0", diff --git a/packages/helpers/utils/src/misc.ts b/packages/helpers/utils/src/misc.ts index 0e27c9b5b..545b8e783 100644 --- a/packages/helpers/utils/src/misc.ts +++ b/packages/helpers/utils/src/misc.ts @@ -1,5 +1,6 @@ import * as encoding from "@exodus/walletconnect-encoding"; import * as jsonRpcUtils from "@exodus/walletconnect-jsonrpc-utils"; +import * as crypto from "@exodus/walletconnect-crypto"; // -- hex -------------------------------------------------- // @@ -24,15 +25,10 @@ export function removeHexLeadingZeros(hex: string): string { export const payloadId = jsonRpcUtils.payloadId; export function uuid(): string { - const result: string = ((a?: any, b?: any) => { - for ( - b = a = ""; - a++ < 36; - b += (a * 51) & 52 ? (a ^ 15 ? 8 ^ (Math.random() * (a ^ 20 ? 16 : 4)) : 4).toString(16) : "-" - ) { - // empty - } - return b; - })(); - return result; + const bytes = crypto.randomBytes(36) + const chars: Array = [] + for (let a = 1; a <= 36; a++) { + chars.push((a * 51) & 52 ? (a ^ 15 ? 8 ^ (bytes[a - 1] % (a ^ 20 ? 16 : 4)) : 4).toString(16) : "-") + } + return chars.join(''); }