Fix mergeChainSettingsWithDefaults function

pull/5285/head
Manuel Wedler 4 months ago committed by Aniket
parent c8d45b5627
commit 2413d50499
  1. 5
      apps/contract-verification/src/app/types/defaults.ts
  2. 3
      apps/contract-verification/src/app/views/SettingsView.tsx

@ -16,16 +16,17 @@ const DEFAULTS: SettingsForVerifier = {
},
}
export function getSettingsForChain(chainId: string, userSettings: ContractVerificationSettings): ChainSettings {
export function mergeChainSettingsWithDefaults(chainId: string, userSettings: ContractVerificationSettings): ChainSettings {
const verifiers: SettingsForVerifier = {}
for (const verifierId in VERIFIERS) {
for (const verifierId of VERIFIERS) {
const userSetting: VerifierSettings = userSettings.chains[chainId]?.verifiers[verifierId]
if (userSetting) {
verifiers[verifierId] = { ...userSetting }
// Only apply default settings for Etherscan and Blockscout on mainnet
if (verifierId === 'Sourcify' || chainId === '1') {
// Add keys not defined by user
for (const key of Object.keys(DEFAULTS[verifierId])) {
if (!verifiers[verifierId][key]) {
verifiers[verifierId][key] = DEFAULTS[verifierId][key]

@ -1,7 +1,7 @@
import { useContext, useState } from 'react'
import { SearchableChainDropdown, ConfigInput } from '../components'
import type { VerifierIdentifier, Chain, VerifierSettings, ContractVerificationSettings } from '../types'
import { getSettingsForChain as mergeChainSettingsWithDefaults } from '../types'
import { mergeChainSettingsWithDefaults } from '../types'
import { AppContext } from '../AppContext'
export const SettingsView = () => {
@ -23,7 +23,6 @@ export const SettingsView = () => {
changedSettings.chains[chainId].verifiers[verifier][key] = value
setSettings(changedSettings)
console.log(changedSettings)
}
return (

Loading…
Cancel
Save