From 3b5d4c774af417d65d404018189b845e337aa8bb Mon Sep 17 00:00:00 2001 From: Matt Holtzman Date: Tue, 14 Sep 2021 08:00:44 -0400 Subject: [PATCH 1/2] update Polygon block explorer URL --- main/store/migrations/index.js | 2 +- main/store/state/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main/store/migrations/index.js b/main/store/migrations/index.js index 8c0b470c9..511c5a1a3 100644 --- a/main/store/migrations/index.js +++ b/main/store/migrations/index.js @@ -83,7 +83,7 @@ const migrations = { type: 'ethereum', symbol: 'MATIC', name: 'Polygon', - explorer: 'https://explorer.matic.network', + explorer: 'https://polygonscan.com', gas: { price: { selected: 'standard', diff --git a/main/store/state/index.js b/main/store/state/index.js index da0af6de5..f5713718e 100644 --- a/main/store/state/index.js +++ b/main/store/state/index.js @@ -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', From 64d02b150176c0082d146d442f7895d4eb15b94f Mon Sep 17 00:00:00 2001 From: Matt Holtzman Date: Wed, 6 Oct 2021 14:48:09 -0400 Subject: [PATCH 2/2] add migration --- main/store/migrations/index.js | 14 +++++- test/main/store/migrations/index.test.js | 60 ++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/main/store/migrations/index.js b/main/store/migrations/index.js index 511c5a1a3..3d90c37f2 100644 --- a/main/store/migrations/index.js +++ b/main/store/migrations/index.js @@ -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', @@ -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 } } diff --git a/test/main/store/migrations/index.test.js b/test/main/store/migrations/index.test.js index 736df08a4..2928b12d4 100644 --- a/test/main/store/migrations/index.test.js +++ b/test/main/store/migrations/index.test.js @@ -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') + }) +})