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

update Polygon block explorer URL #572

Merged
merged 2 commits into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
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
16 changes: 14 additions & 2 deletions main/store/migrations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const migrations = {
type: 'ethereum',
symbol: 'MATIC',
name: 'Polygon',
explorer: 'https://explorer.matic.network',
explorer: 'https://polygonscan.com',
mholtzman marked this conversation as resolved.
Show resolved Hide resolved
gas: {
price: {
selected: 'standard',
Expand Down Expand Up @@ -202,7 +202,6 @@ const migrations = {
return initial
},
10: initial => { // Add Optimism to persisted networks
// if (!initial.main.networks.ethereum[10]) {
initial.main.networks.ethereum[10] = {
id: 10,
type: 'ethereum',
Expand Down Expand Up @@ -338,6 +337,19 @@ const migrations = {
}
}

return initial
},
15: initial => {
// Polygon
if (initial.main.networks.ethereum['137']) {
const oldExplorer = initial.main.networks.ethereum['137'].explorer

if (!oldExplorer || oldExplorer.endsWith('explorer.matic.network')) {
// only replace if it hasn't been changed from the initial setting
initial.main.networks.ethereum['137'].explorer = 'https://polygonscan.com'
}
}

return initial
}
}
Expand Down
2 changes: 1 addition & 1 deletion main/store/state/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ const initial = {
layer: 'sidechain',
symbol: 'MATIC',
name: 'Polygon',
explorer: 'https://explorer.matic.network',
explorer: 'https://polygonscan.com',
gas: {
price: {
selected: 'standard',
Expand Down
60 changes: 60 additions & 0 deletions test/main/store/migrations/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,63 @@ describe('migration 14', () => {
expect(arbitrum.gas.fees.maxFeePerGas).toBe('0xf')
})
})

describe('migration 15', () => {
beforeEach(() => {
state = {
main: {
_version: 14,
networks: {
ethereum: {
137: {
id: 1,
type: 'ethereum',
layer: 'sidechain',
symbol: 'MATIC',
name: 'Polygon',
explorer: 'https://explorer.matic.network',
connection: {
primary: {
on: true,
current: 'matic'
},
secondary: {
on: false,
current: 'local'
}
}
}
}
},
networksMeta: {
ethereum: { }
}
}
}
})

it('updates the initial explorer for Polygon', () => {
const updatedState = migrations.apply(state)
const polygon = updatedState.main.networks.ethereum['137']

expect(polygon.explorer).toBe('https://polygonscan.com')
})

it('adds the Polygon explorer if one does not exist', () => {
delete state.main.networks.ethereum['137'].explorer

const updatedState = migrations.apply(state)
const polygon = updatedState.main.networks.ethereum['137']

expect(polygon.explorer).toBe('https://polygonscan.com')
})

it('does not update the Polygon explorer if it has been manually changed', () => {
state.main.networks.ethereum['137'].explorer = 'https://custom-explorer.io'

const updatedState = migrations.apply(state)
const polygon = updatedState.main.networks.ethereum['137']

expect(polygon.explorer).toBe('https://custom-explorer.io')
})
})