Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove Pylon presets for Goerli chains #1704

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading