Skip to content

Commit

Permalink
fixup! feat(suite): use structuredClone for deep copying
Browse files Browse the repository at this point in the history
  • Loading branch information
dahaca committed Aug 23, 2022
1 parent 3a2563a commit 13a81ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions packages/connect/src/data/coinInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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(),
);
Expand Down
2 changes: 1 addition & 1 deletion packages/suite/src/actions/wallet/sendFormActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit 13a81ec

Please sign in to comment.