Skip to content

Commit

Permalink
remove Pylon presets for Goerli chains (#1704)
Browse files Browse the repository at this point in the history
  • Loading branch information
mholtzman authored Mar 8, 2024
1 parent 5afcfbe commit cb8a8f3
Showing 1 changed file with 60 additions and 1 deletion.
61 changes: 60 additions & 1 deletion main/store/migrate/migrations/41/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import log from 'electron-log'

import { v38StateSchema } from '../38/schema'
import { v38Connection, v38StateSchema } from '../38/schema'

function baseSepolia() {
const chain = {
Expand Down Expand Up @@ -128,6 +128,37 @@ function optimismSepolia() {
return { chain, metadata }
}

function removeGoerliPylonPreset(connection: v38Connection) {
// remove Goerli Pylon preset
const isPylon = connection.current === 'pylon'

if (isPylon) {
log.info('Migration 41: removing Pylon presets from Goerli')
}

return {
...connection,
current: isPylon ? 'custom' : connection.current,
custom: isPylon ? 'wss://evm.pylon.link/goerli' : connection.custom
}
}

function removeBaseGoerliConnection(connection: v38Connection) {
// remove Base Goerli Pylon preset
const isPylon = connection.current === 'pylon'

if (isPylon) {
log.info('Migration 41: removing Pylon presets from Base Goerli')
}

return {
...connection,
on: isPylon ? false : connection.on,
current: isPylon ? 'custom' : connection.current,
custom: isPylon ? '' : connection.custom
}
}

const migrate = (initial: unknown) => {
try {
const state = v38StateSchema.parse(initial)
Expand All @@ -147,6 +178,34 @@ const migrate = (initial: unknown) => {
state.main.networksMeta.ethereum[11155420] = metadata
}

const goerliChainPresent = '5' in state.main.networks.ethereum

if (goerliChainPresent) {
const goerliChain = state.main.networks.ethereum[5]

state.main.networks.ethereum[5] = {
...goerliChain,
connection: {
primary: removeGoerliPylonPreset(goerliChain.connection.primary),
secondary: removeGoerliPylonPreset(goerliChain.connection.secondary)
}
}
}

const baseGoerliChainPresent = '84531' in state.main.networks.ethereum

if (baseGoerliChainPresent) {
const baseGoerliChain = state.main.networks.ethereum[84531]

state.main.networks.ethereum[84531] = {
...baseGoerliChain,
connection: {
primary: removeBaseGoerliConnection(baseGoerliChain.connection.primary),
secondary: removeBaseGoerliConnection(baseGoerliChain.connection.secondary)
}
}
}

return state
} catch (e) {
log.error('Migration 41: could not parse state', e)
Expand Down

0 comments on commit cb8a8f3

Please sign in to comment.