From 13a81ecd6d1bc8eea0bbe9f5132ba46dd6256e5b Mon Sep 17 00:00:00 2001 From: dahaca Date: Tue, 23 Aug 2022 16:05:01 +0200 Subject: [PATCH] fixup! feat(suite): use structuredClone for deep copying --- packages/connect/src/data/coinInfo.ts | 10 +++++----- packages/suite/src/actions/wallet/sendFormActions.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/connect/src/data/coinInfo.ts b/packages/connect/src/data/coinInfo.ts index c1a7ec1dc242..7085ab028cc7 100644 --- a/packages/connect/src/data/coinInfo.ts +++ b/packages/connect/src/data/coinInfo.ts @@ -14,7 +14,7 @@ const ethereumNetworks: EthereumNetworkInfo[] = []; const miscNetworks: MiscNetworkInfo[] = []; export const getBitcoinNetwork = (pathOrName: number[] | string) => { - const networks: BitcoinNetworkInfo[] = window.structuredClone(bitcoinNetworks); + const networks: BitcoinNetworkInfo[] = structuredClone(bitcoinNetworks); if (typeof pathOrName === 'string') { const name = pathOrName.toLowerCase(); return networks.find( @@ -29,7 +29,7 @@ export const getBitcoinNetwork = (pathOrName: number[] | string) => { }; export const getEthereumNetwork = (pathOrName: number[] | string) => { - const networks: EthereumNetworkInfo[] = window.structuredClone(ethereumNetworks); + const networks: EthereumNetworkInfo[] = structuredClone(ethereumNetworks); if (typeof pathOrName === 'string') { const name = pathOrName.toLowerCase(); return networks.find( @@ -41,7 +41,7 @@ export const getEthereumNetwork = (pathOrName: number[] | string) => { }; export const getMiscNetwork = (pathOrName: number[] | string) => { - const networks: MiscNetworkInfo[] = window.structuredClone(miscNetworks); + const networks: MiscNetworkInfo[] = structuredClone(miscNetworks); if (typeof pathOrName === 'string') { const name = pathOrName.toLowerCase(); return networks.find( @@ -84,7 +84,7 @@ export const getBech32Network = (coin: BitcoinNetworkInfo) => { // fix coinInfo network values from path (segwit/legacy) export const fixCoinInfoNetwork = (ci: BitcoinNetworkInfo, path: number[]) => { - const coinInfo: BitcoinNetworkInfo = window.structuredClone(ci); + const coinInfo: BitcoinNetworkInfo = structuredClone(ci); if (path[0] === toHardened(84)) { const bech32Network = getBech32Network(coinInfo); if (bech32Network) { @@ -120,7 +120,7 @@ const detectBtcVersion = (data: { subversion?: string }) => { // TODO: https://github.com/trezor/trezor-suite/issues/4886 export const getCoinInfoByHash = (hash: string, networkInfo: any) => { - const networks: BitcoinNetworkInfo[] = window.structuredClone(bitcoinNetworks); + const networks: BitcoinNetworkInfo[] = structuredClone(bitcoinNetworks); const result = networks.find( info => hash.toLowerCase() === info.hashGenesisBlock.toLowerCase(), ); diff --git a/packages/suite/src/actions/wallet/sendFormActions.ts b/packages/suite/src/actions/wallet/sendFormActions.ts index d52e1d416980..6eb248208ccd 100644 --- a/packages/suite/src/actions/wallet/sendFormActions.ts +++ b/packages/suite/src/actions/wallet/sendFormActions.ts @@ -133,7 +133,7 @@ export const convertDrafts = () => (dispatch: Dispatch, getState: GetState) => { const conversionToUse = areSatsSelected && areSatsSupported ? amountToSatoshi : formatAmount; - const updatedDraft: FormState = window.structuredClone(draft); + const updatedDraft: FormState = structuredClone(draft); const decimals = getAccountDecimals(relatedAccount.symbol)!; updatedDraft.outputs.forEach(output => {