From f0c79a414b9cd5225e52af3bd18ba9a8539c4229 Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Wed, 29 May 2024 17:21:05 +0800 Subject: [PATCH] fix: structuredClone not available in v16 --- packages/accounts-controller/src/utils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/accounts-controller/src/utils.ts b/packages/accounts-controller/src/utils.ts index cbcd3b36ca..458523c1f5 100644 --- a/packages/accounts-controller/src/utils.ts +++ b/packages/accounts-controller/src/utils.ts @@ -1,5 +1,6 @@ import { toBuffer } from '@ethereumjs/util'; import { isCustodyKeyring, KeyringTypes } from '@metamask/keyring-controller'; +import { deepClone } from '@metamask/snaps-utils'; import { sha256 } from 'ethereum-cryptography/sha256'; import type { Draft } from 'immer'; import type { V4Options } from 'uuid'; @@ -96,5 +97,5 @@ export function deepCloneDraft( obj: Draft, ): AccountsControllerState { // We use unknown here because the type inference when using structured clone leads to the same type error. - return structuredClone(obj) as unknown as AccountsControllerState; + return deepClone(obj) as unknown as AccountsControllerState; }